akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int X, t;
    cin >> X >> t;

    int res = X - t;

    cout << (res > 0 ? res : 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll ans=min(x*a+y*b,max(x,y)*2*c);
    if (x<y)
        ans=min(ans,x*2*c+(y-x)*b);
    else
        ans=min(ans,y*2*c+(x-y)*a);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;


#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}

int main(){
  	ll a,b,n;
    cin >> a >> b >> n;
    if(n >= b){
        cout <<(a*(b-1)/b)-a*((b-1)/b);
    }else{
        cout <<(a*n/b)-a*(n/b);
    }
}


Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

#define N_MAX 100000
#define MOD 1000000007

typedef long long int lli;

vector<int> edge[N_MAX];

void dfs(int index,int *dist)
{
	for (int i = 0; i < edge[index].size(); i++){
		if (-1 == dist[edge[index][i]]){
			dist[edge[index][i]] = dist[index] + 1;
			dfs(edge[index][i], dist);
		}
	}
	return;
}

void solv()
{
	int N, u, v; scanf("%d%d%d", &N, &u, &v);
	for (int i = 0; i < N-1; i++){
		int A, B; scanf("%d%d", &A, &B);
		A--; B--;
		edge[A].push_back(B);
		edge[B].push_back(A);
	}

	int distT[N_MAX];
	fill(distT, distT + N, -1);
	distT[u - 1] = 0; dfs(u - 1,distT);

	int distA[N_MAX];
	fill(distA, distA + N, -1);
	distA[v - 1] = 0; dfs(v - 1, distA);

	int ret = 0;
	for (int i = 0; i < N; i++){
		if (distT[i] < distA[i]){
			ret = max(ret, distA[i] - 1);
		}
	}
	
	//int enc = distT[v - 1] / 2;
	//int distT2[N_MAX];
	//fill(distT2, distT2 + N, -1);
	//for (int i = 0; i < N; i++){
	//	if (distA[i] <= enc){
	//		distT2[i] = -2;
	//	}
	//}
	//distT2[u - 1] = 0; dfs(u - 1, distT2);

	//int d = 0, index;
	//for (int i = 0; i < N; i++){
	//	if (distT2[i] > d){
	//		d = distT2[i];
	//		index = i;
	//	}
	//}

	if (0 == ret){
		if (1 == distA[u - 1]){
			printf("0");
		}
		else{
			printf("1");
		}

	}
	else{
		printf("%d", ret);
	}


	//queue<int> takahashi, aoki;
	//int visit[N_MAX]; fill(visit, visit + N, 0);
	//takahashi.push(u - 1); aoki.push(v - 1);

	//int cnt = 0;
	//while (!takahashi.empty()){
	//	queue<int> takahashi_next;
	//	while (!takahashi.empty()){
	//		int index = takahashi.front(); takahashi.pop();
	//		if (0 == visit[index]){
	//			visit[index] = 1;
	//			for (int i = 0; i < edge[index].size(); i++){
	//				if (0 == visit[edge[index][i]]){
	//					takahashi_next.push(i);
	//				}
	//			}
	//		}
	//	}

	//	queue<int> aoki_next;
	//	while (!aoki.empty()){
	//		int index = aoki.front(); aoki.pop();
	//		if (2 != visit[index]){
	//			visit[index] = 2;
	//			for (int i = 0; i < edge[index].size(); i++){
	//				if (2 != visit[edge[index][i]]){
	//					aoki_next.push(i);
	//				}
	//			}
	//		}
	//	}

	//	cnt++;
	//	while (!takahashi_next.empty()){
	//		takahashi.push(takahashi_next.front());
	//		takahashi_next.pop();
	//	}
	//	while (!aoki_next.empty()){
	//		aoki.push(aoki_next.front());
	//		aoki_next.pop();
	//	}
	//};

	//printf("%d", cnt);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 10368
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    S = list(input().rstrip())
    N = len(S)

    ans = 0
    for bit in range(1<<N-1):
        str = S[:]
        cnt = 0
        for i in range(N-1):
            if bit & 1<<i:
                str.insert(cnt+i+1, '+')
                cnt += 1
        ans += sum(map(int, ''.join(str).split('+')))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 12224
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		int[][] d1 = new int[c][c];
		int[][] c1 = new int[n][n];
		int[][] cnum = new int[3][50];
		for(int i = 0; i < c; i++) {
			for(int j = 0; j < c; j++) {
				d1[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				c1[i][j] = sc.nextInt()-1;
				cnum[(i+j)%3][c1[i][j]]++;
			}
		}
		int ans = 1000000000;
		for(int i = 0; i < c; i++) {
			for(int j = 0; j < c; j++) {
				for(int k = 0; k < c; k++) {
					if(i==j||j==k||i==k) continue;
					int res = 0;
					for(int m = 0; m < c; m++) {
						res += cnum[0][m]*d1[m][i];
						res += cnum[1][m]*d1[m][j];
						res += cnum[2][m]*d1[m][k];
					}
					ans = Math.min(ans, res);
				}
			}
		}
		System.out.println(ans);
		
	}

}

Measured memory_bytes: 91520
N = int(input())
H = list(map(int, input().split()))
H.append(0)

t = 1
ans = 0
while t > 0:
    p = H[-1]
    t = 0
    for i in range(N):
        if H[i] > 0 and p <= 0:
            ans += 1
        p = H[i]
        H[i] -= 1
        t = max(H[i], t)
        #print(ans, H[i], t)

print(ans)


Measured memory_bytes: 3188
N = int(input())
a = list(map(int, input().split()))

t = [0] * (10 ** 5 + 3)  # t[X + 1] は ai = X となる i の個数
for x in a:
    for i in range(x - 1, x + 2):
        t[i] += 1
print(max(t))


Measured memory_bytes: 13964
from sys import stdin

n = int(stdin.readline().rstrip())
x = [int(x) for x in stdin.readline().rstrip().split()]

ans = []
for j in range(1,101):
    p = j
    cost = 0
    for i in range(n):
        cost += (p- x[i])**2
    ans.append(cost)
    
print(min(ans))



Measured memory_bytes: 38640
#include<stdio.h>
int a[3]={3,5,7};
long cou=0;
long pow10(int r){
    int h=1;
    for(int i=0;i<r;i++)h*=10;
    return h;
}
int hantei(long N){
    int k=0,m,d7=0,d5=0,d3=0,h;
    while(N>0){
        m=N%10;
        if(m!=7 && m!=5 && m!=3)return 0;
        if(m==7)d7++;if(m==5)d5++;if(m==3)d3++;
        N/=10;
        if(N<=0)break;
        k++;
    }
    if(d7>0 && d5>0 && d3>0){h=1;}else{h=0;}
    return h;
}
void seisei(long N,long d,int l){
    long ret=d;
    if(d<=N){
        for(int i=0;i<3;i++){
            d=ret;
            d+=(long)a[i]*pow10(l);
            if(d<=N){cou+=hantei(d);}else{return;}
            seisei(N,d,l+1);
        }
    }
}
int main(void){
    long N;
    scanf("%ld",&N);
    seisei(N,0,0);
    printf("%ld\n",cou);
    return 0;
}






Measured memory_bytes: 128
import sys
from heapq import heappush, heappop

heap = []

while 1:
    cmd = sys.stdin.readline().split()

    if cmd[0] == 'end':
        break

    if cmd[0] == 'extract':
        print(-heappop(heap))
    else:
        heappush(heap, -int(cmd[1]))

Measured memory_bytes: 47512
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void chmax(int &a, int b) { if (a < b) a = b; }

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

    int res = 0;
    vector<vector<int> > dp(N+1, vector<int>(N+1, 0));
    for (int i = N-1; i >= 0; --i) {
        for (int j = N-1; j > i; --j) {
            if (S[i] == S[j]) chmax(dp[i][j], dp[i+1][j+1] + 1);
            chmax(res, min(dp[i][j], j-i));
        }
    }
    cout << res << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n,a,b;
  cin >> a >> b;
  cout << a * b<< endl;
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>

 int main(){
  int i, x, heap[250];
   
  scanf("%d", &x);   
  for(i = 1; i <= x; i++){
    scanf("%d", &heap[i]);
  }   
  for(i = 1; i <= x ; i++){
    printf("node %d: key = %d, ",i,heap[i]);
         if(i != 1){
      printf("parent key = %d, ",heap[i/2]);
    }
         if(x >= i * 2){
      printf("left key = %d, ",heap[2*i]);
    }
         if(x >= 1 + i * 2){
      printf("right key = %d, ",heap[2*i+1]);
    }
        printf("\n");
       }
return 0;
 }

Measured memory_bytes: 600
#include <stdio.h>
int main(void){
    long i,n,MAX,MIN,SUM=0;
    scanf("%ld",&n);
    long a[n];
    for(i=0;i<n;i++){//i=0??????i=n?????§
        scanf("%ld",&a[i]);//scanf??§????????????
    }
    MAX=a[0];//MAX???????????????a[0]????¨????
    MIN=a[0];//MIN???????????????a[0]????¨????
    for(i=0;i<n;i++){//i=0??????i=n-1?????§
        if(MAX<a[i]){//??????a[i]???MAX????????§????????£??????
            MAX=a[i];//MAX???a[i]?????????
        }
        if(MIN>a[i]){//??????a[i]???MIN???????°?????????£??????
            MIN=a[i];//MIN???a[i]?????????
        }
        SUM+=a[i];//SUM=SUM+a[i]:SUM(?????????0???a[i]~a[n-1]?????§?¶????
    }
    printf("%ld %ld %ld\n",MIN,MAX,SUM);
    return 0;
}

Measured memory_bytes: 676
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
/* Uncomment only if you are not using GNU compiler->
#include <map> #include <algorithm> #include <vector> #include <string.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <chrono> #include <thread> #include <iomanip>
*/ 
using namespace std;

#define endl "\n"
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define re(i,a) for(ll i=0; i<a; ++i)
#define tr(i,v) for(auto &i: v)
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define in(v,n) vll v(n);re(i,n) cin>>v[i]
#define printVec(v,s) cout << s; tr(i, v) cout << i << " ";
#define sz(a) int((a).size())
#define dbgv(c, v) cout << c << " = " << v << endl;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;
typedef vector< pll > vpll;
typedef vector< ll > vll;
typedef complex<double> point;

const long long MOD = 1000000007;
const long long inf = 1e18;

void solve(){
	string s, t;
    cin>>s>>t;
    if(t.length() == s.length() + 1 and t.substr(0, t.length() - 1) == s)
        cout << "Yes";
    else 
        cout << "No";
}

int main()
{

    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    	solve();

    return 0;
}


Measured memory_bytes: 3620
N = int(input())
A = list(map(int,input().split()))
flag=0
for i in range(N):
    if A[i]%2 == 0:
        if A[i]%3!=0 and A[i]%5!=0:
            flag = 1
            
if flag==0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, r;
    cin >> n >> r;
    if(n >= 10){
        cout << r;
    }
    else{
        cout << r + 100 * (10 - n);
    }

    return 0;
}


Measured memory_bytes: 256
n = STDIN.gets.to_i

sp = []

i = 1
while line = STDIN.gets
  sp << [i , *line.split(" ")]
  i = i + 1
end

sp.sort_by! {|a| "#{a[1]}-#{"%03d" % (100 - a[2].to_i)}" }

puts sp.map {|a| a[0] }


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  //cout << C - B << endl;
  
  int HP_t = A,HP_a = C;
  int goal = 1;
  

  
 	while(goal > 0){
      HP_a = HP_a - B;
      //cout << HP_a << endl;
     
     if(HP_a <= 0){
          cout << "Yes" << endl;
        	goal = 0;
       		break;
        }
      
      HP_t = HP_t - D;
  //    cout << HP_t << endl;
      
      if(HP_t <= 0){
          cout << "No" << endl;
        	goal = 0;
       		break;        
        } 
    }
}


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

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

    vector<long long> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h.begin(), h.end() );

    long long dmin  = 10000000000;
    for(int i = 0; i <= n - k ; i++){
        long long dtemp = h[i + k - 1] - h[i];
        if(dtemp < dmin) dmin = dtemp;
    }
    cout << dmin << endl;

    /*
    vector<long long> d(n-1);
    for(int i = 0; i < n - 1; i++){
        d[i] = h[i+1] - h[i];
    }

    long long dmin  = 10000000000;
    long long dtemp ;
    for(int i = 0; i < k; i++){
    }
    */


}



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

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vunique(v) unique(v.begin(), v.end());

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

	int a, b;
	cin >> a >> b;
	float x = (float(a) + float(b)) / 2;
	cout << roundf(x) << endl;
}


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

def main():
#  A,B = map(int, input().split())
  S = input().rstrip()
  SS = sorted(S)

  result = 'No'
  if SS[0] == SS[1]:
    if SS[2] == SS[3]:
      if SS[0] != SS[2]:
        result = 'Yes'
  print(result)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 2940
N, K, Q = map(int, input().split())
A = [0] * Q
P = [K - Q] * N

for i in range(0, Q):
    A[i] = int(input()) - 1

for i in range(0, Q):
    P[A[i]] += 1

for i in range(0, N):
    if P[i] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 10540
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
    cin>>a>>b;
    if((a+b)%2==0){
    	c=(a+b)/2;
	}
    else{ 
    	c=(a+b)/2+1;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n, x = map(int, input().split())
    ll = list(map(int, input().split()))
    res = 1
    d = 0
    for l in ll:
        d = d + l
        if d <= x:
            res += 1
        else:
            break
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int dp[31];//i段目の登り方の総数
int main()
{
  int n;
  dp[0] = 1;
  dp[1] = 1;
  dp[2] = 2;
  for(int i = 3;i <=30;i++){
    dp[i] =dp[i-1]+dp[i-2]+dp[i-3];
  }
  while(cin>>n,n){
    int day;
    int ans;
    if(dp[n]%10)
      day =dp[n]/10+1;
    else
      day =dp[n]/10;
    if(day%365)
      ans =(day/365)+1;
    else
      ans =(day/365);
    cout <<ans<<endl;
  }
  return 0;
}

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

using namespace std;

void abc_160a();

int main()
{
  abc_160a();
}

void abc_160a()
{
  string S;
  cin >> S;

  if (S[2] == S[3] && S[4] == S[5]) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3628
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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! {
        d: usize,
        n: usize,
    }
    let mut a = 1;
    for _ in 0..d {
        a *= 100;
    }
    if n == 100 {
        println!("{}", a * (n + 1));
    } else {
        println!("{}", a * n);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

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

int main(){
	int n; cin >> n;
	vector<int> t(n+1),x(n+1),y(n+1);
	t[0]=0, x[0]=0, y[0]= 0;
	rep(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];
	for(int i = 1; i < n+1; i++){
			int a = t[i]-t[i-1];
			int b = abs(x[i]-x[i-1]);
			int c = abs(y[i]-y[i-1]);
			if (a < b+c){
				cout << "No" << endl;
				return 0;
			}else{
				if((a-b-c)%2 != 0){
					cout << "No" << endl;
					return 0;
				}
				
			}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
//int dp[3001][3001];
const int mod=1e9+7;
#define pb push_back
#define ll long long
int main()
{
    int x,y;
    cin>>x>>y;
    if(y%2) cout<<"No\n";
    else
    {
        y/=2;
        // if(y<x) cout<<"NO\n";
        // else cout<<"YES\n";
        int a,b;
        b=y-x;
        a=x-b;
        if(a>=0&&b>=0) cout<<"Yes\n";
        else cout<<"No\n";

    }
    

}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PN printf("\n")
#define MODV 1000000007

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
void addmod(int &a, ll b){a=(a+b); if(a>=MODV)a-=MODV;}
void mulmod(int &a, ll b){a=(a*b)%MODV;}
template<class T>bool domin(T &a, const T &b){return a>b?a=b,1:0;}
template<class T>bool domax(T &a, const T &b){return a<b?a=b,1:0;}
int gi(){int a;scanf("%d",&a);return a;}
ll gll(){ll a;scanf("%lld",&a);return a;}

int main() {
  int n=gi();
  char *s;
  s = new char[105];
  scanf(" %s", s);
  int o=0, c=0;
  for(int i=0;i<n;i++){
    if(s[i]=='(')o++;
    if(s[i]==')')if(o>0)o--;
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]==')')c++;
    if(s[i]=='(')if(c>0)c--;
  }
  for(int i=0;i<c;i++){
    putchar('(');
  }
  printf("%s",s);
  for(int i=0;i<o;i++){
    putchar(')');
  }
  cout<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll H, W; cin >> H >> W;

  ll result = LLINF;
  rep(i, H+1) {
    ll a = i * W;
    ll b = (H-i) * (W/2);
    ll c = H*W - (a+b);
    ll diff = max(max(abs(a-b), abs(b-c)), abs(c-a));
    result = min(result, diff);
  }
  rep(i, H+1) {
    ll a = i * W;
    ll b = ((H-i)/2) * W;
    ll c = H*W - (a+b);
    ll diff = max(max(abs(a-b), abs(b-c)), abs(c-a));
    result = min(result, diff);
  }
  rep(i, W+1) {
    ll a = i * H;
    ll b = (H/2) * (W-i);
    ll c = H*W - (a+b);
    ll diff = max(max(abs(a-b), abs(b-c)), abs(c-a));
    result = min(result, diff);
  }
  rep(i, W+1) {
    ll a = i * H;
    ll b = H * ((W-i)/2);
    ll c = H*W - (a+b);
    ll diff = max(max(abs(a-b), abs(b-c)), abs(c-a));
    result = min(result, diff);
  }

  cout << result << endl;
  return 0;
}

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

int a, b, c, d, e, k;

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


Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	ll N, M;
	cin >> N >> M;

	// 4隅は必ず表になる
	// 4隅を除く外周の辺は必ず表になる
	// 内側は全て表になる

	ll tN = N - 2, tM = M - 2;
	if ( tN < 0 )
	{
		tN = 1;
	}
	if ( tM < 0 )
	{
		tM = 1;
	}

	cout << ( tN * tM ) << endl;


	return ( 0 );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define print(x,n) for(int i=0;i<n;i++)cout<<x[i]<<" "
using namespace std;

// dp[state]
int dp[100001];

int main() {
	int n;
	cin >> n;
	vector<int> ht(n, 0);
	//Input
	for (int i = 0; i < n; i++) {
		cin >> ht[i];
	}

	// Bottom Up
	// Base Case
	dp[0] = 0;
	// Build dp array
	for (int i = 1; i < n; i++) {
		dp[i] = INT_MAX;
		for (int j = 1; j <= 2 && (i - j) >= 0; j++) {
			dp[i] = min(dp[i], dp[i - j] + abs(ht[i] - ht[i - j]));
		}
	}
	//print(dp, n) << endl;
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 4024
#include<iostream>
#include <math.h>

using namespace std;

int main(){
  int a,b,a2,b2;
  cin >> a >> b;
  a2=a;
  b2=b;
  if(b>1){
  for(int i=2; i<=b; i++){
         a2 = a2 + a* pow(10, i-1);
  }
  }

  if(a>1){
  for(int i=2; i<=a; i++){
         b2 = b2 + b*pow(10, i-1);
  }
  }

  if(a <= b){
  cout << a2 << endl;
  }
  else{
  cout << b2 << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
l = len(a)
fs = 0
ts = 0
for i in a:
    if(i % 4 == 0):
        fs += 1
    elif(i % 2 == 0):
        ts += 1
if(ts > 1):
    l = l - ts + 1
if(l <= fs*2 + 1):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 15020
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int x = n * 800;
		int y = n / 15 * 200;
		
		System.out.println(x - y);

	}
}




Measured memory_bytes: 35420
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(20, [5, 10, 15]), 10)

    def test_2(self):
        self.assertEqual(think(20, [0, 5, 15]), 10)


def solve():
    k, a = read()
    result = think(k, a)
    write(result)


def read():
    k, n = read_int(2)
    return k, read_int(n)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(k, a):
    distance = []
    for i in range(len(a) - 1):
        distance.append(a[i + 1] - a[i])
    distance.append(k - a[-1] + a[0])
    return sum(distance) - max(distance)


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 99448
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int A[10010100],N,W,H;
int main(){
	scanf("%d %d %d",&N,&H,&W);
	int flag=1;
	for (int pos=1;pos<=W*N;pos+=W){
		int x; scanf("%d",&x);
		if (flag>0){
			A[x+pos]++; A[x+pos+W]--;
		}
		else{
			A[pos-x]++; A[pos-x+W]--;
		}
		flag*=-1;
	}
	for (int i=1;i<=W*N;i++) A[i]+=A[i-1];
	int res=0;
	for (int i=1;i<=W*N;i++) if (A[i]<=0) res++;
	res*=H;
	cout<<res<<endl;
}


Measured memory_bytes: 3232
//https://atcoder.jp/contests/abc166/tasks/abc166_e
//2020-05-03
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num;
    cin >> num;
    int tmp_num;
    vector<int> plus;
    vector<int> minus;
    for(int i=0;i<num;i++){
        cin >> tmp_num;
        plus.push_back(tmp_num+i);
        minus.push_back(-tmp_num+i);
    }
    long long ans = 0;
    sort(plus.begin(),plus.end());
    sort(minus.begin(),minus.end());
    int index_minus=0;
    int tmp = -1;
    int ren=0,index_ren=-1;
    bool end_flag = false;
    for(int index_plus=0;index_plus<plus.size();index_plus++){
        if((index_ren>=0)&&(plus[index_plus]==minus[index_ren])){
            ans += ren;
            continue;
        }else{
            ren = 0;
        }
        if(plus[index_plus]<minus[index_minus]){
            continue;
        }else if(plus[index_plus]>minus[index_minus]){
            while(plus[index_plus]>minus[index_minus]){
                index_minus ++;
                if(index_minus==num){
                    index_minus = num-1;
                    end_flag = true;
                    break;
                }
            }
        }
        while(plus[index_plus]==minus[index_minus]){
            index_ren = index_minus;
            index_minus++;
            ren ++;
            if(index_minus == num){
                index_minus = num-1;
                if(end_flag){
                    ren --;
                }else{
                    end_flag = true;
                }
                break;
            }
        }
        if((index_ren>=0)&&(plus[index_plus]==minus[index_ren])){
            ans += ren;
        }else{
            ren = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

using namespace std;

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

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

  ll res = b / x - a / x;
  if (a % x == 0) {
    res++;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
f=[0]*(m+1)
count=0
for i in range(n):
  a=list(map(int,input().split()))
  k=a[0]
  a=a[1:]
  for i in range(k):
    f[a[i]]+=1
    
for i in range(1,m+1):
  if f[i]==n:
    count+=1
    
print(count)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 20:52:57 2020

@author: over-
"""

N, K=map(int,input().split())
H=input().split()

if K>=N:
    print(0)
else:
    H=[int(H[i]) for i in range(N)]
    H.sort()
    if K!=0: H=H[:-K]
    #print(H)
    print(sum(H))




Measured memory_bytes: 26764
#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;} 
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e4+5); 
// ========================================================

int a[N];
int n;

signed main(){
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  #endif
  fio;
    cin>>n;
    for0(i,n) cin>>a[i];
    int cnt = 0;
    for0(i,n)
      for0(j,i)
        for0(k,j){
          int x = a[i],y = a[j],z = a[k];
          if(x + y > z && x + z > y && z + y > x && x!=y && y!=z && x!=z){
            cnt++;
          }
        }
    cout<<cnt<<endl;
  rr;
}

Measured memory_bytes: 3588
N,M = map(int,input().split())

X = [list(map(int,input().split())) for _ in range(M)]

for i in range(M):
  X[i].append(i)

X.sort(key=lambda X:(X[0],X[1]))
X[0].append(1)
for i in range(M-1):
	if X[i+1][0] == X[i][0]:
		X[i+1].append(X[i][3]+1)
	else:
		X[i+1].append(1)

X.sort(key=lambda X:X[2])
for i in range(M):
  a = str(X[i][0])
  b = str(X[i][3])
  print("0"*(6-len(a))+a+"0"*(6-len(b))+b)

Measured memory_bytes: 39816
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> p;
	for (int i = 0;i < n;i++)
	{
		int num;
		cin >> num;
		p.push_back(num);
	}
	sort(p.begin(), p.end());
	vector<int>::iterator p1 = unique(p.begin(), p.end());
	p.erase(p1, p.end());
	vector<int>::iterator pp=p.begin();
	while (pp != p.end())
	{
		cout << *pp;
		if (++pp == p.end())cout << endl;
		else cout << " ";
	}
}


Measured memory_bytes: 3508
def main():
    h1, m1, h2, m2, k = [int(v) for v in input().split()]
    t1 = 60 * h1 + m1
    t2 = 60 * h2 + m2

    ans = t2 - t1 - k
    print(int(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxx = 100005;
ll a[maxx],b[maxx];

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n+1;i++)
        scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%lld",&b[i]);
    ll ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(b[i] >= a[i]){
            b[i] -= a[i];
            ans += a[i];
            if(b[i] >= a[i+1]){
                ans += a[i+1];
                a[i+1] = 0;
            }
            else{
                a[i+1] -= b[i];
                ans += b[i];
            }
        }
        else{
            a[i] -= b[i];
            ans += b[i];
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1792
import itertools
n,m=map(int,input().split())
l=[[0]*n for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1][b-1]=1
    l[b-1][a-1]=1
d=[int(i)+1 for i in range(n)]
ans=chk=0
for i in list(itertools.permutations(d,n)):
    chk=1
    if i[0]!=1: continue
    for j in range(n-1):
        chk*=l[i[j+1]-1][i[j]-1]
    ans+=chk
print(ans)

Measured memory_bytes: 79752
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	cout << N * (N - 1) / 2;
}

Measured memory_bytes: 256
#include<cstdio>

#define Fast register
char BUF[40],*S=BUF;
inline int Getint(){
	Fast int s=0;Fast char c;
	while(c=*S++,c<48||c>57);
	while(s=s*10+c-48,c=*S++,c>47&&c<58);
	return s;
}

int main(){
	fread(BUF,1,40,stdin);
	printf("%d",(Getint()-Getint())%Getint());
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

vvl G(202020);
vl ans(202020), ch(202020,1), cnt(202020), c(202020);
ll k = 0;

ll dfs(int u, int p){
	ll cn = cnt[c[u]];
	for(auto v : G[u]){
		if(v == p) continue;
		ll cur = k - cnt[c[u]];
		ch[u] += dfs(v,u);
		ll nxt = k - cnt[c[u]];
		ans[c[u]] -= (nxt - cur) * (nxt - cur + 1) / 2;
	}
	k++;
	cnt[c[u]] = cn + ch[u];
	return ch[u];
}

int main(){
	ll n; cin >> n;
	rep(i,n) cin >> c[i], c[i]--;
	rep(i,n-1){
		int u,v; cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(0,-1);
	rep(i,n){
		ans[i] += n * (n+1) / 2;
		ans[i] -= (n - cnt[i]) * (n - cnt[i] + 1) / 2;
		cout << ans[i] << "\n";
	}
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, int> mp;
	for (int &x : a) {
		cin >> x;
		mp[x]++;
	}
	long long sum = accumulate(a.begin(), a.end(), 0ll);
	int q;
	cin >> q;
	while (q--) {
		int b, c;
		cin >> b >> c;
		sum -= (long long)mp[b] * b;
		sum += (long long)mp[b] * c;
		mp[c] += mp[b];
		mp[b] = 0;
		cout << sum << '\n';
	}
	return 0;
}


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

using namespace std;

template <class T>
inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>
inline T updmin(T &a, T b) { return a = min(a, b); }

int main()
{
	long long l, r;
	scanf("%lld%lld", &l, &r);
	long long ans = 0x7f7f7f7f7f7f7f7f;
	for (long long i = l; i <= min(r, l + 2020); i++)
	{
		for (long long j = i + 1; j <= min(r, l + 2019); j++)
		{
			updmin(ans, (i * j) % 2019);
		}
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int x, y;
 
    while (true) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }
        else if (x > y) {
            swap(x, y);
        }
        cout << x << " " << y << endl;
    }
     
 
    return 0;
}

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

using namespace std;

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

    long long ans = 0;
    for (auto p : mp)
    {
        int id = p.first;
        int num = p.second;
        if (num < id)
            ans += num;
        else
            ans += num - id;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

/*

    top down

*/

const int N = 1000 + 5;
const int mod = 1e9 + 7;

char a[N][N];
int mem[N][N];
int H , W;

int numberOfWays(int r , int c){

    // we arrived to the final place
    if(r == H-1 && c == W-1) return 1;

    // we are out of the grid
    if(r == H || c == W) return 0;

    // this is an obstacle
    if(a[r][c] == '#') return 0;

    if(mem[r][c] != -1) return mem[r][c];

    int x = numberOfWays(r + 1 , c)%mod;
    int y = numberOfWays(r , c + 1)%mod;

    int ans = (x + y) % mod;

    mem[r][c] = ans;
    return mem[r][c];
}

main(){

    scanf("%d %d" , &H , &W);

    for(int i = 0 ; i < H ; i ++){
            scanf("%s" , &a[i]);
    }

    memset(mem , -1 , sizeof mem);
    printf("%d\n" , numberOfWays(0 , 0));

    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
//Compiler version g++ 6.3.0
int fact(LL n){
  if(n==1||n==0){
    return 1; 
  }  
  else{
    return fact(n-1)*n;}
}
int main()
{
 LL n;
 cin>>n;
 LL a=0,w=0,t=0,r=0;
 while(n--){
   string k; 
   cin>>k; 
   if(k.size()==3){
     t++;  
   }
   else{
   if(k[0]=='A') {
     a++;
   }
   else if(k[0]=='W') {
     w++;  
   }
   else{
     r++;  
   }
  
   }
 }
 cout<<"AC x "<<a<<endl; 
 cout<<"WA x "<<w<<endl; 
 cout<<"TLE x "<<t<<endl; 
 cout<<"RE x "<<r<<endl; 
  return 0;
 }
       


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
  int64_t lucas(int x){
    if(x==0) return 2;
    if(x==1) return 1;
   return lucas(x-1)+lucas(x-2);
  }

int main() {
  int x;
  cin >> x;
  //cout << lucas(x);
  
  vector<int64_t> luca(x+1);
  luca.at(0)=2;
  luca.at(1)=1;
  for(int i=2; i<x+1; i++){
    luca.at(i)=luca.at(i-2)+luca.at(i-1);
  }
  cout << luca.at(x) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    ll x; cin >> x;
    ll d=100;
    ll ans=0;
    while(d < x){
        ll interest = d / 100;
        d += interest;
        ans++;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3156
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
// 20min
int main(void){
  long l, r;
  int ans = 2019;
  scanf("%ld%ld", &l, &r);

  for(long i = l; i < r; i++){
    for(long j = i + 1; j <= r; j++){
      /*      if(i == l  && j == l + 1){
	ans = (l * (l+1)) % 2019;
	}*/
      if(ans > ((i * j) % 2019)){
	ans = (i * j) % 2019;
      }
      if(ans == 0){
	break;
      }
    }
    if(ans == 0){
      break;
    }
  }

  
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
// long long -> lint
using lint = long long;
// fast cin and cout from hitonanode-san's code
// w/o 71 ms -> w/ 18 ms (tested on ABC148-D with C++14(GCC 5.4.1))
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

int main(){
    // input
    int K, X;
    cin >> K >> X;

    // calc
    bool ans = 500*K >= X;

    // out
    printf( ans ? "Yes" : "No" );
} 

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> d(13);
	d[0] = 1;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		d[a]++;
	}
	bool ch = 0;
	if (d[0] > 1 or d[12] > 1) ch = 1;
	for (int i = 0; i < 13; i++) {
		if (d[i] > 2) ch = 1;
	}
	if (ch) {
		printf("0\n");
		return 0;
	}
	set<int> st;
	st.insert(0), st.insert(24);
	int cnt = 0;
	vector<int> p;
	for (int i = 1; i < 12; i++) {
		if (d[i] == 2)
			st.insert(i), st.insert(24 - i);
		else if (d[i] == 1) {
			cnt++;
			p.push_back(i);
		}
	}
	if (d[12]) st.insert(12);
	int ans = 0;
	for (int bit = 0; bit < (1 << cnt); bit++) {
		set<int> a = st;
		for (int i = 0; i < cnt; i++) {
			if ((bit >> i) & 1)
				a.insert(p[i]);
			else
				a.insert(24 - p[i]);
		}
		int now = 24;
		for (auto it = a.begin(); it != a.end(); it++) {
			auto nit = ++it;
			it--;
			if (nit == a.end()) break;
			now = min(now, *nit - *it);
		}
		ans = max(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#!usr/bim/python
#! -*- coding: utf-8 -*-

nm = raw_input()
nm = nm.split()
nm = map(int, nm)



if nm[0] < 2 or nm[1] < 2:
    ans = 0
else:
    ans = (nm[0]-1)*(nm[1]-1)

print ans


Measured memory_bytes: 2568
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [10**10] * N
dp[0] = 0
for i in range(N-1):
    for k in range(1, K+1):
        if i+k < N:
            dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k] - h[i]))

print(dp[-1])


Measured memory_bytes: 52592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader in = new FastReader();
        int a = in.nextInt();
        int sol = a + a*a + a*a*a;
        System.out.println(sol);
    }
}

Measured memory_bytes: 32568