akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#define INF 1000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
ll mod = 1000000007;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (d == 1) cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<cstdlib>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds; 
//#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef long double ld;
typedef vector < pair < ll, ll > > vpll;
#define Boost() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define forn(i,n) for (ll i = 0; i < n; i++)
#define fo(i,n) for (ll i = 1; i <= n; i++)
#define fore(i,l,r) for (ll i = l; i <= r; i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define MAX 1000000007
ll power(ll a,ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fact[500009];
ll fermat_inv(ll y){return power(y,MOD-2);}
ll nCrMod(ll n, ll r){ ll p=fact[n];ll q=(fact[r]*fact[n-r])%MOD;return (p*fermat_inv(q))%MOD;} 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
const ld PI = acos(-1.0);
vl g[20];

  int main(){
      #ifndef ONLINE_JUDGE
      freopen("input.cpp","r",stdin);
      freopen("output.cpp","w",stdout);
      #endif
      Boost();
      int t;
      //cin>>t;
      t=1;
      int t1=t;
      while(t--)
      {
        ll a,b,c;
        ll k;
        cin>>a>>b>>c;
        cin>>k;
        int c1=0;
        while(b<=a)
        {
          b*=2;
          c1++;
        }
        while(c<=b)
        {
          c*=2;
          c1++;
        }
        if(c1<=k)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;  
       }
      return 0;
      }
  

Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		List<Double> ansList = new ArrayList<Double>();
		Scanner sc = new Scanner(System.in);
		while(true){
		if(sc.hasNext()==false) {
			break;
		}

		double a = sc.nextInt();
		double l = sc.nextInt();
		double x = sc.nextInt();

		ansList.add(Math.sqrt(l*l-a*a*0.25)*a*0.5+l*Math.sqrt((l+x)*(l+x)*0.25-l*l*0.25));
		}
		for(int i=0;i<ansList.size();i++) {
		System.out.println(ansList.get(i));
		}
		sc.close();
		}


}


Measured memory_bytes: 35892
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,
        a:[i64;n],
    }
    if a[0] != 0 {
        println!("{}", -1);
        return;
    }
    let mut ans = 0i64;
    for i in 0..n {
        if i < n - 1 && a[i + 1] - a[i] > 1 {
            println!("{}", -1);
            return;
        }
        if i >= n - 1 || a[i] + 1 != a[i + 1] {
            ans += a[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 5264
import sys
A,B = map(int,input().split())

if not ( 1 <= A <= 20 ): sys.exit()
if not ( 1 <= B <= 20 ): sys.exit()
if not (isinstance(A,int) and isinstance(B,int)): sys.exit()

print(A*B) if A <= 9 and B <= 9 else print(-1)

Measured memory_bytes: 9068
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		if(N == 1) {
			System.out.println("Hello World");
		}else if(N == 2) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a+b);
		}
	}
}

Measured memory_bytes: 21332
const main = stdin => {
  const dishes = [A, B, C, D, E] = stdin.trim().split('\n').map((x) => parseInt(x))

  let time = 999999

  for (let i = 0; i < 5; i++) {
    for (let j = 0; j < 5; j++) {
      if (i === j) continue
      for (let k = 0; k < 5; k++) {
        if (i === k || j === k) continue
        for (let l = 0; l < 5; l++) {
          if (i === l || j === l || k === l) continue
          for (let m = 0; m < 5; m++) {
            if (i === m || j === m || k === m || l === m) continue
            let tmpTime = dishes[i];
            if (tmpTime % 10 !== 0) {
              tmpTime += 10 - tmpTime % 10
            }
            tmpTime += dishes[j];
            if (tmpTime % 10 !== 0) {
              tmpTime += 10 - tmpTime % 10
            }
            tmpTime += dishes[k];
            if (tmpTime % 10 !== 0) {
              tmpTime += 10 - tmpTime % 10
            }
            tmpTime += dishes[l];
            if (tmpTime % 10 !== 0) {
              tmpTime += 10 - tmpTime % 10
            }
            tmpTime += dishes[m];

            time = Math.min(time, tmpTime)
          }
        }
      }
    }
  }

  console.log(time)
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29536
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>

using namespace std;


vector< vector<long long int> > b(100010);

long long int sai(long long int n) {
	if (b[n].size() == 0) {
		return 0;
	}
	vector<long long int> c;
	vector<long long int> d;
	for (long long int i = 0; i < b[n].size(); i++) {
		c.push_back(sai(b[n][i]));
		d.push_back(i+1);
	}
	sort(c.begin(), c.end(), greater<long long int>());
	long long int M = 0;
	for (long long int i = 0; i < c.size(); i++) {
		M = max(M, c[i]+d[i]);
	}
	return M;
}

int main() {
	long long int n;
	cin >> n;

	long long int a;
	for (long long int i = 0; i < n-1; i++) {
		cin >> a;
		b[a-1].push_back(i+1);
	}

	cout << sai(0) << endl;

	return 0;
}

Measured memory_bytes: 16640
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    r = 0
    for i in range(N-K+1):
        r += (A[N-i-1] - A[i]) * cmb(N-i-1, K-1, mod)
 
    print(r % mod)
def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, 10 ** 6 + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


main()



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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL (vec)(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define eb emplace_back
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
#define PQ priority_queue
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h,w;
  cin>>h>>w;
  VV(ll,c,10,10,0);
  rep(i,10)rep(j,10)cin>>c[i][j];
  VV(ll,a,h,w,0);
  rep(i,h)rep(j,w)cin>>a[i][j];

  VV(ll,magic,10,10,1e9);
  rep(asd,6){
  rep(i,10){
    rep(j,10){
      rep(k,10){
        c[i][k]=min({c[i][k],c[i][j]+c[j][k]});
      }
    }
  }
  }
  int res=0;
  rep(i,h)rep(j,w)if(a[i][j]!=-1)res+=c[a[i][j]][1];
  out(res);
  
  
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
// cout<<fixed<<setprecision(10);
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
 
const int NM = 2*1e5;
 
int ar[NM];
int fr[NM];
 
int main(){
    int n;
    ll k; 
    cin >> n >> k;
    rep(i, n){
        int a; cin >> a;
        ar[i] = a;//消化コスト
    }
    rep(i, n){
        int a; cin >> a;
        fr[i] = a; // 食べにくさ
    }
    sort(ar, ar+n);
    sort(fr, fr+n, greater<int>());
 
    // へらす
    ll l = -1; ll r = 1e12;
    while(l+1 < r){
        ll mid = (l + r)/2;
        // 
        bool isOk = [&]{
            ll s = 0;
            rep(i, n){
                s += max(0ll, ar[i]-mid/fr[i]);
            }
            return s <= k;
        }();
        if(isOk) r = mid; else l = mid;
    }

    cout << r << endl;
}

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

// main
int main(){
    int N;
    cin >> N;
    vector<int> t_vec={0}, x_vec={0}, y_vec={0};

    for(int i = 0; i < N; ++i){
        int t, x, y;
        cin >> t >> x >> y;
        t_vec.push_back(t);
        x_vec.push_back(x);
        y_vec.push_back(y);
    }

    for(int i = 0; i < N; ++i){
        int dt = t_vec[i+1] - t_vec[i];
        int dist = abs(x_vec[i+1]-x_vec[i]) + abs(y_vec[i+1]-y_vec[i]);
        if(dist > dt){
            cout << "No" << "\n";
            return 0;
        }else{
            if(dt % 2 != dist %2){
                cout << "No" << "\n";
                return 0;
            }
        }

    }
    cout << "Yes" << "\n";
    return 0;
}

Measured memory_bytes: 1644
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

signed main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;

	return 0;
}



Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main()
{
    int H,W;
    cin>>H>>W;
    char arr[H][W];
    for(int i=0;i<H;i++){
        cin>>arr[i];
    }
    
    int newLength=2*H;
    // cout<<"old: "<<H<<" ;new: "<<newLength<<endl;
    
    for(int i=0;i<newLength;i++){  
        int newI=i/2;
    // cout<<"newI: "<<H<<" ;new: "<<newLength<<endl;
        for(int j=0;j<W;j++){ 
            cout<<arr[newI][j];
        }
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main()     //main method
{
    FIO;

        char x;
        cin>>x;
        if(x>='a' && x<='z'){
            cout<<'a'<<"\n";
        }
        else{
            cout<<'A'<<"\n";
        }








    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int main(){
    ll S;
    cin >> S;
    if(S == 1000000000000000000) {
        cout << 0 << " " << 0 << " " << 1000000000 << " " << 0 << " " << 0 << " " << 1000000000
             << endl;
        return 0;
    }
    ll x0 = 0, y0 = 0, x1 = 1000000000, x2 = 1;
    ll y2 = (S / 1000000000) + 1;
    ll y1 = 1000000000 - (S % 1000000000);

    cout << x0 << " " << y0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
    return 0;
}


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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    float A,P;

    cin>>A>>P;

    cout<<(int)(A*3/2+P*1/2)<<endl;


    return 0;
}

Measured memory_bytes: 256
a1 = Array.new
a2 = Array.new 
loop do
score1 =0
score2 =0

n = gets.to_i
if n == 0
	break
end
n.times do
	num1,num2 = gets.split.map(&:to_i)
	if num1>num2
		score1 += num1+num2
	elsif num2>num1
		score2 += num1+num2
	else
		score1 += num1
		score2 += num2
	end
end
a1.push(score1)
a2.push(score2)
end
while !a1.empty?
puts "#{a1.shift} #{a2.shift}"
end

Measured memory_bytes: 8748
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl "\n"
#define pii tuple<ll,ll,ll>
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
const ll N=1005;
const ll INF=LLONG_MAX;
void amfetamin()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
amfetamin();
int n,q;
cin>>n;
int freq[100005];
ll sol=0;
for (int i=1; i<=100005; i++)
    freq[i]=0;
for (int i=0; i<n; i++)
{
    ll a;
    cin>>a;
    sol+=a;
    freq[a]++;
}
cin>>q;
for (int i=0; i<q; i++)
{
    ll b,c;
    cin>>b>>c;
    ll cur=freq[b];
    freq[b]=0;
    sol-=cur*b;
    sol+=cur*c;
    freq[c]+=cur;
    cout<<sol<<endl;
}

}


Measured memory_bytes: 4032
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main{
	static ArrayList<Integer> fract;
	public static void main(String[] args) {
		fract=new ArrayList<Integer>();
		Scanner sc=new Scanner(System.in);
		while(true) {
			int a=sc.nextInt();
			if(a==1) {
				System.exit(0);
			}
			else {
				fract.clear();
				frac(a);
				StringBuilder sb=new StringBuilder();
				sb.append(a);
				sb.append(": ");
				Collections.sort(fract);
				for(int i=0; i<fract.size()-1; i++) {
					sb.append(fract.get(i)+" ");
				}
				sb.append(fract.get(fract.size()-1));
				System.out.println(sb.toString());
			}
		}
	}
	public static void frac(int num) {
		for(int i=0; i<=600000; i++) {
			int wari=0;
			if(i%2==0) {
				wari=((i+1)/2*7)+1;
			}
			else {
				wari=((i+1)/2*7)-1;
			}

			if(wari!=1 && num%wari==0 && ismfp(wari)) {
				fract.add(wari);
			}
		}
	}
	public static boolean ismfp(int num) {
		int tmp=6;
		int[] add= {2,5};
		int counter=0;
		while(tmp*tmp<=num) {
			if(num%tmp==0 && (((num/tmp)%7==1) ||((num/tmp)%7==6))){
				return false;
			}
			tmp+=add[counter%2];
			counter++;
		}
		return true;
	}
}


Measured memory_bytes: 30948
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		
		int a=sc.nextInt();
		if(a==25)
			System.out.println("Christmas");
		else if(a==24)
			System.out.println("Christmas Eve");
		else if(a==23)
			System.out.println("Christmas Eve Eve");
		else if(a==22)
			System.out.println("Christmas Eve Eve Eve");
		else
			System.out.println( "0");
	}
}

Measured memory_bytes: 22740
P=->s{puts s;exit};R,C=gets.split.map &:to_i;N=gets.to_i;M=Hash.new{|h,k|h[k]=[]};N.times{x,y,d=gets.split.map &:to_i;M[x]<<[y+R,d];M[y+R]<<[x,-d]};(a=-1<<61;b=1<<61;s=M.find{|e|e}[0];t=[[s,0]];m={s=>0};(x,d=t.pop;m[x]=d;M[x].map{|y,c|!m[y]?t<<[y,d+c]:m[y]!=d+c&&P[:No]};x<=R ? a=[a,d].max: b=[b,d].min)while !t.empty?;a>b&&P[:No];m.map{|k,v|M.delete k})while !M.empty?;P[:Yes]

Measured memory_bytes: 59772
#include<bits/stdc++.h>
#define inf 1000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 256
from math import gcd
n=int(input())
a=list(map(int,input().split()))
g=gcd(a[0],a[1])
for i in range(n-2):
    g=gcd(g,a[i+2])
if a==[1]*n:
    print("pairwise coprime")
    exit()
if g!=1:
    print("not coprime")
    exit()
temp=[i for i in range(10**6+5)]
p=2
while p*p<=10**6+5:
    if temp[p]==p:
        for q in range(2*p,10**6+5,p):
            if temp[q]==q:
                temp[q]=p
    p+=1
ans=[0]*(10**6+10)
for j in a:
    count=set()
    while j>1:
        count.add(temp[j])
        j//=temp[j]
    for k in count:
        ans[k]+=1
if max(ans)!=1:
    print("setwise coprime")
else:
    print("pairwise coprime")


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n;
    cin1(n);
    string s;
    cin1(s);
    REP(i,0,s.length()) {
        lli x = s[i] - 'A';
        x = (x + n) % 26;
        char y = 'A' + x;
        cout <<y;
    }
    cout << endl;
}


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

int intLength(ll n) {
    int ret = 0;
    while (true) {
        if (n == 0) break;
        n /= 10;
        ret++;
    }
    return ret;
}

int solve(ll N) {
    int ret = 0;
    for (ll i = 1LL; (i * i) <= N; i++) {
        if (N % i == 0) {
            ret = max(intLength(i), intLength(N / i));
            // cout << i << " " << N / i << endl;
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    cout << solve(N) << endl;
}

Measured memory_bytes: 256
#参考:#9428054 @hmmnrst
N,*X = $<.read.split.map &:to_i
M = 10**9+7
i=k=s = 0
f = 1
X.each_cons(2){ |a,b|
	i += 1
	k = (k*i + f) % M
	f = f*i % M
	s = (s*i + (b-a)*k) % M
#p [i,k,f,s]
}
p s

Measured memory_bytes: 9212
//set many funcs template
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int strsortfncsj(const void *a,const void *b){return strcmp((char *)a,(char *)b);}
int strsortfnckj(const void *a,const void *b){return strcmp((char *)b,(char *)a);}

int main(void){
    srand(time(0));
    long long i,j,n,m,a=0,b[128]={0},c,w,r=0,l,t,x[128],y[128],ni;
    clock_t stt,nt;
    double res,st,k,na,nx,ny,fx[128],fy[128];
    double d;
    char s[262144];
    scanf("%lld",&n);
    //l=strlen(s);
    for(i=0;i<n;i++){scanf("%lld%lld",&x[i],&y[i]);fx[i]=x[i];fy[i]=y[i];}
    for(j=0;j<2000000;j++){
      st=j;st/=2000000.0f;st*=(2.0f*pi);
      ni=-1;na=(double)1e100;
      nx=sin(st);nx*=(double)1e11;
      ny=cos(st);ny*=(double)1e11;
      for(i=0;i<n;i++){
        k=dbzt(nx,fx[i])*dbzt(nx,fx[i])+dbzt(ny,fy[i])*dbzt(ny,fy[i]);
        if(k<na){na=k;ni=i;}
      }
      a++;b[ni]++;
    }
    for(i=0;i<n;i++){
      res=b[i];
      printf("%.12lf\n",res/a);
    }
    //qsort(a,n,sizeof(int),sortfncsj);
    //printf("%d\n",r);
    return 0;
}



Measured memory_bytes: 128
//Noszály Áron 10o Debreceni Fazekas Mihály Gimnázium

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define FORN(i, n) for(int i=0;i<(n);i++)
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, l, r) for ((i) = (l); (i) < (r); (i)++)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}
int n;
void solve(vector<int> st, int mod2, int mod3, int sum,  vector<int> volt) {
	if(mod2!=0 || mod3!=0) {
		mod2=((mod2-st.back())%2+2)%2;
		mod3=((mod3-st.back())%3+3)%3;
		
		sum-=st.back();
		st.pop_back();
		
		for(int j=1;j<=30000 && sz(st)<n;++j) {
			if(volt[j]) continue ;
			if(j%3==3-mod3 && j%2==mod2 && __gcd(j, sum)>1) {
				st.pb(j);
				break; 
			}
		}
		
		if(sz(st)==n) goto ok;
		
		mod2=((mod2-st.back())%2+2)%2;
		mod3=((mod3-st.back())%3+3)%3;
		sum-=st.back();
		st.pop_back();
		for(int j=1;j<=30000 && sz(st)<n;j++) {
			for(int k=j+1;k<=30000 && sz(st)<n;k++) {
				if(volt[j] || volt[k]) continue ;
				
				if((j+k)%3==3-mod3 && (j+k)%2==mod2 && __gcd(j, k+sum)>1 && __gcd(k, j+sum)>1) {
					
					st.pb(j);
					st.pb(k);
					
				}
			}
		}
		if(sz(st)==n) goto ok;
		
		return ;
	
	}
	ok:
	int szum=0;
	int g=*st.begin();
	for(auto i:st) {
		szum+=i;
		g=__gcd(g, i);
	}

	if(g>1) return ;
	
	for(auto i:st) {
		if(__gcd(szum-i, i)==1) return ;
	}
	for(auto i:st) {
		cout<<i<<" ";
	}cout<<"\n";
	exit(0);
	
	
}

int main() {
	IO;
	
	
	
	cin>>n;
	vector<int> st;
	
	vector<int> volt(30001);
	int mod2=0, mod3=0, sum=0;
	for(int i=30000;sz(st)<n && i>=1;i--) {
		if(i%2==0 || i%3==0) {
			st.pb(i);	sum+=i;
		
			mod2=(mod2+i)%2;
			mod3=(mod3+i)%3;
			volt[i]=1;
		}
	}
	solve(st, mod2, mod3, sum, volt);
	mod2=0;mod3=0;sum=0;
	volt=vector<int>(30001, 0);
	st.clear();
	for(int i=1;sz(st)<n && i<=30000;i++) {
		if(i%2==0 || i%3==0) {
			st.pb(i);	sum+=i;
		
			mod2=(mod2+i)%2;
			mod3=(mod3+i)%3;
			volt[i]=1;
		}
	}
	solve(st, mod2, mod3, sum, volt);
	
	
	vector<int> osszes;
	for(int i=1;i<=30000;++i) {
		if(i%2==0 || i%3==0) osszes.pb(i);
	}
	
	while(1) {
		random_shuffle(all(osszes));
		mod2=0;mod3=0;sum=0;
		volt=vector<int>(30001, 0);
		st.clear();
		
		for(int i=0;i<sz(osszes) && sz(st)<n;++i) {
			st.pb(osszes[i]);
			sum+=osszes[i];
			mod2=(mod2+osszes[i])%2;
			mod3=(mod3+osszes[i])%3;
			volt[osszes[i]]=1;
		}
		solve(st, mod2, mod3, sum, volt);
	}
	assert(0);
	return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;
// C 96
int main(){
    int h, w; cin >> h >> w;
    string board[50];
    rep(i,h) cin >> board[i];

    const int dx[4] = {1,0,-1,0};
    const int dy[4] = {0,1,0,-1};

    rep(i,h){
        rep(j,w){
            if(board[i][j] == '.') continue;

            int num=0;
            rep(d, 4){
                const int ni = i + dy[d];
                const int nj = j + dx[d];

                if(ni < 0 or h <= ni) continue;
                if(nj < 0 or w <= nj) continue;
                if(board[ni][nj] == '#') num++;
            }
            if(num==0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
 
using namespace std;
 
typedef string::const_iterator State;
typedef pair<int, int> Pii;
 
#define fr first
#define sc second
 
bool is_over = false;
 
struct Parser {
  Pii expression(State &idx) {
    Pii ret = term(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    while ( 1 ) {
      if ( *idx == '+' ) {
    idx++;
    Pii tmp = term(idx);
    ret.fr = ret.fr + tmp.fr;
    ret.sc = ret.sc + tmp.sc;
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      } else if ( *idx == '-' ) {
    idx++;
    Pii tmp = term(idx);
    ret.fr = ret.fr - tmp.fr;
    ret.sc = ret.sc - tmp.sc;
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      } else {
    break;
      }
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }
   
  Pii term(State &idx) {
    Pii ret = factor(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    //
    while ( 1 ) {
      if ( *idx == '*' ) {
    idx++;
    Pii tmp = factor(idx), tmp2 = ret;
    //cout << ret.fr << " " << ret.sc << endl;
    //cout << tmp.fr << " " << tmp.sc << endl;
    ret.fr = tmp2.fr * tmp.fr - tmp2.sc * tmp.sc;
    ret.sc = tmp2.fr * tmp.sc + tmp2.sc * tmp.fr;
    if ( abs(ret.fr)> 10000 || abs(ret.sc) > 10000 ) is_over = true;
    //  cout << ret.fr << " " << ret.sc << endl;
      } else {
    break;
      }
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }
 
  Pii factor(State &idx) {
    Pii ret;
    if ( *idx == '(' ) {
      idx++;
      ret = expression(idx);
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      idx++;
    } else {
      ret = number(idx);
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }
 
  Pii number(State &idx) {
    int tmp = 0;
    while ( '0' <= *idx && *idx <= '9' ) {
      tmp *= 10;
      tmp += *idx - '0';
      if ( abs(tmp) > 10000 ) is_over = true;
      idx++;
      /*if ( *idx == 'i' ) {
    is_real = false;
    idx++;
    }*/
    }
    if ( abs(tmp) > 10000 ) is_over = true;
    //cout << tmp << endl;
    if ( *idx == 'i' ) {
      idx++;
      return Pii(0, 1);
    }
  
    else return Pii(tmp, 0);
  }
};
 
int main()
{
  string s;
  while ( cin >> s ) {
    is_over = false;
    Parser ps;
    string tmp = s.substr(0, s.size() - 1);
    State idx = s.begin();
 
    Pii ret = ps.expression(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    if ( is_over ) cout << "overflow" << endl;
    else if ( ret.fr == 0 && ret.sc == 0 ) cout << 0 << endl;
    else if ( ret.fr == 0 ) {
      printf("%di\n", ret.sc);
    }
    else if ( ret.sc == 0 ) {
      printf("%d\n", ret.fr);
    }
    else {
      printf("%d", ret.fr);
      printf("%+di\n", ret.sc);
      //   cout << ret.fr << '+' << ret.sc << 'i' << endl;
    }
  }
 
  return 0;
}

Measured memory_bytes: 3184
N = int(input())
*A, = map(int,input().split())
count = 0
for i in range(N):
    minj = i
    for j in range(i,N):
        if A[j] < A[minj]:
            minj = j
    if not minj == i:
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
        count += 1
    
print(*A)
print(count)


Measured memory_bytes: 5604
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int func1(int x);
int main(){
  int h,w;
  cin >> h >> w;
  string s[h];
  for(int i=0;i<h;i++)
    cin >> s[i];
  w+=2;
  func1(w);
  for(int i=0;i<h;i++)
    cout << '#' << s[i] << '#' << "\n";
  func1(w);
  return 0;
}

int func1(int x){
  for(int i=0;i<x;i++)
    cout << '#';
  cout << "\n";
}


Measured memory_bytes: 256
C = [list(map(int, input().split())) for i in range(3)]

isCorrect = True

for a, b in [(0, 1), (0, 2), (1, 2)]:
    if ((C[a][0] - C[b][0]) != (C[a][1] - C[b][1])) or ((C[a][1] - C[b][1]) != (C[a][2] - C[b][2])):
       isCorrect = False
    if ((C[0][a] - C[0][b]) != (C[1][a] - C[1][b])) or ((C[1][a] - C[1][b]) != (C[2][a] - C[2][b])):
       isCorrect = False

print("Yes" if isCorrect else "No")

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

public class Main
{
	public static void main(String[] arg) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s;
		int gcd, lcm;
		while((s=br.readLine())!=null)
		{
			int a = Integer.parseInt(s.split(" ")[0]);
			int b = Integer.parseInt(s.split(" ")[1]);

			gcd = gcd(a,b);
			lcm = lcm(a,b);
			System.out.println(gcd + " " + lcm);
		}
	}

	public static int gcd(int a, int b)
	{
		if(b==0) return a;
		else     return gcd(b, a%b);
	}

   	public static int lcm(int a, int b)
	{
		// a * b = gcd * lcm
		b /= gcd(a,b);
		return a * b;
	}
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define INF 		2000000007
#define MOD			10e9+7
#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

int main(){
	int N,X;cin>>N>>X;
	vector<int> L(N);
	REP(i,N)cin>>L[i];

	int suml = 0;
	int cnt = 0;
	REP(i,N){
		suml += L[i];
		if(suml > X){
			cnt = i+1;
			break;
		}
	}
	
	cout << (cnt==0?N+1:cnt) << endl;


	return 0;
}



Measured memory_bytes: 256
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k;
	cin >> n >> k;
	double ans = 0;
	for (int i = 1; i <= n;++i)
	{
		double temp = 1.0 / double(n);
		int f = i;
		double cnt = 0;
		while(f<k)
		{
			cnt++;
			f = f * 2;
		}
		temp *= pow(0.5, cnt);
		ans += temp;
	}

	cout <<std::fixed<<std::setprecision(12)<< ans;

#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
 
int main(void){
    int N, ans=0;
    double dT=1000, T, A;
    std::cin >> N >> T >> A;
 
    for (int i=0; i<N; ++i){
        double h, tmp;
        std::cin >> h;
        tmp = T - 0.006 * h;
        if (dT > std::abs(A - tmp)){
            dT = std::abs(A - tmp);
            ans = i + 1;
        }
    }
 
    std::cout << ans << std::endl;
 
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int a,b,c;
	cin>>a>>b>>c;
	int Vab=a+b;
	int Vac=a+c;
	int Vbc=b+c;
	cout<<min(Vab,min(Vac,Vbc))<<endl;
	return 0;
}


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

s = {}

for i in range(n):
  a = input()
  if a in s :
    s[a] += 1
  elif a not in s:
    s.update({a:1})

b = max(s.values())
for i in sorted(k for k in s if s[k] == b):
  print(i)

Measured memory_bytes: 32096
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

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

    int A, B, C, D, E, F; 
    cin >> A >> B >> C >> D >> E >> F;

    // 100A*i + 100B*j + C*k + D*l <= F
    // (C*k+D*l)/(100A*i+100B*j+C*k+D*l) <= E/(100+E)

    const int JMAX = F / (100 * B);
    const int IMAX = F / (100 * A);

    int ansWt = 100 * A, ansSg = 0;
    REP(j,JMAX+1) {
        REP(i,IMAX+1) {
            int water = 100 * A*i + 100 * B*j;
            if (water > F) continue;

            int SgMax = water/100 * E;
            const int KMAX = SgMax / C;
            const int LMAX = SgMax / D;
            REP(l,LMAX+1) {
                REP(k,KMAX+1) {
                    int sugar = C * k + D * l;

                    if (water + sugar <= F &&
                        (100+E)*(sugar) <= E*(water+sugar)){

                        // sugar/(water+sugar) > ansSg/(ansWt+ansSg)
                        if (sugar*(ansWt+ansSg) > ansSg*(water+sugar)) {
                            ansWt = water;
                            ansSg = sugar;
                        }
                    }
                }
            }
        }
    }

    cout << ansWt + ansSg << " " << ansSg << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,d,x,a[105];
int main()
{
    scanf("%d %d %d",&n,&d,&x);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int day=1;
        ans+=1;
        day+=a[i];
        while(day<=d)
        {
            ans+=1;
            day+=a[i];
        }
    }
    printf("%d",ans+x);
}


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


int main(int argc, char *argv[])
{
	int i;
    int N;
	cin >> N;
    int a[N];
	long long sum = 0;

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


	for (i = 0; i < N; i++) {
		sum += a[i] - 1;
	}

	cout << sum << "\n";

	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int mod = 1e9 + 7;

inline int add(int a, int b) {
  return a+b >= mod ? a+b-mod : a+b;
}

inline int sub(int a, int b) {
  return a >= b ? a-b : a-b+mod;
}

inline int mul(int a, int b) {
  return llint(a)*b % mod;
}

int main(void) {
  
  int N;
  scanf("%d", &N);
  vector<pair<int, int>> v;
  REP(i, 2) REP(j, N) {
    int x;
    scanf("%d", &x);
    v.push_back({x, i});
  }

  sort(v.begin(), v.end());
  int ans = 1;
  int bal = 0;
  for (auto& p: v) {
    if (p.second) {
      if (bal < 0) ans = mul(ans, -bal);
      bal++;
    } else {
      if (bal > 0) ans = mul(ans, bal);
      bal--;
    }
  }
  
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2420
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long k=sc.nextLong();
        long max=0;
        int a[]=new int[n];
        int f[]=new int[n];
        for(int i=0;i<n;i++)a[i]=sc.nextInt();
        for(int i=0;i<n;i++)f[i]=sc.nextInt();
        Arrays.sort(a);
        Arrays.sort(f);
        ArrayList<Po>po=new ArrayList<>();
        for(int i=0;i<n;i++){
            po.add(new Po(a[i],f[n-1-i]));
            max=Math.max(po.get(i).mul(),max);
        }
        long min=0,mid=(max+min)/2;
        while(max!=min){
            long s=0;
            for(int i=0;i<n;i++){
                int b=po.get(i).b;
                long mul=po.get(i).mul();
                s+=(mul<=mid)?0:(long)Math.ceil(((double)(mul-mid))/b);
            }
            if(s>k){
                min=mid+1;
                mid=(min+max)/2;
            }else{
                max=mid;
                mid=(min+max)/2;
            }
        }
        System.out.println(max);
    }
}
class Po{
    int a;
    int b;
    public Po(int x,int y){
        a=x;
        b=y;
    }
    public String toString(){
        return a+" "+b;
    }
    public long mul(){
        return (long)a*b;
    }
}


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

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ans = A - B;
    if(K % 2) ans *= -1;
    cout << ans << "\n";
    /*
    if(abs(ans) > pow(10, 18)){
        cout << "Unfair" << "\n";
    } else{
        if(K % 2) 
    }
     */
    return 0;
}

Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]r){Scanner sc=new Scanner(System.in);int i,n=sc.nextInt(),m=sc.nextInt(),x=sc.nextInt(),w=999999,q=w;int[]a=new int[n],b=new int[m];for(i=0;i<n;i++)w=(w<(a[i]=sc.nextInt()))?w:a[i];for(i=0;i<m;i++)q=(q<(b[i]=sc.nextInt()))?q:b[i];n=q+w;for(i=0;i<x;i++)n=(n<(q=a[sc.nextInt()-1]+b[sc.nextInt()-1]-sc.nextInt()))?n:q;System.out.print(n);}}

Measured memory_bytes: 151836
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
int main(void){
    int n;cin>>n;
    string s1,s2;cin>>s1>>s2;
    ll res=1;
    vector<int> a;
    rep(i,s1.size()){
        if(s1[i]==s2[i]){
            a.push_back(1);
        }else{
            a.push_back(2);i++;
        }
    }
    if(a[0]==1){
        res*=3;
    }else{
        res*=6;
    }
    rep(i,a.size()-1){
        if(a[i]==1){
            if(a[i+1]==1){
                res*=2;res%=mod;
            }else{
                res*=2;res%=mod;
            }
        }else{
            if(a[i+1]==1){
                res*=1;
            }else{
                res*=3;res%=mod;
            }
        }
    }
    cout<<res<<endl;
}

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

using namespace std;

int n, ans;
string a, b;

main(){
  cin >> n >> a;
  for(int i=0;i<n;i++){
    cin >> b;
    for(int j=0;j<b.size();j++){
      for(int k=0;k<b.size();k++){
        for(int l=0;k+l*(j+1)<b.size()&&l<a.size();l++){
          if(b[k+l*(j+1)] != a[l]) break;
          if(l+1 == a.size()){ ans++; goto BR; }
        }
      }
    }
    BR:;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main {
  private final static class Process {
    public String name = null;
    public int pt = 0;

    public Process(String name, int pt) {
        this.name = name;
        this.pt = pt;
    }
}
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] fr = br.readLine().split("\\s");
        int elm = Integer.parseInt(fr[0]);
        int qat = Integer.parseInt(fr[1]);
        Queue<Process> que = new LinkedList<Process>();
        for (int i = 0; i < elm; i++) {
            String[] str = br.readLine().split("\\s");
            Process process = new Process(str[0],
                    Integer.parseInt(str[1]));
            que.offer(process);
        }
        int rt = 0;
        while (que.size() > 0) {
            Process process = que.poll();
            rt += qat;
            if ((process.pt = process.pt - qat) > 0) {
                que.offer(process);
                continue; 
            }
            rt += process.pt;
            System.out.println(process.name + " " + rt);
        }

    }
    
}


Measured memory_bytes: 77540
import java.lang.StringBuilder
import java.util.StringTokenizer

fun main() {
    val reader = System.`in`.bufferedReader()
    var tokenizer: StringTokenizer = StringTokenizer("")

    fun next(): String {
        while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
        return tokenizer.nextToken()
    }

    fun nextLine() = reader.readLine()

    fun solve() {
        var n = next().toLong()

        var ans = StringBuilder()

        while (n > 0){
            n--
            var rem = n%26
            rem += 97
            ans.append(rem.toChar())
            n/=26
        }

        ans.reverse()
        println(ans.toString())



    }

    solve()


}




Measured memory_bytes: 34468
#include <iostream>
#define MAX 1000001
#define INF 1<<27
using namespace std;
bool isPrime(int n){
  if(n == 0 || n == 1)return false;
  for(int i = 2 ; i*i <= n ; i++ ){
    if(n%i == 0)return false;
  }
  return true;
}

int main(){
  int n,yosan;
  int dp[MAX];
  while(cin >> n >> yosan,n){
    fill(dp,dp + MAX,0);
    dp[0] = 1;
    for(int i = 0 ; i < n ; i++ ){
      int a;
      cin >> a; 
      for(int j = a ; j <= yosan ; j++ ){
	if( dp[j - a] )dp[j] = 1;
      }
    }
    int res = -1;
    for(int i = yosan ; i >= 0 ; i-- ){
      if( isPrime(i) && dp[i] ){
	res = i;
	break;
      }
    }
    if(res == -1)cout << "NA" << endl;
    else cout << res << endl; 
  }
}

Measured memory_bytes: 5064