akhauriyash/Code-Regression huggingface dataset:
s=input()
cnt=len(s)-1
ans=0
for i in range(1<<(cnt)):
    op=[""]*cnt
    for j in range(cnt):
               if((i>>j)&1):
                op[j]="+"
    formula=""
    for k,l in zip(s,op+[""]):
        formula+=(k+l)
    ans+=eval(formula)
print(ans)        
              

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll gcd(ll a, ll b)
{
	return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int main()
{
    ll t;
    cin>>t;
    ll b;
    vector<ll>an(t);
    unsigned long long int ans=1;
    int flag=1;
    for(ll i=0;i<t;i++)
    {
        cin>>an[i];
    }
    for(ll i=0;i<t;i++){
        if(an[i]==0){ans=0;flag=1;break;}
        if(ans!=ans*an[i]/an[i]||ans*an[i]>1000000000000000000){flag=0;}
        ans*=an[i];
    }
    if(flag)
    cout<<ans;
    else
    cout<<"-1";
    return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N; cin >> N;
	int four = 0, two = 0;
	rep(i, 0, N) {
		lli tmp_a; cin >> tmp_a;
		if (tmp_a % 4 == 0)four++;
		else if (tmp_a % 2 == 0)two++;
	}

	if (N <= (2 * four + two + (two == 0 ? 1 : 0)))cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  string s, t; cin >> s >> t;

  int ans = t.size();
  for(int i = 0; i <= (int)s.size() - (int)t.size(); i++){
    int res = 0;
    for(int j = 0; j < t.size(); j++){
      res += (s[i+j] != t[j]);
    }
    ans = min(ans, res);
  }
  cout << ans << endl;

  return 0;
}

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

int main() {

    int n; cin >> n;
    const int m = 10;

    vector<vector<int>> f(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> f[i][j];
        }
    }

    vector<vector<int>> p(n, vector<int>(m + 1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m + 1; j++) {
            cin >> p[i][j];
        }
    }

    int ans = -1000000000;
    for (int bit = 1; bit < (1 << m); ++bit) {
        int tmpProfit = 0;
        for (int i = 0; i < n; i++) { // shop
            int timeCnt = 0;
            for (int j = 0; j < m; ++j) { // time
                if (bit & (1 << j)) {
                    if (f[i][j] == 1) timeCnt++;
                }
            }
            tmpProfit += p[i][timeCnt];
        }
        ans = max(ans, tmpProfit);
    }

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

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

typedef long long ll;

int main(){
	ll A,B;
	cin >> A >> B;

	ll cnt = A/2;
	ll ans1 = cnt%2;
	if((A-1)%2 == 0) ans1 ^= (A-1);

	ll cnt2 = (B+1)/2;
	ll ans2 = cnt2%2;
	if(B%2 == 0) ans2 ^= B;

	cout << (ans1 ^ ans2) << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.Line2D;

public class Main{
    int n;
    int xa,ya,xb,yb;
    int xs,ys,xt,yt,o,l;
    Line2D a,b;
    Intersection[] inter;

    class Intersection{
	double dist;
	int owner,height;
	public Intersection(double dist,int owner,int height){
	    this.dist = dist;
	    this.owner = owner;
	    this.height = height;
	}
    }

    void solve(){
	Scanner sc = new Scanner(System.in);
	int T = sc.nextInt();
	while(T--!=0){
	    xa = sc.nextInt(); ya = sc.nextInt();
	    xb = sc.nextInt(); yb = sc.nextInt();
	    n = sc.nextInt();

	    inter = new Intersection[n];
	    a = new Line2D.Double(xa,ya,xb,yb);
	    for(int i=0; i<n; i++){
		xs = sc.nextInt(); ys = sc.nextInt();
		xt = sc.nextInt(); yt = sc.nextInt();
		o = sc.nextInt(); l = sc.nextInt();
		b = new Line2D.Double(xs,ys,xt,yt);
		if(a.intersectsLine(b)){
		    double d = calcDist(xa,ya,xb,yb,xs,ys,xt,yt);
		    inter[i] = new Intersection(d,o,l);
		}else{
		    inter[i] = new Intersection(-1,-1,-1);
		}
	    }

	    Comparator<Intersection> cmp = new Comparator<Intersection>(){
		public int compare(Intersection i1, Intersection i2){
		    if(i1.dist<i2.dist) return -1;
		    if(i1.dist>i2.dist) return 1;
		    return 0;
		}
	    };
	    Arrays.sort(inter, cmp);

	    int ans = Math.min(countGate(0),countGate(1));
	    
	    System.out.println(ans);
	}
    }
    
    double calcDist(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){
	double bx = x4-x3;
	double by = y4-y3;
	double d1 = Math.abs(bx*(y1-y3)-by*(x1-x3));
	double d2 = Math.abs(bx*(y2-y3)-by*(x2-x3));
	double t = d1/(d1+d2);	
	double x = x1+(x2-x1)*t;
	double y = y1+(y2-y1)*t;
	
	return (xa-x)*(xa-x)+(ya-y)*(ya-y);
    }
    
    int countGate(int nowHeight){
	int count = 0;
	for(int i=0; i<n; i++){
	    if(inter[i].dist==-1)continue;
	    if(inter[i].owner==0){
		if(inter[i].height==nowHeight){
		    nowHeight = 1 - nowHeight;
		    count++;
		}
	    }else{
		if(inter[i].height!=nowHeight){
		    nowHeight = 1 - nowHeight;
		    count++;
		}
	    }
	}
	return count;
    }
    
    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 13000
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;

int main()
{
	int n;
	cin>>n;
	int *A = new int[n+2];
	int *left = new int[n+2];
	int *right = new int[n+2];
	A[0] = 0;
	A[n+1] = 0;
	for(int i = 1; i <= n; i++){
		cin>>A[i];
	}
	left[0] = 0;
	for(int i = 1; i <= n+1; i++){
		left[i] = left[i-1] + abs(A[i-1] - A[i]);
	}
	right[n+1] = 0;
	for(int i = n; i != 0; i--){
		right[i] = right[i+1] + abs(A[i] - A[i+1]);
	}
	for(int i = 1; i <= n; i++){
		cout<< left[i-1] + right[i+1] + abs( A[i-1] - A[i+1])<<endl;
	}
	return 0;
}



Measured memory_bytes: 2432
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
const ll N = 1000000000;

#define M_PI 3.14159265358979323846264338327950288

#define ld long double

long double dist(ld a, ld b, ld x, ld y) {
    return sqrt((a - x) * (a - x) + (b - y) * (b - y));
}

void solve() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    ld angle = m / ((ld) 60) * 2 * M_PI;
    ld x = b * cos(angle), y = b * sin(angle);

    ld an = ((h * 60) + m) / ((ld) (12 * 60)) * 2 * M_PI;
    ld ax = a * cos(an), ay = a * sin(an);

    printf("%0.10Lf", dist(x, y, ax, ay));
}

int main(){
    int t;
    t = 1;
    while(t--) {
        solve();
    }
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);

  if (1e17 / d < k || x < k * d)
  {
    ll num = x / d;
    if (num % 2 == k % 2)
    {
      cout << x - num * d;
    }
    else
    {
      cout << -(x - num * d - d);
    }
    
  }
  else // (x > k * d)
  {
    cout << x - k * d;
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

char foo(char b) {
  if (b == 'A') return 'T';
  if (b == 'T') return 'A';
  if (b == 'C') return 'G';
  if (b == 'G') return 'C';
  return 'x';
}

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  char b; cin >> b;
  cout << foo(b) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//---------------------------------//

int N, Q, K;
vector<pii> g[112345];
ll d[112345];

void dfs(int u, int prev, ll cost) {
	chmin(d[u], cost);
	
	REP(i, g[u].size()) {
		int v = g[u][i].fi;
		if (v == prev) continue;
		dfs(v, u, cost + g[u][i].se);
	}
}

int main() {
	cin >> N;
	REP(i, N - 1) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		a--; b--;
		g[a].push_back(pii(b, c));
		g[b].push_back(pii(a, c));
	}
	cin >> Q >> K;
	K--;
	
	fill(d, d + 112345, INF);
	
	dfs(K, -1, 0);
	
	
	while (Q--) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--; y--;
		
		cout << d[x] + d[y] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 14720
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
	
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int res_len;
char res_sss[128];

int n;
char word[16][16], sss[128];
int len[16], sss_len;
bool used[16];
void recur(int depth)
{
	if (depth == n)
	{
		sss[sss_len] = '\0';
		if (sss_len < res_len || sss_len == res_len && strcmp(sss, res_sss) < 0)
		{
			res_len = sss_len;
			strcpy(res_sss, sss);
		}
		return;
	}

	for (int i = 0; i < n; ++i)
	{
		if (!used[i])
		{
			used[i] = true;

			for (int j = max(0, sss_len - len[i]); ; ++j)
			{
				bool diff = false;
				for (int k = 0; k < len[i] && k + j < sss_len; ++k)
				{
					if (word[i][k] != sss[k + j])
					{
						diff = true;
						break;
					}
				}
				if (!diff)
				{
					int common = sss_len - j;
					int add = len[i] - common;
					for (int k = 0; k < add; ++k)
						sss[sss_len + k] = word[i][common + k];
					sss_len += add;
					
					recur(depth + 1);

					sss_len -= add;
					break;
				}
			}

			used[i] = false;
		}
	}
}
int main()
{
	int m;
	while (scanf("%d", &m), m)
	{
		char buf[16][16];
		for (int i = 0; i < m; ++i)
			scanf("%s", buf[i]);

		bool included[16];
		for (int i = 0; i < m; ++i)
		{
			included[i] = false;
			for (int j = 0; j < m; ++j)
				included[i] |= i != j && !included[j] && strstr(buf[j], buf[i]);
		}

		n = 0;
		for (int i = 0; i < m; ++i)
		{
			if (!included[i])
			{
				strcpy(word[n], buf[i]);
				len[n] = strlen(word[n]);
				++n;
			}
		}

		res_len = 1000000;
		sss_len = 0;
		recur(0);
		puts(res_sss);
	}
}

Measured memory_bytes: 0
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

const int N=1e7+1;

vector<int>divisor(N);

void init()
{
	int i,j;
	for(i=1;i<=N;i++)
	{
		for(j=i;j<=N;j+=i)
		{
			divisor[j]++;
		}
	}
}

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n;
	cin>>n;

	init();

	int sum=0;

	for(i=1;i<=n;i++)
	{
		sum+=i*divisor[i];
	}

	cout<<sum<<endl;

}

Measured memory_bytes: 81256
N = int(input())
a = [int(n) for n in input().split(" ")]
a = [a[n] - n - 1  for n in range(N)]
a = sorted(a)
if(N%2==1):
    median = a[int(N/2)]
else:
    median = (a[int(N/2)-1] + a[int(N/2)] )/ 2
sum = 0
for i in range(N):
    sum += abs(a[i] - median)
print(int(sum))

Measured memory_bytes: 25200
n = int(input())
s = input()
ans = 0
for i in range(n-2) :
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                ans += 1
            else :
                pass
        else :
            pass
    else :
        pass
print(ans)

Measured memory_bytes: 2940
import bisect
from math import ceil
class BinaryIndexedTree():
    def __init__(self, max_n):
        self.size = max_n + 1
        self.tree = [0] * self.size
        self.depth = self.size.bit_length()
 
    def initialize(self, seq):
        for i, x in enumerate(seq[1:], 1):
            self.tree[i] += x
            j = i + (i & (-i))
            if j < self.size:
                self.tree[j] += self.tree[i]
 
    def __repr__(self):
        return self.tree.__repr__()
 
    def get_sum(self, i):
        s = 0
        while i:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i < self.size:
            self.tree[i] += x
            i += i & -i
 
    def find_kth_element(self, k):
        x, sx = 0, 0
        dx = (1 << self.depth)
        for i in range(self.depth - 1, -1, -1):
            dx = (1 << i)
            if x + dx >= self.size:
                continue
            y = x + dx
            sy = sx + self.tree[y]
            if sy < k:
                x, sx = y, sy
        return x + 1

n,d,a = map(int,input().split())
monster = sorted([list(map(int,input().split())) for _ in range(n)],key=lambda x:x[0])
x_list = [0]+[monster[i][0] for i in range(n)]+[float("inf")]
h_list = [0]+[monster[i][1] for i in range(n)]+[float("inf")]

bit = BinaryIndexedTree(n+2)
ans = 0
for i in range(1,n+1):
    hp = h_list[i] - bit.get_sum(i)
    if hp < 0:
        continue
    atk_time = ceil(hp/a)
    ans += atk_time
    top = bisect.bisect_right(x_list, x_list[i]+2*d)
    bit.add(i, atk_time*a)
    bit.add(top, -atk_time*a)

print(ans)

Measured memory_bytes: 160556
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll

int32_t main()
{
	string s;
	int n,k;
	cin>>n>>k;
	cin>>s;
	s[k-1]=tolower(s[k-1]);
	cout<<s;
	
}

Measured memory_bytes: 3604
import sys
from itertools import accumulate


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = list(accumulate(A))
    for i in range(N - 1):
        if B[N - i - 2] * 2 >= A[N - i - 1]:
            continue
        else:
            print(i + 1)
            return
    print(N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14432
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

t1, t2, a1, a2, b1, b2 = map(int, read().split())
v1 = t1 * (a1 - b1)
v2 = t2 * (a2 - b2)
if v1 > 0:
    v1 *= -1
    v2 *= -1
if v1 + v2 == 0:
    print('infinity')
elif v1 + v2 < 0:
    print(0)
else:
    s, t = divmod(-v1, v1 + v2)
    ans = s * 2
    if t != 0:
        ans += 1
    print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
 
int main() {
  int N,res=1,Hmax=0;

  cin >> N;
  vector<int> H(N);

  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
  }

  Hmax = H.at(0);
  for(int i = 1; i < N; i++)
  {
     if(H.at(0) <= H.at(i)){
       if(Hmax <= H.at(i)){
        res++;
        Hmax = H.at(i);
       }
     }
     
  }
  cout << res << endl;

}

Measured memory_bytes: 256
# B - Break Number
def main():
    n = int(input())

    if 64 <= n <= 100:
        print(64)
    elif 32 <= n <= 63:
        print(32)
    elif 16 <= n <= 31:
        print(16)
    elif 8 <= n <= 15:
        print(8)
    elif 4 <= n <=7:
        print(4)
    elif 2 <= n <= 3:
        print(2)
    else:
        print(1)

if __name__ ==  "__main__":
    main()

Measured memory_bytes: 9060
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		Combination<Integer> c = new Combination<Integer>();
		for(int i=0; i<n; i++)
			c.add(scan.nextInt());
		c.combAll();
		Iterator<ArrayList<Integer>> iter;
		iter = c.getIter();
		ArrayList<Integer> sumList = new ArrayList<Integer>();
		
		while(iter.hasNext()){
			ArrayList<Integer> tmp = iter.next();
			int sum = 0;
	       	for(int i : tmp)
				sum += i;
			sumList.add(sum);
		}
		
		int queryNum = scan.nextInt();
		for(int i=0 ;i<queryNum; i++){
			if(sumList.contains(scan.nextInt()))
				System.out.println("yes");
			else
				System.out.println("no");
		}
	}
}


class Combination<T> extends ArrayList<T>{
    int r;
    int n;
	ArrayList<T> seq = new ArrayList<T>();
	ArrayList<ArrayList<T>> seqList= new ArrayList<ArrayList<T>>();
	public void combAll(){
		for(int i = 1; i<=this.size() ;i++)
				comb(i);
	}
	public void comb(int r){
		this.r = r;
		combine(0);
	}
    public void combine(int index){
        if(seq.size() == r){
	        seqList.add(seqCopy());
        }else{
	        for ( int i = index; i< this.size()-(r-seq.size()-1); i++ ){
	             seq.add(this.get(i));
	             combine(i+1);
	             seq.remove(seq.size()-1);
	        }
        }
	}
	ArrayList<T> seqCopy(){
		ArrayList<T> tmp = new ArrayList<T>();
		for(int i=0;i<seq.size() ;i++)
			tmp.add(seq.get(i));
		return tmp;
	}
	public Iterator<ArrayList<T>> getIter(){
		return seqList.iterator();
	}
}

/*?¶????????¨????
class Combination<T> extends ArrayList<T>{
    int r;
    int n;
	ArrayList<T> elements;// = new ArrayList<T>();
	ArrayList<T> seq = new ArrayList<T>();
	//ArrayList<ArrayList<t>> iter;
    public Combination(ArrayList<T> list){
			elements = list;
    }
	public void loadElements(Scanner scan){
	//	elements = list;
	}
	public void comb(int r){
		this.r = r;
		seq = new ArrayList<T>();
		for(int i=0; i<r ;i++)
			seq.add(null);
		combine(0,0);
	}
    public void combine( int m ,int index){
        if ( m == r ){
         for ( int i=0; i<r; i++ )
             System.out.print(" " + seq.get(i));
             
        	System.out.println("");
        
        }else{
        //  for ( int i = index + 1; i<n-(r-m-1); i++ ){
        for ( int i = index; i<elements.size()-(r-m-1); i++ ){
             seq.set(m, elements.get(i));
             combine(m+1,i+1);
        }
        }
	}
}
*/

Measured memory_bytes: 218984
from collections import deque
N, M = map(int, input().split())
Graph = [[]for _ in range(N + 1)]
for i in range(M):
    a, b = map(int, input().split())
    Graph[a].append(b)
    Graph[b].append(a)

dist = [-1] * (N + 1)
dist[0] = 0
dist[1] = 0

pre = [-1] * (N + 1)
pre[0] = 0
pre[1] = 1

d = deque()
d.append(1)
while d:
    v = d.popleft()
    for i in Graph[v]:
        if dist[i] != -1:
            continue
        dist[i] = dist[v] + 1
        pre[i] = v
        d.append(i)
ans = dist[0:]
print('Yes')
for j in range(2, len(pre)):
    print(pre[j])


Measured memory_bytes: 35492
def resolve_b():
    n, k = map(int, input().split())

    def Base_10_to_n(X, n): # 再帰処理
        if (int(X / n)):
            return Base_10_to_n(int(X / n), n) + str(X % n)
        return str(X % n)

    ans = Base_10_to_n(n, k)
    print(len(str(ans)))
resolve_b()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    int minv = a[0];
    int ans = 0;
    rep(i,n) {
        if(minv>=a[i]) ans++;
        minv = min(minv,a[i]);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 1024
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const int mod = 1e9 + 7;
const int maxn = 110;
int n, k;
int a[maxn], f[maxn][100100];

void work() {
  n = read(), k = read();
  rep(i, 1, n) a[i] = read();
  rep(j, 0, k) f[0][j] = 1;
  rep(i, 1, n) {
    rep(j, 0, k) {
      if (j - a[i] - 1 < 0) f[i][j] = f[i - 1][j];
      else f[i][j] = (f[i - 1][j] - f[i - 1][j - a[i] - 1] + mod) % mod;
    }
    rep(j, 0, k) (f[i][j] += f[i][j - 1]) %= mod;
  }
  printf("%d\n", (f[n][k] - f[n][k - 1] + mod) % mod);
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 41216
int array[4][3][10];
int main() {
    int n, b, f, r, v;
    scanf("%d", &n);

    for (; n; n--) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        array[b - 1][f - 1][r - 1] += v;
    }
    
    for (b = 0; b < 4; b++) {
        for (f = 0; f < 3; f++) {
            for (r = 0; r < 10; r++) {
                printf(" %d", array[b][f][r]);
            }
            putchar('\n');
        }
        if (b == 3) break;
        puts("####################");
    }
}


Measured memory_bytes: 2028
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
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);
}

int main() {
    LL x,k,d;
    cin >> x >> k >> d;

    LL ans = 0;
    x = abs(x);

    if( x / d >= k) {
        cout << abs( x - k * d) << endl;
    } else if ( x / d < k) {
        LL u = x / d;
        ans = abs(x - d * u);
        if((k - u) % 2 == 0) {
            cout << ans << endl;
            return 0;
        } else {
            cout << min(abs(ans - d) , abs(ans + d)) << endl;
        }
    }
}

Measured memory_bytes: 3584
//C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>


#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Hang in there!

using namespace std;


int main() {
	vector<char>data(3);
	for (int i = 0; i < 3; i++) {
		cin >> data[i];
		if (data[i] == '1') {
			cout << 9;
		}
		else if (data[i] == '9') {
			cout << 1;
		}
		else {
			cout << data[i];
		}
	}
	cout << endl;
}



Measured memory_bytes: 256
import math
n,d = map(int,input().split())
li = []
li2 = []
cnt = 0
for i in range(n):
    li.append(list(map(int,input().split())))

for i in range(n):
    for j in range(n):
        if i <  j:
            x = 0
            for k in range(d):
                x += (li[i][k] - li[j][k]) ** 2
            li2.append(x)
for a in li2:
    for i in range(1,a//2 + 2):
        if a == i**2:
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException{
		int num;
		String[] str;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();

		str = br.readLine().split(" ");
		num = Integer.parseInt(str[0]);

		for(int i = 1; i <= num; i++){
			if(i % 3 == 0){
				builder.append(" " + i);
			}else if(i % 10 == 3){
				builder.append(" " + i);
			}else{
				int j = i;
				while(true){
					if(j % 10 == 3){
						builder.append(" " + i);
						break;
					}

					if(j >= 10){
						j /= 10;
					}else{
						break;
					}
				}
			}
		}
		System.out.println(builder);
		br.close();
	}
}

Measured memory_bytes: 26248
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod=1e9+7;
const int MAXN = 65;
ll x[MAXN];
vector<ll> f;//分解质因数不去重
set<ll> s1; 

ll multi(ll a, ll b, ll p) {
    ll ans = 0;
    while(b) {
        if(b&1LL) ans = (ans+a)%p;
        a = (a+a)%p;
        b >>= 1;
    }
    return ans;
}

ll qpow(ll a, ll b, ll p) {
    ll ans = 1;
    while(b) {
        if(b&1LL) ans = multi(ans, a, p);
        a = multi(a, a, p);
        b >>= 1;
    }
    return ans;
}

bool Miller_Rabin(ll n) {//判断n是否是个素数 
    if(n == 2) return true;
    int s = 20, i, t = 0;
    ll u = n-1;
    while(!(u & 1)) {
        t++;
        u >>= 1;
    }
    while(s--) {
        ll a = rand()%(n-2)+2;
        x[0] = qpow(a, u, n);
        for(i = 1; i <= t; i++) {
            x[i] = multi(x[i-1], x[i-1], n);
            if(x[i] == 1 && x[i-1] != 1 && x[i-1] != n-1) return false;
        }
        if(x[t] != 1) return false;
    }
    return true;
}

ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

ll Pollard_Rho(ll n, int c) { 
    ll i = 1, k = 2, x = rand()%(n-1)+1, y = x;
    while(true) {
        i++;
        x = (multi(x, x, n) + c)%n;
        ll p = gcd((y-x+n)%n, n);
        if(p != 1 && p != n) return p;
        if(y == x) return n;
        if(i == k) {
            y = x;
            k <<= 1;
        }
    }
}

void find(ll n, int c) {
    if(n == 1) return;
    if(Miller_Rabin(n)) {
        f.push_back(n);
        s1.insert(n);
        return;
    }
    ll p = n, k = c;
    while(p >= n) p = Pollard_Rho(p, c--);
    find(p, k);
    find(n/p, k);
}

ll dp[55][55];
ll oo(ll n,ll k){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			for(int p=1;p<i;p++){
				dp[i][j]+=dp[i-p][j-1];
			}
		}
	}
}
ll cc[100005];
void init(){
	cc[0]=1;
	for(int i=1;i<=100000;i++){
		cc[i]=cc[i-1]*i%mod;
	}
}
ll inv(ll a,ll mod){//a对于mod的逆元 
	return a==1?1:(ll)(mod-mod/a)*inv(mod%a,mod)%mod; 
}
ll C(ll n,ll m){
	ll ans;
	ans=cc[n];
	ans*=inv(cc[n-m]*cc[m]%mod,mod);
	ans%=mod;
	return ans;
}
int main(){
	init();
	dp[1][0]=1;
	dp[1][1]=1;
	oo(50,50);
	ll nn,num;
	scanf("%lld%lld",&num,&nn);
	if(nn==1)
		return 0*printf("1\n");
	find(nn,123);
	sort(f.begin(),f.end());
	ll k=1;
	ll ans=1;
	for(int i=1;i<f.size();i++){
		if(f[i]!=f[i-1]){
			ll zzz=0;
			for(int j=1;j<=min(num,k);j++){
				zzz+=C(num,j)*dp[k][j]%mod;
				zzz%=mod;
			}
			ans*=zzz;
			ans%=mod;
			k=1;
		}else{
			k++;
		}
	}
	ll zzz=0;
	for(int j=1;j<=min(num,k);j++){
		zzz+=C(num,j)*dp[k][j]%mod;
		zzz%=mod;
	}
	ans*=zzz;
	ans%=mod;
	printf("%lld\n",ans);
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class BStoneMonument {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt();
            long res = 0;
            for (int i = 1; i <= (b - a); i++) {
                res += i;
            }
            out.println(res - b);
        }

    }
}



Measured memory_bytes: 21332
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, vector<long long> a) {
  ll all = 0;
  ll ans = 1LL << 50;

  vll aa(N, 0);
  REP(i, N) {
    aa[i] = a[i];
    if (i != 0)
      aa[i] += aa[i - 1];
  }

  all = aa[N - 1];
  // ans = abs(all - 2LL * aa[0]);

  FOR(i, 0, N - 1) { ans = min(ans, abs(all - 2LL * aa[i])); }

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> a(N - 1 + 1);
  ll mi = 0;
  for (int i = 0; i <= N - 1; i++) {
    cin >> a[i];
    mi = min(mi, a[i]);
  }
  for (int i = 0; i <= N - 1; i++) {
    // a[i] -= mi;
  }
  solve(N, a);
  return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 20
i64 N;
i64 H[MAX_N];

int main() {
    cin >> N;
    i64 n;
    REP(i, N) cin >> H[i];

    i64 cnt = 0;
    i64 h = H[0];
    REP(i, N) {
        if (H[i] >= h) {
            cnt++;
            h = H[i];
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;

public class Main{
    public static long[] data = new long[50000];
    public static int[][] situ = new int[2][4];
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count=0, tens, target=0;
        long n;
        count = allsearch(101234567);
        while(sc.hasNext()){
            tens = 10000000;
            n = 0;
            target = 0;
            for(int i=0;i<2;i++){
                for(int j=0;j<4;j++){
                    Main.situ[i][j] = sc.nextInt();
                }
            }
            for(int i=0;i<2;i++){
                for(int j=0;j<4;j++){
                    target += Main.situ[i][j]*tens;
                    tens /= 10;
                }
            }
            for(int i=0;i<count;i++){
                if(target == Main.data[i]%100000000){
                    n = Main.data[i]/100000000-1;
                    break;
                }
            }
            System.out.println(n);
        }
    }

    public static int allsearch(long n){
        int p=-1, q=-1, tens, count=0 , search;
        long k=0, t=0;
        Queue<Long> queue = new LinkedList<Long>();
        queue.add(n);
        queue.add(n);
        Main.data[count]=n;
        count++;
        int[] x = {1,0,-1,0}, y = {0,1,0,-1};
        int[][] tmp = new int[2][4];
        while(!queue.isEmpty()){
            tens = 10000000;
            n = queue.remove();
            k = n/100000000;
            n -= k*100000000;
            if(n<0) break;
            for(int i=0;i<2;i++){
                for(int j=0;j<4;j++){
                    Main.situ[i][j] = (int)n/tens;
                    n -= Main.situ[i][j]*tens;
                    tens /= 10;
                }
            }
            for(int i=0;i<2;i++){
                for(int j=0;j<4;j++){
                    if(Main.situ[i][j] == 0){
                        p=i;
                        q=j;
                    }
                }
            }
            for(int xy=0;xy<4;xy++){
                search = 0;
                t = k;
                for(int i=0;i<2;i++){
                    for(int j=0;j<4;j++){
                        tmp[i][j] = Main.situ[i][j];
                    }
                }
                if(p+x[xy] >= 0 && p+x[xy] < 2 && q+y[xy]>=0 && q+y[xy]<4){
                    tmp[p][q] = tmp[p+x[xy]][q+y[xy]];
                    tmp[p+x[xy]][q+y[xy]] = 0;
                }
                n = 0;
                tens = 10000000;
                for(int i=0;i<2;i++){
                    for(int j=0;j<4;j++){
                        n += tmp[i][j]*tens;
                        tens /= 10;
                    }
                }
                for(int i=0;i<count;i++){
                    if(n == Main.data[i]%100000000) search++;
                }
                if(search == 0){
                t++;
                n += t*100000000;
                queue.add(n);
                Main.data[count]=n;
                count++;
                }
            }
        }
        return count;
    }
}


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

int gcd(int a,int b) {
  if (a%b == 0) {
    return b;
  }else if (b%a == 0) {
    return a;
  }else if (a > b) {
    return gcd(b,a%b);
  }else{
    return gcd(a,b%a);
  }
}
  
int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> W(N);
  for (int i=0; i<N; ++i) {
    cin >> V.at(i);
  }
  vector<int> A(N-1);
  vector<int> B(N-1);
  A.at(0) = V.at(0);
  for (int i=1; i<N-1; ++i) {
    A.at(i) = gcd(A.at(i-1),V.at(i));
  }
  B.at(0) = V.at(N-1);
  for (int i=1; i<N-1; ++i) {
    B.at(i) = gcd(V.at(N-i-1),B.at(i-1));
  }
  for (int i=0; i<N; ++i) {
    if (i == 0) {
      W.at(i) = B.at(N-2);
    }else if (i == N-1) {
      W.at(i) = A.at(N-2);
    }else{
      W.at(i) = gcd(A.at(i-1),B.at(N-i-2));
    }
  }
  int a = W.at(0);
  for (int i=1; i<N; ++i) {
    if (a < W.at(i)) {
      a = W.at(i);
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 1792
n = int(input())
if n%10 == 2 or n%10 == 4 or n%10 == 5 or n%10 == 7 or n%10 == 9:
    print("hon")
elif n%10 == 0 or n%10 == 1 or n%10 == 6 or n%10 == 8:
    print("pon")
else: print("bon")

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

int main(){
  int h,w,n,y,x;
  string s,t;
  cin>>h>>w>>n>>y>>x>>s>>t;
  int u=1,d=h,l=1,r=w;
  for(int i=n-1; i>=0; --i){
    if(t[i]=='U')d=min(h,d+1);
    if(t[i]=='D')u=max(1,u-1);
    if(t[i]=='L')r=min(w,r+1);
    if(t[i]=='R')l=max(1,l-1);
    if(s[i]=='U')u++;
    if(s[i]=='D')d--;
    if(s[i]=='L')l++;
    if(s[i]=='R')r--;
    if(u>d||l>r){cout<<"NO"<<endl; return 0;}
  }
  if(u<=y&&y<=d&&l<=x&&x<=r)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 3900
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PF push_front
#define PB push_back
#define VE vector<int>
#define VP vector<PA>
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
//
int N,M;
VE V[100000];
//
deque<int> que;
bool used[100000];
//
int C(int now){
  FOR(i,0,(int)V[now].SI){
    int num=V[now][i];
    if(!used[num]){
      return num;
    }
  }
  return -1;
}
//
int main(){
  cin>>N>>M;
  FOR(i,0,M){
    int A,B;
    cin>>A>>B;
    A--;B--;
    V[A].PB(B);
    V[B].PB(A);
    if(i==M-1){
      que.PF(A);
      que.PB(B);
      used[A]=true;
      used[B]=true;
    }
  }
  while(1){
    int F=C(que.front()),B=C(que.back());
    if(F==-1&&B==-1){
      cout<<que.size()<<endl;
      while(que.size()){
        cout<<que.front()+1;
        que.pop_front();
        if(que.size()){
          cout<<" ";
        }else{
          cout<<endl;
          return 0;
        }
      }
    }else if((F==B)||(F==-1)){
      que.PB(B);
      used[B]=true;
    }else if(B==-1){
      que.PF(F);
      used[F]=true;
    }else{
      que.PF(F);
      que.PB(B);
      used[F]=true;
      used[B]=true;
    }
  }
  return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    int N, D;
    cin >> N >> D;
    cout << N / (2 * D + 1) + (N%(2*D+1)?1:0) << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"reflect"
	"sort"
)

func main() {
	defer writer.Flush() // Use printf, scanf

	// CODE
	var a, b, c, k int
	scanf("%d %d %d %d\n", &a, &b, &c, &k)
	ans := a - b
	if k%2 == 1 {
		ans = b - a
	}
	if ans >= int(1E10) {
		printf("Unfair")
		return
	}
	printf("%d\n", ans)
}

// I/O {{{
var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

// }}}
// Math {{{
func maxInt(x int, y int) int {
	if x > y {
		return x
	}
	return y
}

func minInt(x int, y int) int {
	if x < y {
		return x
	}
	return y
}

// }}}
// {{{ dummy
func dummy() {
	fmt.Printf("Hello, World\n")
	fmt.Printf("%v", reflect.TypeOf(0))

	arr := []int{10, 9, 8, 7, 1}
	sort.Ints(arr)
	fmt.Println(arr)
}

// }}}
// PriorityQueue {{{
// Usage:
// type Person struct {
// 	name string
// 	age  int
// }
//
// func (p1 Person) Less(p2 interface{}) bool {
// 	return p1.age < p2.(Person).age
// }
//
// func main() {
// 	sc.Split(bufio.ScanWords)
// 	defer out.Flush() // Use printf
//
// 	// CODE
// 	q := NewPriorityQueue()
// 	q.Push(Person{name: "B", age: 11})
// 	q.Push(Person{name: "A", age: 10})
// 	q.Push(Person{name: "C", age: 12})
//
// 	for q.Len() > 0 {
// 		p := q.Pop().(Person)
// 		printf("%s %d\n", p.name, p.age)
// 	}
// }
func NewPriorityQueue() *PriorityQueue {
	q := &PriorityQueue{s: new(sorter)}
	heap.Init(q.s)
	return q
}

func (q *PriorityQueue) Pop() Comparable {
	return heap.Pop(q.s).(Comparable)
}

func (q *PriorityQueue) Top() Comparable {
	if len(*q.s) > 0 {
		return (*q.s)[0].(Comparable)
	}
	return nil
}

func (q *PriorityQueue) Fix(x Comparable, i int) {
	(*q.s)[i] = x
	heap.Fix(q.s, i)
}

func (q *PriorityQueue) Remove(i int) Comparable {
	return heap.Remove(q.s, i).(Comparable)
}

func (q *PriorityQueue) Len() int {
	return q.s.Len()
}

type Comparable interface {
	Less(other interface{}) bool
}

type sorter []Comparable

func (s *sorter) Push(x interface{}) {
	*s = append(*s, x.(Comparable))
}

func (s *sorter) Pop() interface{} {
	n := len(*s)
	if n > 0 {
		x := (*s)[n-1]
		*s = (*s)[0 : n-1]
		return x
	}
	return nil
}

func (s *sorter) Len() int {
	return len(*s)
}

func (s *sorter) Less(i, j int) bool {
	return (*s)[i].Less((*s)[j])
}

func (s *sorter) Swap(i, j int) {
	(*s)[i], (*s)[j] = (*s)[j], (*s)[i]
}

// Define priority queue struct
type PriorityQueue struct {
	s *sorter
}

func (q *PriorityQueue) Push(x Comparable) {
	heap.Push(q.s, x)
}

// }}}
// Sort {{{
// sort.Stable(IntSlice(a))
type IntSlice []int

func (a IntSlice) Len() int {
	return len(a)
}
func (a IntSlice) Less(i, j int) bool {
	return a[i] < a[j]
}
func (a IntSlice) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

// }}}


Measured memory_bytes: 640
#!/usr/bin/python

import sys

def main(argv):
    N = int(sys.stdin.readline())
    while N:
        A = map(lambda x: int(x), raw_input().split(" ", N))
        snuke = A[0]
        raccon = sum(A[1:])
        difference = abs(snuke - raccon)
        for i in xrange(1, len(A) - 1):
            snuke += A[i]
            raccon -= A[i]
            d = abs(snuke - raccon)
            if d < difference:
                difference = d
        print(difference)

        N = sys.stdin.readline()
        if N:
            N = int(N)

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 18440
// inputに入力データ全体が入る
function Main(input) {
  	var input = input.split("\n");
    //console.log(input.length);
	var people_item = input[0].split(" ");
    var array=[];
    for(var i=1; i<input.length; i++){
      if(i%2===0){
        var leng = input[i].split(" ");
        for(var j=0; j<leng.length; j++){
          array.push(leng[j]);
          } 
       }

     }
      var set = new Set(array);
      var num=0
      for(var k=1; k<=people_item[0]; k++){
        if(set.has(String(k))===false){
        num=num+1;
        }
      }
   console.log(num);
  }
    
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30268
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    int n,wt;
    cin>>n>>wt;
    vector<ll> w(n);
    vector<ll> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    } 

    ll dp[wt+1];
    memset(dp,0,sizeof(dp));

    for(int j=0;j<=n-1;j++)
    {
        for(int i=wt;i>=0;i--)
        {
            if(i>=w[j])
            {
                dp[i]=max(dp[i],dp[i-w[j]]+v[j]);
            }
           // cout<<dp[i]<<endl;
        }
       // cout<<endl;
    }

    cout<<dp[wt]<<endl;
    return 0;
}
 

Measured memory_bytes: 4412
using System;
using System.Collections.Generic;

namespace ABC134_B
{
    class Program
    {
        static void Main(string[] args) {
            
            string[] input = Console.ReadLine().Split();
            long n = long.Parse(input[0]);
            long d = long.Parse(input[1]);

            long ans = 0;
            ans = n / (2 * d + 1);
            if ((n % (2 * d + 1)) != 0) {
                ans++;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,a,b=mii()

x=n//(a+b)
y=n%(a+b)
if y>a:
    print(x*a+a)
else:
    print(x*a+y)





Measured memory_bytes: 64620
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	int a[3] = {};
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << abs(a[0] - a[2]) << endl;
	


	return 0;
}

Measured memory_bytes: 256