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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string S = "";

    ll y, x;
    y = ty-sy;
    while (y > 0) {
        S += "U";
        y--;
    }

    x = tx-sx;
    while (x > 0) {
        S += "R";
        x--;
    }

    y = ty-sy;
    while (y > 0) {
        S += "D";
        y--;
    }

    x = tx-sx;
    while (x > 0) {
        S += "L";
        x--;
    }

    S += "L";

    y = ty-sy+1;
    while (y > 0) {
        S += "U";
        y--;
    }

    x = tx-sx+1;
    while (x > 0) {
        S += "R";
        x--;
    }

    S += "D";
    S += "R";

    y = ty-sy+1;
    while (y > 0) {
        S += "D";
        y--;
    }

    x = tx-sx+1;
    while (x > 0) {
        S += "L";
        x--;
    }

    S += "U";

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<string,string> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

int main () {
    int n,a;cin>>n>>a;
    int x[55],norm[55];
    rep(i,n) cin>>x[i];
    rep(i,n) norm[i] = x[i] - a;

    map<int,ll> dp[55];
    dp[0][0] = 1;
    rep(i,n) {
        for (auto itr = dp[i].begin();itr!=dp[i].end();itr++) {
            dp[i+1][itr->first+norm[i]] = itr->second;
        }
        for (auto itr = dp[i].begin();itr!=dp[i].end();itr++) {
            dp[i+1][itr->first] += itr->second;
        }
    }
    cout<<dp[n][0] - 1<<endl;
}

Measured memory_bytes: 4920
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
using M = map<int, int>;

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  M mp;
  rep(i, n){
    int x;
    cin >> x;
    if(mp[x] == 0){
      mp[x]++;
      ans++;
    }
    else{
      mp[x]--;
      ans--;
    }
  }
  cout << ans << endl;

       

  return 0;
}

Measured memory_bytes: 8156
#include <bits/stdc++.h>
using namespace std;
//A>C>B,B>C>A

int main() {
  int A = 0,B = 0,C = 0;
  cin >>A>>B>>C;
  
  if(A>B){

     if(C>A){
       cout << "No" <<endl;
  }
    else{
      if(C>B){
      cout << "Yes" << endl;
      }
      else{
        cout<< "No"<<endl;
      }
    }
  }
  else{
    
    if(C>B){
      cout << "No"<< endl;
  }
    else{
      if(C>A){
        cout << "Yes"<<endl;
      }
      else{
        cout << "No"<<endl;
      }
    }
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {

        static void Main(string[] args)
        {
            var S = Read();
            string str = string.Empty;
            foreach (var s in S)
            {
                if (str.Contains(s))
                {
                    Console.WriteLine("no");
                    return;
                }
                str += s.ToString();
            }
            Console.WriteLine("yes");
        }
        public static readonly Func<string> Read = () => Console.ReadLine();
        public static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        public static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)

int main() {
  int N, M;
  cin >> N >> M;
  st a = "No";
  if (N == M) {
    a = "Yes";
  }
  cout << a << endl;
}

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

namespace AtCoderMake.EX_NOMURA2020
{
    class N20C
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select((x) => long.Parse(x)).ToArray();
            long ans = 0;
            long stem = 1;
            long maxStem = a.Sum();
            for(long i = 0; i < a.Length; i++)
            {
                if (stem == 0)
                {
                    ans = -1;
                    break;
                }
                ans += stem;
                if (stem < a[i])
                {
                    ans = -1;
                    break;
                }
                maxStem -= a[i];
                if ((stem - a[i]) * 2 < maxStem)
                {
                    stem = (stem - a[i]) * 2;
                }
                else
                {
                    stem = maxStem;
                }
            }
            if (stem != 0)
            {
                ans = -1;
            }
            Console.WriteLine(ans);
        }
        
    }
}


Measured memory_bytes: 38140
#include<stdio.h>
#include<string.h>
#define T 1
#define H 2
#define DROW 3
int sub( char x[], char y[] ){

  int a,b,i;
  a = strlen(x);
  b = strlen(y);
  
  if ( a > b ){
    for ( i = 0 ; i < b ; i++ ){
      if ( x[i] > y[i] ) return T;
      if ( x[i] < y[i] ) return H;
    }
    return T;
  }
  
  if ( a < b ){
    for ( i = 0 ; i < a ; i++ ){
      if ( x[i] > y[i] ) return T;
      if ( x[i] < y[i] ) return H;
    }
    return H;
  }
  
  if ( a == b ){
    for ( i = 0 ; i < a ; i++ ){
      if ( x[i] > y[i] ) return T;
      if ( x[i] < y[i] ) return H;
    }
    return DROW;
  }

  return 0;
  
}

int main(){

  int n,result;
  scanf("%d",&n);

  int a,b,i;
  char taro[200],hanako[200];
  a = 0;
  b = 0;
  
  for ( i = 0 ; i < n ; i++ ){

    scanf("%s",taro);
    scanf("%s",hanako);

    result = sub( taro, hanako );
    
    if ( result == T ){
      a += 3;
    } else if ( result == H ){
      b += 3;
    } else if ( result == DROW ) {
      a += 1;
      b += 1;
    }

  }

  printf("%d %d\n",a ,b);

  return 0;

}

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

ll sum1[1010101], sum2[1010101];

int main() {
    ll K, N;
    cin >> K >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll ans = A[N-1] - A[0];
    for (int i=0; i<N; ++i) {
        ll tmp = A[N-1] - A[i];
        ll tmp2 = 0;
        if (i > 0) {
            tmp2 = A[i-1] + (K - A[N-1]);
        }
        ans = min(ans, tmp+tmp2);
    }

    cout << ans << endl;
}


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

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	map<ll,int> mp;
	rep(i,n){
		cin >> a[i];
		mp[a[i]]++;
	}
	sort(a.rbegin(),a.rend());
	ll h = 0;
	ll w = 0;
	rep(i,n){
		if(h == 0 && mp[a[i]] >= 4){
			h = w = a[i];
			cout << h * w << endl;
			return 0;
		}
		if(h == 0 && mp[a[i]] >= 2){
			h = a[i];
		}
		if(h != 0 && h != a[i] && mp[a[i]] >= 2){
			w = a[i];
			cout << h*w << endl;
			return 0;
		}
	}
	cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 7296
#include<stdio.h>
int main(void){
  long a,b,c,d,e,f;
  scanf("%ld%ld%ld",&a,&b,&c);
  d=4*a*b;
  e=c-a-b;
  f=e*e;
  if(e<=0){
    printf("No");
  }
  else if(d<f){
    printf("Yes");
  }
  else {
    printf("No");
  }
  return 0;
}
  
  


Measured memory_bytes: 128
#include <stdio.h>
int min(int A, int B) {
  if (A < B) {
    return A;
  } else {
    return B;
  }
}

int main() {
  int A;
  int B;
  int K;
  scanf("%d %d %d",&A, &B, &K);
  int i;
  int count = 0;
  for (i = min(A,B); i > 0; --i) {
    if (A%i == 0 && B%i == 0) {
      ++count;
      if (count == K) {
        break;
      }
    }
  }
  printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 128
# 部分分け
n = int(input())

ans = n
for i in range(n+1):
    cc, t = 0, i
    while t>0:
        cc += t%6
        t //= 6
    t = n - i
    while t>0:
        cc += t%9
        t //= 9
    ans = min(ans,cc)
print(ans)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	if(N%2==0){
	  	System.out.println("" + N/2);
    }else{
      	System.out.println("" + (N/2 + 1));
    }
	}
}

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

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int c[3][3];
	REP(i, 3)
		REP(j, 3)
			cin >> c[i][j];
	REP(i, 101){
		REP(j, 101){
			REP(k, 101){
				bool ok = 1;
				REP(l, 3){
					int b[3] = {c[l][0]-i, c[l][1]-j, c[l][2]-k};
					REP(m, 3){
						if(b[0] != b[m] || b[m] < 0){
							ok = 0;
							break;
						}
					}
				}
				if(ok){
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
}


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

int main()
{
	string s;
	cin>>s;
	
	int i;
	for(i=0;i<s.size();i++)
	{
		if(s[i]==',')
		 s[i]=' ';
	}
	cout<<s<<endl;
}

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

constexpr int INF = 1e9;

class union_find {
public:
    union_find(int n)
        : par_(n, -1)
    {}
    void init(int n) {
        par_.assign(n, -1);
    }

    int root(int x) {
        return par_[x] < 0 ? x : par_[x] = root(par_[x]);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) {
            return false;
        } else {
            if(par_[x] < par_[y]) { // size(x) > size(y)
                par_[x] += par_[y];
                par_[y] = x;
            } else {
                par_[y] += par_[x];
                par_[x] = y;
            }
            return true;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par_[root(x)];
    }

private:
    std::vector<int> par_;
};

struct edge {
    int u, v;
    int cost;
    bool operator<(edge const& e) {
        return cost < e.cost;
    }
};


int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vector<edge> es(m);
        for(int i=0; i<m; ++i) {
            cin >> es[i].u >> es[i].v >> es[i].cost;
            es[i].u--;
            es[i].v--;
        }
        sort(es.begin(), es.end());
        int res = INF;
        for(int i=0; i<m; ++i) {
            union_find uf(n);
            int cnt = 0;
            for(int j=i; j<m; ++j) {
                if(!uf.same(es[j].u, es[j].v)) {
                    uf.unite(es[j].u, es[j].v);
                    cnt++;
                    if(cnt == n-1) {
                        res = min(res, es[j].cost - es[i].cost);
                        break;
                    }
                }
            }
        }
        cout << (res == INF ? -1 : res) << endl;
    }
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, m;
    cin>>n>>m;
    string a[55], b[55];
    rep(i, n) {
        cin>>a[i];
    }
    rep(i, m) {
        cin>>b[i];
    }
    bool flag;
    rep(i, n - m + 1) {
        rep(j, n - m + 1) {
            flag = true;
            rep(ii, m) {
                rep(jj, m) {
                    if(a[i + ii][j + jj] != b[ii][jj]) flag = false;
                }
            }
            if(flag) {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
ll a,b,c,d,n;
str s1,s2,s;
ll ans=0;
int32_t main() {
    fast();
   map<str,ll>maps;
   
   maps["SUN"]=7;
   maps["MON"]=6;
   maps["TUE"]=5;
   maps["WED"]=4;
   maps["THU"]=3;
   maps["FRI"]=2;
   maps["SAT"]=1;
   cin >> s;
   cout<<maps[s];




    cerr << "\nTime taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

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

ll fact(int x)
{
	if(x == 1) return 1;
	else return x*fact(x-1);
}

int main()
{
	int n;
	cin>>n;
	int rt = sqrt(n)+1;
	for(int i = 1; i <= n; i++)
	{
		int cnt = 0;
		for(int x = 1; x <= rt; x++)
		{
			for(int y = 1; y <= rt; y++)
			{
				for(int z = 1; z <= rt; z++)
				{
					if(x*x + y*y + z*z + x*y + y*z + z*x == i)
					{
						cnt++;
					}
					else if(x*x + y*y + z*z + x*y + y*z + z*x > i) break;
				}
			}
		}
		cout<<cnt<<endl;
	} 
}


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

int main(){
	int N,C,K;
	cin>>N>>C>>K;
	int T[N];
	for(int i=0;i<N;++i){
		cin>>T[i];
	}
	sort(T,T+N);
	int ans=1;
	int person=1;
	int time=T[0]+K;
	for(int i=1;i<N;++i){
		if((time>=T[i]) && (person<C)) person++;
		else{
			person=1;
			ans++;
			time=T[i]+K;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
import numpy as np
A = np.array(list(map(int, open(0).read().split())))

next_time = (np.array(A) + 9) // 10 * 10
 
if A[np.nonzero(A%10)].size > 0:
    print(sum(next_time) - (10 - min(A[np.nonzero(A%10)]%10)))
else:
    print(sum(next_time))

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  cout<<(n%2==0 ? n : 2*n) << endl;
  return 0;
}


Measured memory_bytes: 256
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std ;
 
typedef long long ll ;
typedef long double ld ;


#define int long long
#define all(v) v.begin() , v.end()

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

const int N = ( int ) 2e5 + 10 ;

int n , ar [ N ] , seg [ N << 2 ] ;

void build ( int id = 1 , int l = 1 , int r = n + 1 ) {
	if ( r - l < 2 ) {
		seg [ id ] = ar [ l ] ;
		return ; 
	}
	int mid = ( r + l ) >> 1 , lc = id << 1 , rc = lc | 1 ;
	build ( lc , l , mid ) ;
	build ( rc , mid , r ) ;
	seg [ id ] = min ( seg [ lc ] , seg [ rc ] ) ; 
}

int get ( int x , int y , int id = 1 , int l = 1 , int r = n + 1 ) {
	if ( r <= x || l >= y ) return n + 1 ;
	if ( l >= x && r <= y ) return seg [ id ] ;
	int mid = ( r + l ) >> 1 ;
	return min ( get ( x , y , id << 1 , l , mid )
		     , get ( x , y , id << 1 | 1 , mid , r ) ) ; 
}

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	for ( int i = 1 ; i <= n ; ++ i )
		cin >> ar [ i ] ;
	build ( ) ;
	int res = 0 ; 
	for ( int i = 1 ; i <= n ; ++ i ) {
		int bl = i , br = i ; 
		int lo = 0 , hi = i + 1 ;
		while ( hi - lo > 1 ) {
			int mid = ( hi + lo ) >> 1 ;
			if ( get ( mid , i ) > ar [ i ] )
				hi = mid ;
			else
				lo = mid ; 
		}
		smin ( bl , hi ) ;
		lo = i , hi = n + 1 ;
		while ( hi - lo > 1 ) {
			int mid = hi + lo >> 1 ;
			if ( get ( i + 1 , mid + 1 ) > ar [ i ] )
				lo = mid ;
			else
				hi = mid ; 
		}
		br = lo ;
		res += ( br - i + 1 ) * ( i - bl + 1 ) * ar [ i ] ;
	}
	cout << res << endl ; 
}


Measured memory_bytes: 7936
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define Rep(i,x) for(int i=head[x];i+1;i=nxt[i])
#define rep2(i,a,b) for(int i=(a);i<(b);i++)
#define ff first
#define ss second
using namespace std;
const int N=200005;
const int inf=1e9+7;
typedef long long ll;
//------------------------------------------head---------------------------------------------------//
ll cnt[30];
char s[N];
int main()
{
	scanf("%s",s+1);
	ll n=strlen(s+1);
	ll ans=n*(n-1)/2ll+1ll;
	rep(i,1,n)cnt[s[i]-'a'+1]++;
	rep(i,1,26)ans-=cnt[i]*(cnt[i]-1)/2ll;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



int main(){
  string s; cin >> s;
  int k;
  int n = s.size();
  if(n == 1)
  k = s[0] - '0';
  else if(n == 2)
  k = s[1] - '0';
  else
  k = s[2] - '0';

  if(k == 2 || k == 4 || k == 5 || k == 7 || k == 9)
  puts("hon");
  else if(k == 0 || k == 1 || k == 6 || k == 8)
  puts("pon");
  else
  puts("bon");

  return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;

    int A;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
    }

    int ans = (N - 1) / (K - 1);
    if ((N - 1) % (K - 1) == 0)
    {
        cout << ans << endl;
    }
    else
    {
        cout << ans + 1 << endl;
    }
}


Measured memory_bytes: 256
S = raw_input()
c1 = S[0] == 'A'
count, pos = 0, -1
for i in range(2, len(S)-1):
	if S[i] == "C":
		count += 1
		pos = i
c2 = count == 1

c3 = True
for i in range(len(S)):
	if i == 0 or i == pos:
		continue
	if S[i].isupper():
		c3 = False


if c1 and c2 and c3:
	print 'AC'
else:
	print 'WA'

Measured memory_bytes: 2568
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            a.add(scan.nextInt());
        }
        Collections.sort(a);
        int sum = 0;
        for (int i = 0; i < K; i++) {
            sum += a.get(i);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 39368
#include<bits/stdc++.h>
#define LL long long
#define M 100005
using namespace std;
int n,Q,h[M],tt;
struct edge{
	int nxt,to,c;
	LL d;
}G[M<<1];
void Add(int a,int b,int c,LL d){
	G[++tt]=(edge){h[a],b,c,d};
	h[a]=tt;
}
LL ans[M],cnt[M],ds[M],dep[M];
struct que{int id,x,y,f;};
vector<que>wk[M];
int fa[M][20];
int LCA(int a,int b){
	if(dep[a]>dep[b])swap(a,b);
	int step=dep[b]-dep[a];
	for(int i=19;i>=0;i--)
		if(step&1<<i)b=fa[b][i];
	if(a==b)return a;
	for(int i=19;i>=0;i--)
		if(fa[a][i]!=fa[b][i])a=fa[a][i],b=fa[b][i];
	return fa[a][0];
} 
void dfs_init(int x,int f,int d){
	fa[x][0]=f;dep[x]=d;
	for(int i=h[x];i;i=G[i].nxt){
		int u=G[i].to;
		if(u==f)continue;
		dfs_init(u,x,d+1);
	}
}
void dfs(int x,int f,LL dd){
	for(int i=0;i<wk[x].size();i++){
		int id=wk[x][i].id,a=wk[x][i].x,b=wk[x][i].y,ff=wk[x][i].f;
		ans[id]+=1LL*ff*(dd-ds[a]+cnt[a]*b);
	}
	for(int i=h[x];i;i=G[i].nxt){
		int u=G[i].to,c=G[i].c,d=G[i].d;
		if(u==f)continue;
		cnt[c]++;ds[c]+=d;
		dfs(u,x,dd+d);
		cnt[c]--;ds[c]-=d;
	}
}
int main(){
	scanf("%d%d",&n,&Q);
	for(int i=1,a,b,c,d;i<n;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		Add(a,b,c,d);Add(b,a,c,d);
	}
	dfs_init(1,0,0);
	for(int j=1;j<=19;j++)
		for(int i=1;i<=n;i++)
			fa[i][j]=fa[fa[i][j-1]][j-1];
	for(int i=1,x,y,u,v;i<=Q;i++){
		scanf("%d%d%d%d",&x,&y,&u,&v);
		wk[u].push_back((que){i,x,y,1});		
		wk[v].push_back((que){i,x,y,1});
		int lca=LCA(u,v);
		wk[lca].push_back((que){i,x,y,-2});
	}
	dfs(1,0,0);
	for(int i=1;i<=Q;i++)
		printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 30964
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using G = vector<vector<int>>;
    
int main(){
    int n, w;
    cin >> n >> w;
    vector<P> ob(n);
    rep(i,n){
        ll w,v;
        cin >> w >> v;
        ob[i] = P(w,v);
    }

    vector<ll> dp(w+1, 0);
    for(int i=1; i<n+1; i++){
        vector<ll> p(w+1, 0);
        swap(dp, p);
        for(int j=1; j<w+1; j++){
            if(j<ob[i-1].first) dp[j] = p[j];
            else{
                dp[j] = max(p[j], p[j-ob[i-1].first] + ob[i-1].second);
            }
        }
    }

    cout << *max_element(dp.begin(), dp.end()) << endl;

    return 0;
}

Measured memory_bytes: 1816
#include<stdio.h>
int main()
{
	int h,l,i,j,n;
	scanf("%d %d %d",&h,&l,&n);
	h=h>=l?h:l;
	i=n/h;
	j=n%h;
	if(j)
	i++;
	printf("%d\n",i);
	return 0;
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,j,k)for(int i=(j);i<=(k);++i)
#define FFOR(i,j,k)for(int i=(j);i<(k);++i)
#define DFOR(i,j,k)for(int i=(j);i>=(k);--i)
#define bug(x)cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define setbit(s,i)(s|=(1LL<<(i)))
#define bit(s,i)(((s)>>(i))&1LL)
#define mask(i)((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
typedef long long ll;
typedef long double ld;

template <typename T> inline void read(T &x){
	char c;
	bool nega=0;
	while((!isdigit(c=getchar()))&&(c!='-'));
		if(c=='-'){
			nega=1;
			c=getchar();
		}
		x=c-48;
		while(isdigit(c=getchar()))
			x=x*10+c-48;
		if(nega) x=-x;
}

template <typename T> inline void writep(T x){
	if(x>9)writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
	if(x<0){
		putchar('-');
		x=-x;
	}
	writep(x);
}

template <typename T> inline void writeln(T x){
	write(x);
	putchar('\n');
}

#define taskname "B"
int k;
int a[100001];
int main(){
	#ifdef Kanikou
		if(fopen(taskname".inp","r"))
			freopen(taskname".inp","r",stdin);
	#endif
	read(k);
    FOR(i,1,k)read(a[i]);
	ll l=2, r=2;
    DFOR(i,k,1){
		ll low;
		if(l%a[i]==0)low=l;
		else low=l-l%a[i]+a[i];
		ll high=r-r%a[i];
		if(low>high){
			puts("-1");
			return 0;
		}
		low/=a[i];
		high/=a[i];
		l=low*a[i];
		r=high*a[i]+a[i]-1;
	}
	write(l);
	putchar(' ');
	write(r);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

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

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

class Node
{
    public:
        int key;
        Node* left;
        Node* right;
        Node* parent;
        Node( int k = 0 );
};

Node::Node( int k )
{
    key = k;
    parent = NULL;
    left = NULL;
    right = NULL;
}

class Tree
{
    private:
        Node* root;
    public:
        Tree();
        void Insert( Tree& t, int k );
        void PrintInorder( Tree t, Node* target );
        void PrintPreorder( Tree t, Node* target );
};

Tree::Tree()
{
    root = NULL;
}

void Tree::Insert( Tree& t, int k )
{
    Node* y = NULL;
    Node* x = t.root;

    while( x != NULL )
    {
        y = x;
        if( k < x -> key )
            x = x -> left;
        else
            x = x -> right;
    }

    Node* n = new Node(k);
    n -> parent = y;

    if( y == NULL )
        t.root = n;
    else if( n -> key < y -> key )
        y -> left = n;
    else
        y -> right = n;
}

void Tree::PrintInorder( Tree t, Node* target )
{
    if( target == NULL )
        target = t.root;

    if( target -> left != NULL )
        PrintInorder( t, target -> left );
    
    cout << " " << target -> key;

    if( target -> right != NULL )
        PrintInorder( t, target -> right );
}

void Tree::PrintPreorder( Tree t, Node* target )
{
    if( target == NULL )
        target = t.root;

    cout << " " << target -> key;

    if( target -> left != NULL )
        PrintPreorder( t, target -> left );

    if( target -> right != NULL )
        PrintPreorder( t, target -> right );
}

int main()
{
    int n, k;
    string s;
    Tree tree;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> s;
        if( s == "insert" )
        {
            cin >> k;
            tree.Insert( tree, k );
        }
        else
        {
            tree.PrintInorder( tree, NULL );
            cout << endl;
            tree.PrintPreorder( tree, NULL );
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 26592
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
ll arr[12][1002];
ll answer(ll a, ll b,ll c, ll d) 
{
    return arr[c][d]-arr[c][b-1]-arr[a-1][d]+arr[a-1][b-1];
}
ll n,m,k;
bool check(int col,int x,bitset<15> bs)  
{
    int row=0;
    for(int i=1;i<=n;i++){
        if(bs[i]==1){
            ll val=answer(row+1,col+1,i,x);
            // cout<<"C "<<val<<endl;
            if(val>k) return false;
            row=i;
        }
    }
    return true;
}
int main()
{
     cin>>n>>m>>k;
    string s; 
    for(int i=1;i<=n;i++){
        ll sum=0;
        for(int j=1;j<=m;j++){
            char ch; cin>>ch;
            sum=sum+(ch)-'0';
            arr[i][j]=arr[i-1][j]+sum;
        }
    }
    vector<ll> v;
    for(int i=1;i<(1<<(n+1));i++){
        bitset<15> bs(i);
        if(bs[0]==1 && bs[n]==1) v.push_back(i); 
    }
    ll mx=INT_MAX;
    for(int i=0;i<v.size();i++){
        bitset<15> bs(v[i]) ;
        // cout<<bs<<endl;
        int col=0;
        int row=0;
        ll ans=0;
        for(int j=1;j<=m;j++){
            if(!check(col,j,bs)) {
                if(col==j-1)  { ans=INT_MAX; break;}
                else {
                    col=j-1; 
                    j--;
                    ans++;
                }
            }
            // else{
            // 	cout<<"j "<<j<<endl;
            // }
        }
        for(int j=1;j<=n-1;j++) if(bs[j]) ans++;
        // cout<<"A "<<ans<<endl;
        mx=min(mx,ans);
    }
    cout<<mx<<endl;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int n, k;
    cin >> n >> k;
    int mv = (n - 1) * (n - 2) / 2;
    if (mv < k) {
        cout << -1 << endl;
        return 0;
    }
    vector<pair<int, int>> ans;
    reps(i, 1, n) {
        ans.emplace_back(0, i);
    }
    int remain = mv - k;
    reps(i, 1, n - 1) {
        reps(ii, i + 1, n) {
            if (remain <= 0) break;
            remain--;
            ans.emplace_back(i, ii);
        }
        if (remain <= 0) break;
    }
    printf("%d\n", sz(ans));
    rep(i, sz(ans)) {
        printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
    }
    return 0;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

double distance_nD(Vi a, Vi b){
    if(a.size() != b.size()) return -1;
    double dist = 0.0;
    REP(i,a.size()){
        dist += (a[i]-b[i])*(a[i]-b[i]);
    }
    return sqrt(dist);
}

bool is_int32( double x ){
    return static_cast<int32_t>(x)==x;
}

const int INF = 1999999999;

int main(){
    int l,r;
    cin>>l>>r;

    if(r-l>=2019){
        cout<<0<<endl;
    }else{
        int ans = INF;
        REP2(i,l,r+1){
            REP2(j,i+1,r+1){
                ans = min(ans,((i%2019)*(j%2019))%2019);
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define INF 1e9+7
 
int main(){
  int N,a;
  cin >> N;
  int A[N];
  multiset<int> LIS;
  for(int i=0; i<N; i++){
    cin >> a;
    A[i] = a;
  }
  LIS.emplace(A[0]);
  for(int i=1; i<N; i++){
    if(A[i]<=*LIS.begin()){
      LIS.emplace(A[i]);
    }else{
      auto it = LIS.lower_bound(A[i]);
      if(it!=LIS.begin()) it--;
      LIS.erase(it);
      LIS.emplace(A[i]);
    }
  }
  cout << LIS.size() << endl;
  return 0;
}

Measured memory_bytes: 5376
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 998244353;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {  
    ll n; cin >> n;
    vector<pll> prime = prime_factorize(n);

    ll cnt = 0; set<ll> st;
    while(true){
        ll mn = 1e18;
        ll sel_num = -1, sel_rui = -1;
        rep(j, prime.size()){
            pll pl = prime[j];
            //cout << "pf:" << pl.first << " ps:" << pl.second << ln;
            for(int i=1; i<=pl.second; i++){
                ll num = pow(pl.first, i);
                //cout << "num:" << num << ln;
                if(st.find(num) == st.end() && mn > num){
                    sel_num = j; sel_rui = i;
                    mn = num;
                    break;
                }
            }
        }
        if(sel_num == -1) break;
        cnt++;
        //cout << "select!:" << mn << ln;
        st.insert(mn); prime[sel_num].second -= sel_rui;
    }
    cout << cnt << ln;
}



Measured memory_bytes: 4108
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	int ans = 0;
	for(int i=0;i<n-2;i++){
		if ( (a[i+1]-a[i]) * (a[i+1]-a[i+2] ) <0 )ans++;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int N = 0, T = 0, i = 0, j = 0, k = 0, tempA = 0, tempB = 0, tempC = 0, tempD = 100000;
	int W[100];

	scanf("%d", &N);
	/*	for (i = 0;i <100;i++)
	{
	scanf("%d", &W[i]);
	if (W[i] == '\0')
	{

	printf("%d\n", i);
	i--;
	break;
	}
	}*/
	while (scanf("%d", &W[i]) != EOF)
	{
		i++;
	}
	//printf("%d", W[2]);
	//printf("%d", i);
	for (T = 0;T < i;T++)
	{
		for (j = 0;j <= T;j++)
		{
			tempA = tempA + W[j];
		}
		for (k = T+1;k < i;k++)
		{
			tempB = tempB + W[k];
		}
		tempC = abs(tempA - tempB);
		if (tempD > tempC)tempD = tempC;
		tempA = 0;
		tempB = 0;
		tempC = 0;

	}
	printf("%d", tempD);
	
}

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

using namespace std;

#define N 300000

int n,x,y,tot,f[N],head[N],sz[N],d[N];
struct edge{int v,nxt;}e[N];

void add(int x,int y){e[++tot].v=y; e[tot].nxt=head[x]; head[x]=tot;}

void dfs(int u,int fa){
	int sum=0;
	for (int i=head[u],v;i;i=e[i].nxt)
		if ((v=e[i].v)!=fa){
			dfs(v,u); ++sz[u];
			if (f[v]) sum++;
			f[u]+=f[v];
		}
	if (sz[u]>sum) f[u]+=sz[u]-sum-1;
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<n;++i){
		scanf("%d%d",&x,&y); ++x; ++y;
		add(x,y); add(y,x); ++d[x]; ++d[y];
	}
	for (int i=1;i<n;i++)
		if (d[i]>=3){
			dfs(i,0); printf("%d\n",f[i]);
			return 0;
		}
	puts("1");
	
	return 0;
}
			

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


  
int main(){

  int64_t h,w;
  cin>>h>>w;
  
  int64_t difference1,difference2,difference3,difference4;
  

  int64_t k=h/3;
  int64_t a,b,c;
  a=k*w;
  b=min(((w+1)/2)*(h-k),((h-k+1)/2)*w);
  c=h*w-a-b;
  difference1=max(a,max(b,c))-min(a,min(b,c));
  
  a=(k+1)*w;
  b=min(((w+1)/2)*(h-k-1),((h-k)/2)*w);
  c=h*w-a-b;
  difference2=max(a,max(b,c))-min(a,min(b,c));
  
  
  k=w/3;
  
  a=(k+1)*h;
  b=min(((h+1)/2)*(w-k-1),((w-k)/2)*h);
  c=h*w-a-b;
  difference3=max(a,max(b,c))-min(a,min(b,c));

  
  a=k*h;
  b=min(((h+1)/2)*(w-k),((w-k+1)/2)*h);
  c=h*w-a-b;
  difference4=max(a,max(b,c))-min(a,min(b,c));
  
  int64_t answer;
  
  answer=min(min(difference1,difference2),min(difference3,difference4));
  
  cout<<answer<<endl;
  

  

}
  















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

#define int long long

const int N = 1e3 + 10, mod = 1e9 + 7;
int n, m, ans = 1, ar[2][N], mark[N * N];

int32_t main() {
	cin >> n >> m;
	for (int j = 0; j < n; j++) {
			cin >> ar[0][j];
			if (ar[0][j] > n * m || mark[ar[0][j]])
				return cout << 0, 0;
			mark[ar[0][j]] = 1;
	}
	
	memset(mark, 0, sizeof mark);
	for (int i = 0; i < m; i++) {
		cin >> ar[1][i];
		if (ar[1][i] > n * m || mark[ar[1][i]])
			return cout << 0, 0;
		mark[ar[1][i]] = 1;
	}
		
	sort(ar[0], ar[0] + n, [&] (int a, int b) { return a > b; });
	sort(ar[1], ar[1] + m, [&] (int a, int b) { return a > b; });
	
	int l = 0, r = 0;
	for (int i = m * n; i; i--) {
		while (l < n && ar[0][l] >= i)
			l++;
		while (r < m && ar[1][r] >= i)
			r++;
		if (!l || !r)
			return cout << 0, 0;
//		cout << l << ',' << r << " " << ar[0][l - 1] << ' ' << ar[1][r - 1] << endl;
		if (ar[0][l - 1] == i && ar[1][r - 1] == i);
		else if (ar[0][l - 1] == i)
			ans = (ans * r) % mod;
		else if (ar[1][r - 1] == i)
			ans = (ans * l) % mod;
		else
			ans = (ans * (l * r - (m * n - i))) % mod;
	}
	cout << ans;
}

Measured memory_bytes: 8192
#include <iostream>

using namespace std;

int main()
{
	int n,a,b;
	int suma,sumb;
	while(cin>>n,n){
		suma=sumb=0;
		for(int i=0; i<n; i++){
			cin>>a>>b;
			if      ( a<b ){
				sumb += a+b;
			}else if( a>b ){
				suma += a+b;
			}else{
				suma += a;
				sumb += b;
			}
		}
		printf("%d %d\n",suma,sumb);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 2000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
//-------------------------------------------------------------------
ll gcd(ll a, ll b){
  if(b<a) swap(a, b);
  ll r = a % b;
  if(r==0) return b;
  while(r!=0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  return (a/g)*b;
}
int main(int argc, char const *argv[]) {
  ll ans, t, n;std::cin >> n;
  std::cin >> ans;
  re(i, n-1){
    std::cin >> t;
    ans = lcm(ans, t);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
int n,i,j,m,f;
char a[100],b[100],x;
 
while(1){
scanf("%d ",&n);
if(n==0)break;
for(i=0;i<n;i++){
scanf("%c %c ",&a[i],&b[i]);
}
scanf("%d ",&m);
for(i=0;i<m;i++){
scanf("%c ",&x);
f=0;
for(j=0;j<n;j++){
if(x==a[j]){
printf("%c",b[j]);
f=1;
break;
}
}
if(f==0){
printf("%c",x);
}
}
printf("\n");
}
 
return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back



int main(){
    int h,w;
    cin >> h >> w;
    char s[h+2][w+2];
    char ans[h+2][w+2];
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> s[i][j];
        }
    }



    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'){
                continue;
            }
            int count=0;
            if(s[i-1][j-1]=='#'){
                count++;
            }
            if(s[i-1][j]=='#'){
                count++;
            }
            if(s[i-1][j+1]=='#'){
                count++;
            }
            if(s[i][j-1]=='#'){
                count++;
            }
            if(s[i][j+1]=='#'){
                count++;
            }
            if(s[i+1][j-1]=='#'){
                count++;
            }
            if(s[i+1][j]=='#'){
                count++;
            }
            if(s[i+1][j+1]=='#'){
                count++;
            }
            s[i][j]= char(count+'0');     
            
        }
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cout << s[i][j];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,l;cin>>n>>l;
  long long sum=0;
  int mini=INT_MAX;
  int ini=0;
  for(int i=1;i<=n;i++){
    int p=l+i-1;
    if(mini>abs(p)){mini=abs(p);ini=p;}
    sum+=p;
  }
  cout<<sum-ini;
  return 0;  
}


Measured memory_bytes: 256
N = int(input())
a = [int(x) for x in input().split()]

l = {}
for i in range(N):
    l[i] = a[i]

sorted_l = sorted(l.items(), key=lambda x: x[1])

res = ""
for key, value in sorted_l:
    res += str(key + 1) + " "


print(res)


Measured memory_bytes: 25500
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d=0;
    cin>>a>>b>>c;
    if((c-b)%2==0){
	d=(c-b)/2;
	b=0;
	c=0;
    }
    else{
	if((b-1)<(a-c)){
	    c-=b;
	    d=b;
	    b=1;
	}
	else{
	    b+=(a-c+1);
	    d=a-c+1;
	    c=a;
	}
	d+=(abs(b,c)/2);
    }
    cout<<d<<"\n";
}


Measured memory_bytes: 256
L, R = map(int, input().split())
counter = 0
result = 0

for i in range(L,R+1):
  counterJ = 0
  for j in range(i+1, R+1):
    modResult = (i * j) % 2019 
    if i == L and j == L+1:
      result = modResult
    elif result > modResult:
      result = modResult
    if counterJ == 2019:
      break
    counterJ += 1
    
  counter += 1
  if counter == 2019:
    break;
    
print(result)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int a[3];
int main(){
  int n;cin>>n;
  for(int i = 0; n > i; i++){
    int tmp;cin>>tmp;
    if(tmp % 4 == 0)a[2]++;
    else if(tmp % 2 == 0)a[1]++;
    else a[0]++;
  }
  //02020
  if(a[2]+1 == a[0] && a[1] == 0)cout << "Yes" << endl;
  else if(a[2] >= a[0])cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

struct Kruskal{

  struct UnionFind{
    Int n;
    vector<Int> r,p;
    UnionFind(){}
    UnionFind(Int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
    Int find(Int x){
      return (x==p[x]?x:p[x]=find(p[x]));
    }
    bool same(Int x,Int y){
      return find(x)==find(y);
    }
    void unite(Int x,Int y){
      x=find(x);y=find(y);
      if(x==y) return;
      if(r[x]<r[y]) swap(x,y);
      r[x]+=r[y];
      p[y]=x;
    }
  };
  
  struct edge{
    Int from,to;
    double cost;
    Int used;
    char color;
    edge(){}
    edge(Int from,Int to,double cost,char color):
      from(from),to(to),cost(cost),used(0),color(color){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  Int n;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(Int sz):n(sz){}
  
  Int build(Int k=-1){
    sort(edges.begin(),edges.end());
    UnionFind uf(n+1);
    double res=0;
    Int cnt=0;
    for(Int i=0;i<(Int)edges.size();i++){
      edge &e=edges[i];
      if(!uf.same(e.from,e.to)){
	e.used=1;
	res+=e.cost;
	uf.unite(e.from,e.to);
	cnt++;
      }
    }
    if(cnt+1!=n) return -1;
    return res;
  }
};

signed main(){
  Int n,m,k;
  while(cin>>n>>m>>k,n){
    Kruskal kr(n);
    auto edges=kr.edges;
    for(Int i=0;i<m;i++){
      Int u,v,w;
      char c;
      cin>>u>>v>>w>>c;
      u--;v--;
      edges.emplace_back(u,v,w,c);
    }
    double ub=1e12,ans;
    auto check=[&](double x){
      x-=ub;
      kr=Kruskal(n);
      for(auto e:edges){
	if(x>0&&e.color=='A') e.cost+=x; 
	if(x<0&&e.color=='B') e.cost-=x; 
	kr.edges.emplace_back(e);
      }
      
      ans=kr.build();
      if(ans<0) return Int(-1);
      if(x>0) ans-=x*k;
      if(x<0) ans+=x*(n-1-k);
      
      Int res=0;
      for(auto e:kr.edges)
	res+=(e.used&&e.color=='A');
      return res;
    };
    double l=0,r=2*ub;
    if(check(l)<k||check(r)>k){
      cout<<-1<<endl;
      continue;
    }
    for(Int i=0;i<1000;i++){
      double m=(l+r)/2;
      if(check(m)>=k) l=m;
      else r=m;
    }
    check(l);
    cout<<(Int)ceil(ans)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define REP(i, t) for(int i = 0; i < t; i++)

int main()
{
    string O, E;
    cin >> O >> E;
    REP(i, E.length()) cout << O[i] << E[i];
    if (O.length() - E.length() == 1) cout << O[O.length() - 1];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
S = list(input())
ans = 0
if S[0] == '0':
    for i in range(1,len(S),2):
        if S[i] == '0':
            ans += 1
    for i in range(2,len(S),2):
        if S[i] == '1':
            ans += 1

else:
    for i in range(1,len(S),2):
        if S[i] == '1':
            ans += 1
    for i in range(2,len(S),2):
        if S[i] == '0':
            ans += 1
print(ans)


Measured memory_bytes: 3956