akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
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--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    ll n; cin >> n;
    set<ll> st;
    map<ll, ll> odd_m;
    map<ll, ll> even_m;

    // 奇数個目、偶数個目それぞれで各値をカウント (map)
    // 出現頻度最大とその次点を確認
    REP(i, n) {
        ll tmp;
        cin >> tmp;
        st.insert(tmp);

        if (i % 2 == 0) {
            even_m[tmp]++;
        } else {
            odd_m[tmp]++;
        }
    }

    using p = pair<ll, ll>;
    vector<p> odd_v;
    vector<p> even_v;

    for (auto e:odd_m) {
        odd_v.push_back(make_pair(e.second, e.first));
    }

    for (auto e:even_m) {
        even_v.push_back(make_pair(e.second, e.first));
    }

    sort(ALL(odd_v), greater<>());
    sort(ALL(even_v), greater<>());

    // (1) それぞれ2種類以上ある場合 -> 最上位が違う場合は単純にそれ以外をreplace。違う場合1:5-2:3, 1:7-2:1として、最上位頻度が多いほうを選択し、残りは2番目を使う
    // (2) 片方が1種類の場合 -> (1) と同様でいける？2番目がない場合は、片方が1であれば2、そうでなければ1とする
    // (3) どちらも1種類の場合 -> (1) と同様かつ、片方を先に決定するパターン

    ll odd_fix;
    ll even_fix;
    if ((odd_v[0].first > even_v[0].first) || ( (odd_v.size() > 1) && (even_v.size() > 1) && (odd_v[0].first == even_v[0].first) && (odd_v[1].first < even_v[1].first) )) {
        // 奇数のほうを固定
        odd_fix = odd_v[0].second;
        if (even_v[0].second == odd_fix) {
            if (even_v.size() > 1) {
                even_fix = even_v[1].second;
            } else {
                if (odd_fix == 1) {
                    even_fix = 2;
                } else {
                    even_fix = 1;
                }
            }
        } else {
            even_fix = even_v[0].second;
        }
    } else {
        // 偶数のほうを固定
        even_fix = even_v[0].second;
        if (odd_v[0].second == even_fix) {
            if (odd_v.size() > 1) {
                odd_fix = odd_v[1].second;
            } else {
                if (even_fix == 1) {
                    odd_fix = 2;
                } else {
                    odd_fix = 1;
                }
            }
        } else {
            odd_fix = odd_v[0].second;
        }
    }
    cout << n - odd_m[odd_fix] - even_m[even_fix] << endl;
    return 0;
}

Measured memory_bytes: 16484
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
int main(){
	string s;
	int k;
	cin>>s>>k;
	if(s.size()<k){
		cout<<0<<endl;
		return 0;
	}
	if(s.size()==1){
		if(k==1)cout<<9<<endl;
		return 0;
	}
	long long cnt=0LL;
	for(int i=k;i<s.size();i++){
		if(k==1)cnt+=1LL*9;
		else if(k==2)cnt+=1LL*9*(i-1)*9;
		else cnt+=1LL*9*(i-1)*(i-2)/2*81;
	}
	if(k==1){
		cnt+=(int)(s[0]-'0');
	}
	else if(k==2){
		cnt+=1LL*(int)(s[0]-'0'-1)*(s.size()-1)*9;
		for(int j=1;j<s.size();j++){
			if(j+1==s.size()){
				cnt+=(int)(s[j]-'0');
				break;
			}
			if((int)(s[j]-'0')>0){
				cnt+=1LL*(int)(s[j]-'0');
				cnt+=1LL*(s.size()-j-1)*9;
				break;
			}
		}
	}
	else{
		cnt+=1LL*(int)(s[0]-'0'-1)*(s.size()-1)*(s.size()-2)/2*81;
		int num=0;
		for(int i=1;i<s.size();i++){
			if((int)(s[i]-'0')>0){
				num=i;
				break;
			}
		}
		if(!num){
			cout<<cnt<<endl;
			return 0;
		}
		if(num+2==s.size()){
			if((int)(s[num+1])>0){
				cnt+=(int)(s[num]-'0')*(int)(s[num+1]-'0');
			}
			cout<<cnt<<endl;
			return 0;
		}
		if(num+2>s.size()){
			cout<<cnt<<endl;
			return 0;
		}
		cnt+=(s.size()-num-1)*(s.size()-num-2)/2*81;
		cnt+=(int)(s[num]-'0'-1)*(s.size()-num-1)*9; 
		for(int j=num+1;j<s.size();j++){
			if(j+1==s.size()){
				cnt+=(int)(s[j]-'0');
				break;
			}
			if((int)(s[j]-'0')>0){
				cnt+=1LL*(int)(s[j]-'0');
				cnt+=1LL*(s.size()-j-1)*9;
				break;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
bbn=1000000007
	
#+++++
		
def main():
	a, b , c = map(int, input().split())
	ss=a+b+c
	ret = 'win' if ss <= 21 else 'bust'
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3316
a, b = gets.split.map &:to_i

result = 0

(1..100000000000000).each{ |i|
	if i == 1 then
		s1 = (a + 1)/ 2
		t1 = b / 2
		s2 = a % 2
		t2 = b % 2
		
		if ((t1-s1) % 2 + s2 + t2) % 2 == 1 then
			result = 1
		else
			result = 0
		end
		
	end

	x = 2 ** i
	
	s = [a % x - x / 2, 0].max
	t = [(b + 1) % x - x / 2, 0].max

	d = (s - t).abs % 2
	
	result += d * (2 ** (i - 1))

	if x > b then
		break
	end

}

puts result


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    ll odd_num = 0;
    rep(i, n) {
        ll temp;
        cin >> temp;
        if (temp % 2 == 1) {
            odd_num++;
        }
    }
    if (odd_num % 2 == 1) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <climits>
#define mk make_pair
#define pb push_back
#define scanf scanf_s
#define printf printf_s
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> pos;
const ll N = 200010, MOD = 1000000007;

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}

int bb(int v1) {
	if (v1 % 2 == 0)return v1 / 2 - 1;
	else return v1 / 2;
}

ll pw(ll a, ll b) {
	ll v = 1;
	for (; b > 0; b = (b >> 1), a = (a * a) % MOD) {
		if ((b & 1) > 0)v = (v * a) % MOD;
	}
	return v;
}


struct Comb {
public:ll frc[N + 1], rv[N + 1];
	  ll pw(ll v1, ll v2) {
		  ll v3 = 1;
		  for (; v2 > 0; v2 = (v2 >> 1)) {
			  if (v2 & 1)v3 = (v3 * v2) % MOD;
			  v1 = (v1 * v1) % MOD;
		  }
		  return v3;
	  }

	  void set() {
		  frc[0] = 1;
		  rv[0] = 1;
		  for (int i = 1; i < N; i++) {
			  frc[i] = (frc[i - 1] * i) % MOD;
			  rv[i] = pw(frc[i], MOD - 2);
		  }
	  }
	  ll comb(ll a, ll b) {
		  ll v1 = frc[a];
		  v1 = (v1 * rv[b]) % MOD;
		  v1 = (v1 * rv[a - b]) % MOD;
		  return v1;
	  }
};

vector<int> g[N];
int dp[N],n;

int main() {
	cin >> n;
	for (int i = 2; i <= n; i++) {
		int v1; cin >> v1;
		dp[v1]++;
	}
	for (int i = 1; i <= n; i++)cout << dp[i] << endl;
	return 0;
}


Measured memory_bytes: 9096
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <stack>
using namespace std;
int main(){
  int a,b,c,p;
  while(cin>>a>>b>>c){
    if(cin.eof())return 0;
    p=0;
    for(int i=1;i<=10;i++){
      if(i!=a&&i!=b&&i!=c&&a+b+i<=20)p++;
    }
    if((double)p/7>=0.5)cout<<"YES"<<endl;
    else{cout<<"NO"<<endl;}
  }
}

Measured memory_bytes: 0
require 'set'

class Cuboid
	attr_reader *%w(x1 y1 z1 x2 y2 z2)
	def initialize(*args)
		@x1, @y1, @z1, @x2, @y2, @z2 = args
	end
end
		
n, k = gets.split.map &:to_i

z_events = []
n.times {
	c = Cuboid.new(*gets.split.map(&:to_i))
	z_events << [:add, c, c.z1]
	z_events << [:del, c, c.z2]
}
z_events.sort_by!(&:last)

volume = 0
z = 0
area = 0
z_cuboids = Set.new
until z_events.empty?
	next_z = z_events[0][2]
	volume += area * (next_z - z)
	while !z_events.empty? && z_events[0][2] == next_z
		command, c, _ = z_events.shift
		command == :add ? z_cuboids << c : z_cuboids.delete(c)
	end
		
	y_events = []
	z_cuboids.each {|c|
		y_events << [:add, c, c.y1]
		y_events << [:del, c, c.y2]
	}
	y_events.sort_by!(&:last)
	area = 0
	length = 0
	y = 0
	y_cuboids = Set.new
	until y_events.empty?
		next_y = y_events[0][2]
		area += length * (next_y - y)
		while !y_events.empty? && y_events[0][2] == next_y
			command, c, _ = y_events.shift
			command == :add ? y_cuboids << c : y_cuboids.delete(c)
		end

		x_events = []
		y_cuboids.each {|c|
			x_events << [:add, c, c.x1]
			x_events << [:del, c, c.x2]
		}
		x_events.sort_by!(&:last)
		length = 0
		x = 0
		overlap = 0
		until x_events.empty?
			next_x = x_events[0][2]
			length += next_x - x if overlap >= k

			while !x_events.empty? && x_events[0][2] == next_x
				command, c, _ = x_events.shift
				overlap += (command == :add ? 1 : -1)
			end
			x = next_x
		end

		y = next_y
	end
	z = next_z
end

p volume

Measured memory_bytes: 6268
#include <iostream>

using namespace std;

int main(){

  int N,sum=0,num;
  
  cin >> N;

  num = N;

  while(num != 0){
	sum += num % 10;
	num = num / 10;
  }

  if( N % sum != 0){
	cout << "No" << "\n";
  }
  else{
	cout << "Yes" << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=101;

int n,t;
struct route{
	int t,c;
	bool operator<(const route &s)const{
		if(t==s.t)
		  return c>s.c;
		return t<s.t;
	}
}a[MAXN];

int main()
{
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;++i)
	  scanf("%d%d",&a[i].c,&a[i].t);
	sort(a+1,a+n+1);
	if(a[1].t>t)
	{
	    printf("TLE");
	    return 0;
	}
	else
	{
		int minn=0x3f3f3f3f;
		for(int i=1;i<=n;++i)
		  if(a[i].t>t)
		  {
		  	  break;
		  }
		  else
		    minn=min(a[i].c,minn);
		printf("%d",minn);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const llint INF = 100000000;

struct edge { int to, cost; };

int b_s(vector<vector<int>>& a, int key,int z) {
	int left = -1;
	int right = a[z].size();
	while (right - left > 1) {
		int mid = left + (right - left) / 2;
		if (a[z][mid] > key)right = mid;
		else left = mid;
	}
	return left;
}


int main() {
	int a;
	cin >> a;
	Yes(a >= 30);
	return 0;
}


Measured memory_bytes: 3620
n,k = map(int,input().split())
A = list(map(int,input().split()))
one = A.index(1) +1
ans = float('inf')

for i in range(k):
    left = max(0,one-i)
    right = min(n,one+k-1 - i)
    num_l = max(0,int((left-1-0.1)//(k-1))+1)
    num_r = max(0,int((n - right-0.1)//(k-1))+1)
    ans = min(ans,num_r+num_l)

print(ans+1)


Measured memory_bytes: 13880
n=int(input())
a=list(map(int,input().split()))
ans='No'
a2=[i//2 for i in a if i%2==0]
a4=[i for i in a2 if i%2==0]
la2=len(a2)
la4=len(a4)
if la2+la4>=n and la2>0:
    ans='Yes'
elif la2==la4 and 2*la4+1>=n:
    ans='Yes'
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <set>
#include <vector>
#include <iomanip>
#include <numeric>
#include <cfenv>
#include <cmath>
typedef long long int ll;

using namespace std;

int main()
{

    int N, M, X;

    cin >> N >> M >> X;

    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));

    for (int i = 0; i < N; i++)
    {

        cin >> C[i];

        for (int j = 0; j < M; j++)
        {

            cin >> A[i][j];
        }
    }



        int now_mone = INFINITY;

        int global_skill = 0;

    for (int bit = 0; bit < (1 << N); ++bit)
    {

        vector<int> total(M, 0);

        bool skill_up = 1;

        vector<int> S(0);
        for (int i = 0; i < N; ++i)
        {
            if (bit & (1 << i))
            { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }



        if (S.size() > 0)
        {

            for (int j = 0 ;j < S.size(); j++)
            {

                for (int k = 0; k < M; k++)
                {
                    total[k] += A[S[j]][k];
                }
            }

            for (int j = 0; j < M; j++)
            {

                if (total[j] < X)
                {

                    skill_up = 0;
                }
            }

            if (skill_up == 1)
            {

                global_skill =1;

                int mone = 0;

                for (int j = 0 ;j < S.size(); j++)
                {

                    mone += C[S[j]];
                }

               now_mone = min(mone, now_mone);
            }
        }
    }


    if(global_skill == 0){


        cout << -1 << endl;
    }
    else{

        cout << now_mone << endl;
    }

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int a=0;
  int b=0;
  int c=0;
  rep(i,s.size()){
    if(s.at(i)=='a'){
      a++;
    }
    if(s.at(i)=='b'){
      b++;
    }
    if(s.at(i)=='c'){
      c++;
    }
  }
  
  int d=min(a,b);
  d=min(d,c);
  int e=max(a,b);
  e=max(e,c);
  if(e-d<=1){
    cout<<"YES"<<endl;
  }
  
  else{
    cout<<"NO"<<endl;  
  }
  
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,x;
    cin >> k >> x;
    int start = x-k+1;
    if(start < -1000000){
        start = -1000000;
    }
    for (int i = start; (i < 1000000) && (i <= x+k-1); i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
int N;

int calc(vector<int>& vec,int p)
{
  if(vec.size() < 4)
    return 0;

  stack<int> A,B;
  for(int i=0;i<=p;i++)
    A.push(vec[i]);
  for(int i=vec.size()-1;i>p;i--)
    B.push(vec[i]);
 
  bool update;
  while(true)
    {
      update = false;
      if(A.empty() && B.empty())
	break;

      if(!A.empty() && ! B.empty()  && A.top() == B.top())
	{	 
	  int c = A.empty()?B.top():A.top();
	  int cnt = 0;
	  while(!A.empty() && A.top() == c)
	    cnt++,A.pop();
	  while(!B.empty() && B.top() == c)
	    cnt++,B.pop();
	  if(cnt < 4)
	      return A.size() + B.size() + cnt;
	  update = true;
	}
      else 
	{
	  stack<int> C,D;
	  int cnt = 0;
	  int c; 
	  bool pre = false,pre2 = false;
	 
	  if(!A.empty())
	    { 
	      c = A.top();
	      while(!A.empty() && A.top() == c)
		cnt++,C.push(A.top()),A.pop();
	      
	      if(cnt < 4)
		while(!C.empty())
		  A.push(C.top()),C.pop();
	      else 
		pre = true;
	    }	 
	  if(!B.empty())
	    {
	      cnt = 0,c = B.top();
	      while(!B.empty() && B.top() == c)
		cnt++,D.push(B.top()),B.pop();

	      if(cnt < 4)
		while(!D.empty())
		  B.push(D.top()),D.pop();
	      else 
		pre2 = true;
	    }

	  if(pre || pre2)
	    update = true;

	}
      if(!update)
	break;
    }

  return A.size()+B.size();
}

int main()
{
  while(cin >> N,N)
    {
      vector<int> vec; 
      vec.resize(N); 
      for(int i=0;i<N;i++)
	cin >> vec[i];

      int ans = (1<<29);
      for(int i=0;i<N;i++)
	{
	  int pre_color = vec[i];
	  for(int j=1;j<=3;j++)
	    vec[i] = j,ans = min(ans,calc(vec,i));
	  vec[i] = pre_color;
	}
	
      cout << ans << endl;
    }
  return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra
template< typename T >
size_t longest_increasing_subsequence(const vector< T > &a, bool strict) {
  vector< T > lis;
  for(auto &p : a) {
    typename vector< T >::iterator it;
    if(strict) it = lower_bound(begin(lis), end(lis), p);
    else it = upper_bound(begin(lis), end(lis), p);
    if(end(lis) == it) lis.emplace_back(p);
    else *it = p;
  }
  return lis.size();
}

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vl A(n);
        rep(i,n)cin>>A[i];
        reverse(all(A));
        ll ans=longest_increasing_subsequence(A,false);
        cout<<ans<<endl;
    }

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  int ans=0;
  rep(i,n){
    cin >> v[i];
  }
  rep(i,n){
    cin >> c[i];
  }
  rep(i,n){
    if(v[i]-c[i]>0){
      ans += v[i]-c[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << "A" << b[0] << "C" << endl;
    return 0;
}


Measured memory_bytes: 3620
def solve():
  N = int(input())
  ans = [0]*N
  for x in range(1,101):
    for y in range(1,101):
      for z in range(1,101):
        p = x*x + y*y + z*z + x*y + y*z + z*x
        if p <= N:
          ans[p-1] += 1
  return ans
print(*solve(),sep='\n')

Measured memory_bytes: 9228
#include<iostream>
using namespace std;
int main(void)
{
    int a,b;
    cin>>a>>b;
    if(a>b)
    {
        cout<<"a > b"<<endl;
    }
    else if(a<b)
    {
        cout<<"a < b"<<endl;
    }
    else
    {
        cout<<"a == b"<<endl;
    }
    return 0;
}


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

int main(){
  int n,num[1000];
  while(1){
  cin >> n;
  if(!n)break; 
  for(int i = 0 ; i < n ; i++){
    cin >> num[i];
  }
  sort(num,num+n);
  int ans = 0;
  for(int i = 1 ; i < n-1 ; i++){
    ans += num[i];
  }
  cout << ans/(n-2) << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  vector<int> nums;
  int n; cin >> n;
  int tmp;
  rep_i(i, n){
    cin >> tmp;
    nums.push_back(tmp);
    // auto ind = find(nums.begin(), nums.end(), tmp);
    // if(ind == nums.end()){
    //   nums.push_back(tmp);
    // }else{
    //   nums.erase(ind);
    // }
  }
  sort_v(nums);
  int ans;
  int pre = nums[0];
  int c = 1;
  for (int i = 1; i < nums.size(); i++){
    if(pre == nums[i]){
      c++;
    }else{
      if(c%2 == 1){
        ans++;
      }
      pre = nums[i];
      c = 1;
    }
    if(i == nums.size() - 1){
      if(c%2 == 1){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int count=0;
    for(int i=l; i<=r; i++){
        if(i%d==0){
            count=count+1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3632
def main():
    A,B,C = map(int,input().split())
    K = int(input())
    
    for k in range(K):
        if A >= B:
            B *= 2
        elif B >= C:
            C *= 2
            
    if A < B and B < C:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
h1,h2=map(int,input().split())
k1,k2=map(int,input().split())
a,b,c,d=map(int,input().split())
v=a*h1+(h1//10)*c+b*h2+(h2//20)*d
w=a*k1+(k1//10)*c+b*k2+(k2//20)*d
print("even" if v==w else ( "hiroshi" if v > w else "kenjiro" ))

Measured memory_bytes: 7692
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>
bool is_prime(T n){
  for(int i = 2; i * i < n; i++){
    if(n % i == 0) return false;
  }
  return n != 1;
}

int main(){
  int n;
  cin >> n;
  cout << n << ':';
  if(is_prime(n)){
    cout << ' ' <<  n << endl;
    return 0;
  }
  int i = 2;
  while(n != 1){
    while(n % i == 0){
      cout << ' ' << i;
      n /= i;
    }
    i++;
  }
  cout << endl;
}


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

int main(){
    long long n,k,count = 0,first = 0,now,ans = 0;
    int times;
    set<int> visited,roop;
    cin >> n >> k;
    vector<int> a(n,0);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    now = 0;
    for(int i = 0;i < n + 1;i++){
        if(visited.count(now))break;
        else{
            first++;
            visited.insert(now);
            now = a[now] - 1;
        }
    }

    for(int i = 0;i < n + 1;i++){
        if(roop.count(now))break;
        else{
            count++;
            roop.insert(now);
            now = a[now] - 1;
        }
    }

    if(k >first){
        k -= first;
        k %= count;
        times = k + first;
    }else{
        times = k;
    }

    for(int i = 0;i < times;i++){
        ans = a[ans] - 1;
    }
    cout << ans + 1 << endl;
}


Measured memory_bytes: 21056
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    //int a[200005];
    //bool flag=false,d[100005];
    ll a,b,k,ans=0;
    //char s[105],t[105],u;
   
   cin >> a >> b >> k;
    //for(int i=0;i<n;i++) cin >> s[i];
    //for(int i=0;i<n;i++) cin >> t[i];

   if(a-k>=0) a -= k;
   else if(b - k + a >= 0){
     b -= k - a;
     a = 0;
   }else{
       a=0;b=0;
   }
    
    //cout << (!flag ? "Yes" : "No");
    cout << a << " " << b;
    //cout << s;
    //printf("%.10f",ans_d);
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, a, f[200001];

int main()
{
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> a;
    f[a]++;
  }
  for (int i = 1; i <= n; i++)
    cout << f[i] << endl;
  return 0;
}


Measured memory_bytes: 4256
n = int(input())
a = list(map(int, input().split()))
rain = [None]*(n+1)
rain[0] = 0

for i in range(n):
    rain[i+1] = a[i]*2 - rain[i]

x = rain[n] / 2

for i in range(n):
    if i % 2 == 0:
        print(int(rain[i] + x), end= " ")
    else:
        print(int(rain[i] - x), end= " ")

Measured memory_bytes: 14032
#include <iostream>

using namespace std;


int main(){
    int a , b;
    cin >> a >> b;
    int height = 1;
    int heights[1100];

    for(int i = 0;i<=999;++i){
        heights[i] = height;
        height += i + 2;
    }
    int x = heights[b-a-1] - b;
    cout << x<< endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n][4];
	std::set<int> xs, ys;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) a[i][j] = ri();
		xs.insert(a[i][0]);
		xs.insert(a[i][2]);
		ys.insert(a[i][1]);
		ys.insert(a[i][3]);
	}
	std::map<int, int> compx, compy;
	std::vector<int> decompx, decompy;
	int cntx = 0, cnty = 0;
	for (auto i : xs) compx[i] = cntx++, decompx.push_back(i);
	for (auto i : ys) compy[i] = cnty++, decompy.push_back(i);
	std::vector<int> diff[cntx + 1];
	for (int i = 0; i <= cntx; i++) diff[i].resize(cnty + 1, 0);
	for (int i = 0; i < n; i++) {
		int x1 = compx[a[i][0]];
		int x2 = compx[a[i][2]];
		int y1 = compy[a[i][1]];
		int y2 = compy[a[i][3]];
		diff[x1][y1]++;
		diff[x1][y2]--;
		diff[x2][y1]--;
		diff[x2][y2]++;
	}
	for (int i = 0; i <= cntx; i++) for (int j = 0; j < cnty; j++) diff[i][j + 1] += diff[i][j];
	for (int i = 0; i < cntx; i++) for (int j = 0; j <= cnty; j++) diff[i + 1][j] += diff[i][j];
	int64_t res = 0;
	for (int i = 0; i < cntx; i++) for (int j = 0; j < cnty; j++) if (diff[i][j]) {
		res += (int64_t)(decompx[i + 1] - decompx[i]) * (decompy[j + 1] - decompy[j]);
	}
	std::cout << res << std::endl;
	
	return 0;
}



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

int main() {

    int A, B;

    cin >> A >> B;

    //8%
    vector<int> prices8;
    int initPrice8 = A / 0.08 + 1 ;
    int price8 = initPrice8;
    prices8.push_back(price8);
    while(price8*0.08 >= A || initPrice8 == price8){
		if(price8*0.08 >= A && price8*0.08 < A+1){
	      	prices8.push_back(price8);
        }
        price8--;
    }

    price8 = initPrice8 ;
    while(++price8*0.08 < A+1 ){
        prices8.push_back(price8);
    }

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

    //10%
    for (auto price : prices8){
        if(price * 0.1 >= B && price * 0.1 < B+1) {
            cout << price << endl;
            return 0;
        }
    }

    cout << -1 << endl;


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node
{
    int key;
    Node *next, *prev;
};

// 最初のノード(番兵)
Node *nil;

Node *listSearch(int key)
{
    Node *cur = nil->next;
    while (cur != nil && cur->key != key)
    {
        cur = cur->next;
    }
    return cur;
}

void init()
{
    // Nodeのためのメモリを確保
    nil = (Node *)malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

void printList()
{
    // Nodeを順番にたどって出力
    Node *cur = nil->next;

    int isfirst = 0;
    while (1)
    {
        if (cur == nil)
        {
            break;
        }
        if (isfirst > 0)
        {
            printf(" ");
        }
        isfirst++;

        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *node)
{
    if (node == nil)
    {
        return;
    }
    node->prev->next = node->next;
    node->next->prev = node->prev;
    free(node);
}

void deleteFirst()
{
    deleteNode(nil->next);
}

void deleteLast()
{
    // なんで？
    deleteNode(nil->prev);
}

void deleteKey(int key)
{
    deleteNode(listSearch(key));
}

void insertNode(int key)
{
    Node *node = (Node *)malloc(sizeof(Node));
    node->key = key;
    node->next = nil->next;
    node->prev = nil;
    nil->next->prev = node;
    nil->next = node;
}

int main()
{
    int key, n;
    int size = 0;
    char command[20];
    scanf("%d", &n);
    // リストの初期化
    init();

    for (int i = 0; i < n; i++)
    {
        scanf("%s%d", command, &key);
        // commandによって処理を分岐
        if (command[0] == 'i')
        {
            // insert
            insertNode(key);
            size++;
        }
        else if (command[0] == 'd')
        {
            if (command[6] == 'F')
            {
                deleteFirst();
            }
            else if (command[6] == 'L')
            {
                deleteLast();
            }
            else
            {
                deleteKey(key);
            }
            size--;
        }
    }

    printList();

    return 0;
}


Measured memory_bytes: 33840
#include<iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	if(n%4==0||n%7==0)
		cout<<"Yes";
	else if(n==1||n==2||n==3||n==5||n==6)
		cout<<"No"; 
	else
	{
		int flag=0,i;
		for(i=0;i<=n/7;i++)
		{
			if((n-7*i)%4==0)
			{
				flag=1;break;
			}
		}
		if(flag)
		cout<<"Yes";
		else
		cout<<"No"; 
	}
	return 0;
}

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

int main() {
  long n, ans = 0;

  cin >> n;

  vector<long> a(n + 1), b(n);

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

  for (long i = 0; i < n; i++) {
    cin >> b[i];
  }

  for (int i = 0; i < n; i++) {
    ans += min(a[i], b[i]);
    b[i] -= min(a[i], b[i]);
    ans += min(max((long)0, b[i]), a[i + 1]);
    a[i + 1] -= min(max((long)0, b[i]), a[i + 1]);
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 1792
local function str2tbl(s)
    local sub = string.sub
    local t = {}
    for i=1, #s do
        t[i] = sub(s, i, i)
    end
    return t
end

local N, K = io.read("n", "n", "l")
local S = str2tbl(io.read("l"))
local h = 0
local sw = 0
for i=1,N-1 do
    if S[i] == 'L' and S[i+1] == 'L' then
        h = h + 1
    elseif S[i] == 'R' and S[i+1] == 'R' then
        h = h + 1
    else
        sw = sw + 1
    end
end
for k=1,K do
    if sw == 0 then
        break
    elseif sw == 1 then
        h = h + 1
        break
    else
        h = h + 2
        sw = sw - 2
    end
end
print(h)

Measured memory_bytes: 2584
#include <stdio.h>

int main(){
  int a,b;
  scanf("%d %d"  , &a, &b);
  if(a>b){
    printf("a > b\n");
  }else if (a<b){
    printf("a < b\n");
  }else{
    printf("a == b\n");
  }

  return 0;

}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)
 
int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	string s;
	cin>>s;
	if(s.back()=='2' or s.back()=='4' or s.back()=='5' or  s.back()=='7' or s.back()=='9')
		cout<<"hon";
	else if(s.back()=='0' or s.back()=='1' or s.back()=='6' or s.back()=='8')
		cout<<"pon";
	else
		cout<<"bon";
	
	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	final Scanner sc=new Scanner(System.in);
	while(true){
	int a=sc.nextInt();
	int b=sc.nextInt();
	if(a==0 && b==0) break;
	for(int i=0;i<a;i++){
	    for(int j=0;j<b;j++){
		if((i+j)%2==0) System.out.print("#");
		else System.out.print(".");
	    }
	    System.out.println("");
	}
	System.out.println("");
	}
    }
}

Measured memory_bytes: 25760
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace ConsoleApp1
{
    using static Util;

    internal class Program
    {

        static void Main(string[] args)
        {
            var s = ReadIntArray();
            var n = s[0]; var k = s[1];

            var res = 0.0;
            for(var i=0; i<n; i++)
            {
                if(i+1 < k)
                {
                    var now = k / (i + 1.0);
                    var l = Math.Ceiling(Math.Log(now, 2));
                    var c = Math.Pow(1 / 2.0, l);
                    res += (c / n);
                }
                else
                {
                    res += (1.0 / n);
                }
            }

            Console.WriteLine(res.ToString("0.00000000000000"));
#if DEBUG
            Console.Read();
#endif
        }

        public static bool IsDate(string s, string format)
        {
            DateTime d = DateTime.MinValue;
            return DateTime.TryParseExact(s, format, null, System.Globalization.DateTimeStyles.None, out d);
        }
    }

    public static class Util
    {
        public static long[] ReadLongArray() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        public static int[] ReadIntArray() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        public static long ReadLong() => long.Parse(Console.ReadLine());
        public static long ReadInt() => int.Parse(Console.ReadLine());
    }
}


Measured memory_bytes: 13396
# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです。
"""
import math

a,b = map(int, input().split())

alpha = []
beta = []

for x in range(math.floor(a/0.08), math.floor(a/0.05)):
    if math.floor(x * 0.08) == a:
        alpha.append(x)
for y in range(math.floor(b/0.10), math.floor(b/0.05)):
    if math.floor(y * 0.1) == b:
        beta.append(y)

if min(alpha) in beta:
    print(min(alpha))
elif min(beta) in alpha:
    print(min(beta))
else:
    print("-1")    


Measured memory_bytes: 3316
#include <iostream>
#include <numeric>
using namespace std;
int main() {
  int N, M;
  cin >> N;
  cin >> M;

  bool f[M], f2[M];
  for (int i = 0; i < sizeof(f) / sizeof(f[0]); i++) {
    f[i] = false;
    f2[i] = false;
  }

  int K;
  cin >> K;
  for (int i = 0; i < K; i++) {
    int A;
    cin >> A;
    f[A-1] = true;
  }

  for (int n = 1; n < N; n++) {
    for (int i = 0; i < sizeof(f) / sizeof(f[0]); i++) {
      f2[i] = false;
    }
    int K;
    cin >> K;
    for (int i = 0; i < K; i++) {
      int A;
      cin >> A;
      f2[A-1] = true;
    }
    for (int i = 0; i < sizeof(f) / sizeof(f[0]); i++) {
      f[i] = f[i] & f2[i];
    }
  }

  const size_t size = sizeof(f) / sizeof(f[0]);
  cout << accumulate(f, f + size, 0);
}


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

namespace AtCoderBeginnerContest097
{
    class ABC097A
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int C = int.Parse(s[2]);
            int D = int.Parse(s[3]);
            if ((Math.Abs(A - B) <= D && Math.Abs(B - C) <= D) || Math.Abs(A-C) <= D) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
n = int(input())
if n==1 or n==2 or n==3 or n==4 or n==5 or n==6 or n==7 or n==8 or n==9 or n==10 or n==12 or n==14 or n==15 or n==16 or n==18 or n==20 or n==21 or n==24 or n==25 or n==27 or n==28 or n==30 or n==32 or n==35 or n==36 or n==40 or n==42 or n==45 or n==48 or n==49 or n==54 or n==56 or n==63 or n==64 or n==72 or n==81: 
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s=new FastReader();
        int n = s.nextInt();


        long total = 0;
        int[] counter = new int[n];
        for (int i = 1; i < n; i++) {
            int cur = s.nextInt()-1;
            counter[cur]++;
        }
        for (int i = 0; i < n; i++) {
            System.out.println(counter[i]);
        }

    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}



Measured memory_bytes: 61108
#include <stdio.h>

int main(){
	
	int a, b, d, r;
	double f;


	scanf("%d %d", &a, &b);

	d = a / b;
	r = a % b;
	f = (double)a / (double)b;

	printf("%d %d %.5f\n", d, r, f);

	return 0;
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int cur = 1, cnt = 0;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    if (x == cur) cur++;
    else cnt++;
  }
  if (cnt == n) cout << "-1" << endl;
  else cout << cnt << endl;
}





Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        long[] res = new long[n];
        for (int i = n - 2; i >= 0; i--) {
            if (a[i] < a[i + 1]) {
                continue;
            }
            res[i] = res[i + 1] + 1;
        }
        Arrays.sort(res);
        System.out.println(res[n - 1]);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 25784
#include<cstdio>
#include<vector>
#include<queue>
#include<iostream>
using namespace std;
int n; int INFTY = (1<<29);
int visited[100005], d[100005];
struct Edge
{
  int t, w;
};
vector<Edge> G[100005];

void bfs(int v)
{
  for(int i=0; i<n; i++)
  {
    visited[i] = 0; d[i] = INFTY;
  }
  queue<int> Q;
  Q.push(v);
  d[v] = 0;
  visited[v] = 1;
  while(!Q.empty())
  {
    int u = Q.front(); Q.pop();
    for(int i=0; i<G[u].size(); i++)
    {
      Edge e = G[u][i];
      if(visited[e.t] == 0)
      {
        Q.push(e.t);
        visited[e.t] = 1;
        if(d[e.t] > d[u] + e.w )
          d[e.t] = d[u] + e.w;
      }
    }
  }
}

void solve()
{
  bfs(0);
  int target; int maxv=0;
  for(int i=0; i<n; i++)
  {
    //if(d[i] == INFTY) continue;
    if(maxv < d[i])
    {
      maxv = d[i];
      target = i;
    }
  }
  bfs(target);
  maxv = 0;
  for(int i=0; i<n; i++)
  {
   // if(d[i] == INFTY) continue;
    if(maxv < d[i])
    {
      maxv = d[i];
    }
  }
  printf("%d\n", maxv);
}
int main()
{
  scanf("%d", &n);
  int s, t, w;
  for(int i=0; i<n-1; i++)
  {
    scanf("%d%d%d", &s, &t, &w);
    Edge es, et;
    es.t = t; es.w = w;
    et.t = s; et.w = w;
    G[s].push_back(es); G[t].push_back(et);
  }
  solve();

  return 0;
}



Measured memory_bytes: 10412
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	
	scanf("%d", &a);
	scanf("%d", &b);
	
	if (a > b){
		printf("a > b\n");
	}
	else if (a < b){
		printf("a < b\n");
	}
	else {
		printf("a == b\n");
	}
	
	return (0);
}

Measured memory_bytes: 580
module Weighted01DirectedGraph
  (* 頂点を添字，経路長を要素とした配列の実装 *)
  (Array : sig
    type t
    type key
    type elt = int (* 全ての重さが0か1なグラフなので経路長は非負整数 *)
    val get : t -> key -> elt
    val set : t -> key -> elt -> unit
  end)
: sig
  type vertex = Array.key

  val shortest_path :
    (* 全ての頂点についての経路長が無限大で初期化された配列 *)
    Array.t ->
    (* 最短経路を求めたいグラフの，ある頂点から伸びる辺に対してのイテレータ
       重みが0の辺に対してはf0を，1の辺に対してはf1を用いる *)
    (vertex -> f0:(vertex -> unit) -> f1:(vertex -> unit) -> unit) ->
    (* 始点 *)
    vertex ->
    (* 終点を受け取って，始点からの最短距離を返す関数
       始点から辿り着けない場合，無限大を返す
       この関数を覚えておけば，呼び出しごとの途中までの計算結果がシェアされる *)
    (vertex -> int)
end =
struct
  type vertex = Array.key

  let shortest_path d es s =
    (* 始点への経路長を0にする *)
    Array.set d s 0;
    let w = ref 1 in
    let q = ref [s] in
    let rec bfs t =
      match !q with
      (* もう既に全ての頂点までの経路が分かっているので返す *)
      | [] -> Array.get d t
      | us ->
          match Array.get d t with
          (* 既に終点までの距離が分かっているので返す *)
          | x when x < !w -> x
          (* 終点までの距離が分かっていないので，BFSを続行 *)
          | _ ->
              q := [];
              List.iter dfs us;
              incr w;
              bfs t
    and dfs u =
      es u
        ~f0:(fun v ->
          if !w <= Array.get d v then
            (Array.set d v (!w - 1); dfs v))
        ~f1:(fun v ->
          if !w < Array.get d v then
            (Array.set d v !w; q := v :: !q)) in
    bfs
end

module G = Weighted01DirectedGraph (struct
  type t = (int, Bigarray.int_elt, Bigarray.c_layout) Bigarray.Genarray.t
  type elt = int
  type key = int array
  let get = Bigarray.Genarray.get
  let set = Bigarray.Genarray.set
end)

let () = Scanf.scanf "%d %d\n%d %d\n%d %d\n" @@ fun h w ch cw dh dw ->
  let ss = Array.init h @@ fun _ -> Scanf.scanf "%s\n" @@ fun s -> s in
  let d =
    G.shortest_path
      (let d = Bigarray.Genarray.create Bigarray.int Bigarray.c_layout [| h; w |] in Bigarray.Genarray.fill d max_int; d)
      (fun [|i; j|] ~f0 ~f1 ->
        List.iter (fun (i', j') ->
          if 0 <= i' && i' < h && 0 <= j' && j' < w && ss.(i').[j'] = '.' then f0 [|i'; j'|])
        [(i - 1, j); (i + 1, j); (i, j - 1); (i, j + 1)];
        for i' = max 0 (i - 2) to min (h - 1) (i + 2) do
          for j' = max 0 (j - 2) to min (w - 1) (j + 2) do
            if ss.(i').[j'] = '.' then f1 [|i'; j'|]
          done
        done)
      [|ch - 1; cw - 1|]
      [|dh - 1; dw - 1|] in
  Printf.printf "%d\n" @@ if d = max_int then -1 else d



Measured memory_bytes: 16700
import sys

input = sys.stdin.readline

n, x= map(int, input().split())

a_list = list(map(int, input().split()))

count = 0
if a_list[0] > x:
    count += a_list[0] - x
    a_list[0] -= a_list[0] - x
for i in range(len(a_list)):
    if i+1 == len(a_list):
        break
    if a_list[i] + a_list[i+1] > x:
        count += a_list[i] + a_list[i+1] - x
        a_list[i+1] -= a_list[i] + a_list[i+1] - x
        

print(count)

Measured memory_bytes: 20008