akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

vector<tuple<ll, ll, ll>> P;

int main() {

    ll n;
    cin >> n;
    
    ll X[1005], Y[1005], H[1005];
    tuple<ll, ll, ll> T = make_tuple(-1, -1, -1);
    for(ll i = 1; i <= n; i++) {
        cin >> X[i] >> Y[i] >> H[i];
        if (H[i] >= 1) T = make_tuple(X[i], Y[i], H[i]);
    }

    ll ph;
    for(ll i = 0; i <= 100; i++) {
        for(ll j = 0; j <= 100; j++) {
            ph = max(0LL, abs(get<0>(T) - i) + abs(get<1>(T) - j) + get<2>(T));
            bool flag = true;
            for (ll k = 1; k <= n; k++) {
                ll phh = max(0LL, ph - abs(X[k] - i) - abs(Y[k] - j));
                if (H[k] != phh) flag = false;
            }
            if (flag) P.push_back(make_tuple(i, j, ph));
        }
    }    

    if (P.size() == 1) {
        cout << get<0>(P[0]) << " " << get<1>(P[0]) << " " << get<2>(P[0]) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = [int(input()) for i in range(n)]

ok = [[False for i in range(3)] for j in range(3)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                ok[i][j] = True

    

bingo = False

if [True, True, True] in ok:
    bingo = True
if ok[0][0] == ok[1][1] == ok[2][2] == True:
    bingo = True
if ok[0][2] == ok[1][1] == ok[2][0] == True:
    bingo = True
for i in range(3):
    if ok[0][i] == ok[1][i] == ok[2][i] == True:
        bingo = True

print('Yes' if bingo else 'No')




Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;

unsigned long long ans;
int N, K, A[100100];
int x;
int Y[1000][3];
int a;
int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

signed main()
{
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int k;
	k = K;
	while (k) {
		k /= 2;
		x++;
	}
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < N; j++) {
			//			Y[i][0] += !(A[j] & (1 << i));
			Y[i][1] += A[j] & (1LL << i);
		}
		Y[i][1] /= pow(i);
		if (Y[i][1] * 2 <= N) {
			a |= (1LL << i);
		}
		//cout << Y[i][1] << endl;
	}


	for (int i = x; i >= 0; i--) {
		if ((K & (1LL << i))) {
			if (!(a &(1LL << i))) {
				break;
			}
		}
		else {
			if ((a &(1LL << i))) {
				a &= ~(1LL << i);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		ans += a ^ A[i];
	}
	cout << ans << endl;
	//system("pause");

	return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <array>
#include <set>
#include <sstream>
#include <cmath>

using namespace std;

typedef long long LL;


vector<vector<LL>> creat_matrix(LL h, LL w) {
	LL _temp;
	vector<vector<LL>> mat;
	for (LL i = 0; i < h; ++i) {
		vector<LL> vec;
		for (LL j = 0; j < w; ++j) {
			cin >> _temp;
			vec.emplace_back(_temp);
		}
		mat.emplace_back(vec);
	}
	return mat;
}


vector<vector<LL>> inner_product(vector<vector<LL>> X, vector<vector<LL>> Y) {
	size_t n = X.size();
	size_t m = X[0].size();
	size_t l = Y[0].size();

	vector<vector<LL>> mat(n, vector<LL>(l, 0));
	for (LL i = 0; i < n; ++i) {
		for (LL j = 0; j < m; ++j) {
			for (LL k = 0; k < l; ++k) {
				mat[i][k] += X[i][j] * Y[j][k];
			}
		}
	}
	return mat;
}


void show_matrix(vector<vector<LL>> mat) {
	size_t len = mat[0].size();
	for (auto&& t : mat) {
		for (LL i = 0; i < len; ++i) {
			printf("%d", t[i]);
			if (i != (len - 1)) printf(" ");
		}
		printf("\n");
	}
}


vector<string> split(const string& s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;

	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}

	return elems;
}

//
//int main() {
//	int cnt = 0;
//	string w, s; 
//	cin >> w;
//	while (cin >> s, s != "END_OF_TEXT") {
//		string s1, w1;
//		for (int i = 0; i < s.size(); ++i) s1 += tolower(s[i]);
//		for (int i = 0; i < w.size(); ++i) w1 += tolower(w[i]);
//		if (s1 == w1)++cnt;
//	}
//	cout << cnt << endl;
//}


int main() {
	string str, cards;
	auto m = 0;
	vector<string> ans;

	while (cin >> str, str != "-") {
		try{
			m = stoi(str);
		}
		catch (const std::exception&){
			cards = str;
			m = 0;
		}

		if (m > 0) {
			auto shuf = 0;
			auto len = cards.size();
			for (int i = 0; i < m; ++i) {
				cin >> shuf;
				auto _cards = cards;
				reverse(_cards.begin(), _cards.end());
				auto bottom = _cards.substr(len - shuf);
				reverse(bottom.begin(), bottom.end());
				cards.erase(cards.begin(), cards.begin() + shuf);
				cards += bottom;
			}
			ans.emplace_back(cards);
		}
	}

	for (auto&& a : ans) printf("%s\n", a.c_str());
	return 0;
}



Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector< vector<int> > T(n);
    for (int i = 0; i < n - 1; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    ll odp = k;
    stack<int> S;
    vector<bool> odw(n, false);
    S.push(0);
    odw[0] = true;
    while (!S.empty())
    {
        int akt = S.top();
        S.pop();
        ll c = 0;
        for (int i = 0; i < T[akt].size(); ++i)
        {
            if (!odw[T[akt][i]])
            {
                odw[T[akt][i]] = true;
                S.push(T[akt][i]);
                ll mn = k - c - 1;
                if (akt != 0)
                    --mn;
                if (mn <= 0)
                    odp = 0;
                else
                    odp = (odp * mn) % MOD;
                ++c;
            }
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 6520
A,B,C,D,E,F = gets.split.map(&:to_i)

itika = []
nino = []
miku = []
yotuha = []
ituki = []



for a in 0..F / (100 * A)
    for b in 0..(F - (100 * A * a) ) / (100 * B)
        for c in 0..(F - (100 * A * a + 100 * B * b)) / C 
            for d in 0..(F - (100 * A * a + 100 * B * b + C * c)) / D 

                itika.push(a)
                nino.push(b)
                miku.push(c)
                yotuha.push(d)
                
                if C * c + D * d <= E * (A * a + B * b) && (a != 0 || b != 0 || c != 0 || d != 0)

                    ituki.push((C * c + D * d).to_f / (100 * A * a + 100 * B * b + C * c + D * d))

                else

                    ituki.push(0)

                end
            end
        end
    end
end

x = ituki.index(ituki.max)

if ituki.max > 0
puts "#{100 * A * itika[x] + 100 * B * nino[x] + C * miku[x] + D * yotuha[x]} #{C * miku[x] + D * yotuha[x]}"
else 
    puts "#{100 * [A,B].min} #{0}"
end


Measured memory_bytes: 76080
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define INFll (1LL << 60)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int r; cin >> r;
    cout << r*r << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<random>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<unordered_map>
#include<time.h>
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
#define int long long
using namespace std;
typedef long long ll;
typedef long double ld;
using namespace std;
vector<int>e[200001];
int a[200001];
int inf = 9999999999;
signed main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	for (int i = 1; i <= n; i++)
		a[i] = inf;
	queue<int>q;
	q.push(1);
	a[1] = 0;
	while (!q.empty()) {
		int t = q.front(); q.pop();
		if (a[t] + 1 > 2) continue;
		for (int i = 0; i < e[t].size(); i++) {
			if (a[e[t][i]] > a[t] + 1) {
				a[e[t][i]] = a[t] + 1;
				q.push(e[t][i]);
			}
		}
	}
	if (a[n] <= 2)
		cout << "POSSIBLE\n";
	else
		cout << "IMPOSSIBLE\n";
	getchar(); getchar();
}

Measured memory_bytes: 15080
n=int(input())
l=[0]*n
for i in range(1,n+1):
    b=2
    while b<=i:
        while i%b==0:
            i//=b
            l[b-1]+=1
        b+=1
#print(l)
x=1
for i in l:
    if i!=0:
        x=x*(i+1)%(10**9+7)
print(x)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define ll long long int

void Swap(int x[], int i, int j)
{
  int temp;

  temp = x[i];
  x[i] = x[j];
  x[j] = temp;
}

/* クイックソートを行う */
void QS(int x[], int left, int right)
{
  int i, j;
  int pivot;

  i = left;  /* ソートする配列の一番小さい要素の添字 */
  j = right; /* ソートする配列の一番大きい要素の添字 */

  pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

  while (1)
  { /* 無限ループ */

    while (x[i] < pivot) /* pivot より大きい値が */
      i++;               /* 出るまで i を増加させる */

    while (pivot < x[j]) /* pivot より小さい値が */
      j--;               /*  出るまで j を減少させる */
    if (i >= j)          /* i >= j なら */
      break;             /* 無限ループから抜ける */

    Swap(x, i, j); /* x[i] と x[j]を交換 */
    i++;           /* 次のデータ */
    j--;
  }

  if (left < i - 1)      /* 基準値の左に 2 以上要素があれば */
    QS(x, left, i - 1);  /* 左の配列を Q ソートする */
  if (j + 1 < right)     /* 基準値の右に 2 以上要素があれば */
    QS(x, j + 1, right); /* 右の配列を Q ソートする */
}

int main(void)
{
  int n, h, h2, m;
  ll s = 0;
  ll s2 = 0;
  ll s3 = 0;
  int i = 0;
  int a[100];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
  {
    scanf("%d", &m);
    a[i] = m;
    s3 += m;
  }
  QS(a, 0, n - 1);
  h = s3 / n;
  h2 = h + 1;
  //printf("%d %d\n", h, h2);
  for (i = 0; i < n; i++)
  {
    s += (a[i] - h) * (a[i] - h);
    s2 += (a[i] - h2) * (a[i] - h2);
  }
  if (s < s2)
    printf("%lld\n", s);
  else
    printf("%lld\n", s2);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int w, h;
int main() {
	string s;
	int a, b, c, d;
	vector<string> ss;
	while (cin >> s && s != "#") {
		cin >> a >> b >> c >> d; a--; b--; c--; d--;
		ss.clear();
		int lastpos = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == '/') {
				ss.push_back(s.substr(lastpos, i-lastpos));
				lastpos = i+1;
			}
		}
		ss.push_back(s.substr(lastpos, s.size()-lastpos));
		h = ss.size();
		auto bs = vector<vector<bool>>(h);
		for (int i = 0; i < h; i++) {
			auto t = vector<bool>();
			for (int j = 0; j < ss[i].size(); j++) {
				if (ss[i][j] == 'b') t.push_back(true);
				else for (int k = 0; k < ss[i][j]-'0'; k++) t.push_back(false);
			}
			bs[i] = t;
		}
		w = bs[0].size();
		bs[a][b] = false;
		bs[c][d] = true;
		string out = "";
		for (int i = 0; i < h; i++) {
			int count = 0;
			for (int j = 0; j < w; j++) {
				if (bs[i][j]) {
					if (count != 0) {
						out += (count + '0');
						count = 0;
					}
					out += 'b';
				}
				else count++;
			}
			if (count != 0) out += (count + '0');
			if (i != h - 1) out += '/';
		}
		cout << out << endl;
	}
}

Measured memory_bytes: 3232
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#include<math.h>
#define Max 1000
#define INF 1000000000000000000
using namespace std;


int main(){

	string a,b;
	cin >> a >> b;
	cout << b+a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define F first
#define S second
 
#define ler freopen("inspection.in","r",stdin);freopen("inspection.out","w",stdout)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define rep(i,a,b) for(int i=a; i<b; i++)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define sz(a) ((int)(a).size())
#define debug cout<<"ACM ICPC\n"
 
#define pdd pair<ld,ld> 
#define ll long long
#define ld long double
#define vi vector<int> 
#define pii pair<int,int>  
 
#define MAXN 100005
#define LOG 21
#define EPS 1e-8
#define INF 1e12L

ll n, v[MAXN];

int main(){
	cin >> n;
	rep(i,0,n)
		cin >> v[i];
	sort(v,v+n);
	
	ll a=0, b=0;
	rep(i,0,n){
		if(i%2==0) a+= v[i];
		else b+= v[i];
	}
	cout << abs(b-a) << endl;
}







Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			
			String[] tmpArray = br.readLine().split(" ");
			int[] array = new int[n];
			for(int i = 0; i < n; i++){
				array[i] = Integer.parseInt(tmpArray[i]);
			}
			
			int i = -1;
			while(true){
				int[] result = generateAppearanceArray(array);
				i++;
				if(Arrays.equals(array, result)){
					array = result;
					break;
				}
				array = result;
			}
			
			System.out.println(i);
			for(int j = 0; j < n; j++){
				if(j != 0){
					System.out.print(" ");
				}
				System.out.print(array[j]);
				
			}
			System.out.println();
		}
	}
	
	static int[] generateAppearanceArray(int[] original){
		int[] result = new int[original.length];
		int[] count = new int[101];
		
		for(int i = 0; i < original.length ; i++){
			count[original[i]]++;
		}
		
		for(int i = 0; i < result.length ; i++){
			result[i] = count[original[i]];
		}
		
		return result;
	}

}

Measured memory_bytes: 25656
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i=0; i<(int)(n); i++)

int main() {
    int N, K;
    cin >> N >> K;

    vector<int> bars(N);
    rep(i, N){
        cin >> bars.at(i);
    }

    sort(bars.begin(), bars.end(), greater<int>());
    int ans = 0;
    rep(i, K){
        ans += bars.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>


#define MAX 100


using namespace std;


int main()
{
    vector< vector<int> > adj(MAX + 1);
    queue<int> visiting;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int id, k;
        cin >> id >> k;
        for (int j = 0; j < k; j++) {
            int tmp;
            cin >> tmp;
            adj[id].push_back(tmp);
        }
    }

    vector<int> discovered(MAX + 1, -1);
    visiting.push(1);
    discovered[1] = 0;
    while (!visiting.empty()) {
        int now = visiting.front();
        visiting.pop();

        for (vector<int>::iterator it = adj[now].begin(); it != adj[now].end(); ++it) {
            if (discovered[*it] < 0) {
                discovered[*it] = discovered[now] + 1;
                visiting.push(*it);
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << i << " " << discovered[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3160
N = int(input())
H = list(map(int,input().split()))

A = [0]*N
A[1] = abs(H[1] - H[0])

for i in range(2,N):
  on = A[i-1] + abs(H[i] - H[i-1])
  tw = A[i-2] + abs(H[i] - H[i-2])
  A[i] = min(on , tw)

print(A[N-1])


Measured memory_bytes: 13928
import java.util.*;

public class Main {
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        Integer[] l = new Integer[n];
        
        for(int i = 0; i< n; i++) l[i] = sc.nextInt();
        
        Arrays.sort(l, Comparator.reverseOrder());
        
        int res = 0;
        
        for(int i = 0; i < k; i++) res+=l[i];
        
        System.out.println(res);
    }
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {
 
    public Pair(final K key, final V value) {
        super(key, value);
    }
}
 



Measured memory_bytes: 21844
function main() {
  var
  hands, pattern,
  swap,
  i = 0, j;
  for (;;) {
    if (input[i] == 0) break;
    
    
    hands = [];
    for (j = 0; j < 5; j++) {
      hands.push(Number(input[i++]));
    }
    
    pattern = hands.reduce(function (pat, h) {
      return (pat[h] = true, pat);
    }, {});
    
    keys = Object.keys(pattern).map(Number).sort(function (x, y) { return x - y; });
    
    if (keys.length === 2) {
      if (keys[1] - keys[0] == 2) {
        swap = keys[0];
        keys[0] = keys[1];
        keys[1] = swap;
      }
      hands.forEach(function (h) {
        console.log(keys.indexOf(h) + 1);
      });
    } else {
      hands.forEach(function () {
        console.log(3);
      });
    }
  }
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 9968
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 1<<18;

pii D[MX];
int A[MX];

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 0; i < 1<<N; i++){
		scanf("%d", A+i);
		D[i] = pii(A[i], -1);
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 1<<N; j++){
			if(j&1<<i) continue;
			pii u = D[j], v = D[j|1<<i], w;
			if(u.first > v.first) w = pii(u.first, max(u.second, v.first));
			else w = pii(v.first, max(v.second, u.first));
			D[j|1<<i] = w;
		}
	}
	int ans = 0;
	for(int i = 1; i < 1<<N; i++){
		ans = max(ans, D[i].first + D[i].second);
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 6272
import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B
import           Data.Char

swap :: Char -> Char
swap c
    | isLower c = toUpper c
    | otherwise = toLower c

main :: IO ()
main = do
    xs <- B.getLine
    B.putStrLn $ B.map swap xs



Measured memory_bytes: 3432
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

struct edge {int to, cap, rev;};
vector<vector<edge>> G;
vector<bool> used;

int dfs(int v, int t, int f) {
  if(v == t) return f;
  used[v] = true;
  for(auto &e : G[v]) {
    if(!used[e.to] && e.cap > 0) {
      int d = dfs(e.to, t, min(f, e.cap));
      if(d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int main()
{
  int v, e;
  cin >> v >> e;
  G.resize(v);
  rep(i, e) {
    int v, u, c;
    cin >> v >> u >> c;
    G[v].push_back(edge{u, c, SZ(G[u])});
    G[u].push_back(edge{v, 0, SZ(G[v])-1});
  }
  int flow = 0;
  while(true) {
    used.assign(v, false);
    int f = dfs(0, v-1, INF);
    if(f == 0) break;
    flow += f;
  }
  cout << flow << endl;
}


Measured memory_bytes: 3168
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC118B
int main(void) {
  int n, m, a, i, j, k, cou=0, tmp;
  scanf(" %d %d", &n, &m);
  int s[m];
  for(i=0; i<m; i++)
    s[i]=0;

  for(i=0; i<n; i++){
    scanf(" %d", &k);
    for(j=0; j<k; j++){
      scanf(" %d", &a);
      s[a-1]++;
    }
  }
  for(i=0; i<m; i++)
    if(s[i]==n) cou++;
  printf("%d", cou);
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	
	int h[10],a=0,b=0,c=0;
	for(int i=0;i<10;i++)cin>>h[i];
	
	for(int i=0;i<10;i++){
		if(h[i]>a){c=b;b=a;a=h[i];}
		else if(h[i]>b){c=b;b=h[i];}
		else if(h[i]>c)c=h[i];
	}
	
	cout<<a<<endl<<b<<endl<<c<<endl;
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

vi solve(const vi &a, int k){
  int n = a.size();
  vector<vi> max_dp(n+1, vi(k+1,-INF)), min_dp(n+1, vi(k+1,+INF));
  max_dp[0][0] = min_dp[0][0] = 0;

  rep(i,n){
    rep(j,k+1){
      int x = (j&1) ? -1 : 1;
      if(max_dp[i][j] != -INF) {
        chmax( max_dp[i+1][j], max_dp[i][j] + a[i]*x);
        chmin( min_dp[i+1][j], max_dp[i][j] + a[i]*x);
        if(j!=k){
          chmax( max_dp[i+1][j+1], max_dp[i][j] + a[i]*x*-1);
          chmin( min_dp[i+1][j+1], max_dp[i][j] + a[i]*x*-1);
        }
      }

      if(min_dp[i][j] != +INF){
        chmax( max_dp[i+1][j], min_dp[i][j] + a[i]*x);
        chmin( min_dp[i+1][j], min_dp[i][j] + a[i]*x);
        if(j!=k){
          chmax( max_dp[i+1][j+1], min_dp[i][j] + a[i]*x*-1);
          chmin( min_dp[i+1][j+1], min_dp[i][j] + a[i]*x*-1);
        }
      }
    }
  }

  vi res(k+1,0);
  rep(i,k+1){
    int max_v = max_dp[n][i] == -INF ? 0 : abs(max_dp[n][i]);
    int min_v = min_dp[n][i] == +INF ? 0 : abs(min_dp[n][i]);
    res[i] = max( max_v, min_v );
  }
  rep(i,k) chmax(res[i+1], res[i]);
  return res;
}

int main(){
  string s; int k;
  cin >> s >> k;

  vi ud, lr;
  rep(i,s.size()){
    if(s[i] == 'U') ud.eb(-1);
    if(s[i] == 'D') ud.eb(+1);
    if(s[i] == 'L') lr.eb(-1);
    if(s[i] == 'R') lr.eb(+1);
  }

  vi ud_k = solve(ud, k), lr_k = solve(lr, k);
  int ans = 0;
  rep(i,k+1){
    chmax(ans, ud_k[i] + lr_k[k-i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 18936
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int r, c;
vector<vector<bool>> v;

int cnt(vector<vector<bool>> t)
{
	int res = 0;
	REP(j, c)
	{
		int cnt = 0;
		REP(i, r)
		{
			if (t[i][j] == 1) cnt++;
		}
		res += max(cnt, r - cnt);
	}
	return res;
}

int main()
{
	while (cin >> r >> c, r)
	{
		v.clear();
		v.resize(r,vector<bool>(c));
		REP(i, r)REP(j, c)
		{
			int a;
			cin >> a;
			v[i][j] = a;
		}
		int ans = 0;
		REP(i, 1 << r)
		{
			auto tmp = v;
			REP(j, r)
			{
				if ((i >> j)&1)
				{
					REP(k, c)
						tmp[j][k] = !tmp[j][k];
				}

			}

			ans = max(ans, cnt(tmp));
		}
		cout << ans << endl;
	}

	return 0;

}

Measured memory_bytes: 1264
np, cp, tl = map(int, input().split())
bn = [1] + [0 for i in range(np-1)]
ar = []
for i in range(np):
  ar.append(int(input())) 
ar.sort()

lim = ar[0] + tl
num = 1
gto = 1
for i in range(1, np):
  if gto == cp or lim < ar[i]:
    lim = ar[i] + tl
    gto = 1
    num += 1
    bn[i] = num
  else:
    gto += 1
    bn[i] = num

print(bn[-1])

Measured memory_bytes: 11296
#include<iostream>
using namespace std;
int main(){
  int n;
  int cnt=0;
  bool flag=false;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(a==b){
      cnt++;
    }else{
      cnt=0;
    }
    if(cnt>=3){
      flag=true;
    }
  }
  
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return(0);
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

const i64 MAXN = 300005;


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    string s;
    cin >> s;


    i64 R = 0;
    for (i64 i = 0; i < s.size() / 2; i++) {
        if (s[i] != s[s.size() - 1 - i]) {
            R += 1;
        }
    }

    cout << R << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
ans=0

for n in range(N//2+1):
    x=2*n+1
    if x>N:
         break

    num = 0
    for i in range(1,x+1):
        if x%i == 0:
            num +=1
        if num>8:
            break
    if num == 8:
        ans+=1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

struct {
    int N;
    vector<long long> dat;

    void init(int n) {
      N = 1;
      while(N < n) N *= 2;
      dat.resize(2*N-1, LLONG_MAX);
    }

    // update k-th element
    void update(int k, long long a) {
      k += N-1;
      dat[k] = a;
      while(k > 0) {
        k = (k-1)/2;
        dat[k] = min(dat[k*2+1], dat[k*2+2]);
      }
    }

    // add k-th element by a
    void add(int k, long long a) {
      k += N-1;
      dat[k] += a;
      while(k > 0) {
        k = (k-1)/2;
        dat[k] = min(dat[k*2+1], dat[k*2+2]);
      }
    }

    // return min[a, b)
    long long query(int a, int b) {
      return query(a, b, 0, 0, N);
    }
    long long query(int a, int b, int k, int l, int r) {
      if (r <= a || b <= l) return LLONG_MAX;
      if (a <= l && r <= b) return dat[k];
      int m = (l+r)/2;
      return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
} S;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  S.init(n+1);
  vector<int> b(n);
  int zero = 0;
  rep(i, n) {
    cin >> b[i];
    if (b[i]==0) zero++;
  }
  int q; cin >> q;
  vector<P> ra(q);
  rep(i, q) {
    ll l, r; cin >> l >> r;
    ra[i].first = l;
    ra[i].second = r;
  }
  sort(ra.begin(), ra.end());
  S.update(0, 0);
  int j = 0;
  for(int i=1; i<=n; i++) {
    while(j < q && ra[j].first==i) {
      int l = ra[j].first;
      int r = ra[j].second;
      auto mi = S.query(l-1, r);
      if (mi < S.query(r, r+1)) {
        S.update(r, mi);
        debug(r, mi);
      }
      j++;
    }
    auto p = (b[i-1]==0) ? -1 : 1;
    auto mi = S.query(i-1, i)+p;
    if (mi < S.query(i, i+1)) {
      S.update(i, mi);
    }
    debug(i, S.query(i, i+1));
  }

  cout << zero+S.query(n, n+1) << endl;

}

Measured memory_bytes: 8320
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    // 整数の入力
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    // 判定の出力
    if (a-b == b-c) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21972
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __
.' ____ \ [  |      (_)                [  |
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |,
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, std::string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

int m, n;
vii field, t;
int ans;

void dfs(int y, int x, int sum)
{
  t[y][x] = 0;

  REP(i, 4) {
    int ny = y + dy[i], nx = x + dx[i];
    if (!inside(ny, nx, n, m)) continue;
    if (!t[ny][nx]) continue;
    dfs(ny, nx, sum + 1);
  }
  t[y][x] = 1;
  ans = max(ans, sum);
}

signed main()
{
  while (cin >> m >> n, m || n) {
    ans = -INF;
    field = vii(n, vi(m));
    REP(i, n) REP(j, m) field[i][j] = in();
    REP(i, n) REP(j, m) {
      t = field;
      if (!t[i][j]) continue;
      dfs(i, j, 1);
    }
    print(ans);
  }

  return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,a[300009],ans=0;
  cin>>n;
  for(int i=0;i<n*3;i++)cin>>a[i];
  sort(a,a+n*3);
  reverse(a,a+n*3);
  for(int i=0;i<n*2;i+=2){
    ans+=a[i+1];
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> vec(5);
    for (int i = 0; i < 5; i++) {
        cin >> vec[i];
    }
    int k;
    cin >> k;
    int res = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            res += (abs(vec[i] - vec[j]) > k);
        }
    }
    cout << (res ? ":(" : "Yay!") << '\n';
    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m = map(int, input().split())
uf = UnionFind(n)

p_list = list(map(int, input().split()))
for i in range(m):
    x, y = map(int, input().split())
    uf.union(p_list[x - 1] - 1, p_list[y - 1] - 1)

ans = 0
for i, p in enumerate(p_list):
    if uf.same(p - 1, i):
        ans += 1
print(ans)

Measured memory_bytes: 21288
import sys
input = sys.stdin.readline
H, W, h, w = map(int, input().split())
unit = 10 ** 9 - 1
c = H * W
for i in range(h - 1, H, h):
  for j in range(w - 1, W, w): c -= 1
if c == 0:
  print("No")
  exit(0)
res = [[unit // c] * W for _ in range(H)]
for i in range(h - 1, H, h):
  for j in range(w - 1, W, w): res[i][j] = -(unit // c * (h * w - 1) + 1)
if sum([sum(r) for r in res]) > 0:
  print("Yes")
  for r in res: print(*r)
else: print("No")

Measured memory_bytes: 48476
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
 
#define N 600000
#define NIL -1
 
//array
int key[N];
int parent[N];
int leftc[N];
int rightc[N];
//root
int root=NIL;
//function insert
void insert(int z){
  int x,y;
   
  y=NIL;
  x=root;
 
  while(x!=NIL){
    y=x;
    if(key[z]<key[x]) x=leftc[x];
    else x=rightc[x];
  }  
   
  parent[z]=y;
 
  if(y==NIL) root=z;
     
  else if(key[z]<key[y]) leftc[y]=z;
 
  else rightc[y]=z;
   
   
}
 
//function search
int find(int now,int data){
  if(now==NIL||data==key[now]) return now;
  if(data<key[now]) return find(leftc[now],data);
  else return find(rightc[now],data);
}
 
//print
void inorderprint(int now){
  if(now!=NIL){
    inorderprint(leftc[now]);
    printf(" %d",key[now]);
    inorderprint(rightc[now]);
  }
}
 
void preorderprint(int now){
  if(now!=NIL){
    printf(" %d",key[now]);
    preorderprint(leftc[now]);
    preorderprint(rightc[now]);
  }
}
 
 
 
int main(){
 
  int n,i,j,data;
  int z=0;
  char str[10];
  //initialize array
  for(i=0;i<N;i++){
    parent[i]=NIL;
    key[i]=NIL;
    rightc[i]=NIL;
    leftc[i]=NIL;
  }
  //load n
  scanf("%d",&n);
  //load commnad and key
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0) {
      scanf("%d",&data);
      key[z]=data;
      insert(z);
      z++;
    }
    else if(strcmp(str,"find")==0){
      scanf("%d",&data);
      if(find(root,data)!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(str,"print")==0){
      inorderprint(root);
      cout <<endl;
      preorderprint(root);
      cout <<endl;
    }
  }
 
  return 0;
}

Measured memory_bytes: 10000
#import<iostream>
#define l long
using namespace std;l N,M,c,n=1,i,o=1e9+7;l m(l a){l g=1,h=2*o-4;while(h/=2){if(h&1)g=g*a%o;a=a*a%o;}return g;}l C(l b){l r=1,d=1;for(;b;--b)r=r*(N-1+b)%o,d=d*b%o;return r*m(d)%o;}main(){cin>>N>>M;for(i=2;i*i<=M;++i){c=0;while(!(M%i))++c,M/=i;n=n*C(c)%o;}cout<<n*(M^1?N:1)%o<<endl;}

Measured memory_bytes: 256
import java.lang.IllegalArgumentException

fun main(args: Array<String>) {
    val input = readLine() ?: throw IllegalArgumentException("not input")

    val first = input.substring(0..1).toInt()
    val second = input.substring(2..3).toInt()

    val monthRange = 1..12

    if(monthRange.contains(first) and monthRange.contains(second) ) {
        println("AMBIGUOUS")
    } else if(monthRange.contains(first)) {
        println("MMYY")
    } else if(monthRange.contains(second)) {
        println("YYMM")
    } else {
        print("NA")
    }

}

Measured memory_bytes: 31868
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	ll n,m;cin>>n>>m;
	ll ans;
	if(n>1) n-=2;
	if(m>1) m-=2;
	cout<<n*m<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> d(n);
    
    for(int i = 0;i < n;i++){
        cin >> d[i];
    }
    
    int ans = 0;
    for(int i = 0;i < n - 1;i++){
        for(int j = i + 1;j < n;j++){
            ans += d[i] * d[j];
        }
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<int> > A(505, vector<int>(505, 0));
	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		a = 500 - a;
		A[a][b]++;
	}
	for (int i = 0; i < 502; i++) {
		for (int j = 0; j < 502; j++) {
			if (j > 0)A[i][j] += A[i][j - 1];
			if (i > 0)A[i][j] += A[i - 1][j];
			if (i > 0 && j > 0)A[i][j] -= A[i - 1][j - 1];
		}
	}
	vector<int> res(Q);
	for (int i = 0; i < Q; i++) {
		cin >> a >> b;
		a = 500 - a;
		res[i] = A[a][b];
	}
	for (int i = 0; i < Q; i++) {
		cout << res[i] << endl;
	}
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
      std::cin.tie(NULL);
  string first,second;
  std::cin >>first>>second;
  for(int i=0;i<first.length();i++)
  {
      if(first[i] != second[i]){
        std::cout << "No" << '\n';
        return 0;
      }
  }
std::cout << "Yes" << '\n';
return 0;
}


Measured memory_bytes: 3648
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

void moveR(int x1, int x2) {
  for (int i = 0; i < x2 - x1; i++) {
    cout << 'R';
  }
}

void moveU(int y1, int y2) {
  for (int i = 0; i < y2 - y1; i++) {
    cout << 'U';
  }
}

void moveL(int x1, int x2) {
  for (int i = 0; i < x2 - x1; i++) {
    cout << 'L';
  }
}

void moveD(int y1, int y2) {
  for (int i = 0; i < y2 - y1; i++) {
    cout << 'D';
  }
}

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  moveR(sx, tx);
  moveU(sy, ty);
  moveL(sx, tx);
  moveD(sy, ty);
  cout << 'D';
  moveR(sx, tx + 1);
  moveU(sy, ty + 1);
  cout << 'L' << 'U';
  moveL(sx, tx + 1);
  moveD(sy, ty + 1);
  cout << 'R' << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll fibo[10];
ll dp[102][10];

ll func_fibo(ll n){
    if(n <= 0) return 1;
    else{
        return fibo[n];
    }
}
int main()
{
    cout << fixed << setprecision(15);
    ll H, W, K;
    cin >> H >> W >> K;

    fibo[1] = 2;
    fibo[2] = 3;
    for(ll i=3; i<=10; i++){
        fibo[i] = fibo[i-1] + fibo[i-2];
    }
    // cout << func_fibo(8) << endl;

    Fill(dp, 0);

    dp[0][1] = 1;
    
    for(ll i=1; i<=H; i++){
        for(ll j=1; j<=W; j++){
            dp[i][j] += (dp[i-1][j]*func_fibo(j-2)*func_fibo(W-j-1)) % MOD;
            if(j>1){
                dp[i][j] += (dp[i-1][j-1]*func_fibo(j-3)*func_fibo(W-j-1)) % MOD;
            }
            if(j< W){
                dp[i][j] += (dp[i-1][j+1]*func_fibo(j-2)*func_fibo(W-j-2)) % MOD;
            }
            dp[i][j] = dp[i][j] % MOD;
        }
    }

    cout << dp[H][K] << endl;
    return 0;
}

Measured memory_bytes: 256
/* -- 0543:Receipt --*/
#include	<iostream>

using namespace std;

int main(void) {
	int sum, buff;
	while(1) {
		cin >> sum;
		if(sum == 0) { break; }
		for(int i=0; i<9; i++) {
			cin >> buff;
			sum -= buff;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
 
#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;
 
const ll inf = 1LL << 60;
 
template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    string S;
    ll Q;
    cin >> S >> Q;
    bool flag = true;
    string a, b;
    while (Q--) {
        ll t;
        cin >> t;
        if (t == 1) {
            flag = not flag;
        } else {
            char f, c;
            cin >> f >> c;
            if (f == '1' and flag or f == '2' and not flag) {
                a.push_back(c);
            } else {
                b.push_back(c);
            }
        }
    }
 
    reverse(a.begin(), a.end());
 
    string ans = a + S + b;
 
    // cout << a << " " << S << " " << b << "\n";
    
    if (!flag) reverse(ans.begin(), ans.end());
 
    cout << ans << endl;
    
}

Measured memory_bytes: 1300
#include <iostream>
using namespace std;

int main (void){
	long long n,k;
  	cin >> n >> k;
    long long li[1000000];
  	for (int i=0;i<1000000;i++){
      li[i]=0;
    }
  	for (int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;
      li[a]+=b;
    }
  //cout << n << ","<<k<<endl;  	
  long long s =0;
  for (int i=0;i<1000000;i++){
      s+=li[i];
      if(s>=k){
        cout << i << endl;
        break;
      }
      //cout << li[i] << "," << s << endl;
    }
}




Measured memory_bytes: 8064
import java.util.*;
 
public class Main{
 public static void main(String[] args){
  
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int k = sc.nextInt();
   int[] a = new int[n];
   
   for(int i = 0;i < n;i++){
    a[i] = sc.nextInt();
   }
   
   for(int j = k;j < n;j++){
    if(a[j] > a[j-k]){
     System.out.println("Yes");
    }else{
     System.out.println("No");
    }
   }
  
 }
}

Measured memory_bytes: 60160
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int x[n],y[n],t[n];
	for(int i=0;i<n;i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	if((max(t[0],x[0]+y[0])-min(t[0],x[0]+y[0]))%2!=0 or t[0]<x[0]+y[0]){
		cout<<"No";
		return 0;
	}
	for(int i=1;i<n;i++){
		if((max(t[i]-t[i-1],max(x[i],x[i-1])-min(x[i],x[i-1])+max(y[i],y[i-1])-min(y[i],y[i-1]))-min(t[i]-t[i-1],max(x[i],x[i-1])-min(x[i],x[i-1])+max(y[i],y[i-1])-min(y[i],y[i-1])))%2!=0 or t[i]-t[i-1]<(max(x[i],x[i-1])-min(x[i],x[i-1])+max(y[i],y[i-1])-min(y[i],y[i-1]))){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll N;
map<ll, ll> dig;

int main()
{
    cin >> N;
    REP(i, N) {
        ll a;
        cin >> a;
        dig[a]++;
    }
    ll ans = 0;
    for(auto& tmp : dig) {
        ll judge = tmp.second - tmp.first;
        if(judge < 0) { ans += tmp.second; }
        else { ans += judge; }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 6272