akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int a,b=0;
	scanf("%d",&a);
	if(a<4){
		b++;
	}else if(a==5){
		b++;
	}else if(a==6){
		b++;
	}else if(a==9){
		b++;
	}else if(a==10){
		b++;
	}else if(a==13){
		b++;
	}else if(a==17){
		b++;
	}
	if(b==0){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define F first
#define S second
#define s(x) #x<<" "<<x<<" | "<<
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define all(A)  A.begin(),A.end()  
#define has(m,x)   (m.find(x)!=m.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
#define endl "\n"
const int MSIZE = 2e5+5;
const int MOD = 1e9+7 ;



int main(){

    FIO
    string res;
    ll n; cin>>n;
    while(n) { res+='a'+(n-1)%26; n=(n-1)/26; }
    reverse(all(res));
    cout<<res<<endl;
    
    
    return 0;
}
    


Measured memory_bytes: 3644
#include <stdio.h>

int main(){
    int l ,r;
    scanf("%d", &l);
    scanf("%d", &r);

    if(r-l >= 2019) r = l + 2018;

    int result = 2019;
    int mod = 2019;
    long i, j;

    for(i=l;i<r;i++){
        for(j=l+1;j<=r;j++){
            mod = (i*j) % 2019;
            if(mod<result){
                result = mod;
                if(result == 0) break;
            }
        }
    }

    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main()
{
	char s[100001];
	char t[100001];
	scanf("%s", s, 100001);

	int i,cnt;
	cnt = 0;
	int flg;
	flg = 1;

	for (i = 0; i<100001 ; i++) {
		if (s[i] == '\0') break;
		cnt++;
	}

	for (i = cnt - 1; i >= 0; i--) {

		if (i >= 6 && s[i] == 'r' && s[i - 1] == 'e' && s[i - 2] == 'm' && s[i - 3] == 'a' && s[i - 4] == 'e' && s[i - 5] == 'r' && s[i - 6] == 'd') {
			i = i - 6;
		}

		else if (i >= 4 && s[i] == 'm' && s[i - 1] == 'a' && s[i - 2] == 'e' && s[i - 3] == 'r' && s[i - 4] == 'd') {
			i = i - 4;
		}

		else if (i >= 5 && s[i] == 'r' && s[i - 1] == 'e' && s[i - 2] == 's' && s[i - 3] == 'a' && s[i - 4] == 'r' && s[i - 5] == 'e') {
			i = i - 5;
		}

		else if (i >= 4 && s[i] == 'e' && s[i - 1] == 's' && s[i - 2] == 'a' && s[i - 3] == 'r' && s[i - 4] == 'e') {
			i = i - 4;
		}

		else {
          	flg = 0;
			break;
		}

	}

	if (flg == 1) {
		printf("YES");
	}
	else {
		printf("NO");
	}
	


	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  vector<int> v(3);
  REP(i,3)cin >> v[i];
  sort(ALL(v));
  cout << v[0] + v[1] << endl;

  

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class AtCoderr
    {
        static void Main(string[] args)
        {
            long n = long.Parse(ReadLine());
            for (long i = (long)Sqrt(n); i >= 0; i--)
            {
                if (n % i == 0)
                {
                    WriteLine(i + (n/i) - 2);
                    return;
                }
            }
        }

    }
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b != c)
    {
        cout << "Yes" << endl;
    }
    else if (a != b && b == c)
    {
        cout << "Yes" << endl;
    }
    else if (a == c && b != c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b,c;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(a);in(b);in(c);
	printf("%d\n",min(a*b,c));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define INF 1001001000
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    int N,M;
    cin>>N>>M;
    vector <pair<int,int>> keys(M);
    
    rep(i,0,M){
        int a,b;
        cin>>a>>b;
        vector<int> c(b);

        int s=0;
        rep(i,0,b){
            cin>>c[i];
            c[i]--;
            s+=(1<<c[i]);
        }
        keys[i]=(MP(a,s));
    }

    vector <int> dp(1<<(N+1),INF);
    dp[0]=0;

    rep(i,0,M){
        rep(j,0,(1<<N)){
            dp[j|keys[i].second]=min(dp[j|keys[i].second],dp[j]+keys[i].first);
        }
    }
    if(dp[(1<<N)-1]==INF)cout<<-1;
    else cout<<dp[(1<<N)-1];
    return 0;
}

Measured memory_bytes: 256
var
 i,n,m,j,t,s:longint;
 a:array[0..1000] of longint;
begin
 readln(n,m);
 for i:=1 to n do  read(a[i]);
 for i:=1 to n-1 do
  for j:=i+1 to n do
   if a[i]<a[j] then 
    begin
     t:=a[i];
     a[i]:=a[j];
     a[j]:=t;
    end;
 for i:=1 to m do
  s:=s+a[i];
 write(s);
end.

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

const ll MAXN = 40;
const ll SUMMAX = 400;
const ll INF = 1000000;
ll dp[MAXN + 1][SUMMAX + 1][SUMMAX + 1];

int main()
{
    ll N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<ll> a(N), b(N), c(N);
    REP(i, N) cin >> a[i] >> b[i] >> c[i];

    for (int i = 0; i <= N; ++i)
    {
        for (int j = 0; j <= SUMMAX; ++j)
        {
            for (int k = 0; k <= SUMMAX; ++k)
            {
                if (j == 0 && k == 0) dp[i][j][k] = 0;
                else dp[i][j][k] = INF;
            }
        }
    }
    for (ll i = 1; i <= N; ++i)
    {
        for (ll j = 0; j <= SUMMAX; ++j)
        {
            for (ll k = 0; k <= SUMMAX; ++k)
            {
                if (j - a[i - 1] >= 0 && k - b[i - 1] >= 0)
                {
                    if (dp[i - 1][j - a[i - 1]][k - b[i - 1]] != INF)
                    {
                        dp[i][j][k] = min(dp[i - 1][j][k], dp[i - 1][j - a[i - 1]][k - b[i - 1]] + c[i - 1]);
                        dp[i][j - a[i - 1]][k - b[i - 1]] = min(dp[i][j - a[i - 1]][k - b[i - 1]], dp[i - 1][j - a[i - 1]][k - b[i - 1]]);
                    }
                }
            }
        }
    }

    ll ans = INF;
    for (int j = 1; j <= SUMMAX; ++j)
    {
        for (int k = 1; k <= SUMMAX; ++k)
        {
            if (j * Mb == k * Ma)
            {
                if (dp[N][j][k] != INF)
                {
                    ans = min(ans, dp[N][j][k]);
                }
            }
        }
    }
        
    if (ans != INF) cout << ans << endl;
    else cout << "-1" << endl;
}


Measured memory_bytes: 51712
n, k = map(int, input().split())
vi = list(map(int, input().split()))
v = [0 for i in range(n)]
for i in range(n):
    v[i] = vi[i]

keta = 0
ki = k
while ki >= 1:
    ki /= 2
    keta += 1

x = [0 for i in range(keta)]
for h in range(keta):
    for i in range(n):
        if (v[i] % 2 == 1):
            x[h] += 1
        v[i] = v[i] // 2


ans = 0
for j in range(keta):
    i = keta - j - 1
    if (x[i] < n - x[i]) and (k >= 2 ** i):
        k -= 2 ** i
        ans += 2 ** i * (n-x[i])
        ##print("case1:",i,"桁 " , "k=", k)
    else:
        ans += 2 ** i * x[i]
        ##print("case2:", i, "桁")

ans += sum(v) * 2**keta
print(ans)

Measured memory_bytes: 14708
# Here your code !

n=gets.to_i

array1=gets.split.map(&:to_i)
m=gets.to_i

array2=gets.split.map(&:to_i)
array1=array1.sort
array2=array2.sort
i=0
j=0
ll=array1.length
lll=array2.length
answer=0
loop{
    if array1[i]==array2[j]
         i=i+1
         j=j+1
    elsif  array1[i]>array2[j]
        answer=1
        puts "NO"
      break
     elsif array1[i]<array2[j]
       i=i+1
     end
     
     if ll==i || lll==j
         break
    end
    
}

if answer==0
    puts "YES"
end

Measured memory_bytes: 33668
#include <bits/stdc++.h>
using namespace std;
#define int long long

#undef int
int main()
{
#define int long long
      string s, v;
      cin >> v >> s;
      int dp[s.size() + 1][v.size() + 1];
      for (int i = 0; i <= s.size(); i++)
            for (int j = 0; j <= v.size(); j++)
            {
                  if (i == 0 || j == 0)
                        dp[i][j] = 0;
                  else if (s[i - 1] == v[j - 1])
                        dp[i][j] = dp[i - 1][j - 1] + 1;
                  else
                        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }

      int index = dp[s.size()][v.size()];
      int i = s.size(), j = v.size();
      char LCS[index + 1];
      LCS[index] = '\0';
      while (i >= 0 && j >= 0)
      {
            if (s[i - 1] == v[j - 1])
            {
                  LCS[index - 1] = s[i - 1];
                  i--;
                  j--;
                  index--;
            }
            else if (dp[i - 1][j] > dp[i][j - 1])
                  i--;
            else
                  j--;
      }

      cout << LCS << endl;
      return 0;
}


Measured memory_bytes: 70656
import java.util.Scanner;

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

	int m, f, r, i = 0;
	int data[] = new int[100];
	while(true) {
		m = scan.nextInt();
		f = scan.nextInt();
		r = scan.nextInt();
		if(m == -1 && f == -1 && r == -1) break;
		if(m == -1 || f == -1) data[i] = 5;
		else if(m+f >= 80) data[i] = 1;
		else if(m+f >= 65) data[i] = 2;
		else if(m+f >= 50) data[i] = 3;
		else if(m+f >= 30) {
			if(r >= 50) data[i] = 3;
			else data[i] = 4;
		}
		else data[i] = 5;
		i++;
	}
	for(int count = 0; count < i; count++) {
		if(data[count] == 1) System.out.println("A");
		else if(data[count] == 2) System.out.println("B");
		else if(data[count] == 3) System.out.println("C");
		else if(data[count] == 4) System.out.println("D");
		else if(data[count] == 5) System.out.println("F");
	}

	}
}

Measured memory_bytes: 26128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll int n,x,t;
    cin>>n>>x>>t;
    int p;
    if(n%x==0)
    cout<<n/x*t<<endl;
    else
    cout<<((n/x)+1)*t<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
 int n,q;
 cin>>n>>q;
 string s;
 cin>>s;
 vector<int>a(n+1);
 for(int i=0;i<n;i++){
    if(s[i]=='A'&&s[i+1]=='C')a[i+2]=1;
 }
 for(int i=1;i<=n;i++){
    a[i]+=a[i-1];
 }
 while(q--){
    int l,r;
    cin>>l>>r;
    cout<<a[r]-a[l]<<"\n";
 }
    return 0 ;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define all(x) x.begin(),x.end()
#define mod 1000000007

ll expo(ll a,ll b){ll r=1;a=a%mod;while(b){if(b%2)r=(r*a)%mod;a=(a*a)%mod;b=b/2;}
return r;}
struct greaterr
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};



/*vector<bool> sieve(10000007,true);

void help(){
     sieve[0] = false;
     sieve[1] = false;

     for(int i=2;i*i<=10000000;++i){
        if(sieve[i]){
            for(int j=i*i;j<=10000000;j+=i)
                sieve[j] = false;

        }
     }

}


ll exp(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}
*/

vector<ll> sum(200007,0);
vector<int> adj[200007];
  void dfs(int x,int y)
  {
      sum[x]+=sum[y];
      for(auto xx:adj[x])
      {
          if(xx==y)
            continue;
          dfs(xx,x);
      }

  }
int main() {
   fastIO



   int n,q;
   cin>>n>>q;





   for(int i=0;i<n-1;++i)
   {
       int a,b;
       cin>>a>>b;
       adj[a].pb(b);
       adj[b].pb(a);

   }

   for(int i=0;i<q;++i)
   {
       int x,y;

       cin>>x>>y;
       sum[x]+=y;
   }

     dfs(1,0);

   for(int i=1;i<=n;++i)
      cout<<sum[i]<<" ";

	return 0;
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
const ll mod=1e9+7;
const int INF=0x3f3f3f3f;
ll n,m;
ll a[105],ant[100005],num[100005],ans[100005];
ll euler(ll n)
{
    ll ret=n;
    ll a=n;
    for(ll i=2;i*i<=a;i++)
    {
        if(a%i==0)
        {
            ret-=ret/i;
            while(a%i==0)
            {
                a/=i;
            }
        }
    }
    if(a>1)
        ret-=ret/a;
    return ret;
}
int main()
{
    scanf("%lld",&n);

    printf("%d\n",euler(n));
    return 0;
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M; cin >> N >>M;
  for(int i = 0; i < M; i++){
    int a; cin >> a;
    N -= a;
    if(N < 0){
      cout << -1 <<endl;
      return 0;
    }
  }
  cout << N << endl;
}

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

int main(void)
{
	long long int l[3]= {};

	for(int i= 0; i < 3; i++)
		cin>>l[i];

	sort(l, l+3);

	if(l[2]%2 == 0)
		cout<<0<<endl;
	else
		cout<<l[0]*l[1]<<endl;

	return 0;
}

Measured memory_bytes: 256
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;



int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    long double a,b;
    cin>>a>>b;
    long double ans = a*b;
    ll f = ans;
    cout << f << endl;
    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  int count=-1;
  
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  
  for(int j=0;j<N;j++){
    if(a.at(0)==2){
       count=j+1;
   	   break;
    } 
   	 a.at(0)=a.at(a.at(0)-1);
     
  }
  
  cout<<count<<endl;
}

Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
        public static void main(String[] args) {
                InputStream inputStream = System.in;
                OutputStream outputStream = System.out;
                InputReader in = new InputReader(inputStream);
                PrintWriter out = new PrintWriter(outputStream);
                TaskA solver = new TaskA();
                solver.solve(1, in, out);
                out.close();
        }

        static class TaskA {
                public void solve(int testNumber, InputReader in, PrintWriter out) {
                        int n = in.i();
                        if (n <= 2) {
                                out.println(0);
                                return;
                        }
                        out.println((n - 3) / 3 + 1);
                }

        }

        static class InputReader {
                InputStream is;
                private byte[] inbuf = new byte[1024];
                public int lenbuf = 0;
                public int ptrbuf = 0;

                public InputReader(InputStream is) {
                        this.is = is;
                }

                private int readByte() {
                        if (lenbuf == -1) throw new InputMismatchException();
                        if (ptrbuf >= lenbuf) {
                                ptrbuf = 0;
                                try {
                                        lenbuf = is.read(inbuf);
                                } catch (IOException e) {
                                        throw new InputMismatchException();
                                }
                                if (lenbuf <= 0) return -1;
                        }
                        return inbuf[ptrbuf++];
                }

                public int i() {
                        int num = 0, b;
                        boolean minus = false;
                        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
                        if (b == '-') {
                                minus = true;
                                b = readByte();
                        }

                        while (true) {
                                if (b >= '0' && b <= '9') {
                                        num = num * 10 + (b - '0');
                                } else {
                                        return minus ? -num : num;
                                }
                                b = readByte();
                        }
                }

        }
}



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

# (a,b,c,d) -> (ab,bc,cd,da) と変換
# xor x で不変量になる

N = int(readline())

A = list(map(int,readline().split()))
B = list(map(int,readline().split()))

def convert(A):
    return [x ^ y for x,y in zip(A,A[1:])] + [A[-1] ^ A[0]]

C = convert(A); D = convert(B)

def Z_algorithm(S):
    # 共通接頭辞の長さを返す
    N=len(S)
    arr = [0]*N
    arr[0] = N
    i,j = 1,0
    while i<N:
        while i+j<N and S[j]==S[i+j]:
            j += 1
        arr[i]=j
        if not j:
            i += 1
            continue
        k = 1
        while i+k<N and k+arr[k]<j:
            arr[i+k] = arr[k]
            k += 1
        i += k; j -= k
    return arr

Z = Z_algorithm(D + [-1] + C + C)[N+1:N+N+1]

K = [i for i,x in enumerate(Z) if x == N]
X = [A[k] ^ B[0] for k in K]

print('\n'.join('{} {}'.format(k,x) for k,x in zip(K,X)))


Measured memory_bytes: 67024
import java.util.Scanner;

class Main
{
    public static void main(String[] args)
    {
      //入力
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      
      int count = 1;
      int min = 0;
      for (int i=1;i<20; i++) {
        if(count>=b) {
          break;
        }
        count += a-1;
        min ++;
      }
      
      System.out.println(min);
      
    }
      
}



Measured memory_bytes: 23252
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,A; cin>>N;
	map<ll,ll> ct;
	ll ret=0;
	for (int i=0; i<N; i++)
		cin>>A, ct[A]++, ret+=A;
	int Q; cin>>Q;
	for (int i=0; i<Q; i++) {
		ll B,C; cin>>B>>C;
		ret+=ct[B]*(C-B);
		ct[C]+=ct[B]; ct[B]=0;
		cout<<ret<<"\n";
	}
	return 0;
}

Measured memory_bytes: 9524
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int,input().split())
uf = UnionFind(N)
for k in range(M):
    A, B = map(int,input().split())
    uf.union(A-1,B-1)
ans = 1
for k in range(N):
    ans = max(ans,uf.size(k))
print(ans)


Measured memory_bytes: 16928
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#include <utility>
#include <queue>
#include <stdio.h>
#include <string>
#include <map>
#include <stack>
#include <complex>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000007
using namespace std;
typedef long long int ll;
typedef complex<double> xy;

int main(){
    vector<xy> inp;
    double x,y;
    int n=0;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> x >> y;
        inp.push_back(xy(x,y));
    }
    double ans=0.0;
    for (int i=1; i<n-1; i++) {
        xy a = inp[i], b = inp[i+1];
        xy hoge=a-inp[0],piyo=b-inp[0];
        ans += ((conj(hoge)*piyo).imag())/2.0;
    }
    printf("%.1f\n", ans);
}

Measured memory_bytes: 1256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for (auto& e : s) cin >> e;
    sort(s.begin(), s.end());
    for (auto e : s) cout << e; cout << endl;
    return 0;
}

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

using namespace std;

int main(){

    int n, k, q;
    cin >> n >> k >> q;

    int cnt[n];
    memset(cnt, 0, sizeof cnt);

    for(int i=0; i<q; i++){
        int u;
        cin >> u;

        cnt[u-1]++;
    }

    for(int i=0; i<n; i++){
        if(q - cnt[i] < k) cout << "Yes\n";
        else cout << "No\n";
    }

}

Measured memory_bytes: 1024
/*input
9999 1
0
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int n, k, i;
	cin >> n >> k;
	vector<bool> bad(10, false);
	for(i=0; i<k; i++) {
		int x;
		cin >> x;
		bad[x] = true;
	}
	for(;;n++) {
		int m = n;
		bool good = true;
		while(m > 0) {
			int dig = m % 10;
			m /= 10;
			good &= !bad[dig];
		}
		if(good) {
			cout << n << endl;
			return;
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);		
	int t = 1;
	// cin >> t;
	while(t--) {
		run();
	}
}


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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n,m,k;
        cin>>n>>m>>k;

        ll a[n],b[m];

        for(ll i=0;i<n;i++)
        cin>>a[i];

        for(ll i=0;i<m;i++)
        cin>>b[i];

        vector<ll> totala(n),totalb(m);

        for(ll i=0;i<n;i++)
        {
            if(i==0)
            totala[i]=a[i];
            else
            totala[i]=totala[i-1]+a[i];
        }

        for(ll i=0;i<m;i++)
        {
            if(i==0)
            totalb[i]=b[i];
            else
            totalb[i]=totalb[i-1]+b[i];
        }

        ll mx=0;

        for(ll no=0;no<=n;no++)
        {
            ll rem;
            
            if(no==0)
            rem=k;
            else
            rem=k-totala[no-1];

            ll nob=0;

            if(rem>0)
            {
                nob=upper_bound(totalb.begin(),totalb.end(),rem)-totalb.begin();
                mx=max(mx,(no+nob));
            }
            else if(rem==0)
            {
                mx=max(mx,(no+nob));
            }
            
        }

        cout<<mx;

    }
}

Measured memory_bytes: 9504
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

ll N, Q;
ll A[100010];
map<ll, ll> mp;

signed main(){
    cin >> N;
    ll ans = 0;
    REP(i, N){
        cin >> A[i];
        mp[A[i]]++;
        ans += A[i];
    }
    cin >> Q;
    ll B, C;
    REP(i, Q){
        cin >> B >> C;
        ans += (C - B) * mp[B];
        mp[C] += mp[B];
        mp[B] = 0;
        PRINT(ans);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> Vec;

ll solve(Vec &a, Vec &b, ll idx, ll k, ll c)
{
    if (idx == (int)a.size()) return 0;
        
    ll res = 0;
    ll A = a[idx], B = b[idx];
    if (A - c >= B) {
        ll C = (A - c - B) * pow(10, idx);
        res = solve(a, b, idx + 1, k, 0) + C;
    } else {
        ll C = (A - c + 10 - B) * pow(10, idx);
        res = solve(a, b, idx + 1, k, 1) + C;        
        if (k > 0) {
            res = max(res, solve(a, b, idx + 1, k-1, 0) + C);
        }
    }
    return res;
}

int main()
{
    string A, B;
    ll K;
    cin >> A >> B >> K;
    vector<ll> a, b; 
    for (ll i = (ll)A.size()-1; i >= 0; i--) {
        a.push_back(A[i]-'0');
    }

    for (ll i = (ll)B.size()-1; i >= 0; i--) {
        b.push_back(B[i]-'0');
    }

    while (b.size() != a.size()) b.push_back(0);
    
    cout << solve(a, b, 0, K, 0) << endl;
    return 0;
}

Measured memory_bytes: 3324
def com(n, r, mod):
    num = 1
    den = 1
    for i in range(r):
        num = (num * (n-i)) % mod
        den = (den * (i+1)) % mod
    return num * pow(den, mod-2, mod)

N, A, B = map(int, input().split())

mod = 10**9 + 7

sum = pow(2, N, mod) - 1
sum -= com(N, A, mod)
sum -= com(N, B, mod)

print(int(sum % mod))

Measured memory_bytes: 3064
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=300005;

int dp1[SIZE],dp2[SIZE];

int main(){
	int n;
	char t;
	scanf("%d\n",&n);
	for(int i=0;i<n;i++){
		scanf("%c",&t);
		if(t=='E') dp1[i]++;
		else dp2[i]++;
	}
	for(int i=1;i<n;i++) dp1[i]+=dp1[i-1];
	for(int i=n-2;i>=0;i--) dp2[i]+=dp2[i+1];
	int ans=0;
	for(int i=0;i<n;i++) ans=max(ans,dp1[i]+dp2[i]);
	printf("%d\n",n-ans);
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll INF = 1e16;

const int MAXN = 5e5;
int t[4 * MAXN];

void upd(int v, int tl, int tr, int pos, int val) {
	if (tl == tr) {
		t[v] = val;
		return;
	}
	int tm = (tl + tr) / 2;
	if (pos <= tm) {
		upd(2 * v + 1, tl, tm, pos, val);
	}
	else {
		upd(2 * v + 2, tm + 1, tr, pos, val);
	}
	t[v] = (t[2 * v + 1] + t[2 * v + 2]);
}

int ask(int v, int tl, int tr, int l, int r) {
	if (l > tr || r < tl)return 0;
	if (tl >= l && tr <= r) {
		return t[v];
	}
	int tm = (tl + tr) / 2;
	return ask(2 * v + 1, tl, tm, l, r) + ask(2 * v + 2, tm + 1, tr, l, r);
}

struct query {
	int l, r, pos;
};


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, q;
	cin >> n >> q;
	map<int, deque<int>> m;
	vector<int> val(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		val[i] = x;
		m[x].push_back(i);
		if (m[x].size() == 1)upd(0, 0, n - 1, i, 1);
	}
	vector<vector<query>> a(n);
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		l--, r--;
		a[l].push_back({ l, r, i });
	}
	vector<int> ans(q);
	for (int i = 0; i < n; i++) {
		for (auto it : a[i]) {
			ans[it.pos] = ask(0, 0, n - 1, it.l, it.r);
		}
		m[val[i]].pop_front();
		if (m[val[i]].size())upd(0, 0, n - 1, m[val[i]].front(), 1);
	}
	for (auto i : ans) {
		cout << i << "\n";
	}
}

Measured memory_bytes: 394484
#include<iostream>
#define limit 10000

using namespace std;

int main () {
	while ( true ) {

		int N, A, B, C, X;

		
		int pic[100];

		int count = 0;
		int ans = -1;

		cin >> N >> A >> B >> C >> X;

		if ( N + A + B + C + X == 0 )
			break;


		int x;
		x = X;

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

		for ( int i=0; i<limit+1; i++ ) {

			if ( x == pic[count] ) {
				count++;
				ans = i;
			}

			if ( x + B == 0 && pic[count] != 0 )
				break;

			if ( count == N )
				break;

			x = ( A*x + B )%C;
			
		}

		if ( count != N )
			cout << -1 << endl;
		else
			cout << ans << endl;
	}
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

int n, m, q;
vector <vector <int> > a;
int ans = 0;

inline void rec (vector <int> cur, int mx) {
    int sum = 0;
    for (int i = 0; i < sz(cur); i++) sum += cur[i];
    if (sum == n) {
        vector <int> A;
        for (int i = 0; i < sz(cur); i++) {
            for (; cur[i]; --cur[i]) {
                A.pb(i + 1);
            }
        }
        int res = 0;
        for (int i = 0; i < q; i++) {
            if (A[a[i][1] - 1] - A[a[i][0] - 1] == a[i][2]) res += a[i][3];
        }
        umax(ans, res);
        return;
    }
    for (int i = mx; i < sz(cur); i++) {
        vector <int> nw = cur;
        ++nw[i];
        rec(nw, i);
    }
}

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> q;
    a.assign(q, vector <int> (4));
    for (auto &i : a) {
        for (auto &j : i) cin >> j;
    }
    rec(vector <int> (m), 0);
    cout << ans << '\n';
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX (1LL << 63) - 1

using namespace std;
using ll = long long;

ll evalMaxD(ll A, ll B) {
	ll dA = 0;
	while (A > 0) {
		A /= 10;
		dA++;
	}

	ll dB = 0;
	while (B > 0) {
		B /= 10;
		dB++;
	}

	return max(dA, dB);
}

int main() {
	ll argN;
	cin >> argN;

	ll ret = 20;
	for (ll i = 1; i <= sqrt(argN); ++i) {
		if (argN % i == 0) {
			ll tempRet = evalMaxD(i, argN / i);
			ret = min(ret, tempRet);
		}
	}

	cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const int MAX_N = 1e5+10;

LL dp[MAX_N];

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    VL h(N);
    REP(i,N) cin >> h[i];
    REP(i,N){
        dp[i] = LINF;
    }
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    FOR(i,2,N){
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout << dp[N-1] << endl;


}


Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut v:Vec<usize> = (0..n).map(|_| read()).collect();
    v.sort();
    let median = v[(n-1)/2];
    println!("{}", v[n/2] - median);
}

Measured memory_bytes: 3036
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N, K = map(int, input().split())

amari1 = N//K
amari2 = N//K+1
ans = min(abs(N-amari1*K), abs(N-amari2*K))
print(ans)


Measured memory_bytes: 3060
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  private static final long MOD = 1000000007L;

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    long k = sc.nextLong();

    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    long result = 0;
    for (int i = 0; i < n; i++) {
      long l = 0;
      long r = 0;

      for (int j = 0; j < i; j++) {
        if (a[i] > a[j]) {
          l++;
          result += (k - 1) * k / 2;
          result %= MOD;
        }
      }
      long addL = ((k - 1) * k / 2) % MOD * l;
      if (addL < 0) throw new IllegalStateException();

      for (int j = i + 1; j < n; j++) {
        if (a[i] > a[j]) {
          r++;
          result += k * (k + 1) / 2;
          result %= MOD;
        }
      }
      long addR = (k * (k + 1) / 2) % MOD * r;
      if (addR < 0) throw new IllegalStateException();

//      result += calc(r, k, r + l);
//      result %= MOD;
    }

    os.println(result);
  }

  private static long calc(long a, long n, long d) {
    long result = 0;
    result = (result + 2 * a) % MOD;
    result = (result + (n - 1) * d) % MOD;
    result = (result * n) % MOD;
    result = (result / 2) % MOD;
    return result;
//    return ((n * (2 * a + (n - 1) * d)) / 2) % MOD;
  }
}

Measured memory_bytes: 26212
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i*7<=n;i++){
		int now=n-i*7;
		if(now%4==0||now%7==0) {printf("Yes");return 0;}
	}
	if(n==11) {printf("Yes");return 0;}
	if(n==0) {printf("Yes");return 0;}
	if(n%4==0) {printf("Yes");return 0;}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int x;
    cin >> x;
    cout << ((x < 1200) ? "ABC" : "ARC") << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<map>
#include<set>
#define int long long int
int32_t main()
{
	int n;
	cin>>n;
	int j,arr[n];
	for(j=0;j<n;j++)
	    cin>>arr[j];
	map<int,int> mp;
	for(j=0;j<n;j++)
	{
		mp[arr[j]]++;
	}
	set<int> s1,s2;
	for(auto p:mp)
	{
		if(p.second%2!=0)
		   p.second--;
		if(p.second==2)
		{
			s1.insert(p.first);
		}
		else if(p.second>=4)
		{
			s2.insert(p.first);
		}
	}
	int answer=0;
	if(s1.size()!=0&&s2.size()!=0)
    {
		auto it1=s1.rbegin();
		auto it2=s2.rbegin();
		answer=max(answer,(*it1)*(*it2));
	}
	if(s2.size()!=0)
	{
		auto it=s2.rbegin();
		answer=max(answer,(*it)*(*it));
	}
	if(s1.size()>=2)
	{
		auto it=s1.end();
		it--;
		int val=*it;
		it--;
		val*=*it;
		answer=max(answer,val);
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    char res = 'A';
    char a, b, c;
    while(cin >> a >> c >> b){
        if(a == res) res = b;
        else if(b == res) res = a;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1136
from math import ceil
n=int(input())
x=100
ct=0
while(x<n):
    if n<100+x:
        ct+=ceil((n-x)/(x//100))
        break
    else:
        ct+=ceil((100-x%100)/(x//100))
        x+=ceil((100-x%100)/(x//100))*(x//100)
        #print(x,ct)
print(ct)


Measured memory_bytes: 64232
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int cnt = 1;
	int a;
	while (cnt <= 10000) {
		cin >> a;
		if (a == 0) {
			break;
		}
		printf("Case %d: %d\n", cnt, a);
	cnt++;
	}
}


Measured memory_bytes: 3104
#include <algorithm>
#include <climits>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

    vector<pair<int, int> > v;
    for (int i=1; i<=N; ++i) {
        for (int j=i+1; j<=N; ++j) {
            if (N % 2 == 0 && i+j == N+1) {
                continue;
            }
            if (N % 2 == 1 && j != N && i+j == N) {
                continue;
            }
            v.push_back(make_pair(i, j));
        }
    }

    cout << (int)v.size() << endl;
    for (int i=0; i<(int)v.size(); ++i) {
        cout << v[i].first << " " << v[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
char g;
char f[4][13],a,pp;
int v[4][13],tt[100];
int main(void){
    tt['T']=10;tt['J']=11;tt['Q']=12;tt['K']=13;tt['A']=14;
    while(scanf("%c%*c",&g),g!='#'){
        for(int i=0;i<4;i++)
            for(int j=0;j<13;j++){
                scanf("%c%c%*c",&a,&f[i][j]);
                if(a>='0'&&a<='9')v[i][j]=a-'0';
                else v[i][j]=tt[(int)a];
            }
        int lead=0,score[2]={};
        for(int i=0;i<13;i++){
            int w=-1,ws=-1;
            for(int j=0;j<4;j++){
                int sc=v[j][i];
                if(f[j][i]==g)sc+=100;
                if(f[j][i]!=g&&f[j][i]!=f[lead][i])continue;
                if(sc>ws)ws=sc,w=j;
            }
            lead=w;
            score[w%2]++;
        }
        if(score[0]>score[1])cout<<"NS "<<score[0]-6<<endl;
        else cout<<"EW "<<score[1]-6<<endl;
    }
}

Measured memory_bytes: 3136
#include <stdio.h>

int main(void){
    double W,H,x,y;
    scanf("%lf %lf %lf %lf",&W,&H,&x,&y);

    double halfx = W/2;
    double halfy = H/2;

    int other;

    if(x == halfx & y == halfy){
        other = 1;
    }else{
        other = 0;
    }
    
    printf("%lf %d",W*H/2,other);



}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int k; cin>>k;
	int ans=-1;
	for(int i=0,sv=7;i<k;++i){
		if(sv%k==0){
			ans=i+1;
			break;
		}
		sv=sv%k*10+7;
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------
bool is_integer(double x){
  return x==floor(x);
}

int main(void) {
  int n, d;
  cin >> n >> d;

  ll x[n][d];
  rep(i,n){
    rep(j,d){
      cin >> x[i][j];
    }
  }

  int ans=0;
  double dist=0.0;
  rep(i,n){
    rep(j,n){
      dist=0.0;
      if(i>=j){continue;}
      rep(k,d){
        dist+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      if(is_integer(sqrt(dist))){
        ans++;
      }
    }
  }

  prt(ans);
}


Measured memory_bytes: 256
/* ex 3_4
  kt125 */

#include<stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  
  int count = 0;  
  for(int i = 0; i < 9; i++){  //二重ループで九九の値と一致するnがあるか調べる。
    for(int j = 0; j< 9; j++){
      if(n == (i+1) * (j+1)){  // i,j は0から8なので+1する。
        count++ ; break;
      }
    }
  }
  if (count == 0)  // if count == 0, print"No"
    printf("No\n");
  else
    printf("Yes\n");  // if count > 0, print"Yes"
  return 0;
}
    

Measured memory_bytes: 128