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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 108 B / Link: http://abc108.contest.atcoder.jp/tasks/abc108_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	VL x(4), y(4);
	FOR(i, 0, 2) {
		cin >> x[i] >> y[i];
	}
	FOR(i, 0, 2) {
		LL X = x[i + 1] - x[i];
		LL Y = y[i + 1] - y[i];
		swap(X, Y);
		X = -X;
		x[i + 2] = x[i + 1] + X;
		y[i + 2] = y[i + 1] + Y;
	}
	FOR(i, 2, 4) {
		cout << x[i] << " " << y[i] << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/23.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int i;
    int s;
    
    set<int> st;
    
    cin >> s;
    st.insert(s);
    
    i=2;
    while(i <= 1000000){
        if(s%2==0) s = s/2;
        else s = 3*s + 1;
        
        if(st.find(s) == st.end()){
            st.insert(s);
        } else break;
        
        i++;
    }
    
    cout << i << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
     char arr[100], a1[200], a2[200];
      int N, i, j, k;
      scanf("%d", &N);
      scanf("%s",arr);
      if (N % 2 == 0)
      {
            for (i = 0; i < N/2 ; i++)
                  a1[i] = arr[i];
             a1[i] = '\0';
             for (k = 0, j = N/2; j < N; j++, k++)
                   a2[k] = arr[j];
              a2[k] = '\0';
              if (strcmp(a1,a2) == 0)
                  printf("Yes");
              else
                   printf("No");
        }
        else
               printf("No");

         return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if (a == b){
        cout << "a == b"<< endl;
    }
    else if(a > b){
        cout << "a > b" << endl;
    }
    else if(a < b){
        cout << "a < b" << endl;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n;
  cin >> n;
  map<int, int> d;
  REP(i,n){
    int x;
    cin >> x;
    d[x]++;
  }

  int m;
  cin >> m;
  vector<int> t(n);
  REP(i,m) cin >> t[i];

  //

  bool ok = true;

  REP(i,m){
    if(d[t[i]] == 0) {
      ok = false;
      break;
    }
    d[t[i]]--;
  }

  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 13532
//#include <bits/stdc++.h>/*
#include <unordered_map>
#include <functional> //greater
#include <algorithm> //sort
#include <iostream>
#include <iterator>
#include <utility> //pair
#include <sstream>
#include <cstring> //memset
#include <complex>
#include <cassert>
#include <random>
#include <cstdio>
#include <string>
#include <vector>
#include <cctype> //isaplha, tolower
#include <deque>
#include <queue>
#include <stack>
#include <array>
#include <cmath> //sqrt, sin
#include <ctime>
#include <list>
#include <map>
#include <set>
//*/
 
#define int long long
#define uns unsigned
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl '\n'
using namespace std;
 
template<class T> ostream &operator<<(ostream &os, const pair<T,T> &p){
	return os<<"("<<p.fi<<","<<p.se<<")";}
template<class T> ostream &operator<<(ostream &os, const pair<const T,T> &p){
	return os<<"("<<p.fi<<","<<p.se<<")";}
template<class T> ostream &operator<<(ostream &os, const array<T,3> &p){
	return os<<"("<<p[0]<<","<<p[1]<<","<<p[2]<<")";}
template<class T> ostream &operator<<(ostream &os, const vector<T> &p){
	for(auto x: p) os<<x<<' '; return os;}
#define dbug(x) cerr<<">>>> "<<#x<<" = "<<x<<endl
#define _ <<", "<<
#define FOR(X,L,R) for(int X=L;X<R;X++)
#define FI(I,X) for(auto I=(X).begin();I!=(X).end();I++)
#define print(X) {cerr<<"{ ";FI(I,X)cerr<<*I<<' ';cerr<<"}"<<endl;}
#define mset(V,X) memset(V,X,sizeof(V))
#define all(X) (X).begin(),(X).end()
#define upperb(V,X) (int)(upper_bound(all(V),(X))-V.begin())
#define lowerb(V,X) (int)(lower_bound(all(V),(X))-V.begin())
 
const double EPS = 1e-9, PI = acos(-1);
const ll LINF = 0x3f3f3f3f3f3f3f3f, mod = 1e9+7;
const int INF = 0x3f3f3f3f, SZ = 2e5+20;

int n, w, r;
int value[110], weight[110];
int dp[100010];
 
int32_t main(){
	ios::sync_with_stdio(false);cin.tie(0);
	
	cin >> n >> w;
	for(int i = 0; i < n; i++)
		cin >> weight[i] >> value[i];
	// dp[i] = maximum total value of itens with total weight exactly
	for(int item = 0; item < n; item++)
		for(int cur_wei = w - weight[item]; cur_wei >= 0; cur_wei--)
			dp[cur_wei + weight[item]] = max(dp[cur_wei + weight[item]], dp[cur_wei] + value[item]);
	cout<< *max_element(dp, dp + w + 1) <<endl;
 
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e2 + 5, M = 2 * N + 5;



int main(){
    int n, l;
    cin >> n >> l;
    vector<string> a(n);
    for(auto &i : a)cin >> i;
    sort(a.begin(), a.end());
    for(auto i : a)cout << i;
}


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

int main() {
  long N, D;
  cin >> N >> D;
  
  vector<vector<long>> point(N, vector<long>(2));
  
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 2; j++){
      cin >> point.at(i).at(j);
     }
  }
  int count = 0;
  for (int i = 0; i < N; i++){
  
  if(point.at(i).at(0) * point.at(i).at(0) + point.at(i).at(1) * point.at(i).at(1) <= D * D){
       count++;
     }
  }
  cout << count << endl; 
  return 0;
}

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

// Function to find pair with given difference in the array
// This method handles duplicates in the array

int main()
{
	string s;
	cin>>s;
	map<char,int> mp;
	for(int i=0;i<s.length();i++)
        mp[s[i]]++;
    int c=0;
    for(auto it:mp)
        if(it.second==2)
        c++;
    if(c==2)
        cout<<"Yes";
    else cout<<"No";
	return 0;
}


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

using namespace std;

int main()
{
  	string in;
  	cin >> in;
  
  	int ret = 0;
  	int curRem = 0;
  	int rem[2019][2] = {};
  	for(int i = 0; in[i]; i++)
    {
    	for(int i2 = 0; i2 < 2019; i2++)
        {
          	curRem = (i2 * 10 + (in[i] - '0')) % 2019;
          	rem[curRem][!(i % 2)] += rem[i2][i % 2];
          	rem[i2][i % 2] = 0;
        }

      	rem[in[i] - '0'][!(i % 2)]++;
      	ret = ret + rem[0][!(i % 2)];
    }
  
  	cout << ret << endl;
  
	return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    cout<<s1[0]<<s2[0]<<s3[0];
  	return 0;
}







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

int main() {
    int N, K, ans = 1;
    cin >> N >> K;
    rep (i, N) {
        if (2 * ans < ans + K){
            ans *= 2;
        }
        else {
            ans += K;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

bool query(string s){
	cout << "? " << s << endl;
	char p; cin >> p;
	return (p=='Y');
}

int main(){
	string cur;
	string pad(11,'9');

	bool isnine = true;
	while(true){
		pad.pop_back();

		int l=-1,r=10;
		while(l+1<r){
			int mid = (l+r)>>1;

			if(cur.empty() && mid==0){
				l=mid;
				continue;
			}

			if(query(cur+to_string(mid)+pad)){
				r=mid;
			}
			else{
				l=mid;
			}
		}

		assert(l!=9);
		if(l>=0){
			cur+=to_string(r);
		}
		else{
			if(isnine){
				if(query(string(cur.size()+1,'8'))){
					cur+='0';
				}
				else{
					break;
				}
			}
			else{
				if(query(string(cur.size(),'9'))){
					break;
				}
				else{
					cur+='0';
				}
			}
		}
		isnine&=(cur.back()=='9');
	}
	assert(cur.size()<=10);
	cout << "! " << cur << endl;
	return 0;
}


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

int main() {
  int A,B,C,D;//体力A攻撃力B体力C攻撃力D
  cin >> A >>B >>C>>D;
  while(true){
    C -= B;
    if(C<=0){
      cout<<"Yes"<<endl;
      break;
    }
    A -= D;
    if(A<=0){
      cout<<"No"<<endl;
      break;
    }
  }  
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll x, y;

int main(){
	cin >> x >> y;
	
	ll ans = 0;
	while(x <= y){
		x *= 2;
		ans++;
	}
	
	cout << ans << endl;
	return 0;
}

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

int main()
{
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	if (a + b - n >= 2 || (long long)a * b < n)
	{
		puts("-1");
		return 0;
	}
	int lds{};
	if (b > 1) lds = (n - a) / (b - 1);
	int rest{n - a - lds * (b - 1)};
	std::vector<int> ans;
	for (int i{}; i < lds; i++)
		for (int j{(i + 1) * b}; j > i * b; j--)
			ans.push_back(j);
	if (lds < a)
		for (int i{lds * b + rest + 1}; i > lds * b; i--)
			ans.push_back(i);
	for (int i{lds * b + rest + 2}; i <= n; i++)
		ans.push_back(i);
	for (int i{}; i < n; i++)
		printf("%d%c", ans[i], i == n - 1?'\n':' ');

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s.size() < 4)
    cout << "No" << endl;
  else if(s.at(0) == 'Y' && s.at(1) == 'A' && s.at(2) == 'K' && s.at(3) == 'I')
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

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

  double ans=0;
  for(int i=0;i<N;i++) ans+=1.0/A[i];

  cout<<fixed<<setprecision(10)<<1.0/ans<<endl;

  return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    vector<vector<int> > c(3, vector<int>(3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
        
    }

    int num = c[0][0];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            c[i][j] -= num;
        }
        
    }

    vector<int> a(3);
    vector<int> b(3);
    for (int i = 1; i < 3; i++)
    {
        b[i] = c[0][i];
    }
    for (int i = 1; i < 3; i++)
    {
        a[i] = c[i][0];
    }
    
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (c[i][j] != a[i] + b[j])
            {
                cout << "No" << endl;
                return 0;
            }
            
        }
        
    }

    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n,k;
    scanf("%d %d",&n,&k);
    int a[n+1];

    for(int i=1; i<=n; i++){
        a[i] = 1;
        scanf("%d",&a[i]);
    }

    for(int i=1; i<=(n-k); i++){
        if(a[k+i]>a[i]) printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}

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

const int N = 100;
int L[2 * N] = { 0 };

int main(){
	int n, ans = 0;
	cin >> n;
	for(int i = 0;i < 2 * n;++i){
		cin >> L[i];
	}
	sort(L, L + 2 * n, greater<int>());
	for(int i = 0;i < 2 * n;i += 2){
		ans += min(L[i], L[i + 1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define mkp make_pair
typedef pair<ll,ll> P;
int main()
{
	ll n,k;
	cin>>n>>k;
	if(n%k == 0)
	{
		cout<<0<<endl;
	}
	else if(n<k)
	{
		cout<<min(n,abs(n-k))<<endl;
	}
	else if(n>=k)
	{
		cout<<min(n-k,k-(n%k))<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
string s;
cin>>s;
rep(i,s.size()){
 if (count(ALL(s),s.at(i))%2!=0)

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

}
cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
struct P{
	int year;
	string name;
};
bool operator<(P a, P b) {
	return a.year < b.year;
}
bool operator>(P a, P b) {
	return a.year > b.year;
}
int main() {
	int n, q;
	while (cin >> n >> q) {
		P a[50];
		for (int i = 0; i < n; i++) cin >> a[i].year >> a[i].name;
		sort(a, a + n);
		if (a[0].year > q) cout << "kogakubu10gokan" << endl;
		for (int i = n - 1; i >= 0; i--) {
			if (a[i].year <= q) {
				cout << a[i].name << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3200
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}
auto readReals() {
	return array(map!(to!real)(readln().strip().split()));
}
auto readReal() {
	return readReals()[0];
}

const real eps = 1e-10;

int count(int n) {
	int ans;
	while(n) {
		ans += n & 1;
		n >>= 1;
	}
	return ans;
}

int[] list(int n) {
	int[] ans;
	for(int i; i < 32; ++i) {
		if(n & 1 << i) ans ~= i;
	}
	return ans;
}

real dist(real[] a, real[] b) {
	auto r = a.dup;
	r[] -= b[];
	return reduce!("a+b")(real(0), map!("a*a")(r));
}

void main(){
	auto NM = readInts();
	auto N = NM[0];
	auto M = NM[1];
	real[][] c;
	for(int i; i < N; ++i) {
		c ~= readReals();
	}
	real ans = 0;
	for(int i; i < 1 << N; ++i) {
		if(count(i) != M) continue;

		auto l = list(i);
		real d = 0;
		for(int j; j < M; ++j) {
			for(int k = j+1; k < M; ++k) {
				d += dist(c[l[j]], c[l[k]]);
			}
		}
		ans = max(ans, d);
	}
	writefln("%.6f", ans);
}

Measured memory_bytes: 3268
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }


        long[] SA = new long[N + 1];
        for (int i = 0; i < N; i++) {
            SA[i + 1] = A[i] + SA[i];
        }

        long mind = Integer.MAX_VALUE;
        for(int i = 1; i < N; i++) {
            long len1 = SA[i] - SA[0];
            long len2 = SA[N] - SA[i];
            mind = Math.min(mind, Math.abs(len1 - len2));
        }
        
        System.out.println(mind);
        return;
    }

}

Measured memory_bytes: 91916
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

#define POS(i, j, l) (((i) * n + (j)) * n + (l))

i32 inf = -1000000000 - 1;
i32 calc (i32 k, i32 l, i32 r, i32 *v, i32 *dp, i32 n) {
  if (k < 0) return inf;
  if (k == 0) {
    return 0;
  }
  if (l > r) return inf;
  if (dp[POS(k, l, r)] != inf) return dp[POS(k, l, r)];
  i32 max = 0;
  i32 x = calc (k - 1, l, r, v, dp, n);
  max = MAX(max, x);
  x = calc (k - 1, l + 1, r, v, dp, n) + v[l];
  max = MAX(max, x);
  x = calc (k - 1, l, r - 1, v, dp, n) + v[r];
  max = MAX(max, x);
  x = calc (k - 2, l + 1, r, v, dp, n);
  max = MAX(max, x);
  x = calc (k - 2, l, r - 1, v, dp, n);
  max = MAX(max, x);
  dp[POS(k, l, r)] = max;
  return max;
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 *v = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, v + i);
  }
  i32 *dp = (i32 *) calloc ((k + 1) * n * n, sizeof (i32));
  for (i32 i = 0; i < (k + 1) * n * n; ++i) dp[i] = inf;
  i32 ans = calc (k, 0, n - 1, v, dp, n);
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
int main(void){
  int a;
  scanf("%d",&a);
  if(a % 2 == 0){
    printf("%d",a / 2);
  }else if(a % 2 == 1){
    printf("%d",(a + 1) / 2);
  }
  return 0;
}


Measured memory_bytes: 128
n=3
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int, input().split())
count=[0]*4
pos=1
for i in range(n):
  count[a[i]-1]+=1
  count[b[i]-1]+=1
ans="YES"
for i in range(4):
  if count[i]>=3:
    ans="NO"
print(ans)

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

using namespace std;
typedef long long ll;

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (x / d >= k) {
        cout << x - k * d << "\n";
        return 0;
    }
    ll r = x % d, rs = k - (x - r) / d;
    if (rs % 2 == 0) {
        cout << r << "\n";
    } else {
        cout << d - r << "\n";
    }
}


Measured memory_bytes: 3588
n = int(input())-1
x = 26
d = 1
while n >= x:
  n -= x
  d += 1
  x *= 26
  
ans = ""
al = list("abcdefghijklmnopqrstuvwxyz")
tmp = pow(26,d)
for i in range(d-1,-1,-1):
  tmp //= 26 
  ans += al[n//tmp]
  n %= tmp
print(ans)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,b) for(int i= 0; i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define inp(a) for(auto& i : a) cin >> i;
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define MOD 1000000007
const int N = 2e5+7 ;
string s ;

int32_t main(){fast ;
	int n,x,y ;
	cin >> n >> x >> y ;
	vi a(n) ;
	inp(a) ;
	if(n==1)
		cout << abs(a[0]-y) << endl ;
	else{
		cout << max(abs(a[n-2]-a[n-1]) , abs(a[n-1] - y)) << endl ;
	}
}

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

A = 0
B = 0
while(True):
 mx = max(a)
 if mx == -1: break
 mx_idx = a.index(mx)
 a[mx_idx] = -1
 A += mx
 
 mx = max(a)
 if mx == -1: break
 mx_idx = a.index(mx)
 a[mx_idx] = -1
 B += mx

print(A-B)

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

int main() {
  int a,b,sum,sub,mul;
  cin >> a >> b;
  sum = a+b;sub = a-b;mul = a*b;
  if(sum >= sub && sum >= mul){
    cout << sum << endl;
  }
  else if(sub > sum && sub >= mul){
    cout << sub << endl;
  }
  else{
    cout << mul << endl;
  }
}


Measured memory_bytes: 256
// AOJ 2210: Star Watching
// 2017.10.1

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.1415926535897932384626433832795
double xpol, ypol, zpol;			// Polaris
double aa;

int check(double a, double h)
{
	double theta, phi;
	double x, y, z, zz;

	theta = (180 - a) * PI/180.0;
	phi = h * PI/180.0;
	x = cos(theta)*cos(phi);
	y = sin(theta)*cos(phi);
	z = sin(phi);

	zz =  (zpol*xpol*(1-cos(aa)) - ypol*sin(aa))*x
		+ (ypol*zpol*(1-cos(aa)) + xpol*sin(aa))*y
		+ (zpol*zpol*(1-cos(aa)) +      cos(aa))*z;

	return zz > 0;
}

int main()
{
	int t, n, m, mm, dd, hh, min, i, j, f;
	double a, h;
	char date[20], time[20], name[52], *p;
	int mdays[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};

	a = PI, h = 43.2*PI/180.0;		// Polaris
	xpol = cos(a)*cos(h);
	ypol = sin(a)*cos(h);
	zpol = sin(h);

	scanf("%d", &t);
	while (t-- > 0) {
		scanf("%s%s", date, time);
		p = date; mm = atoi(p); while (*p != '/') p++;
		p++;      dd = atoi(p);
		p = time; hh = atoi(p); while (*p != ':') p++;
		p++;     min = atoi(p);
		for (i = 1; i < mm; i++) dd += mdays[i];
		min += 60 * (24*(dd-1) + hh);
		aa = -(double)min * (1+1/365.24)*PI*2/1440.0;

		scanf("%d", &n);
		for (i = 0; i < n; i++) {
			scanf("%s%d", name, &m);
			for (f = 1, j = 0; j < m; j++) {
				scanf("%lf%lf", &a, &h);
				if (f && !check(a, h)) f = 0;
			}
			if (f) puts(name);
		}
	}
	return 0;
}

Measured memory_bytes: 2064
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
//use std::num;
//use petgraph::unionfind::UnionFind;
//use permutohedron::LexicalPermutation as _;

//#[fastout()]
fn main() {
  input! {
      K:i64,
  }
  if K % 2 == 0 || K % 5 == 0 {
    println!("-1");
    return;
  }
  let mut k = K;
  let mut rep7 = 7;
  for i in 1..std::i64::MAX {
    if rep7 >= K {
      rep7 = rep7 % K;
    }
    if rep7 == 0 {
      println!("{}", i);
      return;
    }
    rep7 = rep7 * 10 + 7;
  }
}


Measured memory_bytes: 2152
def combination(n, r):
    res_n = 1
    res_r = 1

    for _ in range(r):
        res_n *= n
        n -= 1

    for _ in range(r):
        res_r *= r
        r += 1

    return res_n // res_r

n, k = map(int, input().split(" "))

res = 0
for i in range(n):
    if i == 0:
        res = combination(k, 1)
    else:
        res *= combination(k - 1, 1)

print(res)

Measured memory_bytes: 3064
program division_into_two
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, i, k = 2, x(0:100000) = 0
  integer(8) :: a, b, s(100000) = 0_8, y(100001) = 0_8
  read(*,*) n, a, b
  if (n == 1) then
    write(*,'(i0)') 2
    stop
  end if
  do i = 1, n
    read(*,*) s(i)
  end do
  if (a > b) then
    a = xor(a,b)
    b = xor(a,b)
    a = xor(a,b)
  end if
  do i = 1, n-2
    if (s(i+2)-s(i) < a) then
      write(*,'(i0)') 0
      stop
    end if
  end do
  do i = 2, n
    x(i) = x(i-1)
    if (s(i)-s(i-1) < a) x(i) = x(i)+1
  end do
  y(1) = 1_8
  do i = 1, n
    do while (k <= n .and. s(k)-s(i) < b)
      k = k+1
    end do
    if (x(i) == x(i-1)) y(i+1) = mod(y(i+1)+y(i),md)
    if (k == i+1 .or. x(k-1) == x(i+1)) y(k) = mod(y(k)+y(i),md)
  end do
  write(*,'(i0)') y(n+1)
end program division_into_two

Measured memory_bytes: 2176
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		var cnt = 0;
		while (true)
		{
			int i = 0, j = 0;
			for (var k = 0; k < 3; k++)
			{
				if (I[k] > I[i]) i = k;
				if (I[k] < I[j]) j = k;
			}
			if (I[i] - I[j] >= 2)
			{
				var k = (I[i] - I[j]) / 2;
				I[j] += 2 * k;
				cnt += k;
				continue;
			}
			WriteLine(cnt + I.Count(x => x != I[j]));
			return;
		}
	}
}


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

vector<int> X[100005];
int A[100005], D[100005];

void dfs1(int s, int par, int t)
{
    if(s == t)
        D[s] = 0;
    
    for(auto x : X[s])
        if(x != par)
        {
            dfs1(x, s, t);

            if(D[x] != -1)
                D[s] = D[x] + 1;
        }
}

void dfs2(int s, int par)
{
    A[s] = 0;

    for(auto x : X[s])
        if(x != par && D[x] == -1)
        {
            dfs2(x, s);
            A[s] = max(A[s], A[x] + 1);
        }
}

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

    int N, a, b;
    cin >> N >> a >> b;

    for(int i=1; i<=N; i++)
    {
        int u, v;
        cin >> u >> v;

        X[u].push_back(v);
        X[v].push_back(u);
    }

    memset(D, -1, sizeof(D));

    dfs1(a, 0, b);
    int d = D[a];
    int target = d / 2 + 1, indx = -1;

    for(int i=1; i<=N; i++)
    {
        if(D[i] != -1 && D[i] > target)
            D[i] = -1;
        if(D[i] == target)
            indx = i;
    }

    dfs2(indx, 0);

    int x = d - target + A[indx];
    int y = target + A[indx];

    cout << y - 1 << "\n";
    return 0;
}


Measured memory_bytes: 12032
#include <stdint.h>

#include <algorithm>
#include <iostream>

using namespace std;

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

  const int64_t a = N / K;
  const int64_t b = (N + K - 1) / K;

  cout << min(N - K * a, abs(N - K * b)) << endl;

  return 0;
}


Measured memory_bytes: 3592
// 以下のソースを勉強する.
// zscoder氏.
// https://atcoder.jp/contests/dp/submissions/3940438
#include <bits/stdc++.h>
using namespace std;

double dp[311][311][311];
int cnt[3];

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        int x;
        scanf("%d", &x);
        x--;
        cnt[x]++;
    }
    
    // 2. dp更新.
    dp[0][0][0] = 0.0;
    for(int k = 0; k <= cnt[2]; k++){
        for(int j = 0; j <= N; j++){
            for(int i = 0; i <= N; i++){
                if(i == 0 && j == 0 && k == 0) continue;
                dp[i][j][k] = 1.0;
                if(i > 0) dp[i][j][k] += (i + 0.0) / N * dp[i - 1][j][k];
                if(j > 0) dp[i][j][k] += (j + 0.0) / N * dp[i + 1][j - 1][k];
                if(k > 0) dp[i][j][k] += (k + 0.0) / N * dp[i][j + 1][k - 1];
                dp[i][j][k] *= (N + 0.0) / (i + j + k);
            }
        }
    }
    // for(int i = 0; i <= N; i++){
    //     for(int j = 0; j <= N; j++){
    //         for(int k = 0; k < 3; k++) printf("%f ", dp[i][j][k]);
    //         printf("\n");
    //     }
    // }
    
    // 3. 出力.
    printf("%.15f\n", dp[cnt[0]][cnt[1]][cnt[2]]);
    return 0;
}

Measured memory_bytes: 229632
N,M,Q = map(int,input().split())
numcomb = [list(map(int,input().split())) for _ in range(Q)]
ans = 0
for i1 in range(1,M+1):
    for i2 in range(i1,M+1):
        for i3 in range(i2,M+1):
            for i4 in range(i3,M+1):
                for i5 in range(i4,M+1):
                    for i6 in range(i5,M+1):
                        for i7 in range(i6,M+1):
                            for i8 in range(i7,M+1):
                                for i9 in range(i8,M+1):
                                    for i10 in range(i9,M+1):
                                        temp = 0
                                        arrs = [0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                                        for a,b,c,d in numcomb:
                                            if arrs[b] - arrs[a] == c:
                                                temp  += d
                                        ans=max(ans,temp)
print(ans)

Measured memory_bytes: 9228
mod=1000000007
n,m=map(int,input().split())
ll=[]
dp=[]
for i in range(n):
  s=input()
  ll.append(s)
  l=[0]*m
  dp.append(l)
for i in range(n):
  if(ll[i][0]=='#'):
    break
  dp[i][0]=1
for j in range(m):
  if(ll[0][j]=='#'):
    break
  dp[0][j]=1
for i in range(1,n):
  for j in range(1,m):
    if(ll[i][j]!='#'):
    	dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod
print(dp[n-1][m-1])

Measured memory_bytes: 51568
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stdio.h>
#include <math.h>
#include <map>
#include <algorithm>

using namespace std;

#define N 100000
static const long long FAR = (1L << 31);

static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

vector<int> G[N];
vector<int> out;
bool Visited[N];
int n, m;
int indeg[N];

void bfs(int s){
	queue<int>q; q.push(s);
	Visited[s] = true;
	while (!q.empty()){
		int u = q.front(); q.pop();
		out.push_back(u);
		for (int i = 0; i < G[u].size(); ++i){
			int v = G[u][i];
			indeg[v]--;
			if (indeg[v] == 0 && !Visited[v]){
				Visited[v] = true;
				q.push(v);
			}
		}
	}
}

void tsort(){
	for (int i = 0; i < n; ++i) indeg[i] = 0;

	for (int u = 0; u < n; ++u){
		for (int j = 0; j < G[u].size(); ++j){
			int v = G[u][j];
			indeg[v]++;
		}
	}

	for (int u = 0; u < n; ++u) if (indeg[u] == 0 && !Visited[u]) bfs(u);
	for (int i = 0; i < out.size(); ++i) cout << out[i] << endl;
}

int main(){
	cin >> n >> m;
	for (int i = 0; i < n; ++i) Visited[i] = false;
	for (int i = 0; i < m; ++i){
		int u, v; cin >> u >> v;
		G[u].push_back(v);
	}
	tsort();
	return 0;
}

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

typedef long long ll;

ll n, cnt_2, cnt_5;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	if (n & 1) {
		cout << 0;
		return 0;
	}
	for (ll x = 2; x <= n; x *= 2)
		cnt_2 += n / x;
	for (ll x = 5; x <= n; x *= 5)
		cnt_5 += (n / x) / 2;
	cout << min(cnt_2, cnt_5);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   string s;
   cin>>s;
   set<char>st;
   int n=s.length();
   for(int i=0;i<n;i++){
     st.insert(s[i]);
   }
  if(st.size()==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
    int n;
    cin >> n;
    v a(n, 0);
    rep(i, n) cin >> a[i];
    int c = 1;
    rep(i, n)
    {
        if(a[i] == c) c++;
    }
    if(c == 1)
    {
        cout << -1 << endl;
    }else{
        cout << n - c + 1 << endl;
    }
}

Measured memory_bytes: 1024
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)
    print(n * (n - 1) // 2)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3944
#include <iostream>

using namespace std;

int main()
{
	int X, answer = 0, tmpX;
	cin >> X;
	answer += (X / 500) * 1000;
	if (X % 500 != 0)
	{
		tmpX = X % 500;
		answer += (tmpX / 5) * 5;
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 10000

int main(){
  int i,j,n,A[N],sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]==2)
      sum++;
  }
  for(i=0;i<n;i++){
    
    if(A[i]<2 || A[i]%2==0) continue;
    
    j=3;
    while(j<=(int)(sqrt(A[i]))){
      if(A[i]%j==0)
	break;
      j=j+2;
    }
    if(j>(int)(sqrt(A[i])))
      sum++;
    
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 628
R=range
def F(a,b):A=len(a);return[all([len(set([a[i+j],b[j],'?']))<3for j in R(min(A-i,len(b)))])for i in R(A)]+[1]
def Z(X):
 i,j,k=X;A,B,C=[len(S[t])for t in X];q=1e5
 for l in R(A+1):
  if M[i][j][l]:
   for r in R(l,A+B+1):
    if(B<r-l or M[j][k][r-l])*M[i][k][min(A,r)]:q=min(q,max(A,l+B,r+C))
 return q
S=[input()for i in R(3)]
M=[[F(i,j)for j in S]for i in S]
from itertools import*;print(min([Z(i)for i in permutations(R(3))]))


Measured memory_bytes: 55092
import itertools

n, m = input().split()
n, m = int(n), int(m)
 
bulbs = []
 
for i in range(m):
    l = input().split()
    arr = [int(x) for x in l][1:]
    bulbs.append(arr)

needs = [int(x) for x in input().split()]
 
combos = 0

def test(lis):
  for i in range(m):
    curr = 0
    need = needs[i]
    for b in bulbs[i]:
      if lis[b-1] == 1:
        curr += 1
    if curr % 2 != need:
      return False
  return True
  
for i in itertools.product([0, 1], repeat=n):
  if test(list(i)):
    combos += 1

print(combos)

Measured memory_bytes: 3064
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    A = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b] = [int(input_raw[0]), int(input_raw[1])]
        A.append((a, b))
    A.sort()

    count = 0L
    for i in range(N):
        count += A[i][1]
        if count >= K:
            print A[i][0]
            return




if __name__ == '__main__':
    main()


Measured memory_bytes: 18800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		int[] input = new int[n];
		
		String[] tmpArray = br.readLine().split(" ");
		
		for(int i = 0; i < n; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
		}
		
		Arrays.sort(input);
		
		int a = 0;
		int b = n - 1;
		
		int med = input[n - 1]/2;
		for(int i = 1; i < n - 2; i++){
			if(Math.abs(input[a] - med) >= Math.abs(input[i] - med)){
				a = i;
			}
		}
		
		System.out.println(input[b]+" "+input[a]);
	}

}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  string str;
  cin >> str;

  cout << (char) (str[0]+1) << endl;

  return 0;
}




Measured memory_bytes: 3592
/**
 *  author: mahfuzz
 *  created: 12.01.2020
**/
 
#include <iostream>
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n; cin >> n;
    string s; cin >> s;
    
    int cnt = 0;
    for(int i = 0; i < n-2; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
            cnt++;
    }
    
    cout << cnt << "\n";
    
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())

digit = 1
while n > 26 ** digit:
  n -= 26 ** digit
  digit += 1

ans = []
n -= 1
char = 'abcdefghijklmnopqrstuvwxyz'
for i in list(range(digit)):
  ans.append(char[n % 26])
  n -= n%26
  n = int(n/26)

print(''.join(reversed(ans)))

Measured memory_bytes: 9104
#include <stdio.h>
int max(int i, int j, int k)
{
    if( i>=j && i>=k )
        return i;

    if( j>=i && j>=k )
    	return j;

    if( k>=i && k>=j )
    	return k;      
}
int combine(int l, int m)
{
	return l*10 + m;
}
int main()
{
	int a,b,c;
	scanf("%d%d%d", &a, &b, &c);
	int x,y,z;
	 x = combine(a,b);
	 y = combine(b,c);
	 z = combine(c,a);
	printf("%d", max( x+c,y+a,z+b));
return 0;
}

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

int main() {
    string s;
    cin >> s;
    int l = stoi(s.substr(0, 2));
    int r = stoi(s.substr(2, 2));

    string ans = "NA";
    if (l >= 1 && l <= 12) {
        ans = "MMYY";
        if (r >= 1 && r <= 12) ans = "AMBIGUOUS";
    } else if (r >= 1 && r <= 12) {
        ans = "YYMM";
        if (l >= 1 && l <= 12) ans = "AMBIGUOUS";
    }

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


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

using namespace std;

int main(){
        int N;
        int count=0,ans=0;
        cin >> N;
        for(int i=1;i<=N;i=i+2){
                for(int j=1;j<=i;j++){
                    if(i%j==0) count++;
                }
                if(count==8) ans++;
                count = 0;
        }
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 256
x, y, z = map(int, input().split())

a = (y + z) / 2
b = (x + z) / 2
c = (x + y) / 2

if x % 2 or y % 2 or z % 2:
    print(0)
    exit()
if a % 2 or b % 2 or c % 2:
    print(1)
    exit()
if x == y == z:
    print(-1)
    exit()

cnt = 1
while True:
    if cnt % 2 == 0:
        x = (x + a) / 2
        y = (y + b) / 2
        z = (z + c) / 2
    if cnt % 2 == 1:
        a = (x + a) / 2
        b = (y + b) / 2
        c = (z + c) / 2
    cnt += 1
    if x % 2 or y % 2 or z % 2 or a % 2 or b % 2 or c % 2:
        break

print(cnt)


Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main(){

	string a;
	cin>>a;
	long long ans=0;
	long long  s=a.size();

	for(long long i=0;i<s;i++){

		ans+=(int(a[i])-48)%9;
		ans%=9;
	}
	if(ans%9==0){
	
		cout<<"Yes"<<"\n";
		return 0;
	}
	cout<<"No"<<"\n";
	return 0;


}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;


void solve()
{
	int n;
	cin>>n;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	vector<ll>sum(n+1);
	rep(i,n){
		sum[i+1]=sum[i]+a[i];
	}
	ll ans=INF;
	for(int i=1;i<n-2;++i){
		vector<ll>left(4),right(4);
		int ok=1,ng=i+1;
		while(abs(ok-ng)>1){
			int mid=(ok+ng)/2;
			if(sum[i+1]-sum[mid]>sum[mid])ok=mid;
			else ng=mid; 
		}
		left[0]=sum[ok],right[0]=sum[i+1]-sum[ok];
		// ok=1,ng=i+1;
		// while(abs(ok-ng)>1){
		// 	int mid=(ok+ng)/2;
		// 	if(sum[i+1]-sum[mid]<sum[mid])ok=mid;
		// 	else ng=mid; 
		// }
		left[1]=sum[ng],right[1]=sum[i+1]-sum[ng];
		ok=i+2,ng=n;
		while(abs(ok-ng)>1){
			int mid=(ok+ng)/2;
			if(sum[n]-sum[mid]>sum[mid]-sum[i+1])ok=mid;
			else ng=mid; 
		}
		left[2]=sum[ok]-sum[i+1],right[2]=sum[n]-sum[ok];
		// ok=i+2,ng=n;
		// while(abs(ok-ng)>1){
		// 	int mid=(ok+ng)/2;
		// 	if(sum[n]-sum[mid]<sum[mid]-sum[i+1])ok=mid;
		// 	else ng=mid; 
		// }
		left[3]=sum[ng]-sum[i+1],right[3]=sum[n]-sum[ng];
		rep(j,2){
			REP(k,2,4){
				//cout<<left[j]<<" "<<right[j]<<" "<<left[k]<<" "<<right[k]<<"\n";
				chmin(ans,max({left[j],right[j],left[k],right[k]})-min({left[j],right[j],left[k],right[k]}));
			}
		}
	}
	cout<<ans<<"\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 6348
import * as fs from 'fs';

namespace AtCoder.abc118 {

    class ProgramB {
        inp: string[];

        // in
        // 3 4
        // 2 1 3
        // 3 1 2 3
        // 2 3 2
        // out
        // 1
        constructor(inp: string) {
            this.inp = inp.split('\n');
        }

        main() {
            const [n, m]: number[] = this.inp[0].split(' ').map(Number);
            this.inp.shift();

            let cnt: number = 0;
            for (let i: number = 1; i <= m; i++) { // 食べ物
                let flg = true;
                for (let j: number = 0; j < n; j++) { // 人
                    if (!this.inp[j].split(' ').map(Number).slice(1).some((x: number) => x == i)) {
                        flg = false;
                    }
                }
                if (flg) cnt++;
            }
            console.log(cnt);
        }
    }

    const args: string = fs.readFileSync('/dev/stdin', 'utf8').trim();
    const func = new ProgramB(args);
    func.main();
}

Measured memory_bytes: 8588
class T():
    def __init__(self, values):
        self.values = values

    def __add__(self, x):
        return min(self.values, x.values)

    def __mul__(self, x):
        return self.values + x.values

    def Tropical_sum(self):
        return min(self.values)
inf = float('inf')

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

# dp table
dp = [inf]*N
dp[0] = 0

for i in range(N):
    for j in range(1,K+1):
        if i-j>=0:
            dp[i] = T(dp[i]) + T(dp[i-j] + abs(h[i]-h[i-j]))
print(dp[N-1])

Measured memory_bytes: 57056
#include <stdio.h>

int main() {
    int p,q,r;
    int a,b,c,ans;
 
    scanf("%d",&p);
    scanf("%d",&q);
    scanf("%d",&r);
    
    a = p+q;
    b = q+r;
    c = r+p;
    
  if(a <= b)
    ans = a;
  else
    ans = b;
  if(ans >= c)
    ans = c;
  printf("%d",ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;
const int MAX=5e5+10;
//const int INF=1e9+15;



int main(){
	int N;
	ll D;
	cin>>N>>D;
	ll d[MAX];
	rep1(i,N)cin>>d[i];
	int Q;
	cin>>Q;
	
	ll now[MAX];
	now[0]=D;
	rep1(i,N)now[i]=min(now[i-1], abs(now[i-1]-d[i]));
	if(now[N]!=0){
		rep(_,Q)cout<<"YES"<<endl;
		return 0;
	}
	int ur[MAX];
	ur[N]=1;
	for(int i=N-1; i>=0; i--){
		if(d[i+1]>=2*ur[i+1]) ur[i]=ur[i+1];
		else ur[i]=ur[i+1]+d[i+1];
	}
	rep(_,Q){
		int q;
		cin>>q;
		q--;
		if(now[q]>=ur[q+1])cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef double ld;
typedef long long ll;
#define int ll
const ll mod=1e9+7;

int32_t main()
{
    long double n,ans;
    cin>>n;
    int money=100;
    int cnt=0;
    while(money<n)
    {
        money=money*1.01;
        cnt++;
    }
    cout<<cnt<<endl;
}




Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

vector<vector <int>> v;
int color[100],d[100],f[100],t,n;

void dfs_visit(int u)
{
	color[u]=1;
	d[u]=++t;
	int next=-1;
	rep(i,v[u].size())
	{
		if(color[v[u][i]]==0)
		{
			next=v[u][i];
			dfs_visit(next);
		}
	}
	f[u]=++t;
}

void dfs()
{
	rep(i,n)color[i]=0;
	t=0;

	rep(i,n)
	{
		if(color[i]==0)dfs_visit(i);
	}
}

int main()
{
	cin >> n;
	rep(i,n)
	{
		int hoge;cin >> hoge;
		int k;cin >> k;
		v.push_back(vector <int>());
		rep(j,k)
		{
			int fooo; cin >> fooo;
			v[i].push_back(fooo-1);
		}
	}

	dfs();
	rep(i,n)
	{
		cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3136
#include <stdio.h>
#include <stdlib.h>
#include <math.h> 
int main ()
{
	int a[3][3];
	int n,i,j;
	for (i=0;i<3;i++)
	for (j=0;j<3;j++)
	scanf("%d",&a[i][j]);
	if (a[0][0]-a[1][0]==a[0][1]-a[1][1]&&a[0][0]-a[1][0]==a[0][2]-a[1][2]&&a[1][0]-a[2][0]==a[1][1]-a[2][1]&&a[1][0]-a[2][0]==a[1][2]-a[2][2])
	printf ("Yes\n");
	else printf ("No\n");
	return 0;
}

Measured memory_bytes: 128