akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int H, W; cin >> H >> W;
    vector<string> s(H);
    REP(i, H) cin >> s[i];

    mat sum1(H + 2 * W, vec(W + 1, 0)), sum2(H + 2 * W, vec(W + 1, 0));
    REP(i, H + 2 * W){
        REP(j, W){
            int x = i - W + j, y = j;
            if(0 <= x && x <= H - 1 && 0 <= y && y <= W - 1 && s[x][y] == '#') sum1[i][j + 1] = sum1[i][j] + 1;
            else sum1[i][j + 1] = sum1[i][j];
            x = i - W - j, y = j;
            if(0 <= x && x <= H - 1 && 0 <= y && y <= W - 1 && s[x][y] == '#') sum2[i][j + 1] = sum2[i][j] + 1;
            else sum2[i][j + 1] = sum2[i][j];
        }
    }

    /*
    REP(i, H + 2 * W){
        REP(j, W + 1){
            cout << sum1[i][j] << ",";
        }
        cout << endl;
    }*/



    int ans = 0;
    REP(i, H){
        REP(j, W){
            if(s[i][j] == '.') continue;

            FOR(n, 1, INF){
                int x = i + n, y = j + n;
                if(!(0 <= x && x <= H - 1 && 0 <= y && y <= W - 1)) break;
                if(s[x][y] == '#'){
                    if(i - j - 2 * n + W >= 0)
                    ans += sum1[i - j - 2 * n + W][min(j + 2 * n + 1, W)] - sum1[i - j - 2 * n + W][j + n];
                    if(i - j + 2 * n  + W < H + 2 * W)
                    ans += sum1[i - j + 2 * n + W][j + 1] - sum1[i - j + 2 * n + W][max(j - n, 0LL)];
                }
            }

            FOR(n, 2, INF){
                int x = i - n, y = j + n;
                if(!(0 <= x && x <= H - 1 && 0 <= y && y <= W - 1)) break;
                if(s[x][y] == '#'){
                    if(i + j - 2 * n + W >= 0)
                    ans += sum2[i + j - 2 * n + W][j + 1 - 1] - sum2[i + j - 2 * n + W][max(j - n + 1, 0LL)];
                    if(i + j + 2 * n  + W < H + 2 * W)
                    ans += sum2[i + j + 2 * n + W][min(j + 2 * n + 1 - 1, W)] - sum2[i + j + 2 * n + W][j + n + 1];
                }
            }

        }
    }


    cout << ans;
    
    return 0;
}

Measured memory_bytes: 4736
from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import pprint
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


n, m = MI()
if 2 <= abs(n - m):
    print(0)
elif abs(n - m) == 1:
    print((math.factorial(n) * math.factorial(m)) % MOD)
else:
    print((2 * math.factorial(n) * math.factorial(m)) % MOD)


Measured memory_bytes: 7540
#include<bits/stdc++.h>
#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,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vi p(n);
    cin >> p;
    sort(all(p));
    int ans = 0;
    rep(i,k) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
    string s,t; cin >> s >> t;
    int ans = inf;
    FOR(i,s.size()-t.size()+1){
        int temp_ans = 0;
        FOR(j,t.size()){
            if(t[j] != s[i+j]) ++temp_ans;
        }
        ans = min(ans,temp_ans);
    }
    cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
	return 0;
}
 


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

int main() {
  while(true) {
    char c;
    scanf("%c", &c);
    if(c == 10) break;
    if('A' <= c && c <= 'Z') {
      c += ('a' - 'A');
    }else if('a' <= c && c <= 'z') {
      c += ('A' - 'a');
    }
    cout << c;
  }
  cout << "\n";
}


Measured memory_bytes: 3120
import sys
N, A, B, C, D = map(int, input().split())
S = str(input())

if C < D:
	if D < N:
		if '##' in S[A-1:D]:
			print('No')
		else:
			print('Yes')
	else:
		if '##' in S[A-1:]:
			print('No')
		else:
			print('Yes')
else:
	if C < N:
		if '##' in S[A-1:C]:
			print('No')
			sys.exit()
	else:
		if '##' in S[A-1:]:
			print('No')
			sys.exit()
	if (S[D-2] == '.') & (S[D] == '.'):
		print('Yes')
	else:
		if '...' in S[B-2:D]:
			print('Yes')
		else:
			print('No')

Measured memory_bytes: 3636
import math
from collections import defaultdict

N = int(input())
mod = 10 ** 9 + 7
ans = 1
# それぞれの因数となる素数の数をセットする
dp = [0] * (N + 1)
# 素因数分解する関数
def prime_factorize(n):
    divisors = []
    # 27(2 * 2 * 7)の7を出すためにtemp使う
    temp = n
    for i in range(2, int(math.sqrt(n)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                # 素因数を見つけるたびにtempを割っていく
                temp //= i
            divisors.append([i, cnt])
    if temp != 1:
        divisors.append([temp, 1])
    if divisors == []:
        divisors.append([n, 1])

    return divisors

for i in range(1, N + 1):
    for j in prime_factorize(i):
        if j[0] > 1:
            dp[j[0]] += j[1]
# 約数の数:それぞれの因数の(因数の数 + 1)を掛け合わせたもの
for i in dp:
    if i > 0:
        ans = (ans * (i + 1)) % mod
print(ans % mod)


Measured memory_bytes: 40048
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 
 
int main() {
  int N;
  cin >> N;
  cout << 800 * N - (N / 15 * 200) << endl;
  return 0;
}

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

signed main(){
       int n;
       cin >> n;
       int h[n],a[n];
       cin >> h[0]>>h[1];
       a[0]=0;
       a[1]=abs(h[0]-h[1]);
       for(int i=2;i<n;i++){
           cin >>h[i];
           a[i]=min(a[i-2]+abs(h[i-2]-h[i]),a[i-1]+abs(h[i-1]-h[i]));

       }
       cout << a[n-1];


    return 0;
}

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

using namespace std;

#define ll long long int

int main() 
{
    long long int k,n,i,j;
    cin>>k>>n;
    long long int a[n+5],b[n+5];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n-1;i++)
        b[i]=abs(a[i]-a[i+1]);
    b[i]=(k-a[i])+a[0];
    sort(b,b+n);
    j=k-b[n-1];
    cout<<j<<"\n";
    return 0;
}

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

int main() {
	int N, a;
	cin >> N;
	int kosuu;
	double kakuritsu;

	//��̌�
	if (N % 2 == 1) {
		kosuu = (N + 1) / 2;
	}
	else {
		kosuu = N / 2;
	}

	kakuritsu = (double)kosuu / (double)N;
	cout << kakuritsu << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char s;
  cin >> s;
  if (s=='a' || s=='i' || s=='u' || s=='e' || s=='o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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 (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  ll n,k; cin >> n >> k;
  ll cnt = n/k;
  ll ans = cnt*cnt*cnt;
  if(k%2 == 0){
    k /= 2;
    cnt = n/k - cnt;
    ans += cnt*cnt*cnt;
  }

  std::cout << ans << '\n';
}


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

int A, B, C;

int main() {
  // 入力
  cin >> A >> B >> C;
  // 愚直に繰り返す
  int cnt = 0;
  while (cnt < 1e+6) {
    if ((A & 1) || (B & 1) || (C & 1)) break;
    int tmpA = A, tmpB = B, tmpC = C;
    A = tmpB / 2 + tmpC / 2;
    B = tmpA / 2 + tmpC / 2;
    C = tmpA / 2 + tmpB / 2;
    cnt++;
  }
  // 解答
  if (cnt < 1e+6) cout << cnt << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using pint = pair<int,int>;
void Main(){
    int N; cin >> N;
    vector<pint> B;
    vector<int> A;

    int prev = -1;
    for (int i = 0; i < N; i++){
        int a; cin >> a;
        if (a != prev){
            B.push_back(pint(a, B.size()));
            A.push_back(a);
            prev = a;
        }
    }
    sort(B.begin(), B.end(), greater<pint>());
    if (A.size() == 1){
        if (A[0] > 0){
            cout << 1 << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
    else{
        int res = 1;
        int cur = 0;
        for (int i = 0; i < B.size(); i++){
            int id = B[i].second;
            if (id == 0){
                if (A[id] > A[id+1]){
                    ++cur;
                }
            }
            else if (id == A.size()-1){
                if (A[id-1] < A[id]){
                    ++cur;
                }
            }
            else{
                if (A[id-1] < A[id] && A[id] > A[id+1]){
                    ++cur;
                }
                else if (A[id-1] > A[id] && A[id] < A[id+1]){
                    --cur;
                }
            }
            if (i == (int)B.size() - 1 || B[i].first != B[i+1].first){
                res = max(res,cur);
            }
        }
        cout << res << endl;
    }
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 4580
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let w: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut ans = vec![vec![0i64; w + 1]; n + 1];
    for i in 1..n + 1 {
        let wi: usize = read(&mut stdin_lock, &mut buf, b' ');
        let vi: i64 = read(&mut stdin_lock, &mut buf, b'\n');
        for j in 1..w + 1 {
            ans[i][j] = max(
                max(ans[i - 1][j], ans[i][j - 1]),
                if j < wi { 0 } else { ans[i - 1][j - wi] + vi },
            );
        }
    }
    println!("{}", ans[n][w]);
}


Measured memory_bytes: 106748
function main()
  
  N = parse(Int,readline())
  p = zeros(Int,N)
  for i in 1:N
    p[i] = parse(Int,readline())
  end
  
  check = false
  ans = 0
  
  for i in 1:N
    
    if check == false && p[i] == maximum(p)
      check = true
      ans += div(p[i],2)
    else
      ans += p[i]
    end
    
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 109796
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
	
	Scanner stdIn = new Scanner(System.in);
	
	byte n = stdIn.nextByte();
	int ncake = 0;
	int ndonut = 0;
	int total;
	
	do {
	
		do{
		
			total = 4*ncake + 7*ndonut;
					
			if (total == n) {
				System.out.println("Yes");
				return;
			}
		
			ndonut = ndonut + 1;
		
		} while (total <= 100);
		
		ndonut = 0;
		
		ncake = ncake + 1;
		
		total = 0;
		total = 4*ncake + 7*ndonut;
		
	} while (total <= 100);
	
	System.out.println("No");
	
	}

}

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

#define LL long long
LL n, mn, mx, w, p, ans;
vector<LL> v[4];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    cin >> n >> mx;

    for(int i = 1; i <= n; i++) {
        cin >> w >> p;
        if(i == 1) mn = w;
        v[w - mn].push_back(p);
    }    

    for(int i = 0; i < 4; i++) {
        sort(v[i].begin(), v[i].end(), greater<LL>());
        for(int j = 1; j < v[i].size(); j++) v[i][j] += v[i][j-1];
    }
    
    for(LL i = 0; i <= v[0].size(); i++) {
        for(LL j = 0; j <= v[1].size(); j++) {
            for(LL k = 0; k <= v[2].size(); k++) {
                LL res = mn * i + (mn + 1) * j + (mn + 2) * k;
                if(res > mx) continue;
                LL q = v[3].size();
                LL l = min(q, (mx - res) / (mn + 3));
                ans = max(ans, (i > 0 ? v[0][i-1] : 0) + (j > 0 ? v[1][j-1] : 0) + (k > 0 ? v[2][k-1] : 0) + (l > 0 ? v[3][l-1] : 0));
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;



string s;
ll k;
ll n;
int main()
{
        cin >> s >> k;
        n = s.length();
        ll ans = 0;
        ll allsame = 1;
        ll yo=0;
        ll leng=0;
        for(ll i=0;i<n;i++) {
                if(i && s[i] != s[i-1]) allsame=0;
                ll j = i;
                while(j<n && s[j]==s[i]) j++;
                ll ln = j-i;
                ans += ln/2;
                if(i==0) {
                        yo += ln/2;
                        leng += ln;
                }else if(j==n) {
                        yo += ln/2;
                        leng += ln;
                }
                i=j-1;
        }
        if(allsame){
                ll ret = n*k;
                cout << ret / 2 << endl; return 0;
        }
        if(k==1){
                cout << ans << endl; return 0;
        }
        ll ret = (ans - yo) * k;
        ret += yo;
        if(s[0]==s[n-1]) {
                ret += (leng/2)*(k-1);
        }else {
                ret += yo*(k-1);
        }
        cout << ret << endl;
        return 0;
}


Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
	//happy coding

	ll n;
	cin>>n;
	string s;
	while(n){
		if(n%26)s += (char)('a'+(n%26)-1);
		else s+='z';
		if(n%26==0)n--;
		n/=26;
	}
	reverse(all(s));
	cout<<s<<endl;


	
	return 0;
}
int main(){
	int test = 1;
  	//scanf("%d", &test);
  	while (test--)solve();return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#define ll long long
#define maxn 200005
#define re register
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}

string s;
int ans;

int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++) if(s[i]=='1') ans++; 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include<string.h>
using namespace std;
inline long long read(){
    long long x=0,f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
    return x*f;
}
int main()
{
    int n;
    long long a[100000+100],b[100000+100],sum=0;
    cin>>n;
    for(int i=1;i<=n+1;++i){
        a[i]=read();
    }
    for(int i =1;i<=n;++i){
        b[i]=read();
        if(a[i]>b[i]){
            a[i]-=b[i];
            sum+=b[i];
        }
        else{
            b[i]-=a[i];
            sum+=a[i];
            if(a[i+1]>b[i]){
                a[i+1]-=b[i];
                sum+=b[i];
            }
            else{sum+=a[i+1];
                a[i+1]=0;
            }
        }
    }
cout<<sum<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

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

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

    priority_queue<pair<long long, pair<long long, long long>>> que;
    for (int i = 0; i < n; i++) {
        que.push(make_pair(a[i], make_pair(a[i], 1)));
    }

    for (int i = 0; i < m; i++) {
        pair<long long, pair<long long, long long>> p = que.top();
        que.pop();

        if (p.first == 0) {
            break;
        }

        que.push(make_pair(p.second.first / (2 * p.second.second), make_pair(p.second.first, 2 * p.second.second)));
    }

    long long res = 0;
    while (!que.empty()) {
        pair<long long, pair<long long, long long>> p = que.top();
        que.pop();
        res += p.first;
    }

    cout << res << endl;
}


Measured memory_bytes: 4980
N, K = map(int, input().split())

min_value = 10**18

def check(x):
    global min_value

    if x % K == 0:
        min_value = 0
        return
    
    if x < K:
        if K % x == 0:
            min_value = x
            return
        else:
            if abs(x - K) == min_value:
                return
            else:
                if min_value > abs(x - K):
                    min_value = abs(x - K)
                check(abs(x - K))
    else:
        min_value = x % K
        check(x % K)

check(N)

print(min_value)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 1000001;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> p(MAX);
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        p[a]++;
    }
    for (int i = 1; i < MAX; i++) {
        if (p[i] == 0) continue;
        for (int j = i+i; j <= MAX; j+= i) p[j] = 0;
    }
    int ans = 0;
    for (int i = 1; i <= MAX; i++) if (p[i] == 1) ans++;
    cout << ans << '\n';
}


Measured memory_bytes: 7200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int sum = scanner.nextInt();
		while (sum > 0){
			for (int i = 0; i < 9; i++){
				sum -= scanner.nextInt();
			}
			System.out.println(sum);
			sum = scanner.nextInt();
		}
	}
}



Measured memory_bytes: 26156
N, L = map(int, input().split())
lst = [L + i for i in range(N)]
sumlst = sum(lst)
mindiff = 500
index = 0
for j in range(N):
    if mindiff > abs(lst[j]):
        mindiff = abs(lst[j])
        index = j
print(sumlst - lst[index])

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    B=A;

    sort(B.begin(),B.end());
    int max = B[N-1];

    if(B[N-2]==B[N-1]){
        for(int i=0;i<N;i++){
            cout << B[N-1] << endl;
        }
    }else{

    for(int i=0;i<N;i++){
        if(A[i]==max){
            cout << B[N-2] << endl;
        }else{
        cout << max << endl;
    }
    }
    }
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>

using namespace std;

#define int long long

int max3(int a, int b, int c) {
  return max(max(a, b), c);
}

int min3(int a, int b, int c) {
  return min(min(a, b), c);
}


signed main() {
  int h, w;
  cin >> h >> w;

  int ans = 1e12;
  // 3タイプしかない
  // type0
  if (h % 3 == 0 || w % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }
  // type1
  for (int i = 1; i < h; i++) {
    int s1 = i * w;
    int h2 = h - i;
    int w2 = w / 2;
    int w3 = w - w2;
    int s2 = h2 * w2;
    int s3 = h2 * w3;
    ans = min(ans, max3(s1, s2, s3) - min3(s1, s2, s3));
  }
  // type2
  for (int i = 1; i < w; i++) {
    int s1 = i * h;
    int w2 = w - i;
    int h2 = h / 2;
    int h3  = h - h2;
    int s2 = h2 * w2;
    int s3 = h3 * w2;
    ans = min(ans, max3(s1, s2, s3) - min3(s1, s2, s3));
  }

  // 5タイプある？
  // type3
  for (int i = 1; i * 2 < h; i++) {
    int s1 = i * w;
    int s2 = i * w;
    int s3 = (h - 2 * i) * w;
    ans = min(ans, max3(s1, s2, s3) - min3(s1, s2, s3));
  }
  // type4
  for (int i = 1; i * 2 < w; i++) {
    int s1 = i * h;
    int s2 = i * h;
    int s3 = (w - 2 * i) * h;
    ans = min(ans, max3(s1, s2, s3) - min3(s1, s2, s3));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){

    var N = readLine()!!.toLong()

    val mod = 1000000007L

    var all =1L
    var nouse = 1L
    var oneuse = 1L



    for(i in 0 until N){
        all *= 10
        all %= mod
        nouse *= 8
        nouse %= mod
        oneuse *= 9
        oneuse %= mod

    }
    var ans = all - nouse - (oneuse - nouse)*2
    while(ans<0) ans += mod

    println(ans)
}


Measured memory_bytes: 34568
#include <bits/stdc++.h>
#define N 200000
using namespace std;

bitset <N+1> seen;
vector <int> G[N+1];

int ct;
void DFS (int i) {
    ++ct;
    
    seen[i] = 1;
    for (auto it: G[i])
        if (!seen[it])
            DFS(it);
}

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

    int n, m;
    cin >> n >> m;

    int i, j;
    for (; m; --m) {
        cin >> i >> j;
        G[i].push_back(j);
        G[j].push_back(i);
    }

    int ans = 0;
    for (i = 1; i <= n; ++i)
        if (!seen[i]) {
            DFS(i);
            ans = max(ct, ans);
            ct = 0;
        }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 23948
#include <iostream>
#include <string>
#include <vector>

using namespace std;

static inline int charToInt(char c) {
  switch(c) {
  case 'A':
    return 0;
  case 'C':
    return 1;
  case 'G':
    return 2;
  case 'T':
    return 3;
  default:
    return -1;
  }  
}

static inline uint64_t getKey(const string& str) {
  uint64_t total = 0, p = 1;
  for (int i = 0; i < str.length(); i++) {
    total += p * (charToInt(str[i]));
    p *= 5;
  }  
  return total;
}

static const int M = 1046527;
static const int NUL = -1;
static const int L = 14;

static inline int h1(int key) {
  return key % M;
}

static inline int h2(int key) {
  return 1 + (key % (M - 1));
}

static vector<string> H(M);

static inline bool find(const string& str) {
  uint64_t key, h;
  key = getKey(str);
  for (int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (H[h] == str) {
      return true;
    }
    else if (H[h].size() == 0) {
      return false;
    }
  }
  return false;
}

static inline bool insert(const string& str) {
  uint64_t key, h;
  key = getKey(str);
  for (int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (H[h] == str) {
      return true;
    }
    else if (H[h].size() == 0) {
      H[h] = str;
      return false;
    }
  }
  return false;
}

int main() {
  int n, h;

  cin >> n;

  string str, com;
  for (int i = 0; i < n; i++) {
    cin >> com >> str;
    if (com[0] == 'i') {
      insert(str);
    } else {
        cout << (find(str) ? "yes" : "no") << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 27456
my $n=<STDIN>-0;
my $train = {};
foreach my $p (1 ... $n - 1) {
    my @s = map {$_ - 0} split / /,<STDIN>;
    $train->{$p} = \@s; #c s f
}
my $k = {};
foreach my $station (1 ... $n) {
    my $total = $train->{$station}->[1] || 0;
    for(my $i = $station; $i < $n; $i++){
        $total = $train->{$i}->[1] if $train->{$i}->[1] > $total;
        if($i != $station) {
            if($total % $train->{$i}->[2] > 0){
                $total += $train->{$i}->[2] - ($total % $train->{$i}->[2]);
            }
        }
        $total += $train->{$i}->[0];
        #print $train->{$i+1}->[0]
    }
    print $total, "\n";
}

Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        s:chars,
    }
    let first:String = s[0..2].iter().map(|&c| c).collect();
    let second:String = s[2..4].iter().map(|&c| c).collect();
    let first = first.parse::<i32>().unwrap();
    let second = second.parse::<i32>().unwrap();
    if 0 < first && first <= 12 &&  0 < second  &&  second <= 12 {
        println!("AMBIGUOUS");
    } else if 0 < first && first <= 12 {
        println!("MMYY");
    } else if  0 < second  &&  second <= 12{
        println!("YYMM");
    } else {
        println!("NA")
    }
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N; cin >> N;
	vector<pint> vec(N);
	REP(i, N) cin >> vec[i].first >> vec[i].second;
	sort(ALL(vec));
	int af, as, bf, bs;
	if(N & 1){
		af = vec[N/2].first;
	} else {
		af = vec[N/2-1].first;
		bf = vec[N/2].first;
	}

	REP(i, N) swap(vec[i].first, vec[i].second);
	sort(ALL(vec));

	if(N & 1){
		as = vec[N/2].first;
		cout << as-af+1 << ln;
	} else {
		as = vec[N/2-1].first;
		bs = vec[N/2].first;
		cout << bs-bf+1+as-af << ln;
	}
}

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

int main() {
  int NUM, count = 0;
  char color;
  string saved_str;
  
  cin >> NUM;
  for (int iter = 0; iter < NUM; iter++) {
    cin >> color;
    if (saved_str.find(color) != string::npos) {
      continue;
    }
    saved_str += color;
    count++;
  }
  
  if (count == 3) {
    cout << "Three";
  }
  else if (count == 4) {
    cout << "Four";
  }
}


Measured memory_bytes: 256
def solve(n):
    ret = []
    while n > 26:
        if n % 26 == 0:
            ret = [26] + ret
            n = (n - 26) // 26
        else:
            ret = [n % 26] + ret
            n = n // 26
    ret = [n] + ret
    return ret

n = int(input())
ans = ''.join([chr(ord('a') + i - 1) for i in solve(n)])
print(ans)

Measured memory_bytes: 61980
/*
 * C.cpp
 *
 *  Created on: 2020/07/25
 *      Author: 17k1028
 */



#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define REPD(i,n) for(ll i=n-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=a; i<=ll(b); i++)
#define FORD(i,a,b) for(ll i=a; i>=ll(b); i--)

int main(){
	ll N, K;
	cin >> N >> K;
	ll A[N];
	REP(i,N){
		cin >> A[i];
	}
	ll i=0;
	while(K+i < N){
		if (A[i] < A[K+i]){
			cout << "Yes" << endl;
		}else{
			cout  << "No" << endl;
		}
		i++;
	}
}





Measured memory_bytes: 5176
#include <iostream>
#include <list>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using Wbool = std::vector<Vbool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;
template <class T>
using Vec = std::vector<T>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)};
constexpr char BR = '\n';

#define DEBUG(x) std::cerr << #x << " = " << x << '\n';
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())
#define RSORT(A) std::sort((A).rbegin(), (A).rend())
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())



template <class T> inline int argmin(std::vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(std::vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){if(a < b) a = b;}
template <class T> inline void chmin(T &a, T b){if(a > b) a = b;}
template <class T> inline void reverseSORT(Vec<T> &Array){
  std::sort(Array.begin(), Array.end(), std::greater<T>());
}
inline int BitI(int k){return 1 << k;}
inline lli BitL(int k){return 1LL << k;}
inline void putsDouble(double d){printf("%.16lf\n", d);}
inline int toInt(const string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res;
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




int main(void){
    int n; scanf("%d", &n);
    int a = n / 100, b = n % 100;
    if(0 < a and a <= 12 and 0 < b and  b <= 12) puts("AMBIGUOUS");
    else if(0 < a and a <= 12 and not (0 < b and b <= 12)) puts("MMYY");
    else if(0 < b and b <= 12 and not (0 < a and a <= 12)) puts("YYMM");
    else puts("NA");
    return 0;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	int n,d;
	cin >> n >> d;

	int ans = 0;
	while(n > 0){
		n = n - 2*d - 1;
		ans++;
	}

	cout << ans;
    return 0;
}


Measured memory_bytes: 256
#define M_PI 3.14159265358979323846

//#define _GLIBCXX_DEBUG
//#define all(x) (x).begin(),(x).end()

#include <bits/stdc++.h>

#define TASK ""
#define sqr(x) ((x)*(x))
typedef int ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
const ll INFLL = numeric_limits<int>::max();
const ll INFINT = numeric_limits<int>::max();
const ld EPS = 1e-7;
const ll MOD = 1000000000;
const ll MAXN = 223456;

void run()
{
    ll a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0)
    {
        cout << "Zero";
    }
    else if (a > 0)
    {
        cout << "Positive";
    }
    else
    {
        if ((b - a) & 1) cout << "Positive";
        else cout << "Negative";
    }
}

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

#ifdef LOCAL
//#define STRESS
#ifdef STRESS
    freopen("input.txt", "w", stdout);
    ll N = 10;
    cout << N << endl;
    for (int i = 0; i < N; i++)
        cout << rand() % 30 << " " << rand() % 30 << endl;
    return 0;

#endif
    if (strcmp(TASK, "-") != 0)
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
#else
    if (strcmp(TASK, "")   != 0)
    {
        freopen(TASK".in", "r", stdin)  ;
        freopen(TASK".out", "w", stdout)  ;
    }
#endif
    run();

    return 0;
}

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

int main (){
  int A,B,C,D;
  int AB, CD;
  
  cin >> A >> B >> C >> D;
  
  //右の皿と左の皿の重さの合計をそれぞれ計算
  AB = A + B;
  CD = C + D;
  
  //左右の皿で重さを比較
  if(AB == CD){
    cout << "Balanced" << endl;
  }
  else if(AB > CD){
    cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline


def selection_sort(A):
    counter = 0
    for i in range(len(A)):
        _min = i
        for j in range(i, len(A)):
            if A[j] < A[_min]:
                _min = j
        A[i], A[_min] = A[_min], A[i]
        if i != _min:
            counter += 1
    print(" ".join([str(a) for a in A]))
    print(counter)
    return A


def main():
    _ = input()
    A = [int(i) for i in input().strip().split()]
    selection_sort(A)


if __name__ == "__main__":
    main()




Measured memory_bytes: 5608
d=input()
a=[int(i) for i in input().split(' ')]

def w(x):
  if x % 2 ==0:
    return x / 2
  else:
    return 0
n=0
while min(a)>0:
  a=[w(i) for i in a]
  n+=1
  if min(a)==0:
    n-=1
print(n)

Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(){
  string s,t;
  cin>>s>>t;
  int count =t.length();
  for(int i=0;i<=s.length()-t.length();i++){
    int dif=0;
    for(int j=0;j<t.length();j++)
      {
        if(t[j]!=s[i+j]){
          dif++;
        }
      }
    //cout<<dif<<endl;
    count=min(count,dif);
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1);
  map<int, int> a{};
  REP(i, N) {
    cin >> A[i + 1];
    a[A[i + 1]] = i+1;
  }
  for (int i = 1; i <= N; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> e(n + 1);
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        e[p] = 1;
    }
    for (int i = 0;; i++) {
        if (e[x + i] && e[x - i]) continue;
        if (!e[x - i]) {
            cout << x - i << endl;
            return 0;
        }
        if (!e[x + i]) {
            cout << x + i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3628
s=[0]
for i in range(1000):
    s.append(s[i]+i+1)
n,k=map(int,input().split())
p=list(map(int,input().split()))
l=[0]
for i in range(n):
    l.append(l[i]+p[i])
tmp=0
at=n-k
for i in range(n-k+1):
    if l[i+k]-l[i]>tmp:
        tmp=l[i+k]-l[i]
        at=i
ans=0
for i in range(k):
    ans+=s[p[at+i]]/p[at+i]
print(ans)

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

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

    while( m-- > 0 ){
        int money, year, x;
        cin >> money >> year >> x;
        int Max = 0;

        while( x-- > 0 ){
            int type, h;
            double rate;
            cin >> type >> rate >> h;
            int t = money, n = 0;

            for( int i = 0; i < year; i++ ){
                if( type == 0 ){
                    n += t * rate;
                }else{
                    t += t * rate;
                }
                t -= h;
            }
            t += n;
            if( Max < t ) Max = t;
        }
        cout << Max << endl;
    }
}

Measured memory_bytes: 1232
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    long long X,Y;
    cin>>X>>Y;
	int top=0;
    for(long long i=X ; i<=Y ; i*=2){
        top+=1;
    }
    cout<<top<<endl;
    
    
    
    return 0;
}


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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int A, B;
    int ans = 0;

    cin >> A >> B;
    if(A >= 13) {
        ans = B;
    } else if(6 <= A && A <= 12) {
        ans = B / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long 
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=a;i<=b;i++)
#define DF(i,a,b) for (int i=a;i>=b;i--)
#define SZ(x) (int)x.size()-1
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for (;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=333;
int dp[M][M][M];
char s[M];
int n,k;
int solve(int x,int y,int l){
	if (dp[x][y][l]) return dp[x][y][l];
	if (l<0) return -1e9;
	if (x>y) return 0;
	if (x==y) return dp[x][y][l]=1;
	dp[x][y][l]=max(solve(x+1,y-1,l-(s[x]!=s[y]))+2,max(solve(x+1,y,l),solve(x,y-1,l)));
	return dp[x][y][l];
} 
int main(){
	scanf("%s%d",s+1,&k);
	n=strlen(s+1);
	cout<<solve(1,n,k)<<"\n";
	return 0;
} 

Measured memory_bytes: 130816
#include <stdio.h>
#include <algorithm>

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if (a > b) {
    std::swap(a, b);
  }
  puts(a <= c && c <= b ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

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

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,ans=INT_MAX,l,r;

main(){
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
        r+=a[i];
    }
    for(int i=0;i<n-1;i++){
        l+=a[i];
        r-=a[i];
        ans=min(ans,abs(l-r));
    }
    dans;
}



Measured memory_bytes: 1792