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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll a,b,c,s,t,x,y,z;
 ll A,B,C,S,T,X,Y,Z;

 ll count;

 long double pi=3.14159265358979323846;

 string N,M;

unsigned long long D;

signed main(){

	cin>>N>>M;

	a=0;
	b=0;
	REP(i,N.size()-M.size()+1){
		t=i;
		REP(j,M.size()){
			if(N[j+t]==M[j]) a++;
		}
		b=max(a,b);
		a=0;
	}

	cout<<M.size()-b;

	return 0;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n;
    cin >> n;

    vector<ll> dp(n+2, 1);

    for (int i=2; i<n+2; i++) {
        for (int j=i; j<n+2; j+=i) {
            dp[j]++;
        }
    }

    ll sm = 0;
    for (int i=1; i<n+1; i++) sm += i*dp[i];
    cout << sm << "\n";
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    cout << (N + 1) / 2 << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())
s = []
for i in range(n):
    x = input()
    y = collections.Counter(x)
    x = tuple(sorted(list(y.items())))
    s.append(x)
s_count = collections.Counter(s)
s_num = list(s_count.values())
ans = 0
for i in s_num:
    z = 0
    if i >= 2:
        z = int(i*(i-1)/2)
    ans += z
print(ans)

Measured memory_bytes: 78604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define maxn 2005

ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    else gcd(b,a%b);
}
int main()
{
  ll a,b;
  cin>>a>>b;
  cout<<a*b/gcd(a,b);
    return 0;
}


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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> div(0);

  for(int i = 1; i <= 100; i++){
    if(A % i == 0 && B % i == 0)
      div.push_back(i);
  }
  
  cout << div[div.size()-K] << endl;
  return 0;

}

Measured memory_bytes: 256
num = gets.to_i

a = 0
for i in 1..Math.sqrt(num) do
    if num % i == 0
        a = i
    end
end
b = num / a

x = a if a >= b
x = b if a < b

ans = 0
while x >= 1 do
    x /= 10
    ans += 1
end

puts ans


Measured memory_bytes: 1916
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 1e9 + 7;

int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	ll sa = 0, sb = 0, sp = 0;
	vi a, b, al;
	cin >> n;
	for (int x, y, i = 0; i < n; i++) {
		cin >> x >> y;
		a.pb(x);
		b.pb(y);
		sa += x, sb += y;
	}
	for (auto i : a)
		al.pb(i);
	for (auto i : b)
		al.pb(i);
	sort(all(al));
	ll ans = min(sa, sb);
	for (int i = 0; i < n; i++) {
		sp += al[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] > b[i])
			swap(a[i], b[i]);
		ll t = sp;
		int lst = n - 1;
		if (al[lst] >= a[i]) {
			t += -a[i] + al[++lst];
		}
		if (al[lst] >= b[i]) {
			t += -b[i] + al[++lst];
		}
		ans = min(ans, t);
	}
	cout << ans << "\n";
}


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

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> dis(N);
  for (int i = 0; i < N; i++){
    cin >> dis[i];
  }
  
  int sum = 0;
  for (int i = 0; i < N + 1; i++){
    if (i == 0){
      sum += 0;
    }
    else{
      sum += dis[i - 1];
    }
    
    if (sum > X){
      cout << i << endl;
      return 0;
    }
  }
  
  cout << N + 1 << endl;
}
    


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=n;i>0;i--){
        if(i==1){
            cout<<a[i-1];
        }else{
            cout<<a[i-1]<<" ";
        }
    }
    cout<<endl;
}



Measured memory_bytes: 3076
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else if ((a + b) % 2 == 1) {
		cout << (a + b + 1) / 2 << endl;
	}
}

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


int main() {
	
	string a,b;
	cin >> a >> b;
	
	int alen = a.length();
	int blen = b.length();
	
	if (alen != blen){
		
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		
		for (int i=alen; i<max(alen,blen); i++) a.push_back('0');
		for (int i=blen; i<max(alen,blen); i++) b.push_back('0');
		
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		
	}
	if (a > b) cout << "GREATER" << endl;
	else if (a < b) cout << "LESS" << endl;
	else cout << "EQUAL" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>

using namespace std;

int const M_MAX = 200000;
int N, M;
int a[M_MAX + 1];
int b[M_MAX + 1];
int f[M_MAX + 1];
int g[M_MAX + 1];

int main() {
  scanf("%d %d", &N, &M);
  int f_c = 0;
  map<int, int> mp;
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &a[i], &b[i]);
    if (a[i] == 1) {
      f[f_c] = b[i];
      f_c++;
    }
    if (b[i] == N) mp[a[i]]++;
  }

  bool possible = false;
  for (int i = 0; i < f_c; i++) {
    int x = f[i];
    if (mp[x]) {
      possible = true;
      break;
    }
  }
  printf(possible ? "POSSIBLE\n" : "IMPOSSIBLE\n");
}



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

int main()
{
	int H, N;
	while (cin >> H >> N, H | N) {
		vector<vector<string>> c(H + 10, vector<string>(2, string(2, '.')));
		vector<vector<vector<string>>> b(N, vector<vector<string>>(2, vector<string>(2)));
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				c[0][i][j] = '#';
			}
		}
		for (int i = 0; i < H; i++) {
			cin >> c[i + 1][0] >> c[i + 1][1];
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 2; j++) {
				for (int k = 0; k < 2; k++) {
					cin >> b[i][j][k];
				}
			}
		}
		int res = 0;
		int S = 1;
		for (int i = 0; i < N; i++) S *= 9;
		for (int s = 0; s < S; s++) {
			bool ok = true;
			int del = 0;
			int tmp = s;
			auto state = c;
			for (int i = 0; i < N; i++) {
				int dx = tmp % 3 - 1, dy = tmp / 3 % 3 - 1;
				for (int d = 0; d < 2; d++) {
					for (int x = 0; x < 2; x++) {
						for (int y = 0; y < 2; y++) {
							int tx = x + dx, ty = y + dy;
							if (b[i][d][x][y] == '#' && (tx < 0 || 2 <= tx || ty < 0 || 2 <= ty)) {
								ok = false;
								break;
							}
						}
					}
				}
				if (!ok) break;
				int h = H + 8;
				bool f = true;
				do {
					h--;
					for (int d = 0; d < 2; d++) {
						for (int x = 0; x < 2; x++) {
							for (int y = 0; y < 2; y++) {
								int tx = x + dx, ty = y + dy;
								if (b[i][d][x][y] == '#' && state[h + d][tx][ty] == '#') {
									f = false;
								}
							}
						}
					}
				} while (f);
				h++;
				for (int d = 0; d < 2; d++) {
					for (int x = 0; x < 2; x++) {
						for (int y = 0; y < 2; y++) {
							int tx = x + dx, ty = y + dy;
							if (b[i][d][x][y] == '#') {
								state[h + d][tx][ty] = '#';
							}
						}
					}
				}
				for (int d = 1, td = 1; d < H + 10; d++) {
					bool filled = true;
					for (int x = 0; x < 2; x++) {
						for (int y = 0; y < 2; y++) {
							if (state[d][x][y] != '#') {
								filled = false;
							}
						}
					}
					if (filled) {
						for (int x = 0; x < 2; x++) {
							for (int y = 0; y < 2; y++) {
								state[d][x][y] = '.';
							}
						}
						del++;
					}
					else {
						if (d != td) swap(state[d], state[td]);
						td++;
					}
				}
				tmp /= 9;
			}
			if (ok) res = max(res, del);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int A, B, C, D, E;
int main() {
  cin >> A >> B >> C >> D >> E;
  cout << min({A, B, C}) + min(D, E) - 50 << "\n";
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll s[2222][2222];
ll f[2222][2222];

int main(void) {
  ll i, j, k;
  
  ll N, K;
  cin >> N >> K;
  ll x[MAX], y[MAX];
  
  
  for(i=0; i<N; i++) {
    ll x, y;
    char c;
    cin >> x >> y >> c;
    x%=K*2; y%=K*2;
    if(c=='W') (y+=K)%=K*2;
    x++; y++;
    f[x][y]++;
  }
  
  
  for(i=1; i<=K*2; i++) for(j=1; j<=K*2; j++)
    s[i][j]+=s[i][j-1]+f[i][j];
  for(j=1; j<=K*2; j++) for(i=1; i<=K*2; i++)
    s[i][j]+=s[i-1][j];
  
  ll ans=0;
  for(i=1; i<=K+1; i++) {
    for(j=1; j<=K+1; j++) {
      ll t=0;
      t+=s[i-1][j-1];
      t+=s[i-1][K*2]-s[i-1][j+K-1];
      t+=s[i+K-1][j+K-1]-s[i-1][j+K-1]-s[i+K-1][j-1]+s[i-1][j-1];
      t+=s[K*2][j-1]-s[i+K-1][j-1];
      t+=s[K*2][K*2]-s[K*2][j+K-1]-s[i+K-1][K*2]+s[i+K-1][j+K-1];
      chmax(ans, max(t, N-t));
    }
  }
  
  pt(ans);
  
}




Measured memory_bytes: 71936
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();

      if(a!=b&&a!=c){
          System.out.println(a);
      }
      if(b!=a&&b!=c){
          System.out.println(b);
      }
      if(c!=a&&c!=b){
          System.out.println(c);
      }
  }
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); 
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  for (int i  = 0; i < n; i++)
    cin >> x[i];
  int sol = INT_MAX;
  for (int i = 0; i <= n-k; i++) {
    int dist = 0;
    int l = x[i], r = x[i+k-1];
    if (l <= 0 and r <= 0) 
      dist = -l;
    else if (l >= 0 and r >= 0) dist = r;
    else dist = 2*min(-l,r)+max(-l,r);
    sol = min(sol, dist);
  }
  cout << sol << endl;
  return 0;
}



Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
using namespace std;
int head[101000],NUM_EDGE;
bool BOOK[101000];
long long DIS[101000];
struct edge
{
	int TO;
	int NEXT;
	int DIS;
}EDGE[201000];
void ADD(int FROM,int TO,int DIS)
{
	EDGE[++NUM_EDGE].NEXT=head[FROM];
	EDGE[NUM_EDGE].TO=TO;
	EDGE[NUM_EDGE].DIS=DIS;
	head[FROM]=NUM_EDGE;
}
int read()
{
	int x=0,f=1; char c=getchar();
	while (c>'9'||c<'0') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+(c-'0'); c=getchar();}
	return x*f;
}
void DFS(int X) {
	for (int i=head[X]; i; i=EDGE[i].NEXT)
	if (BOOK[EDGE[i].TO]==0) {
		BOOK[EDGE[i].TO]=1;
		DIS[EDGE[i].TO]=DIS[X]+EDGE[i].DIS;
		DFS(EDGE[i].TO);
	}
}
int N,Q,K,U,V,W,X[101000],Y[101000],INF=111199999,MIN;
int main()
{
	N=read();
	for (int i=1; i<=N-1; i++) {
		U=read(); V=read(); W=read();
		ADD(U,V,W); ADD(V,U,W);
	}Q=read(); K=read();
	BOOK[K]=1;
	DFS(K);		
	for (int i=1; i<=Q; i++) {
		X[i]=read(); Y[i]=read(); printf("%lld\n",DIS[X[i]]+DIS[Y[i]]);
	}
	return 0;
}

Measured memory_bytes: 9344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC131B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int N = int.Parse(input[0]);
            int L = int.Parse(input[1]);
            int[] apple = new int[N];
            for (int i = 0; i < N;i++)
            {
                apple[i] = L + i;
            }
            int sum = apple.Sum();//全合計
            int min = 200 + 100;//大きい数を入れておく
            int memo = 0;
            for (int i = 0; i < N; i++)
            {
                if (min>Math.Abs(apple[i]))
                {
                    min = Math.Abs(apple[i]);
                    memo = i;//どのリンゴを食べたか
                }
            }
            Console.WriteLine(sum-apple[memo]);

        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];}
    	int s=0;
    	 for(int i=0;i<n;i++){
    	s = (s^a[i]);
    }
    //s/=4;
    for(int i=0;i<n;i++){
    	cout<<(s^(a[i]))<<" ";
	}
}

Measured memory_bytes: 4300
import java.util.*;
class Main {
 
	//最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int n = sc.nextInt();
		if(n >= 30){
			System.out.println("Yes");
		} else System.out.println("No");
		}
	}

Measured memory_bytes: 35604
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;  
        double area = r*r*pi;
        double length = 2*pi*r;
        System.out.printf("%f %f", area, length);
    }
}


Measured memory_bytes: 28488
#include <bits/stdc++.h>
using namespace std;
int n,h[200001];
long long res,f[200001],s[200001],a[200001];

void up(int k,long long w)
{
    for(int i=k;i<=n;i+=i&-i)
        s[i]=max(s[i],w);
}

long long get(int k)
{
    long long ans=0;
    for(int i=k;i>=1;i-=i&-i)
        ans=max(s[i],ans);
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("test.inp","r",stdin);
    freopen("test.out","w",stdout);
#endif // LOCAL
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&h[i]);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)
    {
        f[i]=get(h[i]-1)+a[i];
        up(h[i],f[i]);
        res=max(res,f[i]);
    }
    cout<<res;
}


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

#define int            long long int
#define float          long double
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define inf            1e18
#define set_pre(x,y)   fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
using namespace std;
int power(int x, int y, int p)
{
    int 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 modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main(){
    int n;
    cin>>n;
    vector<float>p(n,0);
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    float dp[n+1][n+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i>=j)
            {
                if(j==0)
                    dp[i][j]=dp[i-1][j]*(1-p[i-1]);
                else{
                    dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*(p[i-1]);
                }
            }
        }
    }
    float ans=0;
    for(int j=n/2+1;j<=n;j++)
        ans+=dp[n][j];
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 140928
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
using namespace std;
int main(){
  int N,ans=0;
  cin >> N;
  for(int i=0;i<50;i++){
    for(int j=0;j<50;j++){
      if(4*i+7*j==N){
        ans++;
        break;
       }
     }
  }
  if(ans==0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#define mod 1000000007
using namespace std; 

int main(){
    string s; cin >> s;
	vector<char> A;
	vector<char> B;
	long long q; cin >> q;
	int a=0;
	int t,f;
	char c;
	for (int i=0;i<q;i++){
		cin >> t;
		if (t==1){
			if (a) a=0;
			else a=1;
		}
		else {
			cin >> f >> c;
			if (a){
				if (f==1) B.push_back(c);
				else A.push_back(c);
			}
			else{
				if (f==1) A.push_back(c);
				else B.push_back(c);
			}
		}
	}
	if (a) {
		reverse(B.begin(),B.end());
		reverse(s.begin(),s.end());
		for (auto u : B) cout << u;
		cout << s;
		for (auto u : A) cout << u;
	}
	else {
		reverse(A.begin(),A.end());
		for (auto u : A) cout << u;
		cout << s;
		for (auto u : B) cout << u;
	}
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define find(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));

  ll ans = 0;
  string s; cin >> s;
  string t = "CODEFESTIVAL2016";
  for (int i = 0; i < s.size(); i++) {
    // cout << s[i] << " " << t[i] << endl;
    if (s[i] != t[i]) ans++;
  }
  outl(ans)
}


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

int main() {
    int64_t N;
    cin >> N;
    int64_t ans = 0;
    if ( N % 2 == 1 ){
        ans = 0;
    } else {
        int64_t x = 10;
        while ( x <= N ){
            ans = ans + ( N / x );
            x = 5 * x;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n * 800 - (n / 15) * 200 << "\n";
    return 0;
}


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

/*  using namespace  */
using namespace std;

/*  local var  */
int a,b,n;
vector<int> g[100005];
int dist_Fennec[100005];
int dist_Sunuke[100005];

/*  define  */
#define loop(i,j) for(int i = 0; i < j; i++)
#define scan1(d) scanf("%lld",&d);
#define scan2(a,b) scanf("%lld %lld",&a,&b);

/*  typedef  */
typedef long long ll;

/*  function  */
void dfs(int r,int f ,int d, int dist[])
{
	dist[r]=d;
	loop(x,g[r].size()){
		if(g[r][x]!=f) dfs(g[r][x],r,d+1,dist);
	}
}
/*  main program  */
int main()
{
	
	int num;
	cin>>num;
	int d;
	int cnt=0;
	loop(i,num){
		cin>>d;
		while(d%2==0){d/=2;cnt++;}
	}
	cout<<cnt<<endl;
}
	

Measured memory_bytes: 2560
import java.util.*;

public class Main{

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] N = new int[5];
		for(int i = 0 ; i < 5 ; i++){
			N[i] = scanner.nextInt();
		}
		hikaku(N[0],N[1],N[2],N[3],N[4]);
		//scanner.close;

	}

	public static void hikaku(int W, int H , int x , int y , int r) {
		if((x - r) < 0){
			System.out.println("No");
		}
		else if((y - r) < 0){
			System.out.println("No");
		}
		else if((x + r) > W){
			System.out.println("No");
		}
		else if((y + r) > H){
			System.out.println("No");
		}
		else{
			System.out.println("Yes");
		}
	}

	
}

Measured memory_bytes: 26248
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};
const MMMOD: isize = 1_000_000_007;
#[fastout]
fn main() {
    input!(n: isize);

    let ans =
        powmod(10, n) + powmod(9, n).wrapping_neg() + powmod(9, n).wrapping_neg() + powmod(8, n);

    println!("{}", (ans % MMMOD + MMMOD) % MMMOD);
}

fn powmod(x: isize, y: isize) -> isize {
    let mut res = 1;
    for _i in 0..y {
        res = res * x % MMMOD;
    }
    res
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner s  = new Scanner(System.in);
        String str = s.nextLine();
        String up  = str.toUpperCase();
        String low = str.toLowerCase();
        int i;
        for(i=0;i<str.length();i++){
            if(str.charAt(i)==up.charAt(i))System.out.print(low.charAt(i));
            else System.out.print(up.charAt(i));
        }
        System.out.println();
    }
}


Measured memory_bytes: 26924
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    std::string S, T;
    std::cin >> S >> T;
    int64_t size = S.size();

    int64_t ans = 0;
    for (int64_t i = 0; i < size; i++)
    {
        if (S[i] != T[i]) ans++;
    }
    std::cout << ans << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 3780
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD = 1000000007
#define INF (1e9)
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll N;
    cin >> N;
    if (N <= 999) print("ABC");
    else print("ABD");
    return 0;
}


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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
#endif
}

const int Mod = 1e9 + 7;

int fpm(int x, int power) {
	int res = 1;
	for (; power; power >>= 1, x = 1ll * x * x % Mod)
		if (power & 1) res = 1ll * res * x % Mod;
	return res;
}

const int N = 3010;

int d[N], f[N], tot;

int main () {

	File();

	int n = read(), k = read();

	For (i, 1, sqrt(n)) if (!(n % i)) {
		d[++ tot] = i;
		if (i != n / i) d[++ tot] = n / i;
	}
	sort(d + 1, d + tot + 1);

	int ans = 0;
	For (i, 1, tot) {
		f[i] = fpm(k, (d[i] + 1) / 2);
		For (j, 1, i - 1)
			if (!(d[i] % d[j])) 
				(f[i] += Mod - f[j]) %= Mod;
		ans = (ans + 1ll * f[i] * (d[i] / (2 - (d[i] & 1)))) % Mod;
	}
	printf ("%d\n", ans);

    return 0;

}


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

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);


	int n, a[10], b[10], x[10];
	cin >> n;
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	for(int i = 0; i < n; ++i)
		cin >> b[i];
	for(int i = 0; i < n; ++i)
		x[i] = i + 1;
	int idx1 = 0, idx2 = 0, left, right;
	do{
		idx1++;
		bool ok = true;
		for(int i = 0 ; i < n; ++i)
			if(x[i] != a[i])
				ok = false;
			if(ok){
				left = idx1;
			}
	}while(next_permutation(x, x + n));
	sort(x + 0, x + n);
		do{
		idx2++;
		bool ok = true;
		for(int i = 0 ; i < n; ++i)
			if(x[i] != b[i])
				ok = false;
			if(ok){
				right = idx2;
			}
	}while(next_permutation(x, x + n));
	cout << abs(left - right) << '\n';
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 100007;

inline void failure(){puts("Impossible");exit(0);}

int n;
lint lim,val[_]={0};

int main()
{
	n=ty(),lim=ty();
	for(int i=1;i<=n;i++)val[i]=ty();
	for(int i=1;i<n;i++)
	{
		if(val[i]+val[i+1]<lim)continue;
		puts("Possible");
		for(int j=1;j<i;j++)printf("%d\n",j);
		for(int j=n-1;j>=i;j--)printf("%d\n",j);
		return 0;
	}
	failure();

	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>

#define COPY_ARR(a, b, n)         \
    for (int i = 0; i < n; i++) { \
        a[i] = b[i];              \
    }

int main(void)
{
    char s[100005];
    scanf("%s", s);

    long reminder[13] = { 1 };

    int s_len = strlen(s);

    int position = 1;

    const int mod = 1000000007;
    for (int i = s_len - 1; i >= 0; i--) {
        long new_reminder[13] = { 0 };
        if (s[i] == '?') {
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 13; k++) {
                    new_reminder[(j * position + k) % 13] += reminder[k];
                    new_reminder[(j * position + k) % 13] %= mod;
                }
            }
        } else {
            int j = s[i] - '0';
            for (int k = 0; k < 13; k++) {
                new_reminder[(j * position + k) % 13] += reminder[k];
                new_reminder[(j * position + k) % 13] %= mod;
            }
        }
        position *= 10;
        position %= 13;
        COPY_ARR(reminder, new_reminder, 13);
    }

    printf("%ld\n", reminder[5]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int path[100010];
vector<int> g[100010];
int ans;
int dp[100010];
bool vis[100010];
int indeg[100010];
void dfs(int n) {
    vis[n] = true;
    for (int i=0; i < g[n].size(); i++) {
        int node = g[n][i];
        dp[node] = max(dp[node], dp[n]+1);
        ans = max(ans, dp[node]);
        indeg[node]--;
        if (indeg[node]==0) dfs(node);
    }
}
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,u,v;
    cin >> n >> m;
    while (m--) {
        cin >> u >> v;
        g[u].push_back(v);
        indeg[v]++;
    }
    for (int i=1; i <= n; i++) 
        if (!vis[i] && indeg[i]==0) dfs(i);
    cout << ans << "\n";
    return 0;
}

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

public class Main {

	public static void main(String[] args) {

		int count = 0;
		String check;
		Scanner sc = null;
		try {
			sc = new Scanner(System.in);

			check = sc.next();

			//??????????????¬????????§??????????´?
			ArrayList<String> textList = new ArrayList<String>();
			while (sc.hasNext()) {
				String word = sc.next();

				//??????????????????
				if (!word.equals("END_OF_TEXT")) {
					word = word.toLowerCase();

					textList.add(word);
				} else {
					break;
				}
			}
			//??????????????????????????????????????§??????
			for (int i = 0; i < textList.size(); i++) {

				if (textList.get(i).equals(check)) {
					count++;
				}
			}
			System.out.println(count);

		} finally {
			sc.close();
		}
	}

}

Measured memory_bytes: 26364
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

const ll INF = 1e9;

int main() {
    int n;
    cin >> n;
    ll h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    ll dp[n];
    for (int i = 0; i < n; i++) {
        dp[i] = INF;
    }

    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    OUT(dp[n - 1]);
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

template< typename T >
T mod_pow(T x, T n) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ret;
}

int main(void) {
    string L;
    cin >> L;
    int64_t l = L.size();

    int64_t ans = 0;
    int64_t cnt = 0;
    for(int i=0; i<l; i++) {
        if(L[i] == '1') {
            ans += mod_pow(3L, l-1-i) * mod_pow(2L, cnt);
            ans %= MOD;
            cnt++;
        }
    }

    ans += mod_pow(2L, cnt);
    ans %= MOD;

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(std::string S){
  cout<<S.substr(0,3)<<endl;;
}

int main(){
  cout<<setprecision(1000);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3632
# March
n = int(input())
s = []
for i in range(n):
    s.append(input()[0])
li = ['M', 'A', 'R', 'C', 'H']
ans = 0
for _ in range(5):
    a = li.pop()
    li2 = li.copy()
    if a in s:
        for _ in range(len(li)):
            b = li2.pop()
            if b in s:
                for c in li2:
                    ans += s.count(a) * s.count(b) * s.count(c)
print(ans)


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

string s;

int main(){
	cin>>s;
	if(s.length()<26){
		for(char c='a';c<='z';++c)
			if(s.find(c)==-1){
				cout<<s<<c<<endl;
				return 0;
			}
	}
	else{
		set<char> x;
		while(!s.empty()){
			char c=s.back();
			x.insert(c);
			s.pop_back();
			if(c!=*x.rbegin()){
				cout<<s<<*x.upper_bound(c)<<endl;
				return 0;
			}
		}
		puts("-1");
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int(input())
    a = list(map(int, input().split()))
    arr = [0]*(10**6 + 1)
    for x in a:
        if arr[x] == 0:
            for i in range(x, 10**6 + 1, x):
                arr[i] += 1
        else:
            arr[x] += 1
    ans = 0
    for i in a:
        if arr[i] == 1:
            ans += 1
    print(ans)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 34088
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int A, B; cin >> A >> B;
    int ans = 1 ^ 2 ^ 3 ^ A ^ B;
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))

print(dp[N-1])

Measured memory_bytes: 13980
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
    int d;
    cin>>d;
    switch(d){
        case 25:
        cout<<"Christmas"<<endl;
        break;
        case 24:
        cout<<"Christmas Eve"<<endl;
        break;
        case 23:
        cout<<"Christmas Eve Eve"<<endl;
        break;
        case 22:
        cout<<"Christmas Eve Eve Eve"<<endl;
        break;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public string S, T;

        public void Run()
        {
            N = Input.ReadInt();
            S = Console.ReadLine();
            T = Console.ReadLine();

            int overlap = 0;
            int overlapMax = Math.Min(S.Length, T.Length);
            for (int o = overlapMax; o >= 1; o--)
            {
                bool flg = true;
                for (int j = 0; j < o; j++)
                {
                    if (T[j] != S[S.Length - o + j])
                    {
                        flg = false;
                        break;
                    }
                }

                if (flg)
                {
                    overlap = o;
                    break;
                }
            }

            Console.WriteLine(S.Length + T.Length - overlap);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

vector<vector<bool>> visited;
int dx[8]={-1,-1,0,1,1,1,0,-1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
int n,m;
int dfs(int x,int y,vector<vector<int>> field){
    if(visited[x][y])return 0;
    visited[x][y]=true;
    int ret=1;
    for(int i=0;i<8;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(nx<0||ny<0||nx>=n||ny>=m)continue;
        if(visited[nx][ny]==false&&field[nx][ny]){
            ret=dfs(nx,ny,field);
        }
    }
    return ret;
}
int main(void){
    vector<int> ans;
    while(1){
        cin>>m>>n;
        if(n==0&&m==0)break;
        vector<vector<int>> field(n,vector<int>(m));
        rep(i,0,n){
            rep(j,0,m){
                cin>>field[i][j];
            }
        }
        visited=vector<vector<bool>>(n,vector<bool>(m));
        int ret=0;
        rep(i,0,n){
            rep(j,0,m){
                if(field[i][j]){
                    ret += dfs(i,j,field);
                }
            }
        }
        ans.push_back(ret);
    }
    for(auto i:ans){
        cout<<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 28444
n, a, b = list(map(int, input().split()))

mod = 10**9 + 7

import time
start = time.time()

# xの逆元を求める。フェルマーの小定理より、 x の逆元は x ^ (mod - 2) に等しい。計算時間はO(log(mod))程度。
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
	return pow(x, mod-2, mod)

modinv_table = [-1] * (b+1)
for i in range(1, b+1):
    modinv_table[i] = modinv(i)

end = time.time()
# print("time: ", end - start)

def binomial_coefficients2(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table[i + 1]
        ans %= mod
    return ans

# (2 ** n - 1) - nCa - nCb
ans = pow(2, n, mod) - 1

ans -= (binomial_coefficients2(n, a) + binomial_coefficients2(n, b))
print(ans % mod)


# print(binomial_coefficients2 (5, 2) % mod)


Measured memory_bytes: 10944
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
typedef vector<pii> vpii;
#define reps(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define all(g) (g).begin(),(g).end()
#define pb push_back
const int mod = 1e9 + 7;
#define INF 1<<25

int n;
int a[100100];

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

    cin >> n;
    rep(i,n) {
        cin >> a[i];
        a[i]--;
    }
    sort(a,a+n);
    reverse(a,a+n);
    int c = 0;

    while(c + 1 < n && c+1 <= a[c+1]){
        c++;
    }
    int d = a[c] - c;
    int e = 0;

    for(int i = c+1;i < n;i++){
        if (a[i] >= c) e++;
    }

    if (d % 2 || e % 2) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	int ans=0;
	string s;
	cin >> s;

	for(int i=0;i<s.size();i++){
		if(s[i]=='+'){
			ans++;
		}
		else{
			ans--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];

	LL sum = 0;
	rep(i, N) sum += A[i];

	LL t = 0;
	std::vector<LL>ans(N);
	for (LL i = 1; i < N; i += 2) t += A[i] * 2;
	ans[0] = sum - t;
	for (LL i = 1; i < N; ++i) ans[i] = A[i - 1] * 2 - ans[i - 1];

	rep(i, N) out << ans[i] << (i + 1 < N ? " " : "\n");
}


Measured memory_bytes: 2816
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

VI e[100001];

int dfs(int now){
    int m = e[now].size();
    if (m == 0) return 0;
    VI d;
    REP(i,m){
        int next = e[now][i];
        d.push_back(dfs(next));
    }
    sort(ALL(d));
    int res = 0;
    REP(i,m) res = max(res, d[i] + m - i);
    return res;
}

int main() {
    int n;
    cin >> n;
    REP(i,n-1){
        int x;
        scanf("%d", &x);
        e[x-1].push_back(i+1);
    }

    cout << dfs(0) << endl;

    return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; 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()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int h, w;
	cin >> h >> w;
 
	char c;
	int count = 0;
	REP(i, h){
		REP(j, w){
			cin >> c;
			if (c == '#') count++;
		}
	}
 
	if (count == h + w - 1) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N,M,i,j,minj,sum,tmp,flag;
    int A[100];
    double b;
    
    scanf("%d",&N);
    scanf("%d",&M);
    
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    
    sum=0;
    
    for(i=0;i<N;i++){
        sum=sum+A[i];
    }
    
    for(i=0;i<N-1;i++){
        minj=i;
        for(j=i+1;j<N;j++){
            if(A[minj]>A[j]){
                minj=j;
            }
        }
        
        tmp=A[i];
        A[i]=A[minj];
        A[minj]=tmp;
    }
    
    
    b=(double)sum/(double)(4.0*M);
    
    flag=0;
    for(i=N-1;i>=N-M;i--){
        if(A[i]<b){
            flag=1;
        }
    }
    
    
    
    if(flag==1){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    
    return 0;
}

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

int main () {
  
  int N, C;
  cin >> N >> C;
  
  vector<vector<int>> D(C, vector<int>(C));
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      cin >> D[i][j];
    }
  }
  
  vector<vector<int>> count(3, vector<int>(C));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      int c;
      cin >> c;
      count[(i + j) % 3][c - 1]++;
    }
  }
  
  long long score = 250000000;
  
  for (int a = 0; a < C; a++) {
    
    for (int b = 0; b < C; b++) {
      if (b == a) continue;
      
      for (int c = 0; c < C; c++) {
        
        if (c == a || c == b) continue;
        
        long long sub_score = 0;
        
        for (int p = 0; p < C; p++) {
          sub_score += D[p][a] * count[0][p];
        }
        
        for (int p = 0; p < C; p++) {
          sub_score += D[p][b] * count[1][p];
        }
        
        for (int p = 0; p < C; p++) {
          sub_score += D[p][c] * count[2][p];
        }
        
        if (score > sub_score) score = sub_score;
        
      }
    
    }
  
  }
  
  cout << score << endl;
  
}

Measured memory_bytes: 256