akhauriyash/Code-Regression huggingface dataset:
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	int n, m, q;
	cin >> n >> m >> q;
	vector<int> a, b, c, d;
	rep(i, q){
		int aa, bb, cc, dd;
		cin >> aa >> bb >> cc >> dd;
		a.push_back(aa);
		b.push_back(bb);
		c.push_back(cc);
		d.push_back(dd);

	}
	vector<int> x(n+1, 1);
	int ans = 0;
	while(1){
		int cnt = 0;
		rep(j, q){
			if(x.at(b.at(j)) - x.at(a.at(j)) == c.at(j)){
				cnt = cnt + d.at(j);
			}
		}
		if(cnt > ans){
			ans = cnt;
		}
		if(x.at(1) == m){
			break;
		}
		x.at(n) = x.at(n) + 1;
		REPS(i, n){
			if(x.at(i) == m+1){
				x.at(i-1) = x.at(i-1) + 1;
				x.at(i) = 0;
			}
		}
		reps(i, n-1){
			if(x.at(i) > x.at(i+1)){
				x.at(i+1) = x.at(i);
			}
		}

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


Measured memory_bytes: 3584
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
ll pow(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res*=a;
		b/=2;
		a*=a;
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	vector <vll> dp(n+1, vll (13));
	dp[0][0] = 1;
	for(int i = 0; i < n; i++){
		if(s[i] != '?'){
			int d = s[i] - 48;
			for(int j = 0; j < 13; j++){
				dp[i+1][(10*j+d)%13]+=dp[i][j];
				dp[i+1][(10*j+d)%13]%=mod;
			}
		}
		else{
			for(int d = 0; d < 10; d++){
				for(int j = 0; j < 13; j++){
					dp[i+1][(10*j+d)%13]+=dp[i][j];
					dp[i+1][(10*j+d)%13]%=mod;
				}
			}
		}
	}
	cout << dp[n][5] << "\n";
	return 0;
}


Measured memory_bytes: 13648
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, a[1009];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += a[i];
    }
    cout << ans << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 3660
n, a, b = map(int, input().split())

def jud(n,a,b):
    distance_dic_before_a = []
    distance_dic_before_b = []
    distance_dic_before_a.append(a)
    distance_dic_before_b.append(b)

    turn_count = 1
    while True:
        distance_dic_after_a = []
        for a_dir in distance_dic_before_a:
            a_dir_plus = a_dir + 1
            a_dir_minus = a_dir - 1
            if a_dir_plus > n:
                a_dir_plus = n
            if a_dir_minus == 0:
                a_dir_minus = 1
            distance_dic_after_a.append(a_dir_plus)
            distance_dic_after_a.append(a_dir_minus)
        distance_dic_before_a = distance_dic_after_a

        distance_dic_after_b = []
        for a_dir in distance_dic_before_b:
            a_dir_plus = a_dir + 1
            a_dir_minus = a_dir - 1
            if a_dir_plus > n:
                a_dir_plus = n
            if a_dir_minus == 0:
                a_dir_minus = 1
            distance_dic_after_b.append(a_dir_plus)
            distance_dic_after_b.append(a_dir_minus)
        distance_dic_before_b = distance_dic_after_b

        set_a = set(distance_dic_after_a)
        set_b = set(distance_dic_after_b)
        print(set_a, set_b)
        result_set = set_a & set_b
        if len(result_set) > 0:
            return turn_count

        turn_count +=1

def jud_2(n,a,b):
    if abs(a-b) % 2 == 0:
        return abs(a-b) // 2
 
    x = n - a
    y = b - 1
 
    if x > y:
        choice_1 = a-1+1 + (y-a) // 2
        if choice_1 > y:
            return y
        else:
            return choice_1
    else:
        choice_2 = n-b+1 + (x-(n-b+1)) // 2
        if choice_2 > x:
            return x
        else:
            return choice_2
# print(jud(n, a, b))
print(jud_2(n,a,b))

Measured memory_bytes: 3064
n = int(input())
a = []
b = []
for i in range(n):
    s, t = map(int, input().split())
    a.append(s)
    b.append(t)
ans = 0
k = 0
for i in range(n-1,-1,-1):
    if (a[i]+k) % b[i] == 0:
        continue
    else: 
        l = b[i] - (a[i]+k) % b[i]
        ans += l
        k += l
print(ans)


Measured memory_bytes: 11052
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, cnt = 1;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
        if(l[i]%2 == 0) cnt *= 2;
    }
    cout << pow(3, n) - cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,a[N],num[N],ts=0;
int main(){
	ll i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		num[a[i]]++;
	}
	for(i=0;i<=n;i++)
	{
		ts+=num[i]*(num[i]-1)/2;
	}
	for(i=0;i<n;i++)
	{
		cout<<ts-num[a[i]]+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 4736
import itertools
import bisect

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_sum = [0] + list(itertools.accumulate(A))
b_sum = [0] + list(itertools.accumulate(B))

ans= 0

for i in range(n+1):
    if a_sum[i] > k:
        break
    tmp = bisect.bisect_right(b_sum, k - a_sum[i]) -1
    if i + tmp > ans:
        ans = i + tmp

print(ans)


Measured memory_bytes: 128952
n = int(input())
a = input()

nums = list(map(int, a.split()))

alice = []
bob = []
for na in range(int(n)):
    if na == 0 or na % 2 == 0:
        maxn = max(nums)
        alice.append(maxn)
        nums.remove(maxn)
    else:
        maxn = max(nums)
        bob.append(maxn)
        nums.remove(maxn)

print(sum(alice) - sum(bob))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 2000000000
#define PI 3.14159265358979323846
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	long long a;
	string s;
	cin >> a >> s;
	long long b=100*(s[0]-'0')+10*(s[2]-'0')+(s[3]-'0');
	long long c=a*b;
	c/=100;
	cout << c << '\n';
}

Measured memory_bytes: 3652
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 8 * 1000 * 1000 + 200;
const int MAXN = 4 * 1000 * 100 + 20;
const int MLOG = 18;
const int NMAX = 20;

map<int, int> dp;

int DP(int x){
	if(dp[x]) return dp[x];
	dp[x] = (DP(x / 2) + DP((x - 1) / 2) + DP(x / 2 - 1)) % MOD;
	return dp[x];
}

signed main(){
	IO;
	dp[0] = 1;
	dp[1] = 2;
	int n;
	cin >> n;
	cout << DP(n);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double ans1 = Math.ceil(n / 1.08);
        if((int)(ans1 * 1.08) == n) {
            System.out.println((int)ans1);
        } else {
            System.out.println(":(");
        }
    }
}

Measured memory_bytes: 35868
use std::io::stdin;fn main(){let result:Vec<u32> = [1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692].to_vec();let mut st = String::new();stdin().read_line(&mut st).unwrap();let k = st.trim().parse::<usize>().unwrap();println!("{:?}",result[k-1]);}

Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	int n,k,a,c[10]={};
	string s;
	stringstream ss;
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		cin>>a;
		c[a]++;
	}
	for(int i=n;i<=1000000;i++)
	{
		ss<<i;
		ss>>s;
		ss.clear();
		bool flag=true;
		for(int j=0;j<s.length();j++)
		{
			if(c[s[j]-'0'])flag=false;
		}
		if(flag)
		{
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 900
n=int(input())
a=list(map(int,input().split()))
dp=[[0]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
    for l in range(n+1):
        r=i+l
        if r>n:
            continue
        if (n-i)%2==0:
            dp[l][r]=max(dp[l+1][r]+a[l],dp[l][r-1]+a[r-1])
        else:
            dp[l][r]=min(dp[l+1][r]-a[l],dp[l][r-1]-a[r-1])
print(dp[0][n])

Measured memory_bytes: 144792
import Control.Monad

main = do
    n <- readLn
    txy <- replicateM n $ map read . words <$> getLine
    putStrLn $ if analyze ([0, 0, 0] : txy) then "Yes" else "No"

analyze [a, b] = reachable a b
analyze (a : b : xs) = reachable a b && analyze (b : xs)

reachable [t1, x1, y1] [t2, x2, y2] =
    (dt >= dx + dy) && (mod (dt - dx - dy) 2 == 0)
    where dt = t2 - t1; dx = abs(x2 - x1); dy = abs(y2 - y1)

Measured memory_bytes: 81276
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>A>>B>>K;
    ll ri = K - A - B;
    S = "Yes";
    if(ri <= 0) S = "No";
    ri = ri * ri;
    if(4 * A * B >= ri ) S = "No";
    cout<<S<<endl;
}

Measured memory_bytes: 256
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
int main() {
    cout.precision(10);
    cout<<fixed;
    ld R;
    cin >> R;
    ld PI=M_PI;
    cout << 2.0*R*PI<<endl;
}

struct Vec{
    double v[2];
    string to_s(){
        return "("+to_string(v[0])+","+to_string(v[1])+")";
    }
    double& operator[](int t){
        return v[t];
    }
    Vec operator+(Vec t) {
        return {v[0]+t[0],v[1]+t[1]};
    }
    Vec& operator+=(Vec t) {
        v[0]+=t[0];v[1]+=t[1];
        return *this;
    }
    Vec operator-(Vec t) {
        return {v[0]-t[0],v[1]-t[1]};
    }
    Vec& operator-=(Vec t) {
        v[0]-=t[0];v[1]-=t[1];
        return *this;
    }
    Vec operator*(double t) {
        return {v[0]*t,v[1]*t};
    }
    Vec& operator*=(double t) {
        v[0]*=t;v[1]*=t;
        return *this;
    }
    double operator*(Vec t) {
        return v[0]*t[0]+v[1]*t[1];
    }
    Vec operator-(){
        return {-v[0],-v[1]};
    }
    static Vec Z;
};
Vec Vec::Z={0,0};


Measured memory_bytes: 3792
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  int A, ans = X;
  rep(i,0,N-1) {
    cin >> A;
    ans += (D + A - 1) / A;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int i,j,cnt;
  int n,T;
  cin>>n>>T;
  int t[n];
  for(i=0;i<n;i++)cin>>t[i];
  int mi=INT_MAX,ma=0;
  for(i=0;i<n;i++){
    mi=min(mi,t[i]);
    ma=max(ma,t[i]);
  }
  cnt=0;
  for(i=0;i<n-1;i++){
    if(t[i+1]-t[i]-T>0)cnt+=t[i+1]-t[i]-T;
  }
  cout<<T+ma-mi-cnt;
}

Measured memory_bytes: 1024
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    long long A,B;cin >> A >> B;
    vector<long long> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    long long left = -1,right = 1000000007;
    while(right - left > 1){
        long long mid = left+(right-left)/2;
        //mid回攻撃する
        long long blast = B*mid;
        long long attackRemain = mid;
        bool ok = true;
        for(int i = 0;i<N;i++){
            if(retu.at(i) <= blast) continue;
            attackRemain -= ceil((retu.at(i)-blast + A-B-1)/(A-B));
        }
        if(attackRemain < 0) ok = false;
        if(ok){
            right = mid;
        }
        else{
            left = mid;
        }
    }
    cout << right << endl;
}

Measured memory_bytes: 4000
// 69

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long;


int main(){
    int n;
    cin >> n;
    switch (n%10){
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
        default:
            cout << "hon" << endl;
            break;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main()
{
    int p, q, r;
    cin >> p >> q >> r;
    cout << min(p + q, min(q + r, r + p));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int mod = 1e9+7;

int main(){
    //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
    
    int n, m;
    
    cin>>n>>m;
    ++n;
    
    ll ans = 0;
    for(int k=m;k<=n;++k){
        ll c = (n-k-1LL) * k + k + 1;
        ans = (ans + c) %mod;
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3652
using System;

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

        var d = new int[n];
        var s = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            d[i] = int.Parse(s[i]);
        }

        var max_i = 0;
        var sum = 0;
        for (int i = 0; i < n; i++)
        {
            sum += d[i];
            if (d[max_i] < d[i])
            {
                max_i = i;
            }
        }

        if (d[max_i] < sum - d[max_i]) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

int main(){
	int i, j, k, n, array[100];

	scanf("%d", &n);
	for(i = 0; i < n; i++)  scanf("%d", &array[i]);  
	for(i = 0; i < n; i++){
		j = i;
		while(j > 0 && array[j] < array[j-1]){
			k = array[j];
			array[j] = array[j-1];
			array[j-1] = k;
			j--;
		}
		for(j = 0; j < n-1; j++)  printf("%d ", array[j]);
		printf("%d\n", array[n-1]);
	}
	
	return 0;
}

Measured memory_bytes: 600
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long k = scanner.nextLong();
		Map<Integer, Long> map = new TreeMap<>();

		for (int i = 0; i < n; i++) {
			int a = scanner.nextInt();
			long b = scanner.nextLong();
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + b);
			} else {
				map.put(a, b);
			}
		}

		long bSum = 0;
		for (int a : map.keySet()) {
			bSum += map.get(a);
			if (bSum >= k) {
				System.out.println(a);
				return;
			}
		}
	}
}

Measured memory_bytes: 95880
#include <bits/stdc++.h>
#define LL long long
#define F(i, a, b) for(int i = a; i <= b; ++i)

using namespace std;

const int maxn = 1e5 + 5;
int n, m, cnt[maxn];
bool able[maxn];

int main()
{
	scanf("%d%d", &n, &m);
	able[1] = true;
	F(i, 1, n) cnt[i] = 1;
	F(i, 1, m)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		able[y] |= able[x];
		--cnt[x], ++cnt[y];
		if(cnt[x] == 0) able[x] = false;
	}
	int ans = 0;
	F(i, 1, n) if(able[i]) ++ans;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 4240
use std::io::prelude::*;

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn max_index(vs: Vec<i64>) -> (usize, i64) {
    let mut max = (0, std::i64::MIN);
    for (i, v) in vs.iter().enumerate() {
        if v > &max.1 {
            max = (i, *v);
        }
    }
    max
}

fn main() {
    let n: usize = input();
    let mut  a_s: Vec<i64> =
        (0..n).map(|_| input()).collect();

    let b = a_s.clone();
    let (u, _) = max_index(a_s.clone());
    a_s.remove(u);
    let (mut v, _) = max_index(a_s);
    if v >= u {
        v+=1;
    }
    for i in 0..n {
        if u != i {
            println!("{}", b[u]);
        } else {
            println!("{}", b[v]);
        }
    }
}

Measured memory_bytes: 10492
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include<iomanip>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  string ans = "";
  for(int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      ans += '0';
    } else if (s[i] == '1') {
      ans += '1';
    } else {
      if (ans != "") {
        ans.pop_back();
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = input()
S = input()

n = int(N)
tmp = ""
dic = {}
ans = 0

for i in range(n):
    tmp += S[i]
    dic_tmp = [False for i in range(123 - 97)]
    dic = [False for i in range(123 - 97)]

    for j in tmp:
        dic_tmp[ord(j) - 97] = True

    for j in range(i + 1, n):
        dic[ord(S[j]) - 97] = True

    ct = 0
    for k in range(len(dic)):
        if dic_tmp[k] == True and dic[k] == True:
            ct += 1

    ans = max(ans, ct)

print(ans)





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

int main(){
    int n; cin >> n;
    int tmp = n%10;
    
    if(tmp == 2 || tmp == 4 || tmp == 5 || tmp == 7 || tmp == 9) cout << "hon" << endl;
    else if(tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8) cout << "pon" << endl;
    else if(tmp == 3) cout << "bon" << endl;
}

Measured memory_bytes: 3636
n=int(input())
a=list(map(int,input().split()))
d={}
for i in a:
  if i in d:
    d[i]+=1
  else:
    d[i]=0
s=sum(d.values())
if s%2==0:
  print(n-s)
else:
  print(n-s-1)

Measured memory_bytes: 18080
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

x,y=get_i
if x==y
    puts 0
elsif x.abs==y.abs
    puts 1
else
    if x>=0 and x<y
        puts y-x
    elsif x<0 and x>y
        puts (y-x).abs+2
    elsif y>0 and x>y
        puts x-y+2
    elsif y<=0 and x<y
        puts y-x
    elsif x.abs>y.abs
        puts (x.abs-y.abs)+1
    elsif x.abs<y.abs
        puts (y.abs-x.abs)+1
    end
end

Measured memory_bytes: 1788
void main()
{
    long n = readln.chomp.to!long;

    bool[] cards = new bool[n];
    long pair;
    foreach (i; 0 .. n)
    {
        long a = readln.chomp.to!long;
        if (i > 0 && cards[i-1] && a > 0)
        {
            ++pair;
            --a;
        }
        pair += a / 2;
        cards[i] = a % 2 == 1;
    }

    pair.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 1404
#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 N, M;


int main(){
    cin >> N >> M;
    vector<ll> H(N, 0);
    vector<ll> N_cnt(N, 0);
    rep(i, N){ cin >> H.at(i);}

    set<ll> st;
    vector<ll> black_list(N, 0);

    vector<P> michi(M);
    rep(i, M){
        cin >> michi.at(i).first >> michi.at(i).second;
        N_cnt[michi.at(i).first-1]++;
        N_cnt[michi.at(i).second-1]++;

        // ペアごとにデカい方を取る
        ll fst=michi.at(i).first;
        ll scd=michi.at(i).second;

        if(H.at(fst-1)==H.at(scd-1)){
            st.erase(fst);
            st.erase(scd);
            black_list[fst-1]++;
            black_list[scd-1]++;
        }
        else if (H.at(fst-1)>H.at(scd-1)){
            if (black_list[fst-1] == 0) st.insert(fst);
            st.erase(scd);
            black_list[scd-1]++;
        }else if (H.at(fst-1)<H.at(scd-1)){
            if (black_list[scd-1] == 0) st.insert(scd);
            st.erase(fst);
            black_list[fst-1]++;
        }
    }

    // カウントされていない山を加算
    ll count = 0;
    rep(i, N){
        if(N_cnt.at(i)==0) count++;
    }
    cout << count + st.size() << endl;
    return 0;
}

Measured memory_bytes: 8720
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        L=list(map(int,input().split()))
        if L==[1,1,1]:
            return 0
        elif L[0]==L[1] and L[1]==L[2]:
            return -1
        S=sum(L)
        cnt=0
        while True:
            for i in range(3):
                if (S-L[i])%2==0:
                    L[i]=(S-L[i])//2
                else:
                    return cnt
            cnt+=1
    print(main())


resolve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; ++i) {
    if(n % i == 0) {
      res.push_back(i);
      if(i * i != n) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> div = divisor(n);
  ll ans = 0;
  rep(i, div.size()) {
    ll t = n / div[i] - 1;
    if(t == 0) continue;
    if(n % t == n / t) ans += t;

  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <cstdio>
using namespace std;
int main ()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int flag_5=0,flag_7=0;
    if(a==5)
        flag_5++;
    if(b==5)
        flag_5++;
    if(c==5)
        flag_5++;
    if(a==7)
        flag_7++;
    if(b==7)
        flag_7++;
    if(c==7)
        flag_7++;
    if(flag_5==2||flag_7==1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


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

int main()
{
	int a, b;

	cin >> a >> b;

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

	cout << d << ' ' << r << ' ' << fixed << f << '\n';

	return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    cout << max(0, C - (A - B)) << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
s1=""
for i in range(n//2):
  s1+="01"
if n%2>0:
  s1+="0"
ans1=0
for i in range(n):
  if s[i]!=s1[i]:
    ans1+=1
s2=""
for i in range(n//2):
  s2+="10"
if n%2>0:
  s2+="1"
ans2=0
for i in range(n):
  if s[i]!=s2[i]:
    ans2+=1
print(min(ans1,ans2))

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int nth_bit(ll num, int n){
    return (num >> n) & 1;
}
 
int main(){
    int N;
    ll K, A[100000];
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> A[i];
    
    // 0: ans <= K not ensured, 1: ans <= K ensured
    ll dp[2] = {0LL, (ll)-1e18};
 
    for(int d=40; d>=0; d--){
        ll D = 1LL << d;
        
        int num1 = 0;
        for(int i=0; i<N; i++) if(nth_bit(A[i], d)) num1++;
        int num0 = N - num1;
 
        dp[1] += D * max(num0, num1);

        if(nth_bit(K, d)){
            // when K=1, select 0
            dp[1] = max(dp[1], dp[0] + D * num1);
            // select 1
            dp[0] += D * num0;
        }else{
            // 0 -> 1 not allowed
            dp[0] += D * num1;
        }
    }
 
    cout << max(dp[0], dp[1]) << endl;
}

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

int main() {
    int N, H, W;
    cin >> N >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << endl;
}


Measured memory_bytes: 768
#include <stdio.h>
    #include<string.h>
    int main(void) {
      int i,j,A,cou;
      char S[101];
      scanf("%s",S);
      A=strlen(S);
      for(i=1;i<A-1;i++){
          cou++;
      }
      printf("%c%d%c",S[0],cou,S[A-1]);
      return 0;
    }

Measured memory_bytes: 128
def main():
    import sys
    input = sys.stdin.buffer.readline
    H, W = (int(i) for i in input().split())
    c = [[int(i) for i in input().split()] for j in range(10)]
    A = [[int(i) for i in input().split()] for j in range(H)]
    import numpy as np
    from scipy.sparse import csr_matrix
    from scipy.sparse.csgraph import dijkstra
    csr = csr_matrix(c, dtype=np.int32)
    ret = dijkstra(csr)
    ans = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] == -1:
                continue
            cur = A[h][w]
            ans += int(ret[cur][1])
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

int main() {
    int x,n;
    cin>>x>>n;
    vector<int> v(4001,0);
    for(int i = 0;i < n;++i) {
        int p;
        cin>>p;
        ++v[p+100];
    }
    x+=100;
    for(int i = 0;i < 200;++i) {
        if(v[x-i]==0){
            cout<<x-i-100<<endl;
            return 0;
        }
        if(v[x+i]==0){
            cout<<x+i-100<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <bitset>
using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define ZERO(a) memset(a, 0, sizeof(a))

#define RAD(d) (PI * (d) / 180)
#define DEG(r) (180.0 * (r) / PI)

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<class T> void dump(const vector<T> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

template<class T> void dump(int w, int h, const vector<T> &v)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

template<class T> T accumulate(const vector<T> &v)
{
	T sum = 0;
	REP(i, SZ(v)){ sum += v[i]; }
	return sum;
}

template<class T> struct Matrix
{
	T w, h;
	vector<T> A;
	Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {}
	T get(T x, T y) const { return A[y * w + x]; }
};

template<class T> void input(Matrix<T> &m)
{
	REP(j, m.h){
		REP(i, m.w){
			cin >> m.A[j * m.w + i];
		}
	}
}

template<class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b)
{
	Matrix<T> m(b.w, a.h);

	REP(j, m.h){
		REP(i, m.w){
			ll c = 0;
			REP(k, a.w){
				c += a.A[j * a.w + k] * b.A[k * b.w + i];
			}
			m.A[j * m.w + i] = c;
		}
	}

	return m;
}

void dump(const Matrix<ll> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%lld ", m.A[j * m.w + i]); }
		printf("%lld\n", m.A[j * m.w + m.w-1]);
	}
}

void dump(const Matrix<double> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%f ", m.A[j * m.w + i]); }
		printf("%f\n", m.A[j * m.w + m.w-1]);
	}
}

string &to_upper(string &s)
{
	REP(i, s.length()){
		if('a' <= s[i] && s[i] <= 'z'){
			s[i] -= 32;
		}
	}

	return s;
}

string &to_lower(string &s)
{
	REP(i, s.length()){
		if('A' <= s[i] && s[i] <= 'Z'){
			s[i] += 32;
		}
	}

	return s;
}

// すべての約数を列挙する
template <class T> vector<T> get_divisors(T n)
{
	vector<T> ret;
	for(T i = 1; i * i <= n; i++){
		if(n % i == 0){
			ret.push_back(i);
			if(i * i != n)
				ret.push_back(n / i);
		}
	}
	sort(ALL(ret));
	return ret;
}

// 1-sqrt(N)までの約数を列挙する
template <class T> vector<T> get_divisors2(T n)
{
	vector<T> ret;
	for(T i = 1; i * i <= n; i++){
		if(n % i == 0){
			ret.push_back(i);
		}
	}
	return ret;
}

int main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int min_cost = 0x7FFFFFFF;

	for(int k = 0; k <= max(X, Y); k++){
		int cost = 2 * C * k + A * max(0, X - k) + B * max(0, Y - k);
		chmin(min_cost, cost);
	}

	cout << min_cost << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	int n, ans;

	int dfs(int pos, int sum, int before) {
		int ret = 0;
		if(pos == 0 && sum == ans) return(1);
		if(pos < 0 || before > 9 || sum > ans) return(0);
		
		for(int r =before; r< 10; r++) {
			ret += dfs(pos - 1, sum + r, r + 1);
		}
		return(ret);
	}

	void doIt()  {
		Scanner stdIn = new Scanner(System.in);

		while(true) {
			n = stdIn.nextInt();
			ans =stdIn.nextInt();
			if(n + ans == 0) break;

			System.out.println(dfs(n, 0, 0));
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}

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

int main(void){
	int N,s;
	cin>>N;
	map<int,bool> dp;
	dp[0]=true;
	rep(i,N){
		cin>>s;
		for(auto it=dp.rbegin();it!=dp.rend();++it){
			dp[it->first + s]=true;
		}
	}
	for(auto it=dp.rbegin();it!=dp.rend();++it){
		if(it->first%10){
			cout<<it->first<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long n,m;
int main()
{
	cin>>n>>m;
	if(n%m==0) cout<<"0";
	else if(n<m)
	{
		if(n<m-n) cout<<n;
		if(n>=m-n) cout<<m-n;
	}
	else
	{
		n%=m;
		if(n>m-n)
		{
			n=m-n;
			//cout<<abs(n-m)<<endl;
		}
		cout<<n<<endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	if (A+B+C >= 22){
	cout << "bust" << "\n";
 	} else {
	cout << "win" << "\n";

 	}



	return 0;
}


Measured memory_bytes: 3616
/**
 * @author karayuu
 */

fun main(args: Array<String>) {
  val n = readLine()!!
  var x = 0
  var max = 0
  val s = readLine()!!

  s.forEach {
    when (it) {
      'I' -> x++
      'D' -> x--
    }
    max = Math.max(max, x)
  }

  println(max)
}


Measured memory_bytes: 34200
using System;

namespace ABC080_A_Parking
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int n = int.Parse(input[0]);
			int a = int.Parse(input[1]);
			int b = int.Parse(input[2]);

			if (a * n > b)
			{
				Console.WriteLine(b);
			}
			else
			{
				Console.WriteLine(a * n);
			}
		}
	}
}

Measured memory_bytes: 13140
# -*- coding: utf-8 -*-
N = int(input())
S = input()


def calcCountUnion(X, Y):
    counter = 0
    for key in X.keys():
        if key in Y.keys():
            counter += 1
    return counter


def str2dict(S):
    X = {}
    Y = {}
    for a in S:
        X[a] = X[a] + 1 if (a in X.keys()) else 1
    return X, Y


def calcMaxCutCount(S):
    X, Y = str2dict(S)
    maxCutCount = 0
    for a in S:
        X[a] = X[a] - 1
        Y[a] = X[a] + 1 if (a in X.keys()) else 1
        if X[a] <= 0:
            X.pop(a)
        tmp = calcCountUnion(X, Y)
        maxCutCount = max((tmp, maxCutCount))
    return maxCutCount


print(calcMaxCutCount(S))


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [tuple(map(int,input().split())) for i in range(Q)]
from collections import Counter
ctr = Counter(A)
sm = sum(A)

ans = []
for b,c in BC:
    if ctr[b] == 0:
        ans.append(sm)
        continue
    sm += (c-b) * ctr[b]
    ctr[c] += ctr[b]
    ctr[b] = 0
    ans.append(sm)
print(*ans, sep='\n')

Measured memory_bytes: 33784
#!/usr/bin/env python3
import bisect

INF = 10 ** 18


def solve(s,t,x):
  ans = [0]*len(x)
  for i in range(len(x)):
    b = bisect.bisect_right(s,x[i])
    d = bisect.bisect_right(t,x[i])
    res = INF
    for S in [s[b-1],s[b]]:
      for T in [t[d-1],t[d]]:
        res = min(res,abs(S-x[i]) + abs(T-S),abs(T-x[i])+abs(T-S))
    ans[i] = res
  return ans



def main():
  A,B,Q = map(int,input().split())
  s = [-10**18] + [int(input()) for _ in range(A)] + [10**18]
  t = [-10**18] + [int(input()) for _ in range(B)] + [10**18]
  x = [int(input()) for _ in range(Q)]
  ans = solve(s,t,x)
  for i in range(Q):
    print(ans[i])
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 26332
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;
int main() {
	int A, A2, B, B2;
	cin >> A >> A2 >> B >> B2;
	if (A == B - 1) {
		cout << "1";
	}
	else {
		cout << "0";
	}
}

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


void solve(std::string S, std::string T){
    int cnt = 0;
    rep(i, 3)
    {
        if(S[i] == T[i])
            cnt++;
    }
    cout << cnt << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

vector<vector<int>> t(100001);
vector<bool> close(100001,false);
queue<LL> fen,snu;

LL fnum,snum;


LL bfs(){
    while(!fen.empty() || !snu.empty()){
        for(int j = fen.size(); j > 0; j--){
            LL tmp = fen.front();
            fen.pop();
            for(int i = 0; i < t[tmp].size(); i++){
                if(!close[t[tmp][i]]){
                    fen.push(t[tmp][i]);
                    fnum++;
                    close[t[tmp][i]] = true;
                }
            }
        }
        for(int j = snu.size(); j > 0; j--){
            LL tmp = snu.front();
            snu.pop();
            for(int i = 0; i < t[tmp].size(); i++){
                if(!close[t[tmp][i]]){
                    snu.push(t[tmp][i]);
                    snum++;
                    close[t[tmp][i]] = true;
                }
            }
        }
    }
}


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

    LL n;
    cin >> n;


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

    close[1] = close[n] = true;
    fen.push(1);
    snu.push(n);

    fnum = 0;
    snum = 0;

    bfs();

    if(fnum > snum){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }

    return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<math.h>
#include<string>
#include<utility>
#include<queue>
#include<stdlib.h>
#define FOR(i,a,b,c) for(int i=a;i<b;i+=c)
using namespace std;
typedef pair<int, int> P;
int main() {
	int n, s[100001], t[50001], q, ans = 0, fi = 0;
	cin >> n;
	FOR(i, 0, n, 1)cin >> s[i];
	cin >> q;
	FOR(i, 0, q, 1)cin >> t[i];
	FOR(i, 0, q, 1) {
		if (*lower_bound(s, s + n, t[i]) == t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
import java.util.*;
import static java.lang.System.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int ans=0;
int k = Integer.parseInt(sc.next());
int s = Integer.parseInt(sc.next());
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            int z=s-i-j;
            if(0<=z&&z<=k)ans++;
        }
    }
    out.println(ans);
}}

Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(n);re(i, n) std::cin >> a[i];
  ll ans = 1000000000000000;
  for(int i=-100;i<=100;i++){
    ll tmp = 0;
    for(int j=0;j<n;j++){
      tmp += (a[j]-i)*(a[j]-i);
    }
    ans = min(ans, tmp);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
C, S, F = list(range(N)), list(range(N)), list(range(N))
for i in range(N-1):
    C[i], S[i], F[i] = map(int, input().split(' '))

import math
for c in range(N):
    ret = 0
    for next_c in range(c, N-1):
        if ret <= S[next_c]:
            ret = S[next_c]

        else:
            i = int(math.ceil((ret - S[next_c]) / F[next_c]))
            ret = S[next_c] + F[next_c] * i

        ret += C[next_c]

    print(ret)




Measured memory_bytes: 42844
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toLong)
    val hList = mutableListOf<Long>()
    for (i in 1..n) {
        hList.add(readLine()!!.toLong())
    }
    hList.sort()
    var sa = Long.MAX_VALUE

    for (i in 0..(n - k)) {
        sa = Math.min(sa, hList[i.toInt() + k.toInt() - 1] - hList[i.toInt()])
    }
    print(sa)
}


Measured memory_bytes: 49168
#include<stdio.h>

long double dp[301][301][301];

int n;
int a4;
long double RG(int  n1,int n2,int n3)
{
	         if(n1<0||n2<0||n3<0) return 0;

	if(dp[n1][n2][n3]>=0)
		return dp[n1][n2][n3];
	long long  x=n1+n2+n3;
	

	if(n1==0&&n2==0&&n3==0) return dp[n1][n2][n3]= 0;
	return dp[n1][n2][n3]= (n*1.0/(n1+n2+n3)*1.0)*1.0+
		((n1*1.0/x*1.0)*1.0*RG(n1-1,n2,n3)+(n2*1.0/x*1.0)*(1.0)*RG(n1+1,n2-1,n3)+(n3*1.0/x*1.0)*(1.0)*RG(n1,n2+1,n3-1));
}

signed main()
{
	
	scanf("%d",&n);
	int a1=0,a2=0,a3=0;
	long long k=(long long) n;
	for(int i=0;i<=300;i++)
	{
		for(int j=0;j<301;j++)
		{
			for(int y=0;y<=300;y++)
			{
				dp[i][j][y]=-1.0;
			}
		}
	}
	
	for(long long  i=0;i<k;i++)
	{
		scanf("%d",&a4);
		if(a4==1)a1++;
		if(a4==2)a2++;
		if(a4==3)a3++;

	}
	printf("%0.10Lf\n",RG(a1,a2,a3));
}


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

left = a[-1]
sa = 199999999999999999999999999
for i in range(n):
  if sa > abs((left/2) -a[i]):
    right = a[i]
    sa = abs((left/2) - a[i])
    
print(left, right)

Measured memory_bytes: 14428
import fractions

N=int(input())
A=list(map(int, input().split()))

X=[0]*N
X[1]=A[0]
for i in range(2, N):
  X[i]=fractions.gcd(X[i-1], A[i-1])

Y=[0]*N
Y[-2]=A[-1]
for i in range(N-3, -1, -1):
  Y[i]=fractions.gcd(Y[i+1], A[i+1])
  
X[0]=Y[0]
Y[-1]=X[-1]

Z=[fractions.gcd(X[i], Y[i]) for i in range(N)]
    
print(max(Z))

Measured memory_bytes: 16124
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
using ld=long double;
const ld eps=1e-10;
int main(){
    ll n;cin >> n;
    vector<pair<ld,ld>> e(n);
    rep(i,n){
        cin >> e[i].fi >> e[i].se;
    }
    vector<pair<ld,int>> rad(n);
    rep(i,n){
        rad[i].fi=atan2(e[i].se,e[i].fi);
        rad[i].se=i;
    }
    sort(all(rad));
    rep(i,n)rad.pb(rad[i]);
    ld ans=0;
    rep(i,n){
        repl(j,i,i+n){
            ld x=0,y=0;
            for(int k=i;k<=j;k++){
                x+=e[rad[k].se].fi;
                y+=e[rad[k].se].se;
            }
            chmax(ans,sqrt(x*x+y*y));
        }
    }
    CST(12);
    cout << ans <<endl;
} 

Measured memory_bytes: 3812