akhauriyash/Code-Regression huggingface dataset:
#include<vector>
#include<algorithm>
#include<iostream>
template<class F>
auto  minimize_bsearch(int imin,int imax,F &f,int sy,int sx, int base){ //(imin,imax]
    while(imax - imin > 1){
        int mid = imin + (imax - imin)/2;
        if(f(mid,base,sy,sx)) imax = mid;
        else imin = mid;
    }
    return imax; //imax is ans
}

template<class F>
auto  maximize_bsearch(int imin,int imax,F &f,int sy,int sx,int base){ //[imin,imax)
    while(imax - imin > 1){
        int mid = imin + (imax - imin)/2;
        if(f(mid,base,sy,sx)) imin = mid;
        else imax = mid;
    }
    return imin; //imin is ans
}

signed
main(){
    int H,W;
    std::cin >> H >> W;
    std::vector<std::string>graph(H);
    for(auto & str : graph)
        std::cin >> str;
    std::vector<std::vector<int>>hsum(H,std::vector<int>(W,0));
    std::vector<std::vector<int>>wsum(H,std::vector<int>(W,0));
    for(int i = 0; i < graph.size(); ++i){
        wsum[i][0] = (graph[i][0] == '.' ? 0 : -1);
        for(int j = 1; j < W;++j){
            if(graph[i][j-1] == '.' and graph[i][j] == '.')
                wsum[i][j] += wsum[i][j-1] + 1;
            else if(graph[i][j] == '.' and graph[i][j-1] == '#')
                wsum[i][j] = 0;
        }
    }
    for(int j = 0; j < W; ++j){
        hsum[0][j] = (graph[0][j] == '.' ? 0 : -1);
        for(int i = 1; i < H;++i){
            if(graph[i-1][j] == '.' and graph[i][j] == '.')
                hsum[i][j] += hsum[i-1][j] + 1;
            else if(graph[i][j] == '.' and graph[i-1][j] == '#')
                hsum[i][j] = 0;
            
        }
    }
    auto xmaxi_f = [&](int mid,int base,int sy,int sx){ return (mid - sx == wsum[sy][mid] - base);};
    auto xmini_f = [&](int mid,int base,int sy,int sx){ return (sx - mid == base - wsum[sy][mid]);};
    auto ymaxi_f = [&](int mid,int base,int sy,int sx){ return (mid - sy == hsum[mid][sx] - base);};
    auto ymini_f = [&](int mid,int base,int sy,int sx){ return (sy - mid == base - hsum[mid][sx]);};
    
    auto subcalx = [&](int sy, int sx){
        int base = wsum[sy][sx];
        int rx = maximize_bsearch(sx-1,W,xmaxi_f,sy,sx,base);
        int lx = minimize_bsearch(-1, sx,xmini_f, sy, sx, base);
        return (rx - lx);
    };
    auto subcaly = [&](int sy, int sx){
        int base = hsum[sy][sx];
        int ry = maximize_bsearch(sy-1,H,ymaxi_f,sy, sx, base);
        int ly = minimize_bsearch(-1,sy,ymini_f,sy, sx, base);
        return (ry - ly);
    };
    auto cal = [&](int sy,int sx){
        return subcalx(sy,sx) + subcaly(sy,sx);
    };
    int maxi = -1;
    for(int sy = 0; sy < H; sy++){
        for(int sx = 0; sx < W;sx++){
            if(graph[sy][sx] == '#') continue;
            int cnt = cal(sy,sx) + 1;
            maxi = std::max(maxi,cnt);
        }
    }
    std::cout << maxi << std::endl;
}


Measured memory_bytes: 35712
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin>>n;
  int a;
  vector<long long>v1;
  vector<long long>v2;
  
  map<long long,int>m;
  
  for(int i=0;i<n;i++){
    cin>>a;
    v1.push_back(a-i);
    v2.push_back(-a-i);
    m[-a-i]++;
  }
  long long ans=0;
  /*for(int i=0;i<n;i++){
    cout<<v1[i]<<" ";
  }
  cout<<endl;
  for(int i=0;i<n;i++){
    cout<<v2[i]<<" ";
  }
  cout<<endl;
*/

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

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

  auto it=lower_bound(v2.begin(),v2.end(),v1[i]);

  if(it!=v2.end()){
    int pos=it-v2.begin();
    if(v2[pos]==v1[i]){
       ans+=m[v1[i]];
    }
  }
 }
 cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 18840
use std::collections::HashSet;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut set = HashSet::new();
    for _ in 0..n {
        let s:String = read();
        set.insert(s);
    }
    println!("{}", if set.len() == 3 {"Three"} else {"Four"});
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a.at(i);
    rep(i, n) cin >> b.at(i);
    rep(i, n) cin >> c.at(i);

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    rep(i, n){
        int k = b.at(i);
        auto low_pos = lower_bound(a.begin(), a.end(), k);
        ll low_idx = distance(a.begin(), low_pos);
        ll num_A = (low_pos == a.end()) ? n : (low_idx + 1) - 1;

        auto upper_pos = upper_bound(c.begin(), c.end(), k);
        ll upper_idx = distance(c.begin(), upper_pos);
        ll num_C = (upper_pos == c.end()) ? 0 : n - upper_idx;

        ans += num_A * num_C;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4580
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	ll x;
	cin >> x;
	ll money = 100, year = 0;
	while (money<x)
	{
		money *= 1.01;
		year++;
	}
	cout << year << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    string s;
    int k;
    cin >> s >> k;

    vector<ll> cost_to_a(s.length());

    rep(i, s.length()) {
        ll tmp_cost = 'z' + 1 - s[i];
        
        if ( s[i] == 'a') {
            cost_to_a[i] = 0;
        }
        else if ( tmp_cost > k ) {
            cost_to_a[i] = -1;
        }
        else {
            cost_to_a[i] = tmp_cost;
        }
    }

    ll rest_cost = k;

    rep(i, s.length()) {
        if ( cost_to_a[i] == 0 || cost_to_a[i] == -1 ) {
            continue;
        }
        else if ( cost_to_a[i] > rest_cost ) {
            continue;
        }
        else {
            s[i] = 'a';
            rest_cost -= cost_to_a[i];
        }
    }

    if ( rest_cost > 0 ) {
        s[s.length()-1] = s[s.length()-1] + rest_cost % 26;
    }
        
    if ( s[s.length()-1] > 'z' ) {
        s[s.length()-1] = (char)(s[s.length()-1] - ( 'z' - 'a' ));
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 1408
import java.math.BigDecimal;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = Math.abs(sc.nextLong());
        long K = sc.nextLong();
        long D = sc.nextLong();
        BigDecimal x = new BigDecimal(X);
        BigDecimal k = new BigDecimal(K);
        BigDecimal d = new BigDecimal(D);
        if (X == 0) {
            System.out.println(K%2 == 0 ? 0 : D);
            return;
        }
        if (k.multiply(d).compareTo(x) == -1) {
            System.out.println(X-D*K);
            return;
        } else {
            long near = X/D;
            K -= near;
            X -= D*near;
            System.out.println(K%2 == 0 ? X : Math.abs(X-D));
        }
    }
}

Measured memory_bytes: 35872
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second



int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll m,n,i,f=0,j,ans=0,k,x,r,l,t;
    cin >> n ;
    //temp=n;
    ll val[30];
    val[1]=1;
    ll cnt=0;
    while(n%2==0)
    {
          cnt++;
          n/=2;
    }
    if(cnt)
    {
    for(i=0;;++i)
    {
          if((i*(i+1))/2>cnt) break;
    }
    i--;
    ans+=i;
    //cout << ans << endl ;
    }
    //cout << n << endl ;
    for(i=3;i*i<=n;i+=2)
    {
          cnt=0;
          while(n%i==0)
          {
               cnt++;
               n/=i;
               //cout << i << endl ;
          }
          if(cnt)
          {
          for(j=0;;++j)
                {
                      if((j*(j+1))/2>cnt) break;
                }
                j--;
                ans+=j;
          }
                //cout << ans << endl ;
    }
    if(n>2)
    {
          ans++;
    }
    cout << ans ;
    return 0;
}

Measured memory_bytes: 3652
let readInt () = stdin.ReadLine() |> int
let readCharArray () = stdin.ReadLine().ToCharArray()


readInt ()
|> fun x ->
    readCharArray ()
    |> Array.map int
    |> Array.map ((+) x)
    |> Array.map (fun z -> if z > (int 'Z') then z - 26 else z)
    |> Array.map char
    |> System.String
    |> printfn "%s"


Measured memory_bytes: 29864
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <array>

using namespace std;

#define ll long long
#define all(v) v.begin(),v.end()
#define bootstrap ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
// custom hash can be a standalone function object:
struct MyHash
{
    std::size_t operator()(pair<long, long> const& p) const noexcept
    {
        std::size_t h1 = std::hash<long>{}(p.first);
        std::size_t h2 = std::hash<long>{}(p.second);
        return h1 ^ (h2 << 1); // or use boost::hash_combine (see Discussion)
    }
};

struct MyComp
{
    template<typename T>
    std::size_t operator()(T &l, T &r) const noexcept
    {
        return l < r;
    }
};

void solve() {
    int n;
    cin >> n;
    int l, r;
    bool first, second;
    for(int i = 0; i< n;i++) {
        cin >> l >> r;
        if(l == r) {
            if (!first) {
                first = true;
            } else if (!second) {
                second = true;
            } else {
                cout << "Yes";
                return;
            }
        } else {
            first = false;
            second = false;
        }
    }
    cout << "No";
}

int main() {
    bootstrap
    solve();
}


Measured memory_bytes: 3136
#include<iostream>
using namespace std;
int main(){
  long n,m,sum1=0,sum2=0,b4a,a,ans,mod=1000000007,i;
  cin>>n>>m;
  cin>>b4a;
  for(i=1;i<n;i++){
    cin>>a;
    sum1=(sum1+(a-b4a)*i%mod*(n-i)%mod)%mod;
    b4a=a;
  }
  cin>>b4a;
  for(i=1;i<m;i++){
    cin>>a;
    sum2=(sum2+(a-b4a)*i%mod*(m-i)%mod)%mod;
    b4a=a;
  }
  ans=sum1*sum2%mod;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N,M = list(map(int,input().split()))
A = [int(N) for N in input().split()]

ans = 0

for i in A:
    if i >= sum(A) / 4 / M:
        ans += 1
    else:
        ans += 0

if ans >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
 // freopen("input.txt","r",stdin);
#endif

  int a,b,c;
  cin>>a>>b>>c;
  swap(a,b);
  swap(a,c);
  cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
}

Measured memory_bytes: 3532
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())

S =[]
P = []
for i in range (N):
    s,p1 = [k for k in input().split()]
    p = 100-int(p1)
    
    S.append(s)
    P.append(p)

ls =[i for i in range (1,N+1)]
total = list(zip(S,P,ls))


total.sort()


for i in total:
    print(i[2])

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

public class Main {
    public static String winner(int[] setOfMoves, int K){
        boolean[] dp = new boolean[K+1];
        // false: second player wins
        // true: first player wins
        for (int stones = 0; stones <= K; stones++) {
            for (int choice : setOfMoves)
                if (stones >= choice && !dp[stones - choice]) {
                    dp[stones] = true;
                }
        }

        return dp[K] ? "First" : "Second";
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(reader.readLine());
        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());
        int[] A  = new int[N];
        st = new StringTokenizer(reader.readLine());
        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(st.nextToken());
        }
        System.out.println(winner(A, K));
    }
}


Measured memory_bytes: 23380
#include "bits/stdc++.h"
using namespace std;


int main() {

	int D;

	cin >> D;

	if (D == 25) {
		cout << "Christmas" << endl;
	}
	else if (D == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (D == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (D == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}

	return 0;

}


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

const int N = 1005;

template <typename T>
T __abs(T x) {
	return x < 0 ? -x : x;
}

int n, m, D;
int X[N], Y[N];
int d[40];
map<int, char> G;

int sgn1[40], sgn2[40];

void work(int val, int* sgn) {
	for (int i = 1; i <= m; i++)
		sgn[i] = 1;
	for (int i = m; i; i--) {
		if (val >= d[i]) {
			val -= d[i];
			sgn[i] = -1;
		}
	}
}

int main() {
	scanf("%d", &n);
	G[1 * 2 + 1] = 'R';
	G[-1 * 2 - 1] = 'L';
	G[1 * 2 - 1] = 'U';
	G[-1 * 2 + 1] = 'D';
	for (int i = 1, x, y, tmp; i <= n; i++) {
		scanf("%d%d", &x, &y);
		X[i] = x + y, Y[i] = x - y;
		tmp = __abs(x) + __abs(y);
		if (i > 1 && ((tmp & 1) ^ (D & 1))) {
			puts("-1");
			return 0;
		}
		D = max(D, tmp);
	}
	if (!D)
		D = 2;
	int tmp = D, pw2 = 1;
	while (tmp >= pw2) {
		d[++m] = pw2;
		tmp -= pw2;
		pw2 <<= 1;
	}
	if (tmp)
		d[++m] = tmp;
	printf("%d\n", m);
	for (int i = 1; i <= m; i++)
		printf("%d ", d[i]);
	putchar('\n');
	for (int i = 1; i <= n; i++) {
		work(((long long) D - X[i]) >> 1, sgn1);
		work(((long long) D - Y[i]) >> 1, sgn2);
		for (int j = 1; j <= m; j++) {
			putchar(G[sgn1[j] * 2 + sgn2[j]]);
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
int N ; cin >> N; int cnt = 1;
  for(int i = 0; i < N; i++){
    int a; cin >> a;
    if( a % 2 == 0){ cnt*= 2;}}
  int c = 1;
  for(int i = 0; i < N; i++){ c *= 3;}
  
  cout << c - cnt << endl; return 0;}
  

Measured memory_bytes: 256
a = int(input(""))
if 1000 >= a:
    print(1000 - a)
elif 2000 >= a > 1000:
    print(2000 - a)
elif 3000 >= a > 2000:
    print(3000 - a)
elif 4000 >= a > 3000:
    print(4000 - a)
elif 5000 >= a > 4000:
    print(5000 - a)
elif 6000 >= a > 5000:
    print(6000 - a)
elif 7000 >= a > 6000:
    print(7000 - a)
elif 8000 >= a > 7000:
    print(8000 - a)
elif 9000 >= a > 8000:
    print(9000 - a)
else:
    print(10000 - a)

Measured memory_bytes: 9220
N, M = list(map(int, input().split()))
ahs = list(map(lambda x:int(x)//2, input().split()))

odd = sum([ah % 2 for ah in ahs])
if odd!=0 and N-odd!=0:
    print(0)
else:
    from fractions import gcd
    from functools import reduce

    def lcm_base(x, y):
        return (x * y) // gcd(x, y)

    def lcm_list(numbers):
        return reduce(lcm_base, numbers, 1)

    lcm = lcm_list(ahs)

    result = True
    for ah in ahs:
        if (lcm // ah) % 2 == 0:
            result = False
            break

    if result == False:
        print(0)
    else:
        print((M//lcm-1)//2 + 1)

Measured memory_bytes: 14360
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll a[3333];
ll dp[3333][3333];

ll solve(int l, int r)
{
	if(l>r) return 0;
	if(l==r) return a[l];
	if(dp[l][r]!=-ll(1e18)) return dp[l][r];
	return (dp[l][r]=max(a[l]-solve(l+1,r),a[r]-solve(l,r-1)));
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++) dp[i][j]=-ll(1e18);
	}
	for(int i=0;i<n;i++) cin>>a[i];
	cout<<solve(0,n-1)<<'\n';
}


Measured memory_bytes: 80256
N = int(input())
A = [int(a) for a in input().split()]
P = 10**9+7

def inv(a):
    return pow(a, P-2, P)

s = 0
for i in range(N):
    s += inv(i+1)
    
ans = 0
for i in range(N):
    ans += s * A[i]
    ans %= P
    s += inv(i+2) - inv(N-i)
    
for i in range(1, N+1):
    ans = ans * i % P
    
print(ans)

Measured memory_bytes: 62576
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<int,ii> iii;
typedef vector<iii> viii;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
const int MOD = 1e9 + 7;
const ll INF = ll(1e18);
const ld eps = ld(1e-8);
 
ll modpow(ll a, ll b)
{
	if(b < 0) b += (MOD - 1);
	a %= MOD;
	ll r = 1;
	while(b)
	{
		if(b % 2)
		{
			r = (r*a)%MOD;
		}
		a = (a*a)%MOD;
		b /= 2;
	}
	if(r < 0) r += MOD;
	return r;
}
 
ll inv(ll x)
{
	return modpow(x, MOD - 2);
}
 
ll choose(ll n, ll r)
{
	if(r == 0)
	{
		return 1;
	}
	if(n == r)
	{
		return 1;
	}
	ll denom = 1;
	for (ll i = 2; i <= r; i++)
	{
		denom = (denom * i) % MOD;
	}
	ll res = 1;
	for (ll i = n; i > n - r; i--) 
	{
		res = (res * i) % MOD;
	}
	res = (res * modpow(denom, MOD - 2)) % MOD;
	if(res < 0) res += MOD;
	return res;
}
 
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	ll ans = 0;
	swap(a, b);
	ans += choose(w-a+h-2,w-a-1);
	ll cur1, cur2;
	for(int i = 1; i <= h - b - 1; i++)
	{
		if(i == 1)
		{
			cur1 = a;
			cur2 = choose(w-a+h-3,w-a-1);
		}
		//cout << cur1 << ' ' << cur2 << endl;
		ans += (cur1*cur2)%MOD;
		ans %= MOD;
		if(ans < 0) ans += MOD;
		if(i < h - b - 1)
		{
			cur1 = (cur1*(a+i))%MOD;
			cur1 = (cur1*inv(i+1))%MOD;
			cur2 = (cur2*inv(w-a+h-2-i))%MOD;
			cur2 = (cur2*(h-i-1))%MOD;
		}
	}
	ans %= MOD;
	if(ans < 0) ans += MOD;
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const int big=1e9+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
int main(void){
	int n,k,i,j,ans=0;cin>>n>>k;//ans=必要
	vector<int>a(n);
	for(i=0;i<n;i++){cin>>a[i];if(a[i]>k){a[i]=k;}}
	sort(a.rbegin(),a.rend());
	bitset<5001> nap;
	nap[0]=true;
	for(i=0;i<n;i++){
		for(j=k-a[i];j<k;j++){
			if(nap[j]){ans=i+1;break;}
		}
		for(j=5000;j>=0;j--){
			if(nap[j]){nap[min(5000,a[i]+j)]=true;}
		}
	}
	cout<<n-ans<<endl;RE;
}

Measured memory_bytes: 256
n=int(input())
z=[[[0 for y in range(10)]for i in range(3)]for j in range(4)]
for x in range(n):
	a,b,c,d=map(int,input().split())
	z[a-1][b-1][c-1]+=d
	
for j in range(4):
	for i in range(3):
		for h in range(10):
			print(" "+str(z[j][i][h]),end="")
		print()
	if j!=3:
		print("#"*20)




Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int M = 1e9+7;
const int INF = 1<<30;

int _;
char s[200005];

ll gcd(ll a,ll b) {return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll b) {ll s=1;while(b){if(b&1)s=(s*a)%M;b>>=1;a=(a*a)%M;}return s;}



int main()
{
    queue<ll> q;
    int n;
    cin>>n;
    if(n<=9) {cout<<n<<endl; return 0;}
    for(int i=1;i<=9;i++) q.push(i);
    int cnt = 9;
    while(1)
    {
        ll u = q.front();q.pop();
        if(u%10!=0)
        {
            ll t = u*10 + u%10 - 1;
            q.push(t);
            cnt++;
            if(cnt==n) {cout<<t<<endl;return 0;}
        }
        ll t = u*10 + u%10;
        q.push(t);
        cnt++;
        if(cnt==n) {cout<<t<<endl;return 0;}
        if(u%10!=9)
        {
            ll t = u*10 + u%10 + 1;
            q.push(t);
            cnt++;
            if(cnt==n) {cout<<t<<endl;return 0;}
        }
    }
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
int main(){
  int i,j;
  char f[10];
  int d[10];
  while(scanf(" %c",&f[0])!=EOF){
    d[0]=f[0]-'0';
    for(i=1;i<10;i++){
      scanf("%c",&f[i]);
      d[i]=f[i]-'0';
    }//入力
    for(i=9;i>0;i--){
      for(j=0;j<i;j++){
	d[j]=(d[j]+d[j+1])%10;
      }
    }
    printf("%d\n",d[0]);
  }
  return 0;
}


Measured memory_bytes: 540
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func GCD(a, b int) int {
  if a < b { a, b = b, a }
  for 0 < b {
    a, b = b, a % b
  }
  return a
}

func LCM(A []int) int {
  lcm := A[0]
  for _, a := range A {
    lcm = lcm * a / GCD(lcm, a)
  }
  return lcm
}

func main() {
  NM := NextIntVec()
  M := NM[1]
  A := NextIntVec()
  k := 0
  for a := A[0]; a % 2 == 0; k++ {
    a /= 2
  }
  ans := -1
  for _, a := range A[1:] {
    cnt := 0
    for _a := a; _a % 2 == 0; cnt++ {
      _a /= 2
    }
    if cnt != k {
      ans = 0
      break
    }
  }
  if ans < 0 { ans = (M / (LCM(A) / 2) + 1) / 2 }
  Write(ans)
  Output()
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
 cin>>s;
 long long n=s.size();
 if(s[n-1]=='2'||s[n-1]=='9'||s[n-1]=='7'||s[n-1]=='5'||s[n-1]=='4')cout<<"hon";
 else if(s[n-1]=='8'||s[n-1]=='0'||s[n-1]=='1'||s[n-1]=='6')cout<<"pon";
 else cout<<"bon";


    return 0;}




Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
int main(){
	int n, m;
	int ans;
	std::cin >> n >>m;
	std::vector <int>v(m);
	std::vector <int>u(m-1);
	for(int i=0;i<m;++i){
		std::cin >> v[i];
	}
	sort(v.begin(), v.end());
	for(int i=0;i<m-1;++i){
		u[i] = v[i+1] - v[i];
	}
	std::sort(u.begin(), u.end(), std::greater<int>());
	for(int i=n-1;i<m-1;++i){
		ans += u[i];
	}
	std::cout << ans << std::endl;
	return 0;
}

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

#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define fre freopen("in.txt","r",stdin)
typedef long long ll;
const ll INF=0x3f3f3f3f;
const int N=1e7+5;

int prime[N];
bool is_prime[N];
int cnt=0;
void init()
{
    for(int i=2; i<=N; i++)
        is_prime[i]=1;
    for(int i=2; i*i<=N; i++)
    {
        if(is_prime[i])
        {
            for(int j=i*i; j<=N; j+=i)
                is_prime[j]=0;
        }
    }
    for(int i=7; i<=N; i++)
        if(is_prime[i])
            prime[cnt++]=i;
}
int main()
{
    init();
    int n;
    while(cin>>n)
    {
        int num=0;
        printf("7");
        for(int i=1; num<n-1; i++)
        {
            if(prime[i]%10==7)
            {
                printf(" %d",prime[i]);
                num++;
            }
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 14592
main () {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == 1)
    {
        if (b == 2) puts("3");
        if (b == 3) puts("2");
    }
    else if (a == 2) {
        if (b == 1) puts("3");
        if (b == 3) puts("1");
    }
    else if (a == 3) {
        if (b == 1) puts("2");
        if (b == 2) puts("1");
    }
}


Measured memory_bytes: 128
s = input()
t = input()

ss = sorted(s)
tt = sorted(t, reverse=True)


def checker(s, t):
    for sz in ss:
        for tz in tt:
            if sz > tz:
                return 'No'
            elif sz == tz:
                continue
            else:
                return 'Yes'
    if len(ss) < len(tt):
        return 'Yes'
    return 'No'


print(checker(ss, tt))


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

int main()
{
    int Term[32] =
        {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << Term[K-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>

using namespace std;

int main(){

  int x, y;

  while(cin >> x >> y){
    if(x == 0 && y == 0) break;

    int money[y+1][y+1], time[y+1][y+1];

    for(int i = 0; i <= y; i++){
      for(int j = 0; j <= y; j++){
	money[i][j] = 0;
	time[i][j] = 0;
      }
    }

    int from, to, mon, tim;

    for(int i = 0; i < x; i++){
      cin >> from >> to >> mon >> tim;
      money[from][to] = mon;
      money[to][from] = mon;
      time[from][to] = tim;
      time[to][from] = tim;
    }

    int num, order, weight[y+1];

    cin >> num;

    int come[y];

    for(int i = 0; i < num; i++){
      cin >> from >> to >> order;

      for(int i = 0; i <= y; i++){
	weight[i] = -1;
	come[i] = 0;
      }

      weight[from] = 0;
      come[from] = 1;

      int min = from;

      if(order == 1){//time
	while(1){
	  from = min;
	  come[from] = 1;
	  for(int i = 1; i <= y; i++){
	    if(come[i] == 0 && time[from][i] != 0){
	      
	      if(weight[i] == -1 || weight[i] > weight[from] + time[from][i]){
		weight[i] = weight[from] + time[from][i];
	      }
	      
	    }
	  }
	  min = -1;
	  
	  for(int i = 0; i <= y; i++){
	    if(come[i] == 1) continue;
	    if(min == -1) min = i;
	    else{
	      if(weight[min] == -1 || weight[min] > weight[i] && weight[i] != -1) min = i;
	    }
	  }
	  if(min == -1) break;
	}
	    
      }else{//money
	while(1){
	  from = min;
	  come[from] = 1;
	  for(int i = 1; i <= y; i++){
	    if(come[i] == 0 && money[from][i] != 0){
	      
	      if(weight[i] == -1 || weight[i] > weight[from] + money[from][i]){
		weight[i] = weight[from] + money[from][i];
	      }
	      
	    }
	  }
	  min = -1;
	  
	  for(int i = 0; i <= y; i++){
	    if(come[i] == 1) continue;
	    if(min == -1) min = i;
	    else{
	      if(weight[min] == -1 || weight[min] > weight[i] && weight[i] != -1) min = i;
	    }
	  }
	  if(min == -1) break;
	}
	   
      }

      cout << weight[to] << endl;      
    }
  }

  return 0;
}
      

Measured memory_bytes: 948
#include<stdio.h>
int main()
{
	int n,a,b,s,min;
	while(scanf("%d %d %d",&n,&a,&b)!=EOF)
	{
		s=n*a;
		min=s<b?s:b;
		printf("%d\n",min);
	}
	return 0;
}

Measured memory_bytes: 128
import Control.Monad

mup n [] = []
mup n s = (s!!0!!n):(mup n (drop 1 s))

maximum' x = if null x then 0 else maximum x
minimum' x = if null x then 0 else minimum x

ac [] [] [] p q = (maximum' p - minimum' p) * (maximum' q - minimum' q)
ac x y a p q= case (head a) of 1 -> ac (drop 1 x) (drop 1 y) (drop 1 a) (filter (>=(head x)) p) q
                               2 -> ac (drop 1 x) (drop 1 y) (drop 1 a) (filter (<=(head x)) p) q
                               3 -> ac (drop 1 x) (drop 1 y) (drop 1 a) p (filter (>=(head y)) q)
                               4 -> ac (drop 1 x) (drop 1 y) (drop 1 a) p (filter (<=(head y)) q)
main=do
 [w,h,n]<-map read.words<$>getLine
 s<-replicateM n (map read.words<$>getLine)
 let xs = mup 0 s
 let ys = mup 1 s
 let ap = mup 2 s
 let ws = [0..w]
 let hs = [0..h]
 print$ac xs ys ap ws hs
 

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
#define MOD 1000000007
using namespace std;
int main(){
    string s,ans="";
    cin>>s;
    rep(i,0,(int)s.length())ans+='x';
    cout<< ans<<endl;
}

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

using namespace std;

typedef long long int llint;
long long int N;

int main() {
	cin >> N;
	llint ans = N - 1;
	for (llint i = 1; i <= sqrt(N) + 1; i++) {
		if (N % i == 0) {
			ans = min(ans, (i - 1) + (N / i - 1));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
#include <set>
#include <functional>

using namespace std;

bool check(char c) {
    return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}

int main() {
    string s;
    cin >> s;

    int mx = 0;
    int cnt = 0;
    bool now = false;
    s += " ";
    for (int i = 0; i < s.size(); i++) {
        if (now && !check(s[i])) {
            mx = max(mx, cnt);
            cnt = 0;
            now = false;
        } else if (check(s[i])) {
            now = true;
            cnt++;
        }
    }
    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[][10^^5] G, T;
bool[10^^5] F, U;
int[10^^5] P, FROM;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    foreach (_; 0..M) {
        auto ab = readln.split.to!(int[]);
        auto a = ab[0]-1;
        auto b = ab[1]-1;
        G[a] ~= b;
        G[b] ~= a;
    }
    if (M%2 == 1) {
        writeln(-1);
        return;
    }
    int[2][] rr;
    int[] ss = [0];
    F[0] = true;
    while (!ss.empty) {
        auto h = ss[0];
        U[h] = true;
        ss = ss[1..$];
        foreach (n; G[h]) {
            if (F[n]) {
                if (P[h] != n && U[n]) {
                    FROM[n] += 1;
                    rr ~= [n, h];
                }
            } else {
                F[n] = true;
                T[h] ~= n;
                P[n] = h;
                ss ~= n;
            }
        }
    }
    void solve(int i, int p) {
        foreach (n; T[i]) solve(n, i);
        if (i == p) return;
        if (FROM[i]%2 == 1) {
            rr ~= [i, p];
        } else {
            FROM[p] += 1;
            rr ~= [p, i];
        }
    }
    solve(0, 0);
    foreach (r; rr) writefln("%d %d", r[0]+1, r[1]+1);
}

Measured memory_bytes: 21756
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
  
typedef pair<double,double> P;
typedef pair<P,double> P2;
  
P rot(P p, double a){
  a=a*M_PI/180.0;
  return P(p.first*cos(a)+p.second*(-sin(a)),
  p.first*sin(a)+p.second*cos(a));
}
  
double abss(P a,P b){
  return (a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
}
  
double x,y,r;int tt;
vector<P>v;
int main(){
  
  int n;
  cin>>n;
  
    double ans=1e13;
      
    v.clear();
    
    r(i,n){
      cin>>x>>y;
      v.push_back(P(x,y));
    }
  
    r(i,20){
      sort(v.begin(),v.end());
      r(j,n){
        for(int k=j+1,c=0;k<n;k++,c++){
          if(c>50)break;
          ans=min(ans,abss(v[k],v[j]));
        }
      }
      r(j,n)v[i]=rot(v[i],0.1);
    }
  
    printf("%d\n",(int)ans);
      
}


Measured memory_bytes: 11240
#include <iostream>
#include <algorithm>

#define INF 1000000000

using namespace std;

int n;
int p[110000];
int dp[110000];

void swap_v(int& a, int& b) {
    int t = a;
    a = b;
    b = t;
}

int solve(int a) {
    if(dp[a] != INF) {
        return dp[a];
    }

    if(a == n) {
        if(p[a] == a) {
            return INF;
        } else {
            return 0;
        }
    }
    int ll = INF, rr = INF;
    if(p[a] != a) {
        ll = solve(a + 1);
    }
    swap_v(p[a], p[a + 1]);
    if(p[a] != a) {
        rr = solve(a + 1) + 1;
    }
    swap_v(p[a], p[a + 1]);

    int min_val = min(ll, rr);
    if(min_val == INF) {
        throw NULL;
    }

    dp[a] = min_val;
    return min_val;
}

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> p[i];
    }

    for(int i = 0; i <= n; i++) {
        dp[i] = INF;
    }

    cout << solve(1) << endl;
    return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<math.h>
#define SIZE 100000
int main(){
  int n,t,a,place,i;
  int h[SIZE];
  double tem[SIZE],dif,bord=100000.;
  scanf("%d%d%d",&n,&t,&a);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
    tem[i]=t-0.006*h[i];
    dif=fabs(a-tem[i]);
    if(dif<bord){
      bord=dif;
      place=i;
    }
  }
  printf("%d\n",place+1);
 
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize(2,3,"Ofast","unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int CC=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in ll read()
	{
		ll x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<=32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
}
using namespace fast_io;
#define pb push_back
const int N=1e6+5,p=1e9+7;
int n,m,a[N],inv[N],fac[N],ans;
int A(int n,int m){return n<m?0:1ll*fac[n]*inv[n-m]%p;}
int C(int n,int m){return n<m?0:1ll*fac[n]*inv[m]%p*inv[n-m]%p;}
int main()
{
	n=read();m=read();inv[0]=inv[1]=fac[0]=fac[1]=1;
	for(int i=2;i<N;i++) inv[i]=1ll*(p-p/i)*inv[p%i]%p,fac[i]=1ll*fac[i-1]*i%p;
	for(int i=2;i<N;i++) inv[i]=1ll*inv[i]*inv[i-1]%p;
	for(int i=0;i<=n;i++)ans=(ans+1ll*(i&1?p-1:1)*A(m,i)%p*C(n,i)%p*A(m-i,n-i)%p*A(m-i,n-i)%p)%p;
	cout<<ans;
}
//Author: disangan233

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

int main() {
    int mod = 1e9 + 7;

    int n;
    string s;
    cin >> n >> s;

    long ans = 1;
    int c[26] = {};

    for (int i = 0; i < n; i++) {
        c[s[i] - 'a']++;
    }

    for (int i = 0; i < 26; i++) {
        ans = ans * (c[i] + 1) % mod;
    }

    cout << ans - 1 << endl;

    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

int N;
vector<int> a;

unordered_map<int, i64> memo[200010];
i64 dp(int i, int cnt) {
    if (i >= N) {
        return (cnt == N / 2) ? 0 : -LINF;
    }
    if (cnt > N / 2 || cnt < i / 2 - 1) return -LINF;

    if (memo[i].count(cnt)) return memo[i][cnt];

    i64 ret = -LINF;
    chmax(ret, dp(i + 1, cnt));
    chmax(ret, dp(i + 2, cnt + 1) + a[i]);

    return memo[i][cnt] = ret;
}

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

    read(N);
    a.resize(N);
    read(a);

    print(dp(0, 0));

    return 0;
}


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

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

using ll = long long;
const ll INF = 1LL<<60;

int main() {
  ll N;
  cin >> N;
  ll cnt = 0LL;
  vector<ll> v(N);
  for(ll i = 0; i < N; i++) {
    cin >> v.at(i);
    if(v.at(i)<0) cnt++;
  }
  ll ans = 0LL;
  if(cnt % 2==0){
    for(ll i = 0; i< N; i++) {
      ans += abs(v.at(i));
    }
  }
  else {
    ll neg=INF;
    for(ll i = 0LL; i < N; i++) {
      chmin(neg, abs(v.at(i)));
      ans += abs(v.at(i));
    }
    ans -= 2LL*neg;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>

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

  while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
    int div = a;
    a /= div, b /= div, c /= div;

    int time = -d;
    d += a * time, e += b * time, f += c * time;

    double y = f / e;
    double x = c - b * y;

    printf("%.3f %.3f\n", x, y);
  }
  
  return 0;
}


Measured memory_bytes: 2684
#include <iostream>
#include <stdio.h>

#include <string>

#include <vector>
#include <list>
#include <map>

#include <algorithm>
#include <utility>

using namespace std;

int main(const int argc, const char **argv){
  int N;
  scanf("%d", &N);

  if(N == 1){
    printf("Hello World");
    return 0;
  }else if(N == 2){
    int A, B;
    scanf("%d", &A);
    scanf("%d", &B);
    printf("%d\n", A + B);
    return 0;
  }

  return 0;
}


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

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    int score[N];
    for(int i = 0; i < N; i++) score[i] = K - Q;
    for(int i = 0; i < Q; i++){
        int A;
        cin >> A;
        score[A-1]++;
    }
    
    for(int i = 0; i < N; i++)
        if(score[i] > 0) cout << "Yes" << "\n";
        else cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 1024
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
    	int n;
    	cin >> n;
    	int a[n], x = 0;
    	for(int i = 0; i < n; i++)
    	{
    		cin >> a[i];
    		x += a[i];
    	}

    	x /= n;
    	int y = x + 1;
    	int ans1 = 0, ans2 = 0;
    	for(int i = 0; i < n ;i++){
    		ans1 += (a[i] - x) * (a[i] - x);
    		ans2 += (a[i] - y) * (a[i] - y);
    	}

    	cout << min(ans1, ans2) << '\n';
    	
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int pos , sums , sumt;
int main(){
	cin >> s;
	for(int i = 0 ; i < s.size() ; i++){
		if(s[i] == 'T'){
			if(sums == 0){
				sumt++;
			}
			else sums--;
		}
		if(s[i] == 'S'){
			sums++;
		}
	}
	cout << sums + sumt << endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int n;
  cin >> n;
  long long h[n];
  for(int i=1; i <= n; i++) {
    cin >> h[i];
  } 

  long long dp[n+1];
  for(int i=1; i <= n; i++) dp[i] = 10000000009LL;
  dp[1] = 0;

  for(int i=1; i < n; i++) {
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
  }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 1792
N = int(input())
AB = [0] * N
for n in range(N):
  AB[-1-n] = [int(x) for x in input().strip().split()]
ans = 0
cnt = 0
for (a, b) in AB:
  mod = (a + cnt) % b
  if mod:
    t = b - mod
    cnt += t
    ans += t
print(ans)


Measured memory_bytes: 21128
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
#define ll long long
#define ull unsigned long long
#define pii pair <int, int>
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
using namespace std;

namespace IO {
	const int BUF_SIZE = 1 << 13;
	char IBUF[BUF_SIZE];
	char *PIBUF = IBUF + BUF_SIZE - 1;

	inline int getchar() {
		if (++ PIBUF == IBUF + BUF_SIZE)
			fread(PIBUF = IBUF, 1, BUF_SIZE, stdin);
		return *PIBUF;
	}
}

#define getchar()  IO :: getchar()

template <typename T>
inline void getint(T &x) {
	x = 0;
	int b = 1, c = getchar();
	for (;!isdigit(c); c = getchar()) if (c == '-') b = -b;
	for (; isdigit(c); c = getchar()) x = (x<<3) + (x<<1) + (c^48);
	x *= b;
}

inline
void getstr(char *s) {
	int c = getchar();
	for (; isspace(c); c = getchar());
	for (;!isspace(c); c = getchar()) *s = c, ++ s;
	*s = 0;
}

const int N = 1 << 20;
const int inf = 1 << 30;

inline void ERROR() {
	printf("No\n");
	exit(0);
}

struct Range {
	int l, r;
	Range(int _l = -inf, int _r = inf) {
		l = _l;
		r = _r;
	}
	void CombineRange(int nl, int nr) {
		l = max(l, nl);
		r = min(r, nr);
		if (l > r || (r - l) & 1)
			ERROR();
	}
} range[N];

vector <int> g[N];
int val[N];

void dfs1(int u, int p) {
	for (int i = 0; i < (int) g[u].size(); ++ i) {
		int v = g[u][i];
		if (v != p) {
			dfs1(v, u);
			range[u].CombineRange(range[v].l - 1, range[v].r + 1);
		}
	}
}

void dfs2(int u, int p) {
	for (int i = 0; i < (int) g[u].size(); ++ i) {
		int v = g[u][i];
		if (v != p) {
			range[v].CombineRange(range[u].l - 1, range[u].r + 1);
			dfs2(v, u);
		}
	}
}

int main() {
	int n; scanf("%d", &n);
	for (int i = 0; i < n - 1; ++ i) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int k; scanf("%d", &k);
	for (int i = 0; i < k; ++ i) {
		int p, v;
		scanf("%d%d", &p, &v);
		range[p] = Range(v, v);
	}
	dfs1(1, 0);
	dfs2(1, 0);
	printf("Yes\n");
	for (int i = 1; i <= n; ++ i) {
		printf("%d\n", range[i].l);
	}
	return 0;
}


Measured memory_bytes: 44800
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(), M = in.nextInt();
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = in.nextInt();
        }
        boolean[] good = new boolean[N];
        for (int i = 0; i < N; i++) {
            good[i] = true;
        }
        for (int i = 0; i < M; i++) {
            int u = in.nextInt() - 1, v = in.nextInt() - 1;
            if (arr[u] <= arr[v]) {
                good[u] = false;
            }
            if (arr[u] >= arr[v]) {
                good[v] = false;
            }
        }
        int res = 0;
        for (boolean b : good) {
            if (b) {
                res++;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 59760
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;



int main() {
    int n; cin >> n;
    unordered_map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    } 
    vector<string> ss = {"AC", "WA", "TLE", "RE"};
    for (auto& s : ss) {
        cout << s << " x " << mp[s] << endl;
    } 
    return 0;
}

Measured memory_bytes: 3628
N=gets.to_i
h = { 'AC' => 0, 'WA' => 0, 'TLE' => 0, 'RE' => 0 }
N.times do
  h[gets.chomp.to_s] += 1
end
h.each do |k,v|
  puts "#{k} x #{v}"
end


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

using namespace std;

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    if(a/k<b/k || a%k==0 || b%k==0) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}


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

int main()
{
	string s;
	int i,cnt1=0,grade;
	cin>>s;
	int l=s.size();
	for(i=0;i<l;i++){
		if(s[i]=='p'){
			cnt1++;
		}
	}
	grade=l/2-cnt1;
	cout<<grade<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
 #define int long long
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

  int n;
  cin >> n;
  int l[n];
  rep(i, n) cin >> l[i];
  sort(l, l + n);
  int ans = 0;
  rep(i, n) {
    REP(j, i + 1, n) {
      REP(k, j + 1, n) {
        if(l[k] < l[i] + l[j]) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int N;
  char str[100];
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  if(N<1000){
    printf("ABC");
  }else{
    printf("ABD");
  }
  
  return 0;
}

Measured memory_bytes: 128
A,B=list(map(int,input().split()))
x1=int(A/0.08)
x2=int(B/0.1)
poss=[]
for x in range(min(0,x1-10),x1+11):
    poss.append(x)
for x in range(min(0,x2-10),x2+11):
    poss.append(x)
poss=sorted(poss)

for p in poss:
    if int(p*0.08)==A and int(p*0.1)==B:
        print(p)
        exit()
print(-1)

Measured memory_bytes: 39024