akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll t;
	cin >> t;
	if(t <= 999)
		cout << "ABC";
	else
		cout << "ABD";
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  int n,a,num=1,sum=0;cin>>n;
  rep(i,n){
    cin>>a;
    if(a==num)num++;
    else sum++;
  }
  cout<<(sum==n?-1:sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	a=a+b+c+d;
	cout<<a/60<<endl;
	cout<<a%60<<endl;
}

Measured memory_bytes: 3088
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>        P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// メイン
int main()
{
	string S;
	cin >> S;

	int ans = 0;
	int gCnt = 0;
	int pCnt = 0;
	REP(i, S.size()) {
		if (S[i] == 'g') {
			if (pCnt < gCnt) {
				pCnt++;
				ans++;
			} else {
				gCnt++;
			}
		} else {
			if (pCnt < gCnt) {
				pCnt++;
			} else {
				gCnt++;
				ans--;
			}
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    t = S()
    l = len(s)
    for i in range(l):
        if s == t[i:] + t[:i]:
            return 'Yes'
    return 'No'


print(main())


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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,r;
    cin >> n >> r;
    if(n>=10)
        cout << r;
    else
        cout << r+100*(10-n);
}


Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var name=RL();
            var nick=name.Substring(0, 3);
            Console.WriteLine(nick);
            Console.ReadLine();

        }

        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}

Measured memory_bytes: 25888
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

h, n = map(int, input().split())
spells = [list(map(int, input().split())) for _ in range(n)]

dp = [10** 30 for _ in range(h+1)]
dp[0] = 0
for a, b in spells:
	for i in range(h):
		dp[min(i+a, h)] = min(dp[min(i+a, h)], dp[i]+b)

print(dp[h])

Measured memory_bytes: 48348
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(int i = 0; i < x; i++)
using namespace std;
typedef long long ll;
ll MOD = (ll)1e9 + 7;
const int N = 2e4+10, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

struct Block {
    ll w, s, v;
    bool operator<(const Block &rhs) const {
        return w + s < rhs.w + rhs.s;
    }
};

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n; cin >> n;
    vector<Block> blocks(n);
    rep (i,n) cin >> blocks[i].w >> blocks[i].s >> blocks[i].v;
    sort(begin(blocks), end(blocks));
    vector<vector<ll>> dp(1005, vector<ll>(N));
    for (int i = 0; i < n; ++i) {
        for (ll tower_w = 0; tower_w < N; ++tower_w) {
            if (i == 0) {
                dp[0][tower_w] = tower_w >= blocks[0].w ? blocks[0].v : 0;
            } else {
                dp[i][tower_w] = dp[i-1][tower_w];
                if (blocks[i].w <= tower_w && blocks[i].s >= tower_w - blocks[i].w)
                    dp[i][tower_w] = max(dp[i][tower_w], dp[i-1][tower_w-blocks[i].w] + blocks[i].v);
            }
        }
    }
    ll ans = 0;
    for (int tower_w = 0; tower_w < N; ++tower_w)
        ans = max(ans, dp[n-1][tower_w]);

    cout << ans << endl;
}

Measured memory_bytes: 161280
#include <iostream>
#include <string>
using namespace std;
 
int main(){
	long long n,a,b;
  	cin >> n >> a >> b;
  	long long ans,amari,s;
  	s = n/(a+b);
  	ans = s*a + min(a,n%(a+b));
  	 cout << ans << endl;
	
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll h, w;
  cin >> h >> w;
  vector<vc> g(h, vc(w, '#'));
  rep(i, h) rep(j, w) {
    char c;
    cin >> c;
    if(c == '.') g[i][j] = '.';
  }
  vb bh(h, false), bw(w, false);
  rep(i, h) {
    bool ok = true;
    rep(j, w) if(g[i][j] == '#') ok = false;
    bh[i] = ok;
  }
  rep(j, w) {
    bool ok = true;
    rep(i, h) if(g[i][j] == '#') ok = false;
    bw[j] = ok;
  }
  rep(i, h) {
    bool ok = false;
    rep(j, w) {
      if(!bh[i] && !bw[j]) {
        cout << g[i][j];
        ok = true;
      }
    }
    if(ok) cout << '\n';
  }
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
	int n;
	cin >> n;
	vector<int> a(10, 0);
	rep(i, 0, n) {
		int x;
		cin >> x;
		if (x >= 3200) {++a[0]; continue;}
		if (x >= 2800) {++a[1]; continue;}
		if (x >= 2400) {++a[2]; continue;}
		if (x >= 2000) {++a[3]; continue;}
		if (x >= 1600) {++a[4]; continue;}
		if (x >= 1200) {++a[5]; continue;}
		if (x >= 800) {++a[6]; continue;}
		if (x >= 400) {++a[7]; continue;}
		++a[8];
	}
	int mi = 0;
	for (int i = 1; i <= 8; ++i) mi += (a[i] != 0);
	if (mi == 0) mi = 1;
	int rem = 0;
	for (int i = 1; i <= 8; ++i) rem += (a[i] == 0);
	int ma = 8 - rem + a[0];
	if (ma == 0) ma = 1;
	cout << mi << ' ' << ma << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

int main(){
    string S,T;
    cin>>S>>T;
    if(T.size()!=S.size()+1){cout<<"No";return 0;}
    if(T.size()==S.size()+1){
    rep(i,0,S.size()){
        if(T[i]!=S[i]){cout<<"No";return 0;}
    }
    cout<<"Yes";
    }
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string str;
	cin>>n>>str;
	if(n%2!=0)
		cout<<"No"<<endl;
	else
	{
		int half = n / 2;
		bool good = true;
		for(int i=0;i<half;i++)
		{
			if(str[i] == str[i+half])
				continue;
			else
			{
				good = false;
				break;
			}
		}
		if(good)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<queue>
//#include<stack>
//#include<algorithm>
#define ll long long
#define endl "\n"
using namespace std;

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    int ac=0,tle=0,wa=0,re=0;
    while(t--)
    {

        string s;
        cin>>s;
        if(s=="AC")
        {
            ac++;
        }
        if(s=="WA")
        {
            wa++;
        }
        if(s=="TLE")
        {
            tle++;
        }
        if(s=="RE")
        {
            re++;
        }

    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;


    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int t[N],x[N],y[N];
  for(int i=0;i<N;i++) cin >> t[i] >> x[i] >> y[i];

  int xnow = 0;
  int ynow = 0;
  int tnow = 0;
  for(int i=0;i<N;i++){
    int xnxt = x[i];
    int ynxt = y[i];
    int dt = t[i] - tnow;

    int dist = abs(xnow - xnxt) + abs(ynow - ynxt);
    if(dt < dist){
      cout << "No" << endl;
      return 0;
    }
    if(dt%2 != dist%2){
      cout << "No" << endl;
      return 0;
    }

    xnow = xnxt;
    ynow = ynxt;
    tnow = t[i];
  }

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


Measured memory_bytes: 1408
A, B, X = gets.chomp.split(" ").map(&:to_i)
H = X.to_f / A**2

if A * B / 2.0 > A * H
  theta = Math.atan(B**2 / (2*H*A))
else
  theta = Math.atan((2 * B - 2 * H) / A)
end
puts theta * 180 / Math::PI


Measured memory_bytes: 1788
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var ans = 0;

        var tmp = (int)Math.Ceiling((decimal)n / 1000);
        ans = 1000 * tmp - n;

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27500
#include<iostream>
#include<vector>
#include<cmath>
#include<limits>
#include<algorithm>
#include<string>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;

int gcd_three(int a,int b,int c){
	return std::gcd(std::gcd(a,b),c);
}

int main(){
    unsigned long int k,kotae=0;
	cin>>k;
	//頭わっっっっっっっっっっる
	for(int a=1;a<=k;a++){
		for(int b=1;b<=k;b++){
			for(int c=1;c<=k;c++){
				kotae+=gcd_three(a,b,c);
				//cout<<gcd_three(a,b,c)<<endl;
			}
		}
	}
	cout<<kotae<<endl;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

vector<int> uf;

int find(int a){
  if(uf[a]==a) return a;
  else return uf[a]=find(uf[a]);
}

void uni(int a,int b){
  a=find(a);
  b=find(b);
  if(a==b) return;
  uf[a]=b;
  return;
}

int main(){
  int n,m;
  cin >> n >> m;
  uf=vector<int>(n);
  for(int i=0;i<n;i++) uf[i]=i;
  vector<int> count(m+1,0);
  vector<list<int>> l(m+1);
  int k,L;
  for(int i=0;i<n;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> L;
      count[L]++;
      l[L].push_back(i);
    }
  }
  list<int>::iterator itr;
  int pre;
  for(int i=1;i<=m;i++){
    if(count[i]<=1) continue;
    itr=l[i].begin();
    pre=(*itr);
    itr++;
    for(;itr!=l[i].end();itr++){
      uni(pre,(*itr));
      pre=(*itr);
    }
  }
  int par=find(0);
  for(int i=1;i<n;i++){
    if(find(i)!=par){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int main(void){
    int W, a, b;
    scanf("%d %d %d", &W, &a, &b);
    if ((b <= a+W && b >= a)||(a <= b+W && a >= b)){
        printf("0\n");
    }else{
        printf("%d\n", abs(a+W-b)>abs(b+W-a)?abs(b+W-a):abs(a+W-b));
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  string a;
  cin >> a;
  if(a.size()%2 != 0){
    cout << "No" << endl;
    return 0;
  }
  REP(i,a.size()/2){
    if(a[2*i] != 'h'||a[2*i + 1] != 'i'){
      cout << "No" << endl;
      return 0;
    }
  }
        cout << "Yes" << endl;
}


Measured memory_bytes: 256
from collections import deque

n = int(input())
l = deque()
for _ in range(n):
    cmd = input().split()
    if cmd[0] == 'insert':
        l.appendleft(cmd[1])
    elif cmd[0] == 'delete':
        try: l.remove(cmd[1])
        except: pass
    elif cmd[0] == 'deleteFirst':
        l.popleft()
    else:
        l.pop()

print(*l)


Measured memory_bytes: 69736
#include <iostream>
#include <algorithm>

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

using namespace std;

int main(){
	int m, n;
	cin >> m >> n;
	int ans = 0;
	rep(i, m){
		int sum = 0;
		rep(j, n){
			int x;
			cin >> x;
			sum += x;
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long ll;

int MAX_N = 1e5;
vector<int> color(MAX_N + 1, -1);
vector<vector<pair<int, int> > > tree(MAX_N+1);
vector<bool> searched(MAX_N + 1);

void dfs(int oya) {
    for (pair<int, int> pir : tree[oya]) {
        int obj = pir.first; int dis = pir.second;
        if (!searched[obj]) {
            searched[obj] = true;
            if (dis % 2 == 0) {
                color[obj] = color[oya];
            } else {
                color[obj] = (color[oya] + 1) % 2;
            }
            dfs(pir.first);
        }
    }
}

int main() {
    int N; cin >> N;
    vector<bool> parent(N+1, true);
    for (int i = 0; i < N - 1; i++) {
        int u, v, w; cin >> u >> v >> w;
        tree[u].push_back({v, w});
        tree[v].push_back({u, w});
    }
    color[1] = 0; 
    searched[1] = true;
    dfs(1);
    for (int i = 1; i < N + 1; i++) {
        printf("%d\n", color[i]);
    }
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
int f[N], g[N];
int main(int argc, char const *argv[]) {
  int n = read(), m = read();
  for (int i = 1; i <= n; ++ i) {
    f[i] = 1;
  }
  g[1] = 1;
  for (int i = 1; i <= m; ++ i) {
    int x = read(), y = read();
    if (g[x]) g[y] = 1;
    if (!--f[x]) g[x] = 0;
    ++ f[y];
  }
  int ans = 0;
  for (int i = 1; i <= n; ++ i) {
    ans += g[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll, ll> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()


ll num[10000100];

int main(){
  rep(i, 10000100) num[i] = 1;
  ll N; cin >> N;
  for (ll i = 2;i <= N;i++){
    for (ll j = 1; i*j <= N; j++){
      num[i*j] += 1;
    }
  }
  ll ans = 0;
  for (ll i = 1; i<=N ; i++){
    ans += i*num[i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 81764
#include <iostream>
#include <algorithm>
#include <float.h>
#include <stdio.h>
#include <math.h>
#define REP(i,n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int i = 0, a, b, R[1000000];
    char op;

    while (true) {
        cin >> a >> op >> b;
        
        if (op == '+') R[i] = a + b;
        else if (op == '-') R[i] = a - b;
        else if (op == '*') R[i] = a * b;
        else if (op == '/') R[i] = a/b;
        else break;
        i++;

    }
      
    for (int j = 0; j < i; j++) cout << R[j] << endl;
    return 0;

}


Measured memory_bytes: 3100
#include<cstdio>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<iostream>
#include<string>
using namespace std;
int main()
{
	priority_queue<int>q;
	int m,n,op;
	long long sum=0;
	cin>>n>>m;
	for(int i=0;i<n;i++)
    {
		cin>>op;
		q.push(op);
	}
	while(m--)
	{
		op=q.top()/2;
		q.pop();
		q.push(op);
	}
	while(!q.empty())
	{
		sum+=q.top();
		q.pop();
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  bool can = true;
  rep(i,n){
    if(vec[i] % 2 == 0){
      if(vec[i] % 3 != 0 && vec[i] % 5 != 0){
        can = false;
      }
    }
  }
  if(can){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        int a, b, c, k; scanf("%d%d%d%d", &a, &b, &c, &k);
        long long ans = 0;
        ans += min(k, a);
        k -= min(k, a);
        k -= min(k, b);
        ans -= min(k, c);
        cout << ans << '\n';
    }
    return 0;
}

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

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

    string s;
    cin >> s;

    int n = (int)s.size();
    for (int i = 1; i * 2 < n; i++) {
        s[i] = s[i * 2];
    }
    s.resize((n + 1) / 2);

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    int a, b;

int N=100000000;
int s=0;
while(N--){s+=N;}

    while( scanf("%d %d", &a, &b) != EOF ){
        printf("%d\n", a + b+s-s);
    }    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
using namespace std;
int main()
{
	char ch;
	int n,i,k;
	string s;
	cin>>n>>s>>k;
	ch=s[k-1];
	for(i=0;i<n;i++)
	{
		if(ch==s[i])
		cout<<s[i];
		else
		cout<<"*";
	}
	cout<<endl;
	return 0;
}

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

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

const ll inf = (1LL<<62);

int n;
ll arr[405];
ll dp[405][405];

ll recur(int i, int j)
{
    if(j == i) return 0;
    if(j == i+1) return arr[i]+arr[j];
    if(dp[i][j] != -1) return dp[i][j];

    ll cost = inf;
    for(int k=i; k<j; k++)
    {
        cost = min(cost,recur(i,k)+recur(k+1,j));
    }
    for(int k=i; k<=j; k++)
        cost += arr[k];
    return dp[i][j] = cost;
}

int main()
{
    FASTIO
    memset(dp,-1,sizeof(dp));
    cin >> n;
    for(int i=0; i<n; i++) cin >> arr[i];
    recur(0,n-1);
    ll ans = (n > 2) ? dp[0][n-1] : arr[0]+arr[1];
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4888
from collections import deque
n,k=map(int,input().split())
p=list(map(int,input().split()))

minp=[0]*(n-k+1)
maxp=[0]*(n-k+1)
q1=deque([0])
q2=deque([0])
for i in range(1,k):
    while p[q1[-1]]>p[i]:
        q1.pop()
        if len(q1)==0:
            break
    while p[q2[-1]]<p[i]:
        q2.pop()
        if len(q2)==0:
            break
    q1.append(i)
    q2.append(i)
for i in range(n-k+1):
    minp[i]=p[q1[0]]
    maxp[i]=p[q2[0]]
    if i==n-k:
        break
    if q1[0]==i:
        q1.popleft()
    if q2[0]==i:
        q2.popleft()
    while p[q1[-1]]>p[i+k]:
        q1.pop()
        if len(q1)==0:
            break
    while p[q2[-1]]<p[i+k]:
        q2.pop()
        if len(q2)==0:
            break
    q1.append(i+k)
    q2.append(i+k)

d=[0]*n
d[0]=1
for i in range(1,n):
    if p[i]>p[i-1]:
        d[i]=d[i-1]+1
    else:
        d[i]=1

ans=int(k in d)
if d[k-1]!=k:
    ans+=1
for i in range(n-k):
    if d[i+k]>=k:
        continue
    if not (p[i]==minp[i] and p[i+k]==maxp[i+1]):
        ans+=1

print(ans)

Measured memory_bytes: 90192
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define INFINI 100000001


int main(){

char a,b;
scanf("%c %c",&a,&b);

if(a>b)printf(">");
else if(a<b)printf("<");
else printf("=");

return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main(){
 char s[101]={};
 scanf("%s",s);
 int l=strlen(s),a=0;
 for(int i=0;i<l/2;i++)
  if(s[i]!=s[l-i-1])a++;
 printf("%d\n",a);
 return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
vector<int> vis(200001,0);
vector<int> sizee(200001,0);
int dfs(int x,vector<set<int> > &adj)
{
     vis[x]=1;
     int currsize=1;
     for(auto j:adj[x])
     {
         if(vis[j]==0)
         {
             currsize+=dfs(j,adj);
         }
     }
     sizee[x]=currsize;
     return currsize;
}
int main()
{

    int n,m;
    cin>>n>>m;
    vector<set<int> > adj(n+1);
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].insert(b);
        adj[b].insert(a);
    }
    /*for(int i=1;i<=n;i++)
    {
        cout<<i<<"-> ";
        for(auto j:adj[i])
            cout<<j<<" ";
        cout<<endl;
    }*/
    int ans=0;
    for(int i=1;i<=n;i++)
    {

        if(vis[i]==0)
        {
            ans=max(ans,dfs(i,adj));
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 42224
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */



  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9;


  int main()
  {
    fast_cin();
    int N;
    cin>>N;
    vector<int>d(N);
    for(int i=0;i<N;i++)
      cin>>d[i];
    sort(d.begin(),d.end());
    cout<<d[N/2]-d[(N/2)-1];
    return 0;
  }


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define rreps(i, n) for (int i = (n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int dp[3010][3010];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  string s, t;
  cin >> s >> t;
  s += '#';
  t += '$';
  rep(i, s.size()) rep(j, t.size()) {
    amax(dp[i + 1][j], dp[i][j]);
    amax(dp[i][j + 1], dp[i][j]);
    if (s[i] == t[j]) amax(dp[i + 1][j + 1], dp[i][j] + 1);
  }
  string ans;
  int i = s.size() - 1, j = t.size() - 1;
  while (i + j) {
    int x = dp[i][j];
    if (i && dp[i - 1][j] == x) {
      i--;
    } else if (j && dp[i][j - 1] == x) {
      j--;
    } else {
      i--;
      j--;
      ans += s[i];
    }
  }
  reverse(all(ans));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35584
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)


if N % 2 == 0:
    list = A[0:N//2]
    print(sum(list) * 2 - A[0])
else:
    list = A[0:(N+1)//2]
    print(sum(list) * 2 - A[0] - A[(N+1)//2-1])


Measured memory_bytes: 31496
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n,m,c;
    cin >> n >> m >> c;
    int b[m];
    rep(i,m)cin >> b[i];
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,n){
        rep(j,m)cin >> a[i][j];
    }
    int cnt = 0;
    rep(i,n){
        int sum = c;
        rep(j,m)sum += a[i][j] * b[j];
        if(sum > 0)cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#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;

int main()
{
    int N;
    cin >> N;
    ll max = 0;
    ll n = 0;
    REP(i, N)
    {
        ll A, B;
        cin >> A >> B;
        if (max < A)
        {
            max = A;
            n = B;
        }
    }
    cout << max + n << endl;
    return 0;
}

Measured memory_bytes: 256
import math

n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]

ans = 0
for i in range(n):
    for l in range(i+1,n):
        k = 0
        for j in range(d):
            k += (x[i][j]-x[l%n][j])**2
    #    print(math.sqrt(k))
        if math.sqrt(k)%1 == 0:
            ans += 1
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 3006;

int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}

double a[MAXN];
int n;
double dp[MAXN][MAXN];

double solve(int ind, int heads, int tails){
    if(ind == n){
        if(heads > tails){
            return 1.00;
        } else {
            return 0.00;
        }
    }
    if(dp[ind][heads] != -1.0){
        return dp[ind][heads];
    }
    double z1 = a[ind] * solve(ind +1, heads+1, tails);
    double z2 = (1-a[ind]) * solve(ind +1, heads, tails+1);
    return dp[ind][heads] = z1 + z2;
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(int i= 0;i<=n+2;i++){
        for(int j =0;j<=n+2;j++){
            dp[i][j] = -1.0;
        }
    }
    for(int i= 0;i<n;i++){
        cin>>a[i];
    }
    cout<<setprecision(11)<<solve(0,0,0)<<endl;
    return 0;
}


Measured memory_bytes: 71040
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int S;
  cin >> S;
  int A = S/1000;
  int B = S/100%10;
  int C = S/10%10;
  int D = S%10;
  
  char op1, op2, op3;
  bool finish = false;
  for (int i=0; i<2; i++) {
    if (finish) break;
    for (int j=0; j<2; j++) {
      if (finish) break;
      for (int k=0; k<2; k++) {
        int ans = A;
        if (i==0) ans += B;
        else ans -= B;
        if (j==0) ans += C;
        else ans -= C;
        if (k==0) ans += D;
        else ans -= D;
        if (ans==7) {
          if (i==0) op1 = '+';
          else op1 = '-';
          if (j==0) op2 = '+';
          else op2 = '-';
          if (k==0) op3 = '+';
          else op3 = '-';
          finish = true;
          break;
        }
      }
    }
  }
        
  cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
    
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  string s, t; cin >> s >> t;
  ll result = 0;
  rep(i,N+1) {
    if (s.substr(i,N-i)==t.substr(0,N-i)) {
      result = i + N;
      break;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
def insertionSort(a):
    for i,v in enumerate(a):
        j=i-1
        while j>=0 and a[j]>v:
            a[j+1]=a[j]
            j-=1
        a[j+1]=v
        print(*a)

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

insertionSort(a)

Measured memory_bytes: 8076
n = input()

if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9":
  print("hon")
elif n[-1]=="0" or n[-1]=="1" or n[-1]=="6" or n[-1]=="8":
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9068
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x,y)

A,B,C,D = map(int, input().split())
E = lcm(C,D)
cnt_C = 0
cnt_D = 0
cnt_E = 0
if A % C == 0:
    cnt_C += 1
if A % D == 0:
    cnt_D += 1
if A % E == 0:
    cnt_E += 1

diff = B-A
cnt_C += (diff+A%C)//C
cnt_D += (diff+A%D)//D
cnt_E += (diff+A%E)//E

print(B-A+1-cnt_C-cnt_D+cnt_E)


Measured memory_bytes: 5052
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int k;
long long a[20010],b[20010];
long long cal(long long x)
{
	long long res=0;
	while (x)
	{
		res+=x%10;
		x/=10;
	}
	return res;
}
int main()
{
	int cnt=0;
	long long now=1,cur=0;
	for (int i=0;i<=15;i++)
	{
		for (int j=0;j<1000 && now*j+cur<=1e15;j++)
		{
			a[cnt]=now*j+cur;
			cnt++;
		}
		cur+=now*9;
		now*=10;
	}
	sort(a,a+cnt);
	cnt=unique(a,a+cnt)-a;
	for (int i=0;i<cnt;i++)
	{
		b[i]=cal(a[i]);
	}
	scanf("%d",&k);
	for (int i=1;i<cnt && k;i++)
	{
		bool f=true;
		for (int j=i+1;j<cnt;j++)
		{
			if (a[i]*b[j]>a[j]*b[i])
			{
				f=false;
				break;
			}
		}
		if (f)
		{
			k--;
			printf("%lld\n",a[i]);
		}
	}
    return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var w, h, x, y, r int
	fmt.Scan(&w, &h, &x, &y, &r)

	if x-r >= 0 && x+r <= w && y-r >= 0 && y+r <= h{
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}


Measured memory_bytes: 1156
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <bitset>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

typedef vector<int> Edges;
typedef vector<Edges> Graph;

int n, m;
int color[100010];
bitset<100010> ok[2];
Graph g;

bool dfs(int from, int c, int &cnt1, int &cnt2) {
  if (color[from] != -1) { return color[from] == c; }
  color[from] = c;
  if (c == 1) { cnt1++; }
  else { cnt2++; }
  bool ret = true;
  FORIT(it, g[from]) {
    int to = *it;
    ret &= dfs(to, c ^ 1, cnt1, cnt2);
  }
  return ret;
}

int main() {
  while (scanf("%d %d", &n, &m) > 0) {
    MEMSET(color, -1);
    g = Graph(n);
    REP(i, m) {
      int f, t;
      scanf("%d %d", &f, &t);
      f--; t--;
      g[f].push_back(t);
      g[t].push_back(f);
    }
    int base = 0;
    map<int, int> cnt;
    REP(i, n) {
      if (color[i] != -1) { continue; }
      int c1 = 0;
      int c2 = 0;
      if (!dfs(i, 0, c1, c2)) {
        goto ng;
      }
      base += min(c1, c2);
      if (c1 == c2) { continue; }
      cnt[max(c1, c2) - min(c1, c2)]++;
    }
    {
      ll ans = 0;
      ok[0].reset();
      ok[1].reset();
      ok[0][0] = 1;
      int prev = 0;
      int next = 1;
      FORIT(it, cnt) {
        int v = it->first;
        int c = it->second;
        REP(start, v) {
          int rest = 0;
          for (int i = start; i < n; i += v) {
            if (ok[prev][i]) {
              ok[next][i] = 1;
              rest = c;
            } else if (rest > 0) {
              ok[next][i] = 1;
              rest--;
            }
          }
        }
        swap(prev, next);
      }
      ok[0] |= ok[1];
      REP(i, n) {
        if (!ok[0][i]) { continue; }
        ll left = base + i;
        ll right = n - left;
        ans = max(ans, left * right - m);
      }
      printf("%lld\n", ans);
    }
    continue;
ng:
    puts("-1");
  }
}

Measured memory_bytes: 4616
#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>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#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++)
typedef pair<ll, ll> LP;
typedef vector<LP> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

const int mn = 1 << 18;
vector<int> loc[mn];

void solve() {
	int n; ll k; cin >> n >> k;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		loc[a[i]].push_back(i);
	}
	rep(i, mn) {
		int len = loc[i].size();
		rep(j, len)loc[i].push_back(loc[i][j] + n);
	}
	vector<int> nex(n);
	vector<int> ad(n, 0);
	rep(i, n) {
		int id = upper_bound(loc[a[i]].begin(), loc[a[i]].end(), i) - loc[a[i]].begin();
		int to = loc[a[i]][id]+1;
		ad[i] = to / n;
		nex[i] = to % n;
	}
	int num = 0;
	int cur = 0;
	while (true) {
		num += ad[cur];
		cur = nex[cur];
		if (cur == 0)break;
	}
	k %= num;
	if (k == 0) {
		cout << endl; return;
	}
	num = 0; cur = 0;
	while (num + 1 < k) {
		num += ad[cur]; cur = nex[cur];
	}
	if (num == k) {
		cout << endl; return;
	}
	vector<int> ans;
	set<int> st;
	for (int i = cur; i < n; i++) {
		if (st.count(a[i])) {
			while (ans.back() != a[i]) {
				st.erase(ans.back());
				ans.pop_back();
			}
			st.erase(a[i]); ans.pop_back();
		}
		else {
			st.insert(a[i]); ans.push_back(a[i]);
		}
	}
	rep(i, ans.size()) {
		if (i > 0)cout << " ";
		cout << ans[i];
	}
	cout << endl;
}

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


Measured memory_bytes: 26484
#include <stdio.h>
#include <stdbool.h>

int main(){
    bool on = true;
    int x[10001] = {0};
    int i = 1;
    int temp = 0;
    while(on == true){
        scanf("%d",&x[temp]);
        if(x[temp] == 0){
            on = false;
        }
        temp++;
    }
    i = 0;
    while(x[i] != 0){
        printf("Case %d: %d\n",i + 1,x[i]);
        i++;
    }
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;

  if (a%3==0 || b%3 == 0 || (a+b)%3==0) {
    cout << "Possible";
  }

  else {
    cout << "Impossible";
  }
}

Measured memory_bytes: 256
nums = int(input())
ary  = list(map(int,input().split()))
count =0
max_count = 0
ary.sort()
ary_count = [0 for i in range(100005)]
ary_count.append(0)

for i in ary:
    ary_count[i] += 1

for i in range(1,100005):
    count += ary_count[i]
    count += ary_count[i+1]
    count += ary_count[i-1]
    if count > max_count:
        max_count = count
    count = 0
print(max_count)

Measured memory_bytes: 14004
#include <iomanip>
#include <iostream>
#include <set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  rep(i, N) cin >> H[i];
  vector<set<int>> G(N);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace(b);
    G[b].emplace(a);
  }

  int answer = 0;
  for (int i = 0; i < N; ++i) {
    bool flag = true;
    for (auto nv : G[i]) {
      if (H[i] <= H[nv]) {
        flag = false;
        break;
      }
    }
    if (flag) answer++;
  }
  cout << answer << endl;
  return 0;
}


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

int main() {
    int counter[5];
    for (int i = 1; i < 5; i++) {
        counter[i] = 0;
    }
    for (int i = 0; i < 6; i++) {
        int t;
        cin >> t;
        counter[t]++;
        if (counter[t] >= 3) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char S[16];
	int i;
	int kitaeri = 0, asumisu = 0;
	if (scanf("%15s", S) != 1) return 1;
	for (i = 0; S[i] != '\0'; i++) {
		if(S[i] == 'R') kitaeri++; else kitaeri = 0;
		if (kitaeri > asumisu) asumisu = kitaeri;
	}
	printf("%d\n", asumisu);
	return 0;
}


Measured memory_bytes: 1732
// AOJ 1142 "列車の編成パートII" (ICPC国内予選 2006 Problem B)
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            Set<String> ss = new HashSet<String>();
            String s = sc.next();
            
            for (int j = 1; j < s.length(); j++) {
                String s1 = s.substring(0, j);
                String s2 = s.substring(j);
                
                StringBuffer tmp1 = new StringBuffer(s1);
                StringBuffer tmp2 = new StringBuffer(s2);
                String s1r = tmp1.reverse().toString();
                String s2r = tmp2.reverse().toString();
                
                ss.add(s1 + s2);
                ss.add(s1 + s2r);
                ss.add(s1r + s2);
                ss.add(s1r + s2r);
                ss.add(s2 + s1);
                ss.add(s2 + s1r);
                ss.add(s2r + s1);
                ss.add(s2r + s1r);
            }
            System.out.println(ss.size());
        }
    }
}

Measured memory_bytes: 54660
#include<bits/stdc++.h>                          
using namespace std;
long long a,b,k;
int main(){
	cin>>a>>b>>k;
	if(k*2>=b-a+1)
	{
		for(int i=a;i<=b;i++)
		    cout<<i<<endl;
	}
	else
	{
		for(int i=a;i<=a+k-1;i++)
		    cout<<i<<endl;
		for(int i=b-k+1;i<=b;i++)
		    cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string b;
  cin>>b;
  if(b=="A"){
    cout<<"T"<<endl;
  }else if(b=="T"){
    cout<<"A"<<endl;
  }else if(b=="C"){
    cout<<"G"<<endl;
  }else if(b=="G"){
    cout<<"C"<<endl;
  }
}




Measured memory_bytes: 256
import java.util.Scanner;

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

    while (in.hasNext()){
      int N = in.nextInt();
      int min = Integer.MAX_VALUE;
      int max = Integer.MIN_VALUE;

      for (int i = 0; i < N; ++i) {
        int a = in.nextInt();
        min = Math.min(min, a);
        max = Math.max(max, a);
      }

      System.out.println(max - min);
    }
  }
}

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

int main() {
    int a, b, k; cin >> a >> b >> k;
    if (b < a) swap(a, b);
    int cnt = 0;
    for (int i = a; 1 <= i; i--) {
        if (a%i == 0 && b%i == 0) {
            cnt++;
            if (cnt == k) {
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, m;
    string s[100], t[100];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> s[i];
    cin >> m;
    for (int i = 0; i < m; i++)
        cin >> t[i];

    int mx = 0;
    for (int i = 0; i < n; i++)
    {
        int tmp = 0;
        for (int j = 0; j < n; j++)
        {
            if (s[i] == s[j])
                tmp++;
        }
        for (int j = 0; j < m; j++)
            if (s[i] == t[j])
                tmp--;
        mx = max(mx, tmp);
    }
    cout << mx << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

char ca[333][333];
int num[633][333];
int n,m;
const int B=305;
void init(int pos){
	memset(num,0,sizeof(num));
	int i,j;
	for(i=-n;i<n;i++){
		for(j=0;j<n;j++){
			num[i+B][j+1]=num[i+B][j];
			if(i+j<0 || i+j>=n)continue;
			if(ca[j][pos]==ca[i+j][pos+1])num[i+B][j+1]++;
		}
	}
}
int check(int a,int b){
	int dis=a-b+B;
	int s=num[dis][n-a]-num[dis][0];
	return s;
}

LL dp[333][333];

int main(){
	int i,j,k;
	LL a,b,c;
	LL s=0;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>ca[i];
	}
	for(i=0;i<m-1;i++){
		init(i);
		for(j=0;j<=n;j++){
			for(k=0;k<=n;k++)dp[j][k]=1e9;
		}
		dp[0][0]=0;
		for(j=0;j<n;j++){
			for(k=0;k<n;k++){
				dp[j+1][k]=min(dp[j][k]+check(j,k),dp[j+1][k]);
				dp[j][k+1]=min(dp[j][k]+check(j,k),dp[j][k+1]);
			}
		}
		a=1e9;
		for(j=0;j<n;j++){
			a=min(a,dp[j][n]);
			a=min(a,dp[n][j]);
		}
		s+=a;
	}
	cout<<s<<endl;
}

Measured memory_bytes: 1920
# 2019/09/07
# AtCoder Beginner Contest 140 - B

# Input
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.append(-999)

# Calc
sum = 0
for i in range(n):
    sum = sum + b[a[i]-1]
    if (a[i+1] - a[i]) == 1:
        sum = sum + c[a[i]-1]

ans = sum
# Output
print(ans)


Measured memory_bytes: 3064