akhauriyash/Code-Regression huggingface dataset:
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
//typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//define
#define i(X) cin>>X;
#define ol(X) cout<<X<<endl;
#define os(X) cout<<X<<" ";
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define line cout<<"\n";
#define pbp(a,b) push_back(make_pair(a,b));
#define vll(A) vector<long lonh> A;
#define ivt(A,n,p) vector<long long> A(n,p);
#define vst(A) sort(A.begin(),A.end());
#define rvst(A) sort(A.rbegin(),A.rend());
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair

const long long inf=(long long)1e18;
const long long mod=(long long)(1e9+7);

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1; 
    x = x % p;  
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll a,ll p)
{
   return power(a,p-2,p);
}

int main()
{
    // #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
    fio;
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        ll n;
        i(n);
        string s="";
        while(n>0)
        {
            s+=char(((n-1)%26)+97);
            n--;
            n/=26;
        }
        forde(i,s.length()-1,0)
        cout<<s[i];
        line;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

ll solve() {
    int D, N;
    cin >> D >> N;
    ll ans = N;
    if (N == 100) ans = 101;
    REP(i, D) {
        ans*=100;
    }
    return ans;
}

int main() {
    cout << solve() << endl;
#ifdef DEBUG
    while (1) {
        cout << solve() << endl;
    }
#endif
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
	int n,a,b,c,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&a,&b,&c);
		if(sqrt(a*a+b*b)==c||sqrt(a*a+c*c)==b||sqrt(c*c+b*b)==a){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

double crp(double x1, double y1, double x2, double y2) {
	return x1 * y2 - y1 * x2;
}

double vabs(double x, double y) {
	return sqrt(x * x + y * y);
}

int main() {
	for(double x1, y1, x2, y2, x3, y3, xp, yp; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;) {
		x1 -= xp;
		x2 -= xp;
		x3 -= xp;

		y1 -= yp;
		y2 -= yp;
		y3 -= yp;

		double v1 = vabs(x1, y1);
		double v2 = vabs(x2, y2);
		double v3 = vabs(x3, y3);

		double rad_a = crp(x1, y1, x2, y2) / (v1 * v2);
		double rad_b = crp(x2, y2, x3, y3) / (v2 * v3);
		double rad_c = crp(x3, y3, x1, y1) / (v3 * v1);

		if((rad_a > 0.0 && rad_b > 0.0 && rad_c > 0.0) || (rad_a < 0.0 && rad_b < 0.0 && rad_c < 0.0)) puts("YES");
		else puts("NO");
	}
	return 0;
}

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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++)cin>>a[i];
  ll b[n+1];
  b[0]=0;
  for(i=0;i<n;i++)b[i+1]=b[i]+a[i];
  sort(b,b+n+1);
  ll c[n+1];
  for(i=0;i<=n;i++)c[i]=1;
  for(i=1;i<=n;i++){
    if(b[i]==b[i-1]){
      c[cnt]++;
    }else cnt++;
  }
  ll sum=0;
  for(i=0;i<=cnt;i++){
    sum+=c[i]*(c[i]-1)/2;
  }
  cout<<sum;
}

Measured memory_bytes: 4992
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define __ %=Mod
using namespace std;

const int maxn = 110000;

int n,m,q;
int s1[maxn][2],s2[maxn][2];
char str[maxn];

int main()
{
	scanf("%s",str); n=strlen(str);
	for(int i=1;i<=n;i++)
	{
		s1[i][0]=s1[i-1][0],s1[i][1]=s1[i-1][1];
		s1[i][str[i-1]-'A']++;
	}
	scanf("%s",str); m=strlen(str);
	for(int i=1;i<=m;i++)
	{
		s2[i][0]=s2[i-1][0],s2[i][1]=s2[i-1][1];
		s2[i][str[i-1]-'A']++;
	}
	
	scanf("%d",&q);
	while(q--)
	{
		int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d);
		int k1=(s1[b][0]-s1[a-1][0])-(s1[b][1]-s1[a-1][1]);
		int k2=(s2[d][0]-s2[c-1][0])-(s2[d][1]-s2[c-1][1]);
		puts((k1-k2)%3==0?"YES":"NO");
	}
	
	return 0;
}


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

#define forsn(i,s,n) for(tint i=(s);i<(tint)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define dforn(i,n) for(tint i = tint(n)-1; i >= 0; i--)
#define debug(x) cout << #x << " = "  << x << endl

using namespace std;

typedef int tint;

random_device rd;
mt19937 gen(rd());

uniform_int_distribution<tint> dis(1, 10000);

void imprimirVector (vector<tint> v)
{
	if (!v.empty())
	{ 
		tint p = tint(v.size());
		cout << "[";
		forn(i,p-1)
			cout << v[i] << ",";
		cout << v[p-1] << "]" << endl;
	}
	else
		cout << "[]" << endl;
}

const tint MAXN = 101;
const tint INFINITO = MAXN*MAXN*MAXN;
tint dp[MAXN][MAXN][2*MAXN];
tint layout[MAXN][MAXN];
tint h,w;

tint best (tint i, tint j, tint k)
{
	if ((i == -1 && j == 0) || (i == 0 && j == -1))
		return 0;
	if (dp[i][j][k] == INFINITO)
	{
		if (layout[i][j] == (k&1))
		{
			if ((i > 0) || (i == 0 && j == 0))
				dp[i][j][k] = min(dp[i][j][k], best(i-1,j,k));
			if ((j > 0) || (i == 0 && j == 0))
				dp[i][j][k] = min(dp[i][j][k], best(i,j-1,k));
		}
		if (k < 2*MAXN-1)
			dp[i][j][k] = min(dp[i][j][k],best(i,j,k+1)+(1-(k&1)));
	}
	return dp[i][j][k];
}

int main()
{
	#ifdef ACMTUYO
		assert(freopen("entrada.in", "r", stdin));
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	while (cin >> h >> w)
	{
		forn(i,h+1)
		forn(j,w+1)
		{
			layout[i][j] = 0;
			forn(k,2*MAXN)
				dp[i][j][k] = INFINITO;
		}
		forn(k,2*MAXN)
		{
			dp[0][1][k] = 0;
			dp[1][0][k] = 0;
		}
		forn(i,h)
		forn(j,w)
		{
			char c;
			cin >> c;
			if (c == '#')
				layout[i+1][j+1] = 1;	
		}
		
		forsn(k,1,2*MAXN)
		forsn(i,1,h+1)
		forsn(j,1,w+1)
		{
			if (layout[i][j] == (k&1))
				dp[i][j][k] = min(dp[i][j-1][k], dp[i-1][j][k]);
			if (k > 0)
				dp[i][j][k] = min(dp[i][j][k],dp[i][j][k-1]+(1-(k&1)));
		}
		
		
		
		int mini = INFINITO;
		forn(k,2*MAXN)
			mini = min(mini,dp[h][w][k]+layout[h][w]);
		
		cout << mini << "\n";
	}
	
	
	return 0;
}






Measured memory_bytes: 8320
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;

int32_t main(){
    vaibhavv06;
    
	int a,b; cin>>a>>b;
	cout<<(a*b)/(__gcd(a,b))<<endl;
}


Measured memory_bytes: 256
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x2 x123456789
#define y2 y123456789

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=1e5+5;

int n,k;
int a[maxn],l[maxn],r[maxn],par[maxn];
int parity[maxn][2];
vector<int> ord;
vector<int> g[maxn];

void dfs(int u,int p){
	l[u]=-INF,r[u]=INF;
	FOR(i,0,g[u].size()){
		int v=g[u][i];
		if(v==p) continue;
		dfs(v,u);
		par[v]=u;
		if(parity[v][0]) parity[u][1]=1;
		if(parity[v][1]) parity[u][0]=1;
		l[u]=max(l[u],l[v]-1);
		r[u]=min(r[u],r[v]+1);
	}
	if(a[u]!=-1){
		l[u]=max(l[u],a[u]);
		r[u]=min(r[u],a[u]);
		parity[u][a[u]&1]=1;
	}
	if(parity[u][0]&&parity[u][1]){
		puts("No");
		exit(0);
	}
	if(l[u]>r[u]){
		puts("No");
		exit(0);
	}
	ord.PB(u);
	return;
}

void solve(int u){
	if(!par[u]){
		a[u]=l[u];
		return;
	}
	l[u]=max(l[u],a[par[u]]-1);
	r[u]=min(r[u],a[par[u]]+1);
	while((l[u]&1)==(a[par[u]]&1)) ++l[u];
	a[u]=l[u];
	return;
}

int main(){
	scanf("%d",&n);
	FOR(i,0,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].PB(v);
		g[v].PB(u);
	}
	scanf("%d",&k);
	memset(a,-1,sizeof(a));
	FOR(i,0,k){
		int v,p;
		scanf("%d%d",&v,&p);
		a[v]=p;
	}
	dfs(1,0);
	puts("Yes");
	reverse(ord.begin(),ord.end());
	FOR(i,0,n) solve(ord[i]);
	REP(i,1,n) printf("%d\n",a[i]);
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int t[n];
    rep(i, n) cin >> t[i];
    int m;
    cin >> m;
    int p[m];
    int x[m];
    rep(i, m) cin >> p[i] >> x[i];

    int cnt = 0;
    while(cnt < m) {
        int sum = 0;

      	int tmp = t[p[cnt]-1];
        t[p[cnt]-1] = x[cnt];
      
      	//rep(i, n) cout << t[i] << ' ';
      	//cout << endl;

        rep(i, n) sum += t[i];        

        cout << sum << endl;
      
      	t[p[cnt]-1] = tmp;
      
      	cnt++;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll N;
    cin >> N;
    vector<ll> H(N);
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }
    bool ans = 1;
    ll a = -1;
    for(int i = 0; i < N; i++){
        if(a <= H[i] - 1){
            a = H[i] - 1;
        }
        else if(a <= H[i]){
            a = H[i];
        }
        else{
            ans = 0;
            break;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int k;
  scanf("%d", &k);
  if(k % 2 == 0) printf("%d\n", (k / 2) * (k / 2));
  else printf("%d\n", (k / 2) * ((k + 1) / 2));
  return 0;
}

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

bool kaibun(string s) {
  int n = s.size();
  bool ans = true;
  for (int i = 0; i < n; ++i) {
    if (s[i] != s[n - i - 1]) {
      ans = false;
    }
  }
  return ans;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  string s1 = s.substr(0, (n - 1) / 2);
  string s2 = s.substr(n - (n - 1) / 2);
  bool ans = kaibun(s) && kaibun(s1) && kaibun(s2);
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
n = int(input())
s = list(input())

if n%2 == 1:
    print('No')
else:
    ans = 'Yes'
    s1 = s[0:int(n/2)]
    s2 = s[int(n/2):n]
    for i in range(int(n/2)):
        if s1[i] != s2[i]:
            ans  = 'No'
    print(ans)

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

int main(){
  int s;
  cin>>s;
  int h=s/3600;
  int m=(s-h*3600)/60;
  s=s-3600*h-m*60;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}


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

char prime[1300000];

int main(void) {
    memset(prime, 1, sizeof(prime));

    prime[0] = prime[1] = 0;
    for(int i=0; i<1300000; i++) {
        if(!prime[i]) continue;
        for(int j=2; i*j<1300000; j++) {
            prime[i*j] = 0;
        }
    }

    while(true) {
        int n,lb,ub;
        scanf("%d", &n);
        if(!n) break;

        lb = ub = n;
        while(!prime[ub++]);
        while(!prime[lb--]);
        printf("%d\n",ub-lb-2);
    }
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n - 1);
	REP(i, n - 1)cin >> v[i];
	int ans = 0;
	ans += v.back();
	ans += v.front();
	RREP(i, n - 2) {
		ans += min(v[i + 1], v[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b,c,d,x,y,z;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if (a>=b)
	{
		x=b;
	}else if (a<b)
	{
		x=a;
	}
	if (c>=d)
	{
		y=d;
	}else if (c<d)
	{
		y=c;
	}
	z=x+y;
	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int ans=0;
	string s;
	getline(cin,s);
	for(int i=0;i<s.size()-1;i++){
		if(s[i]!=s[i+1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;cin >> n;
  vector<int> hoge(n);
  rep_i(i, n){
    cin >> hoge[i];
  }

  int max = hoge[0];
  int count = 0;
  rep_i(i, n){
    if(hoge[i] >= max){
      count += 1;
      max = hoge[i];
    }
  }
  say(count);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0


int main(){
  int n;
  scanf("%d",&n);
  int i,a[n+1];
  for(i=0;i<n;i++)
  scanf("%d",&a[i+1]);
  int count=0;
  for(i=1;i<=n;i++)
  if(a[a[i]]==i)count++;

  printf("%d",count/2);
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 512
n, m = gets.strip.split.map(&:to_i)
ary = gets.strip.split.map(&:to_i).sort.reverse
ans = "Yes"
ary[0..(m-1)].each do |i|
  if i < ary.inject(&:+)/(4*m).to_f
    ans = "No"
  end
end
puts ans

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

using namespace std;

int main()
{
    int i = 1;
    while(1)
    {
        int a;
        cin >> a;
        
        if(a == 0)
        { break; }
        
        cout << "Case " << i << ": " << a << endl;
    ++i;
    }

    return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int H, W;
	char s[60][60] = { '.' };
	cin >> H >> W;
	bool ans = true;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++)cin >> s[i][j];
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') {
				if (s[i + 1][j] == '.'&&s[i][j + 1] == '.'&&s[i - 1][j] == '.'&&s[i][j - 1] == '.')ans = false;
			}
		}
	}
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
ll a[200005],b[200005];

int main() {
	ll n,k,cnt=0,ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		int z=0;
		cin>>z;
		a[z]++;
		if(a[z]==1){
			cnt++;
		}
	}
	for(int i=0;i<200005;i++){
		b[a[i]]++;
	}
	int j=1;
	while(cnt-k>0){
		while(b[j]!=0){
			cnt--;
			ans+=j;
			b[j]--;
			if(cnt-k<=0){
				break;
			}
		}
		j++;
	}
	cout << ans;
}

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

int main(){
  int x;
  cin >> x;
  if( x < 1200 ){
    cout << "ABC" << endl;
  }else{
    cout << "ARC" << endl;
  }
  return 0;
}

Measured memory_bytes: 384
s = int(input())
record = [s]
count = 1

while (True):
    if (s % 2) == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    
    record.append(s)
    count += 1
    
    if (record.count(s) == 2):
        print(count)
        exit()


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			String[] line = br.readLine().split(" ");
			int a = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[1]);
			int C = Integer.parseInt(line[2]);

			double[] ret = new double[3];
			double S = a * b * Math.sin(Math.toRadians(C)) / 2;
			double L = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(C)));
			double h = Math.sin(Math.toRadians(C)) * b;
			ret[0] = S;
			ret[1] = L;
			ret[2] = h;

			int i;
			for (i = 0; i < ret.length; i++) {
				System.out.println(String.format("%.8f", ret[i]));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16928
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const LL INF=1e18;
LL a[500010],ans,s[500010];
int n;
int main(){
	cin>>n;
	FOR(i,1,n) cin>>a[i],s[i]=s[i-1]+a[i];
	ans=INF;
	FOR(i,1,n-1) ans=min(ans,abs(s[n]-s[i]-s[i]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define int ll
using pii = pair <int, int>;
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = 0;
const int mod = 1000000007;
vector <int> candidate;

void comp_all_div(int n)
{
    for (int i = 2; i*i<=n; i++)
    {
        if (n%i==0)
        {
            candidate.push_back(i);
            candidate.push_back(n/i);
        }
    }
    if (n>1)
        candidate.push_back(n);
}

int32_t main()
{
    int n; cin >> n;
    comp_all_div(n);
    sort(all(candidate));
    candidate.erase(unique(all(candidate)),candidate.end());
    int ct = 0;
    for (auto it:candidate)
    {
        int x = n;
        while(x%it==0)
            x/=it;
        if (x%it==1)
            ct++;
    }
    candidate.clear();
    comp_all_div(n-1);
    sort(all(candidate));
    candidate.erase(unique(all(candidate)),candidate.end());
    ct += candidate.size();
    cout << ct << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<'\n'
using namespace std;


int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	int r; cin >> r;
	if(r < 1200) print("ABC");
	else if(r >= 1200 && r < 2800) print("ARC");
	else print("AGC");
	return 0;
}

Measured memory_bytes: 256
//
// ABC105B: Cakes and Donuts
//
//

#include <iostream>
using namespace std;


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

	int A = N / 4;
	int B = N / 7;
	for(int a=0; a<=A; a++)
		for(int b=0; b<=B; b++)
			if( a*4 + b*7 == N) {
				cout << "Yes" << endl;
				return 0;
			}

	cout << "No" << endl;
	return 0;
}


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

int n,q,x,y,v,hd[100010],cnt,fa[100010];
struct node{int to,next,val; bool bo;}e[200010];
long long m;

int ask(int x) {return fa[x]==x?x:fa[x]=ask(fa[x]);}

void addedge(int x,int y,int v)
{
	e[++cnt]=(node){y,hd[x],v,0},hd[x]=cnt;
	e[++cnt]=(node){x,hd[y],v,0},hd[y]=cnt;
}

int main()
{
	scanf("%d%lld%d",&n,&m,&q);
	for (int i=1; i<=q; i++) scanf("%d%d%d",&x,&y,&v),addedge(x+1,y+1,v);
	for (int i=1; i<=n; i++) fa[i]=i;
	int cnt0=0,cnt1=0;
	for (int i=1; i<=q; i++) if (!e[i*2].val)
	{
		if (ask(e[i*2].to)==ask(e[i*2-1].to)) continue;
		fa[ask(e[i*2].to)]=ask(e[i*2-1].to),cnt0++;
	}
	for (int i=1; i<=q; i++) if (e[i*2].val)
	{
		cnt1++;
		if (ask(e[i*2].to)==ask(e[i*2-1].to)) return puts("No"),0;
	}
	cnt=n-cnt0,m-=cnt0;
	if (m>1ll*cnt*(cnt-1)/2) return puts("No"),0;
	if (m<cnt-1+(cnt1>0)) return puts("No"),0;
	puts("Yes");
	return 0;
}

Measured memory_bytes: 4096
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
        int n;
        cin >> n;
        vi a(n);
        rep(i, n) cin >> a[i];
        int flag = 0;
        int ans = 0;
        rep(i, n - 1) {
                if (a[i] < a[i + 1]) {
                        if (flag == -1) {
                                ans ++;                
                                flag = 0;
                        } else {
                                flag = 1;        
                        }
                } else if (a[i] > a[i + 1]) {
                        if (flag == 1) {
                                ans ++;
                                flag = 0;
                        } else {
                                flag = -1;
                        }
                } else {
                        continue;
                }
        }
        D(ans + 1);
        return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll w,h,n; cin >> w >> h >> n;
  ll hmin = 0;
  ll hmax = h;
  ll wmin = 0;
  ll wmax = w;
  REP(i, n){
    ll x,y,a; cin >> x >> y >> a;
    if(a==1){
      wmin = max(wmin, x);
    }
    if(a==2){
      wmax = min(wmax, x);
    }
    if(a==3){
      hmin = max(hmin, y);
    }
    if(a==4){
      hmax = min(hmax, y);
    }
  }
  if(wmax<=wmin || hmax <= hmin) cout << 0 << endl;
  else cout << (wmax-wmin) * (hmax-hmin) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a1, a2, score;
  scanf("%d %d",&a1, &a2);
  if (a1-a2>=2){
    score = a1*2-1;
    printf("%d",score);
  }else if (a2-a1>=2){
    score = a2*2-1;
    printf("%d",score);
  }else{
    score = a1+a2;
    printf("%d",score);
  }
return 0;
}

Measured memory_bytes: 128
n=int(input())
x=[]
u=[]
yen=0
bit=0
for i in range(n):
    a,b=input().split()
    x.append(float(a))
    u.append(b)
for i in range(n):
    if u[i]=="JPY":
        yen+=x[i]
    else:
        bit+=x[i]
print(yen+380000*bit)

Measured memory_bytes: 9120
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;

const int INF=0x3f3f3f3f;
const int N=1e5+5;

int n, k;
ll p[N];
ll pref[N], pref2[N];

ll query(int l, int r) {
    if (l>r) return 0;
    return pref[r]-pref[l-1];
}

ll query2(int l, int r) {
    if (l>r) return 0;
    return pref2[r]-pref2[l-1];
}

int main() {
    scanf("%d %d", &n, &k);
    for (int i=1; i<=n; ++i) {
        scanf("%lld", p+i);
    }
    for (int i=1; i<=n; ++i) {
        pref[i]=p[i]+pref[i-1];
        pref2[i]=p[i]>0 ? p[i] : 0;
        pref2[i]+=pref2[i-1];
    }
    ll sol=0;
    for (int i=1; i<=n; ++i) {
        if (i+k-1>n) break;
        sol=max(sol, query2(1, i-1)+max(query(i, i+k-1), 0LL)+query2(i+k, n));
        //printf("i == %d,    %d\n", i, query2(1, i-1)+query(i, i+k-1)+query2(i+k, n));
    }
    printf("%lld\n", sol);
    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int seisu = scan.nextInt();
		int count = 0;

		for(int i=1;i<=seisu;i++) {
			String mozi = String.valueOf(i);
			if(mozi.length()%2 == 1) {
				count++;
			}
		}
		System.out.println(count);
		scan.close();

	}

}


Measured memory_bytes: 33452
#include <iostream>
#include <string>
int main() {
    std::string a, op, b;
    std::cin >> a >> op >> b;
    if (op == "+")
    {
        std::cout << std::stoi(a) +std::stoi(b) << std::endl;
    }
    else
    {
        std::cout << std::stoi(a) - std::stoi(b) << std::endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int n = s.length-1;
        long sum = 0;
        for(int i = 0; i < (1<<n);i++){
            sum+=add(s,i);
        }
        System.out.println(sum);
    }
    private static long add(char[] s,int bit){
        long res = 0;
        long tmp = 0;

        for(int i = 0;i < s.length;i++){
            tmp = 10*tmp + (s[i]-'0');
            if((bit&(1<<i))!=0){
                res += tmp;
                tmp = 0;
            }
        }
        res += tmp;

        return res;
    }
}

Measured memory_bytes: 21844
/* in the name of Anton */

/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n>>m>>k;
    repA(i,0,10000)
    {
        if(i*n%m==k)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }

    cout<<"NO"<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
//#define mp map<int,int>
//#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
   int n;
   cin>>n;
   int arr[n];
   int max1=0;
   int max2=0;
   rep(i,n)
   {
     cin>>arr[i];
     if(arr[i]>max1){max2=max1;max1=arr[i];}
     else if(arr[i]>max2){max2=arr[i];}
   }
   rep(i,n)
   {
     if(arr[i]==max1)cout<<max2<<"\n";
     else cout<<max1<<"\n";
   }

   return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
#define NUM 1000
int main(void){
    
    int n,i,j;
    int num[NUM][NUM]={{0,0},};
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        for(j=0;j<3;j++){
            scanf("%d",&num[i][j]);
        }
    }
    
    for(i=0;i<n;i++){
        int a,b,c;
        a=num[i][0]*num[i][0];
        b=num[i][1]*num[i][1];
        c=num[i][2]*num[i][2];
        
        if(a==(b+c)||
           b==(a+c)||
           c==(a+b))
            puts("YES");
        else
            puts("NO");
    }
    
    return 0;
}

Measured memory_bytes: 4492
#include <iostream>
using namespace std;
const long m = 1000000007;

long pow(long n, int k) {
    long r = 1;
    while (k > 0) {
        if ((k & 1) == 1) {
            r = r * n % m;
        }
        n = n * n % m;
        k >>= 1;
    }
    return r;
}

long ddiv(long x, long y) {
    return x * pow(y, m - 2) % m;
}

long a[2001];

long c(long n, long k) {
    return ddiv(ddiv(a[n], a[k]), a[n - k]);
}

int main() {
    a[0] = 1;
    a[1] = 1;
    long n;
    cin >> n;
    for (int i = 2; i <= 2000; i++) {
        a[i] = a[i - 1] * i % m;
    }
    long res = 0;
    for (int i = 1; n - 2 * i >= i; i++) {
        res = (res + c(n - 2 * i - 1, i - 1)) % m;
    }
    cout << res << endl;
}


Measured memory_bytes: 3524
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cmath>
#include<bitset>
using namespace std;
#define ll long long
#define N 23
#define INF 0x3f3f3f3f
#define mod 998244353
#define mkp make_pair
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
int n, a[N], b[N], c[N];
int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int i, j, t, ret=0;
	
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin>>n;
	for(i=0; i<n; i++)
		cin>>a[i];
	for(i=1; i<=n; i++)
		cin>>b[i];
	for(i=1; i<n; i++)
		cin>>c[i];
	for(i=0; i<n; i++){
		ret += b[a[i]];
		if(i>0 && a[i]-a[i-1]==1)
			ret += c[a[i-1]];
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

n,m = map(int,input().split())

xy = [[] for i in range(n)]

for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    xy[x].append(y)
    #xy[y].append(x)
    
#xy = [[int(i)-1 for i in input().split()] for j in range(m)]
chk = [0]*n
dp = [0]*n

#print(xy)

def f(x):
    #global dp,chk
    if chk[x] == 1:
        return dp[x]
    fans = 0
    chk[x] = 1
    for i in range(len(xy[x])):
        fans = max(fans,f(xy[x][i])+1)
    dp[x] = fans
    #print(dp,chk)
    return dp[x]

ans = 0

for i in range(n):
    ans = max(ans,f(i))
    #print(f(i))
    
#print(dp)
print(ans)

Measured memory_bytes: 195824
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
using namespace std;
int n, ans; string s;
int main() {
	cin >> n >> s;
	for0(i, n)for0(j, i) {
		if (i - j < ans)continue;
		if (j > 0 && s[i - 1] == s[j - 1])continue;
		int p = j, q = i;
		while (s[p] == s[q]) {
			p++; q++;
			if (p == i)break;
			if (q == n)break;
		}
		ans = max(ans, p - j);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
const int INF = 1e18;

signed main(){
    int n; cin >> n;
    map<int,int> mp;
    int sum = 0;
    REP(i,n){
        int a; cin >> a;
        mp[a]++;
        sum += a;
    }
    int q; cin >> q;
    REP(i,q){
        int b, c; cin >> b >> c;
        mp[c] += mp[b];
        sum += mp[b] * (c-b);
        mp[b] = 0;
        cout << sum << '\n';
    }
}

Measured memory_bytes: 9444
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <cstring>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;

int main(){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0; i<s.size(); i++){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')ans++;
	}
	cout<<ans<<endl;
	

}

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

using namespace std;

int n;
int A[100000];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    sort(A, A+n);
    int L = A[n-1]/2;
    int R = L+1;
    if (A[n-1]%2 == 0) R = L;

    int best = A[0];
    int diff = min(abs(best-L), abs(best-R));
    for (int i = 1; i < n-1; i++) {
        int newDiff = min(abs(A[i]-L), abs(A[i]-R));
        if (newDiff < diff) {
            best = A[i];
            diff = newDiff;
        }
    }

    cout << A[n-1] << " " << best << endl;
}


Measured memory_bytes: 640
N = int(input())
ans = 100
for i in range(1, N // 2 + 1):
  A = str(i)
  B = str(N - i)
  t = 0
  for j in A:
    t += int(j)
  for j in B:
    t += int(j)
  ans = min(ans, t)
print(ans)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename FI,typename Compare>
pair<FI,FI> search_continuous(FI first,FI last,Compare comp){
	FI top = find_if(first,last,comp);
	if(top==last){
		return make_pair(last,last);
	}
	FI end = find_if_not(top,last,comp);
	return make_pair(top,end);
}

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

	int N=in();
	auto X=vecin(N);

	ll minP=1LL<<60;
	REP(i,100){
		ll P=0;
		REP(j,N){
			P+=(X[j]-(i+1))*(X[j]-(i+1));
		}
		minP = min(minP,P);
	}

	out(minP);
	return 0;
}


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

int main () {
  int m, nmin, nmax, tempa, tempb, sa=0;
  while(cin >>m>>nmin>>nmax) {
    int temp = 0;
    sa = 0;
    if(m == 0 && nmin == 0 && nmax == 0)break;
  cin>> tempa;
  for (int i=1;i<m;i++) {
    cin>> tempb;
    if(nmin <= i&& i<= nmax&&sa <= tempa - tempb) {
      sa = tempa - tempb;
      temp = i;
    }
    tempa = tempb;
  }
  cout << temp<< endl;
}
  return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int mpow(int x, int t) {
    if (!t) return 1;
    ll a = mpow(x, t/2);
    a = a * a % mod;
    if (t%2==1) a = a * x % mod;
    return (int)a;
}

int main(){
    int n, k;
    cin >> n >> k;
    vll d(k+1);
    rep1r(i, k) d[i] = mpow(k/i, n);
    rep1r(i, k) {
        for (int j=i*2; j<=k; j+=i) {
            d[i] -= d[j];
        }
    }
    ll ans = 0;
    rep1(i, k) ans += d[i] * i % mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4032
n, m = map(int, input().split())
alis = list(int(input()) for _ in range(m))
dp = [-1]*(n+1)
mod = 10**9 + 7
for i in alis:
    dp[i] = 0
dp[0] = 1
dp[1] = 1 if 1 not in alis else 0
for i in range(2,n+1):
    if dp[i] == -1:
        dp[i] = (dp[i-1] + dp[i-2]) % mod
print(dp[n])

Measured memory_bytes: 7836
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int get() { int r; cin >> r; return r; }
int n, p, m, ans;
signed main() {
	n = get(); m = n + 1;
	for1(i, n) {
		p = get();
		if (p <= m)ans++;
		m = min(m, p);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    fun abs(x : Int) = if (x>0) x else -x

    val sc = java.util.Scanner(System.`in`)
    val N = sc.next().toInt()
    var flag = true
    var t1 = 0
    var x1 = 0
    var y1 = 0

    for (i in 0 until N){
        val t2 = sc.next().toInt()
        val x2 = sc.next().toInt()
        val y2 = sc.next().toInt()

        val time = t2 - t1
        val dist = abs(x2-x1) + abs(y2-y1)

        if (time < dist || (time-dist)%2 == 1) {
            flag = false
            break
        }
        t1 = t2; x1 = x2; y1 = y2
    }
    println(if (flag) "Yes" else "No")
}

Measured memory_bytes: 51600
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;

int main()
{
    optimiza_io
    string S, T;
    cin >> S >> T;
    cout << T + S << "\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=1e6+10;
const int mod=1e9+7;


int mp[10005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(ll i=1;i<=500;i++)
    {
        for(ll j=1;j<=500;j++)
        {
            for(ll x=1;x<=500;x++)
            {
                ll ans=(i+j)*(i+j)+(i+x)*(i+x)+(j+x)*(j+x);

                ans/=2;
                if(ans>10000)
                    continue;
                mp[ans]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
        cout<<mp[i]<<'\n';


}


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

int main() {
  int N; cin >> N;
  vector<int> a(N);
  int asum = 0 ,bsum = 0;
  
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  
  for(int i=0; i<N; i++){
    if(i%2==0) asum += a.at(N-1-i);
    else bsum += a.at(N-1-i);
  }
  
  cout << asum-bsum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  int n;

  cin >> n;

  int current_max = 0;
  int tmax = 0;
  int prev;

  cin >> prev;
  for (int i = 0; i < n-1; ++i) {
    int next;
    cin >> next;

    if (next > prev) {
      current_max = max(current_max, tmax);
      tmax = 0;
    } else {
      current_max = max(current_max, ++tmax);
    }

    prev = next;
  }

  cout << current_max << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin>>n;
vector<long long> v(n+1);
long long sum=0;
for(int i=1;i<=n;i++){
    cin>>v[i];
    sum+=v[i];
}
long long dp[n+10][n+10];
memset(dp,0,sizeof(dp));

for(int i=1;i<=n;i++){
     dp[i][i]=v[i];
     if(i+1<=n)
            dp[i][i+1]=max(v[i],v[i+1]);
}

for(int len=3;len<=n;len++){
      int i=1,j=len;
      while(j<=n){
               dp[i][j]=max(v[i]+min(dp[i+2][j],dp[i+1][j-1]),v[j]+min(dp[i][j-2],dp[i+1][j-1]));

        j++;
        i++;
      }

}


     cout<<2*dp[1][n]-sum<<"\n";

}


Measured memory_bytes: 71040
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
if N>=M: print(0);exit()
if N==1: print(X[-1]-X[0]);exit()
L = []
for i in range(len(X)-1):
    L.append(X[i+1]-X[i])
L.sort()
L = L[:-(N-1)]
print(sum(L))

Measured memory_bytes: 13968