akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}


int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll a[n];
    ll sum=1;
    rep(i,0,n){
        cin>>a[i];
        if(a[i]==0){
            sum=0;
            continue;
        }
        if(sum==-1)continue;
        if(sum>(1000000000000000000+a[i]-1)/a[i]){
            sum=-1;
            continue;
        }
        sum*=a[i];
        if(sum>1000000000000000000)sum=-1;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 4436
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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 (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

// DFS
vector<vector<int>> G;
map<pair<int,int>,int> m;

void dfs(int v,int p,int e){
    int tmp = 0;
    for(auto nv : G[v]){
        if(nv == p)continue;
        tmp++;
        if(e == tmp)tmp++;
        m[{v,nv}] = tmp;
        m[{nv,v}] = tmp;
        dfs(nv,v,tmp);
    }
}

int main() {
    int N;cin >> N;
    G.resize(N);
    vector<pair<int,int>> ch(N-1);
    rep(i,N-1){
        int a,b;cin >> a >> b;
        a--;b--;
        ch[i] = {a,b};
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0,-1,0);

    int ans = 0;
    rep(i,N){
        int tmp = G[i].size();
        ans = max(ans,tmp);
    }

    cout << ans << endl;
    rep(i,N-1){
        cout << m[ch[i]] << endl;
    }
}

Measured memory_bytes: 19456
#include<iostream>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
#define INF 10000000
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> P2;

int m,n,k,d,num;
int cal[6],dijk[200][100];
vector<P> dis[200];

int stoi(string s){
  stringstream ss;
  ss << s;
  int a;
  ss >> a;
  return a;
}

int trans(string s){
  if(s=="H")return m+n;
  if(s=="D")return m+n+1;
  if(s[0]=='C'){
    s.erase(s.begin());
    return stoi(s)-1;
  }
  s.erase(s.begin());
  return stoi(s)+m-1;
}

int main(){
  while(cin >> m >> n >> k >> d && (m||n||k||d)){
    for(int i=0;i<m;i++)cal[i] = 0;

    num = m+n+2;
    for(int i=0;i<num;i++){
      dis[i].clear();
      for(int j=0;j<(1<<m);j++)dijk[i][j] = INF;
    }

    for(int i=0;i<m;i++)cin >> cal[i];

    for(int i=0;i<d;i++){
      string a,b;
      int tmp;

      cin >> a >> b >> tmp;
      dis[trans(a)].push_back(P(trans(b),tmp));
      dis[trans(b)].push_back(P(trans(a),tmp));
    }

    priority_queue<P2 ,vector<P2> ,greater<P2> > q;
    dijk[m+n][0] = 0;
    q.push(P2(0,P(m+n,0)));

    while(q.size()){
      P2 p = q.top();q.pop();
      int dist = p.first, pos = p.second.first, cake = p.second.second;

      for(int i=0;i<(int)dis[pos].size();i++){
	int to = dis[pos][i].first, cost = dis[pos][i].second;
	int visit = cake;
	if(to<m){
	  if( (visit>>to) & 1)continue;
	  else visit += 1<<to;
	} 
	if(dijk[to][visit] > dist + cost){
	  dijk[to][visit] = dist + cost;
	  q.push(P2(dist+cost,P(to,visit)));
	}
      }
    }

    int ans = INF;
    for(int i=0;i<(1<<m);i++){
      int diet = 0;
      for(int j=0;j<m;j++)
	if( (i>>j) & 1)diet += cal[j];
      ans = min(ans,k*dijk[num-1][i] - diet);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1060
n,k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def bs(left, right):
    mid = 0
    
    while left < right:
        mid = (left + right ) //2
        if check(mid, w, k):
            right = mid
        else:
            mid += 1
            left = mid
    return mid

def check(v, wgt, num):
    cnt = 1
    tmp = 0
    for j in wgt:
        tmp += j
        if tmp > v:
            tmp = j
            cnt += 1
            if cnt > num:
                return False
    return True
    
print(bs(max(w), sum(w)))

Measured memory_bytes: 11580
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<pii> v(n);
	for(auto &i:v) cin>>i.F>>i.S;
	sort(all(v));
	set<pii> st;
	for(auto i:v) st.insert(i);
	int opt=10000000;
	For(i,0,n-1) For(j,0,n-1)
	{
		if(i==j) continue;
		int dx=v[j].F-v[i].F;
		int dy=v[j].S-v[i].S;
		int ans=0;
		For(k,0,n-1)
			if(!st.count({v[k].F-dx,v[k].S-dy}))
				ans++;
		opt=min(opt,ans);
		//cout<<opt<<"  "<<dx<<" "<<dy<<"\n";
	}
	if(opt!=10000000) cout<<opt<<"\n";
	else cout<<1<<"\n";
	return 0;
}















Measured memory_bytes: 256
mod reader {
    use std;

    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);

    pub fn read_and_parse<T: std::str::FromStr>() -> T {
        read_line!().trim().parse().ok().unwrap()
    }
}
use reader::*;

fn main() {
    const MOD: u64 = 1_000_000_000 + 7;
    const LETTERS: &'static str = "ACGT";
    const PROHIBIT: [&'static str; 6] =
        ["AGC", "ACG", "GAC", "AGGC", "AGTC", "ATGC"];

    let n: usize = read_and_parse();
    let mut table = Vec::new();
    let mut codons = Vec::new();
    table.resize(61, Vec::new());

    for codon in table.iter_mut() { codon.resize(n - 2, 0); codon[0] = 1 }

    for first in LETTERS.chars() {
        for second in LETTERS.chars() {
            for third in LETTERS.chars() {
                let mut codon: String = String::new();
                codon.push(first);
                codon.push(second);
                codon.push(third);

                if !PROHIBIT[..3].contains(&codon.as_str()) {
                    codons.push(codon);
                }
            }
        }
    }

    for i in 0..(n - 3) {
        for (codon_id, codon) in codons.iter().enumerate() {
            for append in LETTERS.chars() {
                let mut four_letters = codon.clone();
                four_letters.push(append);
                let mut three_letters = codon[1..].to_string();
                three_letters.push(append);

                if PROHIBIT[..3].contains(&three_letters.as_str()) ||
                       PROHIBIT[3..].contains(&four_letters.as_str()) {
                    continue ;
                }

                let matched_index =
                    codons.binary_search(&three_letters).ok().unwrap();

                table[matched_index][i + 1] += table[codon_id][i];
                table[matched_index][i + 1] %= MOD;
            }
        }
    }

    println!("{}" , table . iter (  ) . fold (
             0 , | acc , codon | ( acc + codon . last (  ) . unwrap (  ) ) %
             MOD ));
}


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

int main() {
  int a,b;
  cin>>a>>b;
  int ans=0;
  for(int i=a;i<b+1;i++){
    int c=i%10;
    int d=(i/10)%10;
    int e=(i/100)%10;
    int f=(i/1000)%10;
    int g=i/10000;
    if(c==g && d==f)ans++;
  }
  cout << ans << endl;
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int m; scanf("%d", &m);
	int n = m - 1;
	vi ans(n);
	forn(i, n) {
		scanf("%d", &ans[i]);
	}
	int total = 0; total += ans[0];
	for1(i, n - 1) {
		total += min(ans[i], ans[i - 1]);
	}
	total += ans[n - 1]; printf("%d", total);
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 1e9+7
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const int mod = 1e9 + 7;
//const int N = 2e5+5, M = N;
//=========================================

// This problem is a variation of Longest Increasing Subsequence
// so we optimize the complexity using fenwick tree

const int MAXN = 2e5 + 10;
int N;
int dp[MAXN], h[MAXN], a[MAXN];
int bit[MAXN];

// update the fenwick tree
void update(int idx, int val){
    while(idx <= N){
        bit[idx] = max(bit[idx], val);
        idx += (idx & -idx);
    }
}

// answer the query for idx
int query(int idx){
    int result = 0;
    while(idx > 0){
        result = max(result, bit[idx]);
        idx -= (idx & -idx);
    }
    return result;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> N;

    for(int i = 1; i <= N; ++i)
        cin >> h[i];

    for(int i = 1; i <= N; ++i)
        cin >> a[i];

    for(int i = 1; i <= N; ++i){
        // dp[i] --> stores the max total beauty if the increasing sequence
        // ended at a tree of height i.

        // query(h[i] - 1) --> returns the maximum value of beauty of an increasing sequence in range [0, h[i] - 1].
        dp[i] = query(h[i] - 1) + a[i]; // add beauty of the current tree to the max sequence

        // update the max beauty value at index h[i] i.e, the value for increasing sequence ending at this tree
        update(h[i], dp[i]);
    }

    int best = 0;
    for(int i = 1; i <= N; ++i){
        // find the max value by traversing through total beauty values
        // of each flower height.
        best = max(best, dp[i]);
    }

    // Print the max possible answer.
    cout << best << "\n";

    return 0;
}


Measured memory_bytes: 9776
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve = fmap head . words

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 301;
string s[N];
int dp1[N][N], dp2[N][N];
int n, m;

int get(int J1, int J2) {
  for (int i1 = 0; i1 <= n; i1++) {
    for (int i2 = 0; i2 <= n; i2++) {
      int mn = min(i1, i2);
      if (mn == 0)
        dp1[i1][i2] = 0;
      else
        dp1[i1][i2] = dp1[i1 - 1][i2 - 1] + (s[i1 - 1][J1] == s[i2 - 1][J2]);
      dp2[i1][i2] = dp1[i1][i2];
      if (0 <= i1 - 1 && 0 <= i2 - 1)
        dp2[i1][i2] += min(dp2[i1 - 1][i2], dp2[i1][i2 - 1]);
      else if (0 <= i1 - 1)
        dp2[i1][i2] += dp2[i1 - 1][i2];
      else if (0 <= j1 - 1)
        dp2[i1][i2] += dp2[i1][i2 - 1];
    }
  }
  return dp2[n][n];
}

void solve() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int ans = 0;
  for (int j1 = 0; j1 + 1 < m; j1++) {
    ans += get(j1, j1 + 1);
  }
  cout << ans;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 4444
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();

        int ans = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    if (x == i*500 + j*100 + k*50) {
                        ans++;
                    }
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
	int w, h, xs, ys, xg, yg, n, c, d, x, y;
	int[][] map;
	int[][] visit;
	
	void loop(int p, int q, int r){
		visit[p][q] = 1;
		
		if(visit[p][q+1]==0 && map[p][q+1]==r) loop(p,q+1,r);
		if(visit[p+1][q]==0 && map[p+1][q]==r) loop(p+1,q,r);
		if(visit[p][q-1]==0 && map[p][q-1]==r) loop(p,q-1,r);
		if(visit[p-1][q]==0 && map[p-1][q]==r) loop(p-1,q,r);
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w==0 && h==0) return;
			xs = sc.nextInt();
			ys = sc.nextInt();
			xg = sc.nextInt();
			yg = sc.nextInt();
			n = sc.nextInt();
			map = new int[h+2][w+2];
			visit = new int[h+2][w+2];
			for(int i=0;i<n;i++){
				c = sc.nextInt();
				d = sc.nextInt();
				x = sc.nextInt();
				y = sc.nextInt();
				if(d==0){
					for(int j=0;j<4;j++) map[y][x+j]=c;
					for(int j=0;j<4;j++) map[y+1][x+j]=c;
				}else{
					for(int j=0;j<4;j++) map[y+j][x]=c;
					for(int j=0;j<4;j++) map[y+j][x+1]=c;
				}
			}
			if(map[ys][xs]==0){
				System.out.println("NG");
			}else{
				loop(ys, xs, map[ys][xs]);
				if(visit[yg][xg]==1) System.out.println("OK");
				else System.out.println("NG");	
			}
		}
	}

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

Measured memory_bytes: 26312
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    int a,b;
    cin >> a >> b;

    if(a <= b){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
use std::io::*;
use std::str::FromStr;


fn main() {
    let mut h: i32 = read();
    let a: i32 = read();

    let mut count = 0;
    loop {
        h -= a;
        count += 1;
        if h <= 0 {
            println!("{}", count);
            break;
        }
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed 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")
}


Measured memory_bytes: 4476
def main():
    num_n = int(input())
    plan_lists = [[0, 0, 0]]
    for i in range(num_n):
        plan_lists.append(list(map(int, input().split())))
    for i in range(num_n):
        if sum(plan_lists[i+1][1:]) - sum(plan_lists[i][1:]) > (plan_lists[i+1][0] - plan_lists[i][0]):
            return print("No")
        if (plan_lists[i+1][0] - plan_lists[i][0]) % 2 == 0:
            if (sum(plan_lists[i+1][1:]) - sum(plan_lists[i][1:])) % 2 == 0:
                continue
            else:
                return print("No")
        else:
            if (sum(plan_lists[i+1][1:]) - sum(plan_lists[i][1:])) % 2 == 1:
                continue
            else:
                return print("No")
    print("Yes")





if __name__ == '__main__':
    main()


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n, k;
    cin >> n >> k;
    ll h[n];
    rep(i, n) { cin >> h[i]; }
    if (k >= n) {
        cout << 0 << endl;
        return 0;
    }

    sort(h, h + n);
    ll num = n - k;
    ll sum = 0;
    rep(i, num) { sum += h[i]; }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#define N 500005
using namespace std;

int n, m, z, num, cnt, l, r;
char b[5], a[N];
set<int> v[30];
int main()
{
	int i,j, t1, t2;
	cin >> n;
	scanf ("%s", &a[1]);
	cin >> m;
	for (i = 1; i <= n; i++) {
		num = a[i] - 'a';
		v[num].insert(i);
	}
	for (i = 0; i < 26; i++) v[i].insert(n + 100);
	while (m--) {
		scanf ("%d %d", &z,&t1);
		if (z == 1) {
			scanf ("%s", b);
			num = a[t1] - 'a';
			v[num].erase(t1);
			num = b[0] - 'a';
			v[num].insert(t1);
			a[t1] = b[0];
		} else {
			scanf ("%d", &t2);
			cnt = 0;
			for(i = 0; i < 26; i++) {
				l = *(v[i].lower_bound(t1));
				r = *(v[i].upper_bound(t2));
				if (l != r) cnt++;
			}
			printf("%d\n", cnt);
		}
	}
    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){
  
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a > k)cout << ":(" << endl;
  else cout << "Yay!" << endl;
  



  return 0;
}

Measured memory_bytes: 256
n = int(input())
lines = []
lines.append([int(i) for i in input().split()])
lines.append([int(i) for i in input().split()])

def sum(lines,y,start,end):
  total = 0
  for i in range(start,end):
    total += lines[y][i]

  return total	

max = 0

for i in range(1,n+1) :
  
  v1 = sum(lines,0,0,i)
  v2 = sum(lines,1,i-1,n)
  if max < v1+v2 :
    max = v1+v2
    
print(max)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX_S 100

int main(){

    string s,t;
    string tmp;
    string opt;
    cin >> s >> t;

    vector<string> ar;
    if(s.length() < t.length()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    bool ans = false;
    for(int i = 0;i < s.length()-t.length()+1;i++){
        bool flag = true;
        opt = s;
        //cout << opt << endl;
        tmp = " ";
        tmp.assign(opt,i,t.length());
        //cout << "tmp=" << tmp << endl;
        for(int j = 0;j < tmp.length();j++){

            if(tmp[j] == t[j]){
                //flag = true;
            }else if(tmp[j] == '?'){
                //flag = true;
            }else{
                flag = false;
                break;
            }
            /*if(tmp[j] != '?' && tmp[j] != t[j]){
                flag = false;
                break;
            }*/
        }
        //cout << flag << endl;
        if(flag){
            for(int j = i;j < i+t.length();j++){
                opt[j] = t[j-i];
            }
            for(int j =0;j < s.length();j++){
                if(opt[j] == '?'){
                    opt[j]='a';
                }
            }
            ans = true;
            //cout << opt << endl;
            ar.push_back(opt);
        }
    }

    if(ans){

        for(int i = 0;i < ar.size();i++){
            //cout << ar[i] << endl;
        }
        sort(ar.begin(),ar.end()/*,greater<string>()*/);
        cout << ar[0] << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 764
n, k = list(map(int, input().split()))
p=0
for i in range(1,n+1):
    p0 = 1/n
    cp = i
    while True:
        if cp >= k:
            p += p0
            break
        else:
            cp *= 2
            p0 *= 1/2
print(p)

Measured memory_bytes: 3060
a = [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]
n = gets.to_i

puts(a[n-1])

Measured memory_bytes: 1788
import sys #追加
sys.setrecursionlimit(50000000) #追加
N,M=map(int,input().split())
a=[]
for i in range(0,M):
    a.append(int(input()))
a=set(a)
if M==0:
    a=[-1]
ans=1
s=[-1]*(N+1)
s[0]=1
def dp(n):
    if n==0:
        return 1
    elif n==1:
        return 0 if 1 in a else 1
    if s[n-1]!=-1:
        c=s[n-1]
    elif n-1 in a:
        s[n-1]=0
        c=0
    else:
        c=dp(n-1)%1000000007
        s[n-1]=c
    if s[n-2]!=-1:
        b=s[n-2]
    elif n-2 in a:
        s[n-2]=0
        b=0
    else:
        b=dp(n-2)%1000000007
        s[n-2]=b
    return (c+b)%1000000007
print(dp(N)%1000000007)

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

int g(string n){
  int res = 0;
  for(int i=0;i<n.size();++i){
    res += n[i] - '0';
  }
  return res;
}

int main(){
  int n, ans = 1e9+1;cin>>n;
  for(int i=1;i<n;++i){
    ans = min(ans, g(to_string(i))+g(to_string(n-i)));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import Data.List
import qualified Data.IntMap as M
import Data.Maybe(fromJust)

main = do
  [n,y] <- map read . words <$> getLine :: IO [Int]
  let patten = [(i, j) | i <- [0..n], j <- [0..n-i]]
      m = foldl (solve n y) M.empty patten
      ans = M.lookup y m
  if ans /= Nothing
    then let (a, b) = fromJust ans
         in putStrLn $ show a ++ " " ++ show b ++ " " ++ show (n-a-b)
    else putStrLn "-1 -1 -1"

solve :: Int -> Int -> M.IntMap (Int, Int) -> (Int, Int) -> M.IntMap (Int, Int)
solve n y m (i, j) = M.insert (i*10000+j*5000+(n-i-j)*1000) (i, j) m


Measured memory_bytes: 6524
#include <iostream>
#include <vector>
#include <climits>


using namespace std;


using ll = long long;


ll N, M;
vector<vector<ll>> graph;
bool visited[200000] = { false };

void dfs(ll now, ll d)
{
    if (d > 2)
        return;
    visited[now] = true;
    for (auto e : graph[now]) {
        if (!visited[e])
            dfs(e, d + 1);
    }
}


int main()
{
    cin >> N >> M;
    graph.resize(N);

    for (auto i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }

    dfs(0, 0);
    if (visited[N - 1])
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORN(i,a,b) for(int i=(int)(a);i<=(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPN(i, n) FORN(i, 1, n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))

typedef long long ll;

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

    string w;
    cin>>w;
    map<char,int> m;
    REP(i,w.size()){
        if(m.find(w[i])==m.end()) m.insert({w[i],1});
        else m[w[i]]++;
    }
    EACH(u,m){
        if(u.second%2){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
cnt=0
while True:
    if cnt>=n:
        print('APPROVED')
        break
        
    elif a[cnt]%2==0:
        if a[cnt]%3==0 or a[cnt]%5==0:
            cnt+=1
            continue
        else:
            print('DENIED')
            break
    elif cnt==n:
        print('APPROVED')
        break
    else:
        cnt+=1
        
        continue
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define befv(V) ((V)[(sz(V)-2)])
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

int N, M, K;

int main() {
	cin >> N >> M >> K;

	for(int i = 0; i <= N; i++) for(int j = 0; j <= M; j++) {
		int cnt = i*M + j*N - i*j*2;
		if(K == cnt) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cctype>
#include <map>
#include <cstring>
#include <typeinfo>
#include <utility>
#define REP(i,n) for(int i = 0;i < n ;i++)
#define FOR(i,m,n) for(int i= m ;i<n;i++)
using namespace std;

int main(void){
  int n,k;
  cin >> n >> k;
  double ans = ((double)k*(pow((double)(k-1),(double)(n-1)))) ;
  printf("%.0f",ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0){
      break;
    }
    vector<int> a(1001,0);
    for(int i=0;i<=n;i++){
      a[i+1]=a[i]+i;
      //cout<<a[i+1]<<endl;
    }
    int ans=0;
    for(int i=1;i<n;i++){
      for(int j=i+2;j<=n+1;j++){
        if(a[j]-a[i]==n){
          //printf("a[j]=%d a[i]=%d\n",a[j],a[i]);
          ans++;
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long current = -100;
  long N;
  cin >> N;
  rep (i, N) {
    long h;
    cin >> h;
    if (current - 1 > h) {
      cout << "No" << endl;
      return;
    }
    current = max(current, h);
  }
  cout << "Yes" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
MOD = 1000000007

ndict = defaultdict(int)

for n in A:
  ndict[n] += 1

count = 1

for k, v in ndict.items():
  if v == 1 and k != 0:
    count = 0
    break
  else:
    count *= v
    count %= MOD

print(count)

Measured memory_bytes: 14820
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

//#define int long long

using namespace std;

void Main()
{
	int N, D;
	cin >> N >> D;
	int ans = 0;
	if (N % (D * 2 + 1)) {
		ans = N / (D * 2 + 1) + 1;
	}
	else {
		ans = N / (D * 2 + 1);
	}
	cout << ans << endl;
}

int32_t main()
{
	Main();
	return 0;
}

/*
void sample()
{
	vector<int> v;
	sort(v.begin(), v.end());
	sort(v.begin(), v.end(), greater<int>());

}
*/



Measured memory_bytes: 256
#include <stdio.h>

int sq(int rec[],int cur){
    int i;
    int lim,left = rec[cur];
    if(left){
        lim = (left > rec[cur-1]) ? rec[cur-1] : left;
        for(i=lim;i>0;i--){
            rec[cur] = i;
            rec[cur+1] = left-i;
            sq(rec,cur+1);
            rec[cur] = left;
        }
    }else{
        for(i=0;i<cur;i++){
            printf("%d",rec[i]);
            if(i==cur-1){
                printf("\n");
            }else{
                printf(" ");
            }
        }
    }
}

int main(){
    int n,i;
    int rec[30];
    scanf("%d",&n);
    while(n){
        for(i=n;i>0;i--){
            rec[0] = i;
            rec[1] = n-i;
            sq(rec,1);
        }
        scanf("%d",&n);
    }
}

Measured memory_bytes: 1032
import std.stdio;
import std.string, std.conv;
import std.algorithm, std.array;

void main() {
  for(;;) {
    int stdin[] = readln().split().map!(to!int)().array();
    const N = stdin[0];
    const M = stdin[1];
    if(N == 0 && M == 0) break;

    int taro[] = new int[N];
    int hanako[] = new int[M];
    int ts = 0, hs = 0;
    foreach(i; 0 .. N) {
      taro[i] = readln().chomp().to!int();
      ts += taro[i];
    }

    foreach(i; 0 .. M) {
      hanako[i] = readln().chomp().to!int();
      hs += hanako[i];
    }

    int ta = -1, ha = -1;
    int ss = cast(int)1e9;

    foreach(t; taro) {
      foreach(h; hanako) {
        if(ts - t + h == hs - h + t && t + h < ss) {
          ta = t;
          ha = h;
          ss = t + h;
        }
      }
    }

    if(ta == -1 && ha == -1)
      writeln(-1);
    else
      writefln("%d %d", ta, ha);
  }
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int count;
  count=0;
  for(int i=0;i<1000;i++){
    for(int j=0;j<N;j++){
      if(A.at(j)%2!=0){
        cout<<count;
        return 0;
      }
      A.at(j)/=2;
    }
    count++;
  }
  cout<<count;
}

    


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 51;
const int INF = TEN(9);
const int maxl = 150000;
const ll L = TEN(18);

V<int> g[maxn];
ll m[maxn], sz[maxn];
int p[maxn];

void dfs(int v) {
	sz[v] = 1;
	for (int to : g[v]) {
		dfs(to);
		sz[v] += sz[to];
		m[v] += m[to];
	}
}

ll dp[maxl];

int main() {
	int N, X, D;
	cin >> N >> X >> D;
	p[0] = -1;
	rep(i, N) {
		cin >> m[i];
		if (i) {
			cin >> p[i];
			--p[i];
			g[p[i]].pb(i);
		}
	}
	dfs(0);

	V<pair<pair<ll, ll>, int>> vec;
	V<pair<ll, ll>> items;

	rep(i, N) {
		int num = (i == 0 ? INF : D);
		int d = min(num, 50);

		ll x = m[i], y = sz[i];

		ll c = 1;
		ll s = 0;
		while (s + c < d) {
			s += c;
			items.eb(x, y);
			c *= 2;
			y *= 2;
			x *= 2;
		}
		{
			ll z = d - s;
			items.eb(z * m[i], z * sz[i]);
		}

		num -= d;

		if (num > 0) {
			vec.eb(mp(sz[i], m[i]), num);
		}
	}

	sort(ALL(vec), [&](const pair<pii, int>& a, const pair<pii, int>& b) {
		return (ll)a.fi.fi * b.fi.se - (ll)a.fi.se * b.fi.fi > 0;
	});

	rep(j, maxl) dp[j] = L;
	dp[0] = 0;

	for (auto p : items) {
		for (int j = maxl-1; j >= 0; --j) if (dp[j] != L) {
			chmin(dp[j + p.se], dp[j] + p.fi);
		}
	}

	ll ans = 0;
	rep(j, maxl) if (dp[j] != L) {
		ll cur = j;
		ll rem = X - dp[j];
		if (rem < 0) continue;

		for (auto t : vec) {
			ll u = min<ll>(rem / t.fi.se, t.se);
			cur += u * t.fi.fi;
			rem -= t.fi.se * u;
		}
		chmax(ans, cur);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        
        if(a*a + b*b + c*c -2*(a*b + b*c + c*a) > 0 && c-a-b > 0){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
        
	}
}

Measured memory_bytes: 35784
#include <stdio.h>

int isPrime(int x){
  int i;

  if(x == 0 || x == 1) return 0;

  for(i=2;i*i<=x;i++){
    if(x % i == 0){
      return 0;
    }
  }
  return 1;
}

int ans[1000000];

int main(void){
  int i,n;
  int res;

  ans[0] = 0;
  for(i=1;i<1000000;i++){
    ans[i] = ans[i-1] + isPrime(i);
  }

  while(scanf("%d",&n) != EOF){
    printf("%d\n",ans[n]);
  }

  return 0;
}

Measured memory_bytes: 4124
#include<stdio.h>
int main(void)
{
	int w,h,c,x,z;
	scanf("%d %d %d",&w,&h,&c);
	if(w>h){
		x=w;
	}
	if(w<h){
		x=h;
	}
	while(1){
		if(w%x==0&&h%x==0){
			break;
		}
		x=x-1;
	}
	z=(w/x)*(h/x);
	z=z*c;
	printf("%d\n",z);
	return 0;
}


Measured memory_bytes: 2048
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

const LL mod = 1e9 + 7;

int main() {

	map<int, int> a;

	int N;
	cin >> N;
	REP(i, N) {
		int b;
		cin >> b;
		a[b]++;
	}
	LL ans = 0;
	for (auto i : a) {

		int x = i.first;
		int y = i.second;
		if (x == y) { continue; }
		if (x < y) { ans += (y - x); }
		if (x > y) { ans += y; }

	}
	cout << ans << endl;

}

Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int m[64][64], in[64][32];

int main(){
  int n, f, day;
  while(scanf("%d", &n) && n){
    memset(m, 0, sizeof(m));
    memset(in, 0, sizeof(in));

    rep(i, n){
      scanf("%d", &f);
      rep(j, f){
	scanf("%d", &day);
	in[i][day] = 1;
      }
      m[i][i] = 1;
    }
    
    REP(d, 1, 31){
      set<int>s;
      rep(i, n){
	if(!in[i][d]) continue;
	rep(j, n) if(m[i][j]) s.insert(j);
      }
      rep(i, n){
	if(!in[i][d]) continue;

	for(set<int>::iterator it = s.begin(); it != s.end(); it++){
	  //	  cout << *it << endl;
	  m[i][*it] = 1;
	}
      }
      /*      rep(i, n){
	rep(j, n) printf("%d ", m[i][j]);
	puts("");
	}*/

      if(s.size() == n){
	printf("%d\n", d);
	goto e;
      }
    }
    printf("-1\n");
  e:;
  }
  return 0;
}

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

int main() {
  int a=0,b=0,c=0;
  string s;
  cin >> s;
  r(i,s.size()){
    if(s[i]=='a')a++;
    else if(s[i]=='b')b++;
    else c++;
  }
  if(a-b>1||a-c>1||b-a>1||b-c>1||c-a>1||c-b>1)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}

Measured memory_bytes: 512
/*----- || Hare Krishna || -----*/

/*  "WHY DO WE FALL, BRUCE?"  */

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define elif else if
#define pb push_back
#define pf push_front
#define PI 3.1415926535897932384
#define MOD 1000000007
using namespace std;

char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

string s;
int t;

bool comp(pair<ll,ll> p1, pair<ll,ll> p2){
	return p1.first<p2.first;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n;
    cin >> n;
    vector<pair<ll,ll>> vec;
    for(int i=0; i<n; i++){
    	ll a,b;
    	cin >> a >> b;
    	vec.pb({a,b});
	}
	
	ll ans=-1;
	
	ll maxA=LLONG_MIN, minA=LLONG_MAX, maxB=LLONG_MIN, minB=LLONG_MAX;
	
	for(int i=0; i<n; i++){
		
		ll A,B;
		ll x,y;
		x = vec[i].first;
		y = vec[i].second;
		
		A = x+y;
		B = x-y;
		
		maxA = max(maxA, A);
		minA = min(minA, A);
		maxB = max(maxB, B);
		minB = min(minB, B);
		
//		cout << maxA << ' ' << minA <<' ' << maxB << ' ' <<minB<<endl; 
		
		if(i!=0)
		ans = max(ans, max( maxA-minA, maxB-minB ));
		
	}
	cout << ans << endl;
}


Measured memory_bytes: 7416
def method_name(n, ai)
  bi = Array.new(n, 0)
  n.downto(1) do |i|
    sum = 0
    (2*i).step(n, i){|j| sum += bi[j-1]}
    bi[i-1] += 1 if sum.odd? != ai[i-1].odd?
  end

  puts bi.inject(&:+)
  bi.each_with_index{|v, k| puts k + 1 if v == 1}
end

n = gets.chomp.to_i
ai = gets.chomp.split.map(&:to_i)
method_name(n, ai)


Measured memory_bytes: 22300
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    //年
    int n;
    cin>>n;

    //分岐
    if(n==1) 
    {
        cout<<"Hello World"<<endl;
        return 0;
    }
    else if(n==2)
    {
        int A, B;
        cin>>A;
        cin>>B;
        cout<<A+B<<endl;
        return 0;
    }

    return 0;
}

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

int main(){
  map<int,int> mp;
  int N;
  cin >>N;
  int a;
  for(int i=0;i<N;i++){
    cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for(auto itr = mp.begin();itr != mp.end();itr++){
    if(itr -> second %2  == 1) ans++;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r;
    cin>>r;
    if(r<1200)
        cout<<"ABC";
    else
        if(r<2800)
            cout<<"ARC";
        else
            cout<<"AGC";
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    string S; cin >> S;
    int k = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == 'o') ++k;
    }                        
    if (k + 15-S.size() >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

int main() {
	// your code goes here
	string s;
	cin>>s;
	long long int n,i,c=0;
	if(s=="SAT")cout<<"1"<<endl;
	else if(s=="SUN")cout<<"7"<<endl;
	else if(s=="MON")cout<<"6"<<endl;
	else if(s=="TUE")cout<<"5"<<endl;
	else if(s=="WED")cout<<"4"<<endl;
	else if(s=="THU")cout<<"3"<<endl;
	else if(s=="FRI")cout<<"2"<<endl;
	return 0;
}

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

#define SIZE 101





int main(void){
  int length;
  char message[SIZE];
  
  //fgets(message, SIZE, stdin);
  scanf("%s",message);
  
  length = strlen(message);
  
  printf("%c%d%c\n",message[0], length - 2, message[length-1]);
  
  return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

using namespace std;
using ll =long long;
using P = pair<int,int>;

#define MAX_N 200001
#define MAX_M 200001

int N, M;
ll K = 0;
int res = 0;

ll A[MAX_N];
ll B[MAX_M];

int main(int argc, const char * argv[]) {
 
    cin >> N >> M >> K;
    
    rep(i, N){
        int a;
        cin >> a;
        A[i+1] = A[i] + a;
    }
    
    rep(i, M){
        int b;
        cin >> b;
        B[i+1] = B[i] + b;
    }
    
    for(int i=0; i<N+1; i++){
        int l = 0;
        int r = M+1;
        while(r-l > 1){
            int mid = (l+r) / 2;
            if(B[mid]<=K-A[i]) l=mid;
            else r=mid;
        }
        
        if(A[i]+B[l]<=K) res = max(res, i + l);
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 6720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c1 = sc.next();
		String c2 = sc.next();

		String c1_reverse = new StringBuffer(c1).reverse().toString();
		String c2_reverse = new StringBuffer(c2).reverse().toString();

		if (c1.equals(c2_reverse) && c2.equals(c1_reverse)){
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

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

int main() {
	int a, b, c, d, l, r;
	cin >> a >> b >> c >> d;
	l = a + b;
	r = c + d;
	if (l == r)cout << "Balanced" << endl;
	else if (l < r)cout << "Right" << endl;
	else cout << "Left" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

struct edge{
    int to, cost, enemy;
};
using Edges = vector<edge>;
using WeightedGraph = vector<Edges>;

int N, M, L;
WeightedGraph G;

int dijkstra(WeightedGraph &G, int st){
    // dmg[i][j] := iまでコストjでいくときの最小ダメージ
    vector<vector<int>> dmg(G.size(), vector<int>(L+1, INF));
    using pi = tuple<int, int, int>;
    priority_queue<pi, vector<pi>, greater<pi>> q;
    dmg[st][0] = 0;
    q.push(pi(0, 0, st));
    while(!q.empty()){
        int damage, cost, idx;
        tie(damage, cost, idx) = q.top(); q.pop();
        if(dmg[idx][cost] < damage) continue;
        // cout << damage << " " << cost << " " << idx << endl;
        // rep(i, N){
        //     rep(j, L+1){
        //         cout << dmg[i][j] << " ";
        //     }
        //     cout << endl;
        // }
        // cout << endl;
        for(auto &e: G[idx]){
            // 守る
            int nxt_cost = cost + e.cost;
            if(nxt_cost <= L && dmg[e.to][nxt_cost] > damage){
                dmg[e.to][nxt_cost] = damage;
                q.push(tie(dmg[e.to][nxt_cost], nxt_cost, e.to));
            }
            // 襲われる
            if(dmg[e.to][cost] > damage + e.enemy){
                dmg[e.to][cost] = damage + e.enemy;
                q.push(tie(dmg[e.to][cost], cost, e.to));
            }
        }
    }
    int ans = INF;
    rep(i, L+1) chmin(ans, dmg[N-1][i]);
    return ans;
}

int main(){
    cin >> N >> M >> L;
    while(N > 0){
        G = WeightedGraph(N);
        rep(i, M){
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            a--; b--;
            G[a].push_back(edge{b, d, e});
            G[b].push_back(edge{a, d, e});
        }
        cout << dijkstra(G, 0) << endl;
        cin >> N >> M >> L;
    }

}


Measured memory_bytes: 3452