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

using namespace std;

struct po{
	int x;
	int y;
	bool vis;
};

int main()
{
	int n, m, s, t, u;
	po jw[21];
	char c;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		s = t = 10;
		for(int i = 0; i < n; i++){
			cin >> jw[i].x >> jw[i].y;
			jw[i].vis = false;
		}
		cin >> m;
		for(int i = 0; i < m; i++){
			cin >> c >> u;
			
			if(c == 'N'){
				u += t;
				if(u > 20){
					u = 20;
				}
				for(int i = 0; i < n; i++){
					if(jw[i].x == s && t <= jw[i].y && jw[i].y <= u){
						jw[i].vis = true;
					}
				}
				t = u;
			} else if(c == 'E'){
				u += s;
				if(u > 20){
					u = 20;
				}
				for(int i = 0; i < n; i++){
					if(jw[i].y == t && s <= jw[i].x && jw[i].x <= u){
						jw[i].vis = true;
					}
				}
				s = u;
			} else if(c == 'S'){
				u = t-u;
				if(u < 0){
					u = 0;
				}
				for(int i = 0; i < n; i++){
					if(jw[i].x == s && u <= jw[i].y && jw[i].y <= t){
						jw[i].vis = true;
					}
				}
				t = u;
			} else {
				u = s-u;
				if(u < 0){
					u = 0;
				}
				for(int i = 0; i < n; i++){
					if(jw[i].y == t && u <= jw[i].x && jw[i].x <= s){
						jw[i].vis = true;
					}
				}
				s = u;
			}
		}
		bool f = true;
		
		for(int i = 0; i < n; i++){
			f = jw[i].vis;
			if(!f){
				break;
			}
		}
		
		if(f){
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		// 配列
    	long[] list = new long[N];
    	for(int i = 0; i < N; ++i){
      	list[i] = sc.nextLong();
    	}
        //カウント
     	 int count =0;
      
      for(int i=0; i<N; i++) {
      while(list[i] % 2 == 0){
        list[i] = list[i] / 2;
        count = count+1;
       }
      }
         // 出力
		System.out.println(count);
	}
}

Measured memory_bytes: 47916
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	mod = 10^9+7
	n = readline() |> parseInt
	c = readline() |> split |> parseMap
	if n==1
		println(2*c[1]%mod)
	else
		c = sort(c,rev=true)
		bv = zeros(Int,n+1)
		bv[1] = 1
		for i in 2:n+1
			bv[i]=bv[i-1]*2%mod
		end
		s = 0
		for i in 1:n
			s = (s+(c[i]*(bv[n-1]*(i+1)%mod)%mod))%mod
		end
		println(s*bv[n+1]%mod)
	end
end

main()

Measured memory_bytes: 168200
import java.util.ArrayList;
import java.util.Scanner;

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

		boolean[][] po = new boolean[101][101];
		for (int x=0; x<=100; x++) {
			for(int y=0; y<=100; y++) po[x][y] = true;
		}

		ArrayList<int[]> info = new ArrayList<>();
		ArrayList<int[]> zrInfo = new ArrayList<>();
		boolean got = false;
		for (int i=0; i<n; i++){
			int nux = scanner.nextInt();
			int nuy = scanner.nextInt();
			int nuh = scanner.nextInt();
			if (nuh==0) {
				po[nux][nuy] = false;
				int[] nu = {nux, nuy, nuh};
				zrInfo.add(nu);
				continue;
			}
			if (!got){
				for (int[] old: info) {
					int cnt=0;
					for(int x=0; x<=100; x++){
						for (int y=0; y<=100; y++){
							if(!po[x][y]) continue;
							if(nuh+Math.abs(x-nux)+Math.abs(y-nuy)!=old[2]+Math.abs(x-old[0])+Math.abs(y-old[1])){
								po[x][y] = false;
							}else cnt++;
						}
					}
					if (cnt==1){
						got = true;
						break;
					}
				}
				int[] nu = {nux, nuy, nuh};
				info.add(nu);
			}
		}

		for (int x=0; x<=100; x++){
			for (int y=0; y<=100; y++) {
				if (po[x][y]){
					int[] dat = info.get(0);
					int H = dat[2]+Math.abs(x-dat[0])+Math.abs(y-dat[1]);
					{
						int X = x;
						int Y = y;
						boolean[] conf = {true};
						zrInfo.forEach(pnt -> conf[0] = (conf[0] && H-Math.abs(pnt[0]-X)-Math.abs(pnt[1]-Y)<=0));
						if(!conf[0]) continue;
					}
					System.out.println(x+" "+y+" "+H);
					System.exit(0);
				}
			}
		}
	}

}

Measured memory_bytes: 28640
N=int(input())
a=list(map(int,input().split()))
ave=sum(a)/N
if ave>=0 and ave%1>=0.5:
    ave=int(ave)+1
elif ave<0 and -ave%1>=0.5:
    ave=int(ave)-1
else:
    ave=int(ave)
ans=0
for i in a:
    ans+=(i-ave)**2
print(ans)


Measured memory_bytes: 9168
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,a[100],b[100];
	string s;
	while(true){
	cin>>n;
	if(n==0)break;
	cin>>s;
	for(int i=0;i<n;i++){
		cin>>a[n-i-1]>>b[n-i-1];
	}
	for(int i=0;i<n;i++){
		s[a[i]-1]='a'+(s[a[i]-1]-'a'-a[i]+b[i])%26;
		s[b[i]-1]='a'+(s[b[i]-1]-'a'-a[i]+b[i])%26;
		char tmp=s[a[i]-1];
		s[a[i]-1]=s[b[i]-1];
		s[b[i]-1]=tmp;
	}
	cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
N = int(input())
A = list(map(int, input().split()))

n1, n2, n4 = 0, 0, 0
for a in A:
	if not a % 4:
		n4 += 1
	elif not a % 2:
		n2 = 1
	else:
		n1 += 1

#print(n1, n2, n4)
print(["Yes", "No"][not(n1 + n2 <= n4 + 1)])


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

#define F(i,a,b) for(long long  i =a; i<b; i++)
#define rF(i,a,b) for(long long i=a-1; i>=b;i--)
#define endl "\n"
#define min1(x,y,z) min(x, min(y,z))
#define max1(x,y,z) max(x, max(y,z))
#define input_vector(v,n,type) vector<type> v;for(int i=0;i<n;i++){type x;cin>>x;v.push_back(x);}
#define IOS ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
#define int long long
#define inf (1LL<<61)
typedef pair<int,int> ii;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;



int32_t main()
{
      IOS;

      string s;
      cin>>s;

      if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi")
            cout<<"Yes"<<endl;
      else 
            cout<<"No"<<endl;            



            



      


        
























            return 0;
}

Measured memory_bytes: 256
class SegTree:
    """ define what you want to do with 0 index, ex) size = tree_size, func = min or max, sta = default_value """
    
    def __init__(self,size,func,sta):
        self.n = size
        self.size = 1 << size.bit_length()
        self.func = func
        self.sta = sta
        self.tree = [sta]*(2*self.size)

    def build(self, list):
        """ set list and update tree"""
        for i,x in enumerate(list,self.size):
            self.tree[i] = x

        for i in range(self.size-1,0,-1):
            self.tree[i] = self.func(self.tree[i<<1],self.tree[i<<1 | 1])

    def set(self,i,x):
        i += self.size
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = self.func(self.tree[i<<1],self.tree[i<<1 | 1])

    
    def get(self,l,r):
        """ take the value of [l r) with func (min or max)"""
        l += self.size
        r += self.size
        res = self.sta

        while l < r:
            if l & 1:
                res = self.func(self.tree[l],res)
                l += 1
            if r & 1:
                res = self.func(self.tree[r-1],res)
            l >>= 1
            r >>= 1
        return res

    def max_right(self, l, x):
        """[l,r) が ok であるような最大の r を返す"""
        if l == self.n:
            return l
        l += self.size
        res = self.sta
        check = True
        while check or (l & -l) != l:
            check = False
            while l%2 == 0:
                l >>= 1
            if not self.func(res,self.tree[l]) < x:
                while l < self.size:
                    l <<= 1
                    if self.func(res,self.tree[l]) < x:
                        res = self.func(res,self.tree[l])
                        l += 1
                return l - self.size
            res = self.func(res,self.tree[l])
            l += 1
        return self.n

    def min_left(self, r, x):
        """(r が ok であるような最小の r を返す probably wrong"""
        if r == 0:
            return 0
        r += self.size
        res = self.sta
        check = True
        while check and (r & -r) != r:
            check = False
            r -= 1
            while (r > 1 and r%2):
                r >>= 1
            if not self.func(res, self.tree[r]) < x:
                while r < self.size:
                    r = 2*r + 1
                    if self.func(res, self.tree[r]) < x:
                        res = self.func(res, self.tree[r])
                        r -= 1
                return r + 1 - self.size
            res = self.func(self.tree[r],res)
        return 0


n,k = map(int,input().split())
M = 3*10**5+5
tree = SegTree(M,max,0)
for i in range(n):
    a = int(input())
    x = tree.get(max(0,a-k),min(a+k+1,M))
    tree.set(a,x+1)

print(tree.get(0,M))


Measured memory_bytes: 99404
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int cnt=0,n,d;cin>>n>>d;
  long long x,y;
  for(int i=0; i<n; ++i){
    cin>>x>>y;
    if(sqrt(x*x+y*y)<=d) ++cnt;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3612
using System;
using System.Collections;
using System.Collections.Generic;

class abc147{
    public static void Main(){
        int[] res_13s = {1,10,9,12,3,4};
        Func<int,int> res_13 = x => res_13s[x % 6];
        Func<int,int> mod13 = x => {
            if(x>=0)
                return x%13;
            else
                return (13 - (-x % 13)) % 13;
        };
        string S = Console.ReadLine();
        int[] dp = new int[13];
        dp[0] = 1;
        for(int pow = 0; pow < S.Length ; pow++){
            char digit = S[S.Length - 1 - pow];
            int[] dp_new = new int[13];
            switch(digit){
                case '?':
                for(int j = 0; j < 13; j++){
                    for(int a = 0 ; a < 10 ; a++){
                        int mod_new = mod13(res_13(pow) * a);
                        dp_new[j] = (dp_new[j] + dp[mod13((13 - mod_new) + j)]) % 1000000007;
                    }
                }
                break;
                default:
                for(int j = 0; j < 13;j++){
                    int mod_new = mod13(res_13(pow) * (digit - '0'));
                    dp_new[j] = dp[mod13((13 - mod_new) + j)];
                }
                break;
            }
            dp = dp_new;
        }
        Console.WriteLine(dp[5]);
    }
}

Measured memory_bytes: 15328
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int x,y,n;
    while(cin >> x >> y >> n){
        if(n == 0 && y ==0 && n == 0)return 0;
        int ans = 0;
        for(int i = 1;i < 2000;i++){
            for(int j = 1;j < 2000;j++){
            int sumx = ((x + 100) * i)/100 + ((x + 100) * j)/100;
            int sumy = ((y + 100) * i)/100 + ((y + 100) * j)/100;
            if(sumx == n)ans = max(ans, sumy);
            }
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    double ans=0;
    for(int i=1;i<=n;i++){
        int v=i;
        int count=0;
        while(v<k){
            v*=2;
            count++;
        }
        double tmp=1/(n*1.0)*pow(0.5,count);
        //cout<<count<<" "<<tmp<<endl;
        ans+=tmp;
    }
    //cout<<ans<<endl;
    printf("%.15lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<stdlib.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(void){
    ll N;
    ll A[5];
    cin >> N;
    ll mini = 0;
    ll m = 1000000000000001;
    rep(i,5){
        cin >> A[i];
        if(m > A[i]){
            mini = i;
            m = A[i]; 
        }
    }
    
    if(N%A[mini] == 0 ) cout << 4 + N/A[mini] << endl; 
    else cout << 5 + N/A[mini] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

ll modpow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n) {
        if (n & 1) res = (res * x) % mod; // bitが立っていればxを掛ける
        x = (x * x) % mod; // x を二乗しておく
        n >>= 1; // 右bitシフト（log2）
    }
    return res;
}

const int MAX = 1000000; // nの最大値を入れておくこと

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int n; cin >> n;
    if (n<2) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = modpow(10, n, MOD) - modpow(9, n, MOD);
    ans %= MOD;
    if (ans <= 0) ans += MOD;
    if (ans <= 0) ans += MOD;
    ans -= (modpow(9, n, MOD)-modpow(8, n, MOD));
    if (ans <= 0) ans += MOD;
    if (ans <= 0) ans += MOD;
    cout << ans % MOD << endl;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int c = 0;
    rep(i,1e7) c++;
    cout << max(a+b,max(a-b,a*b));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

map<int,int> mp;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi vec(n);
    vi v(n);
    rep(i,n){
        cin >> vec[i];
        mp[vec[i]] = i%2;
        v[i] = vec[i];
    }
    sort(all(v));
    int ans = 0;
    rep(i,n){
        if(i % 2 == 0 && mp[v[i]]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close \
    std::ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c)         \
    (sort(c.begin(), c.end()), \
     c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define CASET    \
    int ___T;    \
    cin >> ___T; \
    for (int __CS = 1; __CS <= ___T; __CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6 + 10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9 + 7;
void add(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}
void dec(int &a, int b) {
    a -= b;
    if (a < 0) a += mod;
}
char ch[maxn];
#define int long long
int32_t main() {
    int n;
    cin >> n;
    scanf("%s", ch + 1);
    int r = 0, g = 0, b = 0;
    for (int i = 1; i <= n; i++) {
        if (ch[i] == 'R')
            r++;
        else if (ch[i] == 'G')
            g++;
        else
            b++;
    }
    int ans = r * g * b;
    for (int i = 1; i <= n; i++) {
        for (int len = 1; len + i <= n && len * 2 + i <= n; len++) {
            char f = ch[i], s = ch[i + len], se = ch[i + 2 * len];
            if ((f != s && f != se && s != se)) ans--;
        }
    }
    cout << ans << endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  vll a(n);
  REP(i,n)cin>>a[i];

  map<ll,ll> m;
  string ans="YES";
  REP(i, n){
    if(m[a[i]]!=0)
      ans="NO";
    m[a[i]]+=1;
  }

  cout<<ans<<endl;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

ll memo[100];

void init() {
  memo[0] = 2;
  memo[1] = 1;
  rep(i, 2, 100) {
    memo[i] = memo[i-1] + memo[i-2];
  }
};

int main() {
  int N;
  cin >> N;
  init();
  cout << memo[N] << endl;
};


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// main is...
func main() {
	var n int
	fmt.Scanln(&n)

	var sc = bufio.NewScanner(os.Stdin)
	// var list = make([]string, n)
	// var listInt = make([]int64, n)
	var list = make([]int, n)

	sc.Split(bufio.ScanWords)
	// if sc.Scan() {
	// 	list = strings.Fields(sc.Text())
	// }

	// for idx, value := range list {
	// 	valueInt, _ := strconv.Atoi(value)
	// 	// valueInt, _ := strconv.ParseInt(value, 10, 64)
	// 	listInt[idx] = valueInt
	// }

	for idx := range list {
		if sc.Scan() {
			valueInt, _ := strconv.Atoi(sc.Text())
			// valueInt, _ := strconv.ParseInt(value, 10, 64)
			list[idx] = valueInt
		}
	}

	max, tmp := 0, 0
	// for i := n - 1; i > 0; i-- {
	// 	if list[i-1] >= list[i] {
	// 		tmp++
	// 	} else {
	// 		tmp = 0
	// 	}

	// 	if tmp > max {
	// 		max = tmp
	// 	}
	// }
	for i := 1; i < n; i++ {
		if list[i-1] >= list[i] {
			tmp++
		} else {
			tmp = 0
		}

		if tmp > max {
			max = tmp
		}
	}
	fmt.Println(max)

}



Measured memory_bytes: 3072
T=int(input())
for i in range(T):
  N,a,b,c,d=map(int, input().split())
  memo={}
  memo[0]=0
  memo[1]=d
  
  def f(n):
    if n in memo:
      return memo[n]
    e2,e3,e5=n%2,n%3,n%5
    dd=min(d*n,d*e2+a+f((n-e2)//2),d*e2+a+f((n+e2)//2),d*e3+b+f((n-e3)//3),d*(3-e3)+b+f((n+3-e3)//3),d*e5+c+f((n-e5)//5),d*(5-e5)+c+f((n+5-e5)//5))
    memo[n]=dd
    return dd
  print(f(N))

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

const string YES = "Yes";

const string NO = "No";

void solve(int X)
{
    if (X >= 30)
        cout << YES << endl;
    else
        cout << NO << endl;
}

int main()
{
    int X;
    cin >> X;
    solve(X);
    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <complex>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string n;
  cin >> n;
  int sum = 0;
  for (size_t i = 0; i < n.length(); ++i) {
    sum += atoi(n.substr(i, 1).c_str());
  }
  if (atoi(n.c_str()) % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, m;
	cin >> n;
	vi t(n);
	int sum = 0;
	rep(i, 0, n) {
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	rep(i, 0, m) {
		int p, x;
		cin >> p >> x;

		cout << (sum - t[p - 1] + x) << endl;
	}
}

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

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

    long long t = 0;
    int a;
    int p = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (p == 1 && a != 0) {
            a--;
            t++;
        }
        t += a / 2;
        p = a % 2;
    }

    cout << t << endl;
}


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

void _140() {
    int n;
    cin >> n;

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

    int score = 0;
    for (int i = 0; i < n - 1; ++i) {
        score += b[a[i] - 1];
        if (a[i + 1] == a[i] + 1) {
            score += c[a[i] - 1];
        }
        // cout << score << endl;
    }
    score += b[a[n - 1] - 1];

    cout << score << endl;
}

#include <string>
void _141() {
    string s;
    cin >> s;
    bool judge = true;
    for (int i = 0; i < s.size(); ++i) {
        if ((i + 1) % 2 == 0 && s[i] == 'R') {
            judge = false;
            break;
        } else if ((i + 1) % 2 == 1 && s[i] == 'L') {
            judge = false;
            break;
        }
    }

    if (judge) 
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void _142() {
    int n, k;
    cin >> n >> k;
    int count = 0;
    int h;
    for (int i = 0; i < n; ++i) {
        cin >> h;
        if (h >= k)
            count++;
    }
    cout << count << endl;
}

void _143() {
    int n;
    cin >> n;
    int d[50];
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }

    int value = 0;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            value += d[i] * d[j];
        }
    }
    cout << value << endl;
}

void _144() {
    int n;
    cin >> n;

    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
}

void _145() {
    int n;
    string s;
    cin >> n;
    cin >> s;

    if (s.size() %2 ==1) {
        cout << "No" << endl;
        return;
    }

    string first = s.substr(0, s.size() / 2);
    string second = s.substr(s.size() / 2, s.size());
    if (first == second)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void _146() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        s[i] = s[i] + n;
        if (s[i] > 90) {
            s[i] = '@' + (s[i] - 90);
        }
    }
    cout << s << endl;
}

void _147() {
    string s;
    cin >> s;

    int middle = (s.size() + 2 - 1) / 2;
    int count = 0;
    for (int i = 0; i < middle; ++i) {
        if (s[i] != s[s.size() - 1 - i])
            count++;
    }
    cout << count << endl;
}

int main()
{
    _147();
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
int up(int data[], int ans[]);
int down(int data[], int ans[]);
int first(int data[], int ans[], int);

main(){
  int n, data[5000], ans[3];
  int i;

  while(1){
    scanf("%d", &n);
    if(n==0) break;
    for(i=0;i<n;i++){
      scanf("%d", &data[i]);
    }
    first(data, ans, n);
    printf("%d\n", ans[0]);
  }
  return 0;
}


int up(int data[], int ans[]){
  int i;
  int temp;
  int max=INT_MIN;
  int sum=0;
  for(i=ans[2];i<=ans[1];i++){
    sum+=data[i];
    if(max<=sum){
      max=sum;
      temp=i;
    }
  }
  ans[1]=temp;
  if(ans[0]==max) return 0;
  else{
    ans[0]=max;
    down(data,ans);
  }
}


int down(int data[], int ans[]){
  int i;
  int temp;
  int max=INT_MIN;
  int sum=0;
  for(i=ans[1];i>=0;i--){
    sum+=data[i];
    if(max<=sum){
      max=sum;
      temp=i;
    }
  }
  ans[2]=temp;
  if(ans[0]==max) return 0;
  else{
    ans[0]=max;
    up(data,ans);
  }
}


int first(int data[], int ans[], int n){
  int max1=INT_MIN, max2=INT_MIN, temp1, temp2, i, sum;

  ans[0]=INT_MIN;
  ans[1]=n-1;
  ans[2]=0;
  sum=0;
  for(i=ans[2];i<=ans[1];i++){
    sum+=data[i];
    if(max1<=sum){
      max1=sum;
      temp1=i;
    }
  }
  sum=0;
  
  for(i=ans[1];i>=0;i--){
    sum+=data[i];
    if(max2<=sum){
      max2=sum;
      temp2=i;
    }
  }
   
  if(temp1>=temp2){
    ans[1]=temp1;
    ans[0]=max1;
    down(data, ans);
  }
  else{
    ans[2]=temp2;
    ans[0]=max2;
    up(data, ans);
  }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c=0,d,n;
    string s,s1;
    cin >> n;   
    while (n - 3 >=0) { c++; n-=3;}
    cout << c << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int z=0, o=0;
  char j;
  while(scanf("%c", &j) != EOF){
    if(j == '0') z++;
    else if(j == '1') o++;
  }
  cout << 2*min(z, o) << endl;
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  programs
//
//  Created by Arunesh Sarker on 18/11/19.
//  Copyright © 2019 Arunesh Sarker. All rights reserved.
//

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <cstdlib>
using namespace std;

typedef unsigned long long ll;
#define mod 1000000007
     
  // Function to return LCM of two numbers
 ll gcd(ll a, ll b)
 {
     if (a == 0)
         return b;
     return gcd(b % a, a);
 }
   
 // Function to find gcd of array of
 // numbers
 ll findGCD(ll arr[], ll n)
 {
     ll result = arr[0];
     for (ll i = 1; i < n; i++)
     {
         result = gcd(arr[i], result);
   
         if(result == 1)
         {
            return 1;
         }
     }
     return result;
 }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    ll diff=a>b?a-b:b-a;
    if(diff%2==0)
    {
        cout<<diff/2<<"\n";
    }
    else{
        ll res=min(a-1,n-b) + 1 + (b-a-1)/2;
        cout<<res<<"\n";
    }
    
}


Measured memory_bytes: 256
import math
from functools import reduce
K = int(input())
CNT= 0
def gcd(*numbers):
    return reduce(math.gcd, numbers)
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            CNT += gcd(i,j,k)
print(CNT)

Measured memory_bytes: 74936
a, b, h, m = gets.split.map(&:to_i)

theta = 2 * Math::PI * (60 * h + m) / (12 * 60)
phi   = 2 * Math::PI * (60 * h + m) / 60

z = Complex.polar a, theta
w = Complex.polar b, phi

puts (z - w).abs


Measured memory_bytes: 14848
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;
 
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;   
   //  cin>>TESTS;
    while(TESTS--)
    {
       ll n,k;
       cin>>n>>k;
       string s;
       cin>>s;
       std::vector<ll> v;
       ll cnt=1;
       char p=s[0];
       for(int i=1;i<n;i++)
       {
           if(s[i]==p)
               cnt++;
           else
           {
                  v.pb(cnt);
                  cnt=1;
                  p=s[i];
           }
       }
       v.pb(cnt);
       ll ans=0;
       for(int i=0;i<v.size();i++)
           ans+=v[i]-1;
           n=v.size();
       for(int i=0;i<k;i++)
       {
           if(n>2)
           {
               ans+=2;
               n-=2;
           }
           else if(n<=2&&n>1)
           {
               ans+=1;
               n-=1;
           }
           else
           break;
       }
       cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 1480
//boom diggy diggy boom boom
/*
freopen("input.txt","r",stdin);
    	freopen("output.txt","w",stdout);
    	*/
#include<bits/stdc++.h>
#define ull unsigned long long int 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define ll long long 
#define ld long double 

int power(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int ncr(int n,int r){int res=1;if(r>n-r)r=n-r;for(int i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}int max(int a,int b){int ans=a>b?a:b;return ans;}

using namespace std;
void topo_order(int visit[],vector<int> parent[],stack<int> &order,int n)
	{
		if(visit[n])
			return;
		visit[n]++;
		for (int i = 0; i < parent[n].size(); ++i)
		{
			topo_order(visit,parent,order,parent[n][i]);
		}
		order.push(n);
	}
void maximise_value(int x,int value[],vector<int> parent[])
	{
		for (int i = 0; i < parent[x].size(); ++i)
		{
			if(value[x]+1>value[parent[x][i]])
				value[parent[x][i]]=value[x]+1;
		}
	}
int main()
{
 int n,m;
 cin>>n>>m;
 vector<int> parent[n+1];
 int visit[n+1]={};
 for (int i = 0; i < m; ++i)
 {
 	int x,y;
 	cin>>x>>y;
 	parent[x].pb(y);
 }
 stack<int> order;
 for (int i = 1; i <= n; ++i)
 {
 	topo_order(visit,parent,order,i);
 }	
 
 int value[n+1]={};
 while(!order.empty())
 {
 	int x=order.top();
 	maximise_value(x,value,parent);
 	order.pop();
 }
 int ans=0;
 for (int i = 0; i <= n; ++i)
 {
 	ans=max(ans,value[i]);
 }
 cout<<ans;
return 0;
}

Measured memory_bytes: 9216
n=int(input())

b=2

e=2
r=1

for i in range(n):
    if b%2==0:
        e=e+r
        b=b+1
    elif b%2==1:
        r=r+e
        b=b+1
    f=e
    g=r

if f>g:
    print(g)
elif f<g:
    print(f)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s==u){
        printf("%d %d\n", a - 1, b);
    }else{
        printf("%d %d\n", a , b- 1);
    }
}

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

typedef long long ll;

int main()
{
  std::string s;
  std::cin >> s;
  
  std::sort(s.begin(), s.end());
  std::string judge = "Yes";
  ll cnt = 1;
  char c = s[0];
  for (int i = 1; i < (int)s.size(); i++) {
    if (c != s[i]) {
      if (cnt % 2 == 1) {
        judge = "No";
      }
      c = s[i];
      cnt = 1;
    } else {
      cnt++;
    }
  }
  
  if (cnt % 2 == 1) {
    judge = "No";
  }
  
  std::cout << judge << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll check(vector<pair<ll,ll>> p,ll ans,ll k){
 //  cout<<ans<<" ";
    for(ll i=0;i<p.size();i++){
        if(p[i].first>ans){
            if(k<0)return 0;
            ll x=ans/p[i].second;
            ll ac=p[i].first/p[i].second;
            if(k-(ac-x)>=0){
                k=k-(ac-x);
            }
            else{
                return 0;
            }
        }
        else{
            continue;
        }
    }
    return 1;
}
int main(){
    ll n,k;cin>>n>>k;
    vector<ll> a(n),f(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    for(ll i=0;i<n;i++){
        cin>>f[i];
    }
    sort(a.begin(),a.end());
    sort(f.begin(),f.end(),greater<ll>());

    vector<pair<ll,ll>> p;
    ll maxi=INT_MIN;
    for(ll i=0;i<n;i++){
        p.push_back({a[i]*f[i],f[i]});
        maxi=max(maxi,a[i]*f[i]);
    }
    if(k==0){
        cout<<maxi;
        return 0;
    }
    ll s=0;
    ll e=maxi;
    ll ans=maxi;
    while(1){
        if(e<s){
            break;
        }
        ll m=(s+e)/2;
        ll x=check(p,m,k);
        if(x){
            ans=m;
            e=m-1;
        }
        else{
           // cout<<s<<" "<<m<<" ";
            s=m+1;
            
        }
    }
    cout<<ans;

}

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

int main () {

    int N;
    cin >> N;

    int A[N];

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

    int ans = INT_MIN;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) continue;

            ans = max(ans, abs(A[i] - A[j]));
        }
    }
    cout << ans << endl;

    return 0;
}

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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

int main() {
	fastio;
	
	set<string>words;

    int n;
    cin >> n;
    char prev;
    bool rules=true;
    forn(i,n){
        string s;
        cin >>s;
        rules= rules && (words.count(s)==0) && (!i || prev==s[0]);
        words.insert(s);
        prev=s.back();
    }

    cout << (rules? "Yes":"No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
S = input()

zero = "00"

one = "11"

if len(S) % 2 == 0:
	
	Ans = int(len(S) / 2 )
	flont = Ans - 1
	back = Ans + 1
	while (1):
		if S[flont:back] == zero:
			zero += "00"
			flont -= 1
			back += 1
			Ans += 1
			continue
		if S[flont:back] == one:
			one += "11"
			flont -= 1
			back += 1
			Ans += 1
			continue
		else:
			break

if len(S) % 2 == 1:
	zero = "0"
	one = "1"
	Ans = int(len(S) / 2 + 0.5)
	flont = Ans - 1
	back = Ans
	while(1):
		if S[flont:back] == zero:
			zero += "00"
			flont -= 1
			back += 1
			Ans += 1
			continue
		if S[flont:back] == one:
			one += "11"
			flont -= 1
			back += 1
			Ans += 1
			continue
		else:
			Ans -= 1
			break	

print(Ans)
			

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char alph;cin>>alph;
  print(isupper(alph)?'A':'a');
  return 0;
}

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

int  main()
{
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	rep(i, n-2)
	{
		if (s.substr(i, 3) == "ABC")
			ans++;
	}
	cout << ans << endl;
	return (0);
}

Measured memory_bytes: 256
from fractions import gcd

def main():
    n = int(input())
    a = list(map(int,input().split()))

    lgcd = [0 for _ in range(n)]
    rgcd = [0 for _ in range(n)]
    for i in range(n):
        if i == 0:
            lgcd[i] = a[i]
            rgcd[-i-1] = a[-i-1]
        else:
            lgcd[i] = gcd(lgcd[i-1],a[i])
            rgcd[-i-1] = gcd(rgcd[-i],a[-i-1]) 
    
    ans = 0
    for i in range(n):
        if i == 0:
            ans = max(ans,rgcd[i+1])
        elif i == n-1:
            ans = max(ans,lgcd[i-1])
        else:
            ans = max(ans,gcd(lgcd[i-1],rgcd[i+1]))

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 16100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,Q;
    cin >> N;
    vector<ll> A(N);
    map<ll,ll> mp;
    ll sum = 0;
    rep(i,N){
        cin >> A[i];
        mp[A[i]]++;
        sum += A[i];
    }
    cin >> Q;
    vector<ll> B(Q),C(Q);
    rep(i,Q){
        cin >> B[i] >> C[i];
    }
    rep(i,Q){
        sum += (C[i]-B[i])*mp[B[i]];
        mp[C[i]] += mp[B[i]];
        mp[B[i]] = 0;
        cout << sum << endl;
    }
}


Measured memory_bytes: 11388
function main(input) {
    const args = input.split(' ').map(n => parseInt(n, 10));

    const hour = (args[2] - args[0]) * 60;
    const minute = args[3] - args[1];
    const result = hour + minute - args[4];
    console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29636
unittest
{
	assert( [ "2 5 4" ].parse.expand.solve == 2 );
	assert( [ "2 6 3" ].parse.expand.solve == 5 );
	assert( [ "31 41 5" ].parse.expand.solve == 23 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abc = input.front.split.to!( long[] );
	return tuple( abc );
}

auto solve( long[] abc )
{
	abc = abc.sort().array;
	
	auto i = 0;
	while( abc[ 0 ] != abc[ 1 ] || abc[ 0 ] != abc[ 2 ] )
	{
		switch( abc[ 1 ] - abc[ 0 ] )
		{
			case 0:
				abc[ 0 ]++;
				abc[ 1 ]++;
				break;
			
			case 1:
				abc[ 0 ]++;
				abc[ 2 ]++;
				break;
			
			default:
				abc[ 0 ] += 2;
				break;
		}
		
		i++;
	}

	return i;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
ll k;
int q;

int win[MAX_N];

ll score[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d %lld %d", &n, &k, &q);

  for (int i = 0; i < q; ++i) {
    int a;
    scanf("%d", &a);
    win[a] += 1;
  }

  for (int i = 1; i <= n; ++i) {
    score[i] = k - (ll)(q - win[i]);
  }

  for (int i = 1; i <= n; ++i) {
    if (score[i] > 0) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }

  return 0;
}


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

#define M 1046527
#define L 14

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  long long k,i,h;
  k=getKey(str);
  for(i=0;;i++){
    h=(h1(k)+i*h2(k))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0)return 0;
  }
  return 0;
}

int insert(char str[]){
  long long k,i,h;
  k=getKey(str);
  for(i=0;;i++){
    h=(h1(k)+i*h2(k))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}
void in(){
 int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

}
int main(){
  in();
  return 0;
}



Measured memory_bytes: 16108
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		int[] ABC = {in.nextInt(), in.nextInt(), in.nextInt()};
		Arrays.sort(ABC);
		int ans = 0;
		
		while(ABC[1] < ABC[2]){
			ABC[0]++;
			ABC[1]++;
			ans++;
		}
		
		while(ABC[0] <= ABC[2] - 2){
			ABC[0] += 2;
			ans++;
		}
		
		if(ABC[0] < ABC[2]) ans += 2;
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <vector>

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

int main() {
  using namespace std;
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int ans = 0;
  long long req = 0;
  vector<int> suf;
  for (int i = 0; i < n; i++) {
    if (a[i] - b[i] < 0) {
      ans++;
      req += b[i] - a[i];
    } else if (a[i] - b[i] > 0) {
      suf.emplace_back(a[i] - b[i]);
    }
  }
  debug(req, ans);
  sort(suf.begin(), suf.end(), greater<int>());
  long long suf_sum = 0;
  for (int i = 0; i < (int)suf.size(); i++) {
    if (suf_sum >= req) break;
    suf_sum += suf[i];
    ans++;
  }
  if (suf_sum >= req) {
    cout << ans << '\n';
  } else {
    cout << -1 << '\n';
  }
  return 0;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 100000000000000LL;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct point {
    ll next;
    ll cost;
};

int main() {
    ll N, K;

    cin >> N >> K;
    vector<point> points(N + 1);

    for (ll i = 1; i <= N; i++) {
        cin >> points[i].next;
    }

    bool plus_exist = false;

    for (ll i = 1; i <= N; i++) {
        cin >> points[i].cost;
        if (points[i].cost > 0) {
            plus_exist = true;
        }
    }
    if (!plus_exist) {
        ll max_cost = -INF;
        for (ll i = 1; i <= N; i++) {
            max_cost = max(max_cost, points[i].cost);
        }
        print(max_cost);
        return 0;
    }

    map<ll, vector<ll>> unions;
    vector<pair<ll, ll>> isshu_costs;
    set<ll> done;

    for (ll i = 1; i <= N; i++) {
        if (done.count(i)) {
            continue;
        }

        ll cst = 0;
        point p = points[i];
        done.insert(i);
        while (true) {
            cst += points[p.next].cost;
            done.insert(p.next);
            unions[i].push_back(p.next);
            if (p.next == i) {
                break;
            }
            p = points[p.next];
        }
        isshu_costs.push_back(make_pair(i, cst));
    }

    ll max_result = -INF;
    for (auto ic : isshu_costs) {
        ll cost = ic.second;
        ll i = ic.first;
        ll size = unions[i].size();
        ll ic_result = 0;
        ll RK = -1;
        if (cost > 0) {
            if (K >= 2 * size) {
                ll shu = K / size - 1;
                ic_result += shu * cost;
                RK = K - shu * size;
            } else {
                RK = K;
            }
        } else {
            RK = size;
        }
        ll max_move = -INF;
        for (ll s : unions[i]) {
            ll total = 0;
            point pp = points[s];
            for (ll j = 0; j < RK; j++) {
                total += points[pp.next].cost;
                pp = points[pp.next];
                max_move = max(total, max_move);
            }
        }
        ic_result += max_move;
        max_result = max(max_result, ic_result);
    }
    print(max_result);
}


Measured memory_bytes: 4096