akhauriyash/Code-Regression huggingface dataset:
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 24) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int aray[200005];

int qpow(int b, int e) {
	if(!e) return 1;
	if(!(e&1)) return qpow(1ll*b*b%MOD,e>>1);
	return 1ll*b*qpow(b,e-1)%MOD;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; gi(n);
	rep(i, n) gi(aray[i]);
	if(n == 1) {
		print(2*aray[0]%MOD);
		return 0;
	}
	sort(aray, aray+n);
	int psum = 0, ans = 0, cp = qpow(2, n-2);
	rep(i, n) {
		ans = (ans + 2ll * cp * aray[i] + 1ll * cp * psum) % MOD;
		psum += aray[i]; if(psum >= MOD) psum -= MOD;
	}
	cout << (1ll * ans * cp * 4) % MOD << endl;
}


Measured memory_bytes: 5120
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>

#define rep(i,x) for(ll i=0;i<(int)(x);i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll h, w, n;
    cin >> h >> w >> n;
    ll sr, sc;
    cin >> sr >> sc;

    string s, t;
    cin >> s >> t;

    ll up = 0;
    ll dp = 0;
    ll rp = 0;
    ll lp = 0;
    ll us = sr-1;
    ll ds = h-sr;
    ll rs = w-sc;
    ll ls = sc-1;

    rep(i, n){
        if(s[i]=='U') {
            up++;
            ds++;
        }
        if(s[i]=='D'){
            dp++;
            us++;
        }
        if(s[i]=='R'){
            rp++;
            ls++;
        }
        if(s[i]=='L'){
            lp++;
            rs++;
        }
        if(up>=sr || lp>=sc || dp>=h-sr+1 || rp>=w-sc+1){
            cout << "NO";
            return 0;
        }
        if(t[i]=='U' && us>0){
            dp--;
            us--;
            ds++;
        }
        if(t[i]=='D' && ds>0){
            up--;
            ds--;
            us++;
        }
        if(t[i]=='R' && rs>0){
            lp--;
            rs--;
            ls++;
        }
        if(t[i]=='L' && ls>0){
            rp--;
            ls--;
            rs++;
        }
    }
    cout << "YES";

}

Measured memory_bytes: 776
#include<stdio.h>

int main(){
  int a[3][3];
  int b[3][3];
  int n,x;
  int i,j,k;
  int flag = 0;

  for(i = 0;i < 3;i++){
    for(j = 0;j < 3;j++){
      scanf("%d", &a[i][j]);
      b[i][j] = 0;
    }
  }

  scanf("%d", &n);

  for(k = 0;k < n;k++){
    scanf("%d", &x);
    for(i = 0;i < 3;i++){
      for(j = 0;j < 3;j++) if(x == a[i][j]) b[i][j] = 1;
    }
  }

  if(b[0][0] == 1 && b[0][1] == 1 && b[0][2] == 1) flag = 1;
  if(b[1][0] == 1 && b[1][1] == 1 && b[1][2] == 1) flag = 1;
  if(b[2][0] == 1 && b[2][1] == 1 && b[2][2] == 1) flag = 1;
  if(b[0][0] == 1 && b[1][0] == 1 && b[2][0] == 1) flag = 1;
  if(b[0][1] == 1 && b[1][1] == 1 && b[2][1] == 1) flag = 1;
  if(b[0][2] == 1 && b[1][2] == 1 && b[2][2] == 1) flag = 1;
  if(b[1][1] == 1 && b[0][0] == 1 && b[2][2] == 1) flag = 1;
  if(b[0][2] == 1 && b[1][1] == 1 && b[2][0] == 1) flag = 1;


  if(flag == 0) printf("No\n");

  else printf("Yes\n");

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int s = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		boolean jdg = false;
			
		if(s == 1000000000) {
			jdg = true;
		}
		
		for(int i = 0 ; i < n ;i++) {
			if(i < k) {
				a[i] = s;
			}
			else {
				a[i] = jdg ? 1 :(s + 1000);
			}
		}
		
		for(int i = 0 ; i < n-1 ;i++) {
			System.out.print(a[i]+" ");
		}
		System.out.print(a[n-1]);
		System.out.println();

	}

}


Measured memory_bytes: 44540
#include <iostream>
#include <algorithm>
#include <array>

int main(int argc, char *argv[])
{
  std::array<int, 3> iarr;
  for (const int& i : {0, 1, 2}) {
    std::cin >> iarr[i];
  }
  std::sort(iarr.begin(), iarr.end(), [](int a, int b) {
      return a > b;
    });
  std::cout << iarr[0] *  10 + iarr[1] + iarr[2];

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int n,m,q,mindist[100004],col[100004],s[100004],d[100004],c[100004];
vector <int> g[100004];
void dfs(int x,int dist,int color){
	if (dist<=mindist[x]) return;
	mindist[x]=dist;
	if (col[x]==0) col[x]=color;
	for (int i=0;i<g[x].size();i++)
		dfs(g[x][i],dist-1,color);
}
int main(){
	memset (col,0,sizeof(col));
	memset (mindist,-1,sizeof(mindist));
	cin>>n>>m;
	for (int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);  
	}
	cin>>q;
	for (int i=0;i<q;i++)
		cin>>s[i]>>d[i]>>c[i];
	for (int i=q-1;i>=0;i--)
		dfs(s[i],d[i],c[i]);
	for (int i=1;i<=n;i++)
		cout<<col[i]<<"\n";
	return 0;
}

Measured memory_bytes: 8440
n = input()
# a = map(int,input().split())
a = int(n[-1])
# print("a",a)
if a == 2 or a == 4 or a == 5 or a == 7 or a == 9:
    print("hon")
elif a == 3:
    print("bon")
else:
    print("pon")

Measured memory_bytes: 9168
#include <string>
#include <iostream>

int main() {
  std::string str;
  std::cin >> str;
  std::string hitachi;
  for (int i = 0; i < str.size()/2; i++) hitachi += "hi";
  if (hitachi == str) std::cout << "Yes";
  else std::cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[100005];
ll   dp[2][4];   // (curr or next), (empty,A,AB,ABC)

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int len=strlen(str);

    int curr=0, next=1;
    dp[0][curr]=1;
    int i;
    for(i=0; i<len; i++) {
        int k;
        for(k=0; k<4; k++) {
            dp[next][k]=(str[i]=='?'? (dp[curr][k]*3%MOD): dp[curr][k]);
        }
        if(str[i]=='?' || str[i]=='C') dp[next][3]=(dp[next][3]+dp[curr][2])%MOD;            
        if(str[i]=='?' || str[i]=='B') dp[next][2]=(dp[next][2]+dp[curr][1])%MOD;
        if(str[i]=='?' || str[i]=='A') dp[next][1]=(dp[next][1]+dp[curr][0])%MOD;

        swap(curr,next);
    }
    printf("%lld\n", dp[curr][3]);

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    if (n <= 999) {
      cout << "ABC" << '\n';
    } else {
      cout << "ABD" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

/// x^^n % m
long powmod(long x, long n)
{
    alias T = long;
    T m = 10 ^^ 9 + 7;
    if (n < 1)
        return 1;
    if (n & 1)
    {
        return x * powmod(x, n - 1) % m;
    }
    T tmp = powmod(x, n / 2);
    return tmp * tmp % m;
}

long invmod(long x)
{
    return powmod(x, MOD - 2L);
}
// alias invmod = (long x, long m = 10 ^^ 9 + 7) => powmod(x, m - 2, m);

void main()
{
    long N, M;
    scan(N, M);

    auto memo = new long[](M + 1);
    memo[0] = 1;
    foreach (i; 1 .. M + 1)
        memo[i] = memo[i - 1] * i % MOD;
    auto inv = new long[](M + 1);
    foreach (i; 0 .. M + 1)
        inv[i] = invmod(memo[i]);

    long Permutation(long n, long r)
    {
        return memo[n] * inv[n - r] % MOD;
    }

    long Combination(long n, long r)
    {
        return (memo[n] * inv[n - r] % MOD) * inv[r] % MOD;
    }

    long a = Permutation(M, N);
    foreach (i; 1 .. N + 1)
    {
        long b = Permutation(M - i, N - i);
        // dprint(i, a, b, (N - i + 1));
        a += MOD;
        a += (b * Combination(N, i) % MOD) * ((i & 1) ? -1 : 1);
        a %= MOD;
    }
    writeln(a * Permutation(M, N) % MOD);
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 M,K;
    cin >> M >> K;

    /*
    vector<i64> v;
    rep(i,0,1<<M){
        v.emplace_back(i);
        v.emplace_back(i);
    }
    i64 cnt=0;
    do{
        bool ok=true;
        rep(i,0,1<<M){
            i64 l=-1,r;
            rep(j,0,v.size()){
                if(v[j]==i){
                    if(l==-1) l=j;
                    else{
                        r=j;
                        break;
                    }
                }
            }
            i64 x=0;
            rep(j,l,r+1) x^=v[j];
            if(x!=K){
                ok=false;
                break;
            }
        }
        if(ok){
            rep(i,0,v.size()){
                cout << v[i] << " ";
            }
            cout << endl;
            ++cnt;
        }
    }while(next_permutation(begin(v),end(v)));

    cout << cnt << endl;
     */

    if(K>=(1<<M)){
        cout << -1 << endl;
        return;
    }

    if(M==1 and K==1){
        cout << -1 << endl;
        return;
    }

    vector<i64> ans;

    if(K==0){
        rep(i,0,1<<M){
            ans.emplace_back(i);
            ans.emplace_back(i);
        }
        rep(i,0,ans.size()){
            cout << ans[i];
            if(i==ans.size()-1){
                cout << endl;
            }else{
                cout << " ";
            }
        }
        return;
    }

    rep(i,0,K) ans.emplace_back(i);
    ans.emplace_back(K);
    rep(i,0,K) ans.emplace_back(K-i-1);

    rep(i,K+1,1<<M) ans.emplace_back(i);
    ans.emplace_back(K);
    rep(i,0,(1<<M)-(K+1)) ans.emplace_back((1<<M)-i-1);

    rep(i,0,ans.size()){
        cout << ans[i];
        if(i==ans.size()-1){
            cout << endl;
        }else{
            cout << " ";
        }
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<pair<ll, ll>> P(N);
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    P[i].first = B;
    P[i].second = A;
  }
  sort(P.begin(), P.end());
  bool ans = true;
  ll t = 0;
  for (int i = 0; i < N; i++) {
    if (P[i].first - P[i].second < t) {
      ans = false;
      break;
    }
    t += P[i].second;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3328
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }




// ***************************************


int main(){

    ll A, B, C, K;

    cin >> A >> B >> C >> K;

    ll ans = 0;
    ans += min(A, K);
    if (A < K) {
        K -= A;
        if (B < K){
            K -= B;
            ans -= min(K, C);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
stack = []
for l in range(len(N)):
    a = int(N[l])
    if a == 0:
        print(stack.pop())
        #print("POP")
    else:
        #print(a)
        stack.append(a)



Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
    REP(i, a.size()) {
        cin >> a[i];
        a[i]--;
    }
}

ll mod = 1000000007;

int main() {
    string S, T;
    cin >> S >> T;

    if (T.substr(0, S.size()) != S) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=0
for i in range(A+1):
  for j in range(B+1):
    result = X-(i*500+j*100)
    if result >= 0 and result - 50*C <= 0:
      cnt +=1

print(cnt)


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

#define int long long
int mod = 1000000007;

int moduloMultiplication(int a, int b)  { 
    int res = 0; // Initialize result 
  
    // Update a if it is more than 
    // or equal to mod 
    a %= mod; 
  
    while (b) 
    { 
        // If b is odd, add a with result 
        if (b & 1) 
            res = (res + a) % mod; 
  
        // Here we assume that doing 2*a 
        // doesn't cause overflow 
        a = (2 * a) % mod; 
  
        b >>= 1; // b = b / 2 
    } 
    
    return res; 
} 

signed main() {
	int n, k;
	cin >> n >> k;
//	cout << k << endl;
	
	vector<int> a;
	for(int i = 0; i < n; i++) {
		int t; cin >> t;
		a.push_back(t);
	}
	
	int x, p, y, q;
	
	if(k%2==0) {
		x = k/2;
//		cout << x << endl;
		p = moduloMultiplication(k+1, x);	
	}
	else {
		x = (k+1)/2;
//		cout << x << endl;
		p = moduloMultiplication(k, x);	
	}
//	cout << k << endl;
	
	if(k%2==0) {
		y = k/2;
//		cout << y << endl;
		q = moduloMultiplication(k-1, y);	
	}
	else {
		y = (k-1)/2;
//		cout << x << endl;
		q = moduloMultiplication(k, y);	
	}
	
	int count1 = 0, count2 = 0;;
	for(int i = 0; i < n-1; i++) {
		for(int j = i+1; j < n; j++) {
			if(a[j]<a[i]) count1++;
			if(a[j]>a[i]) count2++;
		}
	}
//	cout << count << endl;
//	cout << count2 << endl;
	int ans1 = moduloMultiplication(p, count1);
	int ans2 = moduloMultiplication(q, count2);
	int ans = (ans1+ans2)%mod;
	cout << ans << endl;
	return 0;
}

//	for(int i = 2000; i > 0; i++) {
//		if(!a[i].empty()) {
//			for(int j = 0; j < a[i].size(); j++) {
//				int index = a[i][j];
//				for(int k = i-1; k > 0; k++) {
//					if(!a[k].empty()) {
//						
//					}
//				}
//			}
//		}
//	}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int main(){
    char s[201], t[101], p[101];

    scanf("%s %s", s, p);
    strcpy(t, s);
    strcat(s, t);

    if (strstr(s, p) == NULL) printf("No\n");
    else printf("Yes\n");
}



Measured memory_bytes: 2736
use std::io;
use std::str::FromStr;
use std::cmp::min;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut dp: Vec<u64> = vec![0; n+1];
    for i in 1..(n+1) {
        let mut min_val = dp[i-1] + 1;        
        let mut six_candidate = 6;
        while six_candidate <= i {
            min_val = min(min_val, dp[i - six_candidate as usize] + 1);
            six_candidate *= 6;
        }
        let mut nine_candidate = 9;
        while nine_candidate <= i {
            min_val = min(min_val, dp[i - nine_candidate as usize] + 1);
            nine_candidate *= 9;
        }
        dp[i] = min_val;
    }
    println!("{}", dp[n]);
}

Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <string>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;
string w = "YAKI";

int main(){

	//freopen("Text.txt","r",stdin);
	string s;

	int n,m,k;

	cin >> n >> m >> k;

	for (int i = 0; i <= n; ++i){

		for (int j = 0; j <= m; ++j){
			long long res = (m-j)*i + (n-i)*j;

			if (res == k){
				cout << "Yes";
				return 0;
			}
		}
	}


	cout << "No";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x :
            i += 1
            A[i], A[j] = A[j], A[i]

    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1

b = partition(A, 0, n-1)
A[b] = '[{0}]'.format(A[b])
print(' '.join(map(str, A)))


Measured memory_bytes: 16384
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    vector<string> words;
    string word; 
    string longest = "";

    while(cin >> word) {
        words.push_back(word);
        if(word.length() > longest.length()) {
                longest = word;
        }
    }

    string freq;
    int frequency = 0;
    for(int i = 0; i < words.size(); i++) {
        int tmp = count(words.begin(), words.end(), words[i]);
        if (tmp > frequency) {
            frequency = tmp;
            freq = words[i];
        }
    }

    cout << freq << " " << longest << endl;

    return 0;
}

Measured memory_bytes: 0
n, m = map(int, input().split())
line = [int(part) for part in input().split()]

if n >= m:
    print(0)
    exit()

line.sort()

sub_line = []
for num in range(len(line)-1):
    sub_line.append(line[num+1]-line[num])

sub_line.sort()
#print(sub_line)
print(sum(sub_line[:m-n]))

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

using namespace std;

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

  int N; cin>>N;
  vector<int> maxes;
  auto find_greater = [&](int n) {
    int l=0, r=maxes.size()-1;
    int res=r+1;
    while (l <= r) {
      auto c = (l+r)/2;
      if (n > maxes[c]) {
        res = c;
        r = c-1;
      } else {
        l = c+1;
      }
    }
    return res;
  };

  for (int i = 0; i < N; i++) {
    int a; cin>>a;
    auto p = find_greater(a);
    if (p == maxes.size()) {
      maxes.push_back(a);
    } else {
      maxes[p] = a;
    }
  }
  cout << maxes.size() << endl;

  return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[222222];
long long ans,cnt[33],n;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for (int i=0;i<n;i++)
	{
		ans=ans+i-cnt[s[i]-'a'];
		cnt[s[i]-'a']++;
	}
	printf("%lld\n",ans+1);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int gcd(int a, int b){
    int c;
    while(b != 0){
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    in_arr(int, a, n);
    int b = accumulate(a.begin(), a.end(), a[0], [](int a, int b){ return gcd(a, b); });
    int m = accumulate(a.begin(), a.end(), 0, [](int a, int b){ return max(a, b); });
    if(m < k){
        cout << "IMPOSSIBLE" << endl;
    }else if(k % b == 0){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
N=int(input())
ans=N
for i in range(N+1):
  cnt=0
  t=i
  while t>0:
    cnt+=t%6
    t//=6
  j=N-i
  while j>0:
    cnt+=j%9
    j//=9
  ans=min(ans,cnt)
print(ans)


Measured memory_bytes: 9180
#include<iostream>
using namespace std;
#define REP(i,n) for(unsigned int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define MAX 1000001
 
bool N[MAX] = {};
 
int M[MAX] = {};
 
void SoE()
{
    REP(i, MAX)N[i] = true;
 
    N[1] = true;
    for (unsigned int i = 2; i*i <= MAX; i++)
    {
        for (unsigned int j = i+i; j < MAX; j += i)
        {
            N[j] = false;
        }
    }
}
 
void Count()
{
    M[1] = 0;
    FOR(i, 2, MAX - 1)
    {
        int add = 0;
        if (N[i] == true)
        {
            add = 1;
        }
        M[i] = M[i - 1] + add;
    }
}
 
int main()
{
    SoE();
    Count();
    int tmp;
    while (cin >> tmp)
    {
        cout << M[tmp] << endl;
    }
    return 0;
}


Measured memory_bytes: 7968
#include <stdio.h>
#include <stdlib.h>

#define WHITE 0
#define BLACK 1
#define GLAY  2

int *Adj[101];
int d[101];
int f[101];
int k[101];
int color[101];
int t;

void dfs(int);
void visit(int);

int main()
{
  int i, j, n, u;

  scanf("%d", &n);
  for( i = 1; i<=n; i++ )
    {
      /* 各頂点ごとに隣接する頂点の番号を格納する配列を用意 */
      scanf("%d", &u);
      scanf("%d", &k[u]);
      Adj[u] = (int *)malloc( sizeof(int) * k[u] );

      /* 頂点uに隣接する頂点の番号を読み込む */
      for( j = 0; j<k[u]; j++ )
	scanf("%d", Adj[u]+j);
    }

  dfs(n);
  
  /* 結果出力 */
  for( i = 1; i<=n; i++ )
    printf("%d %d %d\n", i, d[i], f[i]);

  for( i = 0; i<=100; i++ )
    free(Adj[i]);
  return 0;
}


/* 有向グラフに対して深さ優先探索を行う関数 */
void dfs(int n)
{
  int i;

  /* colorをWHITEで初期化 */
  for( i = 1 ; i<=n; i++ )
    color[i] = WHITE;

  /* まだ訪れていない頂点を訪れる */
  for( i = 1; i<=n; i++ )
    {
      if( color[i] == WHITE )
	visit(i);
    }
}


/* 頂点uとそれに隣接する頂点を再帰的に訪れ、タイムスタンプを押す関数 */
void visit(int u)
{
  int i;

  color[u] = GLAY;     /* 頂点uを訪れたと設定 */
  d[u] = ++t;       /* 発見時刻スタンプを押す */

  for( i = 0; i<k[u]; i++ )
    {
      if( color[ *(Adj[u]+i) ] == WHITE )
	visit( *(Adj[u]+i) );
    }

  color[u] = BLACK;       /* 頂点uを調べ終わったと設定 */
  f[u] = ++t;          /* 終了時刻スタンプを押す */
}



Measured memory_bytes: 2128
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    reverse(s[0].begin(), s[0].end());
    reverse(s[1].begin(), s[1].end());
    reverse(s[2].begin(), s[2].end());
    int turn = 0; // 最初は a のターン

    while (1) {
        if (s[turn].length() == 0) {
            char winner = 'A' + (char)turn;
            cout << winner << endl;
            return 0;
        }
        int next = s[turn].back() - 'a';
        s[turn].pop_back();
        turn = next;
    }
    return 0;
}


Measured memory_bytes: 256
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    S= list(sys.stdin.readline().rstrip())
    c1=S.count(S[0])
    c2=S.count(S[1])
    c3=S.count(S[2])
    c4=S.count(S[3])
    if c1==c2==c3==c4==2:
        print("Yes")
    else:
        print("No")


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

using namespace std;

int main() {
int N, K;
	cin >> N >> K;
	vector<int> V(N);
	for(auto &x: V) cin >> x;

	int rres = 0;
	for(int a = 0; a <= min(K, N); a++) {
		for(int b = 0; b + a <= min(K, N); b++) {
			vector<int> c(a + b);
			int res = 0;
			for(int i = 0; i < a; i++) {
				c[i] = V[i];
			}
			for(int j = 0; j < b; j++) {
				c[a + j] = V[N - 1 - j];
			}

			sort(c.begin(), c.end());
			int M = K - a - b;
			for(auto x: c) {
				if(x < 0 && M > 0) {
					M--;
				} else {
					res += x;
				}
			}
			rres = max(rres, res);
		}
	}

	cout << rres << endl;
}


Measured memory_bytes: 256
cards = list()
suits = ["S", "H", "C", "D"]

n = int(input())
for i in range(1, n + 1):
    s, r = input().split()
    r = int(r)
    if s == "S":
        cards.append(r)
    elif s == "H":
        cards.append(r + 13)
    elif s == "C":
        cards.append(r + 26)
    elif s == "D":
        cards.append(r + 39)

for i in range(1, 53):
    if i not in cards:
        print(suits[(i - 1) // 13], (i - 1) % 13 + 1)



Measured memory_bytes: 5608
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sb = sum(b)
s = sb
j = m-1
while s > k:
    s -= b[j]
    j -= 1
ans = j+1
for i in range(n):
    s += a[i]
    while s > k and j >= 0:
        s -= b[j]
        j -= 1
    if s > k:
        break
    ans = max(ans, i+j+2)
print(ans)

Measured memory_bytes: 40440
import sys
import math

len = int(input())
numList = [int(n) for n in input().split()]

errCount = 0
for i in range(len):
    if numList[i] != int(i+1):
        errCount+=1

if errCount == 0 or errCount == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

S = list(input())
N = len(S)
S = np.array(S)
onecount = np.count_nonzero(S == "1")
print(2 * min(onecount, N - onecount))

Measured memory_bytes: 22976
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n,k;
    int a[200001];
    scanf("%d %d", &n,&k);
    
    for(int i=1;i<=n;i++){
    scanf("%d", &a[i]);}
    
   //printf("%d %d %d %d",a[0],a[1],a[2],a[3]);
 
    for(int i=1;i<=n-k;i++){
        if(a[i]<a[i+k]){
        printf("Yes\n"); 
        }
        else{
        printf("No\n");            
        }
        
    }   
}


Measured memory_bytes: 2444
#include<bits/stdc++.h>
using namespace std;
char s;
int a;
int b;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
	if(s=='I')
	a++;
	else
	a--;
	b=max(b,a);
   }   
     cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i32>();
    let (a, b, c) = (line[0], line[1], line[2]);

    if b-a == c-b{
        println!("YES");
    }else{
        println!("NO");
    }
}


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

using namespace std;

int main() {
	int n, sum = 0;
	cin >> n;
	int s[n];
	for(int i = 0; i < n; i++) {
		cin >> s[i];
		sum += s[i];
	}
	if(sum % 10 == 0) {
		bool d = false;
		sort(s, s+n);
		for(int i = 0; i < n; i++) {
			if(s[i] % 10) {
				sum -= s[i];
				d = true;
				break;
			}
		}
		if(d)
			cout << sum << "\n";
		else
			cout << 0;
	}
	else
		cout << sum;
}

Measured memory_bytes: 256
# 入力
[K,S] = list(map(int, input().split()))

# 処理
ans = 0 # 答え
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y          # X+Y+Z = Nより
    if 0 <= Z and Z <= K:  # Zが0以上K以下ならカウント
      ans += 1
      
# 出力
print(ans)

Measured memory_bytes: 2940
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>
#include <random>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  lint x;
  cin>>x;
  lint limit=1000;
  for(lint a=-limit;a<=limit;a++){
    for(lint b=-limit;b<=limit;b++){
      if(a*a*a*a*a-b*b*b*b*b==x){
        cout<<a<<" "<<b<<endl;
        return 0;
      }
    }
  }
  cout<<"Error"<<endl;



  return 0;
}






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

int main()
{
	int dataset;
	cin >> dataset;
	int coeunt = 0;
	int a[100];

	for (int i = 0; i < dataset; i++)
	{
		cin >> a[i];
	}
	for (size_t i = 0; i < dataset; i++)
	{
		int minj = i;
		for (size_t j = i + 1; j < dataset; j++)
		{
			if (a[minj] > a[j]) { minj = j;  }
		}
		if(i!=minj){
			int d = a[i];
			a[i] = a[minj];
			a[minj] = d;
			coeunt++;
		}
		
		
	}

	for (int i = 0; i < dataset; i++)
	{
		if (i > 0) {
			cout << " " << a[i];
		}
		else {
			cout << a[i];
		}
	}

	cout << endl << coeunt << endl;
}

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

int main() {
  int H;
  cin >> H;
  vector<int> heap(H + 1);

  for (size_t i = 0; i < H; i++) {
    cin >> heap[i + 1];
  }

  for (size_t i = 1; i < H + 1; i++) {
    auto node = heap[i];
    cout << "node " << i << ": key = " << node << ", ";
    if (i / 2 >= 1) {
      cout << "parent key = " << heap[i / 2] << ", ";
    }
    if (2 * i <= H) {
      cout << "left key = " << heap[2 * i] << ", ";
    }
    if (2 * i + 1 <= H) {
      cout << "right key = " << heap[2 * i + 1] << ", ";
    }

    cout << endl;
  }
}



Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
 
 template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
    for(const auto& itr : v){
        os << itr << (itr != v.back() ? " " : "");
    }
  return os;
}
// ------------------------

void solve() {
    int N; cin >> N;
    vector<int> A;
    rep(i, N){
        int x;
        cin >> x;
        if(x % 2 == 0){
            A.emplace_back(x);
        }
    }

    for( auto a : A){
        bool three_flag = false;
        bool five_flag = false;
        if(a % 3 == 0){
            three_flag = true;
        }

        if(a % 5 == 0){
            five_flag = true;
        }

        if(!three_flag && !five_flag ){
            cout << "DENIED" << "\n";
            return;
        }
    }

    cout << "APPROVED" << "\n";
    return;
}
 
signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7

def f():
    n = int(input())
    a,b = 1,1
    t = 0
    for _ in range(n):
        l,r = list(map(int, input().split()))
        ll = l
        rr = r
        if ll < a:
            s = a - ll
            ss = (s // l)
            while ss * l + ll < a:
                ss += 1
            ll += l*ss
            rr += r*ss
        if rr < b:
            s = b - rr
            ss = (s // r)
            while ss * r + rr < b:
                ss += 1
            ll += l*ss
            rr += r*ss
        a = ll
        b = rr
        t = ll + rr
    return t

print(f())


Measured memory_bytes: 7816
def dfs(pos, t, sum):
    global cnt
    if t == n:
        if sum == s:
            cnt += 1
        return
    if pos > 9:
        return

    dfs(pos+1, t, sum)
    dfs(pos+1, t+1, sum + pos)


while True:
    n, s = map(int, raw_input().split())
    if n==0 and s==0: break

    cnt = 0
    dfs(0, 0, 0)
    print cnt

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

int main() {

  int N;
  cin >> N;
  
  vector<string> S(N);
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  
  int Nac=0, Nwa=0, Ntle=0, Nre=0;
  
  for(int i = 0; i < N; i++) {
    if(S.at(i)=="AC") Nac++;
    else if(S.at(i)=="WA") Nwa++;
    else if(S.at(i)=="TLE") Ntle++;
    else if(S.at(i)=="RE") Nre++;
  }
  
  cout << "AC x " << Nac << endl;
  cout << "WA x " << Nwa << endl;
  cout << "TLE x " << Ntle << endl;
  cout << "RE x " << Nre << endl;
}

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

int main() {
  long n,q,ans=0;
  cin >> n;
  vector<long> a(n);
  map<long,long> z;
  for(long i=0;i<n;i++) {
    cin >> a[i];
    ans+=a[i];
    z[a[i]]++;
  }
  cin >> q;
  vector<long> b(q);
  vector<long> c(q);
  for(long i=0;i<q;i++) cin >> b[i] >> c[i];
  for(long i=0;i<q;i++) {
    auto itr=z.find(b[i]);
    if(itr!=z.end()) {
      pair p=*itr;
      ans+=(c[i]-b[i])*p.second;
      z[c[i]]+=p.second;
      z.erase(itr);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    int s=4*x-y;
    if(s%2)
        cout<<"No";
    else
    {
        int t=s/2;
        if(t<=x&&t>=0)
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3632
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int[] a) {
    long ans = 0;
    int hi = 0;
    int sum = 0;
    for (int lo = 0; lo < a.length; lo++) {
        // hi を伸ばせるところまで伸ばす
        while (hi < a.length && sum + a[hi] == (sum ^ a[hi])) {
            sum += a[hi++];
        }
        ans += hi - lo + 1 - 1;
        // lo を右にずらすのでその分だけ引く
        sum -= a[lo];
        hi = max(hi, lo);
    }
    return ans;
}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}


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

int main(){
 int n,count = 0;;
 int a[10002];
 int q,b;
 cin >> n;
 for(int i = 0;i < n;i++){
 scanf("%d",&a[i]);
 }
 cin >> q;
 for(int i = 0;i < q;i++){
 	scanf("%d",&b);
 	for(int i = 0;i < n;i++){
 		if(a[i] == b){
 		count++;
 		break;
 		}
 	}
 }
 cout << count <<endl;
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<map>
#include<string>
#include<string.h>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<iostream>
#include<math.h>
#include<stack>
#include<set>
#define INF 2147483647
#define n 300000
#define loop(i, a, b) for(int i=a; i<=b; i++)
#define mem(arr) memset(arr, 0, sizeof(arr));
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
struct edge{
	int to, weight;
};
void solve();
int main()
{
	int times = 1;
//	cin >> times;
	loop(i, 1, times)
	{
		solve();
		cout << '\n';
	}
	return 0;
}
vector<edge> V[n + 50];
int a, b, c, d, e, f;
int arr[n + 50], arr1[n + 50], arr2[n + 50];
string str, str1, str2;

void solve()
{
	int table[150]; mem(table);
	for(int i=1; i<=9; i++)
		for(int j=1; j<=9; j++)
			table[i * j] = true;
	cin >> a;
	if(table[a]) cout << "Yes";
	else		 cout << "No";
}

Measured memory_bytes: 8704
import math

K = int(input())
sumGCD = K * K * K
for a in range(2, K + 1, 1):
    for b in range(2, K + 1, 1):
        for c in range(2, K + 1, 1):
            arr = [a, b, c]
            gcdNum = math.gcd(math.gcd(a, b), c)
            # if gcdNum != 1:
            # print(arr)
            # print(gcdNum)
            sumGCD += gcdNum - 1
print(sumGCD)


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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int res;
	res = a * b / 2;
	printf("%d",res);
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std; 
int n, sum;
int main() { 
	cin >> n; 
	sum = n;
	for (int i = 2; i * i <= n; i++) {
		if (n%i == 0) {
			sum = sum / i*(i - 1);
			while (n%i == 0) { n /= i; }
		}
	}
	if (n != 1) { sum = sum / n*(n - 1); }
	cout << sum << endl; 
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
    vector<vector<int>> dp(n+1, vector<int>(3, 0));
    for(int i = 0; i < n; i++)
    {
        dp[i+1][0] = max(dp[i+1][0], max(dp[i][1], dp[i][2]) + a[i]);
        dp[i+1][1] = max(dp[i+1][1], max(dp[i][0], dp[i][2]) + b[i]);
        dp[i+1][2] = max(dp[i+1][2], max(dp[i][0], dp[i][1]) + c[i]);
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}


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

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if((x - r >= 0 && x + r <= W) && (y - r >= 0 &&  y + r <= H)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int M =sc.nextInt();
		int D = sc.nextInt();
		
		int count = 0;
		for(int i=1;i<=M;i++) {
			for(int p =1;p<=D;p++) {
				int rOne = p%10;
				int rTen = p/10;
				if(rOne*rTen == i && rOne >=2 && rTen >=2) {
					count++;
				}
			}
		}
		
		System.out.println(count);
		
		sc.close();	
	}
}

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    rep(i, 9) rep(j, 9) {
        if (N == (i + 1) * (j + 1)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

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

    if(A+B>C+D){
        cout<<"Left"<< endl;
        }
    else if(A+B==C+D){
        cout<<"Balanced"<< endl;
        }
    else{
        cout<<"Right"<< endl;
    }    
}

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

int main(){
    int N;
    cin >> N;
    bool flag = false;
    if(N % 10 == 7) flag = true;
    else if(N / 10 % 10 == 7) flag = true;
    else if(N / 100 == 7) flag = true;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3592