akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
#define ERASE(a)  (a).erase(unique((a).begin(), (a).end()), (a).end()); // sortしてから
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    int d = n % 1000;
    int ans = 0;
    if (d != 0)
        ans = 1000 - d;
    cout << ans << endl;
}

Measured memory_bytes: 3628
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
d = A[-1]
count = 0
for i in range(1,N+1):
    if A[-i-1]<= (B[-i]-d):
        count += A[-i-1] + d
        d = 0
    elif d >=B[-i]:
        count += B[-i]
        d = A [-i-1]
    else:
        count += B[-i]
        d = A[-i-1]+ d - B[-i]
print(count)


Measured memory_bytes: 18624
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
#include <cstdio>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using P = pair<int,int>;
using TP = tuple<int,int,int>;

int main() {
    int h,w,ch,cw,dh,dw;
    scanf("%d %d %d %d %d %d",&h, &w,&ch,&cw,&dh,&dw);

    char s[h+1][w+1];
    for (int i=0; i<h; i++) {
        scanf("%s",s[i]);
    }

    vector num(h, vector(w,-1));

    const vector dx = {-1,0,+1,0};
    const vector dy = {0,+1,0,-1};

    priority_queue<TP, vector<TP>, greater<>> q;
    q.emplace(0, ch-1,cw-1);
    while(!q.empty()) {
        const auto [c,y,x] = q.top(); q.pop();
        if (x<0 || w<=x) continue;
        if (y<0 || h<=y) continue;
        if (s[y][x] == '#') continue;
        if (num[y][x]>=0 && num[y][x]<=c) continue;
        num[y][x] = c;


        for (short i=0; i<4; i++) {
            const int xi = x + dx[i];
            const int yi = y + dy[i];
            if (xi<0 || w<=xi) continue;
            if (yi<0 || h<=yi) continue;
            if (s[yi][xi] == '#') continue;
            q.emplace(c,yi,xi);
        }

        for (short i=-2; i <=2; i++) {
            const int yi = y + i;
            if (yi<0 || h<=yi) continue;
            for (short j=-2; j<=2; j++) {
                const int xi = x + j;
                if (xi<0 || w<=xi) continue;
                if (s[yi][xi] == '#') continue;
                if (num[yi][xi]>=0 && num[yi][xi]<=c) continue;
                q.emplace(c+1,yi, xi);
            }
        }
    }


    cout << num[dh-1][dw-1] << endl;
}


Measured memory_bytes: 9264
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int n,m;
  cin>>n>>m;
  Graph G(n);
  int h[n];
  rep(i,n){
    cin>>h[i];
  }
  rep(i,m){
    int a,b;
    cin>>a>>b;
    G[a-1].emplace_back(b-1);
    G[b-1].emplace_back(a-1);
  }
  int ans=0;
  rep(i,n){
    int x=1;
    for(auto itr=G[i].begin();itr!=G[i].end();++itr){
      if(h[i]<=h[*itr]){
        x=0;
      }
    }
    ans+=x;
  }
  cout<<ans;
}


Measured memory_bytes: 8800
<?php


fscanf(STDIN, "%d%d", $n, $m);

$pref = array_fill(1, $n, []);
$ans = [];
while($m--){
    fscanf(STDIN, "%d%d", $p, $c);
    $pref[$p][$c] = 0;
    $ans[] = [$p, $c];
}


foreach($pref as $p => $ps){
    ksort($ps);
    $j=1;
    foreach($ps as $city => $zero){
        $pref[$p][$city] = $j;
        $j++;
    }
}

foreach($ans as $data){
    printf("%06d%06d".PHP_EOL, $data[0], $pref[$data[0]][$data[1]]);
}




Measured memory_bytes: 127476
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();

		if (a.equals("H")){
			System.out.println(b);
		}else{
			if(b.equals("H")){
				System.out.println("D");
			}else{
				System.out.println("H");
			}
		}
	}

}


Measured memory_bytes: 21716
abc=list("abcdefghijklmnopqrstuvwxyz")
S=input()
T=input()

c1=[[] for i in abc]
c2=[[] for i in abc]
for i in range(0,len(S)):
    c1[ord(S[i])-ord("a")].append(i)

for i in range(0,len(T)):
    c2[ord(T[i])-ord("a")].append(i)

ans="Yes"
for i in c1:
    if(i not in c2):
        ans="No"
        break
    
print(ans)

Measured memory_bytes: 20528
lst = list(map(int, input().split()))
x_lst = []
y_lst = []
max_lst = []
for i in range(2):
  x_lst.append(lst[i])
  y_lst.append(lst[(i+1)*-1])
for j in range(len(x_lst)):
  for k in range(len(y_lst)):
    max_lst.append(x_lst[j] * y_lst[k])
print(max(max_lst))


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

typedef long long ll;

int main(){
  int N;
  cin >> N;
  ll mxans = 0;
  ll ans = 0;
  int minus_num = 0;
  ll abs_min = 10000000000;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
    if(A.at(i) < 0){
      minus_num++;
    }
  }
  
  for(int i=0; i<N; i++){
    abs_min = min(abs_min, (ll)abs(A.at(i)));
    mxans += abs(A.at(i));
  }
  
  if(minus_num % 2 ==0){
    ans = mxans;
  }
  else{
    ans = mxans - abs_min*2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n,a,i,cnt=0;
  int check[101];
  for(i=0;i<101;i++){
    check[i]=0;
  }
  
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    a=i;
    while(a%2==0){
      a=a/2;
      cnt++;
    }
    check[i]=cnt;
    cnt=0;
  }
  int maxcnt=0,maxnum=1;
  for(i=1;i<=n;i++){
    if(check[i]>maxcnt){
      maxcnt=check[i];
      maxnum=i;
    }
  }
  printf("%d",maxnum);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main()
{
	int a,b;
	scanf("%d\n%d",&a,&b);
	if(a==1&&b==2)
	   printf("3");
    if(a==2&&b==3)
    	printf("1\n");
    if(a==1&&b==3)
    	printf("2\n");
    if(a==2&&b==1)
	   printf("3");
    if(a==3&&b==2)
    	printf("1\n");
    if(a==3&&b==1)
    	printf("2\n");
    	
}



Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static Scanner cin = new Scanner();

    static void Main(string[] args) {
        int N = cin.Int();
        var A = cin.ArrayInt(N);
        var B = cin.ArrayInt(N);
        var C = cin.ArrayInt(N);

        Array.Sort(A);
        Array.Sort(C);

        long ans = 0;
        for (int i = 0; i < N; i++) {
            long p = upper_bound(A, B[i]);
            long q = lower_bound(C, B[i]);
            ans += p * (N - q);
        }

        Console.WriteLine(ans);
        Console.ReadLine();
    }

    static int lower_bound(int[] arr, int key) {
        int lo = 0;
        int hi = arr.Length - 1;
        while(lo <= hi) {
            int mid = (lo + hi) / 2;
            if (arr[mid] <= key) lo = mid + 1;
            else hi = mid - 1;
        }
        return lo;
    }

    static int upper_bound(int[] arr, int key) {
        int lo = 0;
        int hi = arr.Length - 1;
        while (lo <= hi) {
            int mid = (lo + hi) / 2;
            if (arr[mid] < key) lo = mid + 1;
            else hi = mid - 1;
        }
        return lo;
    }

}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 41300
#!/usr/bin/env python3
import sys


def solve(S: int):
    s = '{:04d}'.format(S)
    a, b = str(s)[:2], str(s)[2:]

    def judge(s):
        if s == '00' or int(s) > 12:
            return 'y'
        return 'ym'

    fa, fb = judge(a), judge(b)

    if fa == 'y' and fb == 'y':
        print('NA')
    elif fa == 'y' and fb == 'ym':
        print('YYMM')
    elif fa == 'ym' and fb == 'y':
        print('MMYY')
    elif fa == 'ym' and fb == 'ym':
        print('AMBIGUOUS')
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());
        var nums = Console.ReadLine().Split(' ');
        var min = int.MaxValue;
        var count = 0;

        foreach(var nStr in nums)
        {
            var n = int.Parse(nStr);
            if(n < min)
            {
                count++;
                min = n;
            }
        }
        Console.WriteLine(count);
        Console.ReadLine();
    }
}



Measured memory_bytes: 28124
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
double a,b,c,d,e,f;
double x,y;
while(cin >> a >> b >> c >> d >> e >> f){
  x = (double)((e*c-b*f) / (a*e-b*d));
  y = (double)((-(d*c)+a*f) / (a*e-b*d));
  if(x == 0){x = 0;}
  if(y == 0){y = 0;}
  printf("%.3f %.3f\n",x,y);
 }
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }
int main()
{
    int N, M, S, T;
    cin >> N >> M;
    using P = pair<int, int>;
    vector<P> edge;
    vector<vector<int>> g(N, vector<int>(N, 0));
    for (int i = 0, u, v; i < M; i++) { (cin >> u >> v), edge.push_back({u - 1, v - 1}), g[u - 1][v - 1] = g[v - 1][u - 1] = 1; }
    cin >> S >> T;
    S--, T--;
    vector<bool> used(N, false);
    auto dfs = fix([&](auto&& self, const int s, const int f) -> int {
        if (s == T) { return f; }
        used[s] = true;
        for (int i = 0; i < N; i++) {
            if (used[i] or g[s][i] == 0) { continue; }
            const int d = self(self, i, min(f, g[s][i]));
            if (d == 0) { continue; }
            return g[s][i] -= d, g[i][s] += d, d;
        }
        return 0;
    });
    int flow = 0;
    while (true) {
        fill(used.begin(), used.end(), false);
        const int f = dfs(S, 1 << 30);
        if (f == 0) { break; }
        flow += f;
    }
    cout << flow << endl;
    vector<int> ans;
    for (int i = 0; i < M; i++) {
        const int u = edge[i].first, v = edge[i].second;
        if (g[u][v] == 2) { ans.push_back(i); }
    }
    cout << ans.size() << endl;
    for (const int a : ans) { cout << a + 1 << endl; }
    return 0;
}



Measured memory_bytes: 3284
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main()
{
	int n;
	ll x;
	cin>>n>>x;
	
	ll a[100];
	for(int i=0; i<n; i++) cin>>a[i];
	sort(a, a+n);
	int ct=0;ll sum=0, x0=x;
	for(int i=0; i<n; i++){
      sum+=a[i];
		if(x>=a[i]){
			ct++;
			x-=a[i];
		}
	}
  if(ct==n){
    if(x0!=sum) ct--;
  }
	cout<<ct<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int x = n%10;
  if(x==2||x==4||x==5||x==7||x==9) cout << "hon" << "\n";
  else if(x==0||x==1||x==6||x==8) cout << "pon" << "\n";
  else cout << "bon" << "\n";
  return 0;
}

Measured memory_bytes: 3556
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define rep(i,s,n) for(ll (i)=(s);(i)<(n);(i)++)
#define repd(i,s,n) for(ll (i)=(n-1);(i)>=(s);(i)--)
#define all(x) x.begin(),x.end()
#define size(x) ((ll)(x).size()
#define PB push_back

int main(){
   long double r;
   cin >> r;
   cout << 2*M_PI*r  << endl;

   return 0;
}



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

struct trie{
	struct node{
		vector<int> nextNode;
		vector<int> v;
		node(){
			nextNode.resize(26,-1);
			v.resize(26,0);
		}
	};
	vector<node> nodes;
	
	trie(){
		nodes.push_back(node());
	}
	
	void add(string &S,char lastChar,int currentPos = 0,int currentNode=0){

		if(currentPos==S.size()){
			nodes[currentNode].v[encode(lastChar)]++;
			return;
		}
		
		int c = encode(S[currentPos]);
		if(nodes[currentNode].nextNode[c]==-1){
			nodes[currentNode].nextNode[c] = nodes.size();
			nodes.push_back(node());
		}
		
		int nextNode = nodes[currentNode].nextNode[c];
		add(S,lastChar,currentPos+1,nextNode);
		
		return;
	}
	
	int get_value(string &S,vector<int> &mask,int currentPos = 0,int currentNode=0){
		int ret = 0;
		for(int i=0;i<26;i++){
			if((mask[currentPos]>>i)&1){
				ret += nodes[currentNode].v[i];
			}
		}
		
		if(currentPos==S.size())return ret;
		
		int c = encode(S[currentPos]);
		if(nodes[currentNode].nextNode[c]==-1){
			return ret;
		}
		
		int nextNode = nodes[currentNode].nextNode[c];
		return ret + get_value(S,mask,currentPos+1,nextNode);
		
	}
	
	int encode(char c){
		return c-'a';
	}

	
};

int main(){
	
	int N;
	cin>>N;
	
	vector<string> S(N);
	for(int i=0;i<N;i++){
		cin>>S[i];
		reverse(S[i].begin(),S[i].end());
	}
	
	sort(S.begin(),S.end(),[&](string a,string b){
		return a.size()<b.size();
	});

	trie T;
	
	long long ans = 0LL;
	
	for(int i=0;i<N;i++){
		vector<int> mask(S[i].size()+1,0);
		for(int j=S[i].size()-1;j>=0;j--){
			mask[j] = mask[j+1] | (1<<(S[i][j]-'a'));
		}
		
		ans += T.get_value(S[i],mask);
		
		char c = S[i].back();
		S[i].pop_back();

		T.add(S[i],c);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 420756
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

ll modpow(ll a, ll b, ll m = mod) {
  ll r = 1;
  while (b > 0) {
    if (b & 1) r = (r * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return r;
}

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

  int n;
  cin >> n;
  string x;
  cin >> x;

  ll pcount = 0;
  for (int i = 0; i < n; i++) {
    if (x[i] == '1') pcount++;
  }

  vector<ll> ans(n);
  if (pcount == 0) {
    for (int i = 0; i < n; i++) ans[i] = 1;
  }
  else if (pcount == 1) {
    for (int i = 0; i < n; i++) {
      if (x[i] == '1') ans[i] = 0;
      else if (x[n-1] == '1' || i == n-1) ans[i] = 2;
      else ans[i] = 1;
    }
  }
  else {
    ll plus1 = 0;
    ll minus1 = 0;
    for (int i = 0; i < n; i++) {
      if (x[n-i-1] == '1') {
        plus1 = (plus1 + modpow(2, i, pcount+1)) % (pcount+1);
        minus1 = (minus1 + modpow(2, i, pcount-1)) % (pcount-1);
      }
    }
    for (int i = 0; i < n; i++) {
      ll v;
      if (x[i] == '0') v = (plus1 + modpow(2, n-i-1, pcount+1)) % (pcount+1);
      else {
        v = (minus1 - modpow(2, n-i-1, pcount-1)) % (pcount-1);
        if (v < 0) v += pcount-1;
      }
      ans[i] = 1;
      //cerr << i << " " << ans[i] << " " << v << endl;
      while (v > 0) {
        ll ppcount = 0;
        ll vt = v;
        while (vt > 0) {
          if (vt & 1) ppcount++;
          vt >>= 1;
        }
        v = v % ppcount;
        ans[i]++;
        //cerr << i << " " << ans[i] << " " << v << endl;
      }
    }
  }

  for (int i = 0; i < n; i++) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 5152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int ans = b/a;
		if (ans < c) {
			System.out.println(ans);
		} else {
			System.out.println(c);
		}
	}
}


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


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;



int main()
{
    SAM;
    int x;
    cin>>x;
    if(x>=400 && x<=599)
        cout<<"8";
    else if(x>599 && x<=799)
        cout<<"7";
    else if(x>799 && x<=999)
        cout<<"6";
    else if(x>999 && x<=1199)
        cout<<"5";
    else if(x>1199 && x<=1399)
        cout<<"4";
    else if(x>1399 && x<=1599)
        cout<<"3";
    else if(x>1599 && x<=1799)
        cout<<"2";
    else if(x>1799 && x<=1999)
        cout<<"1";
    
    return 0;
}




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

int main() {
    int a, b, ans;
    string calcSing;
    cin >> a >> calcSing >> b;
    if(calcSing == "+"){
        ans = a + b;
    }else if(calcSing == "-"){
        ans = a - b;
    }
    cout << (ans) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n), b(n);
    int sum = 0;
    int now = 0;
    rep(i, 0, n){
        cin >> a[i] >> b[i];
        sum += b[i];
        now |= a[i];
    }
    bool f[114514] = {};
    int ans = 0;
    if(now <= k) ans = sum;
    bool st = false;
    repb(i, 31, 0){
        if(k & (1LL << i)){
            st = true;
            int tmp = 0;
            rep(j, 0, n){
                if(f[j] == false && a[j] & (1LL << i)){
                    tmp += b[j];
                }
            }
            chmax(ans, sum - tmp);
        }else{
            rep(j, 0, n){
                if(f[j] == false && a[j] & (1LL << i)){
                    // cout << i << " " << a[j] << endl;
                    sum -= b[j];
                    f[j] = true;
                }
            }
            // chmax(ans, sum);
        }
    }
    chmax(ans, sum);
    cout << ans << endl;
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        System.out.println(B+C-A > 0? B+C-A : 0);
        
    }
}


Measured memory_bytes: 22996
a = list(map(int, input().split()))
a.sort()

ans = 0

while a[2] > a[1]:
    a[0] += 1
    a[1] += 1
    ans += 1

if a[2] % 2 != a[0] % 2:
    ans += 1
    a[1] += 1
    a[2] += 1

ans += (a[2] - a[0]) // 2
print(ans)


Measured memory_bytes: 3060
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
    
n=int(input())
ans=0

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=gcd(i,j,k)

print(ans)

Measured memory_bytes: 69852
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    using ii = pair<int, i64>;
    using vii = vector<ii>;
    vector<vii> adj(n);
    for (int i = 0; i < n - 1; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        adj[s].push_back(ii(t, w));
        adj[t].push_back(ii(s, w));
    }

    vi dist(n, 1e18);
    dist[0] = 0;
    function<void(int s)> dfs = [&](int s) {
        for (ii& v: adj[s]) {
            if (v.second + dist[s] < dist[v.first]) {
                dist[v.first] = v.second + dist[s];
                dfs(v.first);
            }
        }
    };

    dfs(0);
    
    i64 ma = -1;
    int mai = -1;
    for (int i = 0; i < n; i++) {
        if (dist[i] > ma) {
            ma = dist[i];
            mai = i;
        }
    }

    dist = vi(n, 1e18);
    dist[mai] = 0;
    dfs(mai);
    ma = -1;
    for (int i = 0; i < n; i++) {
        ma = max(ma, dist[i]);
    }
    cout << ma << endl;
}


Measured memory_bytes: 17552
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...)                                                             \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    i64 c[maxn];
    i64 n, p;
    string s;
    void solve() {
        cin >> n >> p >> s;
        i64 a = 0, ans = 0, deg = 1;
        c[0] = 1;
        for (int i = 0; i < n; ++i) {
            a = (a * 10 + s[i] - '0') % p;
            if (deg == 0) {
                if (a == 0)
                    ans += i + 1;
            } else {
                ans += c[a * pw(deg, p - 2) % p];
                c[a * pw(deg, p - 2) % p]++;
            }
            deg = deg * 10 % p;
        }
        cout << ans << '\n';
    }
    i64 pw(i64 a, i64 b) {
        i64 res = 1;
        while (b) {
            if (b & 1ll)
                res = res * a % p;
            a = a * a % p;
            b >>= 1;
        }
        return res;
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 720
#include <iostream>

#define SIZE 3

using namespace std;

int main() {
	float x[SIZE], y[SIZE], xp, yp, a, b, c;

	while (cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>xp>>yp) {
		a = (xp - x[0]) * (yp - y[1]) - (yp - y[0]) * (xp - x[1]);
		b = (xp - x[1]) * (yp - y[2]) - (yp - y[1]) * (xp - x[2]);
		c = (xp - x[2]) * (yp - y[0]) - (yp - y[2]) * (xp - x[0]);

		if ((a > 0 && b > 0 && c > 0) || (a < 0 && b < 0 && c < 0)) {
			cout << "YES";
		}
		else {
			cout << "NO";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define ld double
#define P pair<ll,ll>
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int n,a[200005];
ll s[200005],ans=1e18;
P search(int L,int R){
	int mid,l=L,r=R;
	while(l<r){
		mid=l+r>>1;
		if(s[R]-s[mid]*2+s[L-1]>0)l=mid+1;
		else r=mid-1;
	}
	ll res=1e18,a,b;
	for(int i=l-1;i<=l+1;++i){
		if(i==0||i==n)continue;
		if(abs(s[R]-s[i]*2+s[L-1])<res)res=abs(s[R]-s[i]*2+s[L-1]),a=s[R]-s[i],b=s[i]-s[L-1];
	}
	return make_pair(a,b);
}
int main(){
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i<=n;++i)s[i]=s[i-1]+a[i];
	for(int i=2;i<n;++i){
		P l=search(1,i),r=search(i+1,n);
		ll Min=min(min(l.first,l.second),min(r.first,r.second)),
		   Max=max(max(l.first,l.second),max(r.first,r.second));
		ans=min(Max-Min,ans);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
const int maxn = 10009;
int n,m,ans;
int a[maxn];
int main()
{
	cin>>n;
	cout<<"Christmas";
	if (n == 24) cout<<" Eve";
	if (n == 23) cout<<" Eve Eve";
	if (n == 22) cout<<" Eve Eve Eve";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int a, b, c; cin >> a >> b >> c;

    if (b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if(b%a)cout<<b-a<<endl;
	else cout<<a+b<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		StringBuilder sb = new StringBuilder();
		sb.append(s.charAt(0));
		sb.append(s.length()-2);
		sb.append(s.charAt(s.length()-1));
		System.out.print(new String(sb));
		sc.close();
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 1005
#define NUM 2010

int H,W;
int table[2][SIZE][SIZE];
int in_num[SIZE];

int V;
vector<int> G[NUM];
int match[NUM];
bool used[NUM];

void add_edge(int from,int to){
	G[from].push_back(to);
	G[to].push_back(from);
}

int dfs(int node_id){
	used[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		int adj_node_id = G[node_id][i],pair_id = match[adj_node_id];
		if((pair_id < 0)||
				(used[pair_id] == false && dfs(pair_id) == true)){

			match[node_id] = adj_node_id;
			match[adj_node_id] = node_id;
			return true;
		}
	}
	return false;
}


int bipartie_matching(){
	int ret = 0;
	for(int i = 0; i < V; i++)match[i] = -1;
	for(int node_id = 0; node_id < V; node_id++){
		if(match[node_id] < 0){
			for(int i = 0; i < V; i++)used[i] = false;
			if(dfs(node_id)){
				ret++;
			}
		}
	}
	return ret;
}


int main(){

	scanf("%d %d",&H,&W);

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){

			scanf("%d",&table[0][row][col]);
			table[1][col][row] = table[0][row][col];
		}
	}

	bool FLG;

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

		if(H == 1){
			swap(H,W);
			continue;
		}

		V = 2*H;

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

			in_num[i] = 0;
		}

		for(int a = 0; a < H; a++){
			for(int b = 0; b < H; b++){
				if(b == a)continue;

				FLG = true;
				for(int k = 0; k < W; k++){
					if(table[i][a][k] < table[i][b][k]){

						FLG = false;
						break;
					}
				}
				if(!FLG)continue;

				add_edge(a,b+H);
				in_num[b]++;
			}
		}

		int count = 0;
		for(int i = 0; i < H; i++){

			if(in_num[i] > 0)count++;
		}
		if(count != H-1){

			printf("NO\n");
			return 0;
		}

		int num_match = bipartie_matching();

		//printf("i:%d num_match:%d\n",i,num_match);

		if(H-num_match > 2){

			printf("NO\n");
			return 0;
		}

		for(int a = 0; a < V; a++){

			G[a].clear();
		}

		swap(H,W);
	}

	printf("YES\n");

	return 0;
}



Measured memory_bytes: 18240
#pragma GCC optimize (2)
    #pragma G++ optimize (2)
    #include<bits/stdc++.h>
    #define INF 0x3f3f3f3f
    #define MAX 100005
    using namespace std;
    //char nc()
    //{
    //	static char buf[100000],*p1=buf,*p2=buf;
    //	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
    //}
    char nc(){return getchar();}
    int read()
    {
    	int x=0,y=1;
    	char c=nc();
    	while(!isdigit(c))
    	{
    		if(c=='-')y=-1;
    		c=nc();
    	}
    	while(isdigit(c))
    	{
    		x=(x<<1)+(x<<3)+(c^48);
    		c=nc();
    	}
    	return x*y;
    }
    int n;
    int main()
    {
    	n=read();
    	if(n==(n&(-n))) puts("No");
    	else
    	{
    		puts("Yes");
    		printf("1 2\n2 3\n3 %d\n%d %d\n%d %d\n",n+1,n+1,n+2,n+2,n+3);
    		for(int i=4;i+1<=n;i+=2)
    			printf("%d %d\n%d %d\n%d %d\n%d %d\n",n+1,i,i,i+1,n+1,n+i+1,n+i+1,n+i);
    		if(!(n&1))
    		{
    			for(int i=20;i>=0;i--)
    				if((1<<i)<n)
    				{
    					if(n-(1<<i)+1==3) printf("%d %d\n%d 3",n,1<<i,n*2);
    					else printf("%d %d\n%d %d",n,1<<i,n*2,n*2-(1<<i)+1);
    					break;
    				}
    		}
    	}
    	return 0;
    }

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, k, a[105];
ll dp[105][100010];

ll mod(ll a) {
    if (a > 0) return a % MOD;
    return (a + MOD) % MOD;
}

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

    rep(i, n+1) dp[i][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            dp[i][j] = mod(dp[i][j-1] + dp[i-1][j]);
            if (j - a[i-1] - 1 >= 0) {
                dp[i][j] = mod(dp[i][j] - dp[i-1][j-a[i-1]-1]);
            }
        }
    }
    cout << dp[n][k] << endl;
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b;
  int x[3]={0};
  cin>>a>>b;
  x[a-1]=1;
  x[b-1]=1;
  rep(i,3){
    if(x[i]==0) cout<<i+1<<endl;
  }
  
	  
  return 0;
}


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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int MAXN = 100;
//#define int long long
const int INF = 1e9;

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

	int n;
  cin >> n;
  int cc = (n + 999) / 1000;
  cout << (cc * 1000) - n << '\n';

    return 0;
}


Measured memory_bytes: 3604
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let x = read_vec::<i64>();
    let l = read::<i64>();
    let mut queries = vec![];
    let q = read::<usize>();
    for _ in 0..q {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        queries.push((min(a, b), max(a, b)));
    }
    let max_log_n = 18;
    let mut next = vec![vec![0; n]; max_log_n];
    next[0][n - 1] = n - 1;
    for i in 0..n - 1 {
        next[0][i] = x.upper_bound(&(x[i] + l)) - 1;
    }
    for ni in 1..max_log_n {
        next[ni][n - 1] = n - 1;
        for j in 0..n - 1 {
            next[ni][j] = next[ni - 1][next[ni - 1][j]];
        }
    }

    for (mut a, b) in queries {
        let mut ans = 0;
        for ni in (0..max_log_n).rev() {
            if next[ni][a] < b {
                a = next[ni][a];
                ans += 1 << ni;
            }
        }
        while a < b {
            a = next[0][a];
            ans += 1;
        }
        assert!(a >= b);
        println!("{}", ans);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
use std::cmp::Ordering;

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}


Measured memory_bytes: 27260
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int main(){
	int a,b;scanf("%d%d",&a,&b);
	long long ret=0;
	init_C(210000);
	for(int i=0;i<=min(a-1,b);i++){
		ret+=Comb(a,i)*Comb(a-1,i)%mod;
	}
	ret%=mod;
	printf("%lld\n",ret);
}

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

int main(){
  ll n,t;
  cin >> n >> t;
  vector<ll> a(n+10);
  vector<ll> b(n+10);
  rep(i,n) cin >> a[i];
  rep(i,n) b[i] = a[i] + t;
  ll ans;
  ans = b[n] - a[1];
  rep(i,n-1){
    if(a[i+1] > b[i]){
      ans -= a[i+1] - b[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

    ll a,b,c;
    cin>>a>>b>>c;

    ll l=4*a*b;
    if(c-a-b<=0){cout<<"No";return(0);}
    ll r=(c-a-b)*(c-a-b);
    if(l<r){cout<<"Yes";}
    else{cout<<"No";}

	return(0);
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc056/tasks/arc070_a
X = read_a_int()
s = 0
for i in range(X + 1):
    s += i
    # print(i, s)
    if s >= X:
        break
print(i)


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

#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000009
#define ll long long
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

int n,k,x,ans;

int main()
{
	cin >> n >> k;
	for(int i = 1;i <= n;i++){
		cin >> x;
		if(x >= k) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    const int sin90 = sin(acos(-1) / 2);
    const int cos90 = cos(acos(-1) / 2);
    const int sinm90 = sin(-acos(-1) / 2);
    const int cosm90 = cos(-acos(-1) / 2);

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    VI ans;
    {
        const auto xd = x1 - x2;
        const auto yd = y1 - y2;
        ans.emplace_back(xd * cosm90 - yd * sinm90 + x2);
        ans.emplace_back(xd * sinm90 + yd * cosm90 + y2);
    }
    {
        const auto xd = x2 - x1;
        const auto yd = y2 - y1;
        ans.emplace_back(xd * cos90 - yd * sin90 + x1);
        ans.emplace_back(xd * sin90 + yd * cos90 + y1);
    }
    for (auto e : ans) {
        printf("%d ", e);
    }
    puts("");
}


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

int main(){
  int D;
  cin >> D;
  
  if(D==25){
    cout << "Christmas" << endl;
  }
  else if(D==24){
    cout << "Christmas Eve" << endl;
  }
  else if(D==23){
    cout << "Christmas Eve Eve" << endl;
  }
  else{
    cout << "Christmas Eve Eve Eve" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int m = -1;
    int ans = 0;
    rep(i, n)
    {
        int t;
        cin >> t;
        if (t >= m)
        {
            ans++;
            m = t;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
k, a, b = [int(i) for i in input().split()]

sum = 0
if a >= b:
    # A >= Bの場合
    # a,bに１施行ずつ使い、それ以外は叩く、という選択
    sum = k + 1
else:
    # A < B の場合
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    elif diff >= 3:
        # a->bコンボが利潤を生み続けるパターン
        rest = 1 + k - a
#         print("K:{}".format(rest))
        if rest >= 0:
            if rest % 2 == 0:
                sum = a + ((diff) * int(rest / 2))
#                 print("biscuits:{}".format(a))
#                 print("diff:{}, k/2:{}".format(diff, rest / 2))
            else:
                # 最後1回はコンボができないので、叩くパターン
                sum = a + ((diff) * int((rest - 1) / 2)) + 1
#                 print("biscuits:{}".format(a))
#                 print("diff:{}, k/2:{}".format(diff, (rest - 1) / 2))
        else:
            sum = k + 1
                
print(int(sum))


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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < 50001; i++) {
      int x = i*1.08;
      if(N==x) {
          cout << i << endl;
          break;
      }
      else if(N<x) {
          cout << ":(" << endl;
          break;
      }
  }
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
    	//int M = sc.nextInt();
      	if(N<1200){
        	System.out.println("ABC");
        }else if(N<2800){
        	System.out.println("ARC");
        }else{
        	System.out.println("AGC");
        }
    }
}

Measured memory_bytes: 21844