akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll X;
    cin >> X;

    map<ll, ll> mp;
    rep(i, 1e5) {
        ll tmp = 1;
        rep(j, 5) {
            tmp *= i;
        }
        if (mp.count(tmp) == 1) continue;
        mp[tmp] = i;
    }

    for (auto itr : mp) {
        ll tmp = X - itr.first;
        ll tmpt = abs(tmp);
        if (mp.count(tmpt)) {
            ll B = mp[tmpt];
            if (tmp >= 0) {
                B = -mp[tmpt];
            }
            cout << itr.second << " " << B << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 9884
import java.util.Scanner;

public class Main {

   void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();

        int tmp = N / (2*D + 1);
        int ans = 0;
        if (N % (2*D + 1) == 0) {
            ans = tmp;
        }
        else {
            ans = tmp + 1;
        }

        System.out.print(ans);

    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}



Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    string s;
    cin >> s;
    bool ok = true;
    reverse(s.begin(),s.end());
    int i=0;
    while(ok&&i<s.size()){
        if(s.substr(i,5)=="maerd")i+=5;
        else if(s.substr(i,5)=="esare")i+=5;
        else if(s.substr(i,6)=="resare")i+=6;
        else if(s.substr(i,7)=="remaerd")i+=7;
        else ok = false; 
    }
    if(ok)cout<< "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
public class Main {
	final int INF = (int)1e9 + 7;
	int N,M;
	int[] a,b,d;
	ArrayList<Integer>[] graph;
	int[][] cost;
	private class P implements Comparable<P>{
		int first,second;
		public P(int first,int second){
			this.first = first;
			this.second = second;
		}
		public int compareTo(P p){
			if(this.first == p.first){
				return this.second - p.second;
			}
			return this.first - p.first;
		}
	}

	public int dijkstra(int s){
		boolean[] used = new boolean[N];
		int ret = 0;
		PriorityQueue<P> pq = new PriorityQueue<P>();
		pq.add(new P(0,s));
		while(pq.size() > 0){
			P p = pq.poll();
			if(used[p.second])continue;
			used[p.second] = true;
			ret+=p.first;
			for(int next : graph[p.second]){
				pq.add(new P(cost[p.second][next],next));
			}
		}
		return ret;
	}

	@SuppressWarnings("unchecked")
	public void solve() {
		while(true){
			N = nextInt();

			if(N == 0)break;

			M = nextInt();
			a = new int[M];
			b = new int[M];
			d = new int[M];
			graph = new ArrayList[N];
			cost = new int[N][N];
			for(int i = 0;i < N;i++){
				graph[i] = new ArrayList<Integer>();
			}
			for(int i = 0;i < M;i++){
				String[] line = next().split(",");
				a[i] = Integer.parseInt(line[0]);
				b[i] = Integer.parseInt(line[1]);
				d[i] = (Integer.parseInt(line[2]) / 100) - 1;
				cost[a[i]][b[i]] = d[i];
				cost[b[i]][a[i]] = d[i];
				graph[a[i]].add(b[i]);
				graph[b[i]].add(a[i]);
			}

			int ans = INF;

			for(int i = 0;i < N;i++){
				ans = Math.min(ans, dijkstra(i));
			}

			out.println(ans);
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 59588
let rec check n k =
  if n <= k && n <= abs (n - k) then n
  else if n <= k && n > abs (n - k) then abs (n - k)
  else
    let md = n mod k in
    check md k

let () =
  let n, k = Scanf.scanf "%d %d\n" (fun a b -> (a, b)) in
  print_int @@ check n k

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

struct Combination
{
  int mod;
  vector< int64_t > mfact, rfact;

  Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod)
  {
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const
  {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const
  {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const
  {
    return (pow(x, mod - 2));
  }

  int64_t P(int n, int r) const
  {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const
  {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const
  {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};

int main()
{
  Combination beet(500001, mod);
  int N, M, K;
  cin >> N >> M >> K;


  vector< int > latte(K + 1), malta(K + 1);

  vector< int > dp1(N + 2 * K + 1);
  dp1[0] = 1;
  int base = 0;
  for(int i = 0; i <= K; i++) {
    for(int j = 1 + base; j <= N + K + base; j++) {
      dp1[j] += dp1[j - 1];
      if(dp1[j] >= mod) dp1[j] -= mod;
    }
    latte[i] = dp1[base + N]; // 1 個削る
    ++base;
  }


  dp1.assign(M + 2 * K + 1, 0);
  dp1[0] = 1;
  base = 0;
  for(int i = 0; i <= K; i++) {
    for(int j = 1 + base; j <= M + K + base; j++) {
      dp1[j] += dp1[j - 1];
      if(dp1[j] >= mod) dp1[j] -= mod;
    }
    malta[i] = dp1[base + M];
    ++base;
  }

  int64 ret = 0;
  for(int i = 0; i <= K; i++) {
    (ret += 1LL * latte[i] * malta[K - i] % mod * beet.C(N + M + 2 * K, N + 2 * i) % mod) %= mod;
  }

  cout << ret << endl;

}


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

int main() {
	int S;
	cin >> S;
	int s = S % 60;
	int m = ((S - s) % 3600) / 60;
	int h = (int)(S / 3600);
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 3036
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    string  s;
    cin >> s ;
    ll ans = 0 ;
   for(ll i=0;i<s.size();i++){
        ans=ans*10+s[i]-'0';
    }
    ll num_operand = s.size()-1 ;

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 1; bit < (1<<num_operand); ++bit) {
        ll l = 0 ;
        ll sum = 0 ;
        ll k = 0 ;
           // cout << ans << endl ;
        for (ll i = 0; i < s.size(); ++i) {
            l = 0 ;
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                 for (ll j = k; j <= i; j++)
                 {
                     l=l*10+s[j]-'0';
                 }
                    sum+=l;
                    k = i+1 ;
            }
        }
        l = 0 ;
        for (ll j = k; j < s.size(); j++)
        {
            l = l*10+s[j]-'0';
        }
        sum+=l;
        ans+=sum ;
    }

        cout << ans << endl ;

    return 0 ;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
const long long inf = 1e17;
const int mod = 1000000007;
int a[200006];int n, k; 
bool check() {
	rep(i, n)if (a[i] != n)return false;
	return true;
}
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];

	rep(i, k) {
		vector<int>imos(n + 1);
		rep(j, n) {
			int l = j - a[j], r = j + a[j];
			if (l < 0)l = 0;
			if (r >= n)r = n - 1;
			imos[l]++; imos[r + 1]--;
		}
		rep(j, n) {
			imos[j + 1] += imos[j];
			a[j] = imos[j];
		}
		if (check())break;
	}
	rep(i, n) {
		if (i)cout << ' '; cout << a[i];
	}cout << endl;
}

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  int tmp = 0;
  bool flag = false;
  for(int i=0; i<n; ++i){
  	int d1, d2;
  	cin >> d1 >> d2;
  	if(d1==d2){
		tmp++;
  	}
  	else tmp = 0;
  	if(tmp==3) flag = true;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3584
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<ll, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
#define LEAD (lead && !i)
#define LIM (lim && i == buc[pos])
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int n, m;
int num[N];
bool valid[N];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) num[i] = 1;
    valid[1] = true;
    for (int i = 1; i <= m; i++) {
        int fr, to;
        fr = read();
        to = read();
        num[fr]--;
        num[to]++;
        if (valid[fr]) valid[to] = true;
        if (!num[fr]) valid[fr] = false;
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) if (valid[i]) cnt++;
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner cin = new Scanner(System.in);
		int K = cin.nextInt();
		int A = cin.nextInt();
		int B = cin.nextInt();
		
		int start = A/K;
		int end = B/K;
		
		for(int i = start;i<=end;i++) {
			int target = i*K;
			if(A<=target&&B>=target) {
				System.out.println("OK");
				return;
			}
		}
		
		System.out.println("NG");
		

	}

}


Measured memory_bytes: 27076
class UnionFind():
    
    def __init__(self,size): 
        self.table = [-1 for _ in range(size)]
        self.cou = [1 for _ in range(size)]
        
    def find(self,x): 
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]
        
    def union(self,x,y): 
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] > self.table[s2]:
                self.table[s1] = s2
                self.cou[s2] += self.cou[s1]
                self.cou[s1] = 0
            elif self.table[s2] > self.table[s1]:
                self.table[s2] = s1
                self.cou[s1] += self.cou[s2]
                self.cou[s2] = 0
            else:
                self.table[s2] = s1
                self.table[s1] -= 1
                self.cou[s1] += self.cou[s2]
                self.cou[s2] = 0
        return
    
n, m, k = map(int, input().split())
BList = [[] for _ in range(n)]
friendU = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    BList[a-1].append(b-1)
    BList[b-1].append(a-1)
    friendU.union(a-1, b-1)

for i in range(k):
    c, d = map(int, input().split())
    if friendU.find(c-1) == friendU.find(d-1):
        BList[c-1].append(d-1)
        BList[d-1].append(c-1)
    
ansl = []
for i in range(n):
    j = friendU.find(i)
    ans = friendU.cou[j] - len(BList[i]) - 1
    ansl.append(ans)

print(*ansl)

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

using namespace std;
#define rep(x, n)          for (int x = 0; x < n; x++)
#define REP(x, a, b)       for (int x = a; x <= b; x++)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).begin(), container.end()
#define sz(container)      (int) (container).size()

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define debug(...) 0
#endif
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    string s;
    set<string> ss;
    rep(i,n){
        cin>>s;
        ss.insert(s);
    }
    cout<<sz(ss)<<'\n';
    return 0;
}

Measured memory_bytes: 19260
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> N >> S;
	bool flag = 0;
	ans = 1 << 30;
	ll br = 0, wh = 0;
	ll tmp = 1;
	vector<int>bw;
	for (int i = 1; i < N; i++) {
		if (S[i] == S[i-1]) {
			tmp++;
		}
		else {
			bw.push_back(tmp);
			tmp = 1;
		}
	}
	if(tmp>0)bw.push_back(tmp);
	int sumwh = 0;

	for (int i = 0; i < bw.size(); i++) {
		if (S[0] == '#') {
			if (i & 1) {
				sumwh += bw[i];
			}
		}
		else {
			if (i %2==0 ) {
				sumwh += bw[i];
			}
		}
	}
	for (int i = 0; i < bw.size(); i++) {
		if (S[0] == '#') {
			if (i & 1) {
				wh+=bw[i];
			}
			else {
				tmp = br + sumwh - wh;
				ans = min(ans, tmp);
				br += bw[i];
			}
		}
		else {
			if (i %2 ==0) {
				wh += bw[i];
			}
			else {
				tmp = br + sumwh - wh;
				ans = min(ans, tmp);
				br += bw[i];
			}
		}
	}
	ans = min(br, ans);
	cout << ans;
}


Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    
    int size=s.size();
    for(int i=0;i<size;i++){
        s.pop_back();
        int ss=s.size();
            if(s.substr(0,ss/2)==s.substr(ss/2,ss/2)){
                cout<<ss-1<<endl;
                return 0;
            }
    }
}

Measured memory_bytes: 256
n = int(input())
p = [tuple(map(int, input().split())) for i in range(n)]
q = [tuple(map(int, input().split())) for i in range(n)]

q = sorted(q)
p = sorted(p, key=lambda x:x[1], reverse=True)
res = 0
l = [0]*n
for i in range(n):
    for j in range(n):
        if q[i][0] > p[j][0] and q[i][1] > p[j][1]:
            if l[j] == 0:
                l[j] = 1
                res += 1
                break
            else:
                continue
        
        
print(res)

Measured memory_bytes: 3064
// small_large

using System;

class small_large {
    public static void Main() {
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);

        if(a < b){
            Console.WriteLine("a < b");
        }

        else if(a > b){
            Console.WriteLine("a > b");
        }

        else if(a == b){
            Console.WriteLine("a == b");
        }

    }
}

Measured memory_bytes: 5300
function Main(arg) {
  let N = arg.trim().split('\n')[0];
  let Ln = arg.trim().split('\n')[1].split(' ');
  
  //sort
  Ln.sort(function(a,b){
    if(Number(a)<Number(b))return -1;
    if(Number(a)>Number(b))return 1;
    return 0;
  });

  let count = 0;
  let triSet = new Set();
  for(let i = 0; i+2 <= N; i++ ){
    for(let j = i+1; j+1 <= N; j++){
      for(let k = j+1; k <= N; k++){
        if(isTriangle(Ln[i],Ln[j],Ln[k])){
          count++;
        }
      }
    }
  }
  console.log(count);
}

function isTriangle (a, b, c){
  let numA = Number(a);
  let numB = Number(b);
  let numC = Number(c);
  return numA + numB > numC 
    && numA + numC > numB
    && numB + numC > numA
    && numA != numB
    && numB != numC;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 31980
#!/usr/bin/env python3
import fractions

N, M = list(map(int, input().split()))
S = input()
T = input()

# 最小公倍数を求める
if N == M:
    l = -1
    if S == T:
        l = N
else:
    if N > M:
        w_n, w_m = N, M
        w_s, w_t = S, T
    else:
        w_n, w_m = M, N
        w_s, w_t = T, S

    if w_n % w_m == 0:
        k = w_n // w_m
        is_ok = True
        l = len(w_s)
        for i, char in enumerate(w_t):
            if S[(i - 1) ** k] != char:
                is_ok = False
                break
        if not is_ok:
            l = -1
    else:
        # 最小公倍数が候補
        l = w_m * w_n // fractions.gcd(w_m, w_n)
        is_ok = True
        s_idx_list = []
        t_idx_list = []

        # w_mの方が小さいのでw_mを基準にする
        for i in range(w_n):
            s_idx_list.append(i * (l // w_n))
            t_idx_list.append(i * (l // w_m))
        common_idx_list = list(set(s_idx_list) & set(t_idx_list))

        for j in common_idx_list:
            s_idx = w_n * j // l
            t_idx = w_m * j // l
            if t_idx > w_m - 1:
                break
            if w_s[s_idx] != w_t[t_idx]:
                is_ok = False
                break
        if not is_ok:
            l = -1

ans = l

print(ans)


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

bool num[10];

bool check_keta(int x){
  while (x>0){
    if(!num[x%10]) return false;
    else x/=10;
  }
  return true;
}

int main() {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  int ans=1000000;
  for(int i=a[0];i<=a[n-1];i++){
    int temp=0;
    for(int j=0;j<n;j++){
      temp+=(i-a[j])*(i-a[j]);
    }
    ans=min(ans,temp);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


int main(){

  ll n,sum=0;
   cin>>n;
   vll a(n,0),suma(n,0);
   map<ll,ll> m;
   rep(i,0,n,1){
        cin>>a[i];
        m[a[i]]++;
        sum=sum+a[i];
        suma[i]=sum;
    }
    ll q;
    cin>>q;
    for(int i=0;i<q;++i){
        ll b,c;
        cin>>b>>c;
        if(m.find(b)!=m.end()){
            ll d=m[b];
            m.erase(b);
            sum=sum-b*d+c*d;
            m[c]+=d;

        }

         cout<<sum<<endl;
    }


}


// 1 2 3 1 5 3 1 0 1 0 2
// 1 2 3 4 5 6 7 8 9 10 11






Measured memory_bytes: 8736
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    string s;
    cin >> s;

    set<char> letterset;

    for (auto &&i : s) {
        letterset.insert(i);
    }

    const int ans = s.size() == letterset.size();
    cout << (ans ? "yes" : "no") << endl;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(){
	int n, x;
	scanf("%d", &n);
	int vet[200000];
	for(int i=0; i<n; ++i)
		vet[i]=0;

	for(int i=0; i<(n-1); ++i){
		scanf("%d", &x);
		++vet[x];
	}
	vet[n]=0;
	for(int i=1; i<=n; ++i)
		printf("%d\n", vet[i]);


    return 0;
	
}


Measured memory_bytes: 2504
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }




void solve() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans = b*d;
    chmax(ans,a*c);
    chmax(ans,a*d);
    chmax(ans,b*c);
    cout<<ans<<endl;
}




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


    ll t=1;
    
    // cin>>t;

    rep(i,t){
        solve(); 
    }

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;
	ll a[alength];
	cin>>n;
	fori(n){cin>>a[i];}
	sort(a,a+n);
	ll ans=1;
	fori(n){
		if(ans==0){
			cout<<0;
			return 0;
		}
		if(1000000000000000000/ans<a[i]){
			cout<<-1;
			return 0;
		}
		ans*=a[i];
	}
	cout<<ans;

}

Measured memory_bytes: 4416
#include<iostream>
using namespace std;
int a,d,w,h,x;
main()
{
    while(cin>>d>>w>>h,d)
    {
        if(d>=w&&d>=h)x=w*w+h*h;
        else if(w>=d&&w>=h)x=d*d+h*h;
        else x=d*d+w*w;
        int n;cin>>n;
        while(n--)
        {
            cin>>a;
            a=a*a*4;
            cout<<(a>x?"OK":"NA")<<endl;
        }
    }
}


Measured memory_bytes: 3068
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;

int main(){
  ll N,W;
  cin >> N >> W;
  ll w[N], v[N];
  REP(i,N){
    cin >> w[i] >> v[i];
  }
  ll dp[N+1][W+1]; //i個目まで使い、重さの総和jのときの価値の最大値
  fill(dp[0],dp[N+1],0);
  for(ll i = 1; i <= N; i++){
    REP(j,W+1){
      if(j-w[i-1]<0){
        dp[i][j] = dp[i-1][j]; //i個目は使わない
      }else{
        dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
      }
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 79104
import Data.List
import qualified Data.ByteString.Char8 as B

main = getLine >> breads >>= B.putStrLn . edit . solve . sort
    where
        edit (a, b) = B.unwords $ fmap (B.pack . show) [a, b]

solve :: [Int] -> (Int, Int)
solve xs
    | cst == 0 = (1, n)
    | otherwise = (cst, cst + n)
    where
        (cst, n) = count (0, 0) xs

        count (acc, prev) (y : ys)
            | y >= 3200 = (acc, length ys + 1)
            | y > prev = count (acc + 1, upper y) ys
            | otherwise = count (acc, prev) ys
        count (acc, _) _ = (acc, 0)

        upper x
            | x < 400 = 399
            | x < 800 = 799
            | x < 1200 = 1199
            | x < 1600 = 1599
            | x < 2000 = 1999
            | x < 2400 = 2399
            | x < 2800 = 2799
            | x < 3200 = 3199
            | otherwise = 4800

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  bool ok = false;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (N == i * j) {
        ok = true;
      }
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N; cin>>N;
  vector<int> L(N);
  for(int i=0; i<N; ++i) cin>>L[i];
  sort(L.begin(),L.end());
  int cnt=0;
  for(int i=0; i<N; ++i) {
    for(int j=i+1; j<N; ++j) {
      for(int k=j+1; k<N; ++k) {
        if(L[k]<L[i]+L[j] && L[i]!=L[j] && L[i]!=L[k] && L[j]!=L[k]) cnt++;
      }
    }
  }
  cout << cnt << endl;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int> > gragh(N);
    int a, b;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        gragh.at(a - 1).push_back(b);
        gragh.at(b - 1).push_back(a);
    }

    vector<int> path(N - 1);
    bool can1, can2;
    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        path.at(i) = i + 2;
    }
    do {
        can1 = true;
        for (int i = 0; i < N - 1; i++) {
            can2 = false;
            int j;
            if (i == 0) {
                j = 1;
            }
            else {
                j = path.at(i - 1);
            }
            for (int k = 0; k < gragh.at(j - 1).size(); k++) {
                if (gragh.at(j - 1).at(k) == path.at(i)) {
                    can2 = true;
                }
            }
            if (!can2) {
                can1 = false;
            }
        }
        if (can1) {
            ans++;
        }
    } while (next_permutation(path.begin(), path.end()));

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
        import java.util.Arrays;
        import java.util.Collections;
        import java.util.Scanner;

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

        if (sockets == 1) {
            System.out.println(0);
            System.exit(0);
        }

        int socketNum = powerstrip;
        int counter = 1;
        while (socketNum < sockets) {
            socketNum += (powerstrip - 1);
            counter++;
        }

        System.out.println(counter);

    }
}

Measured memory_bytes: 22100
# -*- coding: utf-8 -*-
import sys

N,M=map(int, sys.stdin.readline().split())
S=sys.stdin.readline().strip()

L=[]    #答えの集合
for _ in range(N):
    for m in range(M,0,-1):
        if 0<=N-m and S[N-m]=="0":
            L.append(m)
            N-=m
            break
    else:
        break
        
if N!=0:
    print -1
else:
    print " ".join(map(str,L[::-1]))


Measured memory_bytes: 41372
use proconio::{fastout, input};
use std::cmp::min;

#[fastout]
fn main() {
    input! {in_n: usize, in_a: [u64; in_n + 1]};
    let mut leaves = vec![0 as u64; in_n + 1];
    let depth = in_n + 1;

    if in_a[0] == 1 && in_n == 0 {
        println!("1");
        return;
    }

    if in_a[0] != 0 {
        println!("-1");
        return;
    }

    for i in (1..depth).rev() {
        leaves[i - 1] = leaves[i] + in_a[i];
    }

    let mut node = 1;
    let mut total = 1;

    for i in 1..depth {
        let n = node * 2;

        if in_a[i] > n {
            println!("-1");
            return;
        }

        let r = min(n - in_a[i], leaves[i]);
        total += in_a[i] + r;
        node = r;
    }

    println!("{}", total);
}


Measured memory_bytes: 4368
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static string str1;
    static string str2;
    static void Main(string[] args)
    {
        str1 = ReadLine();
        str2 = ReadLine();
        var dp = new int[str1.Length + 1, str2.Length + 1];
        for (var i = 1; i <= str1.Length; i++)
            for (var j = 1; j <= str2.Length; j++)
                if (str1[i - 1] == str2[j - 1])
                    dp[i, j] = dp[i - 1, j - 1] + 1;
                else
                    dp[i, j] = Max(dp[i - 1, j], dp[i, j - 1]);
        WriteLine(Make(str1.Length, str2.Length, dp));
    }
    private static string Make(int m1,int m2,int[,] dp)
    {
        if (m1 <= 0 || m2 <= 0) return "";
        if (str1[m1-1] == str2[m2-1]) return Make(m1 - 1, m2 - 1, dp) + str1.Substring(m1-1, 1);
        else return (dp[m1 - 1, m2] >= dp[m1, m2 - 1]) ? Make(m1 - 1, m2, dp) : Make(m1, m2 - 1, dp);
    }
}


Measured memory_bytes: 48216
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

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

    ll cnt_a;
    if (a == 0LL) {
        cnt_a = 0;
    } else {
        cnt_a = (a - 1) / x + 1;
    }
    ll cnt_b = b / x + 1;

    cout << cnt_b - cnt_a << endl;

    return 0;
}

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

typedef long long ll;
const int maxn = 200010;
int n;
ll ans = 1e18, s[maxn], a[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]), s[i] = s[i - 1] + a[i];
    }
    int j = 1, k = 3;
    for (int i = 2; i < n; i++) {
        ll b = s[j], c = s[i] - s[j];
        ll d = s[k] - s[i], e = s[n] - s[k];
        auto chk = [&](ll x, ll y, int pos) {
            return abs((x + a[pos]) - (y - a[pos])) < abs(x - y);
        };
        while (j + 1 < i && chk(b, c, j + 1)) {
            j++, b = s[j], c = s[i] - s[j];
        }
        while (k + 1 < n && chk(d, e, k + 1)) {
            k++, d = s[k] - s[i], e = s[n] - s[k];
        }
        ans = min(ans, max({b, c, d, e}) - min({b, c, d, e}));
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;
const ll INF = 2e15 + 10;
const ll MAX = 1e14 + 10;
const ld EPS = 1e-9;
const int N = 21;
const int M = 1e5 + 10;

int a[N][N];
int d[(1 << N)][N + 1];

inline void add(int& x, int y) {
    x += y;
    if (x >= MOD)
        x -= MOD;
}

void solve() {
    int n;
    cin >> n;
    fr(i, n)
        fr(j, n)
            cin >> a[i][j];
    d[0][0] = 1;
    for (int mask = 0; mask < (1 << n); mask++) {
        int j = __builtin_popcount(mask);
        if (!d[mask][j]) continue;
        for (int i = 0; i < n; i++)
            if (!((1 << i) & mask) && a[j][i])
                add(d[(1 << i) | mask][j + 1], d[mask][j]);
    }

    cout << d[(1 << n) - 1][n];
}



int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    solve();
}


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

int main() {
  int N;
  cin >> N;
  
  int x = 0;  
  for(int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    x += r - l + 1;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    vector<ll> a(n), b(n), c(m), d(m);
    for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
    for (int i = 0; i < m; ++i) cin >> c[i] >> d[i];
    vector<int> res(n, -1);
    for (int i = 0; i < n; ++i)
    {
        ll dmin = 1 << 30;
        int ind = -1;
        for (int k = 0; k < m; ++k)
        {
            ll dis = abs(a[i] - c[k]) + abs(b[i] - d[k]);
            if (dmin > dis)
            {
                dmin = dis;
                ind = k + 1;
            }
        }
        res[i] = ind;
    }
    for (int i = 0; i < n; ++i)
    {
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)

flag = False
for i in range(N):
    if i%2 == 0:
        if S[i] == "L":
            flag = True
            break

    else:
        if S[i] == "R":
            flag = True
            break

if flag:
    print("No")

else:
    print("Yes")


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	long long int h;
	cin >> h;
	long long int ans = 0;
	long long int i = 1;
	while (h > 0)
	{
		ans += i;
		i *= 2;
		h /= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int x=scan.nextInt();
		System.out.println(x*x*x);

	}

}

Measured memory_bytes: 17396
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    L=[list(map(int,input().split())) for i in range(n)]
    
    L=sorted(L, key=lambda x: x[0])
    print(L[-1][0]+L[-1][1])


    
    
resolve()

Measured memory_bytes: 61148
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

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

    map<ll, int> prime_counter;
    for (int i = 2; i <=N; i++){
        vector<pair<ll,ll>> pfs = prime_factorize(i);
        for (auto pf : pfs) prime_counter[pf.first] += pf.second;
    }

    int prime_count = prime_counter.size();
    vector<vector<int>> dp(prime_count+1, vector<int>(76, 0));
    dp[0][1] = 1;

    int i = 0;
    for (auto pc : prime_counter){
        for (int j = 0; j <= 75; j++){
            for (int k = 1; k <= pc.second+1; k++){
                if (k*j <= 75) dp[i+1][k*j] += dp[i][j];
            }
        }
        i++;
    }

    cout << dp[prime_count][75] << endl;

}

Measured memory_bytes: 3652
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
string X = "";
string S[55];
ll arr[55];


int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		cin >> S[i];
		cin >> arr[i];
	}
	cin >> X;
	int ind = 0;
	for(int i = 0; i < N; i++) {
		if(S[i] == X) {
			ind = i;
		}
	}
	ll sum = 0;
	for(int i = ind + 1; i < N; i++) {
		sum += arr[i];
	}
	printf("%lld\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main()
{
    ll k;
    ll n;
    cin>>k>>n;
    vector<ll> data(n);
    rep(i, n)
    {
        ll a;
        cin >> a;
        data[i] = a;
    }
    priority_queue<ll> cost;
    rep(i, n - 1)
    {
        ll o = data[i + 1] - data[i];
        cost.push(o);
    }
    ll y=data[0]+k-data[n-1];
    cost.push(y);
    cout<<k-cost.top();
}


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

struct edge {int to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const int INf = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll

const int NMAX = 15;

int a[NMAX],b[NMAX];
bool even[NMAX]; //A[i]が偶数ならtrue;

int power(int x, int n){
    int tmp = 1;
  
    if(n>0){
      tmp = power(x, n/2);
      if(n%2==0) tmp = (tmp*tmp)%MOD;
      else tmp = (((tmp*tmp)%MOD)*x)%MOD;
    }
    return tmp;
}

signed main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]%2==0) even[i] = true;
    }

    int herasu=1;
    
    for(int i=0;i<n;i++){
        if(even[i]) herasu *= 2;
    }

    printf("%d\n",power(3,n)-herasu);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
bool is_integer(double x)
{
  return floor(x) == ceil(x);
}
int main()
{
  string s, t;
  cin >> s >> t;
  int min = t.length();
  int tmp;
  for (int i = 0; i < s.length() - t.length() + 1; i++)
  {
    tmp = 0;
    for (int j = 0; j < t.length(); j++)
    {
      if (s[i + j] != t[j])
      {
        tmp++;
      }
    }
    if (tmp < min)
    {
      min = tmp;
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 3604
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))

res = 0
for i, b in enumerate(b_list):
    res += min(a_list[i], b)
    res += min(a_list[i+1], b-min(a_list[i],b))
    a_list[i+1] -= min(b-min(a_list[i],b), a_list[i+1])
print(res)

Measured memory_bytes: 18624
import java.io.*;
import java.util.Scanner;

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

        String ln1 = scanner.nextLine();
        int w = Integer.parseInt(ln1);
        String ln2 = scanner.nextLine();
        int n = Integer.parseInt(ln2);
        int a,b,c;
        int x[] = new int[30];
        for(int i = 0;i < w; i++){
            x[i]= i+1;
        }
        for(int i= 0;i < n;i++){
            String ln3 = scanner.nextLine();
            String ln4[] = ln3.split(",",0);
            a = Integer.parseInt(ln4[0]);
            b = Integer.parseInt(ln4[1]);
            c = x[a-1];
            x[a-1] = x[b-1];
            x[b-1] = c;
        }
        for(int i = 0; i < w; i++){
            System.out.println(x[i]);
        }
        }
    }



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

int main () {
    int N, M;
    vector<string> blue(100), red(100);
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> blue.at(i);
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        cin >> red.at(i);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int count = 0;
        for (int j = 0; j < N; j++) {
            if (blue.at(j) == blue.at(i))  {
                count++;
            }
        }
        for (int j = 0; j < M; j++) {
            if (red.at(j) == blue.at(i)) {
                count--;
            }
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
   long long int n,k;
   cin>>n>>k;
   long long int a[n];
   for(long long int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   sort(a,a+n);
   long long int sum=0;
   for(long long int i=0;i<(n-k);i++)
   {
       sum=sum+a[i];
   }
   cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)


int32_t main() { 
    boost;
	int n,tmp;
	cin>>n;
	map<int,int>mp;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>tmp;
		if(mp.find(i-tmp)!=mp.end())
			ans+=mp[i-tmp];
		mp[i+tmp]++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 16072
n = int(input())
ans = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for _ in range(n):
    a = input()
    ans[a] += 1

print('AC x', ans['AC'])
print('WA x', ans['WA'])
print('TLE x', ans['TLE'])
print('RE x', ans['RE'])


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a != b && b != c && c != a) cout << 3 << endl;
    else if(a == b && b == c) cout << 1 << endl;
    else cout << 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int H = Integer.parseInt(S[0]);
    
    for(int i = 0; i < H; i++){
      String T = sc.nextLine();
      System.out.println(T);
      System.out.println(T);
    }
  }
}

Measured memory_bytes: 24788
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int MAXN = 3456;
const LL MOD = 998244353;
LL dp[MAXN][MAXN];
LL pw2[MAXN];

int main() {
    pw2[0] = pw2[1] = 1;
    for (int i = 2; i < MAXN; i++)
        pw2[i] = (pw2[i - 1] * 2) % MOD;
    int N, S;
    scanf("%d %d", &N, &S);
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        int tmp;
        scanf("%d", &tmp);
        for (int j = tmp; j <= S; j++)
            dp[i][j] = dp[i - 1][j - tmp];
        for (int j = 0; j <= S; j++)
            dp[i][j] = (dp[i][j] + 2 * dp[i - 1][j]) % MOD;
    }
    printf("%lld\n", dp[N][S]);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


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

using namespace std;

int main(){
    int a,b,c;
    int hasil1 = 0,hasil2= 0,hasil3 = 0, hasil=0;
    cin>>a>>b>>c;
    hasil1 = abs(c-a);
    hasil1+= abs(a-b);
    hasil2 = abs(a-b);
    hasil2+= abs(b-c);
    hasil3 = abs(b-c);
    hasil3+= abs(c-a);
    hasil = min(hasil1,hasil2);
    hasil = min(hasil,hasil3);
    cout<<hasil<<endl;


    return 0;
}


Measured memory_bytes: 256