akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll x=a[0],y=a[1];
    vector<ll> vx,vy;
    for(int i=1;i*i<=x;i++){
        if(x%i==0){
            vx.pb(i);
            vx.pb(x/i);
        }
    }
    for(int i=1;i*i<=y;i++){
        if(y%i==0){
            vy.pb(i);
            vy.pb(y/i);
        }
    }
    ll ans=0;
    bool maki;
    for(int i=0;i<vx.size();i++){
        if(vx[i]>ans){
            maki=false;
            for(int j=0;j<n;j++){
                if(a[j]%vx[i]){
                    if(maki){
                        break;
                    }
                    else{
                        maki=true;
                    }
                }
                if(j==n-1){
                    ans=vx[i];
                }
            }
        }
    }
    for(int i=0;i<vy.size();i++){
        if(vy[i]>ans){
            maki=false;
            for(int j=0;j<n;j++){
                if(a[j]%vy[i]){
                    if(maki){
                        j=n;
                    }
                    else{
                        maki=true;
                    }
                }
                if(j==n-1){
                    ans=vy[i];
                }
            }
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
 
int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a>=k){
     cout << k <<endl;
  }
  else if(a<k && b>k-a){
            cout << a <<endl;
  }
  else if(a<k && b<k-a){
        cout << a-(k-a-b) <<endl;
  }
  else{
        cout << a <<endl;
  }
}


Measured memory_bytes: 3556
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define ull unsigned long long
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int x1,x2, y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3,x4, y3,y4;
    int vec_x = y1 - y2;
    int vec_y = -(x1 - x2);
    x3 = x2 + vec_x;
    y3 = y2 + vec_y;
    x4 = x1 + vec_x;
    y4 = y1 + vec_y;
    printf("%d %d %d %d\n",x3, y3, x4, y4);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

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

	vector<long long> output;
	for(long long i = n -1; i >= 0; i-=2){
		output.push_back(a[i]);
	}
	long long sIdx = (n % 2);
	for(long long i = sIdx; i < n; i+=2){
		output.push_back(a[i]);
	}

	for(long long i = 0; i < n; i++){
		cout << output[i];
		if(i != n) cout << " ";
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 5488
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s = S()
k = I()
L = []
for i in range(len(s)):
    for j in range(i + 1, i + 1 + k):
        L.append(s[i:j])



L = sorted(list(set(L)))
print(L[k - 1])


Measured memory_bytes: 5968
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool neg=c=='-';
	neg?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return neg?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
template<class T>inline void mset(T a,int v,int n){memset(a,v,n*sizeof(a[0]));}
const int N=2000010;
inline void getnum(bool a[],int n){
	static char str[N];
	scanf("%s",str);
	for(int i=0;i<n;i++){
		a[n-i-1]=str[i]-'0';
	}
}
inline void putnum(bool a[],int n){
	bool fir=true;
	for(int i=n-1;i>=0;i--){
		if(a[i]||!fir){
			putchar('0'+a[i]);
			fir=false;
		}
	}
	if(fir){
		putchar('0');
	}
	putchar('\n');
}
bool a[N],b[N];
int main(){
	int n,k;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	{
		int tn=ni,tm=ni;
		n=max(tn,tm);
		k=ni;
		getnum(a,tn);
		getnum(b,tm);
	}
	for(int i=n-1;i>=0;i--){
		for(int j=i,tt=k;tt--&&a[j]&&b[j];){
			a[j]=b[j]=0;
			++j;
			assert(!a[j]||!b[j]);
			if(a[j]){
				b[j]=1;
				for(;a[j];j++){
					a[j]=0;
				}
				a[j]=1;
			}else if(b[j]){
				a[j]=1;
				for(;b[j];j++){
					b[j]=0;
				}
				b[j]=1;
			}else{
				a[j]=b[j]=1;
			}
		}
	}
	putnum(a,n+k);
	putnum(b,n+k);
	return 0;
}


Measured memory_bytes: 9088
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[]) throws IOException {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scan = new Scanner(System.in);
		StringBuilder b = new StringBuilder();


		
		int i,s;
		i = 0;

		while(true){
			i++;
			s = scan.nextInt();
			//s = Integer.parseInt(br.readLine());
			if(s == 0){break;}
			
			//str = str+ "Case " + Integer.toString(i) + ": " + str + "\n";
			
			b.append("Case ");
			b.append(Integer.toString(i));
			b.append(": ");
			b.append(Integer.toString(s));
			b.append("\n");
			
			
			
		}

		System.out.print(new String(b));

	}
}

Measured memory_bytes: 42604
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 400010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a;
    cin >> n;
    vector<ll> p(n+1);
    rep(i,n){
        cin >> a;
        p[a] = i;
    }
    set<ll> in,rin;
    in.insert(p[n]);
    rin.insert(-p[n]);
    rin.insert(1);
    in.insert(n);
    ll ans = 0;
    for (ll i = n-1; i >= 1; i--){
        ll l1,l2,r1,r2;
        r1 = *in.upper_bound(p[i]);
        r2 = *in.upper_bound(r1);
        l1 = -(*rin.upper_bound(-p[i]));
        l2 = -(*rin.upper_bound(-l1));
        if (r1 == n) r2 = n;
        if (l1 == -1) l2 = -1;
        //cout << l2 << " " << l1 << " " << p[i] << " " << r1 << " " << r2 << endl;
        ans += (abs(l1-l2)*abs(r1-p[i])+abs(r1-r2)*abs(l1-p[i]))*i;
        in.insert(p[i]);
        rin.insert(-p[i]);
    }
    PRINT(ans);
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n,a[3];
  cin >> n >> a[0] >> a[1] >> a[2];
  vector<string> s(n);
  vector<pair<int,int>> snum;
  rep(i,n){
    cin >> s[i];
    snum.pb({s[i][0]-'A',s[i][1]-'A'});
  }
  vector<char> ans;
  rep(i,n){
    int fir = snum[i].first;
    int sec = snum[i].second;
    if(a[fir]==0 && a[sec]==0){
      cout << "No" << endl;
      return 0;
    }
    else{
      if(a[fir]<a[sec]){
        a[fir]++;
        ans.pb((char)('A'+fir));
        a[sec]--;
      }
      else if(a[fir] > a[sec]){
        a[fir]--;
        a[sec]++;
        ans.pb((char)('A'+sec));
      }
      else{
        if(i==n-1) ans.pb((char)('A'+sec));
        else{
          int nfir = snum[i+1].first;
          int nsec = snum[i+1].second;
          if(nfir == fir || nsec == fir){
            a[fir]++;
            ans.pb((char)('A'+fir));
            a[sec]--;
          }
          else{
            a[fir]--;
            a[sec]++;
            ans.pb((char)('A'+sec));
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
  rep(i,n){
    cout << ans[i] << endl;
  }

  return 0;
    

}


Measured memory_bytes: 7356
/* This code is written by 18to_nhanh */
#define Tourist "169A"
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORs(i,a,b) for(int i=a;i<b;i++)
#define _FOR(i,a,b) for(int i=a;i>=b;i--)
#define _FORs(i,a,b) for(int i=a;i>b;i--)
using namespace std;
const int maxn = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int base = 31;
const int LOG = 20;
typedef pair<int,int> pi;
typedef pair<pi,pi> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
int a,b;
void init(){
//    freopen(Tourist".inp","r",stdin);
//    freopen(Tourist".out","w",stdout);
}
void Time_Decreasing(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}
void enter(){
    scanf("%d %d",&a,&b);
}
void solve(){
    printf("%d",a*b);
}
int main(){
    init();
    Time_Decreasing();
    enter();
    solve();
}



Measured memory_bytes: 3844
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int sx, sy;
	int tx, ty;
	int dx, dy;
	int i;
	char buf[128], *ch;
	void *fgets_return;

	fgets_return = fgets(buf, sizeof(buf), stdin);
	if(fgets_return == NULL) {printf("no input\n"); return 0;}
	ch = strtok(buf, " ");
	if(ch == NULL) {printf("too few input\n"); return 0;}
	sx = atoi(ch);
	ch = strtok(NULL, " ");
	if(ch == NULL) {printf("too few input\n"); return 0;}
	sy = atoi(ch);
	ch = strtok(NULL, " ");
	if(ch == NULL) {printf("too few input\n"); return 0;}
	tx = atoi(ch);
	ch = strtok(NULL, " ");
	if(ch == NULL) {printf("too few input\n"); return 0;}
	ty = atoi(ch);

	dx = tx - sx;
	dy = ty - sy;


	for(i = 0; i < dx; i += 1) {
		printf("R");
	}
	for(i = 0; i < dy + 1; i += 1) {
		printf("U");
	}
	for(i = 0; i < dx + 1; i += 1) {
		printf("L");
	}
	for(i = 0; i < dy + 1; i += 1) {
		printf("D");
	}
	printf("R");

	printf("D");
	for(i = 0; i < dx + 1; i += 1) {
		printf("R");
	}
	for(i = 0; i < dy + 1; i += 1) {
		printf("U");
	}
	for(i = 0; i < dx + 1; i += 1) {
		printf("L");
	}
	for(i = 0; i < dy; i += 1) {
		printf("D");
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 128
/**
 * Author: Ishaan Bajpai
**/
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("/Users/ishan/Desktop/fuzzy-chainsaw-algo/input.txt", "r", stdin);
    freopen("/Users/ishan/Desktop/fuzzy-chainsaw-algo/output.txt", "w", stdout);
#endif
}
const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================
ll int pow(ll int x, ll int n,ll int mod){
    if(n == 0){
        return  1;
    }
    ll int subprob = pow(x, n/2, mod)%mod;
    if(n&1){
        return (x * subprob * subprob)%mod;
    }
    return (subprob * subprob)%mod;
}
int f(vector<vector<ll int>>& arr, int n, int a, vector<vector<ll int>>& dp){
    //basecase 
    if(n == 0){
        return arr[n][a];
    }
    //recurseve
    //if a == 0
    if(dp[n][a] != -1){
        return dp[n][a];
    }
    if(a == 0){
        dp[n][a] = arr[n][a] + max(f(arr, n-1, 1,dp), f(arr, n-1, 2,dp));
    }
    if(a == 1) dp[n][a] = arr[n][a] + max(f(arr,n-1, 0,dp), f(arr, n-1, 2,dp));
    if(a == 2) dp[n][a] = arr[n][a] + max(f(arr,n-1,0,dp), f(arr,n-1,1,dp));
    return dp[n][a];
    
 }
void solve() {
    int n; cin>>n;
    vector<vector<ll int>> arr(n, vector<ll int>(3));
    vector<vector<ll int>> dp(n,vector<ll int>(3,-1));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            cin>>arr[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < 3; i++){
        ans =  max(ans, f(arr,n-1,i,dp));
    }
    cout<<ans<<endl;

}

int main() {
    c_p_c();
    int t = 1;
   // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}


Measured memory_bytes: 21920
N, K = map(int, input().split())
dislike = []
for i in range(0, 10):
	dislike.append(False)
D = list(map(int, input().split()))
for i in range(0, K):
	dislike[D[i]] = True
Y = N
while True:
	flag = True
	for i in range(0, len(str(Y))):
		if dislike[int(str(Y)[i])]:
			flag = False
			break
	if flag:
		print(Y)
		break
	Y += 1

Measured memory_bytes: 41180
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll i=1,ans = 0;
    while(i<n){
        ans++;
        while(i<n && s[i]==s[i-1]){
            i++;
        }
        i++;
    }
    if(n>=2 && s[n-1]==s[n-2]){
        cout<<ans;
    }
    else{
        cout<<ans+1;
    }
    //ans==1?cout<<ans:cout<<ans+1;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    string s; cin >> s;

    ll ans = 0, A = 0;
    int n = s.size();
    rep(i, n) {
        if (s[i] == 'A') A++;
        else if (i < n-1 && s[i] == 'B' && s[i+1] == 'C') continue;
        else if (i > 0 && s[i-1] == 'B' && s[i] == 'C') ans += A;
        else A = 0;
    }
    cout << ans << endl;
}


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

using namespace std;

vector<pair<int, int>> solve(int N){
    int ex = (N%2 ? N : N+1);
    vector<pair<int, int>> vp;
    for(int i=1;i<=N;i++){
        for(int j=i+1;j<=N;j++){
            if(i+j == ex) continue;
            vp.emplace_back(i, j);
        }
    }
    return vp;
}

int main(){
    int N;
    while(cin >> N){
        auto res = solve(N);
        cout << res.size() << endl;
        for(auto& e : res) cout << e.first << " " << e.second << endl;
    }
}

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

int main(){
    int a, b;
    string s;
    cin >> a >> b;
    cin >> s;
    bool flg=true;
    for(int i=0; i<(a+b+1); i++){
        if(i==a){
            if(s.at(i) == '-')
                flg = true;
            else{
                flg = false;  break;
            }
        }else{
            if(s.at(i)>='0' && s.at(i)<='9')
                flg = true;
            else{
                flg = false; break;
            }
        }
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] arr =sc.nextLine().split(" ");
		int n = Integer.parseInt(arr[0]);
		int k = Integer.parseInt(arr[1]);
		sc.close();

		double prob = 0.0;
		for(int i = 1; i <= n; i++) {
			if (i < k) {
				int winNum = (int) Math.ceil(Math.log((double)k/i) / Math.log(2));
				prob += Math.pow(0.5, winNum)/n;
			} else {
				prob += 1.0/n;
			}
		}
		System.out.println(prob);
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
  
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    lol n, m, sum = 0;
    cin >> n >> m;
    m /= 2;
    sum += min(n,m);
    m -= n;
    // cout << n << m;
    if( m >= 2 ){
      sum += m/2;
    }
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 256
bc = []
for i in range(3):
    bc.append(list(map(int, input().split())))

n = int(input())

lb = []
for i in range(n):
    lb.append(int(input()))


def check(a):
    for i in range(3):
        for j in range(3):
            if bc[i][j] == a:
                bc[i][j] = 0
                return


for k in range(len(lb)):
    check(lb[k])

ans = False

for i in range(3):
    if sum(bc[i]) == 0:
        ans = True
        break

    if bc[0][i] + bc[1][i] + bc[2][i] == 0:
        ans = True
        break


if bc[0][0] + bc[1][1] + bc[2][2] == 0:
    ans = True

if bc[2][0] + bc[1][1] + bc[0][2] == 0:
    ans = True

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 998244353
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if(!(n >= b + a - 1 && n <= a * b)) {
		cout << -1;
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		int cnt = 0;
		vector <int> t;
		while(n - i >= a - 1 && cnt < b) {
			t.push_back(i);
			i++;
			cnt++;
		}
		i--;
		reverse(all(t));
		for (auto g : t)
			cout << g << " ";
		a--;
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<string> vec(n);
  for(int i=0; i<n; i++){
    string x;
    cin >> x;
    vec.at(i)=x;
  }
  sort(vec.begin(),vec.end());
  int ans=0;
  for(int i=0; i<n; i++){
    if(i==0){
      ans++;
    }
    else{
      if(vec.at(i)!=vec.at(i-1)){
      ans++;
      }
    }
  }
  cout << ans << endl;
 

}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

ll dx[2] = {-1, 1};
ll dy[2] = {-1, 1};

int main(){

    ll H, W;
    cin >> H >> W;

    vector<vector<char > > masu(H, vector<char >(W, 0));

    for(ll row = 0; row < H; row++){
        for(ll col = 0; col < W; col++){
            cin >> masu[row][col];
        }
    }

    for(ll row = 0; row < H; row++){
        for(ll col = 0; col < W; col++){
            if(masu[row][col] != '#') continue;
            bool f = false;
            for(ll i = 0; i < 2; i++){
                if(col + dx[i] < W && col + dx[i] >= 0 ){
                    if(masu[row][col + dx[i]] == '#'){
                        f = true;
                    }
                }
            }

            bool f2 = false;
            for(ll i = 0; i < 2; i++){
                if(row + dy[i] < H && row + dy[i] >= 0 ){
                    if(masu[row + dy[i]][col] == '#'){
                        f2 = true;
                    }
                }
            }

            if(f == false && f2 == false){
                cout << "No" << endl;
                return 0;
            }

        }
    }

    cout << "Yes" << endl;


}

Measured memory_bytes: 256
n=(int)(input())
a=input().split()
for i in range(n):
  a[i]=(int)(a[i])
  
dic={}
sum=0
for i in range(n):
  if not a[i] in dic:
    dic[a[i]]=1
  else:
    dic[a[i]]+=1
    sum+=dic[a[i]]-1

for i in a:
  print(sum-dic[i]+1)



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

using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;

  string k = "MARCH";
  ll cnt[5];
  memset(cnt, 0, sizeof(cnt));

  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    for (int i = 0; i < 5; i++) {
      if (s[0] == k[i]) {
        cnt[i]++;
      }
    }
  }

  ll sum = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        sum += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
    string s;
    cin >> s;   // topping
    const int ramen = 700;

    int price = ramen;

    if (s[0] == 'o') price += 100;
    if (s[1] == 'o') price += 100;
    if (s[2] == 'o') price += 100;

    cout << price;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000000
using namespace std;
ll i,j;
ll primes[MAX];

void isPrime(){
primes[0]=primes[1]=1;

  for(i=2;i<MAX;i++){
  	if(primes[i]==0){
  		for( j=i*i;j<MAX;j+=i){
  			primes[j]=1;
  		}
  	}
  }

  }

  int main(){
  	isPrime();
     int t;
  	cin>>t;
   while(1){
     if(primes[t]==0){
         cout<<t<<endl;
         break;
     }
     else t++;
   }
   return 0;
  }


Measured memory_bytes: 8064
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int N, A, B,sa;
	cin >> N >> A >> B;
	sa = B - A - 1;
	sa = sa % 2;
	if (sa == 0)
		cout << "Borys" << endl;
	else
		cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
count = 0
for i in range(n):
    for j in range(i+1, n):
        t = l[i] + l[j]
        idx = bisect.bisect_left(l, t)
        count += max(0, idx- (j+1))
print(count)

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

int main(){
 string s,t;
  cin >> s >> t;
  int a=s.size();
  int ans=0;
  
  for(int i=0;i<a;i++){
    if(s[i]!=t[i]) ans++;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3916
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

int main() {
	int n, m, x, k;
	int i, j;
	cin>>n>>m>>x;
	
	int a[n][m];
	int c[n];
	for(i=0;i<n;i++) {
		for(j=0;j<=m;j++) {
			if(j == 0) cin>>c[i];
			else cin>>a[i][j-1];
		}
	}
	
	int mini_cost = INT_MAX;
	for(i=0;i<(1<<n);i++) {
		vector<int> b;
		for(j=0;j<n;j++) {
			if(i&(1<<j)) b.PB(j);
		}
		
		//compute all algo value
		int algo[m];
		MSV(algo, 0);
		int cost = 0;
		for(j=0;j<b.size();j++) {
			int book = b[j];
			cost += c[book];
			for(k=0;k<m;k++) {
				algo[k] += a[book][k];
			} 
		}
		
		bool possible = true;
		for(j=0;j<m;j++) {
			if(algo[j] < x) {possible = false;break;}
		}
		if(possible) mini_cost = min(mini_cost, cost);
	}
	
	if(mini_cost == INT_MAX) mini_cost = -1;
	cout<<mini_cost<<endl;
    return 0;
}



Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N;

	cin >> N;
	
	cout << "Christmas";
	
	for(int i = 0; i < 25 - N; i++){
		cout << " Eve";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
#include <queue>
#include <type_traits>
#include<cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
    unsigned long long MOD =1000000007;
    unsigned long long N,M;
    cin >> N >> M;
    vector<unsigned long long> vec(M+2,0);
    for(int i=0;i<M;i++){
        unsigned long long x;
        cin >> x;
        vec[i]=x;
    }
    vector<unsigned long long> kaidan(N+2,0);
    int j=0;
    kaidan[0]=1;
    if(vec[0]==1){
        kaidan[1]=0;
        j++;
    }else{
        kaidan[1]=1;
    }
    for(unsigned long long i=2;i<N+1;i++){
        if(vec[j]==i){
            if(j==M-1){
                kaidan[i]=0;
                continue;
            }else{
            j++;
            kaidan[i]=0;
            continue;
            }
        }else{
            kaidan[i]=(kaidan[i-1]%MOD + kaidan[i-2] % MOD) % MOD;
        }
    }
    cout << kaidan[N] % MOD<< endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, q;
    cin >> n >> q;
    
    vector<tuple<ll, ll, ll>> p(n);
    rep(i, n) {
        ll s, t, x;
        cin >> s >> t >> x;
        s -= x;  t -= x;
        p[i] = tie(x, s, t);
    }
    sort(all(p));
    
    set<P> st;
    rep(i, q) {
        ll d;
        cin >> d;
        st.insert(make_pair(d, i));
    }
    
    vl ans(q, -1);
    rep(i, n) {
        ll x = get<0>(p[i]);
        ll L = get<1>(p[i]);
        ll R = get<2>(p[i]);
        auto it = st.lower_bound(make_pair(L, -1));
        while(it != st.end()) {
            auto y = *it;
            if(y.first >= R) {
                break;
            }
            ans[y.second] = x;
            st.erase(it++);
        }
    }
    
    rep(i, q) {
        out(ans[i]);
    }
    
    re0;
}

Measured memory_bytes: 20608
n = int(input())
c = [int(input()) for _ in range(n)]
v_c = []
MOD = 10**9+7

for i,v in enumerate(c):
    if i > 0 and v == c[i-1]:
        continue
    v_c.append(v)

dp = [1]*(n+1)
color_cnt = [-1]*(2*10**5+5)
for i in range(1, len(v_c)+1):
    color = v_c[i-1]
    if color_cnt[color] > 0:
        dp[i] = dp[i-1] + dp[color_cnt[color]]
    else:
        dp[i] = dp[i-1]
    dp[i] %= MOD
    color_cnt[color] = i
print(dp[len(v_c)])


Measured memory_bytes: 22104
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(x == 0) {
      System.out.println("1");
    }else if(x == 1) {
      System.out.println("0");
    }
  }
}


Measured memory_bytes: 35628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    print(N-K+1);
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N,H[100001];
    int i,j;
    int max=0,cnt=0;

    scanf("%d",&N);
    for(i = 1 ; i <= N ; i++){
        scanf("%d",&H[i]);
    }
    for(i = 1 ; i <= N-1 ; i++){
        if(H[i] >= H[i+1]){
            cnt++;
            if(max < cnt){
                max = cnt;
            }
        }else{
            cnt = 0;
        }
    }
    printf("%d",max);
    return 0;
}

Measured memory_bytes: 512
b=list(map(int,input().split()))
c = int(input())
ans = 0
r = min([b[0]*4, b[1]*2, b[2]])
r2 = min([r*2, b[3]])
#if c % 2 == 1:
#    ans += r
#   c -= 1
#ans += r2 * (c / 2)
#print(int(ans))

if c%2==1:
	print(((c-1)//2)*r2+r)
else :
	print((c//2)*r2)


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    set<int> st;
    int i = 1;
    while(true){
        if(a*i % b == c){
            cout << "YES" << endl;
            return 0;
        }else if(st.count(a*i % b))break;
        st.insert(a*i % b);
        i++;
    }

    cout << "NO" << endl;

    return 0;
}


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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

pair<int, int> v[1005];
int n, h;
ll dp[1005][40005];

ll solve(int obj, int vida){
    if(dp[obj][vida]!=-1){
        return dp[obj][vida];
    }
    if(obj>n && vida>10000){
        return dp[obj][vida]=INF;
    }
    if(obj>n || vida<=10000){
        return dp[obj][vida]=0;
    }
    ll pega, nao;
    nao=solve(obj+1, vida);
    if(vida>=v[obj].f){
        pega=solve(obj, vida-v[obj].f)+v[obj].s;
        return dp[obj][vida]=min(pega, nao);
    }
    return dp[obj][vida]=nao;
}

int main(){
    fastio;
    memset(dp, -1, sizeof(dp));
    cin >> h >> n;
    for(int i=1; i<=n; i++){
        cin >> v[i].f >> v[i].s;
    }
    cout << solve(1, 10000+h) << endl;
    return 0;
}

Measured memory_bytes: 314880
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 111
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,x[N],mn,mx,ans;
int main(){
	ans=mn=0x3f3f3f3f;
	n=read();
	for(int i=1;i<=n;i++){
		x[i]=read();
		mn=min(mn,x[i]),mx=max(mx,x[i]);
	}
	for(int i=mn;i<=mx;i++){
		int tot=0;
		for(int j=1;j<=n;j++){
			tot+=(x[j]-i)*(x[j]-i);
		}
		ans=min(ans,tot);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import math

n = math.factorial(int(input()))
i = 2
f = defaultdict(int)
a = 1
while i ** 2 <= n:
    while n%i==0:
        n //= i
        f[i] += 1
    i += 1
if n > 1:
    f[n] += 1
for n,m in f.items():
    a = (a*(m+1)) % (10**9+7)
print(a)

Measured memory_bytes: 39152
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
sa = [0]*N
max_ = 0
for i in range(N):
    sa[i] = V[i] - C[i]
    if sa[i] > 0:
        max_ += sa[i]
print(max_)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int n;
	int i, j=0;
	int a[100]={};
	while(scanf("%d", &n)!=EOF){
		for(i=0;i<600;i+=n){
			a[j]+=(i)*(i)*n;
		}
		j++;
	}
	for(i=0;i<j;i++){
		printf("%d\n", a[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇
    let s = io.read::<String>();
    println!("{}", &s[0..3]);
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 2100
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H,W=MAP()
S=''
for i in range(H):
    S+=input()

# 各文字を4つ組と余りにまとめる
C=Counter(S)
cnt=Counter()
for v in C.values():
    cnt[v%4]+=1
# 3つ組は1と2に割り振る
cnt[1]+=cnt[3]
cnt[2]+=cnt[3]
cnt[3]=0

# 縦横とも偶数
if H%2==0 and W%2==0:
    # 全て4つ組
    if cnt[1]==0 and cnt[2]==0:
        Yes()
    else:
        No()

# 縦偶数
elif H%2==0:
    # 2つ組がH/2以下で残りが4つ組
    if cnt[2]<=H//2 and cnt[1]==0:
        Yes()
    else:
        No()

# 横偶数
elif W%2==0:
    # 2つ組がW/2以下で残りが4つ組
    if cnt[2]<=W//2 and cnt[1]==0:
        Yes()
    else:
        No()

# 両方奇数
else:
    # 1つ組1つ、2つ組が(H+W)/2-1以下で残りが4つ組
    if cnt[1]==1 and cnt[2]<=(H+W)//2-1:
        Yes()
    else:
        No()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{
    int a,b,c;cin>>a>>b>>c;c--;
    cout<<c/max(a,b)+1<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

int main(){
  map<ll,ll> m;
  ll asum = 0;
  
  ll n;cin >> n;
  
  rep(i,n) {
    ll a;cin >> a;
    m[a] += 1;
    asum += a;
  }

  ll q;cin >> q;
  rep(i,q){
    ll b,c;cin >> b >> c;
    asum = asum - (m[b] * b) + (m[b] * c);
    m[c] += m[b]; m[b] = 0;
    cout << asum << endl;
  }
  return 0;
}

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

int f(int a,int b){return max(log10(a),log10(b)) + 1;}

int main() {
    long long N;
    cin >> N;
    for(int i=sqrt(N);i>=0;i--){
        if(N%i == 0){
            cout << f(i,N/i);
            break;
        }
    }

    return 0;
} 

Measured memory_bytes: 384
#include<iostream>

using namespace std;

void solve1() {
	int K, N,X,Y;
	cin >> N >> K >> X >> Y;
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (i < K) {
			ans += X;
		}
		else
			ans += Y;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int a,b;
	for(;cin>>a>>b;){
		cout<<a+b<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <set>
#include <limits.h>

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define MOD 1000000007

using ll = long long;

using namespace std;

ll pow_mod(ll a, ll b, ll p) {
	if (b == 0)return 1;
	else if (b % 2 == 0)return (pow_mod(a*a, b / 2, p) % p);
	else return (pow_mod(a, b - 1, p)*a%p);
}

ll sum_digit(ll N) {
	int ans = 0;
	for (; N != 0;) {
		ans += N % 10;
		N /= 10;
	}
	return ans;
}

ll gcd(ll a,ll b) {
	if (!b)return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int A, B, K;

ll ans;

int main(){
	scanf("%d %d %d", &A, &B, &K);
	if (B - A < 2 * K) {
		for (int i = A; i < B + 1; i++)printf("%d\n", i);
	}
	else {
		for (int i = A; i < A + K; i++)printf("%d\n", i);
		for (int i = B + 1 - K; i < B + 1; i++)printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
struct Point{
  long x;
  long y;
  long h;
};
long distance(int x1,int y1,int x2,int y2){
  return abs(x1-x2) + abs(y1-y2);
}
int main(){
  long n;
  vector<Point> pnt;
  cin >> n;
  pnt.resize(n);
  long ii,xx,yy;

  for(ii=0;ii<n;ii++){
	cin  >> pnt[ii].x >> pnt[ii].y >> pnt[ii].h;
  }
  
  Point first= pnt[0];
  long dist,height,tmpHeight;

  for(xx=0;xx<=100;xx++){
	for(yy=0;yy<=100;yy++){

	  for(ii=0;ii<n;ii++){
		dist = distance(xx,yy,pnt[ii].x,pnt[ii].y);
		if(pnt[ii].h != 0){
		  height = pnt[ii].h + dist;
		  break;
		}
	  }
	  //cout << height << endl;
	  //
	  bool flg = true;
	  for(ii=0;ii<n;ii++){
		dist = distance(xx,yy,pnt[ii].x,pnt[ii].y);
		tmpHeight = max(height-dist,0L);
		//cout << "tmpHeight:" << tmpHeight << endl;
		if (pnt[ii].h == tmpHeight)
		  {
		  
		  }		
		else{
		  flg = false;
		  break;
		}
	  }
	  
	  if(flg){
		goto res;
	  }
	  
	}
  }
 res:
  //cout << "xx:" << xx << "yy:" << yy;
  cout << xx << " " << yy <<" " << height ;
  
  return 0;
}


Measured memory_bytes: 256
import itertools

N, M, Q = map(int, input().split())
A = [list(map(int, input().split())) for i in range(Q)]
matrix = list(itertools.combinations_with_replacement([i for i in range(M)], N))
ans = [0 for i in range(len(matrix))]

for i in range(len(matrix)):
  for j in range(Q):
    if matrix[i][A[j][1]-1] - matrix[i][A[j][0]-1] == A[j][2]:
      ans[i] += A[j][3]
  

print(max(ans))
         
  

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

#define ll long long

int main(){

    int N;
    int i,j,k;
    ll int count=2,count_next=1;
    ll int ans = 0;

    cin >> N;

    if(N==1){
        cout << "1" << endl;
        return 0;
    }

    for(i=1;i<N;i++){
        ans = count + count_next;
        count = count_next;
        count_next = ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np

n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353

dp = np.zeros(s + 1, np.int64)
dp[0] = 1

for e in a:
    pre = dp.copy()
    dp = pre * 2
    dp[e:] += pre[:-e]
    dp %= mod

ans = dp[s]
print(ans)


Measured memory_bytes: 27404
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N, x;
	cin >> N >> x;
	
	if (N == 2) {
		if (x == 2) {
			puts("Yes");
			puts(1); puts(2); puts(3);
		}
		else puts("No");
	}
	else if (x == 1 || x == 2 * N - 1)puts("No");
	else {
		puts("Yes");
		set<int>st;
		for (int i = 1; i <= 2 * N - 1; i++)st.insert(i);
		if (x == 2) {
			st.erase(1); st.erase(3); st.erase(x); st.erase(2*N-1);
			for (int i = 0; i < 2 * N - 1; i++) {
				if (i == N - 3)puts(3);
				else if (i == N - 2) puts(1);
				else if (i == N - 1)puts(x);
				else if (i == N)puts(2 * N - 1);
				else { puts(*st.begin()); st.erase(*st.begin()); }
			}
		}
		else {
			st.erase(1); st.erase(x-1); st.erase(x); st.erase(2 * N - 1);
			for (int i = 0; i < 2 * N - 1; i++) {
				if (i == N - 2) puts(1);
				else if (i == N - 1)puts(x);
				else if (i == N)puts(2 * N - 1);
				else if(i == N + 1)puts(x-1);
				else { puts(*st.begin()); st.erase(*st.begin()); }
			}
		}
	}

	return 0;
}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int in[5], n;
    REP(i,0,4) scanf("%d",&in[i]);
    sort(in, in+5);
    scanf("%d",&n);
    puts(in[4]-in[0] <= n ? "Yay!" : ":(");
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int sum = 0;
    for(int i=0; i<4; i++){
        int a;
        cin >> a; 
        sum += a;
    }
    cout << sum/60 << enld;
    cout << sum%60 << enld;
    return 0;
}


Measured memory_bytes: 3152