akhauriyash/Code-Regression huggingface dataset:
using System;
class Program
{
 static void Main(string[] args)
 {
  string[] sS = Console.ReadLine().Trim().Split(' ');
  int iN = int.Parse(sS[0]);
  int iM = int.Parse(sS[1]);
  long iOut = 0;
  if (iN == 1 && iM == 1) { iOut = 1; }
  else if (iN == 2 || iM == 2) { iOut = 0; }
  else if (iN == 1 || iM == 1) { iOut = iN > iM ? iN - 2 : iM - 2; }
  else { iOut = (long)(iN - 2) * (long)(iM - 2); }
  Console.WriteLine("{0}", iOut.ToString().Trim());
 }
}


Measured memory_bytes: 13140
N, M = map(int,input().split())
a, b = 1, M
divisor = []
while a <= b:
    if a * b == M:
        divisor.append(a)
        divisor.append(b)
    a = M // b + 1
    b = M // a
divisor.sort()
for i in divisor:
    if i >= N:
        print(M // i)
        break

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007

int main()
{
    boost
    int n, k;
    cin >> k >> n;

    vi a(n);
    loop(z, a) cin >> z;

    a.pb(a.front() + k);
    int mx = 0;
    for(int i = 0; i < n; i++)
    {
        mx = max(mx, a[i + 1] - a[i]);
    }

    cout << k - mx << nl;
    return 0;
}

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

using namespace std;

int main() {
    while (true) {
        int m, f, r;
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) {
            break;
        }
        if (m == -1 || f == -1) {
            cout << "F" << endl;
        }
        else if (m + f >= 80) {
            cout << "A" << endl;
        }
        else if (m + f >= 65 && m + f < 80) {
            cout << "B" << endl;
        }
        else if (m + f >= 50 && m + f < 65) {
            cout << "C" << endl;
        }
        else if (m + f >= 30 && m + f < 50) {
            if (r >= 50) {
                cout << "C" << endl;
            } else {
                cout << "D" << endl;
            }
        }
        else if (m + f < 30) {
            cout << "F" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for(int i = (s); i < (e); i++)
#define FOE(i, s, e) for(int i = (s); i <= (e); i++)
#define FOD(i, s, e) for(int i = (s); i >= (e); i--)
#define ll long long

ll A[100005], k, ans, tar;
int n;

int main ()
{
	scanf("%d %lld", &n, &k);
	FOR(i, 0, n) scanf("%lld", &A[i]);
	
	FOR(i, 0, n) if (A[i] > k) { ans += A[i] - k; A[i] = k; }
	
	FOR(i, 1, n)
	{
		tar = k - A[i - 1];
		if (A[i] <= tar) continue;
		ans += A[i] - tar;
		A[i] = tar;
	}
	
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
//#include <iakioi> 
//             0 1  2  3  4  5  6  7  8  9  10 11 12
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (month[a] == b)puts("1");
	else puts("0");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  ll n,k;
  cin>>n>>k;

  vector<pair<ll,ll> > vp;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    vp.push_back(mp(a,b));
  }
  sort(all(vp));

  ll cnt=0;
  for(int i=0;i<n;i++){
    if(cnt<=k&&k<=cnt+vp[i].second){
      cout<<vp[i].first<<endl;
      return 0;
    }
    cnt+=vp[i].second;
  }
  return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll x;cin>>x;
    ll p=100;
    ll ans=0;
    f(i,0,3761){
        p+=(p*1)/100;
        if(p>=x){ans=i+1;break;}
    }
    cout<<ans;
    return 0;  
} 





Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int N;
  cin>>N;
  vector<bool> dp(200,false);
  dp.at(0)=true;
  for(int i=0;i<N;i++){
    dp.at(i+4)=dp.at(i)||dp.at(i+4);
  }
  for(int i=0;i<N;i++){
    dp.at(i+7)=dp.at(i)||dp.at(i+7);
  }
  if(dp.at(N)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<char>>grid(h, vector<char>(w));
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> grid[i][j];
    }
  }
  vector<vector<int>>yoko(h, vector<int>(w, 0)), tate(h, vector<int>(w, 0));
  int cnt=0;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(grid[i][j]=='.')cnt++;
      else {
        int z=j-1;
        while(z>=0 && grid[i][z]=='.'){
          yoko[i][z]=cnt;
          z--;
        }
        cnt=0;
      }
    }
    if(grid[i][w-1]=='.'){
      int z=w-1;
      while(z>=0 && grid[i][z]=='.'){
        yoko[i][z]=cnt;
        z--;
      }
    }
    cnt=0;
  }
  for(int j=0; j<w; j++){
    for(int i=0; i<h; i++){
      if(grid[i][j]=='.')cnt++;
      else {
        int z=i-1;
        while(z>=0 && grid[z][j]=='.'){
          tate[z][j]=cnt;
          z--;
        }
        cnt=0;
      }
    }
    if(grid[h-1][j]=='.'){
      int z=h-1;
      while(z>=0 && grid[z][j]=='.'){
        tate[z][j]=cnt;
        z--;
      }
    }
    cnt=0;
  }
  int ret=0;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      ret=max(ret, yoko[i][j]+tate[i][j]-1);
    }
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 35712
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;


//const string k = "enterstringtobechecked";

const int K = 1e6 + 10;
bool seen[K];

int main()
{
    SYNC
   // clock_t tStart = clock();
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    ll n; in(n);
    ll count=0;
    ll k=7%n;
    while(!seen[k])
    {
        seen[k]=true;
        count++;
        if(k==0)
        {
            o(count)<<endl;
            return 0;
        }
        k=((k*10)+7)%n;
    }
    o(-1)<<endl;






    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);   
}


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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	a+=b;c+=d;
	
	if(a==c) cout<<"Balanced"<<endl;
	else if(a>c) cout<<"Left"<<endl;
	else cout<<"Right"<<endl;
	
	return 0;
} 

Measured memory_bytes: 256
N = int(input())
S = input()

l = 0
r = 0
for i in range(N):
    if S[i]==")":
        r -= 1
        if r<0:
            l += 1
            r = 0
    else:
        r += 1

ans = "("*l + S + ")"*r

print(ans)

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

using namespace std;

#define MAX 32
#define INF (1<<29)
typedef pair<int, int> pii;

int H, W, S, sum;
int u[MAX][MAX];
pii memo[MAX][MAX][MAX][MAX];

int get_cost(int h1, int w1, int h2, int w2)
{
    int cost = 0;
    for (int i = h1; i <= h2; i++) {
        for (int j = w1; j <= w2; j++) {
            cost += u[i][j];
        }
    }
    return cost;
}

pii solve(int h1, int w1, int h2, int w2)    
{
    pii res = memo[h1][w1][h2][w2];
    if (res.first != -1) {
        return res;
    }
    
    res = pii(1, S - (sum - get_cost(h1, w1, h2, w2)));
    for (int i = h1; i <= h2-1; i++) {
        int c1 = get_cost(h1, w1, i, w2);
        int c2 = get_cost(i+1, w1, h2, w2);
        
        if (sum - c1 <= S && sum - c2 <= S) {
            pii n1 = solve(h1, w1, i, w2);
            pii n2 = solve(i+1, w1, h2, w2);
            pii n = pii(n1.first + n2.first, min(n1.second, n2.second));
            res = max(res, n);
        }        
    }

    for (int i = w1; i <= w2-1; i++) {
        int c1 = get_cost(h1, w1, h2, i);
        int c2 = get_cost(h1, i+1, h2, w2);
        
        if (sum - c1 <= S && sum - c2 <= S) {
            pii n1 = solve(h1, w1, h2, i);
            pii n2 = solve(h1, i+1, h2, w2);
            pii n = pii(n1.first + n2.first, min(n1.second, n2.second));
            res = max(res, n);
        } 
    }
    return memo[h1][w1][h2][w2] = res;
}

int main()
{
    while (cin >> H >> W >> S, H) {
        sum = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> u[i][j];
                sum += u[i][j];
                for (int k = 0; k < H; k++) {
                    for (int l = 0; l < W; l++) {
                        memo[i][j][k][l] = pii(-1, -1);
                    }
                }
            }
        }
        
        pii res = solve(0, 0, H-1, W-1);
        cout << res.first << " " << res.second << endl;
    }    
    return 0;
}

Measured memory_bytes: 9368
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int n;

int main(int argc, char *argv[]){
    cin >> n;
    ll a;
    // set<ll> A; rep(i, n){ cin >> a; A.insert(a); }
    // cout << A.size() << endl;
    map<ll, ll> A; rep(i, n){ cin >> a; A[a]++; }
    int res = 0;
    for(auto it : A){
        if(it.second > 0 && it.second % 2 != 0) res++;
    }
    cout << res << endl;
    return 0;
}

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

string lcs(string S, string T) {
  int s = S.size();
  int t = T.size();
  int sz = max(s, t) + 1;
  vector<vector<int>> X(sz, vector<int>(sz));
  vector<vector<int>> Y(sz, vector<int>(sz));
  for (int i = 0; i < s; i++) {
    for (int j = 0; j < t; j++) {
      if (S.at(i) == T.at(j)) {
        X.at(i + 1).at(j + 1) = X.at(i).at(j) + 1;
        Y.at(i + 1).at(j + 1) = 0;
      } else if (X.at(i + 1).at(j) < X.at(i).at(j + 1)) {
        X.at(i + 1).at(j + 1) = X.at(i).at(j + 1);
        Y.at(i + 1).at(j + 1) = 1;
      } else {
        X.at(i + 1).at(j + 1) = X.at(i + 1).at(j);
        Y.at(i + 1).at(j + 1) = -1;
      }
    }
  }
  string res;
  for (int i = s, j = t; i > 0 && j > 0;) {
    if (Y.at(i).at(j) > 0) {
      i--;
    } else if (Y.at(i).at(j) < 0) {
      j--;
    } else {
      res.push_back(S.at(i - 1));
      i--;
      j--;
    }
  }
  reverse(res.begin(), res.end());
  return res;
}

int main() {
  int N;
  string S, T;
  cin >> N >> S;
  sort(S.begin(), S.end());
  while (cin >> T) {
    sort(T.begin(), T.end());
    S = lcs(S, T);
  }
  cout << S << "\n";
}

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

using namespace std;

int n;
int a[101];
int s[101];

int main()
{
    scanf("%d",&n);
    s[0] = 0;
    int sum = 0;
    int ans = 0x7f7f7f7f;
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
        sum += a[i];
        s[i] = s[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++)
    {
        int c = abs(sum - 2 * s[i]);
        ans = min(ans,c);
    }
    printf("%d\n",ans);

    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vector<set<int>> st(h + 1);
	int n;
	cin >> n;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		st[a].insert(b);
	}
	REP(i, w)st[h].insert(i);
	int m = 0;
	REP(i, h) {

		if (!st[i + 1].empty() && *st[i + 1].begin() <= m) {
			cout << i + 1 << endl;
			return 0;
		}

		if (st[i + 1].count(m + 1) == 0)m++;
	}
}


Measured memory_bytes: 28416
n = int(input())
def check_10(num, count):
    if num < 10:
        return count
    num /= 10
    count += 1
    return check_10(num, count)
c = 0
counter = check_10(n, c)
result = 0
if counter%2 == 0:
    for i in range(int(counter//2)):
        result += 10**(2*i+1) - 10**(2*i)
    result += n - 10**counter + 1
elif counter >= 2:
    for i in range(int(counter//2)+1):
        result += 10**(2*i+1) - 10**(2*i)
elif counter == 1:
    result += 9
else:
    result += n
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;

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

int main(){
    ll N,x;
    cin >> N >> x;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll ans=0;
    rep(i,N-1){
        ll y=A[i]+A[i+1]-x;
        if (y>0){
            if (A[i+1]>=y){
                A[i+1]-=y;
            }
            else {
                A[i]-=y-A[i+1];
                A[i+1]=0;
            }
            ans+=y;
        }
    }
    cout << ans << endl;
}

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

char a[10],b[10],c[10] ;
int x,y ;

int main(void){

    scanf ("%s%s%s",a,b,c) ;
    
    x = strlen(a) ;
    y = strlen(b) ;

    if ( a[x-1]==b[0] && b[y-1]==c[0] ){
        printf ("YES\n") ;
    } else {
        printf ("NO\n") ;
    }

    return 0 ;
    
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
using namespace std;

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

    int a, b;
    cin >> a >> b;
    printf("%d %d %f\n", a / b, a % b, (double)a / b);

    return 0;
 }

Measured memory_bytes: 3224
n = int(input())
s = input()

cnt = 0
for i in range(1000):
    pin = '%03d' % i
    try:
        i0 = s.index(pin[0])
        i1 = i0 + 1 + s[i0+1:].index(pin[1])
        i2 = i1 + 1 + s[i1+1:].index(pin[2])
        cnt += 1
    except ValueError:
        pass

print(cnt)

Measured memory_bytes: 9252
def solve():
    N, M = map(int, input().split())
    ans = ['?'] * N
    for i in range(M):
        s, c = map(int, input().split())
        s -= 1

        if ans[s] == '?' or str(c) == ans[s]:
            if s == 0 and c == 0:
                if N == 1:
                    ans[s] = str(c)
                else:
                    print('-1')
                    exit(0)
            ans[s] = str(c)
        else:
            print('-1')
            exit(0)
    
    for i in range(len(ans)):
        if ans[i] == '?':
            if i == 0:
                ans[i] = '1'
                if N == 1:
                    ans[i] = '0'
            else:
                ans[i] = '0'
    
    print("".join(ans))

if __name__ == '__main__':
    solve()

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

int main() {
  int N;
  cin >> N;
  vector<int>vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin() , vec.end());
  vector<int>A(1);
  A.at(0) = vec.at(0);
  for(int j = 1; j < N; j++){
    if(A.at(0) != vec.at(j)){
      A.push_back(vec.at(j));
      reverse(A.begin() , A.end());
    }
  }
 cout << A.size() << endl;

}

Measured memory_bytes: 256
n, m = map(int, input().split())
k = []
for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    k.append((a, sum([2 ** (i-1) for i in c])))

C = 2 ** n
INF = 10 ** 6

dp = [[INF for _ in range(C)] for __ in range(m + 1)]
for i in range(m+1):
    dp[i][0] = 0

for i, ki in enumerate(k):
    for j in range(C):
        dp[i+1][j] = dp[i][j]
    for j in range(C):
        dp[i+1][j | ki[1]] = min(dp[i+1][j | ki[1]], dp[i][j] + ki[0])

ans = dp[m][C-1]
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 79192
import numpy as np
D,G=list(map(int,input().split()))
p=np.zeros(D)
c=np.zeros(D)
for i in range(D):
    a,b=list(map(int,input().split()))
    p[i]=a
    c[i]=b
    
def calc(i,j):
    if i//j==0:
        return 1
    else:
        return i//j
      
min_cost=10**9+7
for x in range(2**D):
    score=0
    cost=0
    max_no_use=0
    
    b=str(format(x,'010b'))
    for i in range(1,D+1):
        if b[-i]=="1":
            score+=100*i*p[i-1]+c[i-1]
            cost+=p[i-1]
        else:
            max_no_use=abs(i)-1
    shortage=G-score
    if shortage>0:
        add=calc(shortage,100*(max_no_use+1))
        if add<=p[max_no_use]-1:
            cost+=add
            if min_cost>cost:
                min_cost=cost
    else:
        if min_cost>cost:
            min_cost=cost
print(int(min_cost))

Measured memory_bytes: 12512
#include <bits/stdc++.h>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node {int parent, left, right;};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u, int d){
    if(u == NIL) return ;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(T[u].left != NIL){
        h1 = setHeight(T[u].left) + 1;
    }
    if(T[u].right != NIL){
        h2 = setHeight(T[u].right)+1;
    }
    return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
    if(T[u].parent == NIL) return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL){
        return T[T[u].parent].left;
    }
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL){
        return T[T[u].parent].right;
    }
    return NIL;
}


void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg = 0;
    if(T[u].left != NIL) deg++;
    if(T[u].right != NIL) deg++;
    printf("degree = %d, " , deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ", H[u]);

    if(T[u].parent == NIL){
        printf("root\n");
    } else if(T[u].left == NIL && T[u].right == NIL){
        printf("leaf\n");
    } else{
        printf("internal node\n");
    }
}


int main(){
    int v,l,r,root = 0;
    scanf("%d",&n);

    for(int i = 0; i < n; i++){
        T[i].parent = NIL;
    }

    for(int i = 0; i < n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if(l != NIL) T[l].parent = v;
        if(r != NIL) T[r].parent = v;
    }

    for(int i = 0; i < n; i++) if(T[i].parent == NIL) root = i;

    setDepth(root,0);
    setHeight(root);

    for(int i = 0; i < n; i++) print(i);

    return 0;
}




Measured memory_bytes: 3208
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
int main()
{
	int i,j,k,n,m,x,y,z,t;
	ll ans=0;
	scanf("%d",&n);
	y=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&x);
		if(x<y)
		{
			ans+=(y-x);
		}
		y=max(x,y);
	}
	printf("%lld",ans);
}


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

signed main(){
  bool f=1;
  int a , b;
  cin>>a>>b;
  for(double i=1;i<=10000 && f;i++){
    if(a == (int)(i*0.08) && b == (int)(i*0.1)){
      cout<<(int)i<<endl;
      f=0;
    }
  }
  if(f){
    cout<<-1<<endl;
  }
  return(0);
}

Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
if a+b<2*c:
  print(a*x+b*y)
else:
  if x>y:
    print(min(2*c*y+a*(x-y),2*c*x))
  else:
    print(min(2*c*x+b*(y-x),2*c*y))

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

struct AB {
  int A;
  int B;
};

 
int main() {
  int N;
  cin >> N;
  vector<AB> ABs(N);
  for (int i = 0; i < N; i++) {
    cin >> ABs.at(i).A >> ABs.at(i).B;
  }
  sort(ABs.begin(), ABs.end(), 
     [](const AB& x, const AB& y) { return x.B < y.B;});
  
  int time = 0;
  for (int i = 0; i < N; i++) {
    time += ABs.at(i).A;
    if (time > ABs.at(i).B) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main(){
  int kekka = 0;
  int a,b;
  int num;
  cin >> num >> a >> b;
  
  bool chk = false;
  for(int i = a; i <= b; i++){
    if(i % num == 0){
      chk = true;
    }
  }
  
  if(chk == true) cout << "OK";
  else cout << "NG";
    
}


Measured memory_bytes: 3592
open Core

let n = Scanf.scanf "%d" ident

let a =
  List.init n ~f:(fun _ -> Scanf.scanf " %d" Fn.id)
  |> List.sort ~compare:Int.compare |> List.rev

let alice =
  List.mapi ~f:(fun i n -> if i mod 2 = 0 then n else 0) a
  |> List.fold_left ~f:( + ) ~init:0

let bob =
  List.mapi ~f:(fun i n -> if i mod 2 = 1 then n else 0) a
  |> List.fold_left ~f:( + ) ~init:0

let () = Printf.printf "%d\n" (alice - bob)


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

const double pi = acos(-1);

int main(){
    int n;
    cin >> n;
    vector<double> x, y;
    for(int i=0;i<n;++i){
        double a, b;
        cin >> a >> b;
        x.push_back(a);
        y.push_back(b);
    }

    for(int i=0;i<n;++i){
        vector<double> agl;
        for(int j=0;j<n;++j)
            if(i != j)
                agl.push_back(atan2(y[j]-y[i], x[j]-x[i]));
        sort(agl.begin(), agl.end());
        agl.push_back(agl[0] + 2*pi);
        double maxi = 0;
        for(int j=1;j<agl.size();++j)
            maxi = max(maxi, agl[j] - agl[j-1] - pi);
        printf("%.10f\n", maxi/(2*pi));
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
   ios_base::sync_with_stdio(false);
   ll n;
   cin >> n;

   if(n%2==1)  cout << 0;
   else{
      ll div=1;
      ll total=n/10;
      n/=10;
      for(ll i=0;i<=100;i++){
         div = div * 5;
         total += n / div;
         if(n<div)   break;
      }
      cout << total << '\n';
   }
}
/*


*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	ll n;
	cin>>n;
	ll i=1,j=1;
	for(int x=sqrt(n);x>=1;x--){
		if(n/x*x==n){
			i=x,j=n/x;
			break;
		}
	}
	cout<<i-1+j-1<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt( br.readLine() );
      String[] line = br.readLine().split(" ");

      int[] a = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = Integer.parseInt(line[i]);
      }

      insertionSort(a, n);
    }
  }

  public static void insertionSort(int a[], int max) {
    StringBuilder line = new StringBuilder(a.length*4);
    for (int i=0,j=0,v=0; i < max; i++) {
      for( j = i-1, v = a[i]; j>=0 && a[j]>v; j-- ) {
        a[j+1] = a[j];
      }
      a[j+1] = v;
      dispIntArray(a,line);
      line.setLength(0);
    }
  }
  public static void dispIntArray(int a[],StringBuilder line) {
    for (int i=0, max = a.length-1; i < max; i++) {
     line.append(a[i] + " ");
    }
    System.out.println( line.append(a[a.length-1]) );
  }
}


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

int main() {
  int n,k; cin>>n>>k;
  vector<int> h(n);
  rep(i, n) cin>>h[i];

  int ans=0;
  rep(i, n) if (h[i]>=k) ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main()
{
	ll n,i;
	cin>>n;
	ll dp[n][3];
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(i=1;i<n;i++)
	{
		dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Long N = sc.nextLong();
        Long A = sc.nextLong();
        Long B = sc.nextLong();
        Long ans = 0l;
        ans +=N / (A + B) * A;

        long mod = N % (A+B);

        if(mod > A){
            ans += A;
        } else {
            ans += mod;
        }

        System.out.println(ans);


    }

}









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


int main(){
  long long h;
  cin>>h;
  long long c=0;
  long long n=1;
  
  while(h>0){
    h/=2;
    c+=n;
    n*=2;
  }
  cout<<c<<endl;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    string S;
    cin >> S;
    int N = S.size();

    vector<vector<ll>> dp(N + 1, vector<ll>(4, 0));
    for(int i = N; i >= 0; --i) {
        for(int j = 3; j >= 0; --j) {
            if(i == N) {
                dp[i][j] = (j == 3 ? 1 : 0);
            }
            else {
                dp[i][j] = dp[i + 1][j] * (S[i] == '?' ? 3LL : 1LL);
                if(j < 3 && (S[i] == '?' || S[i] == "ABC"[j])) {
                    dp[i][j] += dp[i + 1][j + 1];
                }
                dp[i][j] %= MOD;
            }
        }
    }

    std::cout << dp[0][0] << std::endl;

    return 0;
}


Measured memory_bytes: 7376
a=list(map(int,input()))
b,c=a[0]*10+a[1],a[2]*10+a[3]
if 1<=b<=12:
    if 1<=c<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1<=c<=12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, res;
string S;
ll f1[5001], f2[5001], p1[5001], p2[5001];


int main() {
	cin >> N >> S;
	f1[0] = f2[0] = 1;
	for (int i = 1; i <= 5000; ++i) {
		f1[i] = f1[i - 1] * 30 % mod;
		f2[i] = f2[i - 1] * 30 % mod998;
	}
	for (int i = 1; i <= N; ++i) {
		p1[i] = (p1[i - 1] * 30 + S[i - 1] - 'a' + 1) % mod;
		p2[i] = (p2[i - 1] * 30 + S[i - 1] - 'a' + 1) % mod998;
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = i + 1; j <= N; ++j) {
			int l = 0; 
			int r = min(j - i + 1, N + 2 - j);
			while (l + 1 != r) {
				int m = (l + r) / 2;
				if ((p1[i + m - 1] - p1[i - 1] * f1[m] % mod + mod) % mod == (p1[j + m - 1] - p1[j - 1] * f1[m] % mod + mod) % mod&& (p2[i + m - 1] - p2[i - 1] * f2[m] % mod998 + mod998) % mod998 == (p2[j + m - 1] - p2[j - 1] * f2[m] % mod998 + mod998) % mod998) {
					l = m;
				}
				else {
					r = m;
				}
			}
			res = max(res, l);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n,h;
    cin>>n>>h;
    vector<long> a(n),b(n);
    for(int i = 0; i< n; i++){
        cin>>a[i];
        cin>>b[i];
    }
    sort(b.begin(),b.end(),greater<long>());
    long a_max = *max_element(begin(a),end(a));
    long sum=0;
    for(auto itr=begin(b); itr!=end(b)&&*itr>a_max; itr++){
        h-=*itr;
        sum++;
        if(h<=0){
            cout<<sum;
            return 0;
        }
    }
    sum+=h/a_max;
    if(h-a_max*(h/a_max)>0)
        sum++;
    cout<<sum;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
a = list(map(int, input().split()))


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort(reverse=True)
    return divisors


s = sum(a)
divisors = make_divisors(s)

for d in divisors:
    reminders = [ai % d for ai in a]
    reminders.sort()
    for i in range(n - sum(reminders) // d, n):
        reminders[i] -= d

    se = sum(abs(r) for r in reminders)
    if se <= 2 * k:
        print(d)
        break



Measured memory_bytes: 3188
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint d(n);
    REP(i,n) cin >> d[i];
    sort(ALL(d));
    int ans = n;
    REP(i,n-1){
        if(d[i+1]==d[i]) ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
using namespace std;
long long n;
long long a[100001];
long long t=0,a1=0,a2=0;
int main()
{
	cin>>n;
	int l=-1;  
	for(int i=0;i<n;i++){
		cin>>a[i];
		t+=a[i];
		if(t==0){
			a1++;
			if(l<0)
			    t=1;
			else
			    t=-1;
		}
		else
		if(t<0&&l<0){
			a1+=1-t;
			t=1;
		}
		else
		if(t>0&&l>0){
			a1+=t+1;
			t=-1;
		}
		l=t;
	}
	t=0;
	l=1;
	for(int i=0;i<n;i++){
		t+=a[i];
		if(t==0){
			a2++;
			if(l<0)
			    t=1;
			else
			    t=-1;
		}
		else
		if(t<0&&l<0){
			a2+=1-t;
			t=1;
		}
		else
		if(t>0&&l>0){
			a2+=t+1;
			t=-1;
		}
		l=t;
	}
	cout<<min(a1,a2);	
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
void sol(int n){
	int M=1e9,a1,a2,a3;
	bool used[n];
	vector<P>A;
	vector<vector<int> >v(n,vector<int>(3));
	r(i,n)r(j,3)cin>>v[i][j];
	r(i,n){
		sort(v[i].begin(),v[i].end());
		do{
			int s,m,h;
			r(j,60){
				h=(v[i][0]+j)%60;
				m=(v[i][1]+j)%60;
				s=(v[i][2]+j)%60;
				if(h%5!=m/12)continue;
				h/=5;
				A.push_back(P(h*3600+m*60+s,i));
			}
		}while(next_permutation(v[i].begin(),v[i].end()));
	}
	sort(A.begin(),A.end());
	r(i,A.size()){
		int cnt=1,x=A[i].first;
		memset(used,0,sizeof(used));
		used[A[i].second]=1;
		r(j,A.size()-1){
			int t=A[(i+j+1)%A.size()].first;
			int id=A[(i+j+1)%A.size()].second;
			if(!used[id])used[id]=1,cnt++;
			if(cnt==n){
				int now=(t-x+43200)%43200;
				if(M>now)M=now,a1=x,a2=t,a3=now;
				break;
			}
		}
	}
	printf("%02d:%02d:%02d %02d:%02d:%02d\n", a1/3600, a1/60%60, a1%60, a2/3600, a2/60%60, a2%60);
}
int main(){
	int n;
	while(cin>>n,n)sol(n);
}


Measured memory_bytes: 3116
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll N;

    cin >> N;

    vector<int> A(N);

    rep(i,N) {
        cin >> A[i];
    }

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

    rep(i, N-1) {
        if(A[i] == A[i+1]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
    
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string s, t;
  cin >> n >> s >> t;
  
  for(int i = 0; i < n; i++){
    if(s.substr(i) == t.substr(0, n - i)){
      cout << n + i << '\n';
      return 0;
    }
  }
  
  cout << 2 * n << '\n';
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

void GenerateSequence(int N,int S,int W,char* seq){
  int g = S;
  for(int i=0; i<N; i++) {
    seq[i] = ((g/7) % 10) + '0';
    if( g%2 == 0 ) { g = (g/2); }
    else           { g = (g/2) ^ W; }
  }
}

int ComputePatterns(const char* seq,int N,int Q){
  int remainder = 0;
  map<int,int> dp;
  dp[0] = 1;

  int res = 0;
  int pow = 1;

  for(int i=0;i<N;i++){
    remainder += ((seq[i]-'0') * pow) % Q;
    remainder %= Q;
    pow *= 10;
    pow %= Q;
    if(seq[i]-'0') res += dp[remainder];
    dp[remainder]++;
  }

  return res;
}

int ComputePatterns25(const char* seq,int N,int Q){
  int non_zero_num = 0;

  int res = 0;
  for(int i=N-1;i>=0;i--){
    if(seq[i]-'0') non_zero_num++;
    if((seq[i]-'0')%Q==0) res += non_zero_num;
  }
  return res;
}


char seq[100001];
int main(){
  int N,S,W,Q;
  while(~scanf("%d %d %d %d",&N,&S,&W,&Q)){
    if(N==0 && S==0 && W==0 && Q==0) break;

    memset(seq,'\0',sizeof(seq));
    GenerateSequence(N,S,W,seq);

    reverse(seq,seq+strlen(seq));
    
    printf("%d\n",(Q == 2 || Q == 5) 
	   ? ComputePatterns25(seq,N,Q)
	   : ComputePatterns(seq,N,Q));
  }
}

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

int main()
{
    int n = 0, a = 0, b = 0, i = 0, total = 0, add = 0, is = 0;
    cin >> n >> a >> b;
    for(i = 1; i <= n; i++)
    {
        is = i;
        while (is > 0)
        {
            add = add + (is % 10);
            is /= 10;
        }
        if(add >= a && add <= b)
        {
            total += i;
        }
        add = 0;
    }
cout << total;
return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

alpha2num = lambda c: ord(c) - ord('a')


def num2alpha(num):
	if num<=26:
		return chr(96+num)
	elif num%26==0:
		return num2alpha(num//26-1)+chr(122)
	else:
		return num2alpha(num//26)+chr(96+num%26)

A = input()

loc_list = deque([])
loc_list_last = deque([])
num = 0
alpha_list = [-1] * 26
alpha_list_last = [-1] * 26
roop = 0
for i in range(len(A) - 1, -1, -1):
	alphanum = alpha2num(A[i])
	if alpha_list[alphanum] == -1:
		num += 1
		alpha_list_last[alphanum] = i
	alpha_list[alphanum] = i
	if num == 26:
		loc_list.appendleft(alpha_list)
		loc_list_last.appendleft(alpha_list_last)
		alpha_list = [-1]*26
		alpha_list_last = [-1]*26
		roop += 1
		num = 0
loc_list.appendleft(alpha_list)
loc_list_last.appendleft(alpha_list_last)
ans = deque([])
#print(loc_list)
for i in range(26):
	if loc_list[0][i] == -1:
		x = i
		ans.append(x)
		break

if len(loc_list) > 1:
	mozi = x
	for n in range(1, len(loc_list)):
		loc = loc_list[n][mozi]
		#print(loc, mozi)
		for i in range(26):
			if loc_list_last[n][i] <= loc:
				ans.append(i)
				mozi = i
				break
#print(loc_list)

ans2 = []

for i in range(len(ans)):
	ans2.append(num2alpha(ans[i] + 1))
print(''.join(ans2))

Measured memory_bytes: 72136
/* #                          */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <deque>
#include <map>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;

constexpr int               inf =   	0x3f3f3f3f;
constexpr long long 		INF = 		9123456789123456789;
constexpr long long         MOD =       1000000007LL;
/*************************************************/
string s, t, u;
int a, b;

void sol() {

}

int main() {
	ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cin.tie(nullptr);
	cin >> s >> t;
  	cin >> a >> b;
  	cin >> u;
  if(u == s) a--;
  else if(u == t) b--;
  cout << a << " " << b << endl;

    return 0;
}

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

int main() {
    uint64_t a;
    string b;

    cin >> a >> b;

    int b1 = b.at(0)-'0';
    string b2 = b.substr(2);

    int b0 = atoi(b2.c_str());

    //cout << b1 << endl;
    //cout << b0 << endl;

    uint64_t f = (uint64_t)a*b1+((uint64_t)a*b0/100);
    cout << f << endl;
}

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

int main () {
    string S, T;
    cin >> S;
    cin >> T;
    bool check = false;
    if (S == T)
        check = true;
    
    if (!check) {
        for (int temp=0; temp<S.length(); temp++) {
            string out;
            out = S[S.length() - 1];
            for (int a=0; a<S.length()-1; a++)
                out += S[a];
            S = out;
            if (out == T) {
                check = true;
                break;
            }
        }
    }

    if (check)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, a, b) for (int i = a; i < (int)(b); i++)
using ll = long long;
ll item[3001][3001], dp[3001][3001][4];
ll R, C, K, r, c, v, ans;
int main()
{
  cin >> R >> C >> K;
  rep(i, K)
  {
    cin >> r >> c >> v;
    item[r - 1][c - 1] = v;
  }
  rep2(i, 1, R + 1)
  {
    rep2(j, 1, C + 1)
    {
      rep(k, 4)
      {
        dp[i][j][k] = dp[i][j - 1][k];
      }
      dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][3]);
      if (item[i - 1][j - 1] > 0)
      {
        dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][3] + item[i - 1][j - 1]);
        rep2(k, 1, 4)
        {
          dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + item[i - 1][j - 1]);
        }
      }
      rep2(k, 1, 4)
      {
        dp[i][j][k] = max(dp[i][j][k - 1], dp[i][j][k]);
      }
    }
  }
  rep(k, 4)
  {
    ans = max(ans, dp[R][C][k]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 355272
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	int N, K;
	cin >> N >> K;
	vec<ll> A(N);
	REP(i, N)cin >> A[i];

	for(int i = 1; i < N; ++i) {
		if (N <= K + (K - 1)*(i - 1)) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	cout << 6 - a - b << endl;
	
	return 0;
}


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

int main() {
  int64_t N, A, B, ans;
  cin >> N >> A >> B;
  if (A%2==B%2) {
    ans=(B-A)/2;
  }
  else {
    ans=min((A-1),(N-B))+1+(B-A-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  cout << (n - 1) / 2 << endl;

  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[110];
int main()
{
    int n, m, sum = 0, c = 0;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i]; sum += a[i];
    }
    sort(a, a + n); double p = sum / (4.0 * m);
    for (int i = n - 1; i >= 0; i--)
    {
        if (a[i] >= p)c++;
        else break;
    }
    if (c >= m)cout << "Yes";
    else cout << "No";

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,i;
  int j=100000;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    j*=1.05;
    if(j%1000!=0){
      j=(j/1000+1)*1000;
    }
  }
  printf("%d\n",j);

  return 0;
}

Measured memory_bytes: 592
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    s = 0
    ans = 0
    right = 0
    for left in range(N):
        while right < N and s & A[right] == 0:
            s ^= A[right]
            right += 1

        ans += right - left

        if left == right:
            right += 1
        else:
            s ^= A[left]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 32384
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
ll n;
cin >>n;
ll a[n];
for(ll i=0;i<n;i++){
cin >>a[i];
}
sort(a,a+n);
ll max=0;
ll max1=0;
ll b[n];
for(ll i=0;i<n;i++){
b[n-1-i]=a[i];
}
for(ll i=0;i<n;i++){
if(i%2==0){
max+=b[i];
}
else{
max1+=b[i];
}
}
cout<<max-max1;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    ll N;
    cin >> N;

    for (ll i = 1; i <= 3500; i++) {
        for (ll j = 1; j <= 3500; j++) {
            ll ue = N * i * j;
            ll sita = 4 * i * j - N * i - N * j;
            if (sita > 0 && ue % sita == 0) {
                cout << i << " " << j << " " << ue / sita << endl;
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 256