akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace agc004_c
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			bool[,] table = new bool[x[0], x[1]];
			for (int i = 0; i < x[0]; i++)
			{
				string s = Console.ReadLine();
				for (int j = 0; j < x[1]; j++)
				{
					table[i, j] = s[j] == '#';
				}
			}
			for (int i = 0; i < x[0]; i++)
			{
				for (int j = 0; j < x[1]; j++)
				{
					if (table[i, j] || i % 2 == 0 && j != x[1] - 1 || j == 0) Console.Write("#");
					else Console.Write(".");
				}
				Console.WriteLine();
			}
			Console.WriteLine();
			for (int i = 0; i < x[0]; i++)
			{
				for (int j = 0; j < x[1]; j++)
				{
					if (table[i, j] || i % 2 == 1 && j != 0 || j == x[1] - 1) Console.Write("#");
					else Console.Write(".");
				}
				Console.WriteLine();
			}
		}
	}
}

Measured memory_bytes: 13792
#include <iostream>

using namespace std;

int main()
{
int A, B ;
cin >> A>> B;

if (A+B >=A-B &&A+B>=A*B)
    cout << A+B ;
else if (A-B>=A+B && A-B>=A*B)
    cout << A-B;
else if (A*B>=A+B &&A*B>=A-B )
    cout <<A*B ;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using Graph=vector<vector<ll>>;
const ll INF=1001001001;
ll i,j,n=2019,m,d,r,l;
int main(){
  cin>>l>>r;r=(r-l>2019?2019:r-l);l%=2019;r+=l;
  for(i=l;i<r;i++)for(j=i+1;j<=r;j++){
    n=min(n,(i*j)%2019);
  }
  cout<<n;
}

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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){


    string s;
    cin>>s;
    int fl1 = 0, fl2 = 0, fl3 = 0, fl4 = 0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='N'){
            fl1=1;
        }
        if(s[i]=='E'){
            fl2=1;
        }
        if(s[i]=='W'){
            fl3=1;
        }
        if(s[i]=='S'){
            fl4=1;
        }
    }
    if((fl1+fl4==0 || fl1+fl4==2) && (fl2+fl3==0 || fl2+fl3==2 )) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
//#pragma comment(linker,"/STACK:102400000,102400000")
//#include <initializer_list>
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define slla(n) scanf("%lld", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); repp(i,1,___T)

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int dx82[9] = { 0,-1,-1,1,1, 2,2,-2,-2 };
const int dy82[9] = { 0,2,-2,2,-2, 1,-1,1,-1 };
const int maxn = 2e6 + 50;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;

ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void extgcd(ll a,ll b,ll& d,ll& x,ll& y){ if(!b){ d=a; x=1; y=0;} else{ extgcd(b,a%b,d,y,x); y-=x*(a/b); }}
ll inverse(ll a,ll n){ ll d,x,y;extgcd(a,n,d,x,y);return d==1?(x+n)%n:-1;}

void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

int n;
char v[maxn];
int val[maxn];
int pre[maxn],suf[maxn];

void solve() {
	sa(n);
	scanf("%s",v+1);
	repp(i,1,n) {
		val[i] = (v[i] == 'W');
		pre[i] = pre[i-1] + val[i];
		//DE(pre[i])
	}
	for(int i=n;i>=1;i--) {
		suf[i] = suf[i+1] + (v[i]=='E');
		//DE(suf[i])
	}
	int ans = n;
	repp(i,1,n) {
		ans = min(ans,pre[i-1] + suf[i+1]);
	}
	cout<<ans<<endl;
}

int main()
{

    int t;
	//sa(t);
	t = 1;
	repp(i,1,t) {

		solve();	
	}
    // system("pause");
    return 0;
}

Measured memory_bytes: 11648
N, M = map(int, input().split())
S = [[int(i) for i in input().split()] for j in range(M)]
p = [int(i) for i in input().split()]
ans = 0
#print(S)
for i in range(2 ** N):
  T = [0] * N
  for j in range(N):
    if ((i >> j) & 1):
      T[j] += 1

  s = 0
  for j in range(M):
    pp = 0
    for k in range(S[j][0]):
      pp += T[S[j][k+1]-1]
    if pp % 2 == p[j]:
      s += 1
      #print(pp, p[j])
  if s == M:
    #print(T)
    ans += 1
print(ans)

Measured memory_bytes: 42352
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();

		if (a > 0 && b > 0) {
			System.out.println("Positive");
		} else if (a <= 0 && b >= 0) {
			System.out.println("Zero");
		} else {
			long def = b - a + 1;
			if (def % 2 == 0) {
				System.out.println("Positive");
			} else {
				System.out.println("Negative");
			}
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 10064
H,W=map(int, input().split())
Ch,Cw=map(int, input().split())
Dh,Dw=map(int, input().split())
A=[]
for i in range(H):
  d=list(input())
  A.append(d)
D=[[10**8]*W for i in range(H)]
DD=[[-1]*W for i in range(H)]
dy=[-1,1,0,0]
dx=[0,0,1,-1,]
ey=[2,2,2,2,2,1,1,1,1,0,0,-1,-1,-1,-1,-2,-2,-2,-2,-2]
ex=[0,1,2,-1,-2,1,2,-1,-2,2,-2,1,2,-1,-2,0,1,2,-1,-2]
for h in range(H):
  for w in range(W):
    if A[h][w]=='#':
      D[h][w]=10**5
from collections import deque
import sys
sys.setrecursionlimit(10**7) 
def bfs(y,x):
  q=deque()
  q.append((y,x))
  
  while len(q):
    y,x=q.popleft()
    cnt=0
    for i in range(4):
      ny=y+dy[i]
      nx=x+dx[i]
      if 0<=ny<H and 0<=nx<W:
        if A[ny][nx]=='.' and D[y][x]<D[ny][nx]:
          q.appendleft((ny,nx))
          D[ny][nx]=D[y][x]
          DD[ny][nx]=1

    for i in range(20):
      my=y+ey[i]
      mx=x+ex[i]
      if 0<=my<H and 0<=mx<W:
        if A[my][mx]=='.' and D[my][mx]==10**8 and DD[my][mx]==-1:
          q.append((my,mx))
          D[my][mx]=D[y][x]+1
            
D[Ch-1][Cw-1]=0
bfs(Ch-1,Cw-1)
if D[Dh-1][Dw-1]==10**8:
  print(-1)
else:
  print(D[Dh-1][Dw-1])


Measured memory_bytes: 136348
#include<iostream>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int y,x;
    while(k--){
        cin>>x>>y;
        if(y>n/2)y=(n+1)-y;
        if(x>n/2)x=(n+1)-x;
        if(x>y)x=y;
        if(x%3==0)cout<<"3"<<endl;
        else cout<<x%3<<endl;

    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p; 

int main() {
    ll N, M;
    cin >> N >> M;
    vector<p> D(N);
    for(int i=0; i<N; ++i) {
        cin >> D[i].first >> D[i].second;
    }
    sort(D.begin(), D.end());

    ll res = 0;
    for(int i=0; i<N; ++i) {
        if(M <= 0) break;
        res += D[i].first * min(D[i].second, M);
        M -= min(D[i].second, M);
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
char ToUpper (char cX) { return toupper(cX); } 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b, c;
    cin >> a >> b >> c;
    transform(a.begin(), a.end(), a.begin(), ToUpper);
    transform(b.begin(), b.end(), b.begin(), ToUpper);
    transform(c.begin(), c.end(), c.begin(), ToUpper);
    cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int change[33][33]={};
    int t[3][33]={};
    int n,c,x;
    long long int min=2500000000;
    long long int sum=0;
    scanf("%d %d\n",&n,&c);
    REP(i,c)REP(j,c)scanf("%d",&change[i][j]);
    REP(i,n)
    {
        REP(j,n)
        {
            scanf("%d",&x);
            t[(i+j)%3][x-1]++;
        }
    }
    REP(i,c)
    {
        REP(j,c)
        {
            REP(k,c)
            {
                if(i!=j && j!=k && k!=i)
                {
                    sum=0;
                    REP(l,c)sum+=change[l][i]*t[0][l];
                    REP(l,c)sum+=change[l][j]*t[1][l];
                    REP(l,c)sum+=change[l][k]*t[2][l];
                    if(min>sum)min=sum;
                }
            }
        }
    }
    printf("%lld\n",min);
    return 0;
}

Measured memory_bytes: 384
icase=0
if icase==0:
    k,s=map(int,input().split())
    icnt=0
    for x in range(k+1):
        for y in range(k+1):
            z=s-x-y
            if 0<=z and z<=k:
                icnt=icnt+1
    print(icnt)
    

Measured memory_bytes: 2940
import math
N, D =map(int, input().split())

X = [list(map(int,input().split())) for i in range(N)]

count = 0
for i in range(0,N-1):
    for j in range(i+1,N):
        dist = 0
        for d in range(D):
            dist += (X[i][d] - X[j][d])**2
        if dist**(0.5)%1 == 0:
            count += 1

print(count)
        


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N), B(N);
    REP(i,0,N) cin >> A[i] >> B[i];

    REV(A);
    REV(B);
    ll c = 0;
    REP(i,0,N) c += (B[i] - (A[i] + c) % B[i]) % B[i];
    PR(c);

    return 0;
}

/*



*/

Measured memory_bytes: 4832
num = input().split()
a = int(num[0])
b = int(num[1])
c = int(num[2])
d = int(num[3])


n_1 = a * c
n_2 = a * d
n_3 = b * c
n_4 = b * d

check = [n_1, n_2, n_3, n_4]
print(max(check))

Measured memory_bytes: 9184
N, K = map(int, input().split())  #数字
MOD = 10 ** 9 + 7

ans = 0
for i in range(K, N + 2):
    A = (i - 1) * i // 2
    B = N * (1 + N) // 2 - (N + 1 - i - 1) * (N + 1 - i) // 2
    ans += B - A + 1

print(ans % MOD)

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

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

  vector<int> L(N);
  rep(i, N) cin >> L[i];
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i] && L[i] + L[j] > L[k])
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	int ans = 0;
	for (int i = 0; i < N; i++) if (A[A[i] - 1] == i + 1) ans++;
	cout << ans / 2 << endl;
}


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

int vgcd(vector<int> v)
{
    int ans = v[0];
    for(int i = 0; i < v.size(); i++)
    {
        ans = __gcd(ans, v[i]);
    }
    return ans;
}

int main()
{
    int N;
    cin >> N;
    vector<int> v;
    for(int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        v.push_back(a);
    }

    int ans = vgcd(v);
    cout << ans;
}

Measured memory_bytes: 1144
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        List<int> list = new List<int>();
        for (int i = 1; i < n; i ++) {
            int a = i;
            int b = n-i;
            list.Add(digitSum(a)+digitSum(b));
        }
        Console.WriteLine(list.Min());
    }
    static int digitSum(int x) {
        if(x < 10) return x;
        else return digitSum(x/10) + x%10;
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main() {
   int n,k;
   cin>>n>>k;
   
   int cnt=1;
   rep(i,0,n){
       cnt=min(cnt+k,cnt*2);
   }
   cout<<cnt<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n; cin >> n;
   if (n%10==7 || (n/10)%10==7 || (n/100)%10==7)
      cout << "Yes" << endl;
   else
      cout << "No" << endl; 
}

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

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

	string s;
	cin >> s;

	if(s[1]=='B')
		cout << "ARC";
	else
		cout << "ABC";


	
	

	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,D;
int R[1001][1001];
string A="RYGB*";

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>D;
	
	if(D%2) {
		FOR(y,H) FOR(x,W) R[y][x]=(y+x)%2;
	}
	else if(D%4==2) {
		FOR(y,H) FOR(x,W) R[y][x]=(y%2*2)+(y/2+x/2)%2;
	}
	else {
		FOR(y,H) FOR(x,W) {
			int dy=y+x+1000;
			int dx=y-x+1000;
			R[y][x]=dy/D%2*2+dx/D%2;
			if((y+x)%2==1) R[y][x]^=3;
		}
		
	}
	
	
	FOR(y,H) {
		FOR(x,W) cout<<A[R[y][x]];
		cout<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>
#define N 100000
#define Q 50000
int main(){
    int S[N], T[Q], C = 0;
    int left, right, mid, key;
    int n, q, i;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &T[i]);
    }
    for(i = 0; i < q; i++){
        key = T[i];
        left = 0;
        right = n;
        while(left < right){
            mid = (left + right) / 2;
            if(S[mid] == key){
                C++;
                break; }
            else if (key < S[mid]){
                right = mid;
            }
            else left = mid + 1;
        }
    }
    printf("%d\n", C);
    return 0; }



Measured memory_bytes: 2308
#include <bits/stdc++.h>
using namespace::std;
#define int long long

#define all(x) (x).begin(), (x).end()
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)

template<class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}



void _main() {
        string a, b; cin >> a >> b;
        int cnt = 0;
        for (int i = 0; i < a.size(); i++) cnt += a[i] != b[i];
        cout << cnt;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
#define REP2(i, m, n) for (ll(i) = (ll)(n)-1; i >= (ll)(m); --i)
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<ll, ll> pll;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
const int MOD = 1000000007;
// constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> inline void print(T x) { cout << x << '\n'; }
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)
// vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(w + 1, vector<int>(k+1, 0)));
long long powmod(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b % 2 == 1) {
            res *= a;
            res %= MOD;
        }
        a *= a;
        a %= MOD;
        b /= 2;
    }
    return res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> x(n),y(n);
    rep(i,n) {
        ll a,b;
        cin >> a >> b;
        x[i] = a-b;
        y[i] = a+b;
    }

    sort(all(x));
    sort(all(y));
    print(max(x.back()-x[0],y.back()-y[0]));
    return 0;
}


Measured memory_bytes: 6376
#include<iostream>
#include<string>
using namespace std;
int main() {
    int n;
    cin >> n;
    string a;
    cin >> a;
    if (a.size() <= n) { cout << a; return 0; }
    else {
        for (int i = 0; i <n; i++)
            cout << a[i];
    }
    cout << "...";
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
char mem[214514];
char t[214514];
char c[214514];
string s[214514];
int a[214514],b[214514];
signed main(){
	ic(n)
	ic(x)
	rep(0,i,n){
		cin>>a[i];
		a[i]-=x;
	}
	if(n==1){
		c(abs(a[0]))
		return 0;
	}
	if(n==2){
		c(gcd(a[0],a[1]));
		return 0;
	}
	sort(a,a+n);
	rep(0,i,n-1)b[i]=a[i+1]-a[i];
	int ans=gcd(b[0],b[1]);
	rep(1,i,n){
		ans=gcd(b[i],ans);
	}
	c(ans)
}
		



Measured memory_bytes: 4352
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans; 
}
int seg_tree1[1000006],seg_tree2[1000006];
vector<int>v1;
void update(int start,int end,int node,int i,int x){
	if(start>i||end<i)return;
	if(start==end){
		seg_tree1[node]=max(seg_tree1[node],v1[i]+x);
		seg_tree2[node]=max(seg_tree2[node],x-v1[i]);
		return;
	}
	int mid=(start+end)/2;
	update(start,mid,2*node,i,x);
	update(mid+1,end,2*node+1,i,x);
	seg_tree1[node]=max(seg_tree1[2*node],seg_tree1[2*node+1]);
	seg_tree2[node]=max(seg_tree2[2*node],seg_tree2[2*node+1]);
}
int query_less(int start,int end,int node,int l,int r){
	if(start>r||end<l||start>end||l>r)return INT_MIN;
	if(start==l&&end==r)return seg_tree2[node];
	int mid=(start+end)/2;
	return max(query_less(start,mid,2*node,l,min(r,mid)),query_less(mid+1,end,2*node+1,max(l,mid+1),r));
}
int query_more(int start,int end,int node,int l,int r){
	if(start>r||end<l||start>end||l>r)return INT_MIN;
	if(start==l&&end==r)return seg_tree1[node];
	int mid=(start+end)/2;
	return max(query_more(start,mid,2*node,l,min(r,mid)),query_more(mid+1,end,2*node+1,max(l,mid+1),r));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	vector<pii>v;
	for(int i=0;i<1000006;i++){
		seg_tree1[i]=INT_MIN;
		seg_tree2[i]=INT_MIN;
	}
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		v.push_back({x,y});
		v1.push_back(y);
	}
	sort(v1.begin(),v1.end());
	sort(v.begin(),v.end());
	int ans=0;
	for(int i=n-1;i>=0;i--){
		int j=lower_bound(v1.begin(),v1.end(),v[i].se)-v1.begin();
		ans=max(ans,-v[i].fi+query_more(0,n-1,1,j,n-1)-v[i].se);
		ans=max(ans,-v[i].fi+query_less(0,n-1,1,0,j)+v[i].se);
		update(0,n-1,1,j,v[i].fi);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 25696
#include<cstdio>

int a[100001],ans,n;
int dispo=1;
bool c[100001];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",a+i);
    }
    for(int i=1;i<=n;i++){
        if(dispo==2){
            printf("%d",ans);
            return 0;
        }else if(*(c+dispo)&1){
            printf("-1");
            return 0;
        }
        ++*(c+dispo);
        dispo=*(a+dispo);
        ++ans;
    }
}

Measured memory_bytes: 640
/**
 * author:  virenkathiriya96
 * created: 2020.08.31 15:22:11
**/

#include<bits/stdc++.h>

using namespace std;

#define int long long

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  for (int &x: a) cin >> x;
  for (int &x: b) cin >> x;
  vector<int> suma(n, 0), sumb(m, 0);
  suma[0] = a[0], sumb[0] = b[0];
  for (int i = 1; i < n; i++) {
    suma[i] = suma[i - 1] + a[i];
  }
  for (int j = 1; j < m; j++) {
    sumb[j] = sumb[j - 1] + b[j];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int rem = k - suma[i];
    if (rem == 0) {
      ans = max(ans, i + 1);
    } else if (rem > 0) {
      ans = max(ans, i + 1);
      auto it = upper_bound(sumb.begin(), sumb.end(), rem);
      if (it != sumb.begin()) {
        it--;
        int index = it - sumb.begin();
        ans = max(i + 1 + index + 1, ans);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    int rem = k - sumb[i];
    if (rem == 0) {
      ans = max(ans, i + 1);
    } else if (rem > 0) {
      ans = max(ans, i + 1);
      auto it = upper_bound(suma.begin(), suma.end(), rem);
      if (it != suma.begin()) {
        it--;
        int index = it - suma.begin();
        ans = max(i + 1 + index + 1, ans);
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


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

using namespace std;
using ll = long long int;

//拡張ユークリッドの互除法
//ax + by = cとなるようなc=gcd(a,b)をxをペアにして返す
//firstがx,secondがc
template <typename number>
pair<number, number> extended_euclid(number a, number b)
{
    number r0, r1, a0, a1, b0, b1;
    r0 = a; r1 = b;
    a0 = 1; a1 = 0;
    b0 = 0; b1 = 1;
    while (r1>0) {
        number q1 = r0 / r1;
        number r2 = r0 % r1;
        number a2 = a0 - q1 * a1;
        number b2 = b0 - q1 * b1;
        r0 = r1 ; r1 = r2;
        a0 = a1 ; a1 = a2;
        b0 = b1 ; b1 = b2;
    }
    number c = r0;
    a = a0; //x
    b = b0; //y
    return  {a, c};
}

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n, 0);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> memo1(n, 0);
    vector<ll> memo2(n, 0);
    memo1[0] = a[0];
    memo2[n - 1] = a[n - 1];
    for(int i = 1; i < n; i++)
    {
        memo1[i] = extended_euclid(memo1[i - 1], a[i]).second;
        memo2[n - 1 - i] = extended_euclid(memo2[n - i], a[n - 1 - i]).second;
    }
    ll result = max(memo1[n - 2], memo2[1]);
    for(int i = 1; i < n - 1; i++)
    {
        ll temp = extended_euclid(memo1[i - 1], memo2[i + 1]).second;
        result = max(result , temp);
    }
    cout << result << endl;
}

Measured memory_bytes: 2560
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))


class BGridCompression {
public:
    void solve(std::istream &in, std::ostream &out) {
      int h, w;
      in >> h >> w;
      vector<string> hs(w), ws(h);
      REP(i, h) {
        string t;
        in >> t;
        REP(j, w) {
          hs[j] += t[j];
          ws[i] += t[j];
        }
      }
      vector<bool> not_show_h_index(w, false), not_show_w_index(h, false);
      REP(i, w) {
        bool f = true;
        char c = '.';
        REP(j, h) {
          f &= hs[i][j] == c;
        }
        if (f) not_show_h_index[i] = true;
      }
      REP(i, h) {
        bool f = true;
        char c = '.';
        REP(j, w) {
          f &= ws[i][j] == c;
        }
        if (f) not_show_w_index[i] = true;
      }

      REP(i, h) {
        if (!not_show_w_index[i]) {
          REP(j, w) {
            if (!not_show_h_index[j])
              out << ws[i][j];
          }
          out << endl;
        }
      }
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  BGridCompression solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 384
use std::cmp;
use std::collections::HashMap;
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 読み込んだStringを空白で分解する
    // println!("buf: {:?}", buf);
    buf = buf.replace("\n", " ");
    buf = buf.replace("\r", " ");
    let mut iter = buf.split_whitespace();

    let n: i32 = iter.next().unwrap().parse().unwrap();
    let w: i32 = iter.next().unwrap().parse().unwrap();

    let wv: Vec<(i32, i32)> = (0..n)
        .map(|_| {
            let v = iter.next().unwrap().parse().unwrap();
            let w = iter.next().unwrap().parse().unwrap();
            (w, v)
        })
        .collect();
    // println!("{:?}", wv);
    println!("{}", solve(&wv, w));
}

fn solve(wv: &Vec<(i32, i32)>, w: i32) -> i32 {
    let mut cache: HashMap<(i32, i32), i32> = HashMap::new();
    solve_iter(0, w, wv, &mut cache)
}

// i 番目移行で重さ j 以下になるような最大値
fn solve_iter(i: i32, j: i32, wv: &Vec<(i32, i32)>, cache: &mut HashMap<(i32, i32), i32>) -> i32 {
    if let Some(v) = cache.get(&(i, j)) {
        return *v;
    }
    let res: i32;
    if i as usize == wv.len() {
        res = 0;
    } else if j < wv[i as usize].0 {
        res = solve_iter(i + 1, j, wv, cache);
    } else {
        res = cmp::max(
            solve_iter(i + 1, j, wv, cache),
            solve_iter(i + 1, j - wv[i as usize].0, wv, cache) + wv[i as usize].1,
        );
    }
    cache.insert((i, j), res);
    res
}



Measured memory_bytes: 35240
#include<bits/stdc++.h>
const int N = 105;
int main()
{
	int n, a[N] = {0};
	
	scanf("%d",&n);
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d",&a[i]);
	}
	
	for(int i = n-1;i >= 0; i--)
	{
		if(i)
		{
			printf("%d ",a[i]);
		}
		else
		{
			printf("%d\n",a[i]);
		}
	} 
	return 0;
} 


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

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	vector<int> h(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	vector<int> a(m);
	vector<int> b(m);
	vector<bool> v(n);
	for(int i = 0; i < n; i++) {
		v[i] = true;
	}
	for(int i = 0; i < m; i++) {
		scanf("%d %d", &a[i], &b[i]);
		if(h[a[i] - 1] >= h[b[i] - 1]) {
			v[b[i] - 1] = false;
		}
		if(h[a[i] - 1] <= h[b[i] - 1]) {
			v[a[i] - 1] = false;
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(v[i]) {
			ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 4596
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
using namespace std;

int main() {
    ll n;
    while(scanf("%lld", &n) != EOF) {
        ll ans = (n / 11) * 2;
        n %= 11;
        if(n >= 1 && n <= 6) ans += 1;
        else if(n > 6 && n < 11) ans += 2;
        printf("%lld\n", ans);
    }
    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
  string s;
  cin >> s;
  REP(i, 3) {
    if(s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3600
#include <stdio.h>
int main(int argc, char **argv) {
  int a,b ;
  scanf("%d %d",&a,&b) ;
  if( a < b )      printf("a < b\n");
  else if( b < a ) printf("a > b\n");
  else             printf("a == b\n");
   return 0 ;
}

Measured memory_bytes: 580
loop do
  n, x = gets.chomp.split(' ').map(&:to_i)
  break if [n, x] == [0, 0]
 
  cnt = 0
  # n + n + 1 + n + 2 = x
  for i in 1 .. x / 3 - 1
    #i + n + n + 1 = x
    for j in i + 1 .. (x - i - 1) / 2
      k = x - i - j
      if j < k && k <= n
        cnt += 1
      end
    end
  end
 
  puts cnt
end

Measured memory_bytes: 8616
#include<iostream>
#include<cstring>
#include <cmath>
using namespace std;
int main(){
  int x;
  cin >> x;
  if(x==105) cout << "1\n";
  else if(x<105) cout << "0\n";
  else{
     int count1=1;
     while(x>105){
       if(x%2!=0){
       int temp=x;
       int count2=0;
        for(int i=1; i<=temp; i++){
          if(temp%i==0) count2++;
        }
        if(count2==8) count1++;
       }
        x--;
     }
     cout << count1 << "\n";
  }

}
  


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cassert>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <climits>
#include <cassert>
#include <ctime>
#include <bitset>
using namespace std;

int n, m;
string s1[111], s2[111];

int main() {
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> s1[i];
  }
  cin >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> s2[i];
  }
  int sol=0,sol1;
  for (int i = 1; i <= n; ++i) {
    sol1=0;
    for (int j = 1; j <= n; ++j) {
      if (s1[i] == s1[j]) sol1++;
    }
    for (int j = 1; j <= m; ++j) {
      if (s1[i] == s2[j]) sol1--;
    }
    sol=max(sol, sol1);
  }
  cout << sol;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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 (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int h, w, k; cin >> h >> w >> k;
    vector<string> c(h);
    rep(i,h) cin >> c[i];
    int sum = 0;
    rep(i,h) rep(j,w) {
        if(c[i][j] == '#') sum++;
    }

    int ans = 0;
    for (int bita = 0; bita < (1<<h); bita++) {
        for (int bitb = 0; bitb < (1<<w); bitb++) {
            int tmp = 0;
            rep(i,h) rep(j,w) {
                if (c[i][j] == '#' && (bita&(1<<i) || bitb&(1<<j))){
                    tmp++;
                }
            }
            if (sum-tmp == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int64_t MOD = 1000000007;

int64_t pown(int64_t x, int64_t n) { //x^n 計算量O(logn)
	int64_t ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x;
            ans %= MOD;
		}
		x = x * x;//一周する度にx, x^2, x^4, x^8となる
        x %= MOD;
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

// 負の数にも対応した % 演算
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// nCk
int64_t nCk(int64_t a, int64_t b){
  int64_t c = 1;
  for(int i=1; i<=b; i++){
    c *= a +1 - i;
    c %= MOD;
    c *= modinv(i,MOD);
    c %= MOD;
  }
  return c;
}



int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int64_t ans = pown(2,N);
  int64_t a = nCk(N,A);
  int64_t b = nCk(N,B);
  ans -= a;
  if(ans < 0){
    ans += MOD;
  }
  ans %= MOD;
  ans -= b;
  if(ans < 0){
    ans += MOD;
  }
  ans %= MOD;
  ans--;
  if(ans < 0){
    ans += MOD;
  }
  ans %= MOD; 
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(a, b):
    return 1 + 2 + 3 - a - b
    #if a + b + c <= 21: return 'win'
    #else: return 'bust'



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    S = parsed_lines[1][0]
    return n, k, S


if not do_submit:
    a, b, c = input_parse("""
    3 1
    ABC
    """)
    print(sol(a, b, c))

    a, b, c = input_parse("""
    4 3
    CABA
    """)
    print(sol(a, b, c))

else:
    #a, b, c = list(map(int, input().split()))
    # S = input().split()
    a = int(input())
    b = int(input())
    # T = input()
    print(sol(a, b))
    # S = input().strip()
    # print(sol(S))

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 300005
#define pb push_back
#define mp make_pair
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
lint A[MAX];
map<lint,lint> M;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint n,sum=0;
    cin>>n;
    lint pos=1;
    while(1){
        if(!((360*pos)%n)){
            cout<<(360*pos)/n;
            return 0;
        }
        pos++;
    }
    return 0;
}



Measured memory_bytes: 3612
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

#define N_MAX 2000100

long long fact[N_MAX];
long long rfact[N_MAX];

long long modpow(long long a, long long b){ 
  long long r = 1LL;
  while(b){
    if(b & 1LL)r *= a;
    if(r >= MOD)r %= MOD;
    a *= a;
    if(a >= MOD)a %= MOD;
    b >>= 1LL;
  }
  return r;
}

long long nCr(long long n, long long r){ 
  long long ret = 1LL;
  ret *= fact[n];
  ret %= MOD;
  ret *= rfact[r];
  ret %= MOD;
  ret *= rfact[n-r];
  ret %= MOD;
  return ret;
}

int main(){
clr(fact,0);
fact[0]=1;
rep(i,1,N_MAX){
  fact[i] = fact[i-1]*i;
  fact[i] %= MOD;
}
clr(rfact,0);
rfact[0]=1;
rep(i,1,N_MAX){
  rfact[i] = rfact[i-1]*modpow(i,MOD-2);
  rfact[i] %= MOD;
}
  ll x,y;
  cin>>x>>y;
  ll l = 0;
  ll r = 0;
  while(1){
    if(x>=y){
      x-=2;
      y--;
      l++;
    }
    else{
      x--;
      y-=2;
      r++;
    }
    if(x<=0||y<=0)break;
  }
  if(x==0&&y==0){
    ll ans = nCr(l+r,r);
    ans %= MOD;
    cout << ans << endl;
  }
  else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 31488
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int n,x;
	cin>>n;
	vi ar(n+1);
	for1(i,n){
		cin>>x;
		ar[x] = i;
		}
	for1(i,n){
		cout<<ar[i];
		if(i!=n) pf(" ");
	}
	return 0;
}

Measured memory_bytes: 1152
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 l=2*i;r,g=l+1,[i,l][l<H and A[i]<A[l]]
 if r<H and A[g]<A[r]:g=r
 if g!=i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


Measured memory_bytes: 65376
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<sqrt(n);i++)
    {
        if(n%i==0)
        {
          c++;
        }
    }
    c=c*2;
    if(pow(sqrt(n),2)==(sqrt(n)*sqrt(n)))
        c++;
    return  c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   

  string str;
  cin>>str;
  cout<<str[0]<<str.length()-2<<str[str.length()-1];



 return 0;
}








Measured memory_bytes: 3600
var lines = [];

var N, A, B, C;
var l, f
var result = Infinity;

var readline = require("readline");

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.on('line', function (x) {
  lines.push(x);
});

rl.on('close', function () {

  var tmp = lines.shift();
  N = Number(tmp.split(" ")[0]);
  A = Number(tmp.split(" ")[1]);
  B = Number(tmp.split(" ")[2]);
  C = Number(tmp.split(" ")[3]);

  l = Array(N);
  f = Array(N);
  f.fill(Infinity);

  for (var i = 0; i < N; i++) { l[i] = Number(lines[i]); }

  console.log(dfs(0, 0, 0, 0));
});



function dfs(n, a, b, c) {
  if (n === N) {
    if (a === 0 || b === 0 || c === 0) { return (Infinity); }
    else {
      return(Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C));
    }
  }
  var res_a = dfs(n + 1, a + l[n], b, c) + (a != 0 ? 10 : 0);    // l[i]をAに加える
  var res_b = dfs(n + 1, a, b + l[n], c) + (b != 0 ? 10 : 0);    // l[i]をBに加える
  var res_c = dfs(n + 1, a, b, c + l[n]) + (c != 0 ? 10 : 0);    // l[i]をCに加える
  var res_x = dfs(n + 1, a, b, c);                               // l[i]加えない

  f[n] = Math.min(res_a, res_b, res_c, res_x);
  return (f[n]);
}

Measured memory_bytes: 9724
#include <bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
ll inf = 1000000007;

vector<pair<int, int>> fs; //素因数分解の素数，指数のペア
void fuctorization(int base)
{
    //base以下のiが約数か
    for (int i = 2; i * i <= base; i++)
    {
        //iで割り切れるならで限界まで割る
        if (base % i == 0)
        {
            int cnt = 0;
            while (base % i == 0)
            {
                base /= i;
                cnt++;
            }
            fs.emplace_back(i, cnt);
        }
    }
    //baseが素数
    if (base > 1)
    {
        fs.emplace_back(base, 1);
    }
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll comb(ll n, ll k)
{
    ll c = 1;
    for (ll i = 0; i < k; i++)
    {
        c *= (n - k + i + 1);
        c /= (i + 1);
        c %= inf;
    }

    c %= inf;
    return c;
}

int main()
{
    int n, m;
    cin >> n >> m;

    COMinit();

    fuctorization(m);
    ll ans = 1;
    for (ll i = 0; i < fs.size(); i++)
    {
        ans *= COM(n + fs[i].second - 1, fs[i].second);
        ans %= inf;
    }
    ans %= inf;
    cout << ans;
}

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

int main() {
	int N, M, sum = 0;
	cin >> N;

	M = N;
	while (10 <= N){
		sum += (N % 10);
		N /= 10;
		if (10 > N)
			sum += N;
	}
	if (sum == 0)
		sum = N;
	cout << (M % sum == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import sys

S = list(input())

for i in range(0, len(S)//2, 1):
    if S[i]!=S[-(i+1)]:
        print("No")
        sys.exit()

#左半分
A = S[0:(len(S)-1)//2]
for i in range(0, len(A), 1):
    if A[i]!=A[-(i+1)]:
        print("No")
        sys.exit()

#右半分
A = S[((len(S)+3)//2)-1:]
for i in range(0, len(A), 1):
    if A[i]!=A[-(i+1)]:
        print("No")
        sys.exit()

print("Yes")

Measured memory_bytes: 3064
let N = Int(readLine()!)!
let a = readLine()!.characters.split(" ").map{Int(String($0))!}
var x = a[0]
var y = a.reduce(0){$0+$1} - a[0]
var ans = abs(x-y)
for i in 1..<N-1 {
    x += a[i]
    y -= a[i]
    ans = min(abs(x-y), ans)
}
print(ans)

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

int main( )
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (b > c) swap(c, b);
    if (a > b) swap(a, b);
    if (a + b == c) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

for i in range(n):
    s[i] = ''.join(sorted(s[i]))
d = {}
for i in range(n):
    if s[i] in d.keys():
        d[s[i]] += 1
    else:
        d[s[i]] = 1
print(sum(d[k] * (d[k] -1) // 2 for k in d))


Measured memory_bytes: 19472
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: Chars
    }
    let ans = match n[n.len() - 1] {
        '2' | '4' | '5' | '7' | '9' => "hon",
        '0' | '1' | '6' | '8' => "pon",
        '3' => "bon",
        _ => "",
    };
    println!("{}", ans);
}


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

int main(){
  int n,m,p,x[100];
  while(cin>>n>>m>>p){
    int sum=0;
    if(n==0&&m==0&&p==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin>>x[i];
      sum+=x[i];
    }
    if(x[m-1]==0){
      cout<<"0"<<endl;
    }else{
    cout<<sum*(100-p)/x[m-1]<<endl;
    }
  }


return 0;
}

Measured memory_bytes: 2996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pl;


int main(){
  int n,m;
  cin>>n>>m;

  priority_queue<int> pq;
  ll ans=0;

  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    pq.push(a);
    ans+=a;
  }

  for(int i=0;i<m;i++){
    int to=pq.top();
    ans+=(to/2-to);
    pq.pop();
    pq.push(to/2);
  }

  cout<<ans<<endl;


}


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

int main (){

    int a;
    cin >> a;

    if(65<=a && a<=90){
        cout << '1' << endl;
    }else if(97<=a && a<=122){
        cout << '2' << endl;
    }else{
        cout << '0' << endl;
    }

    return 0;

}


Measured memory_bytes: 3116
s = list(map(int,input()))

gate1 = 0

cnt1 = 0
cnt2 = 1

for i in range(len(s)):
    if i == 0:
        gate1 = s[i]
        continue
    
    if s[i] != gate1:
        gate1 = s[i]
        cnt2 += 1
        continue
    else:
        if s[i] == 0:
            gate1 = 1
        else:
            gate1 = 0
        cnt1 += 1
        
print(min(cnt1,cnt2))
    

Measured memory_bytes: 3956
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
    string srt;
    int i,l=0,r=0;
    cin>>srt;
    for(i=0;i<=3;i++)
    {
        if(srt[i]==43)
    {
       l++;
    }
    else if(srt[i]==45)
    {
        r++;
    }

}
cout<<l-r<<endl;
 return 0;

}


Measured memory_bytes: 256