akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

using namespace std;

#define MAX 200000
#define Sentinel 2000000000
typedef long long llong;

int L[ MAX / 2 + 2], R[ MAX / 2 + 2];

llong cnt = 0;

void merge( int A[], int left, int mid, int right){

    int i , j , k;

    int n1 = mid - left;
    int n2 = right - mid;

    for( i = 0; i < n1 ; i++ ) L[i] = A[ left + i ];

    for( i = 0; i < n2 ; i++) R[i] = A[ mid + i ];

    L[n1] = R[n2] = Sentinel;

    i = j = 0;

    for( k = left ; k < right ; k++ ){

        if( L[i] <= R[j] ){

            A[k] = L[i];
            i++;
    
        } else{

            A[k] = R[j];
            j++;

            cnt += n1 - i;

        }

    }

}


void mergesort( int A[],  int left, int right){

    int mid;

    if( left + 1 < right ){

        mid = ( left + right ) / 2; 

        mergesort( A, left, mid );
        mergesort( A, mid, right );

        merge( A, left, mid, right);


    } 

}

int main(){

    int A[MAX], n, i;

    scanf("%d", &n);

    for( i = 0 ; i < n ; i++ ) scanf( "%d", &A[i] );


    mergesort( A, 0, n);

    printf("%lld\n", cnt);

    return 0;

}

Measured memory_bytes: 4284
N = int(input())
H = list(map(int,input().split(' ')))
if N == 1:
  print('Yes')
  exit()
for i in range(N-1,0,-1):
  if H[i] >= H[i-1]:
    pass
  elif H[i-1] - H[i] == 1:
    H[i-1] -= 1
  else:
    print('No')
    exit()
print('Yes')
    

Measured memory_bytes: 15020
#include <iostream>
using namespace std;
int main()
{int h,n,s=0;
cin>>h>>n;
int a[n];
 for(int i=0;i<n;i++)
 {cin>>a[i];
   s=s+a[i];
 }
   if(s>=h)
     cout<<"Yes";
 else
   cout<<"No";
 return 0;
}

Measured memory_bytes: 640
# Good Sequence
n = int(input())
a = list(map(int, input().split()))
count = {}
ans = 0
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
for i, c in count.items():
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)


Measured memory_bytes: 17780
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 18 09:48:56 2017

@author: syaga
"""

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    num = 0
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        temp = A[i]
        A[i] = A[minj]
        A[minj] = temp
        if minj != i:
            num += 1
    print(" ".join(map(str, A)))
    print(num)

Measured memory_bytes: 7688
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
  q = p[i-1:i+2]
  asc = sorted(q)
  des = sorted(q,reverse=True)
  if q==asc or q==des:
    count+=1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vint a(n);
    rep(i, n) cin >> a[i];

    vll sum(n+1, 0);
    rep(i, n) sum[i+1] = sum[i] + a[i];

    vll ls;
    rep(i, n) srep(j, i, n) {
        ls.push_back(sum[j+1] - sum[i]);
    }

    ll ans = 0;
    for (int i = 40; i >= 0; --i) {
        vll ls2;
        rep(j, ls.size()) {
            if ((1ll << i) & ls[j]) ls2.push_back(ls[j]);
        }
        if (ls2.size() >= k) {
            ls = ls2;
            ans += (1ll << i);
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int main(void){
  int N;
  string S;
  cin >> N >> S;
  unordered_map<string, int> hash;
  hash["R"] = 0;
  hash["B"] = 0;
  for(int i=0; i<N; i++){
    hash[S.substr(i, 1)] += 1;
  }
  if(hash["R"] >  N / 2){ cout << "Yes" << endl;}
  else{ cout << "No" << endl;}
  return 0;
}
  

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

using namespace std;

using ll = long long;

int main(void) {
    ll n, m;
    cin >> n >> m;

    vector<pair<ll, ll>> bombs(n);
    for(auto &e: bombs) cin >> e.first >> e.second;
    sort(bombs.begin(), bombs.end());

    vector<ll> mp(n+1, 0);
    for(ll i=0; i<n; i++)
        mp[i] = bombs[i].second;

    vector<vector<ll>> G(n+1);
    map<pair<ll,ll>,ll> id;

    for(ll i=0; i<m; i++) {
        ll l, r;
        cin >> l >> r;
        ll li = lower_bound(bombs.begin(), bombs.end(), pair<ll,ll>(l, 0ll)) - bombs.begin();
        ll ri = upper_bound(bombs.begin(), bombs.end(), pair<ll,ll>(r, 1ll)) - bombs.begin();

        // 1 1 1 0
        // 1 0 1 0
        G[li].push_back(ri);
        G[ri].push_back(li);
        id[{li,ri}] = i;
    }

    vector<ll> di(n+1, 0);
    di[0] = mp[0];
    for(ll i=1; i<=n; i++)
        di[i] = mp[i] ^ mp[i-1];

    vector<ll> rs;

    set<ll> vis;
    auto dfs = [&](auto dfs, ll cur, ll pre) -> ll {
        if(vis.count(cur)) return 0;
        vis.insert(cur);
        ll r = di[cur];
        for(auto &v: G[cur]) {
            if(v == pre) continue;
            r ^= dfs(dfs, v, cur);
        }
        if(r) rs.push_back(id[{min(cur,pre), max(cur,pre)}]);
        return r;
    };
    for(ll i=0; i<=n; i++)
        if(dfs(dfs, i, -1)) {
            cout << -1 << endl;
            return 0;
        }

    sort(rs.begin(), rs.end());
    cout << rs.size() << endl;
    for(auto &x: rs) cout << x+1 << ' '; cout << endl;
}


Measured memory_bytes: 36600
# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb

# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# INF = 1001001001001
# MOD = 1000000007

def main():

    N, K = map(int, input().split())
    H = list(map(int, input().split()))

    if N <= K:
        print(0)
        exit()

    H.sort(reverse=True)
    H = H[K:]
    print(sum(H))


if __name__ == '__main__':
    main()


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

char wo[30];
int mk[30];

main()
{
	scanf("%s",wo);
	int len=strlen(wo);
	if(len!=26)
	{
		for(int i=0;i<len;i++)
		{
			mk[wo[i]-'a']=1;
		}
		printf("%s",wo);
		for(int i=0;i<26;i++)
		{
			if(mk[i]==0)
			{
				printf("%c",i+'a');
				return 0;
			}
		}
	}
	else
	{
		for(int i=0;i<26;i++)
		{
			mk[i]=1;
		}
		for(int i=25;i>=0;i--)
		{
			for(int j=0;j<26;j++)
			{
				if(mk[j]==0)
				{
					if('a'+j>wo[i])
					{
						for(int k=0;k<i;k++)
						{
							printf("%c",wo[k]);
						}
						printf("%c",'a'+j);
						return 0;
					}
				}
			}
			mk[wo[i]-'a']=0;
		}
		printf("-1");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll arr[100005];

int main()
{
	int n;
	cin >> n;
	
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		arr[x] += 1;
		sum += x;
	}
	int q;
	cin >> q;
	while (q--) {
		int b, c;
		cin >> b >> c;
		
		arr[c] += arr[b];
		sum = sum + arr[b] * c-arr[b]*b ;
		arr[b] = 0;
		cout << sum << '\n';
	}
		
}

Measured memory_bytes: 4412
s = int(input())
a = [s]
flag = True
while flag:
    if a[-1] % 2 == 0:
        a.append(a[-1]//2)
    else:
        a.append(3*a[-1]+1)
    for i in range(len(a)-1):
        if a[i] == a[-1]:
            m = len(a)
            flag = False
            break
print(m)

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

int main(){
int N;
  cin>>N;
  vector<string>W(N);
  for(int i=0; i<N; i++){
   cin>>W[i]; }
  
  bool flag=true;
  for(int i=0; i<N; i++){
   for(int j=i+1; j<N; j++){
    if(W[i]==W[j]){flag=false;}
   }
  }
  
  for(int i=1; i<N; i++){
    if(W[i-1][W[i-1].size()-1]!=W[i][0]){flag=false;}
  }
  
 if(!flag){cout<<"No";}
 else{cout<<"Yes";}
}

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

int main(){
  int n; cin >> n;
  int h[n];
  for(int i=0;i<n;i++){cin >> h[i];}
  int ans = 1;
  int highest = h[0];
  for(int i=1;i<n;i++){
    if(h[i]>=highest){
      ans++;
      highest = h[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

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

#define dump(x) cerr << #x << " = " <<(x)<<endl;
#define debug(x) cerr << #x << " = " <<(x) << "(L" << __LINE__ << ")" << __FILE__ << endl;

using namespace std;

int main(void){
  int i,n,k;
  cin >> n >> k;
  vector<int> v(k);
  REP(i,k) cin >> v[i];
  bool up = true;
  while(up){
    int s = n;
    bool out = false;
    while(s){
      //cout << s << endl;
      int t = s%10;
      if(find(v.begin(), v.end(), t)!=v.end()){
        out = true;
        break;
      }
      s/=10;
    }
    if(out){n++;}
    else{up=false;}
  }
  cout << n << endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;

int main() {
    int n;cin >> n;
    string s;cin >> s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    rep(i,n) {
        if(s[i] == 'R') r.pb(i);
        if(s[i] == 'G') g.pb(i);
        if(s[i] == 'B') b.pb(i);
    }
    ll ans = r.size()*g.size()*b.size();
    for(int start = 0;start<n-1;start++) {
        for(int end = start+1;end<n;end++) {
            if((end +start) %2 == 1) continue;
            if(s[start] != s[end] && s[start] != s[(end+start)/2] && s[end] != s[(end+start)/2]) ans--;
            
        }
    }
    cout << ans;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i, 0, n) {
        cin >> w[i];
    }
    int ans = INF;
    rep(i, 1, n) {
        int left  = 0;
        int right = 0;
        rep(j, 0, n) {
            if (j <= i) {
                left += w[j];
            } else {
                right += w[j];
            }
        }
        chmin<int>(ans, abs(right - left));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b,c=0,d=1,f;
  cin>>a>>b;
  double e=a;
  if(a==1)
    cout<<b<<endl;
  else{
  fo(i,10000000){
    if(pow(i,e)>b)
      break;
    c=i;
  }
  for(double i=2;i<c+1;i++){
    f=pow(i,e);
    if(b%f==0){
      b=b/f;
      d*=i;
      i--;
    }
  }
  cout<<d<<endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++) {
        int flips = 0, score;
        for(score = i; score < k; score *= 2) {
            flips++;
        }
        ans += 1.0 / (1 << flips);
    }
    cout << fixed << setprecision(9) << ans / n << endl;
    return 0;
}


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

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

	int d,n;
	cin >> d >> n;
	long long ans = 0;
	int p = 1; for(int i=0; i<d; i++) p*= 100;
	if(n<=99) ans = n*p;
	else ans = 101*p;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
using ll = long long;

using namespace std;




int main()
{/*六日目*/
//少数も使いたい割り算はしない方がいい
// 数値の大きさ
//for文で0代入する場所はforの一文下
//オーバーフローする一手手前を分解して作る・ 割り算で減らしていく
//for文いつも間違える/ i<nなら最後はa[n-1]
	int n; cin >> n;
	int maxx=0;
	vector<int> su(n);
	for (int i = 0;i < n;i++) {
		cin >> su[i];
		if (maxx < su[i])
			maxx = su[i];
	}
	int min = 0;
	for (int p = 1;p <=maxx;p++) {//n-1は最後の項
		int sum = 0;
		if (p == 1) {// p = 1の時
			for (int j = 0;j < n;j++) {
				min += (p - su[j]) * (p - su[j]); //一個sumを作る
			}
		}
		else {//pが1以外
			for (int j = 0;j < n;j++) {
				sum += (p - su[j]) * (p - su[j]);
				if (sum >= min)
					break;
			}if (min > sum)
				min = sum;

		}
	}cout << min;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    T = input[0];
  // console.log(T);
   
    var len = T.length;
  //console.log(len);
 var p = len%2;q = Math.floor(len/2);cnt=0;i=0;
// console.log (p,q);
 //console.log(T.substr(i,1));
// console.log(T.substr(len-1,1));
  
	  for(i = 0;i<q;i++)
	  {if (T.substr(i,1)==T.substr(len-1-i,1)){cnt=cnt+0;}
	  else{cnt++;}
		  
	  }
	  console.log(cnt);
	

	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

int main() {
  int result = 0, N;
	cin >> N;

	// initialize
	vector<int> L(N);
	for(int i = 0; i < N; i++) {
		cin >> L[i];
	}
	// sort
	sort(L.begin(), L.end());

  ll ans = 0;
  for(ll i = N - 1; i >= 0; i--) {
    for(ll j = i - 1; j >= 0; j--) {
			// 二部探索で L[i]+L[j] 以上のパターンを走査
      auto itr = lower_bound(L.begin(), L.end(), L[i] + L[j]);
			// 要件を満たさない Indexを取得
      ll ngIndex = distance(itr, L.end());
			// ngIndex の値は 要件を満たさないパターン数を表しているので、L[i]までのパターン数から差し引く
      result += (N - 1 - i) - ngIndex;
    }
  }

	cout << result << endl;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;

int main() {
	ll n, m, r;
	vector<ll> v;
	ll ans = INF;

	cin >> n >> m >> r;

	vector<vector<ll>> dist(n, vector<ll>(n, INF));

	REP(i, r) {
		ll a;
		cin >> a;
		v.push_back(a - 1);
	}

	REP(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		dist[a - 1][b - 1] = c;
		dist[b - 1][a - 1] = c;
	}

	REP(k, n) {
		REP(i, n) {
			REP(j, n) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

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

	do {
		ll d = 0;

		REP(i, r - 1) {
			d += dist[v[i]][v[i + 1]];
		}

		if (d < ans) {
			ans = d;
		}
	} while (next_permutation(v.begin(), v.end()));

	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

string s="",a="zabcdefghijklmnopqrstuvwxyz";

/**ll make(ll x)
{
    if (x<27)
    {
        s+=a[x];
        return x;
    }
    if ()
}**/

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,x;
    cin>>n;
    //make(n);
    while (n)
    {
        s+=a[n%26];
        if (!(n%26))
            x=26;
        else
            x=n%26;
        n-=x;
        n/=26;
    }
    for (int i=sz(s)-1;i+1;--i)
        cout<<s[i];
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  map<char, int> l,r;
  for(int i = 0; i < N; ++i){
    r[S[i]]++;
  }
  int ans = 0;
  for(int i = 1; i < N; ++i){
    int cnt = 0;
    r[S[i-1]]--;
    l[S[i-1]]++;
    for(auto itr = l.begin(); itr != l.end(); itr++){
      if(r[itr->first] > 0) cnt++;
    }
    ans = max(cnt, ans);
  }
  cout << ans << endl;
}


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

#define rep(i,x,y) for(int (i)=(x);(i)<(y);(i)++)

int deast[7][7] = {
  {0, 0, 0, 0, 0, 0, 0},
  {0, 0, 3, 5, 2, 4, 0},
  {0, 4, 0, 1, 6, 0, 3},
  {0, 2, 6, 0, 0, 1, 5},
  {0, 5, 1, 0, 0, 6, 2},
  {0, 3, 0, 6, 1, 0, 4},
  {0, 0, 4, 2, 5, 3, 0}
};

enum sf{
  top, south, east, north, west, bottom
};

void oneflip(int *m, int t, int s, int e, int n, int w, int b){
  m[0] = t; m[1] = s; m[2] = e;
  m[3] = n; m[4] = w; m[5] = b;
}

struct dice_t{
  int men[6];

  dice_t(int t,int f){
    men[0]=t;
    men[1]=f;
    men[2]=deast[t][f];
    men[3]=7-f;
    men[4]=7-men[2];
    men[5]=7-t;
  }

  void flip(int r){
    switch(r){
      case 0://south
      oneflip(men, men[north], men[top], men[east],
              men[bottom], men[west], men[south]);
      break;
      case 1://east
      oneflip(men, men[west], men[south], men[top],
              men[north], men[bottom], men[east]);
      break;
      case 2://north
      oneflip(men, men[south], men[bottom], men[east],
              men[top], men[west], men[north]);
      break;
      case 3://west
      oneflip(men, men[east], men[south], men[bottom],
              men[north], men[top], men[west]);
      break;
    }
  }
};

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

void solve(int n) {
  std::vector<dice_t> vs[300][300];
  const int geta=150;
  rep(i,0,n){
    int t,f;
    cin >> t >> f;
    dice_t d(t,f);
    int x=geta,y=geta;
    while(true){
      bool f=false;
      for(int i=6; i>=4; --i){
          if(f) break;
          rep(j,1,5){
            if(d.men[j]!=i) continue;
            int nx=x+dx[j-1],ny=y+dy[j-1];
            if(vs[x][y].size()<=vs[nx][ny].size()) continue;
            d.flip(j-1);
            x=nx;
            y=ny;
            f=true;
            break;
        }
      }
      if(!f){
        vs[x][y].push_back(d);
        break;
      }
    }
  }
  int ans[7]={};
  rep(x,0,300) rep(y,0,300){
    if(!vs[x][y].size()) continue;
    ++ans[vs[x][y].back().men[0]];
  }
  rep(i,1,7) cout << ans[i] << (i==6?"\n":" ");
}

int main(){
  while (true) {
    int n;
    cin >> n;
    if(!n) break;
    solve(n);
  }
}

Measured memory_bytes: 5192
import collections
n = int(raw_input())

adj = collections.defaultdict(list)

for _ in range(n - 1):
	u, v, w = map(int, raw_input().split(' '))
	adj[u].append((v,w))
	adj[v].append((u,w))
h = { 1:0 }
def dfs(h, adj):
	stack = collections.deque([1])
	while(stack):
		u = stack.pop()
		for v,w in adj[u]:
			if v not in h:
				h[v] = (1- h[u]) if (w % 2) else h[u]
				stack.append(v) #(v, h, adj)
dfs(h, adj)
for node in range(1, n + 1): 
	print h[node]

Measured memory_bytes: 72860
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int sum;
    char a = s[0];
    char b = s[1];
    char c = s[2];
    char d = '1';
    sum = int(a == d) + int(b == d) + int(c == d);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    while (true) {
        int cnt = 0;
        bool flag = false;
        rep(i, n) {
            if (a[i] > 0) {
                if (!flag) {
                    flag = true;
                    cnt++;
                }
                a[i]--;
            } else {
                flag = false;
            }
        }
        ans += cnt;
        if (cnt == 0) break;
    }
    cout << ans << endl;
}

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


using namespace std;

const int N = 100010;

int vec[N], vec2[N];
map <int,int> mp;

int main() {
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; ++i) {
		scanf("%d", &vec[i]);
		mp[vec[i]] = i % 2;
	}

	sort(vec, vec+n);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if(i%2 != mp[vec[i]]) {
			ans++;
		}
	}
	printf("%d\n", ans/2);


}

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

int main(){
  int n;
  cin >> n;
  vector<int> dp(3);
  for(int days=0; days < n; ++days){

    vector<int> hapi(3);
    for(int i=0; i < 3; i++){
      cin >> hapi[i];
    }

    vector<int> dp_pro(3, 0);
    
    for(int i=0; i < 3; i++){
      for(int j=0; j < 3; j++){
        if(j!=i){
          dp_pro[j] = max(dp_pro[j], dp[i] + hapi[j]);
        }
      }
    }
    dp = dp_pro;
  }

  cout << max({dp[0],dp[1],dp[2]}) << endl;
}


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

const int MAXN = 100010;
int dp[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int N; cin >> N;
	iota(dp, dp + N + 1, 0);
	for (int base : {6, 9}) {
		for (int a = base; a <= N; a *= base) {
			for (int b = 0; b+a <= N; b++) {
				dp[b+a] = min(dp[b+a], dp[b] + 1);
			}
		}
	}
	cout << dp[N] << '\n';

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

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

void solve(ll L, ll R, ll d) {
  cout << (R / d) - ((L - 1)/ d) << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll L;
  cin >> L;
  ll R;
  cin >> R;
  ll d;
  cin >> d;

  solve(L, R, d);

  return 0;
}


Measured memory_bytes: 3648
let [| r; d; x |] = stdin.ReadLine().Split(' ') |> Array.map int

let rec getWeights cnt prev xs =
    match cnt with
    | 0 -> List.rev xs
    | _ ->
        let present = r * prev - d
        getWeights (cnt - 1) present (present :: xs)

getWeights 10 x [] |> List.iter (printfn "%d")


Measured memory_bytes: 14044
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)

template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

ll const INF = 1LL << 60;
ll const MAX_N = 100000;
ll const MOD = 1000000007;

// 桁DPの遷移
// - 2進数の計算

// N=63435 について、
// dp[3][true]  : 634○○未満となる数(00000 - 63399)についての暫定の答え
// dp[3][false] : 634○○ となる数(63400 ~ 63429)についての暫定の答え

// dp[i][true] から dp[i+1][true]にのみ遷移
// (i桁目まででNより小さいなら、i+1桁目をどのように選んでもNより小さい）
// dp[i][false] から dp[i+1][true]へ遷移
// (i桁目までNと同じで、 i+1桁目はNより小さい数の時)
// dp[i][false] から dp[i+1][false]へ遷移
// (i桁目までNと同じで、 i+1桁目もNと同じ数の時)

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

    const int MAX_BIT = 45;
    ll dp[MAX_BIT + 1][2];

    rep(i, MAX_BIT + 1) rep(j, 2) dp[i][j] = -1;

    dp[MAX_BIT][0] = 0;

    for (int d = MAX_BIT - 1; d >= 0; d--) {
        ll mask = 1LL << d;
        ll num = 0;

        rep(i, N) {
            if (A[i] & mask) num++;
        }

        // cout << "dp[" << d + 1 << "][0]: " << dp[d + 1][0] << ", "
        //      << "dp[" << d + 1 << "][1]: " << dp[d + 1][1] << endl;
        // cout << "- mask: " << mask << endl;
        // cout << "- 0:" << N - num << ", 1:" << num << endl;
        // cout << "- mask * num: " << mask * num << endl;
        // cout << "- mask * (N - num): " << mask * (N - num) << endl;

        if (dp[d + 1][1] >= 0) {
            dp[d][1] = dp[d + 1][1] + mask * max(num, N - num);
        }

        if (dp[d + 1][0] >= 0) {
            if (K & mask) {
                chmax(dp[d][1], dp[d + 1][0] + mask * num);
                dp[d][0] = dp[d + 1][0] + mask * (N - num);
            } else {
                dp[d][0] = dp[d + 1][0] + mask * num;
            }
        }
    }

    // rep(i, MAX_BIT + 1) {
    //     rep(j, 2) cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    cout << max(dp[0][0], dp[0][1]) << endl;

    return 0;
}


Measured memory_bytes: 4052
package main

import "fmt"

func Range(a, b, c int) string {
	if a < b && b < c {
		return "Yes"
	} else {
		return "No"
	}
}

func main(){
	a := 0
	b := 0
	c := 0
		fmt.Scan(&a)
		fmt.Scan(&b)
		fmt.Scan(&c)
	fmt.Println(Range(a, b, c))
}


Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int P = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
struct BinaryIndexTree {
	int n, a[MAXN];
	void init(int x) {
		n = x;
		memset(a, 0, sizeof(a));
	}
	void modify(int x, int d) {
		for (int i = x; i <= n; i += i & -i)
			update(a[i], d);
	}
	int query(int l, int r) {
		int ans = 0;
		for (int i = r; i >= 1; i -= i & -i)
			update(ans, a[i]);
		for (int i = l - 1; i >= 1; i -= i & -i)
			update(ans, P - a[i]);
		return ans;
	}
} BIT, CIT;
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int n, s, a[MAXN], cnt[MAXN];
int Max[MAXN], pre[MAXN], val[MAXN];
int main() {
	read(n), s = 1;
	for (int i = 1; i <= n; i++)
		read(a[i]), cnt[a[i]]++;
	for (int i = n; i >= 1; i--)
		cnt[i] += cnt[i + 1];
	for (int i = 1; i <= n; i++) {
		cnt[i] -= n - i;
		s = 1ll * s * cnt[i] % P;
	}
	if (s == 0) {
		puts("0");
		return 0;
	}
	for (int i = 1; i <= n; i++)
		val[i] = (cnt[i] - 1ll) * power(cnt[i], P - 2) % P;
	int last = 0; pre[0] = 1;
	for (int i = 1; i <= n; i++) {
		if (val[i] == 0) {
			for (int j = last; j <= i - 1; j++)
				Max[j] = i - 1;
			last = i, pre[i] = 1;
		} else pre[i] = 1ll * pre[i - 1] * val[i] % P;
	}
	for (int i = last; i <= n; i++)
		Max[i] = n;
	int ans = 0; BIT.init(n);
	for (int i = n; i >= 1; i--) {
		update(ans, 1ll * s * power(2ll * pre[a[i]] % P, P - 2) % P * BIT.query(a[i], Max[a[i]]) % P);
		BIT.modify(a[i], pre[a[i]]);
	}
	BIT.init(n), CIT.init(n);
	for (int i = 1; i <= n; i++) {
		update(ans, P - 1ll * s * power(2ll * pre[a[i]] % P, P - 2) % P * BIT.query(a[i] + 1, Max[a[i]]) % P);
		update(ans, 1ll * s * CIT.query(a[i] + 1, n) % P);
		BIT.modify(a[i], pre[a[i]]);
		CIT.modify(a[i], 1);
	}
	writeln(ans); 
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;


int main() {
    int N[10];
    int num1[10];
    int num2[10];
    int n;
    cin>>n;
    int temp=0;
    int t1 = 0, t2 = 0;
    for (int i = 0; i < n; ++i) {
        cin>>num1[i];
    }
    for (int i = 0; i < n; ++i) {
        cin>>num2[i];
    }
    vector <int> num(90000);
    int cnt=0;
    for (int i = 0; i < n; ++i) {
        N[i]=i+1;
    }
    int cnt1,cnt2;
    while(next_permutation(N,N+n)) {
        cnt1=cnt2=0;
        cnt++;
        for (int i = 0; i < n; ++i) {
            if(num1[i]==N[i]){
                cnt1++;
            }
            if (num2[i]==N[i]){
                cnt2++;
            }
        }
        if(cnt1==n){
            t1=cnt;
        }
        if(cnt2==n){
            t2=cnt;
        }
    }
    cout<<abs(t2-t1)<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
  ll a,b;
  cin>>a>>b;
  cout<<a*b<<endl;

return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min({ a,b,c }) << " " << max({ a,b,c }) << endl;
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int k;
  cin >> k;
  int x = k;
  set<int> a;
  int ans = 0;
  REP(i, k+10){
    if (x == 0){
      cout << ans << endl;
      return 0;
    }
    x = (x * 10 + 7) % k;
    ans++;
  }
  cout << -1 << endl;
  return 0;
}



Measured memory_bytes: 3644
#include<iostream>
#include<vector>

int main(){
	std::vector<int> out;
	std::vector<int> stock;
	int a;
	while( std::cin >> a ){
		if( a == 0 ){
			out.push_back(stock.back());
			stock.pop_back();
		}
		else{
			stock.push_back(a);
		}
	}
	
	for(unsigned int i=0; i<out.size(); ++i){
		std::cout << out[i] << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
int main(void){
    int i,n,m,count=0;
    if(scanf("%d %d",&n,&m)!=0){
    int* a=new int[m];
    for(i=0;i<m;i++) {if(scanf("%d ",&a[i])!=0) count+=a[i];}
    if(count<=n)printf("%d\n",n-count);
    else printf("-1");
    }}

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

int main(){
  int n; cin >> n; vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i]; v[i] -= i+1;
  }
  sort(v.begin(), v.end());
  int t = v[n/2];
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += abs(v[i] - t);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

//#define int ll


const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, r, l;
main() {
    file("threesum");
    ios;
    cin >> n >> r;
    if (n >= 10) l = r;
    else l = r + 100 * (10 - n);
    cout<<l;
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**

*/


Measured memory_bytes: 892
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 4020
int d[2][N][N], e[2][N][N];
int n, K;

ll f(ll i, ll j, ll k){
	return e[i][j+K/2][k+K/2]-e[i][j+K/2][k]-e[i][j][k+K/2]+e[i][j][k];
}

int main(){
	scanf("%d %d", &n, &K);
	K *= 2;
	rep(i, n){
		int x, y;
		char c;
		scanf("%d %d %c", &x, &y, &c);
		d[c=='W'][x%K][y%K]++;
	}
	rep(i, 2) rep(j, K*2+10) rep(k, K*2+10){
		e[i][j+1][k+1] = e[i][j+1][k]+e[i][j][k+1]-e[i][j][k]+d[i][j%K][k%K];
	}
	ll res = 0;
	rep(j, K+10) rep(k, K+10){
		ll sum = f(0, j, k)+f(0, j+K/2, k+K/2)+f(1, j+K/2, k)+f(1, j, k+K/2);
		chmax(res, sum);
	}
	cout<<res<<endl;
	/*
	rep(i, 2){
		rep(j, K*2){
			rep(k, K*2) cerr<<e[i][j][k]<<" ";
			cerr<<endl;
		}
		cerr<<endl;cerr<<endl;
	}
	rep(i, 2){
		rep(j, K){
			rep(k, K) cerr<<d[i][j][k]<<" ";
			cerr<<endl;
		}
		cerr<<endl;cerr<<endl;
	}
	*/
	return 0;
}


Measured memory_bytes: 190720
function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const b = parseInt(input.split(" ")[1], 10);
  if(a+b>=10){
    console.log("error");
  }else{
    console.log(a+b);
  }
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
int a[121],b[121],c[121],n;
int main()
{
    cin>>n;
    for(int i=1;i<n;i++)cin>>a[i];
    
    int sum=a[n-1]+a[1];
    for(int i=2;i<n;i++)sum+=min(a[i],a[i-1]);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 200003
#define M 2003
#define inf 1e18
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;

int lcm(int a,int b)
{
    return (a*b)/__gcd(a,b);
}   

signed main()
{
    Arena
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=0ll;
    
    ans+=(b/c - (a-1ll)/c);
    ans+=(b/d - (a-1ll)/d);
    ans-= (b/lcm(c,d) - (a-1ll)/lcm(c,d));
    
    cout<<(b-a+1ll)-ans;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include<stack>
#include<queue>
using namespace std;
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d\n",a*b-(a+b-1));
}


Measured memory_bytes: 256
import collections
N = int(input())
a = list(map(int, input().split()))

c = collections.defaultdict(int)
ans = 0
for x in a:
    c[x] += 1
    c[x-1] += 1
    c[x+1] += 1
    ans = max(ans, c[x], c[x-1], c[x+1])

print(ans)


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	set<int> mochi;
  ll n, d;
  cin >> n;
  rep(i, n) {
    cin >> d;
    mochi.insert(d);
  }
  cout << mochi.size() << endl;
}

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

using namespace std;

using ll = long long;

ll f(int i) {
    return ((ll)i * (i + 1)) / 2;
}

void swap(int& l, int& r) {
    l = l^r;
    r = l^r;
    l = l^r;
}

int main() {
    int n, l, r;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += f(i);
    }
    for(int i = 0; i < n - 1; i++) {
        cin >> l >> r;
        if(l > r) swap(l, r);
        ans -= (ll)l * (n - r  + 1);
    }
    cout << ans;
    return 0;
}

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

int main() 
{ 
    string s; 
    cin>>s; 
    int n; 
    n=s.size(); 

    // check palindrome whole string 
    string s_r; 
    s_r=s; 
    reverse(s_r.begin(),s_r.end()); 
    bool flag1=false; 
    if(s==s_r) 
      flag1=true; 

    // check palindrome first half string 
    string s_first_half; 
    string s_first_half_r; 
    s_first_half=s.substr(0,(n-1)/2); 
    s_first_half_r=s_first_half; 
    reverse(s_first_half_r.begin(),s_first_half_r.end()); 
    bool flag2=false; 
    if(s_first_half==s_first_half_r) 
      flag2=true; 

    // check palindrome second half string 
    string s_second_half; 
    string s_second_half_r; 
    s_second_half=s.substr((n+3)/2-1,(n-1)-(n+3/2-1)+1); 
    s_second_half_r=s_second_half; 
    reverse(s_second_half_r.begin(),s_second_half_r.end()); 
    bool flag3=false; 
    if(s_second_half==s_second_half_r) 
      flag3=true; 


    // output result 
    if(flag3&&flag2&&flag1) 
      cout<<"Yes"<<endl; 
    else 
      cout<<"No"<<endl; 
    

    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
#define debug(x) cerr << #x << ":" << x << endl;

int main()
{
  int N, K;
  cin >> N >> K;
  vector< int64 > x(N);
  bool zero_flag = false;
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
    if (x[i] == 0) {
      zero_flag = true;
      K--;
    }
  }

  if (!zero_flag) {
    x.push_back(0);
    N++;
  }
  
  int64 ans = 1e18 + 1ll;
  
  sort(x.begin(), x.end());

  int zero = 0;
  for (int i = 0; i < N; ++i) {
    if (x[i] == 0) {
      zero = i;
    }
  }
  
  for (int i = 0; i < N; ++i) {
    if (i + K < N && i + K >= zero && i <= zero) {
      int64 tmp = abs(x[i + K] - x[i]);
      if (abs(i - zero) < K) tmp += abs(x[i] - x[zero]);
      ans = min(ans, tmp);
      // debug(i);
      // debug(abs(x[i + K] - x[i]));
      // debug(tmp);
    }
    if (i - K >= 0 && i - K <= zero && i >= zero) {
      int64 tmp = abs(x[i - K] - x[i]);
      if (abs(i - zero) < K) tmp += abs(x[i] - x[zero]);
      ans = min(ans, tmp);
      // debug(i);
      // debug(abs(x[i - K] - x[i]));
      // debug(tmp);
    }
  }

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


Measured memory_bytes: 1792