akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
from collections import defaultdict, deque

n, m = map(int, input().split())
G = defaultdict(set)
U = 10**6
seen = set()
for _ in range(m):
  p, q, c = map(int, input().split())
  G[p+U*c].add((q+U*c, 0))
  G[q+U*c].add((p+U*c, 0))
  G[p+U*c].add((p-U, 0))
  G[q+U*c].add((q-U, 0))
  G[p-U].add((p+U*c, 1))
  G[q-U].add((q+U*c, 1))
que = deque()
que.append((1-U, 0))
while que:
  v, cnt = que.popleft()
  if v in seen:
    continue
  if v == n-U:
    print(cnt)
    exit()
  seen.add(v)
  for nv, cost in G[v]:
    if cost == 0:
      que.appendleft((nv, cnt+cost))
    else:
      que.append((nv, cnt+cost))
print(-1)

Measured memory_bytes: 236148
#include<bits/stdc++.h>
using namespace std;
inline int readInt()
{
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while (ch < '0' || ch > '9')
		{
			if (ch == '-')	sign = -1;
			ch = getchar();
		}
	while (ch >= '0' && ch <= '9')
		{
			n = (n << 1) + (n << 3) + (int)(ch - '0');
			ch = getchar();
		}
	return n * sign;
}
int main()
{
	int t, n;
	n = readInt();
			int a[n + 2], b[n + 2], c[n + 2], mx = 0;
			b[0] = 0;
			for (int i = 1; i <= n; i++)
				{
					a[i] = readInt();
					b[i] = __gcd(b[i - 1], a[i]);
				}
			c[n + 1] = 0;
			for (int i = n; i >= 1; i--)
				c[i] = __gcd(c[i + 1], a[i]);
			mx = max(c[2], b[n - 1]);
			for (int i = 2; i < n; i++) mx = max(mx, __gcd(b[i - 1], c[i + 1]));
			printf("%d\n", mx);
}

Measured memory_bytes: 1408
//21-03-2K20

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 305
int main()
{
    fastio;
    int n,i,sum=0;
    cin>>n;

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

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

    vector<int> c(n-1);
    for(i=0;i<n-1;i++)
        cin>>c[i];

    for(i=0;i<n;i++)
    {
        sum+=b[a[i]-1];
            //cout<<sum<<"\n";
        if(i>0 && a[i]==(a[i-1]+1))
            {
                sum+=c[a[i-1]-1];
               // cout<<sum<<"\n";
            }
    }

    cout<<sum<<"\n";    //:D
    return 0;
}


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

int main()
{
    ll n;
    cin>>n;
    set<ll> data;

    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        if( data.find(x) != data.end() )
        {
            data.erase( x) ;
        } else data.insert(x);
    }
    cout<<data.size();
}

Measured memory_bytes: 8248
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        t: usize,
        mut ab: [(usize, usize); n],
    }
    ab.sort_by_key(|x| x.0);
    let mut dp = vec![0; t+3001];

    for &(a, b) in ab.iter() {
        for i in (0..t).rev() {
            dp[i + a] = max(dp[i + a], dp[i] + b);
        }
    }

    println!("{}", dp.into_iter().max().unwrap());
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<ll> a(n);
	rep (i, 0, n)
		cin >> a[i];

	ll res = 0;
	vector<ll> b;
	rep (i, 0, n)
		b.push_back(a[i] - (i + 1));

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

	ll mid = b[b.size() / 2];
	rep (i, 0, n) {
		res += abs(a[i] - (mid + (i + 1)));
	}

	cout << res << endl;
	return 0;
}


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

int main(){
    int N; cin >> N;
    string S; cin >> S;

    int count = 0;
    for (int i = 0; i < N; i++)
    {
        if(S.substr(i,3) == "ABC") count++;
    }
    cout << count << endl;
}


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

int main(){
	long int gcd[200],num1,num2,lcm[200];
	int a,b;
	int i=0;
	
	while(cin >> a >> b){
		num1 = a;
		num2 = b;
	
		if( a<b ){
			num2 = a;
			num1 = b;
		}
		
		while( (gcd[i]=num1%num2) != 0){
			num1 = num2;
			num2 = gcd[i];
		}
		gcd[i] = num2;
		lcm[i] = a / gcd[i] * b;
		i++;
	}
	
	for(int j=0; j<i; j++)
		cout << gcd[j] <<" "<< lcm[j] << "\n";
	
	return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    while(!(h == 0 && w == 0)){
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if(i == 0 || i == h - 1 || j == 0 || j == w - 1){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}



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

int main()
{
    int n1, n2, n3, mayor, suma;
    cin>>n1 >> n2>> n3;

    if ( n1 >= n2 && n1 >= n3 ){
        mayor=n1;
    }
    else{
        if ( n2 > n3 ){
            mayor=n2;
        }
        else{
            mayor=n3;
        }
    }
    
    suma=n1+n2+n3-mayor;
    cout<<suma;

}

Measured memory_bytes: 3616
N = int(input())
B = list(map(int, input().split()))

if N == 2:
	print(B[0]*2)
elif N == 3:
	if B[0] < B[1]:
		print(B[0]*2 + B[1])
	else:
		print(B[0] + B[1]*2)
else:
	li = []
	for i in range(N-2):
		li.append(min(B[i],B[i+1]))
		
	
	print(B[0] + sum(li) + B[N-2])

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

int main() {
  string n; int sum=0; cin >> n;
  for(int i=0;i<n.size();i++){
    string c = n.substr(i, 1);
    sum += stoi(c);
  }
  if(sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> dp(W+2000);
    for (int i = 0; i < N; i++) {
        int v, w;
        cin >> v >> w;
        for (int j = 0; j < W; j++) {
            dp[j+w] = max(dp[j+w], dp[j]+v);
        }
    }
    cout << dp[W] << endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int main () {
  long H, W;
  cin >> H >> W;
  long ans = 0;
  if(H == 1 || W == 1){
    cout << 1 << endl;
    return 0;
  }
  if(H % 2 == 0){
    ans += W * (H / 2);
  } else {
    ans += W * (H / 2);
    ans += (W + 2 - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	int n ; cin >> n ;
	vector<long long> enemy(n+1) ;
	for(int i=0;i<n+1;i++) cin >> enemy.at(i) ;
	vector<long long> per(n) ;
	for(int i=0;i<n;i++) cin >> per.at(i) ;
	long long ans = 0 ;
	for(int i=0;i<n;i++){
		if(enemy.at(i)>per.at(i)){
			ans += per.at(i) ;
		}else{
			ans += enemy.at(i) ;
			per.at(i) -= enemy.at(i) ;
			if(enemy.at(i+1)>per.at(i)){
				ans += per.at(i) ;
				enemy.at(i+1) -= per.at(i) ;
			}else{
				ans += enemy.at(i+1) ;
				enemy.at(i+1) = 0 ;
			}
		}
	}
	cout << ans << endl ;
}

Measured memory_bytes: 1792
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h> 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <boost/math/common_factor.hpp>
#include <algorithm>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include<chrono>
 
using namespace std;
//using namespace std::chrono;
 
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vl int64_t


int main()
{
  ll n;
  cin>>n;
  if(n%2==1)
    cout<<0;
  
  else
  {
  	/*ll prod=1;
  	for(ll i=2;i<=n;i+=2)
  	prod*=i;
  	
  	cout<<prod<<endl;*/
    ll ctr=0;
    n/=2;
    for(ll i=1; ;i++)
    {
    	ll val=pow(5,i);
    	if(n/val==0)
    	break;
    	
    	else
    	ctr+=n/val;
    }
    
    cout<<ctr;
  }
}


Measured memory_bytes: 384
import java.util.Scanner;
 
public class Main {
	static int count = 0;
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
 
    System.out.println(counter(N, ""));
  }
  public static int counter(long n, String num) {
    if (!num.equals("") && Long.valueOf(num) > n) {
      return 0;
    } 
    if (num.contains("7") && num.contains("5") && num.contains("3")) {
    	count++;
    }
    counter(n, num + "7");
    counter(n, num + "5");
    counter(n, num + "3");
    return count;
  }
}


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

int main(){

    int n;
    cin>>n;
    vector<int> a(n);
    bool check=true;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]) check=false;
    }
    cout<<(check?"YES":"NO")<<endl;


    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
    public static void Main()
    {
        int n = GetInt();
        int ans = 0;
        for (int i = 1; i <= n; i++)
        {
            ans += i;
        }
        Console.WriteLine(ans);
    }
}

public static class MyIO
{
    private static string[] args = null;
    private static int num = -1;
    private static int used = -1;

    private static string getArg()
    {
        if (used == num)
        {
            args = Console.ReadLine().Split(' ');
            num = args.Length;
            used = 0;
        }
        return args[used++];
    }

    public static int GetInt() { return int.Parse(getArg()); }
    public static long GetLong() { return long.Parse(getArg()); }
    public static double GetDouble() { return double.Parse(getArg()); }
    public static string GetString() { return getArg(); }
}


Measured memory_bytes: 11092
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 2005
using namespace std;
int n,num,k,x[MN],y[MN],d[MN][MN],head[MN];
struct edge{int to,next;}g[MN<<1];
void dfs(int *d,int u,int f){
	for(int i=head[u];i;i=g[i].next)if(g[i].to!=f)d[g[i].to]=d[u]+1,dfs(d,g[i].to,u);
}
void ins(int u,int v){g[++num].next=head[u];head[u]=num;g[num].to=v;}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++)scanf("%d%d",&x[i],&y[i]),ins(x[i],y[i]),ins(y[i],x[i]);
	for(int i=1;i<=n;i++)dfs(d[i],i,i);
	if(k%2){
		int res=0x3f3f3f3f;
		for(int i=1;i<n;i++){
			int ans=n;
			for(int j=1;j<=n;j++){
				if(d[x[i]][j]<=k/2)ans--;
				if(d[y[i]][j]==k/2&&d[x[i]][j]>k/2)ans--;
			}res=min(res,ans);
		}printf("%d\n",res);
	}else {
		int res=0x3f3f3f3f;
		for(int i=1;i<=n;i++){
			int ans=n;
			for(int j=1;j<=n;j++)if(d[i][j]<=k/2)ans--;
			res=min(res,ans);
		}printf("%d\n",res);
	}
}

Measured memory_bytes: 16000
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Queue;
import java.util.Scanner;

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

        int n = scanner.nextInt();
        int[] data = new int[120];

        for (int i = 0; i < n; ++i) {
            int b = scanner.nextInt() - 1, f = scanner.nextInt() - 1, r = scanner.nextInt() - 1, v = scanner.nextInt();
            int key = r + 10 * f + 30 * b;
            data[key] += v;
        }

        for (int i = 0; i < 4; ++i) {
            for (int j = 0; j < 3; ++j) {
                for (int k = 0; k < 10; ++k) {
                    int key = k + 10 * j + 30 * i;
                    System.out.print(" " + data[key]);
                }
                System.out.println();
            }
            if (i != 3) System.out.println("####################");
        }
    }
}


Measured memory_bytes: 29204
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,n) for(int i=0;i<n;i++)
#define PRINT(a) cout<<a<<"\n"
#define QUO(x,y) (x-x%y)/y
 
int main(){

	int a,b;
	cin>>a>>b;

	PRINT((a+b)%24);
	
	

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#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;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
const int LOG=64;
ll basis[LOG];

void insertVector(ll mask) {
    F0R(i,LOG) {
        if((mask&(1LL<<i))==0) continue;
        if(!basis[i]) {
            basis[i]=mask;
            return;
        }
        mask^=basis[i];
    }
}

bool checkVector(ll mask) {
    F0R(i,LOG) {
        if((mask&(1LL<<i))==0) continue;
        if(!basis[i])
            return false;
        mask^=basis[i];
    }
    return true;
}

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

    int tt;
    cin >> tt;
    while(tt--) {
        int n;
        cin >> n;
        memset(basis,0,sizeof(basis));
        vector<ll> arr(n);
        F0R(i,n)
            cin >> arr[i];
        string s;
        cin >> s;
        for(int i=n-1; ~i; i--) {
            if(s[i]=='0')
                insertVector(arr[i]);
            else {
                if(!checkVector(arr[i])) {
                    cout << "1\n";
                    goto end;
                }
            }
        }
        cout << "0\n";
        end:;
    }

    return 0;
}


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

void printv(vector<ll> v) {
  for (ll i : v)
    cout << i << endl;
}

int main() {
  ll n, p, q;
  cin >> n >> p >> q;
  vector<ll> l;
  ll sumC = 0;
  rep(i, n) {
    ll c;
    cin >> c;
    sumC += c;
    l.push_back(c - p * (q - i));
  }
  sort(l.begin(), l.end());
  ll ans = sumC;
  ll h = sumC;
  for (ll i = 1; i < n + 1; i++) {
    h = h - l[i-1] + 2 * (i - 1) * p;
    ans = max(ans, h);
  }
  cout << ans << endl;
}



Measured memory_bytes: 7088
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

#Union Find
class UF(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0]*n
        self.size = [1]*n

    # x が属する集合の代表値を返す
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # x と y の集合を結合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    # x と y が同じ集合に属するか判定する
    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    # x が属する集合の要素数を返す
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

N,M,K = LI()
A,B = LIR(M,2)
C,D = LIR(K,2)

b = defaultdict(set)
t = defaultdict(set)

uf = UF(N)

for i in range(M):
    uf.union(A[i]-1,B[i]-1)
    t[A[i]-1].add(B[i]-1)
    t[B[i]-1].add(A[i]-1)

num = [0]*N
for i in range(K):
    if uf.is_same(C[i]-1, D[i]-1):
        num[C[i]-1] -= 1
        num[D[i]-1] -= 1

ans = []
for i in range(N):
    ans.append(uf.get_size(i)-1-len(t[i])+num[i])
print(*ans)

Measured memory_bytes: 131164
import java.util.*;

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

    boolean tmp = true;

    while(tmp == true){
      int x = sc.nextInt();
      int y = sc.nextInt();

      if(x == 0 && y == 0){
        tmp = false;
        break;
      }

      System.out.println(Math.min(x, y) + " " + Math.max(x, y));
    }
  }
}



Measured memory_bytes: 35096
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
#define N 1010
#define ll long long
const ll mod =1e9+7;

int main()
{
    char s[4];
    cin>>s;
    int a=(s[0]-'0')*10+s[1]-'0';
    int b=(s[2]-'0')*10+s[3]-'0';
    if(a+b==0 || a==0&&b>12 || b==0&&a>12 ||(a>12&&b>12)){printf("NA\n");return 0;}
    else if(b<=12&&b!=0)
    {
        if(a==0)printf("YYMM\n");
        else if(a<=12)
            printf("AMBIGUOUS\n");
        else
            printf("YYMM\n");
    }
    else if(a<=12)
    {
        if(b==0)printf("MMYY\n");
        else if(b<=12)
            printf("AMBIGUOUS\n");
        else
            printf("MMYY\n");

    }
    return 0;
}


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

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

	static class D_GridGame {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int height = in.nextInt();
			int width = in.nextInt();
			int n = in.nextInt();
			Obstacle[] os = new Obstacle[n];
			for (int i = 0; i < n; i++) {
				os[i] = new Obstacle();
				os[i].x = in.nextInt() - 1;
				os[i].y = in.nextInt() - 1;
			}
			Arrays.sort(os, (a, b) -> (a.x - b.x));

			int p = 0;
			int[] maxY = new int[height];
			for (int x = 1; x < height; x++) {
				boolean canExtend = true;
				while (p < n && os[p].x == x) {
					if (maxY[x - 1] + 1 == os[p].y) {
						canExtend = false;
					}
					++p;
				}
				maxY[x] = maxY[x - 1];
				if (canExtend) {
					++maxY[x];
				}
			}

			int ans = height;
			for (int i = 0; i < n; i++) {
				if (os[i].x > 0 && maxY[os[i].x - 1] >= os[i].y) {
					ans = Math.min(ans, os[i].x);
				}
			}
			out.println(ans);
		}

		class Obstacle {
			int x;
			int y;

		}

	}

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

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

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

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

	}
}



Measured memory_bytes: 53156
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int n, m, q;
vector<string> A;
int node[2200][2200];
int vedge[2200][2200];
int hedge[2200][2200];

int main() {
  std::ios::sync_with_stdio(false);
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin>>n>>m>>q;
  string s;
  rep(i, m+1) s += "0";
  A.pb(s);
  rep(i, n) {
  	cin>>s;
  	s = "0" + s;
  	A.pb(s);
  }
  
  // rep(i, n+1) cout<<A[i]<<endl;
  
  for(int i = 1;i <= n;i++) {
  	for(int j = 1;j <= m;j++) {
  		node[i][j] = node[i][j-1]+node[i-1][j]-node[i-1][j-1]+(A[i][j] == '1');
  		//cout<<node[i][j]<<" ";
  	} //cout<<endl;
  }
  
  
  
  for(int i = 1;i <= n;i++) {
  	for(int j = 1;j <= m;j++) {
  		hedge[i][j] = hedge[i][j-1]+hedge[i-1][j]-hedge[i-1][j-1]+(A[i][j] == '1' && A[i][j-1] == '1');
  		//cout<<hedge[i][j]<<" ";
  	} //cout<<endl;
  }
  
  for(int i = 1;i <= n;i++) {
  	for(int j = 1;j <= m;j++) {
  		vedge[i][j] = vedge[i][j-1]+vedge[i-1][j]-vedge[i-1][j-1]+(A[i][j] == '1' && A[i-1][j] == '1');
  		//cout<<vedge[i][j]<<" ";
  	} //cout<<endl;
  }
  
  while(q--) {
  	int x1, y1, x2, y2;
  	cin>>x1>>y1>>x2>>y2;
  	int nodes = node[x2][y2]+node[x1-1][y1-1]-node[x1-1][y2]-node[x2][y1-1];
  	int hedges = hedge[x2][y2]+hedge[x1-1][y1]-hedge[x1-1][y2]-hedge[x2][y1];
  	int vedges = vedge[x2][y2]+vedge[x1][y1-1]-vedge[x1][y2]-vedge[x2][y1-1];
  	//debug(nodes);
  	//debug(hedges);
  	//debug(vedges);
  	
  	cout<<nodes-hedges-vedges<<endl;
  }
  
  return 0;
}


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

int h1, h2, k1, k2;
int a, b, c, d;

int main() {
	cin >> h1 >> h2 >> k1 >> k2;
	cin >> a >> b >> c >> d;
	
	int h = h1 * a + (h1 / 10) * c + h2 * b + (h2 / 20) * d;
	int k = k1 * a + (k1 / 10) * c + k2 * b + (k2 / 20) * d;

	if (h > k) cout << "hiroshi" << endl;
	else if (h == k) cout << "even" << endl;
	else cout << "kenjiro" << endl;
	return 0;
}


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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
ll a, b, c, d;
int main()
{
	std::cin >> n >> a >> b >> c >> d;


	bool ok = false;
	for (int i = 0; i < n; ++i)
		if (c*(n - 1 - i) - d * i <= b - a && b - a <= -c * i + (n - 1 - i)*d)
			ok = true;

	if (ok)
		std::cout << "YES" << std::endl;
	else
		std::cout << "NO" << std::endl;
	return 0;
}


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

int main(void) {
	int N, K;
	cin >> N >> K;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int h;
		cin >> h;
		if (h >= K) ans++;
	}
	cout << ans << endl;

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define rep2r(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

using graph = vector<vector<int>>;

vector<int> topo(const graph &g) {
  const int n = g.size();
  vector<int> res;
  vector<bool> vis(n);
  auto dfs = [&](auto dfs, int u) -> void {
    if (vis[u]) return;
    vis[u] = true;
    for (int v : g[u]) {
      dfs(dfs, v);
    }
    res.push_back(u);
  };
  rep(i, n) dfs(dfs, i);
  return res;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N, M; cin >> N >> M;
  vector<vector<int>> G(N);
  vector<pair<int, int>> es;
  rep(i, M) {
    int a, b; cin >> a >> b; a--; b--;
    G[a].push_back(b);
    es.emplace_back(a, b);
  }
  vector<double> rev(N);
  vector<int> top = topo(G);
  rep(i, N) {
    vector<double> dp(N);
    dp[i] = 1;
    for (int u : top) {
      for (int v : G[u]) dp[u] += dp[v] / G[u].size();
    }
    rev[i] = dp[0];
  }
  vector<double> ep(N);
  ep[N - 1] = 0;
  for (int u : top) {
    for (int v : G[u]) {
      ep[u] += (ep[v] + 1) / G[u].size();
    }
  }
  double ans = ep[0];
  rep(i, M) {
    int a = es[i].first;
    int b = es[i].second;
    if (G[a].size() == 1) continue;
    double k = G[a].size();
    // sum(ep) / k -> (sum(ep) - ep[b]) / (k - 1)
    double sum = ep[a] * k;
    double diff = (sum - ep[b] - 1) / (k - 1) - sum / k;
    ans = min(ans, ep[0] + diff * rev[a]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
int main(){
    vector<pair<int,int> > map;
    while(true){
        int H,W;    cin>>H>>W;
        if(H==0&&W==0)break;
        map.push_back(make_pair(H,W));
    }
    rep(i,map.size()){
        rep(j,map[i].first){
            rep(k,map[i].second){
                if((j+k)%2==0)  cout<<'#';
                else cout<<'.';
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3084
n, m, k = map(int, input().split())
li = []
for t in range(n):
    li.append(list(map(int, input().split())))
price_list = []
for bit in range(1, 2**n):
    index_list = []
    for i in range(n):
        if bit & 1<<i:
            index_list.append(i)

    c = 0
    for t in range(1,m+1):
        s = 0
        for i in index_list:
            s += li[i][t]
        if s >= k:
            c += 1
        else:
            break

    if c == m:
        p = 0
        for i in index_list:
            p += li[i][0]
        price_list.append(p)

if len(price_list):
    print(min(price_list))
else:
    print('-1')
        


Measured memory_bytes: 9228
#include<stdio.h>
 

int gcd(int x,int y){
  return y == 0 ? x : gcd(y, x%y);
}


int main(){

  int a,b;

  while(scanf("%d%d",&a,&b)!= EOF){
    printf("%d\n",gcd(a,b));
  }
  return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline


n,k = map(int,input().split())
h = tuple(map(int,input().split()))

def frog_2(N, H, K):
    
    dp = [0] + [float("inf")]*(n-1)
    #print(dp)
    
    for i in range(1,n):
        for j in range(max(0,i-k),i):
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
    #print(dp)
    return print(dp[-1])

frog_2(n,h,k)



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

struct decat
{
    int C[10];
};

bool gt(decat a, decat b)
{
    int sum = 0;
    for (int i = 1; i <= 9; i++) sum += a.C[i] - b.C[i];
    if (sum > 0) return(true);
    else if (sum < 0) return(false);
    for (int i = 9; i; i--)
    {
        if (a.C[i] > b.C[i]) return(true);
        else if (a.C[i] < b.C[i]) return(false);
    }
    return(false);
}

decat inc(decat d, int p)
{
    d.C[p]++;
    return(d);
}

decat D[10005];
int A[10];

int main()
{
    int N, M, H[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
    cin >> N >> M;
    for (int i = 0; i < M; i++) cin >> A[i];
    decat b;
    for (int i = 1; i <= 9; i++) b.C[i] = 0;
    for (int i = 0; i <= N; i++) D[i] = b;
    for (int i = N; i > 0; i--)
    {
        decat cd = D[i];
        bool err = true;
        for (int j = 1; j <= 9; j++) if (cd.C[j])
        {
            err = false;
            break;
        }
        if (i < N && err) continue;
        for (int j = 0; j < M; j++)
        {
            int cur = A[j];
            if (H[cur] <= i && gt(inc(cd, cur), D[i - H[cur]])) D[i - H[cur]] = inc(cd, cur);
        }
    }
    for (int i = 9; i; i--)
    {
        for (int j = 0; j < D[0].C[i]; j++) cout << i;
    }
    cout << '\n';
    return(0);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    ll n,k;
    cin >> n >> k;
    ll r = n/k;
    ll ans = r * r * r;
    if (k % 2 == 0) {
        k /= 2;
        r = n/k - r;
        ans += r * r * r;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int w,a,b;
    scanf("%d %d %d",&w,&a,&b);
    if(b-(a+w)<=0&&a<=b){
        printf("0");
    }else if(a>b){
        printf("%d",a-(b+w));
    }else{
        printf("%d",b-(a+w));
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;




int main() {
	int W, H; cin >> W >> H;
	vector < pair<ll, int>> v;
	for (int i = 0; i < W; i++) {
		ll p; cin >> p;
		v.push_back({ p, 0 });
	}
	for (int i = 0; i < H; i++) {
		ll q; cin >> q;
		v.push_back({ q, 1 });
	}
	sort(v.begin(), v.end());
	ll ans = 0, h = 0, w = 0;
	for (int i = 0; i < H + W; i++) {
		ll r = v[i].first;
		int pq = v[i].second;
		if (pq == 0) {
			ans += (H + 1 - h)*r;
			w++;
		}
		else {
			ans += (W + 1 - w)*r;
			h++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	
	map<string, int> m;
	map<string, int>::iterator it;
	string s;
	int N, M;
	int cnt=0;
	int i;
	
	cin >> N;
	
	for(i=0; i<N; i++)
	{
		cin >> s;
		
		if(m.find(s) != m.end())
			m[s]++;
		else
			m[s] = 1;
	}
	
	cin >> M;
	
	for(i=0; i<M; i++)
	{
		cin >> s;
		
		if(m.find(s) != m.end())
			m[s]--;
		else
			m[s] = -1;
	}
	
	for(it=m.begin(); it!=m.end(); it++)
	{
		if(cnt < it->second) cnt = it->second;
	}
	
	cout << cnt;
	
	return 0;
}

Measured memory_bytes: 256
uses math;
var f,a:array[-1..10,0..1020] of longint;
var n,i,j:longint;
begin
  read(n);for i:=1 to 2 do for j:=1 to n do
  begin read(a[i,j]);f[i,j]:=max(f[i-1,j],f[i,j-1])+a[i,j];end;
  writeln(f[2,n]);
end.


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

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            double ans = 0;
            for (int b = 1; b <= x; b++)
            {
                for (int p = 2; p < 10; p++)
                {
                    double obj = Math.Pow(b, p);
                    if (ans<=obj && obj<=x)
                    {
                        ans = obj;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

int main() {
  double N, M;
  double sum = 0;
  double count = 0;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }

  double border = sum / (4 * M);

  for (int i = 0; i < N; i++) {
    if (A[i] >= border) count++;
  }


  if (count >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#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++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

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

    while (A >=0 || C >= 0)
    {
        C -= B;
        if(C <= 0)
        {
            S = "Yes";
            break;
        }

        A -= D;
        if (A <= 0)
        {
            S = "No";
            break;
        }
        
    }

    cout << S;
    
    


    return 0;
}

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

using namespace std;

using int64 = long long;

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

  int n, m;
  cin >> n >> m;
  int l = 1;
  int r = n;
  for (int i = 0; i < m; i++) {
    int local_l, local_r;
    cin >> local_l >> local_r;
    l = max(l, local_l);
    r = min(r, local_r);
  }
  int ans = (l <= r) ? (r - l + 1) : 0;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int n, m, s, g1, g2, b1, b2, c, d[101][101];
	const int INF = 700000000;
	while(scanf("%d%d%d%d%d", &n, &m, &s, &g1, &g2), n){
		for(int i = 0; i <= n; ++i){
			for(int j = 0; j <= n; ++j){
				d[i][j] = INF;
			}
			d[i][i] = 0;
		}
		
		for(int i = 0; i < m; ++i){
			scanf("%d%d%d", &b1, &b2, &c);
			d[b1][b2] = c;
		}
		
		for(int k = 1; k <= n; ++k)
		for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j){
			d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
		}
		
		int ans = INF;
		for(int i = 1; i <= n; ++i){
			ans = min(ans, d[s][i] + d[i][g1] + d[i][g2]);
		}
		printf("%d\n", ans);
	}
}

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

const int F = 3000;
bool water[F + 1], sugar[F + 1];

int main() {
    int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;
    water[0] = sugar[0] = true;
    for (int i = 1; i <= f; ++i) {
        if (i >= a) water[i] = water[i] || water[i - a];
        if (i >= b) water[i] = water[i] || water[i - b];
        if (i >= c) sugar[i] = sugar[i] || sugar[i - c];
        if (i >= d) sugar[i] = sugar[i] || sugar[i - d];
    }
    int bw = a, bs = 0;
    for (int w = a; w <= f; ++w) if (water[w]) {
        for (int s = 0; w + s <= f; ++s) if (sugar[s]) {
            if (s * 100 <= w * e && s * (bw + bs) > bs * (w + s)) {
                bw = w;
                bs = s;
            }
        }
    }
    cout << bw + bs << ' ' << bs << '\n';
    return 0;
}


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

using ll = long long;

const int MAXN = 2.1e5;
int N;
int A[MAXN];
int B[MAXN];

[[noreturn]] void NOSAD() {
	cout << -1 << '\n'; exit(0);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}

	priority_queue<pair<int, int>> pq;
	for (int i = 0; i < N; i++) {
		if (B[i] < A[i]) {
			NOSAD();
		}
		if (B[i] > A[i]) {
			pq.emplace(B[i], i);
		}
	}
	ll ans = 0;
	while (!pq.empty()) {
		int i = pq.top().second; pq.pop();
		assert(B[i] > A[i]);
		int x = (i+N-1) % N;
		int y = (i+1) % N;
		assert(B[i] >= B[x]);
		assert(B[i] >= B[y]);
		if (B[i] <= B[x] + B[y]) {
			// then we're screwed, as no one can move
			NOSAD();
		}
		if (A[i] >= B[x] + B[y]) {
			// we'll go to A[i]
			if ((B[i] - A[i]) % (B[x] + B[y]) != 0) {
				NOSAD();
			}
			ans += (B[i] - A[i]) / (B[x] + B[y]);
			B[i] = A[i];
			continue;
		} else {
			ans += B[i] / (B[x] + B[y]);
			B[i] %= B[x] + B[y];
			if (B[i] < A[i]) {
				NOSAD();
			}
			if (B[i] > A[i]) {
				pq.emplace(B[i], i);
			}
		}
	}
	cout << ans << '\n';
	return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    ll N; cin >> N;
    // N/m = N mod m  を満たすにはN/m <= m-1が必要 つまり、N <= m^2 -> m >= sqrt(N)
    // とかなんとかやってると、商が10^6以下なことに気付くので各商に対して調べる
    // 商がiのとき、あまりはp+ki
    ll ans = 0;
    int lim = sqrt(N);
    if((double) lim != sqrt(N)) lim++;
    for(int i = 1; i < lim; i++){
        if(N % i == 0 && i == N / (N/i - 1)) ans += N/i - 1; 
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;


int main(){

    int A,B,C; cin >> A >> B >> C;
    if (A==B && B== C){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
# include <iostream>
# include <cstdio>
# include <cmath>
# include <cstring>
# include <string>
# include <cstdlib>
# include <algorithm>
# include <stack>
# include <queue>
# include <vector>
# define maxx (103)
# define Pi (3.14159265358979)
# define inf (2147483647)
using namespace std;
int read() {
	int x=0,f=1;
	char ch;
	while(ch<'0'||ch>'9')  {
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=x*10+ch-'0';
		ch=getchar();
	}
	return f*x;
}
int main() {

	int n=read();
	int a=read();
	
	n%=500;
	
	if(n<=a){
		puts("Yes");
	}else{
		puts("No");
	}

	return 0;
}

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

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

  int ans = 0;
  for( int i = 1; i <= 3; ++i ){
    if( A != i && B != i ){
      ans = i;
    }
  }

  cout << ans << endl;
}


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

fn main() {
	let (x, y, z): (u32,u32,u32) = (read(), read(), read());
	println!("{} {} {}", z, x, y);
}

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: 4352
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;

    vector<char> str = {'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', '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 answer;

    for (int i=0; i<S.size(); i++) {
        auto pos = find(str.begin(), str.end(), S[i]);
        size_t index = distance(str.begin(), pos);
        answer += str[index+N];
        // cout << "an:" << answer[i] << " index:" << index << " N:" << N << " index+N:" << index+N << " str:" << str[index+N] <<  "\n";
    }
    cout << answer;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
//static const ll MOD = 1;
static const ll MAX_L = (ll)1 << 62;

static const ll FACT_SIZE = 1000000;

int main() {
	ll n, p; cin >> n >> p;
	ll o = 0, e = 0;
	rep(i, 0, n) {
		ll a; cin >> a;
		if (a & 1) o++;
		else e++;
	}

	ll k;
	if (o == 0) {
		if (p == 1) {
			cout << 0 << endl;
			return 0;
		}
		else k = e;
	}
	else k = o + e - 1;

	ll ans = 1;
	rep(i, 0, k) {
		ans *= 2;
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long r, d, x;
  cin >> r >> d >> x;
  for (int i = 1; i <= 10; i++) {
    x = r * x - d;
    cout << x << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
# coding:utf-8
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    alice_score = 0
    bob_score = 0

    for loop,num in enumerate(a):
        if loop % 2 == 0:
            alice_score += num
        else: bob_score += num 

    print(alice_score - bob_score)

if __name__ == '__main__' :
    main()

Measured memory_bytes: 3060
//minamoto
#include<bits/stdc++.h>
#define R register
#define ll long long
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
const int N=2e5+5;
int n,L,a[N];ll res,sum[N],suf[N];
int main(){
//	freopen("testdata.in","r",stdin);
	L=read(),n=read();
	fp(i,1,n)a[i]=read(),sum[i]=sum[i-1]+(a[i]<<1);
	fd(i,n,1)suf[i]=suf[i+1]+((L-a[i])<<1);
	res=max(a[n],L-a[1]);
	fp(i,1,n-1){
		R int k=min(i,n-i);R ll tmp=sum[i]-sum[i-k]+suf[i+1]-suf[i+1+k];
		cmax(res,tmp-min(a[i],L-a[i+1]));
		i>k?cmax(res,tmp+(a[i-k]<<1)-a[i]):0;
		n-i>k?cmax(res,tmp+((L-a[i+1+k])<<1)-(L-a[i+1])):0;
//		printf("%d %lld\n",i,tmp);
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 6144
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	double a,b,c,d;
	cin>>a>>b>>c>>d;
	if(ceil(c/b)>ceil(a/d)) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}



Measured memory_bytes: 3740
#include <iostream>
using namespace std;
int n,a,b;
int member[100004];
int sum;;

int main(){
	member[1]=1;
	cin >>n;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		member[a]++;
		member[b+1]--;
	}
	sum=0;
	for(int i=1;i<=n;i++){
		member[i+1]+=member[i];
		if(i+1<=member[i+1])sum=i;
	}
	cout<<sum <<endl;
}

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

int main() {
	int N, M, d, v;
	while (cin >> N >> M, N || M) {
		vector<int> tmp(M);
		for (int i = 0; i < N; ++i) {
			cin >> d >> v;
			tmp[d - 1] = max(v, tmp[d - 1]);
		}
		int ans = 0;
		for (int& i : tmp) ans += i;
		cout << ans << endl;
	}
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll llmin(ll x, ll y){
	if (x > y) return y;
	return x;
}

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++){
		cin >> h[i];
	}
	sort (h.begin(), h.end());
	ll ans = MOD;
	for (int i = 0; i <= n-k; i++){
		ans = llmin(ans, h[i+k-1] - h[i]);
	}
	cout << ans << endl;
 	return 0;
 }


Measured memory_bytes: 640
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
 
int main() {
  int p[] = {6000, 4000, 3000, 2000}, t, n;
  while(cin >>t){
    cin >>n;
    cout <<p[t - 1] * n <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010

ll MIN(ll x,ll y){return x<y?x:y;}
ll MAX(ll x,ll y){return x<y?y:x;}

int main(void){
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	ll m=MIN(a,MIN(b,c));
	ll l=MAX(a,MAX(b,c));
	ll n=(a+b+c)-m-l;
	printf("%lld",l%2==0?0:m*n);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
signed main(){
	int a,b;
	cin>>a>>b;
	cout<<lcm(a,b)<<endl;
}


Measured memory_bytes: 256
A,B,C = map(int,input().split())
K = int(input())

def dfs(i,a,b,c):
    if i == K:
        return A*(2**a)+B*(2**b)+C*(2**c)
    res1 = dfs(i+1,a+1,b,c)
    res2 = dfs(i+1,a,b+1,c)
    res3 = dfs(i+1,a,b,c+1)
    return max(res1,res2,res3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
/*
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
*/
#include <bits/stdc++.h>
#define pb push_back
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)

using namespace std;


typedef long long unsigned ll;
typedef pair<int,int> P;
typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(){

    string a,b;
    cin>>a>>b;
    cout<<b<<a<<endl;
    

    return 0;
}

Measured memory_bytes: 256