akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
#define pii pair<lli,lli>
#define vi vector <lli>
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y);
lli modInverse(lli b, lli m)
{
    lli x, y;
    lli g = gcdExtended(b, m, &x, &y);
    if (g != 1)
        return -1;
    return (x%m + m) % m;
}
lli modDivide(lli a, lli b, lli m)
{
    a = a % m;
    lli inv = modInverse(b, m);
    return (inv * a) % m;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }
    lli x1, y1;
    lli gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli h,w,k;
    cin>>h>>w>>k;
    char mat[h][w];
    lli bl=0;
    rep(i,h){
    	rep(j,w){
    	cin>>mat[i][j];
    	if(mat[i][j]=='#')
    	bl++;
    	}
	}
	lli ans=0;
	for(lli i=0;i<(1<<h);i++){
		for(lli j=0;j<(1<<w);j++){
			lli cnt=0;
			rep(p,h){
				rep(q,w){
					if(mat[p][q]=='#' && ((i&(1<<p))==(1<<p) || (j&(1<<q))==(1<<q)))
					cnt++;
				}
			}
			if((bl-cnt)==k)
			ans++;
		}
	}
	cout<<ans;
    return 0;
}


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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int m1 = min(a, b);
    int m2 = a + b - n;
    if (m2 < 0) {
        m2 = 0;
    }
    cout << m1 << " " << m2;
    return 0;
}

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

using namespace std;

int A[12345];
int main()
{	
	int n;
	cin>>n;
	
	for(int i=0;i<n;i++)
		cin>>A[i];
		
	int mn = *min_element(A,A+n);
	int mx = *max_element(A,A+n);
		
	cout<<mx-mn<<"\n";
	
	// your code goes here
	return 0;
}

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

int gcd(int ,int);

int main(){
  int x,y,z,key;
  scanf("%d %d",&x,&y);
  if((1 > x && x > 10e9) && (1 > y && y > 10e9)) exit(2);
  printf("%d\n",gcd(x,y));
  return 0;
}
  int gcd(x,y){
    int n,i;

    if(x < y){
      i = x;
      x = y;
      y = i;
    }
    while(y > 0){
      n = x % y;
      x = y;
      y = n;
    }
    return x;
  }



Measured memory_bytes: 2036
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    count=[[0]*10 for _ in range(10)]
    for i in range(1,n+1):
        s=str(i)
        count[int(s[0])][int(s[-1])]+=1

    ans=0
    for i in range(10):
        for j in range(10):
            ans+=count[i][j]*count[j][i]
    print(ans)


resolve()

Measured memory_bytes: 40428
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    
    int tot=0;
    rep(i,n) tot = tot ^ a.at(i);
    if(tot == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdint.h>

#define BUF (305)
#define INF (1000000003)

int N;
uint64_t A[BUF][BUF];

void input(void){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			scanf("%llu",&A[i][j]);
		}
	}
}

uint64_t dp[BUF][BUF];
void wf_init(void){
	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= N; j++)
		{
			dp[i][j] = A[i][j];
		}
	}
}

void wf_init_(void){
	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= N; j++)
		{
			dp[i][j] = A[i][j];
		}
	}
}

int min(int a, int b){
	if(a>b) return b;
	return a;
}

void solv_wf(void)
{
	wf_init();

	for (int k = 1; k <= N ; k++)
	{
		for (int i = 1; i <= N; i++)
		{
			for (int j = 1; j <= N; j++)
			{
				dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j] );
			}
		}
	}
}

// 
int comp(void)
{
	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= N; j++)
		{
			if(dp[i][j]!=A[i][j]) return -1;
		}
	}
	return 0;
}

uint64_t count = 0;
void solv_wf_(void)
{
	wf_init_();
	for (int i = 1; i <= N; i++)
	{
		for (int j = i+1; j <= N; j++)
		{	
			int flag = 0;
			for(int k=1;k<=N;k++){
				if(i==k || j==k){

				}
				else if (dp[i][k] + dp[k][j] == dp[i][j]){
					flag = 1;
					//printf("%d %d\n",i,j);
				}
			}
			if(!flag)
			{
				count += dp[i][j];
				//printf("%d\n",count);
			}
		}
	}
}

typedef struct {
	int from;
	int to;
	int cost;
}SIDE;

SIDE sides[BUF*BUF];

void mat2sides(void){
	int cnt = 0;
	for (int i = 1; i <= N; i++)
	{
		for (int j = i; j <= N; j++)
		{
			sides[cnt].from = i;
			sides[cnt].to = j;
			sides[cnt].cost = A[i][j];	
			cnt++;
		}
	}	
}

int mincost[BUF];
int used[BUF];
uint64_t total = 0;
void plim(void){
	for(int i=0;i<=N;i++){
		mincost[i] =INF;
		used[i] = false;
	}
	mincost[1]=0;

	while (1)
	{
		int	v=-1;
		for (int u = 1; u <= N; u++)
		{
			if(!used[u] && (v==-1||mincost[v]>mincost[u])){
				v = u;
			}
		}
		if(v==-1) break;

//		printf("%d,%d \n",v,total);
		used[v] = true;
		total += mincost[v];

		for (int i = 1; i <= N; i++)
		{
			mincost[i] = min(mincost[i], A[v][i]);
//			printf("mini %d",mincost[i]);
		}
	}
}

int main(void)
{
	input();
	solv_wf();
	int ret = comp();

	//No road composition.
	if(ret == -1){
		printf("%d\n",ret);
		return 0;
	}

	solv_wf_();
	//mat2sides();
	/*
	for (int i = 1; i <= N; i++)
	{
		for (int j = i+1; j <= N; j++)
		{
			int temp = A[i][j];
			A[i][j] = INF;
			solv_wf();
			if(dp[i][j]>temp) total+=temp;
			A[i][j] = temp;
		}
	}	
	*/
	printf("%llu\n",count);
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int h,w;
    while(cin>>h>>w, h+w){
        vvc v(h,vc(w));
        rep(i,h)rep(j,w)cin>>v[i][j];
        pii now=pii(0,0);
        int cnt=0; bool flag=true;
        for(;cnt<=10000000;cnt++){
            if(v[now.first][now.second]=='>')now=pii(now.first,now.second+1);
            else if(v[now.first][now.second]=='<')now=pii(now.first,now.second-1);
            else if(v[now.first][now.second]=='^')now=pii(now.first-1,now.second);
            else if(v[now.first][now.second]=='v')now=pii(now.first+1,now.second);
            else break;
            if(cnt==10000000) {flag=false; puts("LOOP");}
        }
        if(flag)cout<<now.second<<" "<<now.first<<endl;
    }
}

Measured memory_bytes: 3084
import bisect
A, B, Q = map(int, input().split())
s = list(int(input()) for _ in range(A))
t = list(int(input()) for _ in range(B))

for i in range(Q):
    ans = 10 ** 19
    x = int(input())
    stmp1 = bisect.bisect_left(s, x)
    for j in range(2):
        if stmp1 == 0 and j == 1:
            continue
        if stmp1 == A and j == 0:
            continue
        ttmp1 = bisect.bisect_left(t, s[stmp1 - j])
        ktmp = 10 ** 11
        if ttmp1 != 0:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1 - 1]))
        if ttmp1 != B:
            ktmp = min(ktmp, abs(s[stmp1 - j] - t[ttmp1]))
        total = abs(x - s[stmp1 - j]) + ktmp
        ans = min(ans, total)

    ttmp1 = bisect.bisect_left(t, x)
    for j in range(2):
        if ttmp1 == 0 and j == 1:
            continue
        if ttmp1 == B and j == 0:
            continue
        stmp1 = bisect.bisect_left(s, t[ttmp1 - j])
        ktmp = 10 ** 11
        if stmp1 != 0:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1 - 1]))
        if stmp1 != A:
            ktmp = min(ktmp, abs(t[ttmp1 - j] - s[stmp1]))
        total = abs(x - t[ttmp1 - j]) + ktmp
        ans = min(ans, total)
    print(ans)

Measured memory_bytes: 90440
#include <iostream>
#include <cfloat>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
 
using namespace std;
 
#define fi first
#define se second
typedef pair<double,double> P;
 
#define MAX (21)
#define INF (DBL_MAX/4)
 
double G[MAX][MAX];
 
int n;
vector<P> crys;
P h, d;
 
double dist(P p1, P p2){
  return sqrt(pow(p1.fi-p2.fi, 2.) + pow(p1.se-p2.se, 2.));
}
 
void makeEdge() {
  for(int i=0; i<n; i++) {
    G[i][i] = 0;
    for(int j=i+1; j<n; j++) {
      G[i][j] = G[j][i] = dist(crys[i], crys[j]);
    }
  }
}
 
//map<ull, double> dp;
unordered_map<int, double> dp;

bool dfs(int S, int idx, double cost) {
  
  if(S==(1<<n)-1) {
    return true;
  }
  
  dp[S] = cost;
  
  for(int i=0; i<n; i++) {
    if((S>>i)&1) continue;
    if(cost + G[idx][i] >= dist(crys[i], d)) return false;
  }
  
  for(int i=0; i<n; i++){
    if((S>>i)&1) continue;
    double ncost = cost + G[idx][i];
    double nS = S|(1<<i);
    if(ncost >= dist(crys[i], d)) return false;
    else {
      if(dp.count(nS) && dp[nS] < ncost) continue;
      if(dfs(nS, i, ncost)) return true;
    }
  }
  
  return false;
}
 
bool solve() {
   
  makeEdge();
  
  dp.clear();
  for(int i=0; i<n; i++) {
    if(dist(h, crys[i]) >= dist(crys[i], d)) continue;
    if(dfs(1<<i, i, dist(h, crys[i]))) {
      return true;
    }
  }
  return false;
}
 
int main(){
  while(true){
    crys.clear();
    cin >> n >> h.fi >> h.se >> d.fi >> d.se;
    if(!n && !h.fi && !h.se && !d.fi && !d.se){
      break;
    }
    crys.resize(n);
    for(int i=0; i<n; i++){
      cin >> crys[i].fi >> crys[i].se;
    }
    cout << (solve() ? "YES" : "NO") << endl;
  }
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i=0;i<n;++i)
	{
		cin >> a[i];
	}

	int64_t money=1000;
	int64_t stock=0;

	int i;
	for (i=0;i<n-1;++i)
	{
		if (a[i]<a[i+1])
		{
			int64_t u=money/a[i];
			stock+=u;
			money-=u*a[i];
		}
		if (a[i]>a[i+1])
		{
			money+=stock*a[i];
			stock=0;
		}
	}
	money+=stock*a[i];
	stock=0;

	cout << money << endl;
}








Measured memory_bytes: 3576
n = int(input())
ab = []
for i in range(n):
    ab.append(list(map(int,input().split())))
ab.sort(key=lambda x:x[1])
s = 0
k = "Yes"
for i in range(n):
    s += ab[i][0]
#    print(s,ab[i][1])
    if ab[i][1] < s:
         k = "No"
         break
print(k)


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

int main() {
    while(1) {
        int n;
        cin >> n;
        if(n == 0) {
            return 0;
        }
        vector<int> a(n);
        double ave = 0;
        for(int i = 0; i < n; i++) {
            cin >> a[i];
            ave += a[i];
        }
        ave /= (double)n;
        int ans = 0;
        for(int i = 0; i < n; i++) {
            if(ave >= a[i]) {
                ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_set>
using namespace std;

int main(){
    unordered_set<string> org;
    string train;
    int N;
    cin >> N;
    for(int k = 0; k < N; k++){
        cin >> train;
        int n = train.length();
        org = {};
        string first, second, first_reverse, second_reverse;
        for(int i = 1; i < n; ++i){
            first = train.substr(0, i);
            second = train.substr(i, n-i);
            first_reverse = first;
            reverse(first_reverse.begin(), first_reverse.end());
            second_reverse = second;
            reverse(second_reverse.begin(), second_reverse.end());
            org.insert(first + second);
            org.insert(first + second_reverse);
            org.insert(first_reverse + second);
            org.insert(first_reverse + second_reverse);
            org.insert(second + first);
            org.insert(second + first_reverse);
            org.insert(second_reverse + first);
            org.insert(second_reverse + first_reverse);
        }
        cout << org.size() << endl;
    }
}

Measured memory_bytes: 3152
import sys
s = list(input())
for i in range(len(s)):
  if i%2: #偶数番目
    #print(s[i],i)
    if s[i] == 'R':
      print('No')
      sys.exit()
  if not i%2: #奇数番目
    #print(s[i],i)
    if s[i] == 'L':
      print('No')
      sys.exit()
print('Yes')

Measured memory_bytes: 38384
import Control.Monad
import Control.Monad.ST
import qualified Data.Array as A
import qualified Data.Array.ST as ST
import qualified Data.Array.Unboxed as AU
import Data.Bits
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Int
import qualified Data.IntMap as IM
import Data.List
import qualified Data.Map as M
import Data.Maybe
import Data.Ord
import qualified Data.Set as S
import Data.Time
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [n, x] <- readInt
  xs <- readInt
  print $ solve x xs

solve x xs = ans
  where
    distances = map (\x' -> abs (x' - x)) xs
    ans = foldl1 gcd distances

Measured memory_bytes: 2940
import java.util.*;

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) || (b == c && a != c) || (c == a && a != b)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include <stdio.h>
int main() {
	int n, i, temp, ans;
	int data[5000];
	while (1) {
		scanf(" %d", &n);
		if (n == 0)
			break;
		temp = -100000;
		for (i = 0; i < n; i++) {
			scanf(" %d", &data[i]);
			if (data[i] > temp)
				temp = data[i];
		}
		if (temp <= 0) {
			printf("%d\n", temp);
			continue;
		}
		temp = ans = 0;
		for (i = 0; i < n; i++) {
			temp = (data[i] + temp > 0) ? data[i] + temp : 0;
			ans = (temp > ans) ? temp : ans;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 620
import functools
import math

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


if inp() in [7, 5, 3]:
    print('YES')
else:
    print("NO")


Measured memory_bytes: 3572
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    
    let t = get();
    if t.len() < 26 {
    	let mut ch = b'.';
    	for c in b'a'..b'z' {
        	if t.contains(c as char) {
            	continue;
            }
        	ch = c;
            break;
        }
        let mut t = t.to_string();
        t.push(ch as char);
        print!("{}", t.to_string());
        return;
    }
    let s = t.as_bytes();
    let mut x = 100;
    for i in 0..25 {
    	let i = 25 - i;
        let j = i - 1;
        if s[j] < s[i] {
        	x = j;
            break;
        }
    }
    if x == 100 {
    	println!("-1");
        return;
    }
    let mut e = vec![];
    for i in 0..x {
    	e.push(s[i]);
    }
    let c = s[x];
    let mut r = b'z';
    for i in x+1..26 {
    	if s[i] < c {
        	continue;
        }
        if s[i] > r {
        	continue;
        }
        r = s[i];
    }
    e.push(r);
    let e = String::from_utf8(e).unwrap();
    println!("{}", e);
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>

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

using namespace std;

int N,M;
vector<vector<int> > G(10);
vector<int> seen(10,0);
int ans = 0;

void dfs(int n, int cnt){
  if(cnt == (N-1)){
    ans++;
    return;
  }
  for(auto &i:G[n]){
    if(seen[i]) continue;
    seen[i] = 1;
    dfs(i,cnt+1);
    seen[i] = 0;
  }
}

int main(){
  cin >> N >> M;
  rep(i,M){
    int a,b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  seen[0] = 1;
  dfs(0,0);
  
  cout << ans << endl;
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ab = br.readLine().split(" ");
		int a = Integer.parseInt(ab[0]);
		int b = Integer.parseInt(ab[1]);

		if (a + b == 15) {
			System.out.println("+");
		} else if (a * b == 15) {
			System.out.println("*");
		} else {
			System.out.println("x");
		}
	}

}


Measured memory_bytes: 22996
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int total;

        Scanner inp = new Scanner(System.in);
        total = inp.nextInt();

        int[] a = new int[total];

        for (int k = 0; k < total; k++) {
            a[k] = inp.nextInt();
        }

        countingSort(a, new int[total], 2000000);
    }

    public static void countingSort(int[] a, int[] b, int k) {
        int[] c = new int[k];

        for (int j = 0; j < a.length; j++) {
            c[a[j]]++;
        }

        for (int i = 1; i < k; i++) {
            c[i] += c[i - 1];
        }

        for (int j = a.length-1; j >= 0; j--) {
            b[c[a[j]]-1] = a[j];
            c[a[j]]--;
        }

        StringBuilder s = new StringBuilder();
        int place = 0;
        for(int item : b) {
            if (place != 0) {
                s.append(" ");

            }

            s.append(item+"");
            place++;
        }

        System.out.print(s + "\n");

    }
}


Measured memory_bytes: 607248
import sys
from collections import Counter

n, *a = map(int, sys.stdin.read().split())

def main():
    cb = Counter(a[i] + i for i in range(n))
    cc = Counter(j - a[j] for j in range(n))
    tot = 0
    for v, c in cb.items():
        tot += c * cc[v]
    print(tot)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 59324
/*
ID: leezhen
TASK: practice
LANG: C++11
*/
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef unsigned long long ull;
#define mp make_pair
#define pb push_back
#define inf 1e9
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

// struct

// data
int x, y;
const int mod = 1e9 + 7;
int an[2000010];

int my_pow(int base, int e) {
  if (e == 1) return base % mod;
  if (e % 2 == 1) {
    return (1LL * base * my_pow(base, e - 1)) % mod;
  } else {
    return my_pow((1LL * base * base) % mod, e / 2);
  }
}

void solve() {
  int t = 2 * x - y;
  if (t < 0 || t % 3 != 0) {
    printf("0\n");
    return;
  }
  int b = t / 3;
  int a = x - 2 * b;
  if (a < 0) {
    printf("0\n");
    return;
  }
  an[0] = 1;
  REP(i, 1, a + b + 1) { an[i] = (1LL * i * an[i - 1]) % mod; }
  int ans =
      (1LL * an[a + b] * (my_pow((1LL * an[a] * an[b]) % mod, mod - 2))) % mod;
  printf("%d\n", ans);
}

int main() {
  int k, kase = 0;
  // scanf("%d", &k);
  k = 1;
  while (k--) {
    scanf("%d%d", &x, &y);
    solve();
  }

  return 0;
}


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

int main(){
	string s;
	cin >> s;
	for(int i=0; i<s.size(); i++){
		if(s[i]-3<'A'){
			s[i]=s[i]+('Z'-'A')-2;
		}else{
			s[i]-=3;
		}
	}
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int a[255];
int main()
{
    char s[105];
    a['A']=1;
    a['T']=1;
    a['C']=1;
    a['G']=1;
    scanf("%s",s);
    int ans=0;
    for(int i=0; s[i]; i++)
    {

        if(a[s[i]]==1)
        {
            int j=i;
            for(; s[j]; j++)
            {
                if(a[s[j]]!=1)
                    break;
            }
            ans=max(ans,j-i);
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

struct WaitedUnionFind{
    vector<int> par, rank, dw;

    WaitedUnionFind( int N ){
        par.resize( N ), rank.resize( N ), dw.resize( N );
        REP( i, N ) par[i] = i, rank[i] = dw[i] = 0;
    }

    int root( int x ){
        if( par[x] == x ){
            return x;
        }else{
            int r = root( par[x] );
            dw[x] += dw[par[x]];
            return par[x] = r;
        }
    }

    bool same( int x, int y ){
        return root( x ) == root( y );
    }

    int weight( int x ){
        root( x );
        return dw[x];
    }

    void unite( int x, int y, int w ){
        w += weight( x ), w -= weight( y );
        x = root( x ), y = root( y );
        if( x == y ) return;
        if( rank[x] < rank[y] ) swap( x, y ), w = -w;
        if( rank[x] == rank[y] ) rank[x]++;
        par[y] = x;
        dw[y] = w;
    }

    int diff( int x, int y ){
        return weight( y ) - weight( x );
    }
};

signed main(){
    bool ok = true;

    int N, M; cin >> N >> M;

    WaitedUnionFind uf( N );

    REP( i, M ){
        int l, r, d; cin >> l >> r >> d;
        l--, r--;
        if( uf.same( l, r ) ){
            int curdiff = uf.diff( l, r );
            if( d != curdiff ) ok = false;
        }else{
            uf.unite( l, r, d );
        }
    }

    if( ok ) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

int main()
{
    string s, t;
    cin >> s >> t;

    int max = 0;
    for (int i = 0; i <= s.length() - t.length(); i++) {
        int bufmax = 0;
        int buf = 0;
        for (int j = 0; j < t.length(); j++) {
            if (s[i + j] == t[j]) {
                buf++;
                if (bufmax < buf) {
                    bufmax = buf;
                }
            }
        }

        if (max < bufmax) {
            max = bufmax;
        }
    }

    cout << t.length() - max;
}

Measured memory_bytes: 3164
#include "bits/stdc++.h"
using namespace std;
#include "atcoder/all"
using namespace atcoder;
#define int long long
#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 FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

signed main(){
	int N, M;
	cin >> N >> M;
	vector<string>grid(N);
	cin >> grid;

	auto itop = [&](int n) {
		return make_pair(n / M, n % M);
	};
	auto ptoi = [&](int i, int j) {
		return i * M + j;
	};

	mf_graph<int> g(N * M + 2);
	int s = N * M;
	int t = N * M + 1;

	// s -> even / odd -> t
	REP(i, N) {
		REP(j, M) {
			if(grid[i][j] == '#') continue;
			int x = ptoi(i, j);
			if((i + j) % 2 == 1) {
				g.add_edge(x, t, 1);
			} else {
				g.add_edge(s, x, 1);
			}
		}
	}

	vector<pair<int,int>>dir = {{1,0},{0,1},{-1,0},{0,-1}};
	// even -> odd
	REP(i, N) {
		REP(j, M) {
			if((i + j) % 2 == 1 || grid[i][j] == '#') continue;
			for(auto[x, y]: dir) {
				int ni = i + x;
				int nj = j + y;
				if(!IN(0, ni, N) || !IN(0, nj, M)) continue;
				if(grid[ni][nj] == '#') continue;
				g.add_edge(ptoi(i, j), ptoi(ni, nj), 1);
			}
		}
	}

	out(g.flow(s, t));
	auto edges = g.edges();
	for(auto e: edges) {
		if(e.from == s || e.to == t || e.flow == 0) continue;
		auto[ui, uj] = itop(e.from);
		auto[vi, vj] = itop(e.to);
		if(ui == vi + 1) {
			grid[vi][vj] = 'v';
			grid[ui][uj] = '^';
		} else if(uj == vj + 1) {
			grid[vi][vj] = '>'; grid[ui][uj] = '<';
		} else if(ui + 1 == vi) {
			grid[ui][uj] = 'v';
			grid[vi][vj] = '^';
		} else {
			grid[ui][uj] = '>'; grid[vi][vj] = '<';
		}
	}
	REP(i, N) out(grid[i]);
}

Measured memory_bytes: 6248
n, p = map(int, input().split())

a = list(map(int, input().split()))

#print(a)

for i in a:
    if i % 2 == 1:
        print(2 ** (n - 1))
        exit(0)

if p == 0:
    print(2 ** n)

else:
    print(0)


Measured memory_bytes: 2940
n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]
cd = [tuple(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1], reverse=True)
cd.sort(key=lambda x: x[0])
ans = 0

for i in cd:
    j = 0
    for j in range(len(ab)):
        if ab[j][0] < i[0] and ab[j][1] < i[1]:
            ab.pop(j)
            ans += 1
            break
print(ans)

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char a;
    cin >> a;
    if (a >= 'A' && a <= 'Z')
        cout << "A";
    else
        cout << "a";
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(void){
    ll a,b;
    cin >> a >> b;
    cout << lcm(a,b);
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int t,j=0,ans=0;
  for(int i=0; i<n; i++) {
    cin >> t;
    if(j <= t) {
      j = t;
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll K;

ll dfs(int j, vector<ll> a){

  ll n = a.size();
  if(n < K){
    return 0;
  }

  vector<ll> a0, a1;

  rep(i, n){
    if(a[i] & (1LL<<j)){
      a1.push_back(a[i]);
    }else{
      a0.push_back(a[i]);
    }
  }

  if(j == 0){
    if(a1.size() >= K){
      return 1;
    }else{
      return 0;
    }
  }else{

    if(a1.size() >= K){
      ll ans;
      ll ret_a1 = dfs(j-1, a1);
      ans = (1LL << j);
      ans += ret_a1;
      return ans;
    }else{
      return dfs(j-1, a);
    }
  }
}

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

  int N;
  cin >> N >> K;

  vector<ll> a(N);
  rep(i, N) cin >> a[i];

  vector<ll> asum;

  for(int i = 0; i < N; i++){
    
    ll sum = a[i];
    asum.push_back(sum);
    for(int j = i+1; j < N; j++){
      sum += a[j];
      asum.push_back(sum);
    }
  }


  cout << dfs(60, asum) << endl;

  return 0;
}


Measured memory_bytes: 209388
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
      ll h,w,k;
      cin>>h>>w;
      string A[h];
      ll B[h][w]={0};
      
          for(ll j=0;j<h;j++)
          {
              cin>>A[j];
              //cout<<A[j];
          }
          //cout<<endl;
      
      for(ll i=0;i<h;i++)
      {
          for(ll j=0;j<w;j++)
          {
              if(A[i][j]!='#')
              {
                  k=0;
                if(i!=0 && A[i-1][j]=='#' )
                {
                    k++;
                }
                if(i!=h-1 && A[i+1][j]=='#')
                {
                    k++;
                }
                if(j!=0 && A[i][j-1]=='#' )
                {
                    k++;
                }
                if(j!=w-1 && A[i][j+1]=='#')
                {
                    k++;
                }
                if((i!=0 && j!=0) && A[i-1][j-1]=='#')
                {
                    k++;
                }
                if((i!=0 && j!=w-1) && A[i-1][j+1]=='#' )
                {
                    k++;
                }
                if((i!=h-1 && j!=0) && A[i+1][j-1]=='#')
                {
                    k++;
                }
                if((i!=h-1 && j!=w-1) && A[i+1][j+1]=='#')
                {
                    k++;
                }
                B[i][j]=k;
                //cout<<k<<" ";
              }
          }
      }
      for(ll i=0;i<h;i++)
      {
          for(ll j=0;j<w;j++)
          {
            if(A[i][j]=='#')
              cout<<'#';
            else
              cout<<B[i][j];
          }
          cout<<endl;
      }
      
    } 
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b) a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b) a=b;}

struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} IoSetup;

int main() {
  int n, cnt = 0; cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i <= n-3; ++i) {
    if (s[i]=='A' && s[i+1] == 'B' && s[i+2] == 'C') ++cnt;
  }
  cout <<  cnt << '\n';
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <cassert>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
//typedef pair<int, int> pii;
using pll = pair<ll, ll>;
using pii = pair<short, short>;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<(a);i++)
#define rep1(i,a) for(int i=1;i<=(a);i++)
#pragma warning(disable:4996)
//#define INF 1000000000000000.0
int main() {
	int n;
	while (cin >> n, n) {
		vector<char> op{ '+' };
		vector<int> num{ 0 };
		int nest = 0;
		rep(i, n) {
			string buf;
			cin >> buf;
			int next=count(ALL(buf), '.');
			while (nest > next) {
				if(op[nest-1]=='+')num[nest-1] += num[nest];
				else num[nest - 1] *= num[nest];
				nest--;
				num.pop_back();
				op.pop_back();
			}
			if (buf[next] == '+') {
				op.push_back('+');
				num.push_back(0);
			}
			else if (buf[next] == '*') {
				op.push_back('*');
				num.push_back(1);
			}
			else if (op[next] == '+')num[next] += buf[next] - '0';
			else num[next] *= buf[next] - '0';
			nest = next;
		}
		while (nest > 0) {
			if (op[nest - 1] == '+')num[nest - 1] += num[nest];
			else num[nest - 1] *= num[nest];
			nest--;
			num.pop_back();
		}
		cout << num[0] << endl;
	}
}

Measured memory_bytes: 3156
/*input
2 1 3 0
AB
AC
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	ll n,a[3],k;
	cin>>n>>a[0]>>a[1]>>a[2];
	string s[n];
	rep(i,0,n){cin>>s[i];}
	vll v;
	rep(i,0,n){
		if(a[s[i][0]-'A']==0&&a[s[i][1]-'A']==0){
			cout<<"No\n";
			return 0;
		}
		if(a[s[i][0]-'A']==0){
			a[s[i][0]-'A']++,a[s[i][1]-'A']--;
			v.pb(s[i][0]-'A');
		}else if(a[s[i][1]-'A']==0){
			a[s[i][0]-'A']--,a[s[i][1]-'A']++;
			v.pb(s[i][1]-'A');
		}else if(a[s[i][0]-'A']>1){
			a[s[i][0]-'A']--,a[s[i][1]-'A']++;
			v.pb(s[i][1]-'A');
		}else if(a[s[i][1]-'A']>1){
			a[s[i][0]-'A']++,a[s[i][1]-'A']--;
			v.pb(s[i][0]-'A');
		}else{
			if(i==n-1){
				v.pb(s[i][0]-'A');
			}else{
				if(s[i+1][0]==s[i][1]){
					a[s[i][0]-'A']--,a[s[i][1]-'A']++;
					v.pb(s[i][1]-'A');
				}else if(s[i+1][0]==s[i][0]){
					a[s[i][0]-'A']++,a[s[i][1]-'A']--;
					v.pb(s[i][0]-'A');
				}else if(s[i+1][1]==s[i][1]){
					a[s[i][0]-'A']--,a[s[i][1]-'A']++;
					v.pb(s[i][1]-'A');
				}else{
					a[s[i][0]-'A']++,a[s[i][1]-'A']--;
					v.pb(s[i][0]-'A');
				}
			}
		}
	}
	cout<<"Yes\n";
	rep(i,0,n)cout<<(char)(v[i]+'A')<<endl;
	return 0;
}




Measured memory_bytes: 7416
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];

    ll ans = 0;

    rep(i,n){
        if(i %2 == 0 && a[i] % 2 == 1) ans++;
    }

    cout << ans << endl;


}

Measured memory_bytes: 3624
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
LL a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	LL lsum = 0;
	LL rsum = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		a[i] -= i;
		rsum += a[i];
	}
	sort(a + 1, a + n + 1);
	LL ans = INF * INF;
	for (int i = 1; i <= n; i++)
	{
		rsum -= a[i];
		ans = min(ans, rsum - (n - i) * a[i] + (i - 1) * a[i] - lsum);
		lsum += a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int N, M;
vector<int> X;

void input(void){
    cin >> N >> M;
    X.resize(N);
    for (auto& xi : X)
        cin >> xi;
}

map<int, map<int, int>> mod_M_cnt;
map<int, int> cnt;

void build(void){
    for (auto xi : X)
        ++mod_M_cnt[xi % M][xi], ++cnt[xi % M];
}

int main(void){
    input();
    build();
    int res = 0;
    res += cnt[0] / 2;
    if (M % 2 == 0)
        res += cnt[M / 2] / 2;
    for (int i = 1; i <= M / 2; ++i){
        if (i == M - i) continue;
        res += min(cnt[i], cnt[M - i]);
        if (cnt[i] < cnt[M - i]){
            swap(cnt[i], cnt[M - i]);
            swap(mod_M_cnt[i], mod_M_cnt[M - i]);
        }    
        int tmp = 0;
        for (auto e : mod_M_cnt[i])
            tmp += e.second / 2;
        res += min((cnt[i] - cnt[M - i]) / 2, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 19328
/******* all required header files *******/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;

/*****All definitions*******/
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define mp make_pair
#define ll long long int
#define pb push_back
#define F first
#define S second
/***************************/

int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	ios_base::sync_with_stdio(0);
	cin.tie(0);

    ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i = 0; i < n; i++)
    {
        cin>>v[i];
    }
    sort(v.begin(), v.end());
    cout<<v[v.size()/2] - v[v.size()/2 - 1];
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N, K;
    cin >> N >> K;
    ll x[N];
    ll ans = 5e15;
    for(ll i = 0; i < N; i++) cin >> x[i];
    for(ll i = 0; i <= N - K; i++){
        ll left = x[i], right = x[i + K - 1];
        ll tmp = 0;
        if(left < 0) tmp += -left;
        if(0 < right) tmp += right;
        if(left < 0 && 0 <  right) tmp += min(-left, right);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.util.stream.*;
import java.util.function.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(x + y / 2);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);}
  int b=0;
  for(int i=0;i<N-1;i++){
    if(a.at(i)==a.at(i+1)){
      b++;
      i++;
    }
  }
  cout << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

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

int main()
{
  int a, L;
  while(cin >> a >> L, (a|L)) {
    map<int, int> m;
    int idx = 0;
    for(;;) {
    string str = to_string(a);
    if( m.find(a) != m.end() ) {
      int v = m[a];
      cout << v << " " << a << " " << (idx - v) << endl;
      break;
    }
    m[a] = idx++;

    while(str.size() < (unsigned long)L) {
      str.append("0");
    }

    string left( str ); sort(left.begin(), left.end(), greater<char>());
    string right( str ); sort(right.begin(), right.end());

    a = stoi(left) - stoi(right);
    }
  }

  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl a(n);
	cin>>a;
	vl l(n),r(n);
	rep(i,n){
		l[i]=i>0?gcd(l[i-1],a[i]):a[i];
	}
	rrep(i,n){
		r[i]=i+1<n?gcd(r[i+1],a[i]):a[i];
	}
	ll ans=1;
	rep(i,n){
		if(i==0)chmax(ans,r[1]);
		else if(i+1==n)chmax(ans,l[n-2]);
		else chmax(ans,gcd(l[i-1],r[i+1]));
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n)  FOR(i,0,n)

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
//-------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//typedef
//-------------------------------------------
typedef long long ll;
int p[1001];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        double min = 1 << 21;
        int mini = 0;

        int n;
        cin >> n;
        if (!n) return 0;

        int h, w;
        REP(i, n) {
            cin >> p[i] >> h >> w;
            double hd = ((double) h ) / 100;
            double bmi = (double)w / (hd * hd);
            if (min > fabs(bmi - 22.0)) {
                min = fabs(bmi - 22.0);
                mini = i;
            } else if (min == fabs(bmi - 22.0)) {
                if (mini > i) {
                    mini = i;
                }
            }
        }
        cout << p[mini] << endl;
    }
    return 0;
}

Measured memory_bytes: 3108