akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#define eps 1e-8

using namespace std;

struct vec2d{
	double x, y;
	vec2d(){}
	vec2d(double x, double y){
		this->x = x, this->y = y;
	}
	double add(double a, double b){
		if(fabs(a+b) < eps * (fabs(a) + fabs(b))) return 0.0;
		return a+b;
	}
	vec2d operator+(vec2d ope){
		return vec2d(add(x, ope.x), add(y, ope.y));
	}
	vec2d operator-(vec2d ope){
		return vec2d(add(x, -ope.x), add(y, -ope.y));
	}
	vec2d operator*(double t){
		return vec2d(x*t, y*t);
	}
	vec2d operator/(double t){
		return vec2d(x/t, y/t);
	}
	double dot(vec2d ope){
		return add(x*ope.x, y*ope.y);
	}
	double cross(vec2d ope){
		return add(x*ope.y, -y*ope.x);
	}
	double norm(){
		double d2 = dot(*this);
		if(d2 > 0) return sqrt(d2);
		return 0.0;
	}
};

int n;
vector<vec2d> vec, poly;

bool compare(vec2d u, vec2d v)
{
	if(u.x < v.x - eps) return true;
	if(u.x > v.x + eps) return false;
	return u.y < v.y - eps;
}

void ConvexHull(vector<vec2d> &src, vector<vec2d> &dest)
{
	sort(src.begin(), src.end(), compare);
	dest.clear();
	dest.resize(2*src.size());
	
	int k = -1;
	for(int i = 0; i < src.size(); i++){
		while(k >= 1 && (src[i]-dest[k]).cross(dest[k]-dest[k-1]) > 0 ) k--;
		dest[k+1] = src[i] ;
		k++;
	}
	for(int i = (int)src.size()-2, t = k; i >= 0; i--){
		while(k > t && (src[i]-dest[k]).cross(dest[k]-dest[k-1]) > 0 ) k--;
		dest[k+1] = src[i];
		k++;
	}
	dest.resize(k+1);
}

int main(void)
{
	cin >> n;
	int x, y;
	for(int i = 0; i < n; i++){
		cin >> x >> y;
		vec.push_back(vec2d(x, y));
	}
	
	ConvexHull(vec, poly);
	poly.pop_back();
	
	double mn_x = 1e18, mn_y = 1e18; int min_i;
	for(int i = 0; i < poly.size(); i++){
		if(poly[i].y < mn_y) mn_y = poly[i].y, min_i = i;
		if(poly[i].y == mn_y && poly[i].x < mn_x) mn_x = poly[i].x, min_i = i;
	}
	
	cout << (int)poly.size()<< endl;
	for(int i = 0; i < poly.size(); i++){
		int j = (i + min_i) % poly.size();
		cout << poly[j].x << " " << poly[j].y << endl;
	}
	
	return 0;
}


Measured memory_bytes: 7516
require 'prime'

class Integer
  def my_divisor_list2
    return [1] if self == 1
    Prime.prime_division(self).map do |e|
      Array.new(e[1]+1).map.with_index do |element, i|
        e[0]**i
      end
    end.inject{|p,q| p.product(q)}.map do |a|
      [a].flatten.inject(&:*)
    end.sort
  end
end

a,b,c=gets.split.map(&:to_i)
d=a.my_divisor_list2&b.my_divisor_list2
p d.reverse.at(c-1)

Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	if(a+b==15) cout<<"+"<<endl;
	else if(a*b==15) cout<<"*"<<endl;
	else cout<<"x"<<endl;
	return 0;
}


Measured memory_bytes: 768
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let A = xs[0];
   let B = xs[1];
   let C = xs[2];
   let D = xs[3];
   let L = Math.max(A,C); 
   let R = Math.min(B,D);
   
   if(R-L>=0){
    console.log(R-L);
   }else if(R-L<0){
    console.log(0)
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));




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

#define ll long long
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define endl "\n"
#define len(x) x.size()
#define gcd(a, b) __gcd(a, b)
#define ste(v) v.begin(), v.end()
#define stea(arr, n) arr, arr+n


void solve(){
    // Solve here
    int n;
    cin>>n;
    if(n==0) cout<<"1";
    else cout<<"0";
}

int32_t main() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
number = list(map(int, input().split(" ")))

if number[0] < number[1]:
    number[0], number[1] = number[1], number[0]

remainder = 1
while remainder != 0:
    remainder = number[0]%number[1]
    number[0] = number[1]
    number[1] = remainder
    
print(number[0])


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int max(int x, int y){return x > y ? x : y;}
int min(int x, int y){return x < y ? x : y;}
int gcd(int x, int y){
	int a = max(x, y);
	int b = min(x, y);
	if(b == 0) return a;
	else return gcd(b, a%b);
}
int main(){
	int N, X;
	cin >> N >> X;
	vector<int> x(N);
	for(int i = 0; i < N; i++) cin >> x[i];
	x.insert(x.end(), X);
	sort(x.begin(), x.end());
	int diff[N];
	for(int i = 0; i < N; i++) diff[i] = x[i+1] - x[i];
	if(N == 1){
		cout << diff[0] << endl;
		return 0;
	}
	sort(diff, diff+N);
	int GCD = gcd(diff[0], diff[1]);
	for(int i = 2; i < N; i++) GCD = gcd(GCD, diff[i]);
	cout << GCD << endl;
}


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

int n;

int main() {
	scanf("%d", &n);
	for (int i = 1, ss = 0; ; i++) {
		ss += i;
		if (ss >= n) {
			int ls = n;
			for (int j = i; j > 0; j--) if (ls >= j) {
				printf("%d\n", j);
				ls -= j;
			}
			return 0;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
    vector<int> sassi;
    int numSassi;

    cin >> numSassi;

    sassi.resize(numSassi);

    for(int i = 0; i < sassi.size(); i++)
    {
        cin >> sassi[i];
    }

    int costoPrec, costoPrecPrec, temp;
    costoPrec = abs(sassi[0] - sassi[1]);
    costoPrecPrec = 0;

    for(int i = 2; i < numSassi; i++)
    {
        temp = costoPrec;
        costoPrec = min(
            costoPrec + abs(sassi[i] - sassi[i - 1]),
            costoPrecPrec + abs(sassi[i] - sassi[i - 2])
        );
        costoPrecPrec = temp;
    }

    cout << costoPrec << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

vector<int> G[100005];//グラフ(木)
//G[i] : ノード番号iのノードから伸びている辺の行き先のvector
//G[i][j] : ノード番号iのノードから伸びている辺のうちj番目の辺の行き先のノード番号

int main(void){
	int n;
	cin>>n;
	int a,b;
	rep(i,n-1){
		cin>>a>>b;
		a--;b--;//1_indexed から 0_indexedに変換
		G[a].push_back(b);
		G[b].push_back(a);
	}

	int c;
	vector<int> C;
	ll ans_sum = 0;
	rep(i,n){
		cin>>c;
		C.push_back(c);
		ans_sum += c;
	}
	sort(all(C));//小さい順にソート
	ans_sum -= C[C.size()-1];//答え1(辺の合計値)
	int ci = 0;//Cのindex 次に埋め込むべきはC[ci] 埋め込むたびにci++していく

	vector<int> count;//各ノードからのびている辺の個数(次数)
	vector<int> ans;//答え2(各ノードへの割り振り)
	rep(i,n){
		count.push_back(G[i].size());
		ans.push_back(-1);//初期化
	}

	while(true){
		bool check = false;//次数1の点はみつかりましたか？見つからなかったらおしまい
		rep(i,n){//全てのノードについて順に確認
			if(count[i] == 1){//次数が1なら
				check = true;//見つけたよー
				ans[i] = C[ci];
				ci++;
				count[i]--;//次数が0の点 = 存在しない　として扱っている (count[i] = -999)とかでもよい
				rep(j,G[i].size()){//ノード　i と辺でつながっている点全ての次数を1下げる
					count[G[i][j]]--;
				}
			}
		}
		if(!check) break;//次数1の点が見つからなかったら終了
	}

	cout<<ans_sum<<endl;
	rep(i,ans.size()){
		if(ans[i] == -1){//初期化したままだったら (後述: a1参照)
			cout<<C[C.size()-1]<<" ";
		}else{
			cout<<ans[i]<<" ";
		}
	}
	cout<<endl;
	return 0;
	/*
	ノードを削除していった結果、最終的に頂点数2辺1の木まで削れる。
	この状態で片方のノード(X)を削除すると、もう片方のノード(Y)にCを割り当てる前に、
	Yの次数が0になってしまう。
	なので、割り当てられてないノード　すなわち初期化時の-1のままであるノードのときは、
	もっとも大きいCを出力する
	*/
}


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

using lint = long long;
const lint LINF = 1e18;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    int N; lint x; cin >> N >> x;
    vector<lint> a(N); rep(i, N) cin >> a[i];

    vector<lint> get(N); rep(i, N) get[i] = a[i];
    lint ans = 0; rep(i, N) ans += get[i];

    for (int k = 1; k < N; k++) {
        rep(i, N) {
            int j = i - k; if (j < 0) j += N;
            get[i] = min(a[j], get[i]);
        }

        lint ans_cand = x*k;
        rep(i, N) ans_cand += get[i];
        ans = min(ans, ans_cand);
    }

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

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

void swap(int& x, int& y) {
    int tmp = x;
    x=y;
    y=tmp;
}

int main(){
    int a, b, c;
    scanf("%d %d %d",&a,&b,&c);
	if(a>b) swap(a,b);
	if(b>c) swap(b,c);
	if(a>b) swap(a,b);
	printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2676
#include <iostream>
#include <vector>

using namespace std;

int main(void){
  long long int n;
  cin >> n;
  vector<long long int> a(n+1, 0);
  vector<long long int> b(n, 0);

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

  long long int sum = 0;
  for (int i = 0; i < n; i++){
    if (a[i] >= b[i]){
      sum += b[i];
      a[i] -= b[i];
    }
    else {
      sum += a[i];
      b[i] -= a[i];
      a[i] = 0;
      if (a[i+1] > b[i]){
        sum += b[i];
        a[i + 1] -= b[i];
      }
      else {
        sum += a[i + 1];
        a[i + 1] = 0;
      }
    }
  }

  cout << sum << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.rbegin(),A.rend());
  long long sum=0;
  for(int i=1;i<N;i++){
    sum+=A.at(i/2);
  }
  cout << sum << endl;
}

Measured memory_bytes: 3988
#include<stdio.h>
#include<string.h>
#include<math.h>
 
 
int main(){
   int n;
   scanf("%d ", &n);
   int a,f=0,ff=0;
   for(int i=0;i<n;i++){
   	scanf("%d ", &a);
    if(a%2==0){
      ff++ ;
      if(a%3==0 || a%5==0){
       	f++; 
      }
    }
   }
   //printf("%d %d",f,ff);
	if(f==ff){
     	printf("APPROVED"); 
    } else{
       printf("DENIED");
    }
   return 0;
 
}

Measured memory_bytes: 128
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;
const ll MOD=1000000007;

bool done[110000]={};

int main(){
    ll k;
    cin>>k;
    priority_queue<pll,vector<pll>,greater<pll>> q; //cost,mod
    q.push({1,1});
    ll ans=-1;
    while(!q.empty()){
        pll p=q.top();
        q.pop();
        if(done[p.S]){continue;}
        done[p.S]=true;
        
        if(p.S*10%k==0){ans=p.F; break;}
        if((p.S+1)%k==0){ans=p.F+1; break;}
        q.push({p.F+1,(p.S+1)%k});
        if(p.S*10%k!=p.S){
            q.push({p.F,p.S*10%k});
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 2548
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a <= c && c <= b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    a = []
    for i in range(5):
        a.append(int(input()))
    b = []
    s = 0
    tmp = 0
    for i in a:
        if i%10 != 0:
            tmp = i + (10-i%10)
            b.append(10-i%10)
        else:
            tmp = i
            b.append(0)
        s += tmp
    print(s-max(b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int lookup[3001][3001];
int LCSLength(string X, string Y)
{
	int m = X.length(), n = Y.length();

	for (int i = 0; i <= m; i++)
		lookup[i][0] = 0;
	for (int j = 0; j <= n; j++)
		lookup[0][j] = 0;
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (X[i - 1] == Y[j - 1])
				lookup[i][j] = lookup[i - 1][j - 1] + 1;
			else
				lookup[i][j] = max(lookup[i - 1][j], lookup[i][j - 1]);
		}
	}
	return lookup[m][n];
}
int main()
{
	string ans;
	string s;
	 string t;
	cin>>s;
	cin>>t;
	int l=LCSLength(s,t);
	if(l==0)
    {
        cout<<ans;
    }
    else{
        int i=s.length();
        int j=t.length();
        int a=0;
        while(i >0 && j>0)
        {
            if(lookup[i][j]==lookup[i-1][j-1]+1 && s[i-1]==t[j-1])
            {
                ans.push_back(s[i-1]);
                i--;
                j--;
            }
            else if(lookup[i][j-1]>lookup[i-1][j])
            {
                j--;
            }
            else
            {
                i--;
            }
        }
      reverse(ans.begin(),ans.end());
      cout<<ans<<'\n';
    }

	return 0;
}


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

using namespace std;
/*
 * Simultaneous Equation
 * ax + by = c
 * dx + ey = f
 */
int main()
{
    vector <double> xlist;
    vector <double> ylist;
    double a, b, c, d, e, f;
    double x = 0,y = 0;
    while(cin >> a >> b >> c >> d >> e >> f)
    {
        double dA = a*e - b*d;
        if(dA == 0)
        {
            //Not Calc
            return -1;
        }
        x = 1/dA*(e*c-b*f);
        y = 1/dA*(-d*c+a*f);
        xlist.push_back(x);
        ylist.push_back(y);

    }
    for(int i; i < (int)xlist.size(); i++)
    {
        x = xlist[i];
        y = ylist[i];
        if(x == 0)
        {
            x = fabs(x);
        }
        if(y == 0)
        {
            y = fabs(y);
        }
        printf("%.3f %.3f\n",x,y);
    }

    return 0;
}

Measured memory_bytes: 3204
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[110000];
int q[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d%d",p+i,q+i);
	}
	long long ret=0;
	int cur=0;
	for(int i=29;i>=0;i--){
		if(b&(1<<i)){
			int t=cur+(1<<i)-1;
			long long tmp=0;
			for(int j=0;j<a;j++){
				if((t&p[j])==p[j])tmp+=q[j];
			}
			ret=max(ret,tmp);
			cur+=1<<i;
		}
		if(i==0){
			int t=cur;
			long long tmp=0;
			for(int j=0;j<a;j++){
				if((t&p[j])==p[j])tmp+=q[j];
			}
			ret=max(ret,tmp);
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 896
import sys

n = int(sys.stdin.readline())
h = list(map(int, sys.stdin.readline().split()))

dp = [10 ** 9] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):

    h1 = dp[i - 1] + abs(h[i] - h[i - 1])
    dp[i] = h1 if h1 < dp[i] else dp[i]

    h2 = dp[i - 2] + abs(h[i] - h[i - 2])
    dp[i] = h2 if h2 < dp[i] else dp[i]

print(dp[-1])

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

using namespace std;
const int INF = (1 << 29);

int main(){
  int n,res = INF;
  string s;
  cin >> n >> s;
  int e[n+1] = {},w[n+1] = {};
  for(int i = 0;i < n;i++){
    if(s[i] == 'E'){
      e[i+1] = e[i] + 1;
      w[i+1] = w[i];
    }else{
      w[i+1] = w[i] + 1;
      e[i+1] = e[i];
    }
  }
  for(int i = 0;i < n;i++){
    res = min(res,w[i]+e[n]-e[i+1]);
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 2948
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
using namespace std;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
#define bs bitset<5001>
#define mk_re(a) if(a){RE();}
int kai_size = 1000001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;

signed main() {
	int n; cin >> n;
	if (n == 0 or n == 2) { cout << 1<< endl; }
	else if (n == 1) { cout << 2 << endl; }
	else { cout << 0 << endl; }
	return 0;
}
/*
13:40~

*/


Measured memory_bytes: 18244
n = gets.to_i
a = []
n.times do |i|
  a[i] = gets.to_i
end

b = a.dup.sort
m = b.last
nm = 0

if b[-2] == m
  nm = m
else
  nm = b[-2]
end

a.each_with_index do |e, i|
  if a[i] == m
    puts nm
  else
    puts m
  end
end

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

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

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = LI()
    if min(a) == 0:
        return 0
    r = 1
    for c in a:
        r *= c
        if r > 10**18:
            return -1

    return r

print(main())





Measured memory_bytes: 24324
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */


void in(){
    
}

void solve(){

    int n;
    set<int> s;

    cin >> n;
    while(n--){
        int ai;
        cin >> ai;
        s.insert(ai);
    }

    cout << s.size() << endl;


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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

int main()
{
    int n, k, cnt = 0;
    cin >> n >> k;
    vector <int> vec (n);
    for (int i = 0; i < n; i++)
        cin >> vec[i];
    sort (vec.begin(), vec.end());
    for (int i = 0; i < k; i++)
        cnt += vec[i];
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long

signed main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int mini = a[0];
  int p = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] < mini) {
      p = i;
      mini = a[i];
    }
  }
  int ans = 100001;
  for (int i = -(k - 1); i <= 0; i++) {
    int q = p + i;
    if (q < 0 || n < q + k) continue;
    int l = q;
    int r = n - (q + k);
    int tmp = 1;
    tmp += l / (k - 1);
    if (l % (k - 1)) tmp++;
    tmp += r / (k - 1);
    if (r % (k - 1)) tmp++;
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
<?php
/*
    Problem URL : http://agc003.contest.atcoder.jp/tasks/agc003_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('error_reporting', E_ALL & ~E_NOTICE);

$a = array();
fscanf(STDIN, "%d", $N);
for ($i = 1; $i <= $N; $i++) {
	fscanf(STDIN, "%d", $a[$i]);
}

$dummy = $a;

$calc1 = 0;
$tmp1 = 0;
$tmp2 = 0;
for ($i = 1; $i <= $N; $i++) {
	$tmp1 = floor($a[$i-1] / 2);
	$a[$i-1] -= $tmp1 * 2;
	$tmp2 = floor(($a[$i-1] + $a[$i]) / 2);
	$x = $tmp2 * 2;
	if ($tmp2 > 0) {
		$x -= $a[$i-1];
		$a[$i-1] = 0;
		$a[$i] -= $x;
	}
	$calc1 += ($tmp1 + $tmp2);	
}

$a = $dummy;
$calc2 = 0;
$tmp1 = 0;
$tmp2 = 0;
for ($i = $N; $i >= 1; $i--) {
	$tmp1 = floor($a[$i+1] / 2);
	$a[$i+1] -= $tmp1 * 2;
	$tmp2 = floor(($a[$i+1] + $a[$i]) / 2);
	$x = $tmp2 * 2;
	if ($tmp2 > 0) {
		$x -= $a[$i+1];
		$a[$i+1] = 0;
		$a[$i] -= $x;
	}
	$calc2 += ($tmp1 + $tmp2);	
}

echo max($calc1, $calc2) . PHP_EOL;


Measured memory_bytes: 33196
N = gets.chomp.to_i
a = Array.new(N){Array.new(N,2)}
d = Array.new(N,0)
for i in 0...N do
    m = gets.chomp.to_i
    for j in 0...m do
        str = gets.split
        b,c = str[0].to_i-1, str[1].to_i
        a[i][b] = c
    end
end
answer = 0
for i in 1...2**N do
    b = i
    c = 0
    for j in 0...N do
        d[j] = b%2
        c += b%2
        b /= 2
    end
    f = 1
    for j in 0...N do
        if d[j] == 1
            for k in 0...N do
                if a[j][k] != d[k] && a[j][k] != 2
                    f = 0
                end
            end
        end
    end
    if f == 1
        answer = c > answer ? c : answer
    end
end
puts answer

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<queue>
using Graph =vector<vector<int>>;



int main() {
    int64_t n,k;
    cin>>n>>k;
    int64_t a=n%k;
    int64_t b=abs(a-k);
    int64_t c=min(a,b);
    cout<<c<<endl;
}

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

int main()
{
string s;
cin >> s;
ll len=(int)(s.length());
ll dp[len][4]={};
if(s[0]=='A'){dp[0][0]=1;dp[0][1]=1;}
else if(s[0]=='?'){dp[0][0]=3;dp[0][1]=1;}
else {dp[0][0]=1;}
string abc="ABCZ";
rep(i,len-1)rep(j,4){
    if(s[i+1]=='?'){
        dp[i+1][j]+=3*dp[i][j];
        dp[i+1][j]=dp[i+1][j]%mo;
        if(j!=3){dp[i+1][j+1]+=dp[i][j];dp[i+1][j+1]=dp[i+1][j+1]%mo;}
        }
    else if(s[i+1]==abc[j]){
        dp[i+1][j]+=dp[i][j];
        dp[i+1][j]=dp[i+1][j]%mo;
        dp[i+1][j+1]+=dp[i][j];
        dp[i+1][j+1]=dp[i+1][j+1]%mo;
    }
    else {
        dp[i+1][j]+=dp[i][j];
        dp[i+1][j]=dp[i+1][j]%mo;
    }
}
/* for (int i = 0; i < 4; ++i){
for (int j = 0; j < 4; ++j) {
    cout << dp[i][j] << " ";
}cout  << endl;} */

cout << dp[len-1][3] << endl;
return 0;
}








Measured memory_bytes: 3584
import java.util.*;
import java.io.*;

class Main
{
    static class Len
    {	
	int a[]; //= new int[2000010];
	int b[]; //= new int[2000010];
	
	Len(int n)
	{
	    a = new int[n+1];
	    b = new int[n+1];
	}
	

    }

    public static void main(String args[])
    {
	int n;
	int i, j, k;

	String line = new String();
	BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));

	//Read ----------------
	//Read n
	try{
	    line=line=bin.readLine();
	}	
	catch(IOException e){
	    System.out.println("Error");
	}

	n=Integer.parseInt(line);
	Len len = new Len(n);
	j=0;
	//Read A[]
	try{
	    line=bin.readLine();
	    //System.out.println(line);
	    StringTokenizer str = new StringTokenizer(line);   
	    for(i=0; i<n; i++)
		{
		    len.a[i]=Integer.parseInt(str.nextToken());
		    if(j<len.a[i])j=len.a[i];
		}
	}
	catch(IOException e){
	    System.out.println("Error");
	}

	//bin=null;

	//Read end------------


	//sort
	countingSort(len, j, n);

	//print
	StringBuffer s = new StringBuffer(50000);
	for(i=1; i<=n; i++)
	    {
		s.append(len.b[i]);
		if(i!=n)s.append(" ");
	    }
	System.out.println(s);

    }

    static void countingSort(Len len, int max, int n)
    {
	int i, j, k;
	int[] c = new int[max+1];

	for(i=0; i<n; i++)c[len.a[i]]++;

	for(i=0; i<=max; i++)
	    {
		if(i!=0)c[i]+=c[i-1];
	    }

	for(i=n-1; i>=0; i--)
	    {
		len.b[c[len.a[i]]]=len.a[i];
		c[len.a[i]]--;
	    }
    }
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    double n,a,b; cin >> a >> b;
    n = (a+b)/2.0;
    if(floor(n)==ceil(n))
    printf("%.0lf\n",n);
    else
    printf("IMPOSSIBLE\n");
    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;
    int m = 3500;
    for(int i = 1; i < m; i++){
        for(int j = i; j < m; j++){
            if(4*i*j-n*j-n*i == 0) continue;
            double t = (double)n*i*j/(4*i*j-n*j-n*i);
            if(floor(t) == t && t > 0){
                cout << i << " " << j << " " << (int)t << endl;
                //int k = (int)t;
                //cout << n*(j*k+i*k+i*j) << " " << 4*i*j*k << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3604
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n;
  rd(n);
  auto a = readln.split.to!(int[]);

  int o, t, f;
  foreach (e; a) {
    if (e % 4 == 0)
      f++;
    else if (e % 2 == 0)
      t++;
    else
      o++;
  }
  t %= 2;
  o += t;
  if (o <= f + 1) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}

void rd(T...)(ref T x) {
  import std.stdio, std.string, std.conv;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 4532
n, k = map(int, input().split())
d = []
A = []
ans = []
for i in range(k):
    hoge = int(input())
    tmp = list(map(int, input().split()))
    d.append(hoge)
    A.append(tmp)

for i in range(1, n+1):
    for j in range(len(A)):
        if i in A[j] and i not in ans:
            ans.append(i)
cnt = 0
for i in range(1, n+1):
    if i not in ans:
        cnt += 1

print(cnt)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int N;
  cin >> N;
  string S;
  cin >> S;

  int r = 0;
  int l = 0;
  rep(i, N) {
    if (S[i] == ')') {
      if (l == 0) {
        r++;
      } else {
        l--;
      }
    } else {
      l++;
    }
  }

  cerr << l << " " << r << endl;
  string ans = "";
  rep(i, r) ans += "(";
  ans += S;
  rep(i, l) ans += ")";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
int vis[maxn];
int prime[maxn], mu[maxn], minprim[maxn], tot = 0; //1 ~ tot
void get_prime(int maxl) 
{
    minprim[1] = 1;
    for (int i = 2; i <= maxl; i++)
    {
        if (!vis[i])
        {
            prime[++tot] = i; minprim[i] = i;
        }
        for (int j = 1; j <= tot; j++)
        {
            if (i * prime[j] > maxl) break;
            vis[i * prime[j]] = 1;
            minprim[i * prime[j]] = prime[j];
            if (i % prime[j] == 0) 
            {
            	break;
            }
        }
    }
    //vis[i] == 0 -> i is a prime
}
int inv[maxn];
void init_inv()
{
    inv[1]=1;
    for (int i = 2; i < maxn; i++) inv[i] = 1ll* inv[mod % i] * (mod - mod / i) % mod;
}
int po[maxn], cnt[maxn];
vector<int>ft[maxn];
inline int add(int x, int y) {int res = x + y; if (res >= mod) res -= mod; return res;}
inline int mul(int x, int y) {ll res = (ll)x * y; res -= res / mod * mod; return res;}
int ksm(int a, int b)
{
    int res = 1;
    while (b) 
    {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
int main()
{
    get_prime(1000000);
    init_inv();
    int n; scanf("%d", &n);
    for (int i = 1, x; i <= n; i++)
    {
        scanf("%d", &x);
        while (minprim[x] > 1) 
        {
            ft[i].push_back(minprim[x]);
            cnt[minprim[x]]++;
            x /= minprim[x];
        }
        for (int p : ft[i]) po[p] = max(po[p], cnt[p]), cnt[p] = 0;
    }
    int all = 1, ans = 0;
    for (int i = 1; i <= 1000000; i++) all = mul(all, ksm(i, po[i]));
    for (int i = 1; i <= n; i++)
    {
        int t = all;
        for (int p : ft[i]) t = mul(t, inv[p]);
        ans = add(ans, t);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 51328
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll x = min(b-1,n);
    ll ans = (a*x)/b;
    cout<<ans<<endl;;
}


Measured memory_bytes: 3588
#include<iostream>
#include<deque>
#include<vector>
#include<string>
#include<stdio.h>
using namespace std;

#define SIZEOF(x) (sizeof x) / (sizeof x[0])



int main(){
    long n;
    vector<long> d;
    cin >> n;
    for(int t = 0 ; t< n ; t++){
        int k;
        cin >> k;
        d.push_back(k);
    }
    
    long count = 0;

    if(n%2==1){
        cout << 0;
    }else{
        sort(d.begin() , d.end());
        count = d[n/2]-d[n/2-1] ;
        cout << count;
    




    }

    return 0;
}

Measured memory_bytes: 1400
n = int(input())
x = list(map(int, input().split()))
m = 10 ** 8
for i in range(min(x), max(x) + 1):
    c = 0
    for j in range(n):
        c += (x[j] - i) ** 2
    if c < m:
        m = c
print(m)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;

int main () {
    int a, b, ans = 0; cin >> a >> b;
    string i_tmp, i_tmpr;
    for (int i = a; i <= b; i++) {
        i_tmp = to_string(i);
        i_tmpr = i_tmp;
        reverse(all(i_tmpr));
        if (i_tmp == i_tmpr) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define vi vector<ll>
# define vvi vector<vi>
# define rep(i, N) for (int i = 0; i < N; i++)
# define Rep(i, N) for (int i = 1; i <= N; i++)
# define deb(x) cerr << #x << ": " << x << endl;
# define deb2(x, i) cerr << #x << "[" << i << "]: " << x[i] << endl;
/*
vi v(10, 2); 
rep(i, 10) deb2(v, i); 
*/

/*
int a; cin >> a;
int a, b; cin >> a >> b;
rep(i, n){cin >> v[i];}
cout <<   << endl;
*/

signed		main()
{
	
	int n, k; cin >> n>>k;
	vi v(n+1, 0);
	rep(i, k)
	{
		int d; cin >> d;
		rep(j, d)
		{
			int a; cin >> a;
			v[a]++;
		}
	}
	int ans = 0;
	Rep(i, n)
	{
		if (v[i] == 0)ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3628
#include <iostream>
#include <map>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n, m;
    cin >> n >> m;

    map<int, string> ac;
    multimap<int, string> wa;
    map<int, bool> hantei;
    REP(i, m) {
        int p; cin >> p;
        string s; cin >> s;
        if (s == "AC") {
            ac[p] = s;
            hantei[p] = true;
        }
        if (s == "WA" && hantei[p] == false)
            wa.emplace(p, s);
    }

    int sum = 0;
    for (auto i : hantei) {
        if (i.second == true)
            sum += wa.count(i.first);
    }

    cout << ac.size() << ' ' << sum << '\n';
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int X,N;
  cin >> X >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  for (int i = 0; i < 100; i++) {
    if ( find(p.begin(),p.end(),X-i) == p.end()) {
      cout << X-i << endl;
      return 0;
    }
    if ( find(p.begin(),p.end(),X+i) == p.end()) {
      cout << X+i << endl;
      return 0;
    }
  }
  return 0;
}

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

namespace ARC077
{
    public class D
    {
        private const long Mod = 1000000000 + 7;

        public static long ModPow(long x, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) != 0) { res = (res * x) % mod; }
                x = (x * x) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long ModInverse(long x, long p)
        {
            return ModPow(x, p - 2, p);
        }

        private void Run()
        {
            var n = int.Parse(Console.ReadLine().Trim());
            var A = Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            var counts = new int[n];
            foreach (var a in A)
            {
                counts[a - 1]++;
            }
            var duplicatedValue = Array.FindIndex(counts, x => x > 1) + 1;
            int firstIndex = Array.IndexOf(A, duplicatedValue);
            int secondIndex = Array.LastIndexOf(A, duplicatedValue);

            var factorial = new long[n + 2];
            factorial[0] = 1;
            for (int i = 1; i < factorial.Length; i++)
            {
                factorial[i] = (i * factorial[i - 1]) % Mod;
            }

            Func<int, int, long> choose = (int n2, int k2) =>
            {
                if (n2 < k2) { return 0; }
                long r = factorial[n2];
                r = (r * ModInverse(factorial[k2], Mod)) % Mod;
                r = (r * ModInverse(factorial[n2 - k2], Mod)) % Mod;
                return r;
            };

            int leftCount = firstIndex;
            int rightCount = A.Length - 1 - secondIndex;

            Console.WriteLine(n); // k==1
            for (int k = 2; k <= n + 1; k++)
            {
                long result = choose(A.Length, k);
                result += Mod - choose(leftCount + rightCount, k - 1);
                result %= Mod;
                Console.WriteLine(result);
            }
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new D().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


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

using namespace std;
typedef long long LL;
const long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int x = 0;
	int N; cin >> N;
	string S; cin >> S;
	int ans = x;
	for(int i=0; i<N; i++){
		if(S[i] == 'I') x++;
		else if(S[i] == 'D') x--;
		if(ans < x) ans = x;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3712
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n,k = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

if k<n:
    h.sort()
    print(sum(h[:n-k]))
else:
    print(0)

Measured memory_bytes: 31988
from collections import deque
k = int(input())

Q = deque(range(1, 10)) #るんるん数を格納するキュー
# Q: 1 2 3 4 5 6 7 8 9

for i in range(k):
  x = Q.popleft()
  #x = 1 <--  Q: 2 3 4 5 6 7 8 9
  last_digit = x % 10 # 1 一番目の桁の値
  if last_digit == 0:
        Q.append(10*x + 0)
        Q.append(10*x + 1)

  elif last_digit == 9:
        Q.append(10*x + 8)
        Q.append(10*x + 9)

  else: # 1<=last_digit <=8
        Q.append(10*x + last_digit - 1)
        Q.append(10*x + last_digit)
        Q.append(10*x + last_digit + 1)
print(x)

Measured memory_bytes: 11948
#include <bits/stdc++.h>
using namespace std;
string k;
int d, n;
long long dp[100005][105][2][2];
vector<int>v;
long long md = 1e9 + 7;
long long rec(int x, int y, int z, int cek){
	if(x == n){
		if(y == 0 && cek && z){
//			for(int i = v.size()-1; i >= 0; i--)cout << v[i];
//			cout << endl;
			return z;
		}
		return 0;
	}
	if(dp[x][y][z][cek] != -1)return dp[x][y][z][cek];
	long long ret = 0;
	if(y == 0 && cek == 1)ret++;
	ret %= md;
	int num = k[n-1-x] - '0';
	for(int i = 0; i < 10; i++){
		if(num > i){
//			v.push_back(i);
			ret += rec(x+1, (y+i)%d, 1, i > 0);
			ret %= md;
//			v.pop_back();
		}else
		if(num == i){
//			v.push_back(i);
			ret += rec(x+1, (y+i)%d, z, i > 0);
			ret %= md;
//			v.pop_back();
		}else{
//			v.push_back(i);
			ret += rec(x+1, (y+i)%d, 0, i > 0);
			ret %= md;
//			v.pop_back();
		}
	}
	return dp[x][y][z][cek] = ret;
}
int main(){
	for(int i = 0; i <= 100000; i++)
		for(int j = 0; j <= 100; j++)
			for(int k = 0; k < 2; k++)
				for(int cek = 0; cek < 2; cek++)
					dp[i][j][k][cek] = -1;
	cin >> k >> d;
	n = k.size();
	cout << rec(0,0,1,0);
}

Measured memory_bytes: 329344
#include <iostream>

using namespace std;

int main(){
    string S;
    cin >> S;

    int N= S.length();

    bool fl = true;
    for(int i=0; i<S.length()/2; i++){
        if(S[i] != S[S.length()-1-i]) fl = false;
    }

    string S2, S3;
    for(int i=0; i<(N-1)/2; i++){
        S2 += S[i];
    }
    for(int i=(N+3)/2-1; i<N; i++){
        S3 += S[i];
    }


    for(int i=0; i<S2.length()/2; i++){
        if(S2[i] != S2[S2.length()-i-1]) fl = false;
    }

    for(int i=0; i<S3.length()/2; i++){
        if(S3[i] != S3[S3.length()-i-1]) fl = false;
    }

    if(fl) cout << "Yes"<<endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x, y, i, j, a[7] = { 1, 3, 5, 7, 8, 10, 12 }, b[4] = { 4, 6, 9, 11 }, c[1] = { 2 };
	scanf("%d %d", &x, &y);

	for (i = 0; i < 7; i++) {
		if (x == a[i]) {
			for (j = 0; j < 7; j++) {
				if (y == a[j]) {
					printf("Yes");
					return(0);
				}
			}
		}
	}

		for (i = 0; i < 4; i++) {
			if (x == b[i]) {
				for (j = 0; j < 4; j++) {
					if (y == b[j]) {
						printf("Yes");
						return(0);
					}
				}
			}
		}
  	printf("No");
}

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

int main(){
	double A, B;
	cin >> A >> B;
	while (cin){
		bool b = true;
		double c = ceil(A / 0.08), d = ceil(B / 0.1), m = d;
		if (c < d){
			m = d;
			if (floor(d * 0.08) == A && floor(d * 0.1) == B) b = true;
			else b = false;
		}
		else if (d < c){
			m = c;
			if (floor(c * 0.1) == B && floor(c * 0.08) == A) b = true;
			else b = false;
		}
		if (b) cout << m << "\n";
		else cout << -1 << "\n";
		cin >> A >> B;
	}
	return 0;
}

Measured memory_bytes: 256
//In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define mod 1000000007


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,m,v,p;
	cin>>n>>m>>v>>p;
	vector <int> A(n);
	for(int i=0;i<n;i++)
		cin>>A[i];
	sort(A.rbegin(),A.rend());
	int lo=p,hi=n-1;
	while(lo<=hi) {
		int mi=(lo+hi)>>1;
		int tot=0;
		for(int i=0;i<n;i++) {
			if(i<p-1||i>=mi)
				tot+=m;
			else {
				if(A[i]>A[mi]+m) {
					tot=-1;
					break;
				}
				tot+=(A[mi]+m-A[i]);
			}
		}
		if(tot>=m*v)
			lo=mi+1;
		else
			hi=mi-1;
	}
	cout<<lo<<"\n";
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;
ll lpow(ll x, ll p) {
    ll tmp = 1;
    if(p == 0) return 1;
    while(p != 0) {
        if(p & 1) tmp = tmp*x;
        x = x*x;
        p = p >> 1;
    }
    return tmp;
}

int main(){
    //input
    ll n, p;
    scanf("%lld%lld", &n, &p);
    
    //solve
    //素因数分解
    struct ret{
        ll val, cnt;
    };
    struct ret ret[101010];
    ll ntmp = p, rcnt = 0;
    for(ll i = 2; i * i <= ntmp; i++) {
        if(ntmp % i == 0){
            ret[rcnt].val = i;
            while(ntmp % i == 0) {
                ret[rcnt].cnt++;
                ntmp /= i;
            }
            rcnt++;
        }
    }
    if(ntmp != 1){
        ret[rcnt].val = ntmp;
        ret[rcnt].cnt = 1;
        rcnt++;
    }
    ll ans = 1;
    rep(i, rcnt){
        ans *= lpow(ret[i].val, ret[i].cnt/n);
    }

    //output
    printf("%lld", ans);
}

Measured memory_bytes: 1716
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String ABC = "ABC";
        String XNX = "X" + S + "X";
        System.out.println((XNX.split(ABC).length)-1);
    }
}

Measured memory_bytes: 21844
S = input()
d = {}
for s in S:
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

if len(d) != 2:
    print("No")
    exit()

for k, v in d.items():
    if v != 2:
        print("No")
        exit()

print("Yes")


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

using namespace std;

const int MOD=1e9+7;

//const int MOD=998244353;

long long sol(long long x){
    if(x%4==1) return 1;
    if(x%4==2) return x+1;
    if(x%4==3) return 0;
    return x;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long a,b;
    cin>>a>>b;
    
    long long ans=sol(b);
    if(a) ans^=sol(a-1);
    cout<<ans;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N;
    cin >> N;
    vector<long> a(N+1);
    for(size_t i=1;i<=N; i++)
    {
        cin >> a[i]; //iの倍数の和の２の剰余;
    }
    vector<long> b(N+1);
    long total = 0;
    bool ok = false;
    for(size_t i=N;i>0; i--)
    {
        long sum = 0;
        if(N/i == 1) b[i] = a[i];
        else
        {
            for(size_t j=2;j<=N/i; j++)
            {
                sum += b[i * j];
            }
            if(a[i] == sum % 2) b[i] = 0;
            else b[i] = 1;
        }
        if(b[i] == 1) total++;
    }
    cout << total << endl;
    if(total != 0)
    {
        for(size_t i=1;i<=N; i++)
        {
            if(b[i]== 1) cout << i << " ";
        }
        cout << endl;
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main() {
  int A, B, C, D;
  int train_fare, bus_fare, total_fare;

  cin >> A >> B >> C >> D;
  train_fare = A;
  if (A > B) train_fare = B;
  bus_fare = C;
  if (C > D) bus_fare = D;
  total_fare = train_fare + bus_fare;

  cout << total_fare << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

using namespace std;

int n;
int fie[9][9];
int used[10];
bool ok[9][9];

bool check(){
	memset(ok,false,sizeof(ok));
	for(int i=0;i<9;i++){
		memset(used,0,sizeof(used));
		for(int j=0;j<9;j++)used[fie[j][i]]++;
		for(int j=0;j<9;j++)if(used[fie[j][i]]>=2)ok[j][i]=true;
	}
	
	for(int i=0;i<9;i++){
		memset(used,0,sizeof(used));
		for(int j=0;j<9;j++)used[fie[i][j]]++;
		for(int j=0;j<9;j++)if(used[fie[i][j]]>=2)ok[i][j]=true;
	}
	
	for(int i=0;i<9;i++){
		int x=i%3*3;
		int y=i/3*3;
		memset(used,0,sizeof(used));
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				used[fie[x+j][y+k]]++;
			}
		}
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(used[fie[x+j][y+k]]>=2)ok[x+j][y+k]=true;
			}
		}
	}
}

int main(void){
	scanf("%d",&n);
	for(int data=0;data<n;data++){
		if(data!=0)printf("\n");
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++)scanf("%d",&fie[j][i]);
		}
		check();
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++)printf("%c%d",ok[j][i]?'*':' ',fie[j][i]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1028