akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009
vi a;
ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
ll n;
ll solve(ll aa,ll bb)
{
	ll ans=0;
	ll haha=aa-bb;
	auto it=upper_bound(all(a),haha);
	ll ind=it-a.begin();

	haha*=-1;
	auto it1=upper_bound(all(a),haha);
	ll ind1=it1-a.begin();
	
	ll ind2=max(ind,ind1);
	haha=aa+bb;
	ll low=0,high=n-1;
	ll ind3=-1;
	while(low<=high)
	{
		ll mid=(low+high)/2;
		if(a[mid]<haha)
		{
			ind3=mid;
			low=mid+1;
		}
		else
		high=mid-1;
	}
	//test4(aa,bb,ind2,ind3);
	if(ind2==n || ind3==-1)
	return 0;
	if(ind3<ind2)
	return 0;

	ans=ind3-ind2+1;
	if((aa-bb)<aa && (bb-aa)<aa && aa<(aa+bb))
	ans--;
	if((aa-bb)<bb && (bb-aa)<bb && bb<(aa+bb))
	ans--;
	//test2("ans",ans);
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        cin>>n;
	rep(i,0,n)
	{
		ll x;cin>>x;
		a.pb(x);
	}
	sort(all(a));

	ll ans=0;
	rep(i,0,n)
	{
		rep(j,i+1,n)
		{
			if(i==j)
			continue;
			ans+=solve(a[i],a[j]);
		
		}
	}
	cout<<ans/3<<endl;
}

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

int main(void)
{
	int n;
	std::cin >> n;

	std::vector<int> v(3 * n);

	for (int i = 0; i < 3 * n; i++) {
		std::cin >> v[i];
	}

	std::sort(v.begin(), v.end());

	long long ans = 0;
	for (int i = 0; i < n;i++){
		ans += v[v.size() - i * 2 - 2];
	}

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

Measured memory_bytes: 1408
n, k = gets.split.map(&:to_i)
hash = Hash.new { 0 }
a = gets.split.map(&:to_i).first(n)
a.each { |i| hash[i] += 1 }


count = 0
balls = hash.values.sort
while balls.size > k do
  count += balls.shift
end

puts count


Measured memory_bytes: 32880
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

main(){
  int n,t,s=0,f1,f2;
  cin>>n>>t;
  cin>>f1;
  for(int i=0;i<n-1;i++){
    cin>>f2;
    s +=min(t,f2-f1);
    f1 = f2;
  }
  cout<<s+t<<endl;
  return 0;
}

Measured memory_bytes: 256
(let ((a (read))
      (b (read))
      (c (read))
      (x (read))
      (sum 0))
  (loop for i below (+ a 1)
        do (loop for j below (+ b 1)
                 do (loop for k below (+ c 1)
                          if (equal (+ (* i 500) (* j 100) (* k 50)) x) do (setf sum (+ sum 1)))))
  (format t "~A~%" sum))


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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  int ave;
  ave = (a + b) / 2;
  
  int even;
  even = (a + b) % 2;
  
  if (even != 0){
    
    ave = ave + 1;
    
  }
  
  cout << ave << endl;
  
 }

Measured memory_bytes: 3572
def water(current_flower):
    start_index = 0
    end_index = N
    catch_flag = False
    for n in range(N):
        if(catch_flag == False and current_flower[n] != 0):
            catch_flag = True
            start_index = n
        if(catch_flag == True and current_flower[n] == 0):
            end_index = n
            break
    for n in range(start_index, end_index):
        current_flower[n] = current_flower[n] - 1
    return current_flower

N = int(input().strip())
h_list = list(map(int, input().strip().split()))

current_flower = list(h_list)
water_count = 0
while(sum(current_flower) != 0):
    current_flower = water(current_flower)
    water_count += 1
print(water_count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
int main(void)
{
    double x1,y1,x2,y2;
    double x,y;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    x = x2 - x1;
    y = y2 - y1;
    
    printf("%lf\n",sqrt(x*x+y*y));
    return 0;
}



Measured memory_bytes: 2104
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[n];
        int[] check = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int res = 0;

        while (!Arrays.equals(arr, check)) {
            int l = 0;
            int min = Integer.MAX_VALUE;
            while (l < n && arr[l] == 0) {
                l++;
            }
            int cp = l;
            while (l < n && arr[l] != 0) {
                min = Math.min(min, arr[l]);
                l++;
//                System.out.println(min);
            }
            for (int i=cp; i<l; i++) {
                arr[i] -= min;
//                System.out.println(cp);
            }
            res += min;

        }


        System.out.println(res);

    }


}



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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n,k;
    cin>>n>>k;
    ll rr,ss,pp;
    cin>>rr>>ss>>pp;
    string sa;
    cin>>sa;
    string s=sa;
    ll rcnt=0,pcnt=0,scnt=0;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='r'){
            ll x=i-k;
            if(x>=0&&s[x]=='r'){
                s[i]='0';
            }
            else rcnt++;
        }
    }
    s=sa;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='s'){
            ll x=i-k;
            if(x>=0&&s[x]=='s'){
                s[i]='0';
            }
            else scnt++;
        }
    }
    s=sa;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='p'){
            ll x=i-k;
            if(x>=0&&s[x]=='p'){
                s[i]='0';
            }
            else pcnt++;
        }
    }
    cout<<(rcnt*pp)+(pcnt*ss)+(scnt*rr)<<endl;
    return 0;
}



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

#define ULL unsigned long long

const int MOD = 1e9 + 7;

ULL N, K;
ULL all_sum;
ULL answer = 0;

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

  cin >> N >> K;

  all_sum = ((N * (N + 1)) / 2);
  for(ULL take = K; take <= N; take++) {
    ULL greatest = all_sum - (((N - take) * (N - take + 1)) / 2);
    ULL smallest = (take * (take - 1)) / 2;
    answer += greatest - smallest + 1;
    answer %= MOD;
  }
  answer++;

  cout << answer % MOD << "\n";

  return 0;
}

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

int main()
{
	char S[101] = {};
	char T[101] = {};
	char mem;
	int i, cnt = 99;

	scanf(" %s %s", S, T);

	while(cnt)
    {
        mem = S[0];
        for(i = 0; i < sizeof(S)-1; i++)
        {
            if(S[i+1] == '\0')break;
            S[i] = S[i+1];
        }
        S[i] = mem;

        if(strcmp(S, T) == 0)
        {
            printf("Yes\n");
            break;
        }

        cnt--;

        if(S != T && cnt == 0)
        {
            printf("No\n");
        }
    }

  	return 0;

}



Measured memory_bytes: 128
import sys
p = [r for r in sys.stdin.read().split('\n') if r != '']
n = int(p[0])
s = p[1:]
for i, r in enumerate(s):
    t = list(r)
    t.sort()
    s[i] = ''.join(t)
d = {}
for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 0
count = 0
for k, v in d.items():
    count += int((v + 1) * v / 2)
print(count)

Measured memory_bytes: 28040
words = {"dream": "A", "dreamer": "A", "erase": "A", "eraser": "A"}
 
ans = []
 
inputs = str(input())
 
inputs = inputs.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")

if len(list(inputs)) > 0:
  print("NO")
else:
  print("YES")

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-

n = int(input())

a = []
for i in range(n):
    a.append(int(input()))

note = [0] * n
i = 0
step = 0
ret = -1
while True:
    if note[i] == 1:
        break
    if i == 1:
        ret = step
        break
    note[i] = 1
    i = a[i] - 1
    step += 1


print(ret)

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

int main() {
  long n, l[2];
  cin >> n; if (n == 1) { puts("1"); return 0; }
  l[0] = 2; l[1] = 1;
  for (int i = 2; i <= n; i++)
    l[i%2] = l[i%2]+l[(i-1)%2];
  cout << max(l[0], l[1]) << endl;
}

Measured memory_bytes: 256
import collections

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=[[0,10**18] for _ in range(n+1)]
q=collections.deque()
q.append((1,0))
check=[0]*(n+1)
check[1]=1
while len(q)!=0:
  v,d=q.popleft()
  for u in g[v]:
    if ans[u][1]>d:
      ans[u][0]=v
      ans[u][1]=d
    if check[u]==0:
      check[u]=1
      q.append((u,d+1))
print('Yes')
for i in range(2,n+1):
  print(ans[i][0])

Measured memory_bytes: 106132
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
	int n;	cin>>n;
	vector<int> x(n);
	vector<int> dif(n-1);
	for(int i=0;i<n;i++)	cin>>x[i];
	for(int i=0;i<n-1;i++)	dif[i]=x[i+1]-x[i];
	ll m,k;	cin>>m>>k;
	vector<int> pos(n-1);
	for(int i=0;i<n-1;i++)	pos[i]=i;
	for(int i=0;i<m;i++){
		int a;	cin>>a;	a--;
		swap(pos[a-1],pos[a]);
	}
	for(ll i=1;i<=k;i<<=1){
		if(k&i){
			vector<int> nextdif(n-1);
			for(int j=0;j<n-1;j++)	nextdif[j]=dif[pos[j]];
			dif=nextdif;
		}
		vector<int> nextpos(n-1);
		for(int j=0;j<n-1;j++)	nextpos[j]=pos[pos[j]];
		pos=nextpos;
	}
	ll ret=x[0];
	for(int i=0;i<n-1;i++){
		cout<<ret<<endl;
		ret+=dif[i];
	}
	cout<<ret<<endl;
	return 0;
}


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

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 998244353;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] ad;
	static int n, s;
	static int[][][] memo;
	static int[] a;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
	    int n=sc.nextInt();
	    int m=sc.nextInt();
	    int sum=0;
	    int []a=new int [n];
	    for(int i=0;i<n;i++)
	    	sum+=a[i]=sc.nextInt();
	    int t=sum/(4*m);
	    if(sum%(4*m)!=0)
	    	t++;
	    int y=0;
	    for(int i=0;i<n;i++)
	    	if(a[i]>=t)
	    		y++;
	    if(y>=m)
	    	System.out.println("Yes");
	    else
	    	System.out.println("No");
		out.close();
	}

	static class pair {
		int id;
		int v;

		public pair(int i, int vi) {
			id = i;
			v = vi;
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
map <string, int> cnt;
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int n;
 	string s;
 	cin >> n;
 	for(int i=1; i<=n; i++)
 	{
 		cin >> s;
 		sort(all(s));
 		cnt[s]++;
 	}
 	ll ans = 0;
 	for(auto it : cnt) ans += 1ll*it.second*(it.second-1);
 	cout << ans/2;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> D(0);
  for(int i=0;i<N;i++){
    int d,j=0;
    cin >> d;
    for(;j<D.size();j++)
      if(D.at(j)==d)
        break;
    if(j==D.size())
      D.push_back(d);
  }
  cout << D.size() << endl;
}

Measured memory_bytes: 256
//Kaori Miyazono, did I reach you ?
//"I can't die because... I'm the one who will protect you." -Asuna Yuuki
 
#include <bits/stdc++.h>
using namespace std;

const int N = 200200;

int n;
int nums[N];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> nums[i];
	int l = 0, r = 0;
	long long int ans = 0;
	long long int x = 0, s = 0;
	while(l < n) {
		while(r < n && (x ^ nums[r]) == s + nums[r]) {
			x ^= nums[r];
			s += nums[r];
			r++;
		}
		//cout << l << ' ' << r << '\n';
		ans += r - l;
		x ^= nums[l];
		s -= nums[l];
		l++;
		r = max(r, l);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

float A, B;
int A_top, A_bottom, B_top, B_bottom;

int main()
{
	cin >> A >> B;

	A_top    = floor((A + 1) * 100 / 8 - 0.001);
	A_bottom = ceil(A * 100 / 8);
	B_top    = (B + 1) * 10 - 1;
	B_bottom = B * 10;

	int p = max(A_bottom, B_bottom);
	int q = min(A_top, B_top);

	if (p <= q)
	{
		cout << p << endl;
	}
	else
	{
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int r;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> r;
	if(r < 1200) cout << "ABC\n";
	else if(r < 2800) cout << "ARC\n";
	else cout << "AGC\n";
	return 0;
}

Measured memory_bytes: 256
// SEE: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_D

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

#define SENTINEL 1000000001

long long count = 0;

void trace(int a[], int size) {
    for (int i = 0; i < size; ++i) {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", a[i]);
    }
    printf("\n");
}

void Merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1], R[n2+1];
    for (int i = 0; i < n1; ++i) {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; ++i) {
        R[i] = A[mid + i];
    }
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    int m = 0;
    int n = 0;
    for (int i = left; i < right; ++i) {
        if (L[m] <= R[n]) {
            A[i] = L[m];
            ++m;
        }
        else {
            A[i] = R[n];
            ++n;
            count += n1 - m;
        }
    }
}

void MergeSort(int A[], int left, int right) {
    if (left >= right - 1) return;
    int mid = (left + right) / 2;
    MergeSort(A, left, mid);
    MergeSort(A, mid, right);
    Merge(A, left, mid, right);
}

int main() {
    int N;
    int A[200000];

    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    MergeSort(A, 0, N);
    printf("%lld\n", count);
    return 0;
}

Measured memory_bytes: 4148
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  int m = n, cnt = 0;
  while(m){
    cnt += m%10;
    m /= 10;
  }

  if(n%cnt) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();
            int count = 0;
            for (int i = 0; i < S.length() / 2; i++) {
                if (S.charAt(i) != S.charAt(S.length() - 1 - i)) {
                    count++;
                }
            }
            out.println(count);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
 
using namespace std;
 
#define all(x) x.begin(), x.end()
 
typedef long long ll;
typedef long double ld;
 
const int N = 123456;
const int M = 1234567;
 
int a[2222], b[2222];
ll bst[1111], c[2222];
bool has_a_cycle[1111];
 
int main(int argc, char const *argv[])
{
	
	#ifdef Cyborg101
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
 
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 
	int n, m;
	cin >> n >> m;
 
	for(int i = 0; i < m; ++i){
		cin >> a[i] >> b[i] >> c[i];
		// c[i] = -c[i];
	}
 
	//const ll inf = 1e18;
	#define inf (1ll << 63)
 
 
	for(int i = 1; i <= n; ++i)
		bst[i] = inf;
 
	bst[1] = 0;
 
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
 
			if(bst[a[j]] == inf) continue;
 
			if(bst[a[j]] + c[j] > bst[b[j]])
				bst[b[j]] = bst[a[j]] + c[j];
		}
	}
 
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
 
			if(bst[a[j]] == inf) continue;
 
			if(bst[a[j]] + c[j] > bst[b[j]]){
				bst[b[j]] = bst[a[j]] + c[j];		
				has_a_cycle[b[j]] = true;
			}
 
			if(has_a_cycle[a[j]])
				has_a_cycle[b[j]] = true;
		}
	}
 
	if(has_a_cycle[n])
		cout << "inf" << endl;
	else
		cout << bst[n] << endl;
 
	return 0;				
}

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

long long N;

int main() {
    cin >> N;
    vector<long long> A(5);
    for (int i = 0; i < 5; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    if (N % A[0] == 0) {
        cout << 4 + N / A[0] << endl;
        return 0;
    }
    cout << 5 +  N / A[0] << endl;
}




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

int N, M;

typedef vector<vector<char>> Map;
Map map;

struct Point{
    int i, j;
};

int bfs(Point& s, Point& t) {
    queue<pair<Point, int>> que;

    vector<vector<bool>> visited(N+2, vector<bool>(M+2));
    que.push(make_pair(s, 0));
    visited[s.i][s.j] = true; 

    while(!que.empty()) {
        auto item = que.front();
        que.pop();
        Point& p = item.first;
        for (int dir = 0 ; dir < 4; dir++) {
            int x = p.i+"0211"[dir]-'1';
            int y = p.j+"1120"[dir]-'1';
            if (x == t.i && y == t.j)
                return item.second+1;
            else if (map[x][y] == '.' && !visited[x][y]){
                visited[x][y] = true;
                que.push(make_pair(Point{x,y}, item.second+1));
            }

        }
    }
    return INT_MAX;
}

int main(){

    cin >> N >> M;

    map = Map(N+2, vector<char>(M+2, '#'));

    for (int i = 1; i <= N; i++)
        for (int j = 1; j <= M; j++) {
            cin >> map[i][j];
        }

    int maximum = INT_MIN;
    for (int i = 1; i <= N; i++)
        for (int j = 1; j <= M; j++)
            for (int i2 = 1; i2 <= N; i2++)
                for (int j2 = 1; j2 <= M; j2++) {
                    
                    if ((i != i2 || j != j2) && map[i][j] == '.' && map[i2][j2] == '.'){
                        Point s{i, j};
                        Point t{i2, j2};
                        
                        maximum = max(maximum, bfs(s, t));
                    }
                }

    cout << maximum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include<time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

int numdigits(ll n){
	int ret=0;
	while(n){
		n/=10;
		ret++;
	}
	return ret;
}

bool lower(ll pos,ll num,ll &cnt){
	cnt=0;

	int dg=numdigits(num);
	REP(i,dg-1){
		cnt+=pow(10LL,i)*(i+1)*9;
	}

	cnt+=(num-(pow(10LL,dg-1)-1))*dg;

	return pos<=cnt;
}

int main(){
	ll n,k;
	while(cin>>n>>k,n|k){
		int lb=-1,ub=1<<30;
		while(ub-lb>1){
			int mid=(lb+ub)/2;
			ll cnt;
			if(lower(n,mid,cnt)){
				ub=mid;
			}else{
				lb=mid;
			}
		}

		ll cnt;
		lower(n,ub,cnt);

		ostringstream oss;
		REP(i,100){
			oss<<ub+i;
		}
		string s=oss.str();
		REP(i,k){
			cout<<s[numdigits(ub)-1-(cnt-n)+i];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1264
data class Relate(val x: Int, val y: Int)

fun main(args: Array<String>) {
    val (n, k) = readIntegerList()
    val aList = readIntegerList()

    var ans = Long.MAX_VALUE
    for (state in 0 until (1 shl n)) {
        if (countOne(state, n) < k) {
            continue
        }

        var tmp = 0L
        var currentMaxHeight = 0
        for (i in 0 until n) {
            if (((state shr i) and 1) == 1) {
                if (aList[i] <= currentMaxHeight) {
                    tmp += currentMaxHeight - aList[i] + 1
                }
                currentMaxHeight = Math.max(currentMaxHeight + 1, aList[i])
            } else {
                currentMaxHeight = Math.max(currentMaxHeight, aList[i])
            }
        }

        ans = Math.min(ans, tmp)
    }

    println(ans)
}

fun countOne(state: Int, n: Int): Int {
    var count = 0
    for (i in 0 until n) {
        if (((state shr i) and 1) == 1) {
            count++
        }
    }

    return count
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 37928
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a;
	cin>>b;
	cin>>c;
	if(a<b){
		if(b<c){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 1156
import math


while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int, input().split()))
    
    ave = sum(s) / n
    dev = math.sqrt(sum((ave - si) ** 2 for si in s) / n)

    print("{:.8f}".format(dev))    
    

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

int main () {
  int n;
  cin >> n;
  map <string, int> make_pair;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(begin(s), end(s));
    make_pair[s]++;
  }
  long long ans = 0;
  for (auto pp: make_pair) {
    long long cnt = pp.second;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << '\n';
  return (0);
}

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

ll g1(ll n, int p){
  if(n == 0) return 0;
  return n/p + g1(n/p, p);
}

ll g2(ll n, int p){
  ll ans = g1(n/2, p);
  if(p == 2) ans++;
  return ans;
}

int main(){
  ll n; cin >> n;
  if(n%2){cout << 0 << endl;  return 0;}
  cout << min(g2(n,2),g2(n,5)) << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int x[3], y[3]; double l[3], a[3], ret;
int main() {
	for (int i = 0; i < 3; i++) scanf("%d%d", &x[i], &y[i]);
	for (int i = 0; i < 3; i++) l[i] = hypot(x[(i + 1) % 3] - x[(i + 2) % 3], y[(i + 1) % 3] - y[(i + 2) % 3]);
	for (int i = 0; i < 3; i++) a[i] = acos(((x[(i + 1) % 3] - x[i]) * (x[(i + 2) % 3] - x[i]) + (y[(i + 1) % 3] - y[i]) * (y[(i + 2) % 3] - y[i])) / l[(i + 1) % 3] / l[(i + 2) % 3]);
	for (int i = 0; i < 3; i++) ret = max(ret, l[i] / (1 / tan(a[(i + 1) % 3] / 2) + 1 / tan(a[(i + 2) % 3] / 2) + 2));
	printf("%.12lf\n", ret);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using P = pair<int,int>;
int h, w, a[105][105];
char s[105][105];
int main(){
	scanf("%d%d", &h, &w);
	rep(i,h) scanf("%s", s[i]);
	rep(i,h) a[i][w] = 300;
	rep(j,w) a[h][j] = 300;
	for(int i=h-1; i>=0; i--) for(int j=w-1; j>=0; j--){
		a[i][j] = min(a[i+1][j]+(s[i][j]!=s[i+1][j]),a[i][j+1]+(s[i][j]!=s[i][j+1]));
		if(i==h-1&&j==w-1) a[i][j] = 0;
	}
	printf("%d\n", (a[0][0]+1+(s[0][0]=='#'))/2);
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(n * n * n);
        }

    }
}


Measured memory_bytes: 11220
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
using namespace std;

#define abs_val(a)       (((a)>0)?(a):-(a))
typedef long long        ll;

ll mulMod(ll a, ll b, ll c)
{
	ll x = 0, y = a%c;
	while (b > 0)
	{
		if (b % 2 == 1)
			x = (x + y) % c;
		y = (y * 2) % c;
		b /= 2;
	}
	return x%c;
}

ll gcd(ll a, ll b)
{
	return !b ? a : gcd(b, a%b);
}

ll Mod(ll a, ll b, ll p)
{
	ll res = 1;
	ll x = a%p;

	while (b)
	{
		if (b & 1)
		{
			res = mulMod(res, x, p);
		}
		x = mulMod(x, x, p);
		b /= 2;
	}
	return res%p;
}


bool millerTest(ll d, ll s, ll n)
{
	ll a = rand() % (n - 4) + 2;
	ll x = Mod(a, s, n);

	if (x == 1 || x == n - 1)
		return true;

	for (int r = 1; r < d; r++)
	{
		x = mulMod(x, x, n);

		if (x == 1)
			return false;
		if (x == n - 1)
			return true;
	}
	return false;
}



bool isPrime(ll n, int k = 20)
{
	if (n <= 1 || n == 4)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0)
		return false;

	ll s = n - 1, d = 0;
	while (s % 2 == 0)
	{
		s /= 2;
		d++;
	}
	for (int i = 0; i < k; i++)
	{
		if (millerTest(d, s, n) == false)
			return false;
	}
	return true;
}

map <ll, ll> MAP;

ll pollard_rho(ll n)  //pollard rho implementation
{
	if (n % 2 == 0)
		return 2;

	ll x = rand() % n + 1;
	ll c = rand() % n + 1;
	ll y = x;
	ll g = 1;

	//fn is f(x) = x*x + c
	while (g == 1)
	{
		x = (mulMod(x, x, n) + c) % n;
		y = (mulMod(y, y, n) + c) % n;
		y = (mulMod(y, y, n) + c) % n;
		g = gcd(abs_val(x - y), n);
	}
	return g;
}

void factorize(ll n)   //fn to factorize the number
{
	if (n == 1)
		return;

	if (isPrime(n))      //if n is prime,store it
	{
		MAP[n]++;
		return;
	}
	ll divisor = pollard_rho(n);   //get a divisor of n
	factorize(divisor);
	factorize(n / divisor);
}

int main()
{
	//freopen("in.txt", "r", stdin);

	int tc = 1;
	map<int, int> dic;
	for (int tcase = 1; tcase <= tc; tcase++)
	{
		ll n;
		scanf("%lld", &n);

		if (n == 1)
		{
			printf("0");
			return 0;
		}
		factorize(n);

		for (auto it : MAP)
		{
			for (int k = 0; k<it.second; k++) {
				dic[it.first]++;
			}
		}
		MAP.clear();
	}
	int ans = 0;
	for (auto iter = dic.begin(); iter != dic.end(); iter++) {
		int ee = (*iter).second;

		if (0 < ee && ee <= 2) { ans += 1; }
		else if (2 < ee&& ee <= 5) { ans += 2; }
		else if (5 < ee&& ee <= 9) { ans += 3; }
		else if (9 < ee && ee <= 14) { ans += 4; }
		else if (14 < ee&& ee <= 20) { ans += 5; }
		else if (20 < ee&& ee <= 27) { ans += 6; }
		else if (27 < ee && ee <= 35) { ans += 7; }
		else if (35 < ee && ee <= 44) { ans += 8; }
	}
	printf("%d", ans);
}

Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll x, k, d;

int main() {
	cin >> x >> k >> d;
	x = abs(x);
	ll k1 = k, d1 = d, tenk = 0, tend = 0;
	while (k1) {
		k1 /= 10;
		tenk++;
	}
	while (d1) {
		d1 /= 10;
		tend++;
	}
	if (tenk + tend >= 17) {
		if (((x - x % d) / d) % 2 == k % 2) {
			cout << x % d << endl;
		}
		else {
			cout << abs(x % d - d) << endl;
		}
	}
	else if (x - k * d > x % d) {
		cout << x - k * d << endl;
	}
	else {
		if (((x - x % d) / d) % 2 == k % 2) {
			cout << x % d << endl;
		}
		else {
			cout << abs(x % d - d) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    cout << fixed;
    cout << setprecision(5);
    int a, b;
    cin >> a >> b;
    cout << a / b << " ";
    cout << a % b << " ";
    double _a = static_cast<double> (a); 
    double _b = static_cast<double> (b);
    cout << _a/_b << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



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


int factorial_loop(long long n);

int main(void)
{
long long n;
long long result1;


cin>>n;

if(0<n&&n<21) ;
else return 0;

	result1 =factorial_loop(n);

//	cout<<(long long)result1<<endl;
	return 0;

}
int factorial_loop(long long n) {
    long long result = 1;
    long long k;

    for(k = 1; k <= n; k++) {
        result *= k;
		//
    }
	cout<<result<<endl;
    return result;
}

Measured memory_bytes: 1156
import sys

N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得
#print(s) #出力：['s_1', 's_2', 's_3', 's_N']

jud = ''
strlist = []
for string in s:
    pre = string[0]
    suf = string[-1]
    if string in strlist:
        print('No')
        sys.exit()

    if jud == '':
        jud = suf
    else:
        if pre != jud:
            print('No')
            sys.exit()
        else:
            jud = suf
    strlist.append(string)
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pi pair<int, int>
#define pb push_back
#define int long long

using namespace std;

const int maxn = 1e5 + 1;

int a[maxn], p[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, k; cin >> n >> k;
    n %= k;
    int ans = n;
    for (int i = 0; i < 10; i++) {
        n = abs(n - k);
        ans = min(ans, n);
    }
    cout << ans;
    return 0;
}
/*
2
aabbaabbbaaaa
aaaabbbaabbaa

2
bbaabaaaaabbbbbbbababaabaabaabbabababbbabbabbabbbabaabbbbbbaabaaaaaaaaababaaabbabbaaaaaabaababbaaabbbbbaaabababbaaabbbbaaababbbabaaabaaabbbbbbbbbbbabaaaaabaabababababbbaabaaaababaababbaaaabbababbbabba
abbabbbababbaaaabbabaababaaaabaabbbababababaabaaaaababbbbbbbbbbbaaabaaababbbabaaabbbbaaabbababaaabbbbbaaabbabaabaaaaaabbabbaaababaaaaaaaaabaabbbbbbaababbbabbabbabbbabababbaabaabaabababbbbbbbaaaaabaabb
*/


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

using namespace std;
using ll = long long;
ll n,t[400010],mx = 0;
void built(){
	for(int i = n-1;i>0;i--){
		t[i] = max(t[i<<1],t[i<<1|1]);
	}
}

ll query(int l, int r){
	ll mn = mx;
	for(l += n, r += n; l<r; l >>= 1,r >>= 1){
		if(l&1) mn = max(mn,t[l++]);
		if(r&1) mn = max(mn,t[--r]);
	}
	return mn;
}

int main(){
	int i;
	cin >> n;
	for(i=0;i<n;i++){
		int x; cin >> x; t[i + n] = x;
	}
	built();
	for(i=0;i<n;i++){
		cout << max(query(0,i),query(i + 1,n)) << endl;
	}
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn  = 1e5+10;
int32_t main(){
	IOS
	int n;cin>>n;
	vector<int>clr(n),a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	multiset<int>st;
	int cnt = 0;
	for(int i=n-1;i>=0;i--){
		auto it=st.upper_bound(a[i]);
		if( it != st.end() ){
			//bug3(i,a[i],*it);
			st.erase(it);
		}else{
			cnt++;
		}
		st.insert(a[i]);
	}
	cout<<cnt;
 }
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 9336
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

type P struct{ first, second int }

type ByP []P

func (b ByP) Len() int           { return len(b) }
func (b ByP) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }
func (b ByP) Less(i, j int) bool { return b[i].first < b[j].first }

func (con *contest) main() error {
	var N, K int
	con.Scan(&N, &K)
	A := []P{}
	for i := 0; i < N; i++ {
		var a, b int
		con.Scan(&a, &b)
		A = append(A, P{a, b})
	}
	sort.Sort(ByP(A))
	for _, a := range A {
		if K <= a.second {
			con.Println(a.first)
			break
		}
		K -= a.second
	}
	return nil
}


Measured memory_bytes: 7424
#include <stdio.h>

int main()
{ int a,b;char op;
	while(1){
	scanf("%d %c %d",&a,&op,&b);
	if(op=='+'){printf("%d\n",a+b);}
	else if (op=='-'){printf("%d\n",a-b);}
	else if(op=='*'){printf("%d\n",a*b);}
	else if(op=='/'){printf("%d\n",a/b);}
	else if(op=='?'){break;}
	}
	
	
	return 0;
}


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

using namespace std;

int main(){

  int n,c=0;
  string leg;
  bool ll=false,rl=false,l=false;

  while(true){
    cin>>n;
    if(!n) break;
    c=0;
    l=false;
    ll=false;
    rl=false;
    
    for(int i=0; i<n; ++i){
      cin>>leg;
      if(leg=="lu") ll=true;
      if(leg=="ru") rl=true;
      if(leg=="ld") ll=false;
      if(leg=="rd") rl=false;
      if(l){
	if(!ll){
	  if(!rl){
	    ++c;
	    l=false;
	  }
	}
      }else{
	if(ll){
	  if(rl){
	    ++c;
	    l=true;
	  }
	}
      }
    }

    cout << c << endl;
    
  }
  
  return 0;
}



Measured memory_bytes: 3128
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>

using namespace std;


#include <math.h> 


int main() {

	int N;
	cin >> N;

	vector<int64_t> a(N);

	int result = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		result = result ^ a[i];

	}
	for (int i = 0; i < N; i++) {
		int kekka;
		kekka = result ^ a[i];
		cout << kekka <<" ";
		

	}

	return 0;
}

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

int main() {
  //input
  int A, B;
  cin >> A >> B;
  //calc&output
  for(int i = 1; i < 4; i++) {
    if ( i == A ) {
      continue;
    }
    if ( i == B ) {
      continue;
    }
    cout << i << endl;
  }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  rep(i, k) {
    vector<int> b(n + 1);
    rep(i, n) {
      int l = max(0, i - a[i]);
      int r = min(i + a[i] + 1, n);
      b[l]++;
      b[r]--;
    }
    
    rep(i, n) b[i + 1] += b[i];
    b.pop_back();
    
    if (a == b) break;
    
    a = b;
  }
  
  rep(i, n) cout << a[i] << " ";
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def ARC072C():
    N = int(input())
    a = list(map(int, input().split()))
    cnt1 = 0
    cnt2 = 0
    sum1 = a[0]
    sum2 = a[0]
    if sum1 <= 0:
        cnt1 = 1 - a[0]
        sum1 = 1
    if sum2 >= 0:
        cnt2 = abs(-1 - a[0])
        sum2 = -1
    j = 1
    #print(sum1, sum2)
    for i in range(1, N):
        sum1 += a[i]
        sum2 += a[i]
        if j % 2 == 0:
            if sum1 <= 0:
                cnt1 += 1 - sum1
                sum1 = 1
            if sum2 >= 0:
                cnt2 += abs(-1 - sum2)
                sum2 = -1
        else:
            if sum1 >= 0:
                cnt1 += abs(-1 - sum1)
                sum1 = -1
            if sum2 <= 0:
                cnt2 += 1 - sum2
                sum2 = 1
        j += 1
        #print(sum1, sum2)
    #print(cnt1, cnt2)
    print(min(cnt1, cnt2))
ARC072C()


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

#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf  1e18
#define mk(arr,n,type) type *arr=new type[n];
#define ti(arr,n) for(ll i=0;i<n;++i)cin>>a[i];
#define ot(arr,n) for(ll i=0;i<n;++i)cout<<a[i]<<" ";
#define str(a) string a;cin>>a;
#define w(x) int x;cin>>x;while(x--)
int main()
{
  int x;cin>>x;
  if(x==1)cout<<0;
  else
    cout<<1;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios_base::sync_with_stdio(false);

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

  vector<long long> sum(n + 1);
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + a[i];
  }
  
  long long ans = 5e16, half;
  for (int i = 1; i < n - 1; i++) {
    // [0, i] + [i + 1, n - 1]
    int l, r;
    half = (sum[i + 1] + 1) / 2;
    l = lower_bound(sum.begin(), sum.end(), half) - sum.begin();
    half = (sum[n] - sum[i + 1] + 1) / 2 + sum[i + 1];
    r = lower_bound(sum.begin(), sum.end(), half) - sum.begin();
    for (int j : {l - 1, l}) {
      for (int k : {r - 1, r}) {
        long long p, q, r, s;
        p = sum[j];
        q = sum[i + 1] - sum[j];
        r = sum[k] - sum[i + 1];
        s = sum[n] - sum[k];
        ans = min(ans, max({p, q, r, s}) - min({p, q, r, s}));
      }
    }
    
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 5584