akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <utility>
#include <array>
#include <algorithm>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?n=0,false:(n=in<T>(c),true);}
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};


long lcm(long a, long b) {
	return a * b / __gcd(a, b);
}

int main() {
	array<int, 3> s;
	for (;;) {
		for (auto &i: s) {
			int a {in()}, m {in()};
			if (!a)
				return 0;
			i = 1;
			for (int t = a % m; t != 1; t = t * a % m)
				i++;
		}
		outl(lcm(lcm(s[0], s[1]), s[2]));
	}
}


Measured memory_bytes: 2400
n,kk= map(int, input().split())
a= list(map(int, input().split()))
x=[]
for i in range(n):
    v=0
    for j in range(i,n):
        v+=a[j]
        x.append(v)
x.sort()
r=len(bin(x[-1]))-2

ans=0
flag=False
# 高い位からbitが立つか調べる
v=[]
for i in range(r-1,-1,-1):
    cnt=0
    v.append(i)
    for j in x:
        flag=True
        for k in v:
            if not (j>>k)&1:
                flag=False
                break
        if flag:
            cnt+=1

    if cnt>=kk:
        ans+=pow(2,i)
    else:
        v.pop(-1)

print(ans)

Measured memory_bytes: 66428
import itertools
H,W,K=map(int,input().split())
C=[input() for i in range(H)]
ans=0
for paint_H in itertools.product([0,1], repeat=H):
  for paint_W in itertools.product([0,1], repeat=W):
    cnt=0
    for i in range(H):
      for j in range(W):
        if paint_H[i]==0 and paint_W[j]==0 and C[i][j]=="#":
          cnt+=1
    if cnt==K:
      ans+=1
print(ans)

Measured memory_bytes: 9176
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int N;
    cin >> N;

    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p[i], p[i]--;

    vector<bool> b(N, false);
    for (int i = 0; i < N; i++) b[i] = (p[i] == i);

    int ans = 0;
    for (int i = 0; i < N - 1; i++) if (b[i]) ans++, b[i] = b[i + 1] = false;
    if (b.back()) ans++;

    cout << ans << endl;

    return 0;
}











































































Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000


void merge_sort(int *t1, int *s1, int left, int right);


int main(){
  char buf[1024];
  int N,M;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &N, &M);

  int *A=(int *)malloc(sizeof(int)*N);
  int *B=(int *)malloc(sizeof(int)*N);

  rep(i,N){
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf, "%d %d", &A[i], &B[i]);
  }

  merge_sort(A, B, 0, N-1);

  long sum=0;
  long count=0;
  int number=0;

  while(number!=N && count+B[number]<=M){
    //printf("A[%d] = %d, B[%d] = %d\n", number, A[number], number, B[number]);
    //ここ、マジで重要。long型の変数を用意するのと、int*intの演算時点でlongにキャストすること。
    sum+=(long)A[number]*B[number];
    count+=B[number];
    number++;
    //printf("%ld\n", sum);
  }

  sum+=A[number]*(M-count);

  printf("%ld\n", sum);

  return 0;

}


void merge_sort(int *t1, int *s1, int left, int right){    //アドレスが渡される
    if(left==right){
        ;
    }
    else{
        int n2=(right-left+1)/2;
        int n3=right-left+1-n2;
        int i=0,j=0,k=0;

        // rep(p,n2+n3){
        //   printf("t1[%d] = %p, t1[%d][0] = %d, t1[%d][1] = %d\n", p, t1[p], p, t1[p][0], p, t1[p][1]);
        // }

        merge_sort(t1, s1, left, left+n2-1);
        merge_sort(t1, s1, left+n2, right);

        int *t2=(int *)malloc(sizeof(int)*n2);
        int *t3=(int *)malloc(sizeof(int)*n3);
        int *s2=(int *)malloc(sizeof(int)*n2);
        int *s3=(int *)malloc(sizeof(int)*n3);

        for(i=0;i<n2;i++){
          t2[i]=t1[left+i];
          s2[i]=s1[left+i];
        }
        for(i=0;i<n3;i++){
          t3[i]=t1[left+n2+i];
          s3[i]=s1[left+n2+i];
        }

        // printf("t2[0] = %d, t3[0] = %d\n", t2[0], t3[0]);
        // printf("s2[0] = %d, s3[0] = %d\n", s2[0], s3[0]);

        //ここの実装にn時間かかった。定義されていない領域にアクセスしないの重要。
        for(i=0;i<n2+n3;i++){
            if(k==n3 || (j<n2 && t2[j]<t3[k])){
                t1[left+i]=t2[j];
                s1[left+i]=s2[j];
                j++;
            }
            else{
                t1[left+i]=t3[k];
                s1[left+i]=s3[k];
                k++;
            }
        }
    }
}


Measured memory_bytes: 23040
from bisect import bisect_left
def main():
        x=int(input())
        l,h=0,x
        ans=-1
        while(l<=h):
            m=(l+h)//2
            if(m*(m+1)//2<x):
                l=m+1
            else:
                h=m-1
                ans=m
        print(ans)
main()

Measured memory_bytes: 62060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  string s , t , u ;
  cin >> s >> t >> u ;
  cout << "A" << t[0] << "C" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;


//---------------------------------------------------------------
template<int MOD> struct ModInt { int x;
    explicit operator bool() const { return !!x; }
    ModInt(int v = 0) : x(v % MOD) { if (x < 0) x += MOD; }
    ModInt(long long v) : x(v % MOD) { if (x < 0) x += MOD; }
    ModInt &operator+=(const ModInt &r) { if ((x += r.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(const ModInt &r) { if ((x += MOD - r.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(const ModInt &r) { x = 1LL * x * r.x % MOD; return *this; }
    ModInt &operator/=(const ModInt &r) { return *this *= r.inv(); }
    ModInt operator-() const { return x ? ModInt(MOD - x) : ModInt(x); }
    ModInt operator+(const ModInt &r) const { return ModInt(*this) += r; }
    ModInt operator-(const ModInt &r) const { return ModInt(*this) -= r; }
    ModInt operator*(const ModInt &r) const { return ModInt(*this) *= r; }
    ModInt operator/(const ModInt &r) const { return ModInt(*this) /= r; }
    ModInt inv() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u); } // x.pow(MOD-2)
    ModInt pow(long long k) const { ModInt r(1), a(x);
        while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
    bool operator==(const ModInt r) const { return x == r.x; }
    bool operator!=(const ModInt r) const { return x != r.x; }
    bool operator< (const ModInt r) const { return x <  r.x; }
    friend ostream& operator<<(ostream &os, const ModInt<MOD>& a) { return os << a.x; }
    friend istream& operator>>(istream &is, ModInt<MOD>& a) { return is >> a.x; }
};
template<typename T, int SZ> struct Comb { vector<T> _fac, _ifac, _inv;
    Comb() : _fac(SZ + 1), _ifac(SZ + 1), _inv(SZ + 1) {
        _fac[0] = _ifac[SZ] = _inv[0] = 1;
        for (int i = 1; i <= SZ; i++) _fac[i] = _fac[i - 1] * i;
        _ifac[SZ] /= _fac[SZ];
        for (int i = SZ - 1; i >= 0; i--) _ifac[i] = _ifac[i + 1] * (i + 1);
        for (int i = 1; i <= SZ; i++) _inv[i] = _ifac[i] * _fac[i - 1]; }
    T inv(int n) { return n < 0 ? T(0) : _inv[n]; }
    T fac(int n) { return n < 0 ? T(0) : _fac[n]; }
    T ifac(int n) { return n < 0 ? T(0) : _ifac[n]; }
    T P(int a, int b) { return (b < 0 || a < b) ? T(0) : _fac[a] * _ifac[a - b]; }
    T C(int a, int b) { return b < 0 ? T(0) : P(a, b) * _ifac[b]; }
    T H(int n, int k) { if (n < 0 || k < 0) return T(0);
        return k == 0 ? T(0) : C(n + k - 1, k); }
};
typedef ModInt<MOD> mint;
//---------------------------------------------------------------


int main() {
    Comb<mint, 250000> com;
    int n, k; cin >> n >> k;
    cout << com.C(n - 1, k - 1) << endl;
    return 0;
}


Measured memory_bytes: 5568
program bt;

var x,a:integer;

begin
   readln(x);
   if (x>=400) and (x<=599) then a:=8 else
   if (x>=600) and (x<=799) then a:=7 else
   if (x>=800) and (x<=999) then a:=6 else
   if (x>=1000) and (x<=1199) then a:=5 else
   if (x>=1200) and (x<=1399) then a:=4 else
   if (x>=1400) and (x<=1599) then a:=3 else
   if (x>=1600) and (x<=1799) then a:=2 else
   if (x>=1800) and (x<=1999) then a:=1;
   write(a);
   readln;
end.

Measured memory_bytes: 1368
//Summer Vacation of 2018
//Contest:Atcoder Regular Contest 100
//Author:Jimmy2017
//Problem C
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll;
using namespace std;
int a[200005]; 
int main()
{
	int n; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		cin>>a[i]; 
		a[i]-=i+1; 
	}
	std::sort(a,a+n); 
	ll ans=0;
	for (int i=0;i<n;i++)
		ans+=abs(a[i]-a[n>>1]); 
	printf("%lld\n", ans);
	return 0; 
}

Measured memory_bytes: 1024
/*
 _     _    ___  ___  __ __ 
| |   | |  |__ \|__ \/_ /_ |
| |__ | |__   ) |  ) || || |
| '_ \| '_ \ / /  / / | || |
| |_) | |_) / /_ / /_ | || |
|_.__/|_.__/____|____||_||_|

*/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n;
        cin>>n;
        vi a,b;
        rep(i,0,n)
        {
            ll x;
            cin>>x;
            a.pb(x);
        }
        priority_queue < pii, std::vector<pii>, std::less<pii> > mxheap;
        rep(i,0,n)
        {
            ll x;
            cin>>x;
            b.pb(x);
            mxheap.push({x,i});
        }
        ll ans=0;
        // mxheap.push(), mxheap.top(), mxheap.pop()
        while(!mxheap.empty())
        {
            pii p=mxheap.top();
            ll i=p.S;
            ll s=b[(p.S+1)%n]+b[(p.S+n-1)%n];
            mxheap.pop();
            if((b[i]-a[i])%s==0)
            {
                ans+=(b[i]-a[i])/s;
                b[i]=a[i];
                continue;
            }
            if(s>=b[i])
            {
                cout<<-1<<endl;
                return 0;
            }
            ans+=b[i]/s;
            b[i]%=s;
            if(b[i]<a[i])
            {
                cout<<-1<<endl;
                return 0;
            }
            mxheap.push({b[i],i});
        }
        cout<<ans<<endl;
    
    }
    return 0;
}

Measured memory_bytes: 11376
#include<bits/stdc++.h>
#define MAX (long long)(5e3 + 4)
#define MOD (long long)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: synv_with_stdio(false), cin.tie(nullptr)

using namespace std;

bool eq(int a[] ,int b[],int n){
  for(int i=0;i<n;++i){
    if(a[i] != b[i]){
      return 0;
    }
  }
  return 1;
}

int main(){
  int n;
  cin >> n;
  int a[n] , b[n];
  for(int i=0;i<n;++i){
    cin  >> a[i];
  }
  for(int i=0;i<n;++i){
    cin >> b[i];
  }
  int aa[n];
  int ia , ib;
  bool fa(0) , fb(0);
  iota(aa,aa+n,1);
  for(int i=0;;++i){
    if(eq(a,aa,n)){
      ia = i;
      fa = 1;
    }
    if(eq(b,aa,n)){
      ib = i;
      fb = 1;
    }
    if(fa & fb) break;
    next_permutation(aa,aa+n);
  }
  cout << abs(ia - ib);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
const int mod=998244353;
int N;
struct Point{int x,y;bool operator<(const Point&p)const{return x<p.x||x==p.x&&y<p.y;}}P[210];
int cro[210][210][210],area[210][210][2],pw2[210],f[210][210][210];
int o,L[210],R[210];
bool cmp(int i,int j){
	//printf("cmp(%d,%d)=%d\n",i,j,cro[o][i][j]>0);
	return cro[o][i][j]>0;
}
int geta(int ty,int i,int j,int k){
	int s=area[i][j][ty]+area[j][k][ty]-area[i][k][ty];
	if(ty)s=-s;
	//printf("geta(%d,%d,%d,%d)=%d\n",ty,i,j,k,s-1);
	return s-1;
}
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d%d",&P[i].x,&P[i].y);
	std::sort(P,P+N);
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			for(int k=0;k<N;k++){
				cro[i][j][k]=(P[j].x-P[i].x)*(P[k].y-P[i].y)-(P[k].x-P[i].x)*(P[j].y-P[i].y);
				if(i<=k&&k<j){
					if(cro[i][j][k]>=0)area[i][j][0]++;
					if(cro[i][j][k]>0)area[i][j][1]++;
				}
			}
	for(int i=*pw2=1;i<=N;i++)pw2[i]=pw2[i-1]*2%mod;
	for(o=N;o--;){
		//printf("o=%d\n",o);
		int lc=0,rc=0;
		for(int i=0;i<o;i++)L[lc++]=i;
		for(int i=o+1;i<N;i++)R[rc++]=i;
		std::sort(L,L+lc,cmp);
		std::sort(R,R+rc,cmp);
		//printf("L:");for(int i=0;i<lc;i++)printf(" %d",L[i]);puts("");
		//printf("R:");for(int i=0;i<rc;i++)printf(" %d",R[i]);puts("");
		for(int j=0;j<rc;j++){
			//printf("j=R[%d]=%d\n",j,R[j]);
			int m=0;
			while(m<lc&&cro[L[m]][R[j]][o]<0)m++;
			for(int i=m,p=j,sum=1;i--;)if(cro[L[i]][R[j]][o]<0){
				while(p&&cro[L[i]][R[p-1]][o]<0)(sum+=f[o][R[--p]][R[j]])%=mod;
				f[L[i]][o][R[j]]=1ll*sum*pw2[geta(0,L[i],o,R[j])]%mod;
				//printf("up i=L[%d]=%d p=R[%d]=%d sum=%d\n",i,L[i],p,R[p],sum);
				//printf("f(%d,%d,%d)=%d\n",L[i],o,R[j],f[L[i]][o][R[j]]);
			}
			for(int i=m,p=j,sum=1;i<lc;i++)if(cro[L[i]][R[j]][o]>0){
				while(p<rc&&cro[L[i]][R[p]][o]>0)(sum+=f[o][R[p++]][R[j]])%=mod;
				f[L[i]][o][R[j]]=1ll*sum*pw2[geta(1,L[i],o,R[j])]%mod;
				//printf("dn i=L[%d]=%d p=R[%d]=%d sum=%d\n",i,L[i],p,R[p],sum);
				//printf("f(%d,%d,%d)=%d\n",L[i],o,R[j],f[L[i]][o][R[j]]);
			}
		}
	}
	int s=0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			int up=0,dn=0,on=1;
			for(int k=i+1;k<j;k++){
				int c=cro[i][j][k];
				if(c>0)(up+=f[i][k][j])%=mod;
				else if(c<0)(dn+=f[i][k][j])%=mod;
				else(on*=2)%=mod;
			}
			s=(s+(1ll*up*(dn+1)%mod+dn)*on)%mod;
			//printf("i=%d j=%d up=%d dn=%d on=%d\n",i,j,up,dn,on);
		}
	}
	printf("%d\n",s);
}

Measured memory_bytes: 71680
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
map< ll , ll > mp;
int main()
{
	int n , a; 
	cin >> n >> a;
	cout << max(0 , n * n - a) << endl;
	return 0;
} 




Measured memory_bytes: 256
/*
	*	Created By: 'Present_Sir'
	*	Created On: Friday 14 August 2020 01:58:23 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;
const int mod = 1e9+7;

int expo(int a, int b){
    if(b == 0){
        return 1;
    }
    int ans = expo((a*a)%mod,b/2);
    if(b%2){
        return (a*ans)%mod;
    }
    return ans%mod;
}

void solve(){
    int n,k;
    cin>>n>>k;
    
    int ans = 0;
    vector<int> dp(k+1);
    
    for(int i=k; i>=1; --i){
        int t = k/i;
        int curans = expo(t,n);
        curans %= mod;
        int minus = 0;
        for(int j=2*i; j<=k; j+=i){
            minus += dp[j];
            minus %= mod;
        }
        dp[i] = (curans-minus+mod)%mod;
        //ans += (curans-minus+mod)%mod;
        ans += (dp[i]*i)%mod;
        ans %= mod;
    }
    cout<<ans<<endl;
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}


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

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif
/*---------------------------Defines----------------------*/
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
/*-----------------------Modular Arithmetic---------------*/
inline int add(int x,int y,int mod){
    x+=y;
    if (x>=mod) return x-mod;
    return x;
}
inline int sub(int x,int y,int mod){
    x-=y;
    if (x<0) return x+mod;
    return x;
}
inline int mul(int x,int y,int mod){
    return (x*1ll*y)%mod;
}
inline int power(int x,int y,int mod){
    int ans=1;
    while(y){
        if (y&1) ans=mul(ans,x,mod);
        x=mul(x,x,mod);
        y>>=1;
    }
    return ans;
}
inline int inv(int x,int mod){
    return power(x,mod-2,mod);
}
/*-----------------------------Code begins----------------------------------*/



void solve(){
    ll n;cin>>n;
    vvll v;
    for(ll i=0;i<n;i++){
        ll a,b,c;cin>>a>>b>>c;
        v.pb({a,b,c});
    }
    ll dp[n][3];
    dp[0][0]=v[0][0];
    dp[0][1]=v[0][1];
    dp[0][2]=v[0][2];
    for(ll i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i][0];
        dp[i][1]=max(dp[i-1][2],dp[i-1][0])+v[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+v[i][2];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);

    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 8752
from copy import deepcopy
N = int(input())
A = [int(input()) for n in range(N)]
Aorder = deepcopy(A)
Aorder.sort()
odd, even = set(), set()
for i in range(N):
    if i % 2 == 0:
        even |= {Aorder[i]}
    else:
        odd |= {Aorder[i]}

missmatch = 0
for i in range(N):
    if i % 2 == 0:
        if A[i] in odd: missmatch += 1
    else:
        if A[i] in even: missmatch += 1
print(missmatch//2)

Measured memory_bytes: 14416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(void) {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    ll sum = 0;
    for(int i=k;i<n;i++){
        sum += a[i];
    }
    cout << sum << endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i],as[i]--;
  vector<Int> rs(n);
  for(Int i=0;i<n;i++) rs[as[i]]=i+1;
  for(Int i=0;i<n;i++) cout<<rs[i]<<endl;
  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)                  //COMMON FOR LOOP (ITERATOR)
#define itr(x,n) for(int x=0;x<n;x++)                                       //COMMON FOR LOOP (VARIABLE)
#define itrab(x,a,b) for(int x=a;x<b;x++)                                   //FOR LOOP WITH SPECIFIED START/END
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn                         //PRINTS VECTOR,SET,MAP OF INTS
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn    //PRINTS VECTOR,SET,MAP OF PAIRS
#define sz(x) (ll)((x).size())
#define dTor(x) ((x)*pi)/180.0

#define pi   3.14159265359
#define INF  1000000000
#define INFF 1000000000000000000

typedef long long int ll;       //TYPEDEFS
typedef long double ld;
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;

const ll M=1000000007;          //COMMON MODULO PRIMES
const ll N=998244353;

ll power(ll x, ll y, ll p){     //MODULAR EXPONENTIATION
    ll 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;
}
ll inv(ll x, ll m){             //FERMAT INVERSE
    return power(x,m-2,m);
}
ll nCr(ll n, ll r){             //nCr MOD P  
    vl fac(10);
    if (r==0) 
        return 1;
    return (fac[n]*inv(fac[r],M)%M*inv(fac[n-r],M)%M)%M;
}
struct comp{                    //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff<b.ff);
    else
        return (a.ss>b.ss);
}
void sieve(){       //SIEVE OF ERATOSTHENES
    vector<bool> pr(1000000+1,1);
    for(ll i=2;i*i<=1000000;i++)
        if(pr[i]==1)
            for(ll j=i*i;j<=1000000;j+=i)
                pr[j]=0;
}
bool isValid(ll i, ll j, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=0&&i<n&&j>=0&&j<m){
        return true;
    }
    return false;
}

//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
        standardVar;
        ll a,b,c;
        cin>>a>>b>>c>>k;
        ll sum=0;
        sum+=min(a,k);
        k-=min(a,k);
        k-=min(b,k);
        sum-=min(c,k);
        cout<<sum nn;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	cout << (a - (u == s)) << ' ' << (b - (u == t)) << endl;
}


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

int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		if(a < b){
			for(int j = a;j <= b;j++) cout << (j == a ? "" : " ") << j;
		}else if(a >= 6){
			for(int j = a;j <= 9;j++) cout << (j == a ? "" : " ") << j;
			if(b >= 6) {
				for(int j = 5;j >= 0;j--) cout << " " << j;
				for(int j = 1;j <= b;j++) cout << " " << j;
			}
			else for(int j = 5;j >= b;j--) cout << " " << j;
		}else{
			for(int j = a;j >= b;j--) cout << (j == a ? "" : " ") << j;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 +5;
long long a[N];
ll att(ll n){
	if(n==0) return 0;
	if(n==1) return 1;
	return 1+att(n/2)*2;
}
int main(){
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	cout<<att(n)<<endl;
	return 0;
} 

Measured memory_bytes: 256
# 高八士君は回文が大好きで、回文でない文字列が許せません。
# 高八士君は文字列を 1 回ハグするごとに、文字列から 1 文字を選んで任意の文字に変えることができます。
# 文字列 S が与えられます。S を回文にするために必要なハグの最小回数を答えてください。

s = gets.chomp

check_count = s.length / 2
hug = 0

check_count.times do |i|
    reverse_index = s.length - 1 - i
    if s[i] != s[reverse_index]
        hug += 1
    end
end

puts hug

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

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

	string sh; cin>>sh;
	if (sh[2] == sh[3] && sh[4] == sh[5])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>
int main(){
int sum=0,ans=0,count=0,b,bit,a[15],n,s,i;
while(1){
scanf("%d %d\n",&n,&s);
if(n==0 && s==0){
break;
}
for(bit=0;bit<1024;bit++){
b=bit;
for(i=0;i<10;i++){
a[i]=0;
}
for(i=0;i<10;i++){
a[i]=b%2;
b=b/2;
}
for(i=0;i<10;i++){
if(a[i]==1){
count++;
}
}
if(count==n){
for(i=0;i<10;i++){
if(a[i]==1){
sum=sum+i;
}
}
if(sum==s){
ans++;
}
}
count=0,sum=0;
}
printf("%d\n",ans);
ans=0;
}
return 0;
}


Measured memory_bytes: 2032
N, Y = map(int, input().split())

for a in range(N + 1):
    for b in range(N + 1):
        if a + b > N:
            break
        else:
            c = N - a - b
            total = 10000 * a + 5000 * b + 1000 * c
            if total == Y:
                print('{0} {1} {2}'.format(a, b, c))
                exit()

print('-1 -1 -1')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,A,B;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> A >> B;
  cout << min(N*A,B) << endl;

  return 0;
}

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

	using namespace std;

	int main(){

	  string a,b;
	  int count =0;
	  cin>>a>>b;
	  for(int i=0;i<a.length();i++){
	  	if(a[i]!=b[i]){
	  		count++;
	  		break;
	  	}
	  	

	}	
	if(count>0)
	  		cout<<"No";
	  	else
	  		cout<<"Yes";

	  return 0;
	}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int h = fr.nextInt();
		int w = fr.nextInt();
		String[] str = new String[h];
		Set<Integer> rows = new HashSet<>();
		Set<Integer> cols = new HashSet<>();
		for (int i=0; i<h; i++) {
			str[i] = fr.nextLine();
			boolean valid = true;
			for (int j=0; j<w; j++) {
				if (str[i].charAt(j) != '.') {
					valid = false;
					break;
				}
			}
			if (valid) {
				rows.add(i);
			}
		}
		for (int j=0; j<w; j++) {
			boolean valid = true;
			for (int i=0; i<h; i++) {
				if (str[i].charAt(j) != '.') {
					valid = false;
					break;
				}
			}
			if (valid) {
				cols.add(j);
			}
		}
		for (int i=0; i<h; i++) {
			if (rows.contains(i)) {
				continue;
			}
			for (int j=0; j<w; j++) {
				if (!cols.contains(j)) {
					System.out.print(str[i].charAt(j));
				}
			}
			System.out.println();
		}
	}
	
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 27972
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
typedef long long ll;
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; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
ll tmp1,tmp2;
void insertionSort(ll A[],ll N){
  for(ll i = 1;i< N;i++){
    ll v = A[i];
    ll j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    rep(j,N){
      if(j == N-1){
        cout << A[j];
      }else{
        cout << A[j] << " ";
      }
    }
    cout << endl;
  }
} // N個の要素を含む0-オリジンの配列A
int main(){
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n){
    cin >> a[i];
  }
  rep(j,n){
    if(j == n-1){
      cout << a[j];
    }else{
      cout << a[j] << " ";
    }
  }
  cout << endl;
  insertionSort(a,n);
}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll par(ll a,ll b){
    if(a%b==0) 
    return a/b-1;
    else 
    return a/b;
}
ll par(ll,ll);
int main() {
	ll n; cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++){
	    sum+=par(n,i);
	}
	cout<<sum<<endl;
}
	
	
	   

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int cnt;
vector<int> v;//?´???°??§???????´???°??§???????????°??????????????\????????????

void print(int num){
	printf("%d:", num);
	rep(i, cnt) printf(" %d", v[i]);
	printf("\n");
	return;
}

//???????´???°????´???°????????????????¢??????????
void check(int yakusu){
	if (cnt == 0){
		v.push_back(yakusu);//cnt==0??§???????´???°????????????????´???°??§?????????
		cnt++;
	}else{
		rep(i, cnt){
			if (yakusu % v[i] == 0) break;//v[i]?????\??£??????????´???°??§????????????????????§????´???°??§?????????			

			//?????§???v[i]?????\??£?????????????????¨?????§????????????????????£????????§????´???°??§??????
			if (i == cnt - 1){
				cnt++;
				v.push_back(yakusu);
			}
		}
	}
	
	return;
}

void slove(int num){
	cnt = 0;//cnt????????????
	//?´???°??§??????????????¢????????????????´???°??§????????????check()??¢??°??§?????????
	for (int i = 6; i<= num; i += 7){
		if (num % i == 0) check(i);
		if (num % (i + 2) == 0) check(i + 2);
	}
	return;
}

int main(void){
	int n;
	rep(i, 1000000){
		scanf("%d", &n);
		if(n == 1) break;
		slove(n);
		print(n);
		v.clear();//v?????°?????????????????°?????\??£??????????????§???????????§?????????????????¨???????????????
	}	

	return 0;
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    long k;
    cin >> n >> k;
    vector<int> a(n * 2);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i + n] = a[i];
    }
    int MAX = 1000000;
    vector<int> last(MAX + 1);
    vector<int> next(n * 2);
    for (int i = a.size() - 1; i >= 0; i--) {
        next[i] = last[a[i]];
        last[a[i]] = i;
    }
    int x = 0;
    vector<long> pk(n, -1);
    while (true) {
        if (k <= 2) {
            vector<int> s;
            vector<bool> z(MAX + 1);
            for (int i = x; i < k * n; i++) {
                if (z[a[i % n]]) {
                    while (z[a[i % n]]) {
                        int t = s.back();
                        s.pop_back();
                        z[t] = false;
                    }
                } else {
                    z[a[i % n]] = true;
                    s.push_back(a[i % n]);
                }
            }
            for (int x : s) {
                cout << x << " ";
            }
            break;
        }
        x = next[x] + 1;
        while (x >= n) {
            k--;
            x -= n;
        }
        if (pk[x] != -1) {
            long d = pk[x] - k;
            k %= d;
        }
//        cout << x << " " << k << "\n";
        pk[x] = k;
    }

    return 0;
}

Measured memory_bytes: 11124
import copy
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
B = A

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    ans = 0
    for k in range(N):
        for i in range(N):
            for j in range(N):
               # if d[i][j] == d[i][k] + d[k][j]:
               #   if (i != k) and (j != k):
               #     ans += d[i][j]
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################

#d = [[float("inf") for i in range(10)] for i in range(10)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
#for i in range(10):
#  for j in range(10):
#    d[i][j] = C[i][j]

#print(warshall_floyd(d))
#print(warshall_floyd(C))
B = copy.deepcopy(A)
cost = warshall_floyd(B)
#print(cost , A)

ans = 0
for i in range(N):
  for j in range(N):
    if cost[i][j] < A[i][j]:
      print("-1")
      quit()

for i in range(N):
  cost[i][i] = 10 ** 18
for i in range(N):
  for j in range(N):
    p = 1
    for k in range(N):
      if cost[i][j] >= cost[i][k] + cost[k][j]:
        p = 0
        break
    if p == 1:
      ans += cost[i][j]


ans = ans / 2
#for i in range(10):
#  ans += num[i] * cost[i][1]

print(int(ans))

Measured memory_bytes: 56156
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

int main() {
  ll n;cin >> n;
  vector<ll> a(n),s(n+1,0);
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) s[i+1]=s[i]+a[i];
  map<ll,ll> m;
  ll ans=0;
  for(int i=0;i<=n;i++){
    ans+=m[s[i]]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 15872
#include <iostream>
 
using std::cin;
using std::cout;
using std::endl;

static int const MODULO = 1e9 + 7;

static long
mmul(long a, long b)
{
  return (a * b) % MODULO;
}

int
main()
{
  int N;
  cin >> N;
  long p = 1;
  for (int i = 1; i <= N; i++)
  {
    p = mmul(p, i);
  }
  cout << p << endl;
  return 0;
}


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

for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        XY[i].append((x-1, y))

for i in range(2**n):
    correct = [False]*n
    tmp_cnt = 0
    flag = True

    for j in range(n):
        if i&(1<<j):
            correct[j] = True
            tmp_cnt += 1

    for j in range(n):
        if correct[j]:
            for x, y in XY[j]:
                if (y==0 and correct[x]) or (y==1 and not correct[x]):
                    flag = False
    if flag:
        ans = max(tmp_cnt, ans)

print(ans)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N, M; cin >> N >> M;
    int res = 1;

    rep(i, M/N){
        int a1 = M/N-i;
        int a2 = M-(N-1)*a1;
        if(a2%a1 == 0){
            res = a1;
            break;
        }
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include<stdio.h>

int main()

{    

int a,b,c,d; 

 scanf("%d %d %d",&a,&b,&c);        

if(a>b)   

  {  

  d=b;b=a;a=d;            

}         

if(b>c)    

{         

d=c;c=b;b=d; 

 }     

if(a>b)

{         

d=b;b=a;a=d;    

}    

printf("%d %d %d\n",a,b,c);    

return 0;

}

Measured memory_bytes: 596
#include<cstdio>
int main(void){
int w;
int h;
for(;;){
scanf("%d %d",&w,&h);
if(w==0&&h==0)break;
else{
for(int i=0;i<h;i++)printf("#");
printf("\n");
for(int i=2;i<w;i++){
printf("#");
for(int j=2;j<h;j++)printf(".");
printf("#\n");
}
for(int i=0;i<h;i++)printf("#");
printf("\n\n");
}
}
return 0;
}

Measured memory_bytes: 2596
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m,count=0;
  cin>>n>>m;
  int k;
  vector<int> a(m+1,0);
    for(int i=0;i<n;i++){
      cin>>k;
      for(int j=0;j<k;j++){
        int s;
        cin>>s;
        a[s]++;
      }
    }
  
  for(int i=0;i<m+1;i++){
    if(a[i]==n) count++;
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    long long int n, p, q;
    cin >> n >> p >> q;
    long long int c[n];
    long long int d[n];
    long long int e[n];
    for(long long int i = 0; i < n; i++)
    {
        cin >> c[i];
        d[i] = c[i] + p * i;
    }
    sort(d, d+n);
    for(long long int j = 0; j < n; j++)
    {
        e[j] = d[j] - p * (q + 2 * j);
    }
    long long int x = 0;
    long long int y = 0;
    for(long long int k = 0; k < n; k++)
    {
        y = y + e[n-1-k];
        if(x < y)
        {
            x = y;
        }
    }
    
    cout << x + n * p * q + n * (n-1) * p / 2 << endl;

}

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

struct Card {
    char suit, value;
};

void bubble (struct Card A[], int N) {
    for (int i=0; i<N; ++i) {
        for (int j=N-1; j>i; --j) {
            if (A[j].value < A[j-1].value) {
                swap(A[j], A[j-1]);
            }
        }
    }
}

void selection (struct Card A[], int N) {
    int Min=0, tmp;
    
    for (int i=0; i<N; ++i) {
        int minj=i;
            for (int j=i; j<N; ++j) {
                if (A[j].value < A[minj].value) {
                    minj = j;
                }
        }
        swap(A[i], A[minj]);
    }
}

void print (struct Card A[], int N) {
    for (int i=0; i<N; ++i) {
        if(i>0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable (struct Card A1[], struct Card A2[], int N) {
    for (int i=0; i<N; ++i) {
        if(A1[i].suit != A2[i].suit) return false;
    }
    return true;
}

int main() {
    Card A1[100], A2[100];
    int N;
    cin >> N;
    for (int i=0; i<N; ++i) {
        cin >> A1[i].suit >> A1[i].value;
    }
    for (int i=0; i<N; ++i) {
        A2[i] =A1[i];
    }
    
    bubble(A1, N);
    selection(A2, N);
    
    print(A1, N);
    cout << "Stable" << endl;
    print(A2, N);
    if (isStable(A1, A2, N)) {
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    
    return 0;
}



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

int main(){
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	int L = a + b;
	int R = c + d;

	if (R > L){
		cout << "Right" << endl;
	}
	else if (R < L){
		cout << "Left" << endl;
	}
	else{
		cout << "Balanced" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;
long bigp = 1000000007;


int main(){
    ll n,k;
    string s;
    cin >> n >> k;
    cin >> s;
    vector<ll> base(n);
    rep(i,n){
        base[i]=ll(s[i]-'0');
    }
    ll prev = 1;
    ll count = 0;
    vector<ll> rl;
    rep(i,n){
        if(base[i]==prev){
            count += 1;
        }
        else{
            rl.push_back(count);
            prev = base[i];
            count = 1;
        }
    }
    rl.push_back(count);
    if(base[n-1]==0){   
        rl.push_back(0);
    }

    ll l = rl.size();
    ll sum = 0;
    ll first_end = min(2*k+1,l);
    rep(i,first_end){
        sum += rl[i];
    }
    ll ans = sum;
    reps(i,2*k+1,l){
        sum = sum + rl[i] - rl[i-2*k-1];
        if(i%2==0 && sum > ans){
            ans = sum;
        }
    }
    cout << ans;
}


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

using namespace std;

const int N = 200005;

int n;
int a[N], pref[N], suff[N];

int main() {

	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i ++) {
		pref[i] = max(pref[i - 1], a[i]);
	}
	for (int i = n; i >= 1; i --) {
		suff[i] = max(suff[i + 1], a[i]);
	}
	for (int i = 1; i <= n; i ++) {
		cout << max(pref[i - 1], suff[i + 1]) << '\n';
	}
	return 0;
}

Measured memory_bytes: 3968