akhauriyash/Code-Regression huggingface dataset:
import math

N, X = map(int, input().split())
min = 100000000
cnt = 0
for i in range(N):
	m = int(input())
	X -= m
	cnt += 1
	if min > m:
		min = m
if X > 0 :
	cnt += math.floor(X / min)
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const ll INF = INT_MAX;


int main() {
  int n;cin >>n;
  vint a(n);
  int maxa=0,maxb=0,maa=0;
  repeat(i,n){
    cin >> a[i];
    maxa = max(maxa,a[i]);
  }
  repeat(i,n){
    if(a[i] == maxa) continue;
    int b;
    if(2*a[i]>maxa){
      b = maxa-a[i];
    }else{
      b = a[i];
    }
    if(maxb < b){
        maxb = b;
        maa = a[i];
    }
  }
  cout << maxa << " " << maa << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long int ll;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT

using namespace std;

signed main() {
  ll N, M;
  cin >> N >> M;
  ll w = 0;
  rep(i, M) {
    ll a;
    cin >> a;
    w += a;
  }
  N -= w;
  if (N >= 0) {
    cout << N << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)


void printArray(int A[], int N) {
    rep(i,N-1)
        printf("%d ", A[i]);
    printf("%d\n",A[N-1]);
}

// 昇順に並び替え後の配列および、交換回数を表示する
void bubbleSort(int A[], int N) {
    int flag = 1;  // 逆順の存在有無
    int head = 0; // 未整列の先頭
    int count = 0;

    while (flag == 1) {
        flag = 0;
        // tailは未整列の末尾
        for(int tail = N -1; tail > head ;tail--) {
            if(A[tail-1] > A[tail]) {
                flag = 1;
                count++;
                int work;
                work = A[tail]; A[tail] = A[tail-1]; A[tail-1] = work;
            }
        }
        head++;
    }
    printArray(A,N);
    printf("%d\n",count);
}


int main() {
    int N;
    int A[100];

    scanf("%d", &N);
    rep(i,N)
        scanf("%d",&A[i]);
    
    bubbleSort(A,N);
    return 0;
}


Measured memory_bytes: 2692
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [n,m,c] = nextIntArray()
    let b = nextIntArray()
    let ans = 0
    while(hasNext()){
        let a = nextIntArray()
        let total = c
        for(let i = 0; i<b.length; i++){
            total += b[i]*a[i]
        }
        if(total > 0) ans++
    }
    console.log(ans)
}
Main()



Measured memory_bytes: 29636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

string str;
int main() {
    while (cin >> str) {
        string res = "";
        for (int i = 0; i < str.size(); ++i) {
            if (str[i] != 'B') res += str[i];
            else {
                if (res.size() > 0) res.pop_back();
            }
        }
        cout << res << endl;
    }
}













Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

double pi = acos(-1);

signed main(){
	double  A,B,H,M;
	cin >> A >> B >> H >> M;
	double tyou = 6.0 * M;
	double tan = H * 30 + M / 2.0;
	double kakudo = abs(tyou - tan);
	kakudo = min(kakudo,360.0 - kakudo);
	double rad = kakudo * (pi / 180.0);
	double takasa = B * sin(rad);
	A -= B * cos(rad);
	printf("%.20lf\n",sqrt((double)takasa*takasa+A*A));

}

Measured memory_bytes: 4100
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int A,B,C,D;
    string S,T;
int main(){
    cin>>A>>B;

    if(A<=B)cout<<A;
    else cout<<A-1;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,d,aa[1100][4000],ab[1100][10],cnt=0;
pair<int,int> p[220000];
string s;
char c;
signed main(){
    cin>>n;
    if(n/100<13&&0<n/100){
        if(n%100<13&&0<n%100){
            cout<<"AMBIGUOUS";
        }else{
            cout<<"MMYY";
        }
    }else{
        if(n%100<13&&0<n%100){
            cout<<"YYMM";
        }else{
            cout<<"NA";
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			h -= a;
		}
		String ans = h <= 0 ? "Yes" : "No";
		System.out.println(ans);
		sc.close();
	}
}


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

#define pb push_back
#define ll long long int
#define mpi map<int, int>
#define vi vector<int>
#define si set<int>
#define pii pair<int, int>
#define vpi vector<pii>
#define vs vector<string>
#define pri priority_queue<int>
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define For(i, n) for (int i = 0; i < n; i++)
#define Ford(i, a, b) for (int i = a; i >= b; i--)
#define Rep(i, x, y) for (int i = x; i <= y; i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

double tick()
{
    static clock_t oldt, newt = clock();
    double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
    oldt = newt;
    return diff;
}

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

    if (b > n)
        cout << a * n / b << endl;
    else
    {
        ll k1 = a * n / b - a * (ll)(n / b);
        ll k2 = a * (b - 1) / b;
        if (k1 > k2)
            cout << k1 << endl;
        else
            cout << k2 << endl;
    }
    cerr << "execution time is: " << tick() << "\n";
}


Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
using namespace std;

const int MAX_V = 10000;

vector<int> G[MAX_V];
list<int> sorted;
bool V[MAX_V];
int v, e;
int indeg[MAX_V];

void bfs(int s) {
    queue<int> que; que.push(s);
    V[s] = true;

    while (!que.empty()) {
        int u = que.front(); que.pop();
        sorted.push_back(u);
        for (auto i = 0; i < G[u].size(); i++) {
            int ver = G[u][i]; indeg[ver]--;
            if (indeg[ver] == 0 && !V[ver]) {
                V[ver] = true;
                que.push(ver);
            }
        }
    }
}

void topologicalSort() {
    for (int i = 0; i < v; i++) {
        indeg[i] = 0;
    }

    for (int u = 0; u < v; u++) {
        for (auto i = 0; i < G[u].size(); i++) {
            int ver = G[u][i];
            indeg[ver]++;
        }
    }

    for (int u = 0; u < v; u++) {
        if (indeg[u] == 0 && !V[u]) bfs(u);
    }
}




int main(void) {
    cin >> v >> e;
    for (int i = 0; i < v; i++) {
        V[i] = false;
    }

    int s, t;
    for (int i = 0; i < e; i++) {
        cin >> s >> t;
        G[s].push_back(t);
    }

    topologicalSort();

    for (auto it = sorted.begin(); it != sorted.end(); it++) {
        cout << *it << endl;
    }
    return 0;
}

Measured memory_bytes: 2204
s = input()
num = len(s)
ans = num/2
if not ans.is_integer():
    ans = int(ans)+1

for i in range(num):
    a, b, count = s[i], [], 0
    for j in range(num):
        if s[j] != a:
            count += 1
        else:
            b.append(count)
            count = 0
        b.append(count)
    ans = min(ans, max(b))
print(int(ans))


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

template<class Type>
Type solve(Type res = Type()){
    ll A,V,B,W,T; cin >> A >> V >> B >> W >> T;
    ll D = abs(A-B);
    if(V <= W) return "NO";
    if(D <= T*(V-W)) return "YES";
    else return "NO";
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<string>() << endl;
    return 0;
}

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


int main(){
  long A, B, N, m, x;
  cin >> A >> B >> N;
  if (A==B){
    if (N>=B){
      x = B - 1;
    }else{
      x = N;
    }
    m = long(x) - A * long(x/A);
    cout << m;
    return 0;
  }
  if (N < B){
    m = long(A*N/B) - A * long(N/B);
  }else{
    x = long(N/B) * B - 1;
    m = long(A*x/B) - A * long(x/B);
  }
  cout << m;
  return 0;
}

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


int main(){
    int stack[100];
    int idx = 0;
    string input;
    int res;
    
    while(cin >> input){
        //if(input==' ')cout << "??????" << endl;
        if(input == "+"){
            stack[idx-2] = stack[idx-2] + stack[idx-1];
            idx--;
        }else if(input == "-"){
            stack[idx-2] = stack[idx-2] - stack[idx-1];
            idx--;            
        }else if(input == "*"){
            stack[idx-2] = stack[idx-2] * stack[idx-1];
            idx--;
        }else{
            stack[idx] = atoi(input.c_str());
            idx++;
        }
        
        
        
        //cout << stack[0] << " " << stack[1] << " " << stack[2] << " " << stack[3] << " " << stack[4] << endl;
        
    }
    
    
    cout << stack[0] << endl;
    return 0;

}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,k; cin >> n >> k;
  int idx = 0;
  while(n){n/=k;idx++;}
  cout << idx <<  endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,X,Y;
    cin>>n>>m>>X>>Y;
    int x_max=-100, y_min=100;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x_max<x) x_max=x;
    }
    for(int i=0;i<m;i++){
        int y;
        cin>>y;
        if(y_min>y) y_min=y;
    }
    if(x_max<y_min && x_max>X && y_min<Y)
        cout<< "No War"<< endl;
    else
        cout<< "War"<< endl;
}



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

using namespace std;

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


#define X real()
#define Y imag()
typedef complex<double> P;

int main(){
	  
	int n;
	cin>>n;
	rep(i,n){	
		double xa,ya,ra,xb,rb,yb;
		cin>>xa>>ya>>ra>>xb>>yb>>rb;
		
		P a = P(xa,ya);
		P b = P(xb,yb);
		
		double c = abs(a-b);
		
		if(abs(ra-rb)>c){
			if(ra>rb)puts("2");
			else puts("-2");
			continue;
		}
		if(ra+rb<c){
			puts("0");
			continue;
		}
		puts("1");
	}
	
}

Measured memory_bytes: 1208
#include<stdio.h>
#include<string.h>
int main(void) {
int a=0,c = 0;
char W[11], T[1001], END[] = "END_OF_TEXT";
scanf("%s", W);
while (1) {
scanf("%s", T);
if (strcmp(T, END) == 0)break;
for(a=0;T[a]!='\0';a++)if(T[a]>='A'&&T[a]<='Z')T[a]+=0x20;
if (strcmp(W, T) == 0)c++;
}
printf("%d\n", c);
return 0;
}


Measured memory_bytes: 2100
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
///////////////////////////////////////////////////////////

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

    ll k;cin >> k;
    queue<ll> Q;
    for(ll i = 1;i <= 9;i++){
        Q.push(i);
    }
    for(int i = 1;i < k;i++){
        ll x = Q.front();
        Q.pop();
        ll d = x % 10;
        x *= 10;
        if(d != 0)Q.push(x + d - 1);
        Q.push(x + d);
        if(d != 9)Q.push(x + d + 1);
    }
    cout << Q.front() << '\n';
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl

int keta(ll n){
    return (int)(log10(n)+1);
}

int main(){
    ll n;
    cin>>n;
    ll i=sqrt(n);
    while(true){
        if(n%i==0){
            break;
        }
        i--;
    }
    cout<<max(keta(i),keta(n/i))<<endl;
    
    return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
    // get values from input
    int N;
    READ(N);

    // main procedure
    if (N < 9) {
        WRITE_N(N);
        return 0;
    }

    int i = 9;
    priority_queue<ll, vector<ll>, greater<ll>> queue;
    for (ll n : {1,2,3,4,5,6,7,8,9}) {
        queue.push(n);
    }

    vector<ll> last_added(3);
    while (i < N) {
        ll base = queue.top();
        queue.pop();
        int digit0 = base % 10;
        if (digit0 == 0) {
            queue.push(base * 10);
            queue.push(base * 10 + 1);

            last_added[1] = base * 10;
            last_added[2] = base * 10 + 1;
            i += 2;
        } else if (digit0 == 9) {
            queue.push(base * 10 + 8);
            queue.push(base * 10 + 9);

            last_added[1] = base * 10 + 8;
            last_added[2] = base * 10 + 9;
            i += 2;
        } else {
            queue.push(base * 10 + digit0 - 1);
            queue.push(base * 10 + digit0);
            queue.push(base * 10 + digit0 + 1);

            last_added[0] = base * 10 + digit0 - 1;
            last_added[1] = base * 10 + digit0;
            last_added[2] = base * 10 + digit0 + 1;
            i += 3;
        }
    }
    ll ans = *(last_added.end() - (i + 1 - N));
    // output
    WRITE_N(ans);

    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int MOD = 1e9+7;
const long long INF = 1LL << 60;
const int inf = 1e9;
typedef long long ll;

int main(){
    int N, D;
    cin >> N >> D;
    int ans=0, cnt=1;
    while(1){
        if(cnt<=N){
            ans++;
            cnt += D*2+1;
            //cnt += D+1;
        }
        else{
            break;
        }

    }
    cout<<ans<<endl;
}

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

using namespace std;

int n, a[5], b[10], memo[5][260];

int dp(int pos, int mask) {
	int temp, ret = 500000000, cnt = 0, sum;
	if (pos == 3)
		return 0;
	if ((mask + 1) == (1 << n))
		return 500000000;
	if (memo[pos][mask] != -1)
		return memo[pos][mask];
	for (int i = 1; i < (1 << n); i++) {
		if (((mask & i) != mask) || (mask == i))
			continue;
		temp = mask ^ i;
		cnt = -1;
		sum = 0;
		for (int j = 0; j < n; j++)
			if (temp & (1 << j)) {
				cnt++;
				sum += b[j];
			}
		ret = min(ret, (10 * cnt) + abs(sum - a[pos]) + dp(pos + 1, i));
	}
	memo[pos][mask] = ret;
	return ret;
}

int main() {
	int ans;
	scanf("%d", &n);
	for (int i = 0; i < 3; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &b[i]);
	memset(memo, -1, sizeof memo);
	ans = dp(0, 0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int main(){
  long long mini=INF;
  long long w,h;
  cin>>h>>w;
  if(h%3==0||w%3==0){
    cout<<0<<endl;
    return 0;
  }
  long long a,b,c;
  for(int i=1;i<=w;i++){
    if(h%2==1){
      a=i*h;
      b=(w-i)*h;
      c=(w-1)*(h+h%2);
    }else{
      a=i*h;
      b=(w-i)*int(h/2);
      c=(w-i)*int(h/2);
    }
    
    mini=min(mini,max(a,max(b,c))-min(a,min(b,c)));

    if(h%2==0){
      a=i*h;
      b=(w-i)*(int(h/2)+1);
      c=(w-i)*(int(h/2)-1);
    }
    
    //cout<<a<<" "<<b<<" "<<c<<endl;
    mini=min(mini,max(a,max(b,c))-min(a,min(b,c)));
  }

  
  //cout<<"hh"<<endl;
  for(int i=1;i<h;i++){
    if(w%2==1){
      a=i*w;
      b=(h-i)*int(w/2);
      c=(h-i)*(int(w/2)+1);
    }else{
      a=i*w;
      b=(h-i)*(int(w/2)-1);
      c=(h-i)*(int(w/2)+1);
    }
    //cout<<a<<" "<<b<<" "<<c<<endl;
    mini=min(mini,max(a,max(b,c))-min(a,min(b,c)));
    if(w%2==0){
      a=i*w;
      b=(h-i)*(int(w/2));
      c=(h-i)*(int(w/2));
    }
    mini=min(mini,max(a,max(b,c))-min(a,min(b,c)));
  }
  if(w>3){
    long long s;
    s=(int(w/3)+1)*h-int(w/3)*h;
    mini=min(mini,s);
  }
  
  if(h>3){
    long long s;
    s=(int(h/3)+1)*w-int(h/3)*w;
    mini=min(mini,s);
  }
  cout<<mini<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
    ll n, p, ans = 1;
    cin >> n >> p;
    for(auto a : prime_factor(p)){
        if(a.second >= n){
            ans *= pow(a.first, a.second/n);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B;
cin>>A>>B;
if(A==B){
	cout<<"Draw"<<endl;
}
if((B>A ||B==1)&&A!=1){
	cout<<"Bob"<<endl;
}
if((A>B ||A==1)&&B!=1){
	cout<<"Alice"<<endl;
	return 0;
}
}

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

int main() {
  int n;
  cin >> n;
  unordered_set<int> a;
  bool is_duplicate = false;
  rep(i,n) {
    int b;
    cin >> b;
	auto itr = a.find(b);
    if (itr != a.end()) {
      is_duplicate = true;
      break;
    }
    a.emplace(b);
  }
  
  if (is_duplicate)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  
  return 0;
}

Measured memory_bytes: 8520
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a >= b and c >= d:
    print(b + d)
elif a >= b and  c < d:
    print(b + c)
elif a < b and c >= d:
    print(a + d)
else:
    print(a + c)

Measured memory_bytes: 3060
#include <cstdint>
#include <iostream>

using namespace std;
#define COUNTER_SIZE 100000

static uint32_t counter[COUNTER_SIZE];

int32_t main()
{
  uint32_t N;
  cin >> N;
  for(uint32_t i = 0; i < N; i++){
    uint32_t val;
    cin >> val;
    if(val > 0){
      counter[val-1]++;
    }
    counter[val]++;
    counter[val+1]++;
  }

  uint32_t max_count = 0;
  for(uint32_t i = 0; i < COUNTER_SIZE; i++){
    max_count = max(max_count, counter[i]);
  }

  cout << max_count << endl;

  return 0;
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            (long N, long M) = Slice2<long>();
            var dct = new Dictionary<long, long>();
            var graph = Enumerable.Repeat(0, (int)N).Select(_ => new List<(long to, long score)>()).ToArray();
            for (var i = 0; i < M; ++i)
            {
                (long a, long b, long c) = Slice3<long>();
                a--; b--;
                graph[a].Add((b, c));
            }
            var INI = long.MinValue / 2;
            var score = Enumerable.Repeat(INI, (int)N).ToArray();
            score[0] = 0;
            var closed = new bool[N];
            for (var r = 0; r < N; ++r)//繰り返し数
            {
                for (var i = 0; i < N; ++i)
                {
                    foreach (var e in graph[i])
                    {
                        if (score[i] != INI && score[e.to] < score[i] + e.score)
                        {
                            score[e.to] = score[i] + e.score;
                            if (N - 1 == r)
                                closed[e.to] = true;
                        }
                    }
                }
            }
            for (var r = 0; r < N; ++r)
                for (var i = 0; i < N; ++i)
                    foreach (var e in graph[i])
                        if (closed[i])
                            closed[e.to] = closed[i];
            if (closed[N - 1])
                WriteLine("inf");
            else
                WriteLine(score[N - 1]);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28832
n_str = input()
k = int(input())

def k1(n_str):
	n_str = str(int(n_str))
	n_len = len(n_str)
	return 9*(n_len-1) + int(n_str[0])

def k2(n_str):
    s = 0
    n_str = str(int(n_str))
    n_len = len(n_str)
    if n_len < 2:
        return 0
    s += k2('9'*(n_len - 1))
    s += k1('9'*(n_len - 1)) * (int(n_str[0]) - 1)
    s += k1(n_str[1:])
    return s
                      
def k3(n_str):
    s = 0
    n_str = str(int(n_str))
    n_len = len(n_str)
    if n_len < 3:
        return 0
    s += k3('9'*(n_len - 1))
    s += k2('9'*(n_len - 1)) * (int(n_str[0]) - 1)
    s += k2(n_str[1:])
    return s

if k == 1:
    print(k1(n_str))
elif k == 2:
    print(k2(n_str))
elif k == 3:
    print(k3(n_str))

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

using namespace std;

void print(vector<int> a){
    for(int i = 0; i < a.size(); i++){
        cout << a[i] << " ";
    }
    cout << endl;
}

int call(vector<int> a){
    int result = 1;
    vector<int> x(a.size());
    for(int i = 0; i < a.size(); i++) x[i] = i+1;
    while(true){
        for(int i = 0; i < a.size(); i++){
            if(x[i] != a[i]) break;
            if(i == a.size() - 1) return result;
        }
        result++;
        next_permutation(x.begin(), x.end());
    }
}

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    int av = call(a);
    int bv = call(b);
    cout << abs(av - bv) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();

        int left=0, right=2147483647;

        int l, r;
        for (int i=0; i<M; i++){
            l = sc.nextInt();
            r = sc.nextInt();
            if (l > left){
                left = l;
            }
            if (r < right){
                right = r;
            }
        }
        sc.close();

        int result=0;
        if(left <= right){
            result = right - left + 1;
        }
            
        System .out.println(result);

    }

}

Measured memory_bytes: 62924
def main():
    while True:
        a, b = map(int, input().split())
        if a == 0 and b == 0:
            break
        if a <= b:
            print(f"{a} {b}")
        else:
            print(f"{b} {a}")
    return 0


if __name__ == "__main__":
    main()


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long N) { cout << (1000 - N % 1000) % 1000 << endl; }

signed main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3764
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (s == u) a--;
  else b--;
  cout << a << " " << b << endl;
}


Measured memory_bytes: 3596
a, b = map(int, input().split())
cnt = 0
for i in range(a, b+1):
    l = []
    tmp = i
    l.append(int(tmp%10))
    tmp /= 10
    l.append(int(tmp%10))
    tmp /= 10
    l.append(int(tmp%10))
    tmp /= 10
    l.append(int(tmp%10))
    tmp /= 10
    l.append(int(tmp%10))
    if l[0] == l[4] and l[1] == l[3]:
        cnt += 1
print(cnt)

Measured memory_bytes: 41324
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200001
ll s[N << 2], t[N << 2];
vector<pair<int, int> > a[N];
void add(int x, int L, int R, int l, int r, ll c) {
    if (l <= L && R <= r) return (void)(s[x] += c, t[x] += c);
    int mid = (L + R) >> 1;
    if (l <= mid) add(x << 1, L, mid, l, r, c);
    if (r > mid) add(x << 1 | 1, mid + 1, R, l, r, c);
    s[x] = max(s[x << 1], s[x << 1 | 1]) + t[x];
}
int n, m;
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1, x, y, z; i <= m; i++) {
        scanf("%d%d%d", &x, &y, &z);
        a[y].emplace_back(x, z);
    }
    for (int i = 1; i <= n; i++) {
        add(1, 1, n, i, i, s[1]);
        for (auto &it : a[i]) add(1, 1, n, it.first, i, it.second);
    }
    printf("%lld\n", max(s[1], 0ll));
    return 0;
}

Measured memory_bytes: 21820
#include <bits/stdc++.h>
using namespace std; 
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define mo 1000000007
/*int const nmax = 1000006; 
vector<int> v[nmax]; 
void dfs(int i , int p)
{
	for(int j = 0; j<v[i].size(); j++)
	{
		int node = v[i][j]; 
		if(node!=p)
		{
			dfs(node,i); 
		}
	}
}*/
/////////////////////////////
ll gcd(ll a ,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll poww(ll a,ll n){if(n==0)return 1;ll p=poww(a,n/2);p=(p*p)%mo;if(n%2)p=(a*p)%mo;return p;}
////////////////////////////////////////////////////


void solve()
{
 ll x ; 
 cin>>x; 
 ll cur = 100; 
 lp(i,0,4000)
 {
  ld temp = cur ; temp/=100; 
  temp = temp*101; 
  cur = temp; 
 	//cur =cur/100; cur = cur*101; 
 	if(cur>=x)
 	{
 		cout<<i+1<<endl; return; 
	 }
	// cout<<cur<<endl; 
 }
 cout<<3760<<endl; 
}
int main()
{ ios; 

ll t =1; 
 while(t--)
	solve(); 
	return 0 ; 
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Queue<Integer> q = new PriorityQueue<Integer>(new MyComparator());
        for(int i = 0; i < n; i++){
            q.add(sc.nextInt());
        }
        for(int i = 0; i < m; i++){
            int a = q.poll();
            q.add(a/2);
        }
        long ans = 0;
        for(int i = 0; i < n; i++){
            ans += q.poll();
        }
        System.out.println(ans);
    }
}

class MyComparator implements Comparator<Integer>{
 
    public int compare(Integer n1, Integer n2) {
        if(n1 < n2) {
            return 1;
        } else if(n1 > n2) {
            return -1;
        } else{
            return 0;
        }
    }
}


Measured memory_bytes: 61944
use std::io::stdin;

fn main() {
    let mut debt = 100000;
    let mut buf = String::new();
    match stdin().read_line(&mut buf) {
        Ok(_) => {
            let week: u32 = buf.trim().parse::<u32>().unwrap();
            for _ in 1..week + 1 {
                let interest = debt * 5 / 100;
                debt += (interest / 1000) * 1000;
                if interest % 1000 > 0 {
                    debt += 1000;
                }
            }
            println!("{}", debt);
        }
        Err(_) => return,
    }
}



Measured memory_bytes: 5016
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pll &a, const pll &b){return (a.second < b.second);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

vector<string> vec;

void generate(vl arr, ll v, ll n, ll mx){
    if(v == n){
        string str = "a";
        str.resize(n, 'a');
        rep(i, n)   str[i]+=arr[i];
        vec.pb(str);
        return;
    }
    rep(i, mx+2){
        arr[v] = i; 
        generate(arr, v+1, n, max(mx, arr[v]));
    }
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n;
        cin>>n;
        vl arr(n);
        generate(arr, 1, n, 0);
        sort(vec.begin(), vec.end());
        rep(i, s(vec))  cout<<vec[i]<<endl;
    }
}

Measured memory_bytes: 7796
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

ld dp[310][310][310];

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

    int N;
    cin >> N;
    vector<int> a(3, 0);
    for (int i = 0; i < N; i++)
    {
        int v;
        cin >> v;
        a[v - 1]++;
    }
    ld p = 1.0 / N;
    // 3 の個数
    for (int k = 0; k <= N; k++)
    {
        // 2 の個数
        for (int j = 0; j <= N; j++)
        {
            // 1 の個数
            for (int i = 0; i <= N; i++)
            {
                // 0 の個数
                int zero = N - i - j - k;
                if (zero < 0)
                    break;
                if (zero == N)
                    continue;

                if (i)
                    dp[i][j][k] += dp[i - 1][j][k] * i * p;
                if (j)
                    dp[i][j][k] += dp[i + 1][j - 1][k] * j * p;
                if (k)
                    dp[i][j][k] += dp[i][j + 1][k - 1] * k * p;
                dp[i][j][k] += 1;
                dp[i][j][k] /= (1.0 - zero * p);
            }
        }
    }
    cout << fixed << setprecision(15) << dp[a[0]][a[1]][a[2]] << endl;
}


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

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

const int MOD = 1000000007;

int main() {
    int K; cin >> K;
    int X,Y; cin >> X >> Y;

    bool xm=false,ym=false,xy=false;
    if(X<0) X = -X, xm=true;
    if(Y<0) Y = -Y, ym=true;

    if(X<Y) swap(X,Y), xy=true;
    vector<pair<int,int>> ans;

    if((X+Y)%2==1 && K%2==0){
        cout << -1 << endl;
        return 0;
    }else if(X+Y==K){
        ans.push_back({X,Y});
    }else if((X+Y)%2==0 && X+Y<K){
        int n = 2;
        int y = 0;
        REP(i,n){
            y += K;
            if(y<= (n*K-X+Y)/2){
                ans.push_back({0,y});
            }else if((n*K-X+Y)/2 < y && y<= (n*K+X+Y)/2){
                ans.push_back({y-(n*K-X+Y)/2, (n*K-X+Y)/2});
            }else{
                ans.push_back({X, (n*K-X+Y)/2-y+(n*K+X+Y)/2});
            }
        }
    }else if(X+Y<K){
        ans.push_back({X,X-K});
        ans.push_back({(K+3*X-Y)/2, (-K+X+Y)/2});
        ans.push_back({X,Y});
    }else if(X+Y >= K){
        int n = (X+Y-1)/K + 1;
        if(n*K%2 != (X+Y)%2){
            n++;
        }
        int x=0,y=0;
        REP(i,n){
            y += K;
            if(y<= (n*K-X+Y)/2){
                ans.push_back({0,y});
            }else if((n*K-X+Y)/2 < y && y<= (n*K+X+Y)/2){
                ans.push_back({y-(n*K-X+Y)/2, (n*K-X+Y)/2});
            }else{
                ans.push_back({X, (n*K-X+Y)/2-y+(n*K+X+Y)/2});
            }
        }
    }
    cout << ans.size() << endl;
    REP(i,ans.size()){
        int x = ans[i].first;
        int y = ans[i].second;
        if(xy) swap(x,y);
        if(xm) x = -x;
        if(ym) y = -y;
        cout << x << " " << y << endl;
    }



    
    return 0;
}

Measured memory_bytes: 5156
#include<stdio.h>
int main(){
	int count[5][4][11]={},b,f,r,v,n,a,i;
	scanf("%d",&n);
	for(i = 1;i <= n; i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		count[b][f][r]+=v;
	}
	for(b = 1;b < 5;b++){
		for(f = 1;f < 4;f++){
			for(r = 1;r < 11;r++){
				printf(" %d",count[b][f][r]);
			}
			printf("\n");
		}
		if(b <= 3){
		for(a = 1;a <= 20; a++){
			printf("#");
		}
		printf("\n");
		}
	}		
}


Measured memory_bytes: 2144
N = int(input())
A = [int(input()) for _ in range(N)]
Pushed = [False]*N
Pushed[0] = True
i = 0
cnt = 0
while True:
    i = A[i] - 1
    cnt += 1
    if Pushed[i]:
        print(-1)
        break
    Pushed[i] = True
    if i == 1:
        print(cnt)
        break


Measured memory_bytes: 13860
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int n; cin >> n;
    ll ans=1;
    vector<ll> aa(n);
    rep(i,n){
        cin >> aa[i];
        if(aa[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i,n){
        ll pe=1000000000000000000/ans;
        if(pe<aa[i]){
            cout << -1 << endl;
            return 0;
        }
        ans*=aa[i];
    }
    cout << ans << endl;
return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9
 
bool is_prime(int x){

    for(int i=2;i*i<=x;i++){
        if(x<=1){
            return false;
        }
        if(x%i==0){
            return false;
        }
    }
    return true;

}

int main(){

    int x;
    cin >> x;

    int ans = x;
    while(!is_prime(ans)){
        ans++;
    }

    cout << ans << endl;

    return 0;

}

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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

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 <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> ll sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

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

int n, a, b, c;
int l[10];
bool used[10];
ll ans = linf;
ll gousei;

int main() {
    char c[100000];
    list<char> s;
    cin >> c;
    for (int i = 0; c[i] != 0; i++) {
        s.push_back(c[i]);
    }
    int ans = 0;
    for (auto ite = s.begin(); ite != s.end(); ite++) {
        auto itebuf = ite;
        if (*ite != *(++itebuf) && itebuf != s.end()) {
            ite = s.erase(ite);
            ite = s.erase(ite);
            ans += 2;
            if (ite == s.begin())
                ite--;
            else {
                ite--;
                ite--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

int main() {
	int n; cin >> n;
	if (n) {
		int m; cin >> m;
		int M = m;
		ll sum = m;
		for (int i = 1; i < n; ++i) {
			int v; cin >> v;
			m = min(m, v);
			sum += v;
			M = max(M, v);
		}
		cout << m << " " << M << " " << sum << endl;
	}
	else {
		cout << 1000000 << " " << (-1000000) << " " << 0 << endl;
	}
}

Measured memory_bytes: 1164
#include<iostream>
 
int main(){
int N, T;
int i, judge;

  scanf("%d %d", &N,&T);
  
int c[N],t[N];

judge = 1001;
 
  for(i = 0; i < N; i++){
  scanf("%d %d", &c[i], &t[i]);

  if(t[i] <= T){
  if(c[i] < judge)
  judge = c[i];
  }
}
 
  if(judge == 1001)
    printf("TLE\n");
 
  else printf("%d\n",judge);
 
}

Measured memory_bytes: 256