akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


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

    list<char> ans;

    for(char c : s) ans.push_back(c);

    bool direction = true;

    rep(i, q) {
        int m;
        cin >> m;

        if (m == 1) direction = !direction;
        else {
            int p;
            char c;
            cin >> p >> c;

            if (!direction) {
                if (p == 1) p = 2;
                else p = 1;
            }

            if (p == 1) {
                ans.push_front(c);
            } else {
                ans.push_back(c);
            }
        }
    }

    if(!direction) reverse(ans.begin(), ans.end());

    for (char c : ans) cout << c;
    cout << endl;

}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    if(n%2 == 1){
    	cout << "No" << endl;
    }
    else{
    	bool ok = true;
    	for(int i = 0; i < n/2; i++){
    		if(s[i] != s[i+n/2]) ok = false;
    	}
    	if(ok) cout << "Yes" << endl;
    	else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=2e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint solve(llint D,llint ue,llint st){
	//ue が今見ている上の桁
	//st が下の桁
	if(D==0&&ue<st){return 1;}
	if(D==0&&ue==st){return 10;}
	if(D!=0&&ue<=st){return 0;}
	if(D%st!=0){return 0;}//それはそー
	if(abs(D)>ue*10){return 0;}//なおせん
	llint ans=0;
	for(int i=-9;i<=9;i++){
		int ho=0;if(st==1&&i>=0){ho=1;}//(stが1なら最上位は0で)ないです
		ans+=solve(D-(ue-st)*i,ue/10,st*10)*(10-abs(i)-ho);
	}
	return ans;
}
int main(void){
	llint ans=0,i,j,n,d,ue,st,ansa=0;
	cin>>d;
	if(d%9!=0){cout<<0<<endl;return 0;}
	for(j=1;j<=18;j++){
		ue=1;
		for(i=0;i<j;i++){ue*=10;}
		ans+=solve(d,ue,1);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int white,black,x=1,y=1;
bool map[505][505];
int main(){
	for(register int i=1;i<=50;i++){
		for(register int j=1;j<=100;j++){
			map[i][j]=true;
		}
	}
	scanf("%d%d",&white,&black);
	white--;black--;
	while(white>=1){
		map[x][y]=false;
		white--;
		y+=2;
		if(y>100){
			y=1;
			x+=2;
		}
	}
	x=100;y=1;
	while(black>=1){
		map[x][y]=true;
		black--;
		y+=2;
		if(y>100){
			y=1;
			x-=2;
		}
	}
	printf("100 100\n");
	for(register int i=1;i<=100;i++){
		for(register int j=1;j<=100;j++){
			switch(map[i][j]){
				case true:printf("#");break;
				case false:printf(".");break;
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3772
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

long long D;
long long p10[30];
int ctr(int a, int dep) {
  int t = min(9, 9-a) - max(0, -a) + 1;
  if (dep == 0) t--;
  return t;
}
long long dfs(int dep, long long cur, long long rev) {
  if (dep == 20) return 0;
  long long s = 0;
  for (int e=-9; e<=9; e++) {
    int t = cur*10+e;
    if (t < 0 || 1LL*t*p10[dep+1] > p10[10]) continue;
    s += 1LL * ctr(e, dep) * dfs(dep+1, t, rev+e*p10[dep]);
  }

  // (cur) (-rev)
  if ((p10[dep]*cur-rev) == D) s += 1;
  // (cur) (0) (-rev)
  if ((p10[dep+1]*cur-rev) == D) s += 10;
  return s;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> D;
  p10[0] = 1;
  for (int i=1; i<30; i++) p10[i] = 10LL*p10[i-1];
  cout << dfs(0, 0, 0) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

constexpr ll mod = 1000000007;

// 2部グラフ判定
// 頂点 v を c で塗る. v に隣接するノードは -c
bool dfs(const vector<vector<int>> g, vector<int>& color, int v, int c) {
  color[v] = c;
  for (int i = 0; i < g[v].size(); i++) {
    if (color[g[v][i]] == c) return false;   // 隣接するノードが同じ色で塗られていた
    if (color[g[v][i]] == 0 && !dfs(g, color, g[v][i], -c)) return false;  // 隣接するノードを -c で塗れない
  }
  return true;
}

void warshall_floyd(const int& n, vector<vector<int>>& d) {
  rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
}

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

  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  vector<vector<int>> g(n, vector<int>());   // グラフの辺
  rep(i, n) rep(j, n) {
    if (s[i][j] == '1') g[i].push_back(j);
  }

  vector<int> color(n, 0);

  if (!dfs(g, color, 0, 1)) {
    cout << -1 << endl;
    return 0;
  }

  vector<vector<int>> d(n, vector<int>(n, INF));
  rep(i, n) d[i][i] = 0;
  rep(i, n) rep(j, n) {
    if (s[i][j] == '1') d[i][j] = 1;
  }

  warshall_floyd(n, d);

  int ans = 0;
  for (auto& v : d) {
    chmax(ans, MAX(v) + 1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 20684
N = int(input())

a =[0]

for i in range(N):
    a.append(int(input()))


f =[0]*(N+1)

i=1
c = 0
while f[i]==0:
    f[i]=1
    i = a[i]
    c +=1
    if i ==2:
        break
if f[i]==1:
    print(-1)
else:
    print(c)

Measured memory_bytes: 7848
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	s := next()
	nsew := map[byte]bool{}

	for i := 0; i < len(s); i++ {
		nsew[s[i]] = true
	}

	if nsew['N'] && !nsew['S'] || !nsew['N'] && nsew['S'] || nsew['E'] && !nsew['W'] || !nsew['E'] && nsew['W'] {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
#define reps(i,j,n) for(int i = (j) ; i < (int)(n) ; ++i)    
#define rep(i,n) reps(i,0,n)  
#define each(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)    
typedef pair< int , int > Pi;  
typedef pair< int , Pi > Pii;
typedef long long int64;  
const int INF = 1 << 30;  
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is>>a.first>>a.second; }  
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os<<a.first<<" "<<a.second; }  
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ rep(i,sz(vc)) is >> vc[i]; return is;}  
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ rep(i,sz(vc)) os << vc[i] << endl; return os; }

int N;
Pi data[300000];

int calc(int value) { //value:許容匹数
  int64 sum = 0; //放出量の合計
  priority_queue< Pi, vector< Pi >, greater< Pi > > que; //許容量が小さい順
  for(int i = 0; i < N; i++){
    que.push( Pi( data[i].second, data[i].first));
    sum += data[i].first;
    // sum / que.size() を摂取する → sum / que.size() <= que.top()
    while(!que.empty() && sum > (int64)value * que.top().first){
      sum -= que.top().second;
      que.pop();
    }
    if(que.size() >= value) return true;
  }
  return false;
}

int Binary_Search( int row, int high) {
  int mid = (row + high + 1) >> 1;
  if(row == high)    return(row);
  else if(calc(mid)) return(Binary_Search( mid, high));
  else               return(Binary_Search( row, mid - 1));
}

int main() {

  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    scanf("%d %d", &data[i].first, &data[i].second);
  }
  sort( data, data + N);
  cout << Binary_Search( 0, N) << endl;
}

Measured memory_bytes: 11448
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
long long nibeki(long long a){
    long long t = 1;
    while(a >= t){
        t = 2*t;
    }
    return t;
}
int main(){
    multiset<long long> st;
    int n,p;
    cin >> n;
    for(int i = 0;i<n;i++){
        cin >> p;
        st.insert(p);
    }
    long long q,r;
    long ans = 0;
    while(!st.empty()){
        auto tem = st.end();
        tem--;
        q = nibeki(*tem) - *tem;
        if(q != *tem){
            ans = ans + min(st.count(*tem),st.count(q));
            if(st.count(*tem)>=st.count(q)){
                st.erase(*tem);
                st.erase(q);
            }
            else{
                r = st.erase(q) - st.erase(*tem);
                st.erase(*tem);
                st.erase(q);
                for(int i = 0;i<r;i++){
                    st.insert(q);
                }
            }
        }
        else{
            ans = ans + (st.count(*tem))/2;
            st.erase(*tem);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	int N,X;
	cin >> N >> X;
	if(N == 0){
		if(X == 0){
			puts("0 0");
		}else{
			puts("-1");
		}
	}else if(N == 1){
		if(X == 0){
			puts("0 0 1 1");
		}else{
			puts("-1");
		}
	}else{
		if((1<<N) <= X){
			puts("-1");
		}else{
			deque<int> deq;
			deq.pb(X);
			rep(i,1<<N) if(i!=X){
				deq.push_front(i);
				deq.push_back(i);
			}
			deq.pb(X);
			rep(i,2*(1<<N)) cout << deq[i] << " ";
			cout << endl;
		}
	}
}


Measured memory_bytes: 2944
N = int(input())
a = [0] + [int(x) for x in input().split()]

nball = [0] * (N + 1)  # nball[i] ... i番目の箱に入っているボールの数

nball[N] = a[N]

for i in range(N - 1, 0, -1):
    if 2 * i <= N:
        nball[i] = ( a[i] + sum(nball[2 * i : N + 1 : i]) ) % 2  # nball[2*i] + nball[3*i] + ... + nball[floor(N/i)*i]
    else:
        nball[i] = a[i]

M = 0
b = []
for i in range(N + 1):
    M += nball[i]
    if nball[i] > 0:
        b.append(i)

print(M)
if len(b) > 0:
    print(' '.join(map(str, b)))

Measured memory_bytes: 85480
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[3][4100];

int main(){
    ll n;
    cin>>n;
    string s;
    rep(i,0,n){
      s += "x";
    }
    string s1;
    cin>>s1;
    s += s1;
    rep(i,0,n){
      s += "z";
    }
    rep(i,0,s1.sz){
      if(s1[i]=='R')d[0][i+1]++;
      if(s1[i]=='G')d[1][i+1]++;
      if(s1[i]=='B')d[2][i+1]++;
    }
    rep(i,0,4050){
      rep(j,0,3){
        d[j][i+1] += d[j][i];
      }
    }
    ll ans1 = 0;
    rep(i,0,s1.sz){
      if(s1[i]=='R'){
        ans1 += d[1][i]*(d[2][4010]-d[2][i]);
        ans1 += d[2][i]*(d[1][4010]-d[1][i]);
      }
      if(s1[i]=='G'){
        ans1 += d[0][i]*(d[2][4010]-d[2][i]);
        ans1 += d[2][i]*(d[0][4010]-d[0][i]);
      }
      if(s1[i]=='B'){
        ans1 += d[1][i]*(d[0][4010]-d[0][i]);
        ans1 += d[0][i]*(d[1][4010]-d[1][i]);
      }
    }
    ll ans2 = 0;
    rep(i,n,n+n){
      rep(j,1,n){
        if(s[i-j]=='x')continue;
        if(s[i+j]=='z')continue;
        if(s[i]!=s[i-j]&&s[i]!=s[i+j]&&s[i-j]!=s[i+j]){
          ans2++;
        }
      }
    }
    cout << ans1-ans2 << endl;
    return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

bool ABC(int n) {
	if (0 < n && n < 13) {
		return true;
	}
	else {
		return false;
	}
}

int main(void) {
	rapid_pleaseAC_fast;

	double n, m;
	cin >> n >> m;
	vdouble a(n);
	double sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	double cnt = 0;
	double x = sum / (4 * m);
	rep(i, n) {
		if (a[i] >= x) {
			cnt++;
		}
	}
	Yes(cnt >= m);

	please AC;
}
//参考：---

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
	int n;
	
	cin >> n;
	
	while (n>0) {
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double xp = ((y1 - y3) * (y1 * y1 - y2 * y2 + x1 * x1 - x2 * x2) - (y1 - y2) * (y1 * y1 - y3 * y3 + x1 * x1 - x3 * x3)) / (2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3));
        double yp = ((x1 - x3) * (x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2) - (x1 - x2) * (x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3)) / (2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3));
		double r = sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
		
		printf("%.3f %.3f %.3f\n", xp, yp, r);
		
		n--;
	}
	
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    vector<string> s(2);
    repeat(i, 2) cin >> s[i];
    if (s[0].size() != s[1].size()) {
        cout << (s[0].size() < s[1].size() ? "LESS" : "GREATER") << endl;
    }
    else if (s[0] == s[1]) {
        cout << "EQUAL" << endl;
    }
    else {
        repeat(i, (int)s[0].size()) {
            if (s[0][i] < s[1][i]) {
                cout << "LESS" << endl;
                break;
            }
            else if (s[0][i] > s[1][i]) {
                cout << "GREATER" << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc172/tasks/abc172_d
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> s;
  cin >> t;
  SORT(s);
  SORTR(t);
  a = s.size();
  b = t.size();
  rep(i, 0, a)
  {
    if (s[i] < t[i])
    {
      cout << "Yes" << endl;
      return 0;
    }
    else if (s[i] > t[i])
    {
      cout << "No" << endl;
      return 0;
    }
  }
  if (a < b)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
use whiteread::parse_line;

fn main() {
    let (n, m, c): (usize, usize, i32) = parse_line().unwrap();
    let b: Vec<i32> = parse_line().unwrap();
    let mut a: Vec<Vec<i32>> = Vec::with_capacity(n);
    for _ in 0..n {
        a.push(parse_line().unwrap());
    }
    let mut cnt = 0;
    for i in 0..n {
        let mut ans = 0;
        for k in 0..m {
            ans += a[i][k] * b[k];
        }
        ans += c;
        if ans > 0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


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

int main(){
  int n,i;
  cin >> n;
  vector<int> h(n+1),ans(n+1);
  for(i=0; i<n; i++){
    cin >> h[i+1];
  }
  ans[2]=abs(h[2]-h[1]);
  for(i=3; i<=n; i++){
    ans[i]=min(ans[i-1]+abs(h[i]-h[i-1]),ans[i-2]+abs(h[i]-h[i-2]));
  }
  cout << ans[n] << endl;
}
               

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(1e9);
const int mod = inf + 7;
using namespace std;
const int N = 5e5 + 555;
void solve()
{
	string s;
	cin >> s;
	int cnt = 0;

	char last = 'A';
	ll sum = 0;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'B') {
			cnt++;
		}
		if(s[i] == 'W'){
			sum += cnt;
		} 
	}
	cout << sum;
}

int main()
{
	Red;
	solve();
	return 0;
}

Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;
const long long MAX = 1000000000000001;
long long ruijyo(long long a, long long n){
  long long res = 1;
  while (n){
    if (n & 1) res = res * a;
    a = a*a;
    n = n >> 1;
  }
  return res;
}

int main(){
  string alph = "abcdefghijklmnopqrstuvwxyz";
  vector<long long> namesum;
  namesum.push_back(0);
  int i = 0;
  while (namesum.at(i) <= MAX) {
    namesum.push_back(namesum.at(i) * 26 + 26);
    i++;
  }
  
  long long N; cin >> N;
  for (int k = 0; k < namesum.size(); k++){
    if (namesum.at(k) < N && N <= namesum.at(k+1)){
      N = N-namesum.at(k);
      for (int i = k; i >= 0; i--){
        cout << alph.at((N-1)/ruijyo(26,i));
        N = N - ((N-1)/ruijyo(26,i))*ruijyo(26,i);
      }
      break;
    }
  }
  cout << endl;
}


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

int main()
{
    string a,b;
    cin>>a>>b;
    if((a=="1"||a=="2")&&(b=="2"||b=="1")){
        cout<<"3"<<endl;
    }
    else if((a=="1"||a=="3")&&(b=="3"||b=="1")){
        cout<<"2"<<endl;
    }
    else if((a=="2"||a=="3")&&(b=="3"||b=="2"))
{
        cout<<"1"<<endl;

}}


Measured memory_bytes: 3564
#include<iostream>
#include<string>
using namespace std;
#define MOD 1000000007

int N;
string S1, S2;

long long dp[52][3][3];
long long solve(int now, int up, int down) {
	if (now == N) return 1;
	if (dp[now][up][down] != -1) return dp[now][up][down];
	if (S1[now] == S2[now]) {
		if (up != down)
			return dp[now][up][down] = ( solve(now + 1, (up + down) * 2 % 3, (up + down) * 2 % 3) )%MOD;
		else
			return dp[now][up][down] = ( solve(now + 1, (up + 1) % 3, (up + 1) % 3)
				+ solve(now + 1, (up + 2) % 3, (up + 2) % 3) )%MOD;
	}
	else {
		if (up == down)
			return dp[now][up][down] = (solve(now + 2, (up + 2) % 3, (down + 1) % 3) + solve(now + 2, (up + 1) % 3, (down + 2) % 3)) % MOD;
		else
			return dp[now][up][down] = (solve(now + 2, down, up) + solve(now + 2, down, (up + down) * 2 % 3) + solve(now + 2, (up + down) * 2 % 3, up)) % MOD;
	}
}

int main() {
	cin >> N;
	cin >> S1 >> S2;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				dp[i][j][k] = -1;
			}
		}
	}

	if (S1[0] == S2[0]) {
		cout << (solve(1, 0, 0) + solve(1, 1, 1) + solve(1, 2, 2)) % MOD << endl;
	}
	else {
		cout << (solve(2, 0, 1) + solve(2, 1, 2) + solve(2, 2, 0)
			+ solve(2, 1, 0) + solve(2, 2, 1) + solve(2, 0, 2)) % MOD << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int linearsearch(int ,int , int *);
int main(){
  int ans=0,l,kazu1,stuff1[10000],kazu2,stuff2,i,j,k;
  scanf("%d",&kazu1);
  for(i=0;i<kazu1;i++){
    scanf("%d",&stuff1[i]);
  }
  scanf("%d",&kazu2);
  for(j=0;j<kazu2;j++){
    scanf("%d",&stuff2);
  l=linearsearch(stuff2,kazu1,stuff1);
  if(l==1){ans++;}
  }
  printf("%d\n",ans);
  return 0;
}


int linearsearch(int stuff2,int kazu1,int *stuff1){
  int i,j,k;
    i=0;
  while(1){
    if(stuff1[i]==stuff2){return 1;break;}
    else if(i==kazu1-1){return 0;break;}
    else {i++;}
  }
}

  
    



Measured memory_bytes: 2108
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long k = sc.nextLong();
    if(a >= k){
      a-=k;
    } else if(a<k && a+b >= k){
      b-=(k-a);
      a=0;
    } else if(a+b < k){
      a=0;
      b=0;
    }
    System.out.println(a+" "+b);
  }
}

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

int main(){
    int N;cin>>N;
    vector<int> vec;
    for(int a = 0;a < N;a++){
        int b;cin >> b;
        vec.push_back(b);
    }
    vector<int> b1,b2;
    for(int a= 0;a < N;a++){
        int b;cin >> b;
        if(vec.at(a) == 0)b1.push_back(b);
        if(vec.at(a) == 1)b2.push_back(b);
    }
    if(b1.empty() || b2.empty()){
        cout<<0<<endl;
    }else{
        cout<<*min_element(b1.begin(),b1.end())+*min_element(b2.begin(),b2.end())<<endl;
    }
}
//2t+2



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const signed INF_=1001001001; const int INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int I=IN,O=IN,T=IN,J=IN,L=IN,S=IN,Z=IN;
    int ans=0;
    {
        int tmp=O;
        if(I>0 && J>0 && L>0) tmp+=3;
        tmp+=(J-1)/2*2;
        tmp+=(L-1)/2*2;
        tmp+=(I-1)/2*2;
        chmax(ans,tmp);
    }
    {
        int tmp=O;
        tmp+=J/2*2;
        tmp+=L/2*2;
        tmp+=I/2*2;
        chmax(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		String str=input.readLine();
		double r=Double.parseDouble(str);
		System.out.println((String.format("%.6f",r*r*Math.PI))+" "+(String.format("%.6f",r*2*Math.PI)));
	}
}

Measured memory_bytes: 24652
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a, b, k;
    cin  >> a >> b >> k;
    ll a_end, b_end;

    a_end = max((ll)0, a-k);
    b_end = a < k ? max((ll)0, b - (k - a)) : b;

    cout << a_end << " " << b_end << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
S = input()
ans = [0] * len(S)
cnt = 0
for _ in range(2):
  for i in range(len(S)):
    if S[i] == "R":
      cnt += 1
    else:
      ans[i] += cnt // 2
      ans[i-1] += -(-cnt // 2)
      cnt = 0
  ans = ans[::-1]
  S = list(S[::-1])
  for i in range(len(S)):
    if S[i] == "R":
      S[i] = "L"
    else:
      S[i] = "R"
print(*ans)

Measured memory_bytes: 6992
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 60;
int a[maxn];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", a + i);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			ans += a[i] * a[j];
		}
	}
	printf("%d", ans);
}

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

int main(){
  int n; cin>>n;
  bool flag=false;
  for(int i=0;i<n;i++){
    char c; cin>>c;
    if(c=='Y')flag=true;
  }
  if(flag)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}

Measured memory_bytes: 256
let () =
  let (m1, d1) = Scanf.sscanf (input_line stdin) "%d %d" (fun a b -> (a, b)) in
  let (m2, d2) = Scanf.sscanf (input_line stdin) "%d %d" (fun a b -> (a, b)) in
  let ans = if m1 <> m2 then 1 else 0
  in
  print_int ans;
  print_newline ()


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

public class Main {
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String[] word = br.readLine().split("\\s+");
		long[] A = new long[N];
		for(int i=0;i<N;i++){
			A[i] = Long.parseLong(word[i]);
		}
		long sum   = 0;
		for( int  i = 0;i<N;i++){
			for(int j=i+1;j<N;j++){
				sum += A[i] * A[j];
			}
		}
		System.out.println(sum);
		
	}
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct UnionFind{
	vi data;
	UnionFind(int n):data(n,-1){}
	int Find(int i){
		return data[i]<0?i:(data[i]=Find(data[i]));
	}
	bool Unite(int a,int b){
		a=Find(a),b=Find(b);
		if(a==b) return false;
		if(-data[a]<-data[b]) swap(a,b);
		data[a]+=data[b];
		data[b]=a;
		return true;
	}
	int Size(int i){
		return -data[Find(i)];
	}
};

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int s,int d,int w):src(s),dst(d),weight(w){}
};
typedef vector<vector<Edge>> Graph;
bool operator<(const Edge& a,const Edge& b){return a.weight<b.weight;}
bool operator>(const Edge& a,const Edge& b){return a.weight>b.weight;}

void solve(int n,vector<Edge> edges)
{
	int m=edges.size();
	
	int mst_weight=0;
	vi used(m);
	{ // Kruskal
		UnionFind uf(n);
		rep(i,edges.size()){
			Edge e=edges[i];
			if(uf.Unite(e.src,e.dst)){
				mst_weight+=e.weight;
				used[i]=true;
			}
		}
	}
	
	int count=0,bridge_sum=0;
	rep(i,m) if(used[i]){
		Edge candidate=edges[i];
		edges.erase(begin(edges)+i);
		
		UnionFind uf(n);
		int connected_component=n,weight=0;
		for(Edge e:edges){
			bool flg=uf.Unite(e.src,e.dst);
			if(flg) weight+=e.weight;
			connected_component-=flg;
		}
		if(connected_component>1 || weight>mst_weight){
			count++;
			bridge_sum+=candidate.weight;
		}
		
		edges.insert(begin(edges)+i,candidate);
	}
	
	cout<<count<<' '<<bridge_sum<<endl;
}

int main()
{
	for(int n,m;cin>>n>>m && n|m;){
		vector<Edge> edges;
		rep(i,m){
			int u,v,w; cin>>u>>v>>w; u--,v--;
			edges.emplace_back(u,v,w);
		}
		sort(all(edges));
		solve(n,edges);
	}
}

Measured memory_bytes: 2440
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}

map<int,int>mp;
void solve()
{
  
  int n,q;
  cin >> n;
  int a[n+1];
  
  set<int>st;
  
   int sum = 0;
  forf(i,1,n+1) 
  {
    cin >> a[i];
    st.insert(a[i]);
    mp[a[i]]++;
    sum+=a[i];
  }
  
  cin >> q;
 
  forf(i,0,q)
  {
    int a,b;
    cin >> a >> b;
    if(st.find(a)==st.end())
    {
      cout<<sum<<endl;
      continue;
    }
   
    mp[b]+=mp[a];
    sum -= a*mp[a];
    sum += b*mp[a];
    mp[a]=0;
    st.insert(b);
    st.erase(st.find(a));
    cout<<sum<<endl;
  }

}


int32_t main()
{
 // pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 12136
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll; 

int ans;
int N;
vector<int> L;

int main(void) {
    scanf("%d", &N);
    REP(i, 0, N) {
        int l;
        scanf("%d", &l);
        L.push_back(l);
    }

    sort(L.begin(), L.end());

    REP(i, 0, N-2) {
        REP(j, i+1, N-1) {
            int d = lower_bound(L.begin(), L.end(), L[i]+L[j]) - L.begin();
            ans += d - j - 1;
        }
    	
    }
   

  
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N=200010;
int cnt[N];
int n, m;
int main(){
	int t;
	// while(){
		scanf("%d",&n);
		for(int i=1; i*i<=n; ++i){
			for(int j=1; j*j<=n-i*i; ++j){
				for(int k=1; k*k<=n-i*i-j*j; ++k){
					++cnt[i*i+j*j+k*k+i*k+i*j+j*k];
				}
			}
		}
		for(int i=1; i<=n; ++i){
			cout<<cnt[i]<<endl;
		}
	// }
}

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

int main(){
  ll a; double b;
  cin >> a >> b;
  // .99999みたいな時に切り捨て型変換が行われてしまうから+0.5で補正
  int bb = b*100+0.5;
  ll ans = a*bb;
  printf("%lld\n",ans/100);
  return 0;
}

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

int main(){
  vector<string> X(3);
  for(int i=0;i<3;i++){
    cin >> X.at(i);
  }

  if((X.at(0).at(X.at(0).size()-1) == X.at(1).at(0))&&
     (X.at(1).at(X.at(1).size()-1) == X.at(2).at(0))){
    cout << "YES" <<endl;
  }else{
    cout << "NO" <<endl;
  }

}

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

int main()
{
  	long long int N,A,B,ans,temp;
  	cin>>N>>A>>B;
  	ans = A * (N/(A+B));
  	temp = (A+B) * (N/(A+B));
  	if(A < N-temp)
      	ans+=A;
  	else
      	ans += N-temp;
  	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define M 10000000
bool prime[M];
int main()
{
	
	int ans, n;

	for (int i = 2; i * i < M; i++){
		if (prime[i] == false){
			for (int j = i; j < M; j += i){
				if (!(i == j)) {
					prime[j] = true;
				}
			}
		}
	}
	while (cin >> n){
	  ans = 0;
		for (int i = 2; i <= n; i++){
			if (prime[i] == false) ans++;
	  }
		cout << ans << endl;
	}
	return (0);
}

Measured memory_bytes: 10924
n=int(input())
s=input()
k=int(input())
ans=s[k-1]
#print(ans)
if s[0]==ans:
    atai=s[0]
else:
    atai='*'
for i in range(1,n):
    if s[i]==ans:
        atai=atai+s[i]
    else:
        atai=atai+'*'

print(atai)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int A, B;
  cin >> A >> B;
  if(A>=13) cout << B << endl;
  else if(A>=6) cout << B/2 << endl;
  else cout << 0 << endl;
  
  return 0;
}


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

void solve(int delta_x){
	int number_of_rectangle, height_of_rectangle;
	int integer = 0;
	number_of_rectangle = 600 / delta_x;
	for(int i = 1;i < number_of_rectangle;i++){
		height_of_rectangle = (delta_x * i) * (delta_x * i);
		integer += height_of_rectangle * delta_x;
	}
	cout << integer << endl;
}

int main(){
	int number_of_rectangle, delta_x;
	while(cin >> delta_x){
		solve(delta_x);
	}
	return 0;
}

Measured memory_bytes: 3040
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
    int n,a[5],sum;
    char s,c[5]={'W','Y','G','P'};
    while(cin>>n&&n)
    {
        memset(a,0,sizeof(a));sum=0;
        for(int i=0;i<n*2-1;i++)
        {
            cin>>s;
            if(s!=' '){
            {if(s=='Y')
            {sum=1;
            }
            }}
        }
        if(sum==0)
        cout<<"Three"<<endl;
        else
            cout<<"Four"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define lld         double
#define pb          push_back
#define mp 			make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define PI 		   3.14159265
#define fr(i,a,b)  for(int i=a;i<b;i++)
using namespace std;



int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,t,i;
    ll x,y;
    vii v;
    cin>>n>>t;
    ll ans=INT_MAX;
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        if(y<=t)
        ans=min(ans,x);
    }
    if(ans!=INT_MAX)
    std::cout << ans << '\n';
    else
    std::cout << "TLE" << '\n';

}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.array;

bool[] make_prime_table(int n) {
  bool[] table = new bool[](n + 1);
  foreach(ref x; table) x = true;
  table[0] = table[1] = false;
  for(int i = 2; i * i < n + 1; i++) {
    if (table[i]) {
      for(int j = 2 * i; j < n + 1; j += i) table[j] = false;
    }
  }
  return table;
}

void main() {
  bool[] is_prime = make_prime_table(10000);
  for(int n; readf("%d\n", &n), n != 0;) {
    while(!is_prime[n] || !is_prime[n - 2]) n--;
    writeln(n - 2, " ", n);
  }
}

Measured memory_bytes: 1060
price, num = gets.chomp.split
unluck_num = gets.chomp.split.map(&:to_i).sort
luck_num = ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - unluck_num).sort

def like_it?(num, pay)
 num.each { |n|
  return false if pay.to_s.chars.map(&:to_i).include?( n )
 }
 return true
end

pay = price
until like_it?( unluck_num, pay)
 pay = pay.to_i + 1
end
puts pay


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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

void solve(){
	int a,b,c;
	cin >> a >> b >> c;
	if(b * c >= a) cout << "Yes\n";
	else cout << "No\n";
}

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

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0,cnt,t,m=100000000;
    int a[105];
    cin>>t>>n;
    for(int i=0;i<t;i++)
      {
          cin>>a[i];
          sum+=a[i];
          if(a[i]<m)
                m=a[i];
      }
      cnt=t;
      n=n-sum;
      cnt+=(n/m);
      cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
import sys
n = int(input())

l = []
for i in range(n):
    l.append(list(map(int, input().split())))

l = sorted(l, key= lambda x:x[1])

time = 0
for i in range(n):
    time += l[i][0]
    if time > l[i][1]:
        print("No")
        sys.exit()

print("Yes")
        
            
        
    
        




Measured memory_bytes: 55256
#include <stdio.h>
int main(void){
    // Your code here!
    char str[200001];
    char *pstr = str;
    char *first;
    
    scanf("%200000s",str);
    
    while(*pstr != 'A'){
        pstr++;
    }
    
    first = pstr;
    
    while(*pstr){
        pstr++;
    }
    
    pstr--;
    while(*pstr != 'Z'){
        pstr--;
    }
    
    printf("%d\n",pstr-first+1);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;


int main()
{
    ll N, M, R; cin >> N >> M >> R;
    vvll G(N, vll(N, inf));
    rep(i, N) G[i][i] = 0;
    vll r(R); rep(i, R) cin >> r[i], r[i]--;
    rep(i, M) {
        ll a, b, c; cin >> a >> b >> c;
        a--, b--;
        G[a][b] = c;
        G[b][a] = c;
    }

    sort(all(r));
    rep(k, N) rep(start, N) rep(end, N) G[start][end] = min(G[start][end], G[start][k] + G[k][end]);

    ll minn = inf;
    do {
        ll total = 0;
        rep(i, R-1) {
            total += G[r[i]][r[i+1]];
        }
        minn = min(minn, total);
    } while (next_permutation(all(r)));

    cout << minn << endl;
    return 0;
}

Measured memory_bytes: 512