akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int a[10];
int b[10];
int c[10]={0,2,5,5,4,5,6,3,7,6};
int t,n,m;

int f(int d){
	if(a[d]){
		b[d]++;
		n-=c[d];
		return 1;
	}
	return 0;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d",&t);
		a[t]++;
	}
	
	if(a[1]){
		//1を使う
		if(n%2==1){
			//1,1
			if(f(7));//7111
			//3,1
			else if(f(5));//511
			else if(f(3));//311
			else if(f(2));//211
			//5,1
			else if(f(8));//81
		}
		b[1]+=n/2;
	}else if(a[7]){
		//7を使う
		if(n%3==1){
			//1,1
			if(f(4));//774
			//4,1
			else if(f(8));//87
			//4,2
			else if(f(5))f(5);//75
			else if(f(3))f(3);//73
			else if(f(2))f(2);//72
		}else if(n%3==2){
			//2,1
			if(f(5));//77775
			else if(f(3));//77773
			else if(f(2));//77772
			//2,2
			else if(f(4))f(4);//77744
			//8,2
			else if(f(8))f(8);//887
		}
		b[7]+=n/3;
	}else if(a[4]){
		//4を使う
		if(n%4==1){
			//1,1
			if(f(5));//544444
			else if(f(3));//444443
			else if(f(2));//444442
			else if(a[8]){
				//5,2
				if(f(9))f(8);//98444
				else if(a[6])f(8),f(6);//86444
				//9,3
				else if(f(8))f(8),f(8);//8884
			}
		}else if(n%4==2){
			//2,1
			if(f(9));//9444
			else if(f(6));//6444
			//2,2
			else if(f(5))f(5);//5544
			else if(f(3))f(3);//4433
			else if(f(2))f(2);//4422
			//6,2
			else if(f(8))f(8);//884
		}else if(n%4==3){
			//3,2
			if(n>=11&&a[9]&&(a[5]||a[3]||a[2])){
				f(9);
				if(f(5));//9544
				else if(f(3));//9443
				else if(f(2));//9442
			}
			//3,1
			else if(f(8));//8444
			//3,2
			else if(a[6]&&(a[5]||a[3]||a[2])){
				f(6);
				if(f(5));//6544
				else if(f(3));//6443
				else if(f(2));//6442
			}
			//3,3
			else if(f(5))f(5),f(5);//5554
			else if(f(3))f(3),f(3);//4333
			else if(f(2))f(2),f(2);//4222
		}
		b[4]+=n/4;
	}else if(a[5]||a[3]||a[2]){
		//532を使う
		if(n%5==1){
			//1,1
			if(f(9));//95555
			else if(f(6));//65555
			//6,3
			else if(f(8))f(8),f(8);//8885
		}else if(n%5==2){
			//2,2
			if(n>=12&&f(9))f(9);//995
			//2,1
			else if(f(8));//855
			//2,2
			else if(f(6))f(6);//665
		}else if(n%5==3){
			//3,3
			if(n>=18&&f(9))f(9),f(9);//999555
			//3,2
			else if(a[8]&&(a[6]||a[9])){
				if(a[9])f(9),f(8);//985555
				else if(a[6])f(8),f(6);//865555
			}
			//3,3
			else if(f(6))f(6),f(6);//666555
			//8,4
			else if(f(8))f(8),f(8),f(8);//88885
		}else if(n%5==4){
			//4,4
			if(n>=24&&f(9))f(9),f(9),f(9);//99995
			//4,2
			else if(f(8))f(8);//88555
			//4,4
			else if(f(6))f(6),f(6),f(6);//66665
		}
		b[a[5]?5:a[3]?3:2]+=n/5;
	}else if(a[9]){
		while(n%6)f(8);
		b[9]+=n/6;
	}else if(a[6]){
		while(n%6)f(8);
		b[6]+=n/6;
	}else if(a[8]){
		b[8]+=n/7;
	}
	for(int i=9;i>0;i--)while(b[i]--)putchar('0'+i);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define ld long double
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define ff first
    #define ss second
    #define pb push_back
    #define deb(x) cout<<#x<<" : "<<x<<endl;
    #define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
    #define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
    #define deb4(w,x,y,z) cout<<#w<<" : "<<w<<"\t"<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define printv(a)  for(ll i=0;i<a.size();i++)  cout<<a[i]<<" ";
    #define PI 3.141592653589793238
   
    const ll mod=1e9+7;
    const ll N=1e6+5;
    const ll inf=1e18;
   
    ll powermod(ll x, ll y, ll p)
    {
        ll res = 1;
        x = x % p;
        while (y > 0)
        {
            if (y & 1) res = (res*x) % p;
            y = y>>1;
            x = (x*x) % p;
        }
        return res;
    }
  
    
        int main()
    {   
        FAST;
        ll n,w;
        cin>>n>>w;
        vll weight(n),value(n);
        for(ll i=0;i<n;i++)
        cin>>weight[i]>>value[i];
        ll sum=0;
        for(auto e:value)
        sum+=e;
        vll dp(sum+1,inf);
        dp[0]=0;
        for(ll i=0;i<n;i++)
        {
            for(ll j=sum-value[i];j>=0;j--)
            {
                dp[j+value[i]]=min(dp[j+value[i]],dp[j]+weight[i]);
            }
        }
        ll ans=0;
        for(ll i=sum;i>=0;i--)
        {
            if(dp[i]<=w)
            {
                ans=i;
                break;
            }
        }
        cout<<ans<<"\n";
        return 0;
    }
    

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int,string> Pis;

int main(){
  int n;
  cin>>n;
  int x[n];
  int s,t=0;
  ll x2,x1=0;
  int min;
  REP(i,n){
    cin>>x[i];
    x1+=x[i];
  }
  int p=x1/n;
  REP(i,n){
    s+=(x[i]-p)*(x[i]-p);
    t+=(x[i]-(p+1))*(x[i]-(p+1));
  }
  if(s<t){
    min=s;
  }else{
    min=t;
  }
  cout<<min<<endl;
}


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 P = pair<int, int>;

int main() {
    int l,r,d;
    cin >> l >> r >>d;
    int ans = 0;
   	for(int i=l;i<r+1;i++){
        if(i % d == 0){
            ans++;
        }
    }
  	
    cout << ans << endl;
    
    return 0;
}

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

int main(void)
{
    int x;

    scanf("%d" ,&x);

    if(400<=x && x<=599)
        printf("8");
    else if(600<=x && x<=799)
        printf("7");
    else if(800<=x && x<=999)
        printf("6");
    else if(1000<=x && x<=1199)
        printf("5");
    else if(1200<=x && x<=1399)
        printf("4");
    else if(1400<=x && x<=1599)
        printf("3");
    else if(1600<=x && x<=1799)
        printf("2");
    else
        printf("1");

    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;

    vector<vi> A(n);
    rep(i, n){
        A[i] = vi(n, -1);
        int m; cin >> m;
        rep(_, m){
            int x, y; cin >> x >> y; x--;
            A[i][x] = y;
        }
    }
    int res = 0;
    rep(k, 1 << n){
        bool ok = true;
        rep(i, n){
            if(((k >> i) & 1) == 0) continue;
            rep(j, n){
                if(A[i][j] == -1) continue;
                if(A[i][j] != ((k >> j) & 1)){
                    ok = false;
                    break;
                }
            }
        }
        if(not ok) continue;
        int cur = __builtin_popcount(k);
        chmax(res, cur);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
double D[80]; int d;

//double pop_n(){
//  return (D[--d]);}
//void push_n(double a) {
//  D[d]=a; d++;
//}

int main() {
  char inbuf[99];
  while (gets(inbuf)) {
    char *tp = strtok(inbuf, " \n");
    while (tp != NULL) {
      //      double a,b;
      if ((tp[0] == '+') && (tp[1]==0)) {
        D[d-2]+=D[--d];
      }
      else if (tp[0] == '*') {
        D[d-2]*=D[--d];
      }
      else if ((tp[0] == '-') && (tp[1]==0)) {
        D[d-2]-=D[--d];
      }
      else if (tp[0] == '/') {
        D[d-2]/=D[--d];
      }
      else {
        D[d++]=atof(tp);
      }
      tp = strtok(NULL, " \n");
    }
    printf("%.6lf\n",D[--d]);
  }
  return 0;
}

Measured memory_bytes: 580
#include<stdio.h>

int main(){
   int x[5],i;
   int dif = 0;
   for(i = 0;i<5;i++){
      scanf("%d",&x[i]);
      if(x[i]==0){
         dif=i+1;
      }
   }
   printf("%d",dif);
   return 0;
}



Measured memory_bytes: 1728
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			int[] signals = new int[n];
			int count = 0;
			for (int i = 0; i < n; i++) {
				try {
					signals[i] = sc.nextInt();
				} catch (InputMismatchException e) {
					signals[i] = Integer.MAX_VALUE;
					sc.next();
					count++;
				}
			}
			int min = Integer.MIN_VALUE;
			int max = Integer.MAX_VALUE;
			for (int i = 0; i < n; i++) {
				if (signals[i] == Integer.MAX_VALUE) {
					if (i % 2 == 0) {
						if (i > 0) {
							max = Math.min(max, signals[i - 1]);
						}
						if (i < n - 1) {
							max = Math.min(max, signals[i + 1]);
						}
					} else {
						min = Math.max(min, signals[i - 1]);
						if (i < n - 1) {
							min = Math.max(min, signals[i + 1]);
						}
					}
				}
			}
			if (max - min == 2) {
				boolean isNone = false;
				for (int i = 0; i < n; i++) {
					if (signals[i] == Integer.MAX_VALUE) {
						signals[i] = max - 1;
					}
					if (i > 0) {
						if ((i % 2 == 0 && signals[i - 1] <= signals[i])
								|| (i % 2 == 1 && signals[i - 1] >= signals[i])) {
							isNone = true;
							break;
						}
					}
				}
				if (isNone) {
					System.out.println("none");
				} else {
					System.out.println((max + min) / 2);
				}
			} else if (count == 1) {
				System.out.println("ambiguous");
			} else {
				boolean isNone = false;
				for (int i = 0; i < n; i++) {
					if (signals[i] == Integer.MAX_VALUE) {
						signals[i] = max - 1;
					}
					if (i > 0) {
						if ((i % 2 == 0 && signals[i - 1] <= signals[i])
								|| (i % 2 == 1 && signals[i - 1] >= signals[i])) {
							isNone = true;
							break;
						}
					}
				}
				if (isNone) {
					System.out.println("none");
				} else {
					System.out.println("ambiguous");
				}
			}
		}
		sc.close();
	}

}

Measured memory_bytes: 62916
n, k = gets.strip.split.map(&:to_i)
s = gets.strip.split('')

rl = []
c = s.first
count = 0
s.each do |chr|
  if chr==c
    count += 1 
  else
    rl << count
    c=chr
    count=1
  end
end
rl << count

if rl.length-1 < 2*k
  p s.length-1
  exit
end

#p rl

p rl.map {|c| c-1 }.inject(:+) + k*2


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 25;
int n;
int a[N], b[N], c[N];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    for(int i = 1; i < n; i++) cin >> c[i];
    int ans = 0;
    a[0] = -2;
    for(int i = 1; i <= n; i++) {
        ans += b[a[i]];
        if(a[i] == a[i - 1] + 1) ans += c[a[i - 1]];
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>

struct Node {
  int p;
  int l;
  int r;
};

struct Node t[50];
int n;

void preParse(int u){
  if (u == -1) {
    return;
  }
  printf(" %d", u);
  preParse(t[u].l);
  preParse(t[u].r);
}

void inParse(int u){
  if (u == -1) {
    return;
  }
  inParse(t[u].l);
  printf(" %d", u);
  inParse(t[u].r);
}

void postParse(int u){
  if (u == -1) {
    return;
  }
  postParse(t[u].l);
  postParse(t[u].r);
  printf(" %d", u);
}

int main(void){
  int v, l, r, root, i;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    t[i].p = -1;
  }

  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    t[v].l = l;
    t[v].r = r;
    if (l != -1) {
      t[l].p = v;
    }
    if (r != -1) {
      t[r].p = v;
    }
  }

  for (i = 0; i < n; i++) {
    if (t[i].p == -1) {
      root = i;
    }
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2036
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    long long n,m,ans=0;
    scanf("%lld%lld",&n,&m);
    if (n<=m/2){
        m-=2*n;
        ans+=n;
    } else {
        ans+=m/2;
        m=0;
    }
    
    ans+=m/4;
    printf ("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    r=[]
    for I in range(n):
        x=int(input())
        r.append(x)
    s=[]
    i=0
    MAX=sum(r[0:k])
    PRE=MAX
    for J in range(n-k):
        a=r[i]
        b=r[i+k]
        PRE=PRE-a+b
        if PRE>MAX:
            MAX=PRE
        else:
            pass
        i+=1
    print(MAX)


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int x;  cin >> x;
  if(x<1200)  printf("ABC\n");
  else  printf("ARC\n");
  return 0;
}

Measured memory_bytes: 3664
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      long answer = 0L;
      
      long cur = 1L;
      
      int i = 0;
      
      while(i < n){
         if(cur % 3 == 0 || cur %  5 == 0){
            i++;
            cur ++;
         } else {
            answer += cur;
            cur++;
            i++;
         }
      }
      
      out.println(answer);
      
      

      
      
      
      
      
      out.close();
   }
   
      
}

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

int main() {
    string S;
    cin >> S;
    sort(begin(S), end(S));
    if(S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  for (T &i: v) os << i << ",";
  os << "]";
  return os;
}

template<class TH> void _dbg(const char *sdbg, TH h){ cout<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cout<<*sdbg++;
  cout<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef __DJKIM613
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

const long long MOD = 1e6 + 3;

long long mod_pow(long long a, long long b){
  long long ret = 1;
  while(b){
    if(b & 1) ret = ret * a % MOD;
    a = a * a % MOD;  b >>= 1;
  }
  return ret;
}

long long mod_inv(long long a){
  return mod_pow(a, MOD - 2);
}

long long Q, X, D, N;
long long F[MOD], INVF[MOD];
long long ans;

int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  F[0] = 1;
  for(int i = 1 ; i < MOD ; i++) F[i] = F[i - 1] * i % MOD;

  INVF[MOD - 1] = MOD - 1;
  for(int i = MOD - 1 ; i >= 1 ; i--) INVF[i - 1] = INVF[i] * i % MOD;
  debug(INVF[1]);
  cin >> Q;
  while(Q--){
    cin >> X >> D >> N;

    if(D == 0) {
      cout << mod_pow(X, N) << '\n';
      continue;
    }
    
    X = X * mod_inv(D) % MOD;

    if(X + N - 1 >= MOD || X == 0) ans = 0;
    else {
      ans = F[X + N - 1] * INVF[X - 1] % MOD;
      ans = ans * mod_pow(D, N) % MOD;
    }

    cout << ans << '\n';
  }
  return 0;
}

Measured memory_bytes: 16512
N, Ma, Mb = gets.split.map(&:to_i)
M = [0]
V = [0]
N.times do
  a, b, c = gets.split.map(&:to_i)
  M << Mb * a - Ma * b
  V << c
end

dp = Array.new(N + 1) do |i|
  Hash.new do |h, j|
    if M[i] == j 
      dp[i][j] = [dp[i - 1][j], V[i]].min 
    else
      dp[i][j] = [dp[i - 1][j], dp[i - 1][j - M[i]] + V[i]].min
    end
  end
end

dp[0] = Hash.new(4001)
puts dp[N][0] > 4000 ? "-1" : dp[N][0]

Measured memory_bytes: 4732
s = input()
L = []
for i in range(len(s)):
  if not s[i] in L:
    L.append(s[i])
ans = float('inf')
if len(L) == 1:
  print(0)
else:
  for i in range(len(L)):
    k = s
    sub = 0
    flag = False
    while flag == False:
      cur = ''
      cnt = 0
      for j in range(len(k)-2,-1,-1):
        if cnt == len(cur):
          if k[j] == L[i]:
            cur = L[i]*2 + cur
          else:
            cur = k[j] + cur
        else:
          if k[j] == L[i]:
            cur = L[i] + cur
          else:
            None
        cnt += 1
      check = L[i]*len(cur)
      sub += 1
      if check == cur:
        if sub <= ans:
          ans = sub
        flag = True
      else:
        k = cur
  print(ans)

Measured memory_bytes: 3064
n = int(input())
A, B = 0, 0
for i in range(n):
    x, y = map(int,input().split())
    dx, dy = 1, 1
    if A > x:
        dx = A // x
        if A % x != 0:
            dx += 1
    
    if B > y:
        dy = B // y
        if B % y != 0:
            dy += 1

    a = max(dx, dy)
    A, B = a * x, a * y
print(A + B)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

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

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n;
  cin >> n;
  string s;
  cin >> s;
  string s2;
  if (n % 2 != 0){
    No;
    return 0;
  }
  REP(i,n/2){
    s2 += s.at(i);
  }
  bool chk = true;
  REP(i,n/2){
    if (s2.at(i) == s.at(i+n/2)){
    }else{
      chk = false;
    }
  }
  if (chk){
    Yes;
  }else{
    No;
  }
  return 0;
}



Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
max_c = 0
c = 0
for i in range(n - 2, -1, -1):
    if h[i] >= h[i + 1]:
        c += 1
        if max_c < c:
            max_c = c
    else:
        c = 0
print(max_c)


Measured memory_bytes: 15020
n, k = map(int,input().split())
a = list(map(int,input().split()))
one_index = a.index(1)
ans = 10 ** 6
for i in range(one_index - (k-1) ,one_index + (k-1) + 1 ):
    l = i
    r = i + (k-1)
    cnt_l = 0
    cnt_r = 0
    if l >= 0:
        if l % (k-1) == 0:
            cnt_l = l // (k-1)
        else:
            cnt_l = l // (k-1) + 1
        
    if r < n:
        if (n-1-r) % (k-1) == 0:
            cnt_r = (n-1-r) // (k-1)
        else:
            cnt_r = (n-1-r) // (k-1) + 1
    ans = min(ans, 1 + cnt_l + cnt_r)
print(ans)



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



#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int>> vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;


void two(int n){
    vector<int> a(16);
    for(int i = 0; n>0 && i < 16; i++){
        a[i] = n%2;
        n/=2;
    }
    reverse(all(a));
    for(auto e: a)cout << e;
    cout << endl;
}

bool one(int d, int n){
    return 1<<d & n; 
}


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int i = 0;
    for(int&e : a){
        scanf("%d", &e);
    }
    long ans = 0;
    
    
    
    size_t l = 0;
   //i : r
   // p: l
   //h:x
   //uwi
   int x = 0;
    rep(r,n){
        
        while(l<r && (x & a[r])){
            x^=a[l++];
        }
        x ^= a[r]; 
        ans+=r-l+1;;

    }
   
    cout << ans << endl;
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  vi a(n);
  rep(i,0,n) cin >> a[i];

  int mx = 0;
  ll ans = 0;

  rep(i,0,n) {
    ckmax(mx, a[i]);
    ans += mx-a[i];
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3984
#include <stdio.h>
int main(void){
    
    int n,x;
    scanf("%d %d",&n,&x);
    int a[100];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        for(int j=i-1;j>=0;j--){
            if(a[j]>a[j+1]){
                int aa=a[j+1];
                a[j+1]=a[j];
                a[j]=aa;
            }
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        //printf("%d %d %d\n",i,x,a[i]);
        if(x>=a[i] && i<n-1){
            x-=a[i];
            ans++;
        }else if(x==a[i] && i==n-1){
            x-=a[i];
            ans++;
        }
    }
    
    printf("%d",ans);
}

Measured memory_bytes: 1728
"""2ずつインクリメントして素数か検証"""
def NextPrime(X):
        while True:
                flag = 1
                for i in range(3, round(X**(1/2)), 2):
                        if X % i == 0:
                                flag = 0
                                break
                if flag == 1:
                        return X
                X += 2


X = int(input())

if X == 2:
        print(X)
        exit()
elif X %2 == 0:  #Xが２でない偶数ならば素数になりえないのでインクリメント
        X += 1

print(NextPrime(X))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using Int = long long;

int main() {

	Int A, B, C, D, E, F;

	std::cin >> A >> B >> C >> D >> E >> F;

	long double max_density = (long double)(E * 100) / (long double)(100 + E);
	long double ans_density = 0;
	Int ans_sum = 0;
	Int ans_sugar = 0;
	Int number_a = F / 100 / A;
	Int number_b = F / 100 / B;
	Int number_c = F / C;
	Int number_d = F / D;

	for (Int a = 0; a <= number_a; a++) {
		for(Int b=0;b<=number_b;b++){
			long double sum = 100 * A * a + 100 * B * b;
			if (sum > F)break;

			if (100 * A * a + 100 * B * b > 0) {
				for (Int c = 0; c <= number_c; c++) {
					long double sum = 100 * A * a + 100 * B * b + C * c;
					if (sum > F)break;

					for (Int d = 0; d <= number_d; d++) {
						long double sum = 100 * A * a + 100 * B * b + C * c + D * d;
						if (sum > F)break;

						long double sugar = C * c + D * d;
						long double density = sugar*100/ sum;
						if (density >= ans_density && density <= max_density) {
								ans_density = density;
								ans_sum = sum;
								ans_sugar = sugar;
						}
					}
					
				}
				
			}
		}
	}

	std::cout << ans_sum <<" "<< ans_sugar << std::endl;

}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  vector<int> ans(N);

  for (int i = 0; i < N; i++) {
    ans.at(N - vec.at(i)) = i + 1;
  }

  reverse(ans.begin(), ans.end());
  
  for (int i = 0; i < N; i++) {
    cout << ans.at(i) << endl;  
  }
}

Measured memory_bytes: 1664
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll X;
  cin >> X;
  auto x = static_cast<double>(X);

  REP(a, -1000, 1000) {
    REP(b, -1000, 1000) {
      if ((a - b) *
          (pow(a, 4) +
           pow(a, 3) * b +
           pow(a, 2) * pow(b, 2) +
           a * pow(b, 3) +
           pow(b, 4)) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 4048
#include<stdio.h>
#include<stdlib.h>
int func(const void* a,const void* b);
struct city{
    int year_of_birth;
    int prefecture;
    int number;
    unsigned long long int ans;
};

int main(){
    int n,m;
    scanf("%d %d",&n,&m);

    int prefecture_ptr[n];
    for(int i = 0;i < n;i++){
        prefecture_ptr[i] = 0;
    }

    struct city towns[m];
    for(int i = 0;i < m;i++){
        scanf("%d %d",&towns[i].prefecture,&towns[i].year_of_birth);
        towns[i].number = i;
        towns[i].ans = 0;
    }
    
    qsort(towns,m,sizeof(struct city),func);
    
    for(int i = 0;i < m;i++){
        towns[i].ans += ++prefecture_ptr[(towns[i].prefecture - 1)];
        //printf("%d\n", prefecture_ptr[towns[i].prefecture - 1]);
        //printf("%d\n", towns[i].prefecture * 1000000);
        towns[i].ans += ((unsigned long long int)towns[i].prefecture * 1000000);
    }

    unsigned long long int ans_num[m];
    int hoge;
    for(int i = 0;i < m;i++){
        hoge = towns[i].number;
        ans_num[hoge] = towns[i].ans;
    }
    for(int i = 0;i < m;i++){
        printf("%012llu\n",ans_num[i]);
    }
    return 0;
}
int func(const void* a,const void* b){
    return ((struct city*)a)->year_of_birth - ((struct city*)b)->year_of_birth;
}


Measured memory_bytes: 5244
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

t = max(a, b, c, d, e) - min(a, b, c, d, e)

if k < t:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
)

const Mod = 1000000007

func main() {
	N, M := ReadInt(), ReadInt()
	a := ReadInts(M)
	m := make(map[int]bool)
	for _, ai := range a {
		m[ai] = true
	}
	dp := make([]int, N+1)
	dp[0] = 1
	for i := 0; i < N; i++ {
		if !m[i+1] {
			dp[i+1] += dp[i]
			dp[i+1] %= Mod
		}
		if i+2 <= N && !m[i+2] {
			dp[i+2] += dp[i]
			dp[i+2] %= Mod
		}
	}
	fmt.Println(dp[N])
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 7120
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890LL
#define ll long long

int N;
map<string, int> m;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for(int i=0; i<N; i++)
	{
		string s;
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << "\n";
	cout << "WA x " << m["WA"] << "\n";
	cout << "TLE x " << m["TLE"] << "\n";
	cout << "RE x " << m["RE"] << "\n";
	return 0;
}

Measured memory_bytes: 3660
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, String> m = new HashMap<String, String>();
		String preString = sc.next();
		char lastChar = preString.charAt(preString.length() - 1);
		m.put(preString, preString);

		for (int i = 1; i < N; i++) {
			String string = sc.next();
			if (string.charAt(0) != lastChar || m.containsKey(string)) {
				System.out.println("No");
				return;
			}
			lastChar = string.charAt(string.length() - 1);
			m.put(string, string);
		}

		System.out.println("Yes");

		return;
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return 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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    ll k;
    cin >> s >> k;
    int cnt = -1;
    k = min((ll)size(s), k);
    rep(i, k) {
        if(s[i] != '1') {
            cnt = i;
            break;
        }
    }
    if(cnt == -1) printf("%c\n", s[k-1]);
    else printf("%c\n", s[cnt]);
}

Measured memory_bytes: 3696
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	s := getNextString(scanner)
	dd := make([]int, n+1)
	mm := make([]int, n+1)
	for i := 0; i < n; i++ {
		if s[i] == 'D' {
			dd[i+1]++
		}
		if s[i] == 'M' {
			mm[i+1]++
		}
	}
	for i := 0; i < n; i++ {
		dd[i+1] += dd[i]
		mm[i+1] += mm[i]
	}
	var dmc, dm int64
	q := getNextInt(scanner)
	for c := 0; c < q; c++ {
		k := getNextInt(scanner)
		dmc = 0
		dm = 0

		for i := 0; i < n; i++ {
			if i-k >= 0 && s[i-k] == 'D' {
				dm -= int64(mm[i] - mm[i-k])
			}
			if s[i] == 'C' {
				dmc += dm
				continue
			}
			if s[i] == 'M' {
				dm += int64(dd[i])
				if i-k+1 >= 0 {
					dm -= int64(dd[i-k+1])
				}
			}
		}

		fmt.Fprintln(writer, dmc)
	}
}


Measured memory_bytes: 19200
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    int n;string s,t;
    cin >> n >> s >> t;
    REP(i,n){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;

}

Measured memory_bytes: 256
// C - pushpush
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

vi solve(int N, vi &A){
	vi ans(N);//0_origin
	int f = N/2, b = N/2 + 1;
	if(N%2 == 0){//even <- 0_origin
		f--;
		b--;
	}
	rp(ia, 0, N){
		int ix = ia%2==0? f--: b++;
		ans[ix] = A[ia];
	}
	if(N%2 == 0) reverse(ans.begin(), ans.end());
	return ans;
}

int main(){
	int N; cin>>N;
	vi A(N);
	rp(i, 0, N) cin>>A[i];
	vi ans = solve(N, A);
	rp(i, 0, N) cout<< ans[i] <<" ";
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			String s = sc.next();
			int a = Integer.parseInt(s.substring(0, 2));
			int b = Integer.parseInt(s.substring(2, 4));
			if (1 <= a && a <= 12 && 1 <= b && b <= 12) {
				System.out.println("AMBIGUOUS");
			} else if (1 <= a && a <= 12) {
				System.out.println("MMYY");
			} else if (1 <= b && b <= 12) {
				System.out.println("YYMM");
			} else {
				System.out.println("NA");
			}
		}

	}
}

Measured memory_bytes: 21844
/* 
* ID: juryc
* PROG: Brick Break
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
vector<int> v(n); 
for(int& i: v) cin>>i;
//sort(v.begin(),v.end()); 
int re=1;
for(int i:v){
if(i==re)re++;
}
if(re==1) cout<<-1<<endl;
else{cout<<n-re+1<<endl; }
return 0;
}

Measured memory_bytes: 3992
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque 
def main():
    n, k = map(int, readline().split())
    d = {int(i) for i in readline().split()}
    dq = deque()
    cnd = []
    for i in range(10):
        if i in d:
            continue
        dq.append(i)
        cnd.append(i)

    while len(dq)>0:
        v = dq.popleft()
        for i in range(10):
            if i in d:
                continue
            cnd.append(v*10+i)
            dq.append(v*10+i)
        if n <= dq[-1]:
            break

    ans = 0
    for i in cnd:
        if n <= i:
            print(i)
            break
if __name__ == '__main__':
    main()


Measured memory_bytes: 3820
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int f(int n,int x){
    if(n<0) return 0;
    else return n/x+1;
}

signed main()
{
    int a,b,x;
    cin>>a>>b>>x;

    cout<<f(b,x)-f(a-1,x)<<endl;
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(x) for(int i=0;i<x;i++)
#define reprev(x) for(int i=x-1;i>=0;i--)
#define repdef(x,n) for(int i=x;i<n;i++)
#define Debug(x) cout<<x<<"\n";
#define Debug2(x,y) cout<<x<<" "<<y<<"\n";
#define mod 1000000007
#define MAX 100005
int fast_exp(ll base,ll exp){
	if(exp==1){
		return base%mod;
	}
	if(exp&1){
		int ans=fast_exp(base,exp-1);
		return (base%mod*ans%mod)%mod;
	}else{
		int ans=fast_exp(base,exp/2);
		return (ans%mod*ans%mod)%mod;
	}
}
int fast_exp_itr(ll base,ll exp,ll p){
	ll ans=1;
	base=base%p;
	while(exp>0){
		if(exp&1){
			ans=((ans%p)*(base%p))%p;
		}
		exp>>=1;
		base=((base%p)*(base%p))%p;
	}
	return ans;
}
int euclid_gcd(int a,int b){
	if(b==0){
		return a;
	}
	return euclid_gcd(b,a%b);
}
bool comp(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b){
	if(a.first==b.first){
		return a.second.second<b.second.second;
	}
	return a.first<b.first;
}
int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k,q;
	cin>>n>>k>>q;
	int arr[n];
	// memset(arr,k,sizeof(arr));
	rep(n){
		arr[i]=k;
	}
	rep(q){
		int d;
		cin>>d;
		arr[d-1]++;
	}
	rep(n){
		arr[i]-=q;
		if(arr[i]<=0){
			cout<<"No\n";
		}else{
			cout<<"Yes\n";
		}
	}
	return 0;
}

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

int main()
{
	int n;

	cin >> n;

	vector<int> a(2 * n);

	for (int i = 0; i < 2 * n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	int sum = 0;

	for (int i = 0; i < 2 * n; i += 2) {
		sum += a[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;

int main(){
    double n, m, d; cin >> n >> m >> d;
    double ans = 2 * (n - d) * (m - 1) / n / n;
    if(d < EPS) ans /= 2;
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n, k, i, j, d, a;
  int sunuke[100] = {};
  scanf("%d %d", &n, &k);
  for (i = 0; i < k; i++) {  // kこのお菓子に対して
    scanf("%d", &d);         // d人がそのお菓子をもつ
    for (j = 0; j < d; j++) {
      scanf("%d", &a);
      sunuke[a - 1]++;
      // printf("%dが持ってる\n", a);
    }
  }
  int count = 0;
  for (i = 0; i < n; i++) {
    if (sunuke[i] == 0) {
      count++;
      // printf("%dが持ってない\n", i);
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1732
#!/usr/bin/env python3
import sys


def solve(X: int):
    c = 100
    i = 0
    while c < X:
        c = int(c * 1.01)
        i += 1
    return i


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    print(solve(X))

if __name__ == '__main__':
    main()


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

int main(){
    
    vector< vector<int> > c(3, vector<int>(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)    cin >> c[i][j];
    }

    string ans = "Yes";

    int a[3], b[3];
    a[0] = 0;
    for(int i=0;i<3;i++)    b[i] = c[0][i];
    for(int i=1;i<3;i++)    a[i] = c[i][0] - b[0];

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(a[i] + b[j] != c[i][j]){
                ans = "No";
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;


int main()
{
    int n, x;
    scanf("%d %d", &n, &x);
    if (x == 1 || x == 2 * n - 1)
        puts("No");
    else
    {
        puts("Yes");
        vector<int>A(2 * n, -1);

        A[n - 2] = x - 1;
        A[n - 1] = x;
        A[n] = x + 1;
        int now = 1;

        for (int i = 0; i < 2 * n - 1; i++)
        {
            if (A[i] == -1)
            {
                while (abs(now - x) <= 1)
                    now++;
                A[i] = now++;
            }
        }
        
        for (int i = 0; i < 2 * n - 1; i++)
            printf("%d\n", A[i]);
    }
}


Measured memory_bytes: 2304
import java.util.*;
import java.io.*;

public class Main
{
  final int mod = (int)1e9+7;
  int n, m;
  boolean[] a;
  int[] dp;
  
  Main(Scanner in, PrintWriter out)
  {
	n = in.nextInt();
    m = in.nextInt();
    a = new boolean[n+2];
    for (int i = 0; i < m; i++)
      a[in.nextInt()] = true;
    dp = new int[n];
    Arrays.fill(dp, -1);
    out.println(dp(0));
  }
  
  int dp(int at)
  {
    if (at == n) return 1;
    if (at > n) return 0;
    if (dp[at] != -1) return dp[at];
    int cnt = 0;
    if (!a[at+1]) cnt += dp(at+1);
    cnt %= mod;
    if (!a[at+2]) cnt += dp(at+2);
    cnt %= mod;
    return dp[at] = cnt % mod;
  }

  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new	Main(in, out);
    out.close();
  } 
}


Measured memory_bytes: 50616
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    h = LI()
    mx = h[0]

    for x in h[1:]:
        if mx-1 <= x:
            pass
            mx = max(mx, x)
        else:
            print("No")
            break
    else:
        print("Yes")
main()


Measured memory_bytes: 93796
n,m=map(int,input().split())
A=[]
for i in range(m):
    A.append(list(map(int,input().split()))[1:])
P=list(map(int,input().split()))

ans=0
for bit in range(1<<n):
    for i in range(m): #それぞれの電球について
        if P[i]!= sum([bit>>(j-1) & 1 for j in A[i]])%2:
            break
        if i==m-1:
            ans+=1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> vs(n);
  for (int i = 0; i < n; i++) {
    std::cin >> vs[i];
  }
  std::vector<int64_t> cs(n);
  for (int i = 0; i < n; i++) {
    std::cin >> cs[i];
  }
  std::vector<int64_t> benefits(n);
  for (int i = 0; i < n; i++) {
    benefits[i] = vs[i] - cs[i];
  }
  std::sort(benefits.rbegin(), benefits.rend());
  int64_t ret = 0;
  for (int i = 0; i < n; i++) {
    if (benefits[i] <= 0) {
      break;
    }
    ret += benefits[i];
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}
// data structure {{{

// Union-Find
// verified AOJ DSL_1_A
struct UF {
    vector<int> p;  // parent
    vector<int> r;  // rank

    UF(int n) {
        p.resize(n);
        r.resize(n);
        for(int i=0;i<n;i++){
            p[i] = i;
            r[i] = 1;
        }
    }

    int find(int x) {
        if(x == p[x]){
            return x;
        }else{
            return p[x] = find(p[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(r[x] < r[y]){
            p[x] = y;
        }else{
            p[y] = x;
            if(r[x] == r[y]){
                r[x]++;
            }
        }
    }
};
//}}}

int main() {
    int n, k, l;cin >> n >> k >> l;
    // vector<pair<int, int>> p(k), r(l);
    UF ufp(n), ufr(n);
    for(int i=0;i<k;i++){
        // cin >> pp.first >> pp.second;
        // pp.first--;pp.second--;
        int a, b;cin >> a >> b;a--;b--;
        ufp.unite(a, b);
    }
    for(int i=0;i<l;i++){
        // cin >> rr.first >> rr.second;
        // rr.first--;rr.second--;
        int a, b;cin >> a >> b;a--;b--;
        ufr.unite(a, b);
    }

    // vector<pair<int, int>> pr;
    // sort(p.begin(), p.end());
    // sort(r.begin(), r.end());
    // set_intersection(p.begin(), p.end(),
    //                  r.begin(), r.end(),
    //                  inserter(pr, pr.end()));

    map<pair<int, int>, int> m;

    for(int i=0;i<n;i++){
        pair<int, int> p = {ufp.find(i), ufr.find(i)};
        if(m.find(p) == m.end()){
            m[p] = 0;
        }
        m[p]++;
    }

    bool flag = true;
    for(int i=0;i<n;i++){
        if(!flag){
            cout << " ";
        }
        flag = false;
        pair<int, int> p = {ufp.find(i), ufr.find(i)};
        cout << m[p];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 15104