akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000

const int coins[] = {10,50,100,500};

// number of conins of the yen
int n_coin(int yen){
  int res=0;
  rep(i,4){
    res += yen/coins[3-i];
    yen = yen%coins[3-i];
  }
  return res;
}


int main(){
  int yen;
  bool isfirst=true;
  while(cin>>yen, yen){
    if(!isfirst){ cout<<endl; }
    else isfirst=false;

    int bill[4];
    int total=0;
    rep(i,4){
      scanf("%d", &bill[i]);
      total+=bill[i];
    }

    int res[4];

    int min = INF;
    rep(i, bill[0]+1){
      rep(j, bill[1]+1){
	rep(k, bill[2]+1){
	  rep(l, bill[3]+1){
	    int pay=i*coins[0]+j*coins[1]+k*coins[2]+l*coins[3];
	    int charge=pay-yen;
	    if( charge<0 ){
	      continue;
	    }
	    int left = total-i-j-k-l+n_coin(charge);
	    if(left<min){
	      res[0]=i; res[1]=j; res[2]=k; res[3]=l;
	      min = left;
	    }
	    break;
	  }
	}
      }
    }

    rep(i,4){
      if(res[i]!=0)
	printf("%d %d\n", coins[i], res[i]);
    }
  }
}

Measured memory_bytes: 1252
#include <iostream>
#include <cmath>

using namespace std;



int main () {
	int n;
	
	while(cin>>n){
		bool m[10]={false};
		int i=512,j=9,max=0;
		while(n!=0){
			if (n>=i) {
				m[j]=true;
				n%=i;
				if(j>max)max=j;
			}
			
			i/=2;
			j--;
		}
		
		for (int k=0; k<10; k++) {
			if (m[k]) {
				cout << (int)pow(2, (double)k);
				if (k!=max) {
					cout << ' ';
				}
			}
		
		}
		
		cout << endl;
		
		
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  int64_t sum = 0;
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  
  int64_t x = 0;
  int64_t ans = 10000000000;
  for(int i=0; i<N-1; i++){
    x += vec.at(i);
    sum -= vec.at(i);
    ans = min(ans,abs(x-sum));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, m ;  cin >> n >> m ; 
    int gcd=__gcd(n,m);
    string f,s; cin >> f >> s;
    int nadd=n/gcd, madd=m/gcd;
    if (gcd>1){
        bool ok=true;
        int i=n/gcd,j=m/gcd;
        for (int ii=0,jj=0;ii<n and jj<m;ii += i,jj += j){
            if (f[ii] != s[jj]) ok=false;
        }
        if (ok) cout << (n*m)/__gcd(n,m) << endl; 
        else cout << -1 << endl;
    }
    else {
        if (f[0]==s[0]) cout << (n*m)/__gcd(n,m) << endl;
        else cout << -1 << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0,rem=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n; i++){
        if(s[i] == 'I')sum++;
        else sum--;
        if(rem<=sum)rem=sum;
    }
    cout<<rem<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 30 19:55:40 2018
ABC088D
@author: maezawa
"""

h, w = list(map(int, input().split()))
a = []
for i in range(h):
    a.append(list(input()))
    
b = [[-1]*w for _ in range(h)]
dirs = [(-1, 0), (0, 1), (1, 0), (0, -1)]

a[0][0]=0
ok = True
finish = False
cnt = 1
current = [0, 0]
front = [current]
nextfront = []

while True:
    for cell in front:
        for direction in dirs:
            y, x = [cell[0]+direction[0], cell[1]+direction[1]]
            if y<0 or y>=h or x<0 or x>=w:
                continue
            if a[y][x] == '.':
                a[y][x] = cnt
                nextfront.append([y, x])
            if y == h-1 and x == w-1:
                finish = True
                break
    if finish == True:
        break
    elif nextfront == []:
        #print(y, x, cnt)
        ok = False
        break
    front = nextfront[:]
    nextfront = []
    cnt += 1
cntblack = 0
for y in range(h):
    for x in range(w):
        if a[y][x] == '#':
            cntblack += 1
#print(a)
if ok:
    print(h*w-1-a[h-1][w-1]-cntblack)
else:
    print(-1)
    
    

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = int;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}
vector<bool> seen;
vector<int> grp;

void dfs(const Graph &G, int v, int group)
{
    seen[v] = true;
    if (grp[v] == -1)
    {
        grp[v] = group;
    }
    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v, group);
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &p[i]);
    }
    Graph g(N);
    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    seen.assign(N, false);
    grp.assign(N, -1);
    ll cnt = 0;
    for (int i = 0; i < N; i++)
    {
        dfs(g, i, i);
    }

    for (int i = 0; i < N; i++)
    {
        if(grp[i] == grp[p[i]-1]){
            cnt++;
        }
    }
    
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 9984
# -*- coding: utf-8 -*-

antenna = []

for _ in range(5):
    antenna.append(int(input()))

k = int(input())

ans = 'Yay!'

for j in range(4):
    for l in range(j+1, 5):
        if abs(antenna[j] - antenna[l]) > k:
            ans = ':('

print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

long long f(long long b, long long n) {
	if (n < b) return n;
	return f(b, n / b) + n % b;
}

int main() {
	long long N, S;
	cin >> N >> S;
	if (N == S) {
		cout << N + 1;
		return 0;
	}
	for (long long i = 2; i <= sqrt(N); i++) {
		if (f(i, N) == S) {
			cout << i;
			return 0;
		}
	}
	if (N < S) {
		cout << -1;
		return 0;
	}
	long long ans = -1;
	for (long long i = 1; i < sqrt(N); i++) {
		if ((N - S) % i != 0) continue;
		long long B = (N - S) / i + 1;
		if (f(B, N) == S) {
			ans = B;
		}
	}
	cout << ans;
}

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

int main(){
  int n, ti, m, pi, xi, i, sum;
  vector<int> t;
  
  cin >> n;
  
  for (i=0; i<n; i++) {
    cin >> ti;
    t.push_back(ti);
  }  
  sum = accumulate(t.begin(), t.end(), 0);
  
  cin >> m;
  
  for (i=0; i<m; i++) {
    cin >> pi >> xi;
    cout << sum - t[pi-1] + xi << endl;
  }
  
  return 0;  
}

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

class Program
{
    static int[] dx = new int[] { 0, 0, 1, -1 };
    static int[] dy = new int[] { 1, -1, 0, 0 };

    static void Solve()
    {
        var n = sc.Long();
        var m = sc.Long();

        if (n > 2 && m > 2)
        {
            pr.WriteLine((n - 2) * (m - 2));
        }
        else if (n == 1 && m == 1)
        {
            pr.WriteLine(1);
        }
        else if (n == 2 || m == 2)
        {
            pr.WriteLine(0);
        }
        else
        {
            pr.WriteLine(Math.Max(n, m) - 2);
        }
    }

    static int[,] Mul(int[,] a, int[,] b)
    {
        var ret = new int[a.GetLength(0), b.GetLength(1)];
        for (int i = 0; i < a.GetLength(0); i++)
            for (int j = 0; j < b.GetLength(1); j++)
                for (int k = 0; k < a.GetLength(1); k++)
                    ret[i, j] += a[i, k] * b[k, j];

        return ret;
    }

    static int[,] Pow(int[,] a, int n)
    {
        var b = new int[a.GetLength(1), a.GetLength(0)];

        var f = n % 2 == 1;

        for (int i = 0; i < a.GetLength(0); i++)
            b[i, i] = 1;

        while (n > 0)
        {
            if (n % 2 == 1)
                b = Mul(a, b);


            n >>= 1;
        }

        return b;
    }

    class Coord
    {
        public int x;
        public int y;
    }

    static void Main(string[] args)
    {
        // pr.AutoFlush = true;
        Solve();
        pr.Flush();
        // Console.ReadKey();
    }

    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
}

#region IO
class Scanner
{
    private int _i = 0;
    private string[] line = new string[0];

    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }

    public string Str()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }

        return line[_i++];
    }

    public int Int() => int.Parse(Str());
    public long Long() => long.Parse(Str());
    public double Double() => double.Parse(Str());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] Str(int n) => Enumerate(n, Str);
}

class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion

Measured memory_bytes: 11220
n=int(input())
A=sorted(list(map(int,input().split())))

for i in range(1,n):
    A[i]=A[i]+A[i-1]

cnt=1
for i in reversed(range(1,n)):
    if A[i]<=A[i-1]*3:
        cnt +=1
    else:break

print(cnt)

Measured memory_bytes: 14308
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  
  int n;cin>>n;
  vector<pair<int,int> > a(1e5,mp(0,0));
  vector<pair<int,int> > b(1e5,mp(0,0));
  
  rep(i,1e5)a[i].se = b[i].se = i + 1;
  int t = 0,s = 0;
  rep(i,n){
    int tmp;cin>>tmp;
    if(i % 2){
      a[tmp].fi++;
      t++;
    }
    else {
      b[tmp].fi++;
      s++;
    }
  }
  sort(all(a));
  sort(all(b));
  reverse(all(a));
  reverse(all(b));

  int ans = INF;
  auto calc = [&](int i,int j){return t + s - (a[i].fi  + b[j].fi);};
  if(a[0].se != b[0].se){  
    ans = calc(0,0);
    print(ans);
    return 0;
  }


  ans = min(calc(0,1),ans);
  ans = min(calc(1,0),ans);
  
  print(ans);

  return 0;
}


Measured memory_bytes: 1792
N, A = map(int, input().split())
x = list(map(int, input().split()))
maxX = max(max(x), A)
dp = [[[0 for _ in range(N * maxX + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1
for i in range(N):
    for j in range(N + 1):
        for k in range(N * A + 1):
            if dp[i][j][k] == 0: continue
            dp[i + 1][j][k] += dp[i][j][k]
            dp[i + 1][j + 1][k + x[i]] += dp[i][j][k]

ans = 0
for i in range(1, N + 1):
    ans += dp[N][i][A * i]
print(ans)

Measured memory_bytes: 71712
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
using namespace std;


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

    int n;
    cin >> n;

    for(int i=0; i<n; i++){
        int b;
        cin >> b;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(b == a[i][j]) a[i][j] = -1;
            }
        }
    }

    for(int i=0; i<3; i++){
        if(a[i][0]==-1 && a[i][1]==-1 && a[i][2]==-1){
            cout << "Yes" << endl;
            return 0;
        }
    }

    for(int j=0; j<3; j++){
        if(a[0][j]==-1 && a[1][j]==-1 && a[2][j]==-1){
            cout << "Yes" << endl;
            return 0;
        }
    }

    if(a[0][0]==-1 && a[1][1]==-1 && a[2][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(a[2][0]==-1 && a[1][1]==-1 && a[0][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n;
int m,rm;
bool np[10001];
int pr[1011],pn;
int arr[1011],an;
int a2[1011],a2n;
ll a[511][511];
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
unordered_map<ll,bool> mp;
int main()
{
	for(int i=2;i<=6000;i++)
	{
		if(!np[i])pr[pn++]=i;
		for(int j=i+i;j<=6000;j+=i)np[j]=1;
	}
	int it=0;
	while(pr[it]<=500)it++;
	for(int i=0;i<=255;i++)arr[an++]=pr[it+i];
	geti(n);
	for(int i=1;i<=n;i++)
	{
		if(i<n-i+1)a2[++a2n]=i,a2[++a2n]=n-i+1;
		else if(i==n-i+1)a2[++a2n]=i;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if((i+j-1)&1)
			{
				a[i][j]=1ll*a2[i]*arr[(j-1)/2];
				assert(!mp[a[i][j]]);
				mp[a[i][j]]=1;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if((i+j)&1)
			{
				for(int d=0;d<4;d++)
				{
					int ni=i+dx[d],nj=j+dy[d];
					if(ni>=1&&ni<=n&&nj>=1&&nj<=n)
					{
						if(a[i][j]==0)a[i][j]=a[ni][nj];
						else a[i][j]=a[i][j]/__gcd(a[i][j],a[ni][nj])*a[ni][nj];
					}
				}
				ll k=1;
				while(mp[k*a[i][j]])
				{
					k++;
				}
				a[i][j]*=k;
				mp[a[i][j]]=1;
				if(a[i][j]>5e14)cerr<<i<<","<<j<<" "<<a[i][j]<<endl;
				assert(a[i][j]<=5e14);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			puti(a[i][j]<<1|((i+j)&1));
		}
		puts("");
	}
	
	return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll h, n;
    cin >> h >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    ll sum = 0;
    rep(i, n) { sum += a[i]; }
    if (sum >= h) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    string s;
    cin >> s;
    s.pop_back();
    int n  = s.size();
    bool f = false;
    while (true) {
        if (s.size() % 2 == 0) {
            REP(i, s.size() / 2) {
                if (s[i] != s[i + s.size() / 2]) {
                    s.pop_back();
                    break;
                }
                if (i == s.size() / 2 - 1)
                    f = true;
            }
        } else {
            s.pop_back();
        }
        if (f)
            break;
    }

    std::cout << s.size() << std::endl;

    return 0;
}

Measured memory_bytes: 256
s = {}
h = {}
c = {}
d = {}

suit = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]

n = gets.chomp.to_i
n.times do
  mark, card = gets.chomp.split
  case mark
  when 'S' then s[card] = 1
  when 'H' then h[card] = 1
  when 'C' then c[card] = 1
  when 'D' then d[card] = 1
  end
end

(suit - s.keys).each do |card|
  puts "S #{card}"
end

(suit - h.keys).each do |card|
  puts "H #{card}"
end

(suit - c.keys).each do |card|
  puts "C #{card}"
end

(suit - d.keys).each do |card|
  puts "D #{card}"
end

Measured memory_bytes: 6108
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    cur = 1
    for i in range(1, N + 1):
        cur *= i
        cur %= MOD

    print(cur)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62864
import numpy as np

n, k = map(int, input().split())

A = np.array(input().split(), np.int64)

A.sort()

posA = A[A > 0]
negA = A[A < 0]
zeros = (A == 0).sum()

left = -10 ** 18
right = 10 ** 18

while left + 1 < right:
    num = (left + right) // 2

    less_count = 0

    if num >= 0:
        less_count += zeros * n

    limit_pair_for_pos = num // posA
    limit_idxs = np.searchsorted(A, limit_pair_for_pos, side='right')
    less_count += limit_idxs.sum()

    limit_pair_for_neg = num // negA + (num % negA != 0)
    limit_idxs = n - np.searchsorted(A, limit_pair_for_neg, side='left')
    less_count += limit_idxs.sum()

    duplicate_cases = (A ** 2 <= num).sum()
    less_count -= duplicate_cases
    less_count //= 2

    if less_count >= k:
        right = num
    else:
        left = num

print(right)

Measured memory_bytes: 34580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main(){
  int h,w; cin >> h >> w;
  vector<string> g(h);
  for(int i = 0; i < h; i++) cin >> g[i];
  vector<vector<bool>> seen(h,vector<bool>(w,false));
  ull ans = 0;
  int dy[4] = {-1,1,0,0}, dx[4] = {0,0,-1,1};
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(seen[i][j]) continue;
      ull bl = 0, wh = 0;
      seen[i][j] = true;
      queue<P> q;
      q.push(P(i,j));
      while(!q.empty()){
        int y = q.front().first, x = q.front().second;
        q.pop();
        if(g[y][x] == '#') bl++;
        else wh++;
        for(int k = 0; k < 4; k++){
          int yy = y+dy[k], xx = x+dx[k];
          if(0 > yy || yy >= h || 0 > xx || xx >= w) continue;
          if(g[y][x] == g[yy][xx]) continue;
          if(seen[yy][xx]) continue;
          seen[yy][xx] = true;
          q.push(P(yy,xx));
        }
      }
      ans += bl*wh;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define s(n)                        scanf("%d",&n)
#define ss(n)                       scanf("%s",n)
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define fill(a,v)                   memset(a, v, sizeof a)
#define fi              freopen("input.txt", "rt", stdin)
#define fo              freopen("output.txt", "wt", stdout)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

void solve()
{

    int n,l;
    cin>>n>>l;

    vector<string> v;
    forall(i,0,n)
    {
        string str;
        cin>>str;
        v.push_back(str);
    }

    sort(v.begin(), v.end());

    forall(i,0,n)
    {
        cout<<v[i];
    }
    cout<<'\n';
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int v[55];
using namespace std;
int main()
{
    int n;
    float ans=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>v[i];
    }
    sort(v+1,v+n+1);
    ans=((float)(v[1]+v[2]))/2;
    
    for(int i=3; i<=n; i++)
    {
        ans=(ans+v[i])/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#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;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll W, H, N; cin >> W >> H >> N;
    ll l, r, t, b; l = 0; r = W; t = H; b = 0;
    rep(i, N){
        ll x, y, a; cin >> x >> y >> a;
        if(a == 1){
            chmax(l, x);
        }
        else if(a == 2){
            chmin(r, x);
        }
        else if(a == 3){
            chmax(b, y);
        }
        else{
            chmin(t, y);
        }
    }
    if(r-l > 0 && t-b > 0) cout << (r-l)*(t-b);
    else cout << 0;
    cout << endl;
    return 0;
}



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

#define REP(i,a,b) for(int i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

char input[70][70];
string dp[70][70];

int comp(string s,string t) { // comp s and t if s < t return negative
  if(s.length() != t.length()) return (s.length() - t.length());
  rep(i,s.length()) if(s[i] != t[i]) return (s[i] - t[i]);
  return 0;
}

int main() {
  int w,h,n;
  while(cin>>w>>h, w|h) {
    string s;
    rep(i,h) {
      cin>>s;
      rep(j,w) {
	dp[i][j] = "";
	input[i][j] = s[j];
      }
    }

    rep(i,h) {
      rep(j,w) {
	char c = input[i][j];
	if(i == 0 && j == 0) {
	  if(c <= '9' && c >= '0') dp[i][j] = string(1,c);
	}else{
	  if(!(c <= '9' && c >= '0')) continue;
	  string ab = "",left = "";
	  if(i > 0) ab = dp[i-1][j] + string(1,c);
	  if(j > 0) left = dp[i][j-1] + string(1,c);
	  if(comp(ab,left) <= 0) {
	    dp[i][j] = left;
	  }else{
	    dp[i][j] = ab;
	  }
	  if(dp[i][j][0] == '0') dp[i][j] = dp[i][j].substr(1);
	}
      }
    }

    string ans = "";
    rep(i,h) rep(j,w) { if(comp(ans,dp[i][j]) < 0) ans = dp[i][j]; }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int H,W;
    int A[82][82];
    int B[82][82];
    int C[82][82];
    bool dp[82][82][13000]={};
    int mx[82][82]={};
    
    cin >> H >> W;
    REP(i,H){
        REP(j,W){
            cin >> A[i][j];
        }
    }
    REP(i,H){
        REP(j,W){
            cin >> B[i][j];
        }
    }
    
    int K=0;
    REP(i,H){
        REP(j,W){
            C[i][j]=abs(A[i][j]-B[i][j]);
            K+=C[i][j];
        }
    }
    
    dp[0][0][C[0][0]]=1;
    mx[0][0]=C[0][0];
    
    REP(i,H){
        REP(j,W){
            REP(k,mx[i][j]+5){
                if(dp[i][j][k]==0)continue;
                if(j!=W-1){
                    dp[i][j+1][abs(k-C[i][j+1])]=1;
                    dp[i][j+1][abs(k+C[i][j+1])]=1;
                    mx[i][j+1]=max(mx[i][j+1],abs(k-C[i][j+1]));
                    mx[i][j+1]=max(mx[i][j+1],abs(k+C[i][j+1]));
                }
                if(i!=H-1){
                    dp[i+1][j][abs(k-C[i+1][j])]=1;
                    dp[i+1][j][abs(k+C[i+1][j])]=1;
                    mx[i+1][j]=max(mx[i+1][j],abs(k-C[i+1][j]));
                    mx[i+1][j]=max(mx[i+1][j],abs(k+C[i+1][j]));
                }
            }
        }
    }
    int Ans=INF;
    REP(k,mx[H-1][W-1]+5){
        if(dp[H-1][W-1][k]==1){
            Ans=k;
            break;
        }
    }
    cout << Ans << endl;
    
    return 0;
}



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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N;
	cin >> N;
	vector <int> L(N, 0);
	for (int ii = 0; ii < N; ++ii){
		cin >> L[ii];
	}

	sort(L.rbegin(), L.rend());

	int maxVal = L[0];
	int sum = 0;
	for (int ii = 1; ii < N; ++ii){
		sum += L[ii];
	}

	if (maxVal < sum){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;

	}




	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//????????£?????????????????§????????????????????????
				//????????\???
				Scanner sc = new Scanner(System.in);
				//int???????????????a
				int W = sc.nextInt();
				int H = sc.nextInt();
				int  x = sc.nextInt();
				int  y = sc.nextInt();
				int  r = sc.nextInt();
			//
			if((0 < x+r)&&(0 < y+r)){
				//?????¶??????????????????????????°Yes
				if((x+r<= W)&&(y+r<=H)){
						System.out.println("Yes");
					}else {
						System.out.println("No");
					}
	}else{
		System.out.println("No");
	}
	}
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int N;
int x[MC],y[MC],t[MC];

int main(){
	cin >> N;
	repp(i,1,N+1) cin >> t[i] >> x[i] >> y[i];
	repp(i,1,N+1){
		int d = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
		int dt = t[i] - t[i-1];
		if(dt < d || (dt+d)%2==1) return cout << "No" << endl , 0;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1408
a = list(input())
a.sort()
#sortメソッドを使って、順番に並べる。
# たとえbcaでもcbaでもabcの順にしてくれる
if a[0] == 'a' and a[1] == 'b' and a[2] == 'c':
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9004
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip>

typedef long double ld;
typedef long long ll;

void print()
{
  std::cout << std::endl;
}

template<class T>
void print(T param)
{
  std::cout << param << std::endl;
  return;
}

template<class T, class... S>
void print(T param1, S... param2)
{
  std::cout << param1 << " "; print(std::forward<S>(param2)...);
}

void solve()
{
  ll N, K;
  std::cin >> N >> K;

  std::vector<ll> va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }


  ll sum = 0LL;
  for (ll i = 0; i < K; i++) {
    sum += va[i];
  }

  ll max_sum = sum;
  for (ll i = K; i < N; i++) {
    sum += va[i] - va[i-K];
    max_sum = std::max(sum, max_sum);
  }

  ld ans = (max_sum + K) / 2.0;
  std::cout << std::fixed << std::setprecision(9);
  print(ans);
  return;
}

int main()
{
  solve();
  return 0;
}


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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = 0;

            for(int i = 0; i < 4; i++)
            {
                if (s[i] == '+') 
                {
                    ans++;
                }
                else
                {
                    ans--;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27376
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

a.sort()
a.append(0)
erased = 0
ans = 0
for i in range(1,n+1):
    if a[i-1] == a[i]:
        erased = (erased+1)%2
    else:
        if erased == 0:
            ans += 1
        erased = 0
print(ans)

Measured memory_bytes: 7388
while True:
    l = input().split()
    l[0] = int(l[0])
    l[2] = int(l[2])
    if l[1] == "+":
        print(l[0]+l[2])
    elif l[1] == "-":
        print(l[0]-l[2])
    elif l[1] == "*":
        print(l[0]*l[2])
    elif l[1] == "/":
        print(l[0]//l[2])
    elif l[1] == "?":
        break



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

int n;
vector<int> a;

// kを増やすべきかどうか
bool check(int x, int k){
    if (n-k <= n/2) return false;
    return abs(a[n-k*2-1]-x) <= abs(a[n-k-1]-x);
}

int main(void){
    int q;
    cin >> n >> q;
    a.resize(n);
    rep(i,n) cin >> a[i];
    vector<ll> sum(n+1), t_sum(n+1);
    rep(i,n){
        sum[i+1] = sum[i] + a[i];
        if (i % 2 != n % 2) {
            t_sum[i+1] = t_sum[i] + a[i];
        } else {
            t_sum[i+1] = t_sum[i];
        }
    }
    rep(_,q){
        int x;
        cin >> x;
        int l = 0, r = n;
        while (l + 1 < r) {
            int m = (l+r)/2;
            if (check(x, m)) l = m;
            else r = m;
        }
        int k = r;
        cout << sum[n]-sum[n-k] + t_sum[max(n-2*k,0)]<< endl;
    }

    return 0;
}


Measured memory_bytes: 3712
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    fast;
    int n;cin>>n;
    ll a[n];
    rep(i,n)
    cin>>a[i];

    int dp[n]={0};
    for(int i=1; i<n; i++)
    {
    	if(i==1)
    	{
    		dp[i]=abs(a[0]-a[i])+dp[0];
    	}
    	else
    	{
    		dp[i]=min(((abs(a[i]-a[i-1])+dp[i-1])),(abs(a[i]-a[i-2])+dp[i-2]));
    	}
    	//cout<<dp[i]<<" ";
    }

    cout<<dp[n-1];
    
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long factrial(long long x){
    long long y = 1;
    for (int i = 1; i <= x; i++)
    {
        y *= i;
        y %= mod;
    }
    return y;
}
long long power(long long x, long long n, long long M){
    long long res = 1;
    if(n > 0){
        res = power(x, n / 2, M);
        if(n%2 == 0)res = (res * res) % M;
        else res = (((res * res) % M) * x) % M;
    }
    return res;
}
int main(){
    int x, y;
    cin >> x >> y;
    int a = 2 * y - x;
    int b = 2 * x - y;
    if (a < 0 || b < 0 || a % 3 != 0 || b %3 != 0)
    {
        cout << 0 << endl;
        return 0;
    }
    a /= 3; b /= 3;
    long long ans = factrial(a+b);
    ans *= power(factrial(a), mod-2, mod);
    ans %= mod;
    ans *= power(factrial(b), mod-2, mod);
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,Q;
    cin >> N >> Q;
    while(N != 0){
        map<int,int> mp;
        for(int i=0; i<N; i++){
            int M;
            cin >> M;
            for(int j=0; j<M; j++){
                int a;
                cin >> a;
                mp[a]++;
            }
        }
        int ans = 0;
        int mx = 0;
        for(auto m: mp){
            if(m.second >= Q){
                if(chmax(mx,m.second)){
                    ans = m.first;
                }
            }
        }
        cout << ans << endl;
        cin >> N >> Q;
    }
    return 0;
}


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

using namespace std;

int main(){
    const int vx[]={0,1,0,-1};
    const int vy[]={-1,0,1,0};
    int w,h;
    while(true){
        cin>>w>>h;
        if(w==0)break;
        vector<vector<char>> m(h+2,vector<char>(w+2,'#'));
        queue<pair<int,int>> bq,wq;
        for (int i = 0; i < h; ++i) {
            string s;
            cin>>s;
            for (int j = 0; j < w; ++j) {
                m[i+1][j+1]=s[j];
                if(m[i+1][j+1]=='B')bq.push(make_pair(i+1,j+1));
                else if(m[i+1][j+1]=='W')wq.push(make_pair(i+1,j+1));
            }
        }
        vector<vector<int>> a(h+2,vector<int>(w+2,0));
        while(!bq.empty()){
            auto t=bq.front();
            bq.pop();
            for (int i = 0; i < 4; ++i) {
                int ny=t.first+vy[i];
                int nx=t.second+vx[i];
                if(a[ny][nx]!=1&&m[ny][nx]=='.'){
                    bq.push(make_pair(ny,nx));
                    a[ny][nx]+=1;
                }
            }
        }
        while(!wq.empty()){
            auto t=wq.front();
            wq.pop();
            for (int i = 0; i < 4; ++i) {
                int ny=t.first+vy[i];
                int nx=t.second+vx[i];
                if((a[ny][nx]&2)==0&&m[ny][nx]=='.'){
                    wq.push(make_pair(ny,nx));
                    a[ny][nx]+=2;
                }
            }
        }
        int ba=0,wa=0;
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                if(a[i][j]==1)++ba;
                else if(a[i][j]==2)++wa;
            }
        }
        cout<<ba<<" "<<wa<<endl;
    }
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a + b >= 10) {
        cout << "error\n";
    } else {
        cout << a + b << "\n";
    }
}

Measured memory_bytes: 3572
K, A, B = map(int, input().split())

def f(K, A, B):
    if A >= B - 2 or K <= A:
        return K + 1
    
    # then A < K and A < B

    # break cookies for (A-1) times
    K -= (A - 1)
    if K % 2 == 0:
        return A + (B - A) * (K // 2)
    else:
        return 1 + A + (B - A) * (K // 2)
    
ans = f(K, A, B)
print('%d'%ans)



Measured memory_bytes: 2940
n = int(input())
a = list(map(int, input().split()))
al, bo = [], []
for i in range(n):
	if i % 2 == 0:
		al.append(max(a))
		a.remove(max(a))
	else:
		bo.append(max(a))
		a.remove(max(a))
print(sum(al)-sum(bo))


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define llint long long
const double pi=3.141592653589793;
int c1,c2,c3;
int n;
vector<vector<vector<double>>> dp(300+1, vector<vector<double>>(300+1, vector<double>(300+1,0)));
vector<vector<vector<int>>> p(300+1, vector<vector<int>>(300+1, vector<int>(300+1,0))); 

double pp(int a1,int a2,int a3){
    if (p[a1][a2][a3]==1){
        return dp[a1][a2][a3];
    }
    else{
        p[a1][a2][a3]=1;
        double a0=a1+a2+a3;
        double f=n/a0;
        if (a1>0){
            f+=pp(a1-1,a2,a3)*a1/a0;
        }
        if (a2>0){
            f+=pp(a1+1,a2-1,a3)*a2/a0;
        }
        if (a3>0){
            f+=pp(a1,a2+1,a3-1)*a3/a0;
        }
        dp[a1][a2][a3]=f;
        return dp[a1][a2][a3];

    }
}

int main() {
    cin>>n;
    map<int,int> c;
    c[1]=0;
    c[2]=0;
    c[3]=0;
    rep(i,n){
        int a;
        cin>>a;
        c[a]+=1;
    }
    c1=c[1],c2=c[2],c3=c[3];
    /*rep(i,n+1){
        rep(j,c2+c3+1){
            rep(k,c3+1){
                prev[i][j][k]=0;
            }
        }
    }*/
    //cout<<c1<<endl;
    //cout<<dp[0][0][0]<<endl;
    //cout<<c1<<" "<<c2<<" "<<c3<<endl;
    //cout<<dp.size()<<endl;
    //cout<<dp[n][n][n]<<endl;
    //cout<<p[0][0][0]<<endl;
    //p[c1][c2][c3]=1;
    //cout<<p[c1][c2][c3]<<endl;
    p[0][0][0]=1;
    pp(c1,c2,c3);
    cout << fixed << setprecision(12);
    cout<<dp[c1][c2][c3]<<endl;




    return 0;
}

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

int main() {
    int a = 0, b = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {

        if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T') {
            a++;
        }
        else {
            b = max(a, b);
            a = 0;
        }
    }
    cout << max(a, b) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }
    else{
      u = u->right;
    }
  }
  return u;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u->left != NIL){
    inorder(u->left);
  }
  printf(" %d", u->key);
  if(u->right != NIL){
    inorder(u->right);
  }
}



void preorder(Node u){
  printf(" %d", u->key);
  if(u->left != NIL){
    preorder(u->left);
  }
  if(u->right != NIL){
    preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for(i = 0;i < n;i++){
    scanf("%s", com);

    if ( com[0] == 'f' ){
      scanf("%d", &x);
      if (treeSearch(root, x) != NIL) {
	printf("yes\n");
      }
      else{ 
	printf("no\n");
      }
    }

    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 

    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

  }
  return 0;
}

Measured memory_bytes: 19364
import glob
import math


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\168\\D'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    alph = []

    def rec(self, result, now, max, N):

        if now == N:
            res = ""
            for i in result:
                res += self.alph[i]
            print(res)
            return

        if now == 0:
            result[0] = 0
            self.rec(result, now+1, 0, N)
            return

        for i in range(0, max+2):
            if i == N:
                return
            result[now] = i
            if i > max:
                self.rec(result, now+1, i, N)
            else:
                self.rec(result, now+1, max, N)

    def resolve(self):

        count = 0

        N, M = map(int, self.input_data().split())
        node = [list(map(int, self.input_data().split())) for i in range(M)]
        sp = [[0, 200000] for i in range(N+1)]   # signpost
        path = [[] for i in range(N+1)]
        for n in node:
            path[n[0]].append(n[1])
            path[n[1]].append(n[0])

        next = [1]
        sp[1][1] = 0
        while len(next) != 0:
            now = next.pop(0)
            for n in path[now]:
                if sp[n][1] > sp[now][1]+1:
                    sp[n][0] = now
                    sp[n][1] = sp[now][1]+1
                    next.append(n)


        print('Yes')
        for i in range(2,N+1):
            print(str(sp[i][0]))

solver = Solver(REL_PATH)
solver.exec_resolve()


Measured memory_bytes: 66432
n,m=map(int,input().split())
l=sorted(list(set(map(int,input().split()))))
df=l[0]

s=len(bin(df))-2
cnt=0
for i in range(s):
  if df%2:break
  df//=2
  cnt+=1
l=tuple(map(lambda x:x//(2**cnt),l))

for i in l:
  if i%2==0:print(0);exit()

def gcd(a,k):
  if k:return gcd(k,a%k)
  return a
an=l[0]
for i in l:
  an=an*i//gcd(an,i)

print(-(-(m//(an*2**(cnt-1)))//2))


Measured memory_bytes: 12068
def mul(a, b):
    return ((a % P) * (b % P)) % P

def div(x, y):
    return mul(x, pow(y, P-2, P))

def comb(n, r):
    x = 1
    for i in range(n, n - r, -1):
        x = (x * i) % P
        
    y = 1
    for i in range(1, r+1):
        y = (y * i) % P
    return div(x, y)
  
n, a, b = map(int, input().split())
P = 10 ** 9 + 7
res = pow(2, n, P) - 1 - comb(n, a) - comb(n, b)
print(res % P)

Measured memory_bytes: 3064