akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int w, h, n;
    cin >> w >> h >> n;
    bool iswhite[110][110];
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            iswhite[i][j] = true;
        }
    }
    for(int k=0; k<n; k++){
        int x, y, a;
        cin >> x >> y >> a;
        if(a==1){
            for(int i=1; i<=h; i++){
                for(int j=1; j<=x; j++){
                    iswhite[i][j]=false;
                }
            }
        }else if(a==2){
            for(int i=1; i<=h; i++){
                for(int j=x+1; j<=w; j++){
                    iswhite[i][j]=false;
                }
            }
        }else if(a==3){
            for(int i=1; i<=y; i++){
                for(int j=1; j<=w; j++){
                    iswhite[i][j]=false;
                }
            }
        }else if(a==4){
            for(int i=y+1; i<=h; i++){
                for(int j=1; j<=w; j++){
                    iswhite[i][j]=false;
                }
            }
        }
    }
    
    int ans = 0;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(iswhite[i][j]) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
x,k,d = map(int, input().split())

if abs(x) > k*d:
  print(abs(x)-k*d)
else:
  a = abs(x)//d
  if (k-a)%2 == 0:
    print(abs(x)-a*d)
  else:
    print(abs(abs(x)-(a+1)*d))

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(x) (((long long)x>=0)?(long long)x%modulo:(long long)(x+modulo)%modulo)

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	int kaijou_set(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		int a = kaijou[n];int b = 1;int m = modulo-2;
		while(m!=0){
			if(m%2){
				b=mod(b*a);
			}
			a=mod(a*a);
			m/=2;
		}
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
};


int main(){
	int H,W,A,B;
	cin>>H>>W>>A>>B;
	combi c;
	c.kaijou_set(H+W-2);
	int ans = c.junretsu(H-1,W-1);
	for(int i=0;i<B;i++){
		int x = mod(c.junretsu(H-A-1,i)*c.junretsu(A-1,W-1-i));
		ans=mod(ans-x);
	}
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}
const int b=1e15;
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
//ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n,w;
cin>>n>>w;
int a[n][2];int maxv=0;
for(int i=0;i<n;i++){
cin>>a[i][0]>>a[i][1];maxv+=a[i][1];}
int dp[n+1][maxv+1];
for(int i=0;i<=n;i++)
dp[i][0]=0;
for(int i=1;i<=maxv;i++)
dp[0][i]=b;
for(int i=1;i<=n;i++)
for(int j=1;j<=maxv;j++)
{
    if(j<a[i-1][1])
    dp[i][j]=dp[i-1][j];
    else
    dp[i][j]=min(dp[i-1][j],dp[i-1][j-a[i-1][1]]+a[i-1][0]);
}
int ans=0;
for(int i=0;i<=n;i++)
for(int j=0;j<=maxv;j++)
    if(dp[i][j]<=w)
    ans=max(ans,j);
    cout<<ans;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

ll gcd(ll x,ll y)
{
    if(x<y) swap(x,y);
    ll r=x%y;
    x=y;
    y=r;
    if(y==0) return x;
    else return gcd(x,y); 
}

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

    ll e=c*d/gcd(c,d),vc=0,vd=0,ve=0;
    vc=b/c-a/c;
    if(a%c==0) vc++;
    vd=b/d-a/d;
    if(a%d==0) vd++;
    ve=b/e-a/e;
    if(a%e==0) ve++;

    cout<<(b-a+1)-vc-vd+ve<<endl;
    
	return 0; 
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){	
	ll n, i, ans = 0;
	cin >> n;
	vector<ll>v(n + 1);
	for(i = 1; i <= n; i++)cin >> v[i];
	map<ll , ll>mp;
	rep(i,1,n+1){
		ans += mp[i - v[i]];
		mp[i + v[i]]++;
	}
	cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input1.txt","r",stdin);
//    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
	// cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 27320
#include<iostream>
#include<math.h>
#include<set>
#include<string.h>
#define ll long long
using namespace std;


int main(){
  ll N,M;
  cin >> N >> M;
  ll H[N] = {};
  for(int i=0;i<N;i++) cin >> H[i];
  ll a[M] = {};
  ll b[M] = {};
  ll high[N] = {};
  for(int i=0;i<M;i++){
    cin >> a[i] >> b[i];
    if(H[a[i]-1] > H[b[i]-1]) high[b[i]-1]++;
    if(H[a[i]-1] < H[b[i]-1]) high[a[i]-1]++;
    if(H[a[i]-1] == H[b[i]-1]) {
      high[a[i]-1]++;
      high[b[i]-1]++;
    }
  }

  int result=0;
  for(int i=0; i<N; i++){
    if(high[i]==0) result++;
    //cout << i << ":" <<  high[i] <<" "<<endl;
  }
  cout << result << endl;



}

Measured memory_bytes: 6748
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

struct Node {
    Node *next, *prev;
    int key;
};

Node *nil;
Node* listSearch (int );
void init ();
void printList ();
void deleteNode (Node * );
void deleteFirst();
void deleteLast();
void deleteKey(int );
void insert(int );

int main(void) {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i ++) {
        scanf("%s%d", com, &key);
        if (com[0] == 'i') {
            insert(key);
            np ++;
            size ++;
        }
        else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            }
            else {
                deleteKey(key);
                nd ++;
            }
            size --;
        }
    }
    printList();
    return 0;
}

Node* listSearch(int key) {
    Node *cur = nil -> next;
    while (cur != nil && cur -> key != key) {
        cur = cur -> next;
    }
    return cur;
}

void init() {
    nil = (Node *)malloc(sizeof (Node));
    nil -> next = nil;
    nil -> prev = nil;
}

void printList() {
    Node *cur = nil -> next;
    int isf = 0;
    while (1) {
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur -> key);
        cur = cur -> next;
    }
    printf("\n");
}

void deleteNode (Node * t) {
    if (t == nil) return;
    t -> prev -> next = t -> next;
    t -> next -> prev = t -> prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil -> next);
}

void deleteLast() {
    deleteNode (nil -> prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof (Node));
    x -> key = key;
    x -> next = nil -> next;
    nil ->next -> prev = x;
    x -> prev = nil;
    nil -> next = x;
}



Measured memory_bytes: 34440
N = int(input())

A = [None] * N

x = 1
while 6 ** x <= N:
    x += 1

y = 1
while 9 ** y <= N:
    y += 1

Q = ([1] + [6 ** i for i in range(1, x)] + [9 ** i for i in range(1, y)])
Q.sort()

for n in range(1, N+1):
    if n in Q:
        A[n-1] = 1
    else:
        a = []
        for q in Q:
            if n - q > 0:
                a.append(A[(n - q)-1] + 1)
        A[n-1] = min(a)

print(A[N-1])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for(int i = 0; i<n; i++) cin>>a[i];
	int ans = 0,flag = 1;
	while(flag)
	{
		for(int i = 0; i<n; i++)
		{
			if(a[i]&1 || a[i]==0) flag = 0;
			a[i]>>=1;
		}
		if(flag) ans++;
		else break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod)
{ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
void google(int t) {cout << "Case #" << t << ": ";}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	ll l, r;
	cin >> l >> r;
	if (ceil(lld(l) / 2019) * 2019 <= r)
		cout << 0 << endl;
	else
	{
		ll ans = 1e18;
		for (ll i = l; i <= r; i++)
			for (ll j = i + 1; j <= r; j++)
				ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3608
fun main() {
    val (A, B, C, D) = readLine()!!.split(" ").map(String::toInt)
    val a = C / B + if (C % B == 0) 0 else 1
    val b = A / D + if (A % D == 0) 0 else 1
    if (a <= b) {
        println("Yes")
    } else {
        println("No")
    }
}





Measured memory_bytes: 36376
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let _ = lines.next().unwrap().unwrap();
    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let hs: Vec<i32> = splited.map(|x| x.parse().unwrap()).collect();

    let mut cur_h = hs[0];
    let mut cur_n = 0;
    let mut cur_max = -1;

    for &h in &hs[1..] {
        if h <= cur_h {
            cur_n += 1;
        } else {
            if cur_max < cur_n {
                cur_max = cur_n;
            }
            cur_n = 0;
        }
        cur_h = h;
    }

    if cur_max < cur_n {
        cur_max = cur_n;
    }

    writeln!(&mut writer, "{}", cur_max).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"5
10 4 8 7 3", br"2
",
        ),
        (
            br"7
4 4 5 6 6 5 5", br"3
",
        ),
        (
            br"4
1 2 3 4", br"0
",
        ),
    ];

    #[test]
    fn test_c() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 6396
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

A,B = imn()

for i in range(1, 10000):
    if A == math.floor(i *0.08) and B == math.floor(i*0.1):
        print(i)
        exit()
print(-1)

Measured memory_bytes: 5940
s=input()
t=input()
n=len(s)
f=0
a=[[] for i in range(26)]
for i in range(n):
    
    if len(a[ord(s[i])-97])==0:
        a[ord(s[i])-97].append(t[i])
    else:
        if a[ord(s[i])-97][0]!=t[i]:
            f=1
x=[a[i][0] for i in range(26) if len(a[i])==1]
if len(x)!=len(set(x)):
    f=1
print("Yes" if f==0 else "No")

    


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> D(n);
    copy_n(istream_iterator<int>(cin), n, D.begin());

    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            ans += D[i] * D[j];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    vi v;
    v.pb(0);
    int now = 0;
    vi ind;
    rep(i,n) {
        if(chmax(now,a[i])) {
            v.pb(a[i]);
            ind.pb(i);
        }
    }
    int sz = ind.size();
    vl sum(sz),cnt(sz);
    rep(i,n) {
        auto it = lower_bound(all(v),a[i]);
        int pos = it-v.begin()-1;
        sum[pos] += a[i]-*(it-1);
        cnt[0]++;
        cnt[pos]--;
    }
    rep(i,sz-1) cnt[i+1] += cnt[i];
    vl ans(n);
    rep(i,sz) {
        int dis = v[i+1]-v[i];
        ans[ind[i]] = sum[i]+cnt[i]*dis;
    }
    rep(i,n) cout << ans[i] << '\n';
}


Measured memory_bytes: 6844
S = [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]
K = int(input())


print(S[K - 1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#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())
int n,m;
priority_queue<int>que;
ll ans;
vector<int>query[100005];
int main(){
	cin>>n>>m;
	rep(i,n){
		int a,b;  cin>>a>>b;
		query[a].pb(b);
	}
	for(int i=1;i<=m;i++){
		rep(j,query[i].size()) que.push(query[i][j]);
		if(que.size()) {ans+=que.top(); que.pop();}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5632
import java.util.HashMap;
import java.util.Scanner;

public class Main {


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

	    Result result = execute(sc.nextLine());
        System.out.println(result);
    }

    public static Result execute(String str){
        if(!isPalindrone(str)){
            return Result.No;
        }
        int length = str.length();
        String firstHalf = str.substring(0,(length - 1)/2);
        if(!isPalindrone(firstHalf)){
            return Result.No;
        }
        String lastHalf = str.substring((length + 1)/2);
        if(!isPalindrone(lastHalf)){
            return Result.No;
        }
        return Result.Yes;
    }


    private static boolean isPalindrone(String str) {
        int length = str.length();
        if(length == 1){
            return true;
        }
        for(int i = 0; i< (length+1) / 2 ; i++){
            if(str.charAt(i) != str.charAt(length - i - 1)){
                return false;
            }
        }
        
        return true;
    }

    public static enum Result{
        Yes,
        No;
    }
}


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

int N;
vector<int> p, q;

int main() {
    cin >> N;
    vector<int> p(N), q(N);

    for(int i = 0; i < N; ++i) {
        cin >> p[i], --p[i];
    }
    for(int i = 0; i < N; ++i) {
        cin >> q[i], --q[i];
    }

    map<vector<int>, int> order;
    int iter = 0;

    vector<int> v(N);
    for(int i = 0; i < N; ++i) {
        v[i] = i;
    }

    do {
        order[v] = iter++;
    } while(next_permutation(v.begin(), v.end()));

    cout << abs(order[p] - order[q]) << endl;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    scanf("%d",&n);
    scanf("%d",&k);
    int arr[n+5];
    for(int i=1;i<=n;i++)
    {
    scanf("%d",&arr[i]);
    }
    int dp[n+k];
    for(int i=0;i<=n;i++)dp[i]=1e9+5;
    dp[1]=0;
   for(int i=1;i<=n;i++)
    {
     
     for(int j=i;j<=i+k;j++)
     if(j<=n)
         dp[j]=min(dp[j],dp[i]+abs(arr[i]-arr[j]));
    }
    printf("%d",dp[n]);
    return 0;
}


Measured memory_bytes: 1024
### 解説読んでから書いたコード
n, m = map(int, input().split())
MOD = 1000000007
if m > 0:
    a = [int(input()) for i in range(m)]
else:
    a = []

a.append(-1)
a_i = 0

step = [0] * (n+2)
step[-1] = -1
step[0] = 1
for i in range(1, n+1):
    if a[a_i] == i:
        step[i] = -1
        a_i += 1
    else:
        if step[i-2] == step[i-1] == -1:
            print(0)
            exit()
        elif step[i-2] == -1 or step[i-1] == -1:
            step[i] = max(step[i-2], step[i-1])
        else:
            step[i] = (step[i-2] + step[i-1]) % MOD
            
print(step[n])

Measured memory_bytes: 7848
a, b, k = map(int, input().split())
mx = max(a, b)
match, ans = 0, 0

for i in range(mx):
    if ((a % (mx - i)) == 0) and ((b % (mx - i)) == 0):
        
        match += 1
        ans = mx - i
        
        if match == k:
            break
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int N; cin>>N;
  ll sum = 0;
  for(int i=1; i<=N; i++) {
    if(i%3==0 || i%5==0) continue;
    sum+=i;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
#include <climits>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

const int MAX_N=1<<17;

//セグメント木を持つグローバル配列
int n;
ll dat[2*MAX_N-1];

//初期化
void init(int n_){
    //簡単のために要素数を2のべき乗に
    n=1;
    while(n<n_) n*=2;

    //全ての値をINT_MAXに
    for(int i=0;i<2*n-1;i++) dat[i]=2147483647;
}

//k番目の値(0-indexed)をaに変更
void update(int k,ll a){
    //葉の節点
    k+=n-1;
    dat[k]=a;
    //登りながら更新
    while(k>0){
        k=(k-1)/2;
        dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
}

//[a,b)の最小値を求める
//後ろの方の引数は、計算の簡単のための引数
//ｋは接点の番号、l,rはその接点が[l,r)に対応づいていることを表す
//したがって、外からはquery(a,b,0,0,n)として呼ぶ
ll query(int a,int b,int k,int l,int r){
    //cout<<l<<r<<endl;
    //[a,b)と[l,r)が交差しなければ,INT_MAX
    if(r<=a || b<=l) return 2147483647;

    //[a,b)が[l,r)を完全に含んでいれば、この節点の値
    if(a<=l && r<=b) return dat[k];
    else{
        //そうでなければ、２つの子の最小値
        ll vl=query(a,b,k*2+1,l,(l+r)/2);
        ll vr=query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
}

int main(){
  int q,com,j,s,t;
  ll x,y;
  cin>>y>>q;
  init(y);

  for(int i=0;i<q;i++){
      cin>>com;
      if(com==0){
          cin>>j>>x;
          update(j,x);
      }else{
          cin>>s>>t;
          ll a=query(s,t+1,0,0,n);
          cout<<a<<endl;;
      }

  }
  //for(int i=0;i<7;i++) cout<<dat[i]<<endl;
}



Measured memory_bytes: 5136
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n, k;
  scan(n, k);
  k -= 1;
  string s;
  scan(s);
  s[k] = s[k] - 'A' + 'a';
  print(s);

  return 0;
}


Measured memory_bytes: 888
while 1:
	n,k = map(int,raw_input().split())
	s = [0]*(n+1)
	ss = [0]*(n+1)
	if n == 0: break
	c = sorted([int(raw_input()) for i in range(k)])
	use0 = -1
	if c[0] == 0:
		use0 = 1
		c.pop(0)
	for i in c:
		s[i] = s[i-1]+1
		ss[i] = ss[i-1]+1
		if s[i-1] == 0 and s[i-2] > 0:
			ss[i] = s[i] + s[i-2] + 1
	print max(s) if use0 == -1 else max(ss)
	

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

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

    map<string, int> m;
    string s;
    int mx = 0;
    for (int i = 0; i < n; i++) {
        cin>>s;
        m[s]++;
        mx = max(mx, m[s]);
    }

    vector<string> most;
    for (pair<string, int> e : m) {
        if (e.second == mx) most.push_back(e.first);
    }

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

    for (int i = 0; i < most.size(); i++) {
        cout<<most[i]<<endl;
    }

}



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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

#define deb(x) cerr<<#x<<":"<<x<<"\n";
#define dvi(x) for(ll i=0;i<x.size();i++)cerr<<#x<<"["<<i<<"]:"<<x[i]<<" ";
#define iter(v) for(auto it:v)
#define wt ll t;cin>>t;while(t--)
#define rl(x) ll x;cin>>x;
#define rvi(x,n) vi x(n);for(ll i=0;i<n;i++) cin>>x[i];
#define rs(x) string x;cin>>x;
#define w(x) cout<<x<<endl;
#define wvi(x) for(ll i=0;i<x.size();i++) cout<<x[i]<<" ";cout<<endl;
#define ws(x) cout<<x<<endl;
#define all(v) v.begin(),v.end()
#define pb push_back
#define ppb pop_back
#define pll pair<ll, ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
const ll N = 1e9+7;

map<long long, long long> factorize(long long n) {	//returns map containing factor and multiplicity, Eg: 60 = {{2,2},{3,1},{5,1}}
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}

void FAST() {	//FAST Input Output, DONT use both scnaf,prllf / cin,cout , Use any ONE system
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll dfs(vvi gr,ll i,ll an)
{
	ll ans=1;
	for(auto it:gr[i])
	{
		if(it==an)continue;
		ans+=dfs(gr,it, i);
	}
	return ans;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt","w", stdout);
    #endif
	FAST();
	rl(x)
	if(x)cout<<0;
	else cout<<1;
}

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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


int main(){
    int n,x,t;
    cin>>n>>x>>t;
    
    int ans;
    ans = n/x;
    if(n%x!=0)ans++;
    cout<<t*ans<<endl;
}



Measured memory_bytes: 3628
s = input()
a = []
sbox = []

for i in s:
    a.append(int(i))

n = len(a)

def f(i, box, k):
    if i == n-1:
        box += k
        sbox.append(box)
    else:
        f(i + 1, box + k, a[i + 1])
        f(i + 1, box, 10 * k + a[i + 1])

f(0, 0, a[0])
print(sum(sbox))


Measured memory_bytes: 3064
let rec f x y m=if y=0then 1else let z=f(x*x mod m)(y/2)m in if y mod 2=1then x*z mod m else z and p n=if n==2then true else if n<2||n mod 2=0then false else if f 2(n-1)n=1then true else false and($)i a=if i=0then Printf.printf"%d
"a else(i-1)$(if p(read_int())then a+1else a);;(read_int())$0

Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int64_t> a(n);
  vector<int64_t> b(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i)>>b.at(i);
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  int ma=(n%2==1?a.at(n/2):a.at((n-1)/2)+a.at((n-1)/2+1));
  int mb=(n%2==1?b.at(n/2):b.at((n-1)/2)+b.at((n-1)/2+1));
  cout<<mb-ma+1<<endl;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N, C;
  cin >> N >> C;
  vector<int> x(N + 2), v(N + 2);
  rep(i, 1, N + 1) { cin >> x[i] >> v[i]; }
  int ans = 0;

  vector<int> y(x), w(v);
  rep(i, 0, N + 1) { y[i] = C - y[i]; }
  rep(i, 1, N + 1) { v[i] += v[i - 1]; }
  rrep(i, 1, N + 1) { w[i] += w[i + 1]; }

  vector<int> fx(v), fy(w);
  rep(i, 1, N + 1) { fx[i] -= x[i]; }
  rrep(i, 1, N + 1) { fy[i] -= y[i]; }

  vector<int> gx(fx), gy(fy);
  rep(i, 1, N + 1) { chmax(gx[i], gx[i - 1]); }
  rrep(i, 1, N + 1) { chmax(gy[i], gy[i + 1]); }

  rrep(i, 1, N + 2) {
    int score = fy[i] - y[i] + gx[i - 1];
    chmax(ans, score);
  }

  rep(i, 0, N + 1) {
    int score = fx[i] - x[i] + gy[i + 1];
    chmax(ans, score);
  }

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


Measured memory_bytes: 6528
S = list(input())

for i in range(len(S)):
    S[i] = int(S[i])
    
mae = S[0]*10 + S[1]
ato = S[2]*10 + S[3]

if (1 <= mae <= 12) and (1 <= ato <= 12):
    print('AMBIGUOUS')

elif (1 <= mae <= 12) and (ato < 1 or 12 < ato):
    print('MMYY')
    
elif (mae < 1 or 12 < mae) and (1<= ato <= 12):
    print('YYMM')

else:
    print('NA')


Measured memory_bytes: 3060
n = int(input())
a = n-(n//100)*100
b = a-(a//10)*10
if b == 2 or b == 4 or b == 5 or b == 7 or b == 9:
  print("hon")
if b == 0 or b == 1 or b == 6 or b == 8:
  print("pon")
if b == 3:
  print("bon")



Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,k;
    cin >> n >> k;
    ll num=1;
    rp(i,n){
        if(num<=k) num*=2;
        else num+=k;
    }
    print(num);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "Yes" << endl;
  exit(0);
}

void no() {
  cout << "infinity" << endl;
  exit(0);
}

int main() {
  // a[i][j] = iは高橋or青木
  vector<ll> t(2);
  vector<vector<ll>> a(2, vector<ll>(2));
  REP(i, 2) { cin >> t[i]; }
  REP(i, 2) {
    REP(j, 2) { cin >> a[i][j]; }
  }
  vector<ll> diff(2);
  ll tak = 0, aok = 0;
  REP(i, 2) {
    tak += a[0][i] * t[i];
    aok += a[1][i] * t[i];
    diff[i] = tak - aok;
  }
  diff[1] += -diff[0];
  // REP(i, 2) { DUMP(diff[i]); }
  ll sum = diff[0] + diff[1];
  ll step = diff[0];
  if (sum == 0) {
    no();
  }

  if (step > 0 && sum > 0 || step < 0 && sum < 0) {
    cout << 0 << endl;
    return 0;
  }

  ll ans;
  step = abs(step);
  sum = abs(sum);
  ans = (step % sum == 0) ? step / sum * 2 : step / sum * 2 + 1;
  cout << ans << endl;
}

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


int main(){
	
	int n;
	scanf("%d", &n);
	long long int total = 0;
	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=n; j++){
			for(int k = 1; k<=n; k++){
				total += __gcd(i, __gcd(j, k));
			}
		}
	}
	printf("%d", total);
}

Measured memory_bytes: 3844
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Console;

namespace CPLib
{
    class Atria
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            long sum = 0;
            int[] cnt = new int[(int)1E5+1];
            for (int i = 0; i < n; i++)
            {
                sum += s[i];
                cnt[s[i]]++;
            }
            int q = int.Parse(ReadLine());
            for (int i = 0; i < q; i++)
            {
                int[] bc = ReadLine().Split(' ').Select(int.Parse).ToArray();
                sum += (bc[1] - bc[0]) * cnt[bc[0]];
                cnt[bc[1]] += cnt[bc[0]];
                cnt[bc[0]] = 0;
                WriteLine(sum);
            }
        }
    }
}


Measured memory_bytes: 51244
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll A, B, C;
  cin >> A >> B >> C;
  cout << max(0LL, C - A + B) << rt;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = sorted(li())
half = A[-1]//2

ind = bisect.bisect_left(A, half)

if A[ind]!=half:
    if ind > 0 and half - A[ind-1] < A[ind] - half:
        ind -= 1
if ind == N-1:
    ind -= 1

print(A[-1], A[ind])

Measured memory_bytes: 14136
/**
 *  author: Haunted_Cpp
**/
 
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
 
template<typename T> ostream &operator << (ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream &operator << (ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream &operator << (ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
 
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }
 
#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); 
  int r, c, k;
  cin >> r >> c >> k;
  vector<vector<char>> mat(r, vector<char>(c));
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> mat[i][j];
    }
  } 
  int ans = 0;
  for (int i = 0; i < (1 << r); i++) {
    for (int j = 0; j < (1 << c); j++) {
      vector<vector<char>> g = mat;
      for (int x = 0; x < r; x++) {
        if ((i >> x) & 1) {
          for (int z = 0; z < c; z++) {
            g[x][z] = '.';
          }
        }
      }
      for (int x = 0; x < c; x++) {
        if ((j >> x) & 1) {
          for (int z = 0; z < r; z++) {
            g[z][x] = '.';
          }
        }
      }
      int cur = 0;
      for (int x = 0; x < r; x++) for (int z = 0; z < c; z++) cur += g[x][z] == '#';
      ans += cur == k;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<set>

using namespace std;

int main(){
	set<string> st;
	int n; cin >> n;

	for (int i = 0; i < n; i++){
		string act;
		string str;
		cin >> act >> str;
		if (act == "insert"){
			st.insert(str);
		}else if (act == "find"){
			set<string>::iterator itr = st.find(str);
			if (itr == st.end()){
				cout << "no" << endl;
			} else {
				cout << "yes" << endl;
			}
		}	
	}

return 0;
}

Measured memory_bytes: 32132
#include <iostream>

using namespace std;

const int MAX_N = 100;

int main() {
    int n;
    int a[MAX_N];

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

    for (int i = 0; i < n; i++) {
        cout << a[i];
        if (i < n - 1) {
            cout << " ";
        }
    }

    cout << endl;

    for (int i = 1; i < n; i++) {
        int j = i - 1;
        int v = a[i];
        
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }

        a[j + 1] = v;
        
        for (int k = 0; k < n; k++) {
            cout << a[k];
            if (k < n - 1) {
                cout << " ";
            }
        }

        cout << endl;
    }

}

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

int main() {
  ll x,y;
  cin >> x >> y;
  ll ans = 0;
  
  if(x > 0 && y > 0){
    if(abs(x) <= abs(y)){
      ans = y-x;
    }else{
      ans = x-y+2;
    }
  }else if(x > 0 && y < 0){
    if(abs(x) <= abs(y)){
      ans = abs(y)-abs(x)+1;
    }else{
      ans = abs(x)-abs(y)+1;
    }
  }else if(x < 0 && y > 0){
    if(abs(x) <= abs(y)){
      ans = abs(y)-abs(x)+1;
    }else{
      ans = abs(x)-abs(y)+1;
    }    
  }else if(x < 0 && y < 0){
    if(abs(x) < abs(y)){
      ans = abs(y) - abs(x) + 2;
    }else{
      ans = abs(x) - abs(y);
    }    
  }else if(x > 0 && y == 0){
    ans = x + 1;
  }else if(x < 0 && y == 0){
    ans = abs(x);
  }else if(x == 0 && y > 0){
    ans = y;
  }else{
    ans = abs(y) + 1;
  }
  
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n;
cin >> n;
int ans = n/3;
cout << ans << endl;
return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, K; cin >> N >> K;
	YES(N / 2 +(N&1)>= K);

	return 0;
}


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

#define MAX_DATA	(1000)
#define MAX_LEN		(100)

/*win_p??¬??????0xXY (X:???????????????Y:??±?????????) 1???WIN 0:LOSE */
int func(char *taro_dt_p,char *hana_dt_p, int *win_p)
{
	int wk;
	int rtn;
	int i;
	int flg;
	int max;

	if (strlen(taro_dt_p) > strlen(hana_dt_p)) {
		max = strlen(taro_dt_p);
	}
	else {
		max = strlen(hana_dt_p);
	}
	for (flg=i=0 ; i<max ; i++) {
		if (taro_dt_p[i] != hana_dt_p[i]) {
			flg++;
			break;
		}
	}
	if (flg == 0) {
		rtn = 1;
		*win_p = 0x11;
	}
	else {
		wk = taro_dt_p[i] - hana_dt_p[i];
		if (wk > 0) {
			rtn = 3;
			*win_p = 0x10;
		}
		else {
			rtn = 3;
			*win_p = 0x01;
		}
	}
	return rtn;
}


int main()
{
	int n;
	int i;
	int win_flg;
	int rtn;
	int hana=0;
	int	taro=0;
	char hana_dt[MAX_DATA][MAX_LEN];
	char taro_dt[MAX_DATA][MAX_LEN];
	

	scanf("%d",&n);
	for (i=0 ; i<n ; i++) {
		scanf("%s %s",&(taro_dt[i][0]),&(hana_dt[i][0]));
		rtn = func(&(taro_dt[i][0]),&(hana_dt[i][0]),&win_flg);
		if ((win_flg & 0x10) != 0) {
			taro += rtn;
		}
		if ((win_flg & 0x01) != 0) {
			hana += rtn;
		}
	}

	printf("%d %d\n",taro,hana);
	return 0;
}

Measured memory_bytes: 796