akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,k;cin >> n >> k;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    vector<int> t = {0};
    rep(i,n){
        t.push_back(a[t.back()]);
    }
    int J;
    for(J = 0;t[J] != t.back();J++);
    int T = t.size() - J-1;
    //trace(t,T);
    if(k < J){
        cout << t[k] + 1 << endl;
        return 0;
    }
    k -= J;
    k %= T;
    cout << t[k + J] +1 << endl;

    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll big = 1000000007;
const ll big2 = 1000000009;

ll n,m,k,T,q;


int main() {

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d;

    cin >>n >> a >> b;
    if((a%2 != b%2)){
        cout << "Borys\n";
    }
    else{
        cout << "Alice\n";
    }

    return 0;
}


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

using namespace std;


signed main(){

    
    int a,b;
    cin >> a >> b;
    
    int max=0,min=0;
    
    max = b+a-1;
    min = b-a+1;
    
    if(max>1000000){
        max=1000000;
    }
    if(min < -1000000){
        min = -1000000;
    }

    
    for(int i = min; i <= max ; i++){
        cout << i ;
        cout << " ";
    }

 }


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    ll n, m;
    cin >> n >> m;

    ll first, second;

    set<ll>oneNeighbors;
    set<ll>nNeighbors;

    REP(i, m){
        cin >> first >> second;
        if (first == 1) oneNeighbors.insert(second);
        if (second == n) nNeighbors.insert(first);
    }
    set<ll> intersect;
    set_intersection(nNeighbors.begin(),nNeighbors.end(),oneNeighbors.begin(),oneNeighbors.end(),
                  std::inserter(intersect,intersect.begin()));
    
    if (intersect.empty()){
        cout << "IMPOSSIBLE" << endl;
    }
    else{
        cout << "POSSIBLE" << endl;
    }
    
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N;
vector<string> ans;

void dfs(string s, char nxt) {
    if (s.length() == N) {
        ans.push_back(s);
        return;
    }
    s.push_back(nxt);
    dfs(s, nxt + 1);
    s.pop_back();

    REP(i, s.length()) {
        s.push_back(s[i]);
        dfs(s, nxt);
        s.pop_back();
    }
}

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

    cin >> N;
    ans.clear();
    dfs("", 'a');

    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    REP(i, ans.size()) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 252512
from itertools import accumulate
n,q=map(int,input().split())
*s,=input()
l=[0]*q
r=[0]*q
for i in range(q):
    l[i],r[i]=map(int,input().split())
a=[0]*n
for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        a[i]=1
b=[0]+list(accumulate(a))
for i in range(q):
    print(b[r[i]-1]-b[l[i]-1])

Measured memory_bytes: 17312
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

// 1つ使うとA-1口増える
int main() {
  int a, b;
  cin >> a >> b;
  int x = b - 1, y = a - 1;
  cout << (x + y - 1) / y << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    K = int(input())
    N = len(s)
    ans = set()
    for i in range(N):
        for j in range(1,K+1):
            ans.add(s[i:i+j])
    print(sorted(ans)[K-1])
if __name__ == "__main__":
    main()

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

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

  int ans = 0;
  ll mon = 100;
  
  while(mon < X){
    mon += mon/100;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	int n,k;cin>>n>>k;vector<int>p(n);
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	sort(p.begin(),p.end());
	int s=0;
	for(int i=0;i<k;i++) s+=p[i];cout<<s;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | ";
    __f(comma + 1, args...);
}
ll max(ll a, ll b) { return (a > b ? a : b); }
ll min(ll a, ll b) { return (a < b ? a : b); }
#define all(x) (x).begin(), (x).end()
void solve()
{
    ll ans = 0;
    ll n, x, t;
    cin >> n >> x >> t;
    while (n > 0)
    {
        n -= x;
        ans += t;
    }
    cout << ans << "\n";
}
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    ll t;
    // cin >> t;
    solve();
    return 0;
}


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

string s;
string t;

int main() {
    cin>>s>>t;
    int cnt=0;
    for (int i=0; i<3; i++) {
        if (s[i]==t[i]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

//NodePointer listSearch(int key){
//  /* your code */
//}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->next->prev = t->prev;
  t->prev->next = t->next;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if (t == nil) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer x = nil->next;

  for(x = nil->next; x != nil; x = x->next) {
    if (x->key == key) {
      if (x->next == nil)
        deleteLast();
      else if (x->prev == nil)
        deleteFirst();
      else 
        deleteNode(x);
      break;
    }
  }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  x->prev = nil;

  nil->next->prev = x;
  nil->next = x;

}


int main(void)
{
  int key, n, i;
  
  char com[20];
  

  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {
      insert(key);
     
    } else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key);
 
      }
   
    }
  }

  printList();
  return 0;
}




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

using namespace std;

typedef long long ll;

const int max_sum = 4e3+403;
const int mid = max_sum>>1;
const ll mod = 1e9+7;

bool buf;
int n;
ll res;
ll dp[max_sum][max_sum];
vector<pair<int, int> > inp;

int main() {

	buf = scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		int x, y;
		buf = scanf("%d %d", &x, &y);

		inp.emplace_back(x, y);
		dp[mid-x][mid-y] ++;
		dp[mid+x][mid+y] --;
	}

	for (int i = 2; i < max_sum; i++) {
		for (int j = 2; j < max_sum; j++) {
			ll c = 0;
			if (dp[i][j] < 0) {
				c = -dp[i][j];
				dp[i][j] = 0;
			}
			dp[i][j] = (dp[i][j] + dp[i-1][j] + dp[i][j-1]) % mod;

			res = (res + c*dp[i][j]) % mod;

			int i2 = i-2, j2 = j-2;
			if (!i2 or !j2) {
				dp[i2][j2] = 1; 
				continue ;
			}
			dp[i2][j2] = (dp[i2-1][j2] + dp[i2][j2-1]) % mod;
		}
	}
	for (auto pa : inp) {
		res = (res - dp[2*pa.first][2*pa.second] + mod) % mod;
	}

	printf("%lld\n", ((res&1 ? mod : 0) + res)>>1);

	return 0;
}

Measured memory_bytes: 156444
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b;
  cin>>a>>b;
  if(a <= b) a++;
  cout << a - 1 << endl;

  return 0;
}


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

long long a[100010];
long long b[100010];
long long mi = 0;

int n;

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

  for(int j = 0;j < n;j++) cin >> b[j];

  priority_queue<long long> que;

  int ans = 0;

  for(int i = 0;i < n;i++){
    long long c = a[i] - b[i];

    if(c >= 0){
      que.push(c);
    }else{
      ans++;
      mi += c;
    }
  }

  while(mi < 0 && !que.empty()){
    ans++;
    mi += que.top();
    que.pop();
  }

  if(mi >= 0){
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	string N;
	cin >> N;

	cout << (N.find('7') != string::npos ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long mod=1000000007;

int main(){
  long long N;
  cin >> N;
  string ans="";
  long long k=2,r=1;
  //int b[35]; b[0]=1;
  while(N!=0){
    if(N%k!=0){
      ans+='1';
      N-=r;
    }
    else{ans+='0';}
    k*=2; r*=-2;
  }
  if(ans=="")ans+='0';
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[7],index=1;
	for (int i=1;i<=5;i++)
	{
		cin>>a[i];
		if (a[i]==0)   index=i;
	}
	cout<<index;
	return 0;
} 

Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


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

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string S, T;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S >> T;
	cout << T << S << endl;
}







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

int main(){

  long double a,b,c;
  cin >> a >> b >> c;
  
  long double aa,bb,cc;
  long double EPS = 1e-14;
  
  aa=sqrtl(a);
  bb=sqrtl(b);
  cc=sqrtl(c);
  
  if (aa + bb < cc - EPS){
    cout << "Yes" << endl;

  }else{
    cout << "No" << endl;

  }  
  
}

Measured memory_bytes: 256
n = int(input())
W = list(map(int, input().split()))
#W.sort()
s1 = 0
s2 = 0
ans = []
for i in range(1,n+1):
    a = sum(W[0:i])
    b = sum(W[i:])
    ans.append((abs(a-b)))
    
    #print(abs(sum(W[i+1:])-sum(W[0:i+1])))
print(min(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<string> input(int n) {
    vector<string> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<string> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i];
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table.at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n, r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n) {
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  string s,t;
  cin >> s >> t;
  t.pop_back();
  sayYes(s==t);
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a * b == 15) {
        cout << "*" << endl;
    } else if (a + b == 15) {
        cout << "+" << endl;
    } else {
        cout << "x" << endl;
    }
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}



using namespace std;
int main(){
    int a,b,ab,x,y;
    cin >> a >> b >> ab >> x >>y;

    int  k = max(x,y);

    int ans = INF;

    for (int i = 0; i<=k; i++){
        int q = max(0, x-i);
        int w = max(0,y-i);

        ans = min(ans, a*q + b*w + i*ab*2 );
    }

    cout << ans <<endl;
}

Measured memory_bytes: 256
# AGC034B - ABC
def main():
    S = input().rstrip().replace("BC", "X")
    ans, cur = 0, 0
    for i in S:
        if i == "A":
            cur += 1
        elif i == "X":
            ans += cur
        else:
            cur = 0
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3500
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  double x1, y1, x2, y2;
  double r;
  cin >> x1 >> y1 >> x2 >> y2;
  r = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  printf("%.8lf\n", r);
  return 0;
}


Measured memory_bytes: 3196
/*
    学籍番号：11870277    名前   ：安江郁人
    課題   ：list4-13
    作成日  ：2018/6/15
*/

#include <stdio.h>

int main(void)
{char str[4];
  int x=0, b=0, c=0;
  
  scanf("%s", str);
 
 if(str[0]=='a')
   x=x+1;
 if (str[1]=='a')
    x=x+1;
 if (str[2]=='a')
    x=x+1;
 
  if(str[0]=='b')
   b=b+1;
 if (str[1]=='b')
    b=b+1;
 if (str[2]=='b')
    b=b+1;
 
  if(str[0]=='c')
   c=c+1;
 if (str[1]=='c')
    c=c+1;
 if (str[2]=='c')
    c=c+1;
 
 if(x==1 &&b==1&&c==1)
   printf("Yes");
 else
   printf("No");
 
  return 0;
}


Measured memory_bytes: 128
x, n = map(int, input().split())

if n == 0:
  print(x)

else:
  p = list(map(int, input().split()))

  xu = x
  uc = 0
  while xu in p:
    xu += 1
    uc += 1

  xd = x
  dc = 0
  while xd in p:
    xd -= 1
    dc += 1
  
  if uc < dc:
    print(xu)
  else:
    print(xd)    

Measured memory_bytes: 9196
#include <utility>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#define ll long long
#define rep(i,rept) for (ll i = 0; i < rept; i++)
#define Yes(b) std::cout<< (b ? "Yes" : "No")<<std::endl
#define YES(b) std::cout<< (b ? "YES" : "NO")<<std::endl
using namespace std;

int main() {
	string s,str;
	cin >> s >> str;
	if (s == str) {
		Yes(true);
		return 0;
	}
	rep(i, s.size()) {
		str.insert(str.begin(), str[s.size() - 1]);
		str.pop_back();
		if (str == s) {
			Yes(true);
			return 0;
		}
	}
	Yes(false);
	return 0;
}


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

int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int n,a,b;
	cin >> n >> a >> b;
	if((b-a)%2==0)cout << (b-a)/2;
	else{
		cout << min(a+(b-a-1)/2,(n-(a+n-b+1))/2+n-b+1);
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define int long long

using namespace std;

string S, T;

signed main()
{
    cin >> S >> T;

    int ans = 0;
    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] != T[i])
            ans++;
    }

    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    int AC=0, WA=0, TLE=0, RE=0;
    for(int i=0; i<n; i++){
        cin >> s;
        if(s.at(0)=='A') AC++;
        else if(s.at(0)=='W') WA++;
        else if(s.at(0)=='T') TLE++;
        else if(s.at(0)=='R') RE++;
    }
    
    cout << "AC x  " << AC << endl;
    cout << "WA x  " << WA << endl;
    cout << "TLE x  " << TLE << endl;
    cout << "RE x  " << RE << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        String t = in.next();
        int diffCount = 0;
        int len = s.length();
        for(int i=0; i<len; i++) {
            if(s.charAt(i) != t.charAt(i)) {
                diffCount++;
            }
        }
        System.out.println(diffCount);
    }
}


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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if ((x + r) > w || (y + r) > h) {
        cout << "No";
    }
    else if ((x - r) < 0 || (y - r) < 0) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
    
    cout << endl;
}


Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_program(s) cout << s <<endl;return 0
int kai_size = 1000001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int RE() {
	vel v(3, 2);
	return v.at(4); 
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, kai_size-1) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, kai_size) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	if (r < 0 || n < r) { return 0; }
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

int per(int a, int b) {
	int ans = a % b;
	if (ans < 0) { ans += b; }
	return ans;
}
vel uni(vel &v) {
	sor(v);
	vel ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i-1]) { ans.push_back(v[i]); }
	}
	v = ans;
	return v;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
bool is_prime(int i) {
	for (int j = 2; j*j <= i; j++) {
		if (i%j == 0) { return false; }
	}
	return true;
}
int get(int i, int j, vvel &ans) {
	int n = ans.size();
	if (i < 0 || n <= i || j < 0 || n <= j) { return 1; }
	return ans[i][j];
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
int solve(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 1) { return 1; }
	return a % b;
}
signed main() {
	make_kai();
	int n; cin >> n;
	int ans = 0;
	if (n == 2) { cout << 1 << endl; return 0; }
	int count_1 = n - 2;
	int count_2 = 0;
	while (count_1 >= 0) {
		int pl = com(count_1 + count_2, count_1);
		pl *= kai[count_1 + count_2+1]; pl %= p;
		pl *= kai[n -2- count_1 - count_2]; pl %= p;
		ans += pl;
		count_1 -= 2;
		count_2++;
	}
	ans = kai[n] - ans;
	cout << per(ans, p) << endl;
	return 0;
}


Measured memory_bytes: 15872
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        var N = int.Parse(input[0]);
        var D = int.Parse(input[1]);
        int[,] c = new int[N,D];
        for (var i = 0; i < N; i++)
        {
            string[] coords = Console.ReadLine().Split(' ');
            for (var k = 0; k < D; k++)
            {
                c[i,k] = int.Parse(coords[k]);
            }
        }
        int ans = 0;
        for (var i = 0; i < N; i++)
        {
            for (var j = i+1; j < N; j++)
            {
                int sum2 = 0;
                for (var k = 0; k < D; k++)
                {
                    sum2 += (c[i, k] - c[j, k]) * (c[i, k] - c[j, k]);
                }
                int r = (int)Math.Sqrt(sum2);
                if (r * r == sum2 || (r + 1) * (r + 1) == sum2) ans++;
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>

using namespace std;

double get_x2(double x, int r, int r2) {
	/*
	float temp = r + (r2 * 2);
	if (temp < sqrt2 * r) {
		return x;
	} else {
	*/
		return x + sqrt(pow(r2 + r, 2) - pow(r - r2, 2));
	//}
}

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

	vector<int> r(n);
	vector<double> pos(n);

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

	pos[0] = 0;
	for (int i = 1; i < n; i++) {
		double temp = 0;
		for (int j = 0; j < i; j++) {
			temp = max(temp, get_x2(pos[j], r[j], r[i]));
		}
		pos[i] = temp;
	}

	double max_r1 = pos[n - 1] + r[n -1];
	double min_r1 = pos[0] - r[0];

	for (int i = 0; i < n; i++) {
		max_r1 = max(max_r1, pos[i] + r[i]);
		min_r1 = min(min_r1, pos[i] - r[i]);
	}

	printf("%.8lf\n", max_r1 - min_r1);
}

Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main() {
//    freopen("/Users/wangjiaolv/Desktop/test/in.txt", "r", stdin);
    string S, T;
    cin >> S >> T;
    bool ok = true;
    map<char,char> ma, ima;
    for (int i = 0; i < S.size(); ++i) {
        char s = S[i], t = T[i];
        if (ma.count(s)) if (ma[s] != t) ok = false;
        if (ima.count(t)) if (ima[t] != s) ok = false;
        ma[s] = t; ima[t] = s;
    }
    if (ok) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 776
#include<stdio.h>

int main(void)
{
  int c = 0, i, j, minj, N, t;
  scanf("%d", &N);
  int A[N];
  for(i = 0; i < N; i++)
  {
    scanf("%d",&A[i]);
  }
  for(i = 0; i < N; i++)
  {
    minj = i;
    for(j = i; j < N; j++)
    {
      if(A[j] < A[minj])
        {
          minj = j;
        }
    }
      if(minj > i)
      {
        t = A[i];
        A[i] = A[minj];
        A[minj] = t;
        c++;
      }
    }
    for(i = 0; i < N - 1; i++)
    {
      printf("%d ",A[i]);
    }
  printf("%d\n%d\n",A[N - 1], c);
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31); // 2147483647

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) { return (a % b + b) % b; }

int main(){
    int n; 
    cin >> n;
    string s,t;
    cin >> s >> t;
    int mx = 0;
    rep(i,0,n){
        bool flag = false, end = true;
        int cnt = 0;
        rep(j,i,n){
            if(s[j] == t[j-i]){
                cnt++;
                flag = true;
            }
            else{
                if(flag){
                    end = false;
                    break;
                }
            }
        }
        if(end){
            mx = max(mx, cnt);
        }
    }
    cout << size(t)+size(s)-mx << endl;
    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_d
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[102][100001];
ll n=0,w=0;
ll weights[102];
ll values[102];
int main() {
    cin>>n>>w;
    memset(dp,0,sizeof(dp));
    memset(weights,0,sizeof(weights));
    memset(values,0,sizeof(values));
    for(ll i=1;i<=n;++i){
        cin>>weights[i]>>values[i];
    }
    for(ll i=1;i<=n;++i){
        for(ll j=1;j<=w;++j){
            if(j<weights[i]){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-weights[i]]+values[i]);
            }
        }
    }
    // for(ll i=0;i<=n;++i){
    //     for(ll j=0;j<=w;++j){
    //        cout<<dp[i][j]<<" ";
    //    }
    //     cout<<endl;
    // }
    // cout<<endl;
    cout<<dp[n][w]<<endl;
    return 0;
}


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

int main() {
    long n;
    cin >> n;
    auto m = n - 1;
    map<long, int> f;
    for(int i = 2; i <= m / i; i++) {
        if(m % i)
            continue;
        while(m % i == 0)
            m /= i, f[i]++;
    }
    if(m > 1)
        f[m]++;
    long r = 1;
    for(auto p : f)
        r *= p.second + 1;
    for(int i = 2; i <= n / i; i++) {
        if(n % i)
            continue;
        for(m = n; m % i == 0; m /= i)
            ;
        if(m % i == 1)
            r++;
    }
    cout << r << endl;
    return 0;
}


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


Measured memory_bytes: 2612
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#define ll long long

using namespace std;

int K,S;
int cnt=0;

bool check(int m){
    int l=0,r=K+1;
    while(r-l>=1){
        if(m==(l+r)/2){
            return true;
        }
        else if(m<(l+r)/2){
            r=((l+r)/2);
        }
        else{
            l=(l+r)/2+1;
        }
    }
    return false;
}
int main(){
    int x;
    cin >> K >> S;
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            x=S-i-j;
            if(check(x)){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{

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

        int x = scan.nextInt();
        int n =1;
        while (x != 0) {
            System.out.println("Case "+n+": " + x);
            x = scan.nextInt();
            n++;
        }
    }
}



Measured memory_bytes: 40916
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ", trim(fgets(STDIN)));
  $min = PHP_INT_MAX;
  for($i=-100; $i<=100; $i++){
      $cal = 0;
      for($j=0; $j<$n; $j++){
          $cal += ($a[$j]-$i)**2;
      }
      $min = min($min, $cal);
  }
  echo $min;

Measured memory_bytes: 4604
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        string S = ReadLine();
        int N = S.Length;
        for (int i = N-1; i >= 1; i--)
        {
            if (i % 2 != 0) continue;
            if (S.Substring(0, i / 2 - 1) == S.Substring(i / 2,i/2-1))
            {
                WriteLine(i);
                return;
            }
        }
        WriteLine(1);
    }
}


Measured memory_bytes: 25940
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{	string s;int i,a,b,mn,mx;
	cin >> a >> b;
	mn=min(a,b);mx=max(a,b);
	for(i=0;i<mx;i++)
	s+=mn+'0';
	cout << s;
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
void insertionSort(vector<int> &A, int N) {
    for (int i = 1; i < N; ++i) {
        rep(i, N) {
            if (i != N - 1) cout << A[i] << " ";
            else cout << A[i] << endl;
        }
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            --j;
        }
        A[j + 1] = v;
    }
}
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    insertionSort(A, N);
    rep(i, N) {
        if (i != N - 1) cout << A[i] << " ";
        else cout << A[i] << endl;
    }
}

















Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

ll a[2005],b[2005];
int main(){
  int n;ll x; scanf("%d%lld",&n,&x);
  REP(i,n){
    int x; scanf("%d",&x); a[i]=b[i]=x;
  }
  ll best=INF;
  REP(i,n){
    ll sum=0;
    REP(j,n) b[j]=min(b[j],a[(j-i+n)%n]),sum+=b[j];
    best=min(best,sum+i*x);
  }
  printf("%lld\n",best);
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    map<ll,ll> mp;
    for(auto a:A) mp[a]++;
    
    ll sum = accumulate(A.begin(),A.end(),0LL);
    int Q; cin >> Q;
    while(Q--){
        int B,C; cin >> B >> C;
        
        ll cnt = mp[B]; mp[B] = 0;
        sum -= B*cnt;
        mp[C] += cnt;
        sum += C*cnt;
        
        cout << sum << endl;
        
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 10120
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int  p[20];
    for(int i=0; i<n; i++)
    {
        cin >> p[i];
    }
    int a=0;
    for(int i=1; i<n-1; i++)
    {
        if(!(p[i-1]<=p[i] && p[i+1] <=p[i]) && !(p[i-1] > p[i] && p[i+1] > p[i]))
        {
            a++;
        }
    }
    cout << a << endl;
    return 0;
}

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

#define rep(n, i) for (int i = 0; i < (n); ++i)

using ll = long long;
using namespace std;

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

    int sum = 0;
    for (int a = 1; a <= k; ++a)
      for (int b = 1; b <= k; ++b)
        for (int c = 1; c <= k; ++c)
          sum += gcd(a, gcd(b, c));
    cout << sum << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double l, r;
map<char, int> lleft;
map<char, int> rright;

int main()
{
	while (cin >> l >> r)
	{
		if (l >= 1.1) lleft['A']++;
		else if (l >= 0.6) lleft['B']++;
		else if (l >= 0.2) lleft['C']++;
		else lleft['D']++;

		if (r >= 1.1) rright['A']++;
		else if (r >= 0.6) rright['B']++;
		else if (r >= 0.2) rright['C']++;
		else rright['D']++;
	}

	printf("%d %d\n", lleft['A'], rright['A']);
	printf("%d %d\n", lleft['B'], rright['B']);
	printf("%d %d\n", lleft['C'], rright['C']);
	printf("%d %d\n", lleft['D'], rright['D']);

	return 0;
}

Measured memory_bytes: 1212
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    if(n%2==0){
        cout << "0.50000000000" << endl;
    }else{
        double x;
        x = (double)(n+1)/(double)(2*n);
    printf("%.7f\n",x);
    }
    return 0;
}

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

int main() {
  
  int N, X; cin >> N >> X;
  
  int d = 0; int ans = 1;
  
  for (int i = 0; i < N; i++) {
    
    int L; cin >> L; d += L;
    
    if (d <= X) ans++; else break;
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
 int n,kk;
 ll int data[50];
 cin >> n >> kk;
 REP(i, n) cin >> data[i];
 int k = min(n, kk);
 ll int ans = -1;
 for(int a = 0; a <= k; a++){
  for(int b = 0; b <= k; b++){
    if(a + b > k) continue;
    priority_queue<ll int> pq;
    ll int sum = 0;
    for(int i = 0; i < a; i++){
      sum += data[i];
      pq.push(-1 * data[i]);
    }
    for(int i = 0; i < b; i++){
      sum += data[n-1-i];
      pq.push(-1 * data[n-1-i]);
    }
    // cout << "a : " << a << " b : " << b << endl;
    for(int i = 0; i < kk - a - b; i++){
      if(not pq.empty()){
        ll int top = pq.top();
        //cout << " top : " << top << endl;
        pq.pop();
        if(-1 * top < 0) sum -= (-1 * top);
      }
    }
    // cout << " sum : " << sum << endl;
    // cout << " --------- " << endl;
    if(a == 0 && b == 0) ans = sum;
    else ans = max(sum, ans);
  }
 } 
 cout << ans << endl;
}

Measured memory_bytes: 256