akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  ll N; cin >> N;
  ll T = 1<<N;
  vector<ll> S(T);
  REP(i,T) cin >> S[i];
  sort(ALL(S));
  multiset<ll> generated, unfinished;
  generated.insert(-S[T-1]);
  REP(i,T-1) unfinished.insert(-S[i]);
  REP(i,N){
    //generatedへ移す用
    vector<ll> tmp;
    auto it = generated.begin();
    while(it!=generated.end()){
      auto ub = unfinished.upper_bound((*it));
      if(ub==unfinished.end()) no();
      tmp.push_back(*ub);
      unfinished.erase(ub);
      it++;
    }
    FOREACH(x,tmp) generated.insert(x);
  }
  yes();
}



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

using namespace std;

int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    int m=t;
    int y=(t*n)/x;
    while(1)
    {
        if(m>=y) break;
        else
        {
            m+=t;
        }
    }
    cout<<m<<endl;

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> h(n), dp(n);
    rep(i,n) cin>>h[i];
    for (int i = n-1; i > 0; --i) if (h[i-1] >= h[i]) dp[i-1] = dp[i]+1;
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}


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

int vis[60][30];

int main(void){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        int len=s.size();
        for(int j=0; j<len; j++){
            vis[i][s[j]-'a']++;
        }
    }
    for(int i=0; i<27; i++){
        int cnt=100;
        for(int j=0; j<n; j++){
            cnt=min(cnt, vis[j][i]);
        }
        for(int j=0; j<cnt; j++){
            cout << (char)(i+'a');
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';

using namespace std;

struct node{
    vector< pair<ll, ll> > edges;
};

ll N;
static node nodes[100001];
ll colours[100001];
ll Maxim=0;



void saiki(ll index, ll from, ll except){
    ll colouring_num=1;
    rep(i, nodes[index].edges.size()){
        if(nodes[index].edges[i].first==from) continue;
        if(colouring_num==except) colouring_num++;
        if(colouring_num>Maxim) colouring_num=1;
        colours[nodes[index].edges[i].second]=colouring_num;
        saiki(nodes[index].edges[i].first, index, colouring_num);
        colouring_num++;
    }
}


int main(void){
    MEMSET(colours, 0);
    cin>>N;
    ll a, b;
    rep(i, N-1){
        cin>>a>>b;
        nodes[a-1].edges.push_back({b-1, i});
        nodes[b-1].edges.push_back({a-1, i});
    }
    
    rep(i, N) Maxim=max(Maxim, (ll)nodes[i].edges.size());
    cout<<Maxim<<endl;
    saiki(0, -1, -1);
    rep(i, N-1){
        cout<<colours[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 11008
#include <stdio.h>



int main(void)
{
    int a,b,c;
    int a1,b1,c1;
    int tmp;
    int i,j;
    int tyou,diya;

    tyou = 0;
    diya = 0;
    while (scanf("%d", &a) != EOF){
        scanf(",%d,%d", &b, &c);
        if (a > b){
            tmp = a;
            a = b;
            b = tmp;
        }
        if (a % 3 == 0){
            a1 = a / 3;
            if (b % 4 == 0){
                b1 = b / 4;
                if (c % 5 == 0){
                    c1 = c / 5;
                    if (a1 == b1 && a1 == c1 && b1 == c1){
                        tyou++;
                    }
                }
            }
        }
        if (a == b){
            diya++;
        }
    }

    printf("%d\n%d\n", tyou, diya);
    return (0);
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
 
int main() {
   int n,m,a[60],b[60],c[60],d[60];
   cin >> n >> m;
   rep(i,n)
   cin >> a[i] >> b[i];

   rep(i,m)
   cin >> c[i] >> d[i];

   rep(i,n){
      int min=1e9,ans=-1;
      rep(j,m){
         int dist=abs(a[i]-c[j])+abs(b[i]-d[j]);
         if(dist<min){
            ans=j+1;
            min=dist;
         }
      }
      cout << ans << endl;
   }
}

Measured memory_bytes: 256
#include <math.h>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int l;
	cin >> l;
	vector<int> a;
	int k;
	for ( int i = 0; i < n; i++ ) {
		cin >> k;
		a.push_back(k);
	}
	int time = 0;
	int time_max = 0;
	int dir = 0;	//1:右下がり 2:右上がり
	for ( int i = 0; i < n - 1; i++ ) {
		time += l - a[i];
		if ( dir != 2 && a[i] < a[i+1] ) {
			time_max = max( time_max, time );
			time = l - a[i];
			dir = 2;
		}else if ( dir != 1 && a[i] > a[i+1] ) {
			time_max = max( time_max, time );
			time = l - a[i];
			dir = 1;
		}
	}
	time += l - a[n-1];
	time_max = max( time_max, time );
	cout << time_max << endl;
	return 0;
}

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

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

    bool table[3][101] = {};

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

    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(table[2][i] && (!table[0][i] || table[1][i]))    cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3120
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

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

  //i can't leave this problem with WA lol

  int x = 0;

  cin >> x;

  cout << (x == 7 || x == 5 || x == 3 ? "YES\n" : "NO\n");

  return 0;
}
/*

*/


Measured memory_bytes: 3588
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	int n;
	cin>>n;
	rep(i,1,10){
		rep(j,1,10){
			if(i*j==n){
				cout<<"Yes"<<endl;
				return;
			}
		}
	}  
	cout<<"No"<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 3000005
#define INF 1000000000
#define MOD 998244353
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int fact[MAXN],invf[MAXN];
int N,M;
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<0) a+=MOD;}
int pow_mod(int a,int i)
{
    int s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
int comb(int n,int k)
{
    if(n<k) return 0;
    return 1LL*fact[n]*invf[k]%MOD*invf[n-k]%MOD;
}
int main()
{
    fact[0]=invf[0]=1;
    for(int i=1;i<=3000000;i++) fact[i]=1LL*fact[i-1]*i%MOD;
    invf[3000000]=pow_mod(fact[3000000],MOD-2);
    for(int i=2999999;i>=1;i--) invf[i]=1LL*invf[i+1]*(i+1)%MOD;
    scanf("%d%d",&N,&M);
    int ans=0;
    for(int i=0;i<=M;i++) if((3*M-i)%2==0) add(ans,1LL*comb(N,i)*comb((3*M-i)/2+N-1,N-1)%MOD);
    for(int i=0;i<=M;i++) if((M-i)%2==0) dec(ans,1LL*N*comb(N,i)%MOD*comb((M-i)/2+N-1,N-1)%MOD);
    for(int i=0;i<=M;i++) if((M-i)%2==0) add(ans,1LL*N*comb(N-1,i)%MOD*comb((M-i)/2+N-2,N-2)%MOD);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 23680
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include <math.h>
#include<algorithm>
using namespace std;

int main(int argc,char** argv)
{


	int n;
	cin >> n;
	for(int i = 0; i <= n/4 ; i++){
		if( (n-(4*i))%7 == 0 ){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" <<endl;
	return 0;

}


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
int a[M];
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)cin>>a[i];
    int sum=a[1];
    int ses=0;
    for(int i=2;i<=n;i++)
    {
       int x=gun(a[i],sum);
       ses=ad(ses,x);
       sum=ad(sum,a[i]);
    }
    cout<<ses<<"\n";
    return 0;

}





































Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x7fffffff,MAXN=1<<17;
int main()
{
    char a[20];
    bool c1,c2;
    cin>>a;
    if((a[0]-'0')*10+(a[1]-'0')<=12&&(a[0]-'0')*10+(a[1]-'0')>0)
        c1=true;
    else
        c1=false;
    if((a[2]-'0')*10+(a[3]-'0')<=12&&(a[2]-'0')*10+(a[3]-'0')>0)
        c2=true;
    else
        c2=false;
    if(c1&&c2)
        cout<<"AMBIGUOUS";
    if(c1&&(!c2))
        cout<<"MMYY";
    if(c2&&(!c1))
        cout<<"YYMM";
    if((!c1)&&(!c2))
        cout<<"NA";
    return 0;
}


Measured memory_bytes: 256
def main():
    string = input()
    range_ = int(input())
    substrings = []
    for i in range(len(string)):
        for j in range(1, range_ + 1):
            substrings.append(string[i:i + j])
    substrings = list(set(substrings))
    substrings.sort()
    print(substrings[range_ - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 5084
h,w = map(int,input().split())
S = [input() for _ in range(h)]
C = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    new = []
    flag = False
    cnt = 0
    for j in range(w):
        if flag:
            if S[i][j] == "#":
                for k in new:
                    C[i][k] += cnt
                cnt = 0
                new = []
                flag = False
            else:
                cnt += 1
                new.append(j)
        else:
            if S[i][j] == ".":
                cnt = 1
                flag = True
                new.append(j)
    else:
        if flag:
            for k in new:
                C[i][k] += cnt
            cnt = 0
            flag = False
for j in range(w):
    new = []
    flag = False
    cnt = 0
    for i in range(h):
        if flag:
            if S[i][j] == "#":
                for k in new:
                    C[k][j] += cnt
                cnt = 0
                new = []
                flag = False
            else:
                cnt += 1
                new.append(i)
        else:
            if S[i][j] == ".":
                cnt = 1
                flag = True
                new.append(i)
    else:
        if flag:
            for k in new:
                C[k][j] += cnt
            cnt = 0
            flag = False
ans = -1
for i in range(h):
    ans = max(ans,max(C[i]))
print(ans-1)

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


int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}
int nums[105] = {0};

int main(void){
    int n;
    scanf("%d", &n);
    char s[105];
    scanf("%s", s);
    int i = 0;
    while (s[i] != '\0'){
        if (s[i] == 'I'){
            nums[i+1] = nums[i]+1;
        }else if(s[i] == 'D'){
            nums[i+1] = nums[i]-1;
        }
        i++;
    }
    int max = -100000000;
    for (int i = 0; i <= n; i++){
        max = max>nums[i]?max:nums[i];
    }
    printf("%d\n", max);
    return 0;
}



Measured memory_bytes: 128
a = gets.split(" ").map(&:to_i)

case true
when (a[0] == 1) && (a[1] == 1)
  puts 'Draw'
when a[0] == 1
  puts 'Alice'
when a[1] == 1
  puts 'Bob'
when a[0] == a[1]
  puts 'Draw'
when a[0] > a[1] then
  puts 'Alice'
else
  puts 'Bob'
end

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e5 + 5);

int n, q;
vector<int> graph[MAX_N];

ll lazy[MAX_N];
ll actual[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &q);

  for (int i = 1; i <= n - 1; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);

    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  for (int i = 1; i <= q; ++i) {
    int p;
    ll x;
    scanf("%d %lld", &p, &x);

    lazy[p] += x;
  }

  queue<tuple<int, int, ll>> que;

  que.push(make_tuple(1, 0, 0LL));

  while (!que.empty()) {
    auto cur = que.front();
    que.pop();

    int node = get<0>(cur);
    int parent = get<1>(cur);
    ll acc = get<2>(cur);

    acc += lazy[node];

    actual[node] += acc;

    for (auto &e : graph[node]) {
      if (e == parent) continue;

      que.push(make_tuple(e, node, acc));
    }
  }

  for (int i = 1; i <= n; ++i) {
    printf("%lld ", actual[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 19828
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
using namespace std;
#define ll long long
#define MST(vis,x) memset(vis,x,sizeof(vis))
int main()
{
    char a,b,c;
    char s1[1000],s2[1000];
    scanf("%s",s1);
    scanf("%s",s2);
    if(strlen(s1)>strlen(s2))
    {
         printf("GREATER\n");
         return 0;
    }
    else if(strlen(s1)<strlen(s2))
    {
        printf("LESS\n");
        return 0;
    }
    if(strcmp(s1,s2)>0)
    {
        printf("GREATER\n");
    }
    else if(strcmp(s1,s2)<0)
        printf("LESS\n");
    else printf("EQUAL\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

ll D = 365;
ll C[26] = {};
ll S[365][26] = {};

ll score(const vector<ll> &ans){
  ll ret = 0;
  ll last[26] = {};
  rep(i,D){
    ret += S[i][ans[i]];
    last[ans[i]] = i+1;
    rep(j,26){
      ret -= C[j] * (i+1 - last[j]);
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  cin>>D;
  rep(i,26){
    cin>>C[i];
  }
  rep(i,D){
    rep(j,26){
      cin>>S[i][j];
    }
  }

  vector<ll> ans(D);
  rep(i,D){
    ll best_type = -1;
    ll max_eval = 0;
    rep(j,26){
      if(max_eval < S[i][j]){
        best_type = j;
        max_eval = S[i][j];
      }
    }
    ans[i] = best_type;
  }
  cerr << score(ans) << endl;

  rep(i,D){
    cout<<ans[i] + 1 << endl;
  }
  return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[200200];

int main() {
    cin >> n;
    rin{
        cin >> a[i];
    }
    sort(a, a + n);
    li res = 0;
    rin{
        res += a[n - 1 - i / 2];
    }
    res -= a[n - 1];
    cout << res << endl;


    return 0;
}

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

using namespace std;
using ll =long long;
using db = double;

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; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;

ll ans;
//ここから書き始める
int main()
{
	cout << setprecision(10);
	string s; cin >> s;
	vector<int> max_dist(26);
	for(char c = 'a' ; c <= 'z' ; c++){
		int position_c = 0;
		int inVec = 0;
		rep(i,s.size()){
			if(s[i] == c){
			 inVec =max	(i - position_c , inVec);
			 position_c = i+1;
			}
		}//文字探しが終わった後の処理
		inVec = max(inVec,(int)(s.size()-position_c));
		max_dist[c-'a']=inVec;
	}
	SORT(max_dist);
	cout << max_dist[0] << endl;



}


Measured memory_bytes: 256
//#define DEBUG

int Nsets, Ncodes; int mapW, mapH;
int tankX, tankY, tankD;//the position and the direction of the tank
char map[20][20]; char code;
void init_map(); void print_map(); void step(); void move(int); void shoot();

int main(){
	int i;
	scanf("%d", &Nsets);
	while(Nsets--){
		init_map();
			#ifdef DEBUG
			printf("map print test.\n");
			print_map();
			#endif
		scanf("%d", &Ncodes);
		for(i = 0; i < Ncodes; i++)step( scanf(" %c", &code) );
		print_map();
		if(Nsets)printf("\n");
	}
	return 0;
}

void step(){
	int i;
	char move_symbol[] = "UDLR";
	for(i = 0; move_symbol[i]; i++){
		if(move_symbol[i] == code){
			move(i);
			return;
		}
	}
	shoot();
}
void move(int d){
		#ifdef DEBUG
		printf("move(%d) is called.\n", d);
		#endif
	int moveX[] = {0,0,-1,1}; int moveY[] = {-1,1,0,0};
	int newX = tankX + moveX[d], newY = tankY + moveY[d];
	char tank_symbol[] = "^v<>";
	//is leagal move?
	if( (0 <= newX && newX < mapW) && (0 <= newY && newY < mapH) &&
	map[newX][newY] == '.'){
		//move
		map[tankX][tankY] = '.';
		tankX = newX, tankY = newY;
	}
	tankD = d;
	map[tankX][tankY] = tank_symbol[tankD];
}
void shoot(){
	int moveX[] = {0,0,-1,1}; int moveY[] = {-1,1,0,0};
	int x = tankX + moveX[tankD], y = tankY + moveY[tankD];
	while(0 <= x && x < mapW && 0 <= y && y < mapH){
		if(map[x][y] == '*'){
			map[x][y] = '.';
			break;
		}else if(map[x][y] == '#'){
			break;
		}
		x += moveX[tankD], y += moveY[tankD];
	}
}

void init_map(){
	int i, j, k;
	char tank_symbol[] = "^v<>";
	scanf("%d %d", &mapH, &mapW);
	for(j = 0; j < mapH; j++)for(i = 0; i < mapW; i++){
		scanf(" %c", &map[i][j]);
		for(k = 0; tank_symbol[k]; k++)if(map[i][j] == tank_symbol[k])tankX = i, tankY = j, tankD = k;
	}
}
void print_map(){
	int i, j;
	for(j = 0; j < mapH; j++){
		for(i = 0; i < mapW; i++)printf("%c", map[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i;
	ll sum = 0, ans, k;
	cin >> num;
	vector<ll> d(num), a(num + 1, 0);
	rep(i, num) {
		cin >> d[i];
		a[d[i]]++;
	}
	rep(i, num + 1)
		sum += a[i] * (a[i] - 1) / 2;
	rep(i, num) {
		k = a[d[i]];
		ans = sum - k * (k - 1) / 2 + (k - 1) * (k - 2) / 2;
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, k, a;
    cin >> n >> k;
    map<int, int> mp;
    fore(i,0,n) {
        cin >> a;
        mp[a]++;
    }
    int ans = 0, dif = mp.size();
    if (dif > k) {
        vector<int> v;
        for (auto &x : mp) {
            v.pb(x.S);
        }
        sort(v.begin(), v.end());
        fore(i,0,dif-k) ans += v[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 10744
// 自力で回答
// (もしかすると大昔にSRMで類題を解いたかもしれない)
// 
// XORの性質からg(N) = 1 ^ 2 ^ ... ^ Nを計算できれば
// f(A, B) = g(B) - g(A - 1)であるので、g(x)を求めればよい
//
// 数値を書き下してみる
//　 10進   2進   xor累計
//     0  0000    0000
//     1  0001    0001
//     2  0010    0011
//     3  0011    0000
//     4  0100    0100
//     5  0101    0001
//     6  0110    0111
//     7  0111    0000
// 各桁の周期性を利用して1の数を数えることでxorの結果がわかる
// ただし、一番左の桁だけ特殊なので場合分けして特別扱いする

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

// 0からnまでのXORを取った結果を返す
ll xor_to_n(ll n) {
    ll digit = 0;
    ll v = 2;
    ll ret = 0;
    while (v <= n * 10) {
        if (v == 2) {
            auto n2 = n % 4;
            ret |= (n2 == 1 || n2 == 2);
        } else {
            auto mod_v = n % v;
            if (mod_v >= v / 2) {
                ll one_num = mod_v - (v / 2) + 1;
                if (one_num % 2) {
                    ret |= (1LL << digit);
                }
            }
        }
        v *= 2;
        ++digit;
    }
    return ret;
}

int main(void)
{
    cin.sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    cout << (xor_to_n(B) ^ xor_to_n(A - 1)) << endl;
    return 0;
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;



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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
				
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try {
				int N = Integer.parseInt(br.readLine());
				List<String> line = Arrays.asList(br.readLine().split("\\s"));
//				List<Integer> data = line.stream().map(d -> Integer.parseInt(d)).collect(Collectors.toList());
				List<Long> data = line.stream().map(d -> Long.parseLong(d)).collect(Collectors.toList());
				
				System.out.printf("%d %d %d\n", 
						data.stream().min((a,b)-> a.compareTo(b)).get(),
						data.stream().max((a,b)-> a.compareTo(b)).get(),
						data.stream().mapToLong(d -> d).sum());
			}catch(IOException e) {
				e.printStackTrace();
			}
			
	}
}



Measured memory_bytes: 34120
n,q = map(int,input().split())
s = input()
Query = [list(map(int,input().split())) for _ in range(q)]
x = [ 0 for _ in range(n) ]
for i in range(n-1):
    if s[i:i+2] == "AC":
        x[i+1] = x[i] + 1
    else:
        x[i+1] = x[i]
for l,r in Query:
    print(x[r-1]-x[l-1])


Measured memory_bytes: 30680
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func sum(a []int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	h := nextInts(n)

	ans := 0
	for {
		l := 0
		for l < n && h[l] == 0 {
			l++
		}
		if l == n {
			break
		}
		r := l
		for r < n && h[r] > 0 {
			h[r]--
			r++
		}
		ans++
	}
	fmt.Println(ans)
}


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


void solve(long long a, long long b, long long x){
  double depth = (double)(x)/a/a;
  double ad = a;
  double bd = b;
  double L, theta;
  if(depth>bd/2){
    L = sqrt(ad*ad + 4*(bd-depth)*(bd-depth));
    theta = acos(a/L)/2.0/3.1415926589*360;
  } else {
    double y = 2.0*x/ad/bd;
    L = sqrt(bd*bd+y*y);
    theta = acos(y/L)/2.0/3.1415926589*360;
  }
  cout << setprecision(12) << theta << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long x;
    scanf("%lld",&x);
    solve(a, b, x);
    return 0;
}


Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(1){
    if ( cur == nil ) break;
    if(cur->key == key) {
        return cur;
    }
    cur = cur->next;
  }
    
  return nil;
}

void init(){
  nil = (NodePointer)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
    NodePointer p = t->prev;
    NodePointer n = t->next;
    
    p->next = n;
    n->prev = p;
    
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
  NodePointer cur = listSearch(key);
  if(cur != nil) {
      
      deleteNode(cur);
  }
}


void insert(int key){
  NodePointer x;
  x = (NodePointer)malloc(sizeof(struct node));
  x->key = key;
  
  NodePointer f = nil->next;
  x->prev = nil;
  x->next = f;
  
  nil->next = x;
  f->prev = x;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	deleteKey(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 37540
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void Comuse() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  solve();
}

///////////////////////////////////////////////////////////

int N;

void solve() {
  cin >> N;
  vector<int> H(N);
  int max = 0;
  int counter = 0;
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
    if(i >= 1 && H.at(i) <= H.at(i-1)){
      counter++;
      if(counter > max){
        max = counter;
      }
    } else{
      counter = 0;
    }
  }
  cout << max <<endl;
}

Measured memory_bytes: 640
n = int(input())
ans = 0
'''
A*B<=N-1となるAとBの組み合わせが何通りあるかを調べること
この考えを導きだせるかが、この問題を解くカギとなる
Cの最小値1を右辺に移項してN-1となっている
不等式となっている点がポイント
Cの最小値1としておけばAとBの組み合わせを全部考えることができる
次に、AとBどちらでも良いが、あるA（もしくはB）が1つの値を決めたときに、
それに対応するB（もしくはA）が何通りあるかを計算して、A（もしくはB）の値をn-1まで
計算して足してあげれば答えとなる
とてもシンプルなコードだけどこれでACとなるはず
'''

for i in range(1,n):
    #print(i, (n-1)//i)
    ans += (n-1)//i
print(ans)

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

int main(){
  int i, N, K, sum;
  sum = 0;
  cin >> N >> K;
  vector<int> x(N);
  for(i = 0; i < N; i++){
  	cin >> x.at(i);
  }
  for(i = 0; i < N; i++){
	sum += 2*min(x.at(i), K-x.at(i));
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#define llint long long

using namespace std;

struct BIT{
	int size;
	vector<llint> bit;
	BIT(){size = 0;}
	BIT(int s){
		size = s;
		bit.resize(size+1);
		init();
	}
	void init(){
		for(int i = 1; i <= size; i++) bit[i] = 0;
	}
	llint query(int i){
		llint ret = 0;
		while(i > 0){
			ret += bit[i];
			i -= i&(-i);
		}
		return ret;
	}
	void add(int i, llint x){
		while(i <= size){
			bit[i] += x;
			i += i&(-i);
		}
	}
};


llint n, Q;
string s;
BIT bit[26];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	cin >> s;
	s = "#" + s;
	
	for(int i = 0; i< 26; i++) bit[i] = BIT(500005);
	
	for(int i = 1; i <= n; i++){
		bit[s[i]-'a'].add(i, 1);
	}
	
	llint t, l, r; char c;
	cin >> Q;
	for(int q = 1; q <= Q; q++){
		cin >> t;
		if(t == 1){
			cin >> l >> c;
			bit[s[l]-'a'].add(l, -1);
			s[l] = c;
			bit[s[l]-'a'].add(l, 1);
		}
		if(t == 2){
			cin >> l >> r;
			llint ans = 0;
			for(int i = 0; i < 26; i++){
				if(bit[i].query(r) - bit[i].query(l-1) > 0) ans++;
			}
			cout << ans << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 102576
H, W, A, B = map(int, input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = int(10**9+7) #出力の制限
NN = 10**6 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = 0
for i in range(W-B):
    a = cmb(H-A+B-1+i, B+i, mod)* cmb(W-B+A-2-i, A-1, mod)
    ans += a
    ans %= mod
print(ans)

Measured memory_bytes: 122068
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string w;cin>>w;
  vector<int>v(26,0);

  rep(i,0,w.size()){
    int n=w[i]-'a';
    v[n]++;
  }

  rep(i,0,26){
    if(v[i]%2!=0){out("No");return 0;}
  }
  out("Yes");


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = 1e18+7;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int _size = s.size()/2 -1;
    while(true){
        string a = s.substr(0,_size);
        string b = s.substr(_size,_size);
        if(a==b){
            cout << 2*_size << endl;
            return 0;
        }
        _size--;
    }
}

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

int N, C;
int G[10][10];

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

bool visited[10][10];

bool isRemove(int x, int y, int num) {
  if(visited[y][x]) return true;
  visited[y][x] = true;
  for(int i = 0; i < 6; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx < 0 || nx >= N) continue;
    if(ny < 0 || ny >= N) continue;
    if(G[ny][nx] == -1) continue;
    if(G[ny][nx] == 10) continue;
    if(G[ny][nx] == 0) return false;
    else if(G[ny][nx] == num) 
      if(!isRemove(nx, ny, num)) return false;
  }
  return true;
}

int remove(int x, int y, int num) {
  int cnt = 1;
  G[y][x] = 10;
  for(int i = 0; i < 6; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx < 0 || nx >= N) continue;
    if(ny < 0 || ny >= N) continue;
    if(G[ny][nx] == num) {
      cnt += remove(nx, ny, num);
    }
  }
  return cnt;
}

int solve() {
  int maxi = -9999999;
  int cpG[10][10];
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      cpG[i][j] = G[i][j];
    }
  }

  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < i+1; ++j) {
      if(G[i][j] == 0) {
	int tmp = 0;
	G[i][j] = C;
	fill(visited[0], visited[10], false);
	if(isRemove(j,i, G[i][j])) tmp -= remove(j, i, G[i][j]);
	for(int k = 0; k < 6; k++) {
	  int nx = j + dx[k];
	  int ny = i + dy[k];
	  if(nx < 0 || nx >= N) continue;
	  if(ny < 0 || ny >= N) continue;
	  if(G[ny][nx] == 0) continue;
	  if(G[ny][nx] == -1) continue;
	  if(G[ny][nx] == 10) continue;
	  if(G[ny][nx] == G[i][j]) continue;

	  fill(visited[0], visited[10], false);
	  if(isRemove(nx, ny, G[ny][nx])) tmp += remove(nx, ny, G[ny][nx]);
	}
	//cout << "(" << j << ", " << i << ") "<< tmp << endl;
	maxi = max(maxi, tmp);

	for(int k = 0; k < N; ++k) {
	  for(int l = 0; l < N; ++l) {
	    //cout << G[k][l];
	    G[k][l] = cpG[k][l];
	  }
	  //cout << endl;
	}
      }
    }
  }
  return maxi;
}

main() {
  while(( cin >> N >> C ) && (N || C) ) {
    fill(G[0], G[10], -1);
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < i+1; ++j) {
	cin >> G[i][j];
      }
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
  
  
  
void change(char *str){
  int len=strlen(str);
  int i;
  for(i=0;i<len;i++){
    if('a'<=str[i]&&str[i]<='z'){
      str[i]-=32;
    }
  }
}
  
int main(){
  char t[10000];
  char key[10000];
  char eofstr[]={"END_OF_TEXT"};
  int ans=0;
  
  scanf("%s",key);
  change(key);
  
  while(1){
    scanf("%s",t);
    if(strcmp(t,eofstr)==0){
      break;
    }
    change(t);
    if(strcmp(t,key)==0){
      ans++;
    }
  }
  
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=100000007,MAX=200005;
const ll INF=1LL<<60;
vector<pair<int,ll>> G[MAX];
ll dat[MAX];
bool seen[MAX];
bool ok=true;
ll ma1=INF,ma2=INF;

void DFS(int u,int p){
    for(int i=0;i<G[u].size();i++){
        int a=G[u][i].first;ll b=G[u][i].second;
        if(seen[a]==0){
            dat[a]=b-dat[u];
            if(a<=100000) ma1=min(ma1,dat[a]);
            else ma2=min(ma2,dat[a]);
            seen[a]=1;
            DFS(a,u);
        }else{
            if(dat[a]+dat[u]!=b) ok=false;
        }
    }
}


int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int R,C;cin>>R>>C;
    int N;cin>>N;
    
    for(int i=0;i<N;i++){
        int a,b;ll c;
        cin>>a>>b>>c;
        
        G[a].push_back({100000+b,c});
        G[100000+b].push_back({a,c});
    }
    
    for(int i=1;i<=200000;i++){
        if(seen[i]==0){
            dat[i]=0;
            seen[i]=1;
            ma1=INF;
            ma2=INF;
            if(i<=100000) ma1=0;
            else ma2=0;
            DFS(i,-1);
            if(ma1+ma2<0) ok=false;
        }
    }
    
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}


Measured memory_bytes: 16640
/* ******* MD Imran Hosen *******
     *******  BSMRSTU  *******
                :)
                (:
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<iterator>
#include<stdio.h>
#include<string>
#include<vector>
#include<math.h>
#include<list>
#include<map>
using namespace std;
int main()
{
    map<int ,int>imran;
    map<int,int>::iterator it;

    //map<int ,int>date;
    //map<int,int>::iterator it2;

    imran.insert(make_pair(1,31));
    imran.insert(make_pair(2,28));
    imran.insert(make_pair(3,31));
    imran.insert(make_pair(4,30));
    imran.insert(make_pair(5,31));
    imran.insert(make_pair(6,30));
    imran.insert(make_pair(7,31));
    imran.insert(make_pair(8,31));
    imran.insert(make_pair(9,30));
    imran.insert(make_pair(10,31));
    imran.insert(make_pair(11,30));
    imran.insert(make_pair(12,31));
    int a,b,c,d,x,y;

    cin>>a>>b>>c>>d;
    x=0;
    //date.insert(make_pair(a,b));
    //date.insert(make_pair(c,d));

    for(it=imran.begin();it!=imran.end();it++)
    {
        if((it->second==b)&&(it->first == a))
        {
            cout<<"1"<<endl;
            x=5;
        }

    }
    if(x==0)
    {
        cout<<"0"<<endl;
    }


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	int i;
	int cnt = 0;
	for (i = 0; i < 3; i++)
	{
		if (s[i] == 'R')
		{
			cnt++;
		}
	}
	if (cnt != 2)
		cout << cnt;
	else
	{
		if (s[0] == s[1] || s[1] == s[2])
			cout << "2";
		else
			cout << "1";
	}
	return 0;
}

Measured memory_bytes: 3616