akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(int n, int m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(int n, int m) {return (n / gcd(n, m) * m);}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};

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

  int n, m;
  cin >> n >> m;
  vt<int> p(m), y(m);
  rep(i, 0, m) cin >> p[i] >> y[i];

  vvt<int> vec(n + 1);
  rep(i, 0, m) vec[p[i]].push_back(y[i]);
  rep(i, 1, n + 1) sort(all(vec[i]));

  map<pi, string> mp;
  rep(i, 1, n + 1) {
    rep(j, 0, vec[i].size()) {
      string a = to_string(i);
      string b = to_string(j + 1);

      string s = string(6 - a.size(), '0') + a + string(6 - b.size(), '0') + b;
      mp[make_pair(i, vec[i][j])] = s;
    }
  }

  rep(i, 0, m) cout << mp[make_pair(p[i], y[i])] << endl;
}


Measured memory_bytes: 18688
# coding: utf-8
#lines = <<'EOS'
#4
#1 2 2 4
#2 1 4
#3 0
#4 1 3
#EOS

lines = $stdin.read
array = lines.split("\n")

N = array[0].to_i

m = Array.new(N).map{Array.new(N, 0)}

for i in 1...array.length
  elems = array[i].split(" ").map(&:to_i)
  u = elems[0]
  k = elems[1]
  v = elems.drop(2) # Array#tail ?????????

  #puts "#{u}, #{k}, #{v.to_s}"
  for j in 0...v.length
    #puts "m[#{u-1}][#{v[j]-1}] = 1"
    m[u-1][v[j]-1] = 1
  end
end

for i in 0...N
  puts m[i].join(" ")
end

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

int main(){
  int n;
  while(cin >> n){
    int num=0;
    for(int i=0; i<=9; i++)
      for(int j=0; j<=9; j++)
	for(int k=0; k<=9; k++){
	  if((n-i-j-k)>=0 && (n-i-j-k)<=9)
	    num++;
	}
    cout << num << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define REP(name, stop) for (ll(name) = 0; (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    string ans;
    if (((a + d - 1) / d) >= ((c + b - 1) / b))
        ans = "Yes";
    else
        ans = "No";
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3588
N = int(input())
A = [0] + list(map(int, input().split()))
B = list(map(int, input().split()))
C = [0] + list(map(int, input().split()))
ans = sum(B)

for i in range(1, N):
    if A[i]+1 == A[i+1]:
        ans += C[A[i]]
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zero = 0;
ll INF = 10000000000;

int main(void){
    ll N;
    cin >> N;
    vector<ll> a(N);
    for(ll i = 0; i<N; i++){
        cin >> a.at(i);
    }
    ll cnt = 0;
    ll cntzero = 0;
    for(ll i: a){
        if(i < 0){
            cnt++;
        }
        else if(i == 0){
            cntzero++;
        }
    }
    ll ans = 0;
    ll minabs = 10000000000;
    if(cnt % 2 == 0 || cntzero >= 1){
        for(ll i: a){
            ans += abs(i); 
        }
        printf("%lld",ans);
    }
    else{
        for(ll i: a){
            minabs = min(minabs, abs(i));
        }
        for(ll i: a){
            ans += abs(i); 
        }
        ans -= minabs*2;
        printf("%lld",ans);
        
    }
    
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String foc=scan.next();
		String real=scan.next();
		int count=0;
		for(int i=0;i<3;i++) {
			if(foc.charAt(i)==real.charAt(i)) {
				count++;
			}
		}
		System.out.println(count);
		
	}
}

Measured memory_bytes: 21332
import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, A, B, C = map(int, input().split())

    factrial = [1] * (2*N)
    # pa[i] / pab[i] is the probobility that A wins i times when there is no draw.
    pa = [1] * (2*N)
    pb = [1] * (2*N)
    pab = [1] * (2*N)
    for k in range(1, 2*N):
        factrial[k] = (factrial[k-1] * k) % MOD
        pa[k] = (pa[k-1] * A) % MOD
        pb[k] = (pb[k-1] * B) % MOD
        pab[k] = (pab[k-1] * (A+B)) % MOD
    
    fact_inv = [1] * (2*N)
    fact_inv[2*N-1] = pow(factrial[2*N-1], MOD - 2, MOD)
    pab_inv = [1] * (2*N)
    pab_inv[2*N-1] = pow(pab[2*N-1], MOD - 2, MOD)
    for k in range(2*N-2, -1, -1):
        fact_inv[k] = (fact_inv[k+1] * (k+1)) % MOD
        pab_inv[k] = (pab_inv[k+1] * (A+B)) % MOD
 
    def comb_mod(n, r, MOD=10**9+7):
        return (factrial[n] * fact_inv[r] * fact_inv[n-r]) % MOD

    ans = 0
    for m in range(N):
        E = (comb_mod(N+m-1, N-1)\
            * (pa[N]*pb[m] + pa[m]*pb[N]) * pab_inv[N+m]\
            * (N+m) * 100 * pow(100-C, MOD-2, MOD))\
            % MOD

        ans = (ans + E) % MOD

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 50420
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    string t="CODEFESTIVAL2016";
    int ans=0;
    for(int i=0;i<16;i++){
    	if(s[i]!=t[i])ans++;
    }
    cout <<ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <typeinfo>
#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll int,ll int>
#define pii             pair<ll int,ll int>
#define vi              vector<ll int>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll int)x.size()
#define hell            1000000007
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (long long int i=a;i<b;i++)
#define repr(i,a,b)     for (long long int i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define bs              binary_search
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
using namespace std;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={0+,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/
 
//primes for hashing 937,991,1013,1409,1741
ll n,arr[100200],dp[100200],k;

ll find(ll ind){
	if (dp[ind]!=-1)return dp[ind];
	if (ind==n-1){dp[ind]=0;return 0;}
	if (ind>n-1)return hell;
	ll temp=find(ind+1)+abs(arr[ind]-arr[ind+1]);
	rep(i,2,k+1){
		temp=min(temp,find(ind+i)+abs(arr[ind]-arr[ind+i]));
	}
	dp[ind]=temp;
	return dp[ind];
}

void solve() {
    cin>>n>>k;
    rep(i,0,n){
    	cin>>arr[i];
    }
    memset(dp,-1,sizeof dp);
    cout<<find(0);
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
#define MAX_N 100000
#define MAX_P 200005
int fact[MAX_P];
int extgcd(int a,int b,int& x,int& y){
  int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
int mod_inverse(int a,int m){
  int x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

int euler_phi(int n){
  int res=n;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      res=res/i*(i-1);
      for(;n%i==0;n/=i);
    }
  }
  if(n!=1) res=res/n*(n-1);
  return res;
}

int euler[MAX_N];

void euler_phi2(){
  for(int i=0;i<MAX_N;i++) euler[i]=i;
  for(int i=2;i<MAX_N;i++){
    if(euler[i]==i){
      for(int j=i;j<MAX_N;j+=i) euler[j]=euler[j]/i*(i-1);
    }
  }
}

int mod_pow(int x,int n,int mod){
  int res=1;
  while(n>0){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}

void init(int p){
  fact[0]=1;
  for(int i=1;i<MAX_P;i++) fact[i]=(fact[i-1]*i)%p;
}

int mod_fact(int n,int p,int& e){
  e=0;
  if(n==0) return 1;
  int res=mod_fact(n/p,p,e);
  e+=n/p;
  if(n/p%2!=0)return res*(p-fact[n%p]) %p;
  return res*fact[n%p]%p;
} 
int mod_comb(int n,int k,int p){
  if(n==k||k==0) return 1;
  int e1,e2,e3;
  int a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inverse(a2*a3%p,p)%p;
}

signed main(){
  int n;
  cin>>n;
  cout<<euler_phi(n)<<endl;
  return 0;
}

/*
verified on 2017/04/28
mod_pow:

int n,m;
cin>>m>>n;
cout<<mod_pow(m,n,MOD)<<endl;

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B&lang=jp

euler_phi:


*/

Measured memory_bytes: 3096
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define df 0
int dc=10000;
int d[10];
int search(int n);
int check(int n);


int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int i;
  for(i=0;i<10;i++){
    d[i]=1;
  }
  for(i=0;i<k;i++){
    int a;
    scanf("%d",&a);
    d[a]=0;
  }
  if(df){
    for(i=0;i<10;i++){
      printf("%d ",d[i]?i:-1);
    }
    printf(": available\n");
  }
  printf("%d",search(n));
  return 0;
}

int search(int n){
  int flag=0;n--;
  while(flag==0){
    dc-=df; if(dc<0){printf("err in search"); return 0;}
    n++;
    flag=check(n);
  }
  return n;
}


int check(int n){
  int flag=1;
  if(df)printf("check %d",n);
  while(n){
    dc-=df; if(dc<0){printf("(%d)err in check",n); return 0;}
    if(d[n%10]==0){
      if(df) printf("... %d:not available\n",n%10);
      flag=0;
    }
    n/=10;
  }
  return flag;
}

/// confirm df==0 ///


Measured memory_bytes: 128
#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,l,t;
  cin>>n>>l>>t;
  vector<Int> x(n),w(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>w[i];

  vector<Int> ps;
  for(Int i=0;i<n;i++){
    if(w[i]==1) ps.emplace_back((x[i]+t)%l);
    if(w[i]==2) ps.emplace_back((x[i]-t%l+l)%l);    
  }
  sort(ps.begin(),ps.end());

  Int cnt=0;
  for(Int i=1;i<n;i++){
    if(w[i]==w[0]) continue;
    Int d=(w[0]==1?x[i]-x[0]:x[0]+(l-x[i]));
    if(t*2<d) continue;
    cnt+=1+((t*2-d)/l);    
  }
  if(w[0]==2) cnt=n-cnt%n;
  cnt%=n;
  
  Int pos=(w[0]==1?x[0]+t:x[0]-t%l+l)%l;
  Int p=  lower_bound(ps.begin(),ps.end(),pos)-ps.begin();
  Int q=--upper_bound(ps.begin(),ps.end(),pos)-ps.begin();

  Int idx=w[0]==1?q:p;
  vector<Int> ans(n);
  for(Int i=0;i<n;i++) ans[(cnt+i)%n]=ps[(idx+i)%n];

  //cout<<cnt<<" "<<idx<<endl;
  for(Int i=0;i<n;i++) cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 4468
#include <iostream> 
#include <map>
#include <algorithm>
using namespace std; 
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define ll long long int
#define REPI(a, b, i, inc) for(ll i = a; i < b; i = i + inc)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define F first
#define S second
#define pb push_back
#define test ll t; cin>>t; while(t--)
#define testi ll t; cin>>t; REP(tc,1,t+1)
#define vec vector
#define veci vector<int>
#define pi pair<int,int>
#define mp make_pair
#define all(v) v.begin(), v.end()
#define uset unordered_set
#define umap unordered_map

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 

int main() {
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
    int n;
    cin>>n;
    ll arr[n];
    ll sum=0;
    
    REP(i,0,n)
    cin>>arr[i];
    
    sort(arr, arr+n);
    sum+=arr[n-1];
    int j=n-2;
    n=n-2;
    int N=n;
    n=n/2;
    REP(i,0,n)
    {sum+= arr[j]+arr[j]; j--;}
    if(N%2==1)
    	sum+=arr[j];

    cout<<sum;


    
    


			
 
			
	
	return 0;
}


Measured memory_bytes: 4728
#include<iostream>
using namespace std;
//结构体中的字符存扑克牌的花色，数字存扑克牌的大小
typedef struct {
	char word;
	int value;
}Card;
//冒泡排序算法
void BubbleSort(Card a[], int n) {
	int i, j;
	for (i = 0; i < n; i++) {
		for (j = n - 1; j > i; j--) {
			if (a[j].value < a[j - 1].value)
			{
				swap(a[j], a[j - 1]);
			}
		}
	}
}
//选择排序算法
void SelectionSort(Card a[], int n) {
	int i, j, min;
	for (i = 0; i < n - 1; i++) {
		//第一层循环为无序区
		min = i;//k记录当前的下标，到时需要交换
		for (j = i + 1; j < n; j++) {
			//第二层循环为有序区
			if (a[j].value < a[min].value)
				min = j; //此时min便是最小的数
		}
		if (min != i) {
			//为了防止最小数有两个，即最外层for循环i是最小数，无序区也有一个最小数，这样交换过来排序便不再稳定
			swap(a[min], a[i]);
		}
	}
}
void Print(Card a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << a[i].word<<a[i].value;
	}
}
bool Stable(Card c1[], Card c2[] ,int n) {
	int i;
	for (i = 0; i < n; i++) {
		if (c1[i].word != c2[i].word)
			return false;
	}
	return true;
}
int main() {
	Card c1[100], c2[100];
	int n; cin >> n;
	for (int i = 0; i < n; i++)
		cin >> c1[i].word >> c1[i].value;
	for (int i = 0; i < n; i++)
		c2[i] = c1[i];
	BubbleSort(c1, n);
	SelectionSort(c2, n);
	Print(c1, n);
	cout << endl << "Stable" << endl;//冒泡排序得到的结论总是稳定的
	Print(c2, n);
	bool bl=Stable(c1, c2, n);
	if (bl)
		cout<<endl << "Stable" << endl;
	else
		cout<<endl << "Not stable" << endl;
	
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;

    vector<vector<int> > ss;
    rep(i, m) {
        int k;
        cin >> k;
        vector<int> s(k);
        rep(j, k) cin >> s[j];
        ss.push_back(s);
    }

    vector<int> p(m);
    rep(i, m) cin >> p[i];

    ll ans = 0;    
    rep(pat, 1 << n) {
        bool ok = true;
        rep (i, m) {
            auto& s = ss[i];
            int cnt = 0;
            rep(j, s.size()) {
                // s[j]のスイッチがついていたら
                if ((pat >> (s[j] -  1) ) & 1) {
                    cnt++;
                }
            }
           // cout << pat << " " << i << " " << cnt << endl;
            if (cnt % 2 != p[i] ) {
                ok = false;
                break;
            }
        }

        if (ok) {
            ans ++;
        }
    }

    put(ans);

    return 0;
}

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

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

  int N, K; cin >> N >> K;
  for (int i = 0; i < N; i++) { int A; cin >> A; }
  cout << (N + K - 3) / (K - 1) << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cctype>

using namespace std;


int main(){
int a,b,c;
	
	cin>>a>>b>>c;
	
	if((a*100+b*10+c)%4){//余りがあると1が建つのでnoが出力
		cout<<"NO"<<endl;
	}else cout<<"YES"<<endl;
	return 0;

}

Measured memory_bytes: 256
from itertools import groupby

s = input()
k = int(input())
a = [sum(1 for _ in g) for _, g in groupby(s)]
if len(a) == 1:
    print(len(s) * k // 2)
else:
    x, y = a[0], a[-1]
    b = (x + y) // 2 if s[0] == s[-1] else x // 2 + y // 2
    print(x // 2 + y // 2 + sum(x // 2 for x in a[1:-1]) * k + b * (k - 1))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int p[300001];
vector<int> G[300001];
vector<int> rG[300001];
int num[300001];
bool used[300001];
vector<int> vs;
int cmp[300001];

vector<int> group[300001];
set<int> s[300001];
int done[300001];

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]])dfs(G[v][i]);
	}
	vs.push_back(v);
}

void rdfs(int v,int k){
	used[v]=true;
	cmp[v]=k;
	for(int i=0;i<rG[v].size();i++){
		if(!used[rG[v][i]])rdfs(rG[v][i],k);
	}
}

int scc(){
	memset(used,0,sizeof(used));
	vs.clear();
	for(int v=0;v<n;v++){
		if(!used[v])dfs(v);
	}
	memset(used,false,sizeof(used));
	int k=0;
	for(int i=vs.size()-1;i>=0;i--){
		if(!used[vs[i]])rdfs(vs[i],k++);
	}
	return k;
}

bool check(int nv,int miniz){
	num[nv]=miniz;
	for(int i=rG[nv][0];i!=nv;i=rG[i][0]){
		s[i].clear();
		for(int j=0;j<G[i].size();j++){
			s[i].insert(num[G[i][j]]);
		}
		int mini=0;
		for(set<int>::iterator it=s[i].begin();it!=s[i].end();it++){
			if(mini!=*it)break;
			mini++;
		}
		num[i]=mini;
	}
	s[nv].clear();
	for(int i=0;i<G[nv].size();i++){
		s[nv].insert(num[G[nv][i]]);
	}
	int next=0;
	bool flag=true;
	for(set<int>::iterator it=s[nv].begin();it!=s[nv].end();it++){
		if(*it==miniz)flag=false;
		if(*it!=next && next!=miniz)flag=false;
		if(*it==next)next++;
	}
	if(next!=miniz)flag=false;
	return flag;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
		p[i]--;
		G[p[i]].push_back(i);
		rG[i].push_back(p[i]);
	}
	int k=scc();
	for(int i=0;i<n;i++){
		group[cmp[i]].push_back(i);
	}
	memset(num,-1,sizeof(num));
	for(int i=k-1;i>=1;i--){
		int mini=0;
		int nv=group[i][0];
		for(set<int>::iterator it=s[nv].begin();it!=s[nv].end();it++){
			if(mini!=*it)break;
			mini++;
		}
		num[nv]=mini;
		s[rG[nv][0]].insert(mini);
	}
	int nv=group[0][0];
	int mini1=0,mini2=1;
	for(set<int>::iterator it=s[nv].begin();it!=s[nv].end();it++){
		if(*it==mini1){
			mini1++;
			mini2++;
		}
		if(*it==mini2){
			mini2++;
		}
	}
	printf("%s\n",(check(nv,mini1)||check(nv,mini2))?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define ll long long
#define mod 1e9+7

using namespace std;

int main()
{
  string s;
  cin >> s;
  ll cnt = 0;
  char current = s[0];
  rep(i, s.size()) {
    if (s[i] != current) {
      current = s[i];
      ++cnt;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;
using ll = long long;

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

	if (N % 2) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < N / 2; ++i) {
		if (S[i] != S[N / 2 + i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef pair<int, int> pi;
#define SQ(a) (a) * (a)
#define deb(x) cout << #x << " = " << x << '\n'
#define deb2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
 
 
int main(int argc, char const *argv[])
{
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n>=30){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>

int main()
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	if(a==b and b==c)
	{
		printf("1");
	}
	else if(a==b and b!=c)
	{
		printf("2");
	}
	else if(a==c and a!=b)
	{
		printf("2");
	}
	else if(b==c and a!=b)
	{
		printf("2");
	}
	else if(a!=b and b!=c)
	{
		printf("3");
	}
	
}
	

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX = 1e5+10;

int N, M;
vector<int> X;
vector<int> diff;

int main(){
    cin >> N >> M;
    if (N >= M) {
        cout << 0 << endl;
        return 0;
    }
    X = vector<int>(M);
    for (int i = 0; i < M; i++) {
        cin >> X[i];
    }
    sort(X.begin(), X.end());

    long long ans = 0;
    for (int i = 1; i < M; i++) {
        diff.push_back(X[i] - X[i-1]);
        ans += X[i] - X[i-1];
    }
    sort(diff.begin(), diff.end());

    for (int i = 0; i < N-1; i++) {
        ans -= diff[M-2-i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if((a*b)%2==0) System.out.println("Even");
		else System.out.println("Odd");

	}

}


Measured memory_bytes: 26952
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=105;
//i_am_noob
int n,k;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> k;
	print1(min(n%k,k-n%k));
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,q;
int a[21];
int  aaa(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  return aaa(i+1,m)||aaa(i+1,m-a[i]);
}

int main(void){

  int m;
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d",&m);
    if(aaa(0,m))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}





Measured memory_bytes: 2084
#include <stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  int V[N], C[N];
  for(int i=0; i<N; i++){
    scanf("%d",&V[i]);
  }
  for(int i=0; i<N; i++){
    scanf("%d",&C[i]);
  }
  int ans=0;
  for(int i=0; i<N; i++){
    if(V[i]-C[i]>0){
      ans += (V[i]-C[i]);
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
n, k = list(map(int, input().split()))
hs = [0] + list(map(int, input().split())) 


max_val = sum([max(hs[i + 1] - hs[i], 0) for i in range(n)])
dp = [[max_val for _ in range(n + 1)] for _ in range(n + 1)]

dp[0][0] = 0
for i in range(1, n + 1):
	for j in range(1, n + 1):	
		dp[i][j] = min([dp[i - 1][l] + max(hs[j] - hs[l], 0) for l in range(j)])

print(min([dp[n - k][l] for l in range(n + 1)]))

Measured memory_bytes: 43484
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    int memo[n];
    for(int i=0;i<n;i++)
    {
        memo[i]=0;
    }
    memo[0]=0;
    memo[1]=abs(ar[1]-ar[0]);
    for(int i=2;i<n;i++)
    {
        memo[i]=min(memo[i-1]+abs(ar[i]-ar[i-1]),memo[i-2]+abs(ar[i]-ar[i-2]));
    }
    cout<<memo[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cstdio>
#include <cctype>
#include <queue>
#include <cmath>
#include <stack>
using namespace std;
const int inf = 0x3f3f3f3f, N = 20;

int e[N][N];
void floyd(int n)
{
    for(int k = 0; k <= n; k++)
        for(int i = 0; i <= n; i++)
            for(int j = 0; j <= n; j++)
            e[i][j] = min(e[i][k] + e[k][j], e[i][j]);
}
int main()
{
    int m;
    while(cin >> m, m) {
    for(int i = 0; i < 10; i++)
        for(int j = 0; j < 10; j++) {
            if(i == j) e[i][j] = 0;
            else e[i][j] = e[j][i] = inf;
        }
        int Max = 0;
        while(m--) {
            int x, y, l;
            scanf("%d%d%d", &x, &y, &l);
            if(x > Max) Max = x;
            if(y > Max) Max = y;
            e[x][y] = e[y][x] = l;
        }
        floyd(Max);
        int msum = inf, mp;
        int ms = 0;
        for(int i = 0; i <= Max; i++) {
            ms = 0;
            for(int j = 0; j <= Max; j++) {
                ms += e[i][j];
            }
            if(ms < msum) {
                msum = ms;
                mp = i;
            }
        }
        printf("%d %d\n", mp, msum);
    }
    return 0;
}

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

int main(){
    string s;cin>>s;
    if(s.size()==3)
        reverse(s.begin(), s.end());
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3564
fn main() {
  let n = get::val::<usize>();

  let mut dp = vec![0u64; 87];
  dp[0] = 2;
  dp[1] = 1;
  for k in  2 .. 87 {
    dp[k] = dp[k-2] + dp[k-1];
  }

  println!("{}", dp[n])
}


#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}


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

ll abs(ll a, ll b) {
  return a > b ? a - b : b - a;
}

int main() {
  ll a, v, b, w, t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;

  ll d1 = abs(a, b);
  ll d2 = (v - w) * t;

  if (d2 >= d1) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

/*
*/


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

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
int main()
{
   ll k,n;
   cin>>k>>n;
   ll a[n],b[n];
   ll s=0;
   ffor(i,0,n)
    cin>>a[i];
	ffor(i,1,n)
	b[i]=a[i]-a[i-1];
	b[0]=a[0]+k-a[n-1];
	ll m=-1;
	ffor(i,0,n)
	{
		s+=b[i];
		m=max(m,b[i]);
	}
	cout<<s-m;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007
 

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'C') {
			for (int j = i; j < s.length(); j++) {
				if (s[j] == 'F') {
					print("Yes"); return 0;
				}
			}
		}
	}
	print("No");




	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int a, b; cin>>a>>b;
    cout << max(0, a - 2 * b) << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
vector<vector<int>> getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
using namespace std;
long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

int main(){
	vector<string> A;
	int len = 0;
	string S;
	cin >> S;
	len += S.length();
	A.emplace_back(S);
	cin >> S;
	len += S.length();
	A.emplace_back(S);
	int odd = 1; // 1:odd, 0:even

	// cout << A[0] << " " << A[1] << endl;
	// cout << len << endl;
	int pos0 = 0;
	int pos1 = 0;
	rep(i,len)
		if(odd){
			cout << A[0][pos0++];
			odd = 0;
		}else{
			cout << A[1][pos1++];
			odd = 1;
		}
		cout << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	long int n,i;
	scanf("%ld",&n);
	long int d[100001]={0},l;
	for(i=0;i<n;i++)
	{
		scanf("%ld",&l);
		d[l]++;
	}
	long int a=0,k1,k=0;
	for(i=1;i<=100001;i++)
	{
		a+=d[i];
		if(a==n/2)
		{k1=i;break;}
		else if(a>n/2)
		{printf("%d",0);return 0;}
	}
	for(i=k1+1;;i++)
	{
		if(d[i]==0)
		{
			k++;
		}
		else
		{
			k++;
			printf("%ld",k);
			return 0;
		}
	}
}

Measured memory_bytes: 896
#include <iostream>

 

using namespace std;

int main()
{
   int a, b, temp, i;
   for(i=1; i<=3000; i++)
    { 
      cin >> a >> b;
       if(a==0 && b==0)
         break;
     if(a > b) 
        {
      
         temp = a;
         a = b;
         b = temp;
        } 
       
     cout << a << " " << b << endl;
    }  
}


Measured memory_bytes: 3064
n = int(input())
xy = []
for i in range(n):
    a = int(input())
    s = []
    for j in range(a):
        x, y = map(int, input().split())
        s.append([x, y])
    xy.append(s)

ans = 0
for bit in range(1, 2**n):
    flg = True
    # i人目の証言を検証する
    for i in range(n):
        if not flg:
            break

        # i人目が不親切の場合は検証する意味なし
        if not (bit >> i & 1):
            continue

        # i人目の各証言を確認
        for j in xy[i]:
            x = j[0]
            y = j[1]

            # 証言と矛盾していたらダメ
            if (bit >> (x - 1) & 1) ^ y:
                flg = False
                break
    if flg:
        ans = max(ans, bin(bit).count('1'))

print(ans)



Measured memory_bytes: 42224
//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

fn main() {
    input! {
        n: usize,
        p: [u64;n],
    }

    let mut st = p.clone();
    st.sort();

    if p == st {
        println!("YES");
        return;
    }

    for i in 0..n - 1 {
        for j in i + 1..n {
            let mut t = p.clone();
            t.swap(i, j);
            if t == st {
                println!("YES");
                return;
            }
        }
    }

    println!("NO");
}


Measured memory_bytes: 4352
N, Y = map(int,input().split())
a = -1
b = -1
c = -1
for i in range(N+1):
  for j in range(N+1-i):
    if i*9000 + j*4000 == Y - 1000*N:
      a = i
      b = j
      c = N-i-j
print(a, b, c)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;
int main()
{
    int n;
    double ax,ay,bx,by,cx,cy,x,y,r;
    double A1,B1,C1,A2,B2,C2;
    cin>>n;
    while(n--){
        cin>>ax>>ay>>bx>>by>>cx>>cy;
        A1=2*(bx-ax);
        B1=2*(by-ay);
        C1=ax*ax-bx*bx+ay*ay-by*by;
        A2=2*(cx-ax);
        B2=2*(cy-ay);
        C2=ax*ax-cx*cx+ay*ay-cy*cy;
        x=(B1*C2-B2*C1)/(A1*B2-A2*B1);
        y=(C1*A2-C2*A1)/(A1*B2-A2*B1);
        r=sqrt((ax-x)*(ax-x)+(ay-y)*(ay-y));
        printf("%.3f %.3f %.3f\n",x,y,r);
    }
    return 0;
}

Measured memory_bytes: 1244
sx, sy, tx, ty = map(int, input().split())
print(
       'L' + 'U' * (ty - sy + 1) + 'R' * (tx - sx + 1) + 'D' +
             'L' * (tx - sx    ) + 'D' * (ty - sy    )       +
       'D' + 'R' * (tx - sx + 1) + 'U' * (ty - sy + 1) + 'L' +
             'D' * (ty - sy    ) + 'L' * (tx - sx    )
      )

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

int main(){
	int n;
	int x=0;
	while (cin >> n){
		for (int i = 0; i < 10; i++){
			for (int j = 0; j < 10; j++){
				for (int k = 0; k < 10; k++){
					for (int l = 0; l < 10; l++){
						if (n == i + j + k + l){
							x = x + 1;
						}
					}
				}
			}
		}
		cout << x << endl;
		x = 0;
	}
}


Measured memory_bytes: 3008
using System;

class Program
{
    static void Main(string[] args)
    {
        var A = int.Parse(Console.ReadLine());
        var B = int.Parse(Console.ReadLine());
        var C = int.Parse(Console.ReadLine());
        var X = int.Parse(Console.ReadLine());
        var count = 0;
        var value = 0;

        for(int i=0; i<=A; i++)
        {
            // value = 500*i;
            // if(value == X) { ++count; }

            for(int j=0; j<=B; j++)
            {
                // value = 500*i + 100*j;
                // if(value == X) { ++count; }

                for(int k=0; k<=C; k++)
                {
                    value = 500*i + 100*j + 50*k;
                    if(value == X) { ++count; }

                    // value = 50*k;
                    // if(value == X) { ++count; }
                }
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>
int solve(char* key,int n1,char* s,int n2){
    int i,j,flag;
    int k;

    k=0;
    while(n1+k*(n1-1)<=n2){
	for(i=0;i<n2-(n1+k*(n1-1))+1;i++){
	    flag=1;
	    for(j=0;j<n1;j++){
		if(key[j]!=s[i+(k+1)*j]){
		    flag=0;
		    break;
		}
	    }
	    if(flag) return 1;
	}
	k++;
    } 
    return 0;
}

int main(void){
    int n,i,j;
    char name[30],s[101];
    int n1,n2,ans=0;

    scanf("%d",&n);
    scanf("%s",name);
    n1=strlen(name);
    for(i=0;i<n;i++){
	scanf("%s",s);
	n2=strlen(s);
	if(solve(name,n1,s,n2)){
	    ans++;
	}
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <string.h>
#define N 1010
char a[N];
char b[N];
int dp[N][N];
//int LCS(int i, int j){
//    if(i == -1 || j == -1) return 0;
//    if(a[i] == b[j]) return LCS(i-1, j-1) + 1;
//    else return LCS(i-1, j) > LCS(i, j-1) ? LCS(i-1, j) : LCS(i, j-1);
//}
int main(){
    int k;
    scanf("%d", &k);
    while(k--){
        scanf("%s", a);
        scanf("%s", b);
        int n = strlen(a);
        int m = strlen(b);
        for(int i = n-1; i >= 0; i--) a[i+1] = a[i];
        for(int i = m-1; i >= 0; i--) b[i+1] = b[i];
        int max = n > m ? n : m;
        for(int i = 0; i <= max; i++) dp[0][i] = dp[i][0] = 0;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                if(a[i] == b[j]) dp[i][j] = dp[i-1][j-1] + 1;
                else {
                    dp[i][j] = dp[i-1][j] > dp[i][j-1] ? dp[i-1][j] : dp[i][j-1];
                }
            }
        }
        printf("%d\n", dp[n][m]);
        //printf("%d\n", LCS(strlen(a)-1, strlen(b)-1));
    }
    return 0;
}


Measured memory_bytes: 6684
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("READ.txt", "r", stdin)
#define Write          freopen("OUTPUT.txt", "w", stdout)
#define INF            1000000007


void solve()
{
    int n;
    cin>>n;
    lll arr[n+3],ans=0;
    lll sum=0;
    for(int i=1;i<=n;i++)
    {
    	cin>>arr[i];
    }
    for(int i=1;i<=n;i++)
    {
       ans=ans+(sum*arr[i]);
       sum+=arr[i];
       sum%=INF;
       ans%=INF;
    }
    cout<<ans<<endl;
}

int main()
{
    fast
    #ifndef ONLINE_JUDGE
    Read;
    Write;
    #endif
    //sieve();
    //int cnt=1;
    //int t; cin>>t; while(t--) solve();
    solve();
}

Measured memory_bytes: 5228
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,K = LI()
    A = [0] + LI()

    his = [0] * (N+1)
    s = 1
    cnt = 1
    his[1] = 1
    while his[A[s]] == 0:
        s = A[s]
        cnt += 1
        his[s] = cnt


    if K >= cnt:
        s = A[s]
        cnt -= his[s] - 1

        k = (K - his[s] + 1) % cnt
    else:
        k = K
        s = 1
    for i in range(k):
        s = A[s]
    print(s)



if __name__ == '__main__':
    main()

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

//セグメント木
//全て添字で扱うこと
struct segment_tree {
  long long n; //vの要素数
  long long m; //葉の数
  vector<long long> v; //セグ木本体．ただの配列を使う
  long long id_e; //単位元

  //二項演算
  long long binary_op(long long a, long long b) {
    return gcd(a,b);//処理
  }

  //初期化関数．数列と単位元を受け取って初期化
  void init(vector<long long> a, long long b) {
    id_e = b;
    m = 1;
    while (m < a.size()) m *= 2; //aの項数以上の2べきのうち最小のものを求める
    n = 2 * m - 1;
    v.resize(n);
    for (long long i = 0; i < a.size(); i++) v[m - 1 + i] = a[i]; //葉(1段目)の値
    for (long long i = a.size(); i < m; i++) v[m - 1 + i] = id_e; //葉(1段目)の右端の0埋め
    for (long long i = m - 2; i >= 0; i--) { //2段目以降を順番に埋めていく
      v[i] = binary_op(v[2 * i + 1], v[2 * i + 2]);
    }
  }

  //ある項の値をbに書き換え
  void change(long long a, long long b) {
    a += m - 1;
    v[a] = b; //葉(1段目)を書き換え
    while ((a - 1) / 2 != a) { //2段目以降を順番に書き換え
      a = (a - 1) / 2;
      v[a] = binary_op(v[2 * a + 1], v[2 * a + 2]);
    }
  }

  //区間和の補助関数
  //cur:今見ている頂点の，配列vでの添字
  //[l, r]:v[cur]がカバーする区間
  long long seg_sub(long long a, long long b, long long cur, long long l, long long r) {
    if (a <= l && r <= b) return v[cur]; //今見ている頂点のカバーする区間が，[a, b]に完全に収まっている場合
    if (r < a || b < l) return id_e; //今見ている頂点のカバーする区間が，[a, b]と全く被っていない場合
    return binary_op( //今見ている頂点のカバーする区間が，[a, b]と一部被っている場合
      seg_sub(a, b, 2 * cur + 1, l, (l + r) / 2),
      seg_sub(a, b, 2 * cur + 2, (l + r) / 2 + 1, r)
    );
  }

  //区間[a, b]の和
  //最上段の頂点から子へ再帰していく
  long long partial_sum(long long a, long long b) {return seg_sub(a, b, 0, 0, m - 1);}
};

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

  segment_tree seg;
  seg.init(a, 0);

  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    seg.change(i, 0);
    ans = max(ans, seg.partial_sum(0,n-1));
    seg.change(i, a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6904
n,m = map(int,input().split())
x = list(map(int,input().split()))

if n >= m:
    print(0)
    exit()

x.sort()

dists = []
point = x.pop(0)
for xs in x:
    dists.append(xs-point)
    point = xs
dists.sort(reverse=True)

print(sum(dists[(n-1):]))



Measured memory_bytes: 20492
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],z,zs;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    z=1;
    for(int i=2;i<=n;i++)
        if(a[i]==a[i-1]) z=(z+1)%2;
        else{ zs+=z; z=1;}
    zs+=z%2;
    cout<<zs<<endl;
    return 0;
}

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

int a, b, n;
int field[20][20];
bool nothough[20][20];
int main()
{
  while(cin >> a >> b && (a || b)){
    memset(nothough, false, sizeof nothough);
    memset(field, 0, sizeof field);
    cin >> n;
    for(int i = 0; i < n; i++){
      int x, y;
      cin >> x >> y;
      nothough[x][y] = true;
    }

    field[1][1] = 1;
    for(int i = 1; i <= a; i++)
      for(int j = 1; j <= b; j++)
	if(!nothough[i][j])
	  field[i][j] += field[i - 1][j] + field[i][j - 1];
  
    cout << field[a][b] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)

const int MX = 3e6 + 7;

bool prm[MX];

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    ll n;
    cin >> n;
    vector<ll> v;
    repp(i, 2, sqrt(n)){
        if(n % i == 0){
            ll c = 0;
            while(n % i == 0) n /= i, c++;
            v.pb(c);
        }
    }

    if(n > 1) v.pb(1);
    ll res = 0;
    for(auto pr : v){
        ll v = 1, j = 2;
        while(1){
            if(v + j > pr) break;
            v += j++;
        }
        res += j - 1;
    }
    cout << res;
}
 


Measured memory_bytes: 3756
#include <iostream>

int main() {
    int a;
    int b;
    int c;
    int count = 0;

    std::cin >> a >> b >> c;
    if(a == b && a == c){
        count = 1;
    } else if(a == b || a == c || b == c){
        count = 2;
    } else {
        count = 3;
    }

    std::cout << count << std::endl;
}


Measured memory_bytes: 256
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
X = [0] * (N + 1)
for i in range(N):
    X[i + 1] = X[i] + A[i] % M
    X[i + 1] %= M
X = X[1:]
d = defaultdict(int)
for x in X:
    d[x] += 1
ans = d[0]
for k, v in d.items():
    if 2 <= v:
        ans += v * (v - 1) // 2
print(ans)

Measured memory_bytes: 62576
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			char[] s = sc.next().toCharArray();
			int n = s.length -1;
			long ans=0;
			for(int bits = 0; bits < (1 << n); bits++) {
				long num = 0;
				long a=s[0]-'0';
				for(int i = 0; i < n; i++) {
					if((bits & (1<<i)) != 0) {
						num+=a;
						a=0;
					}
					a=a*10+s[i+1]-'0';
				}
				num+=a;
				ans+=num;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21716