akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
//#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
typedef long long ll;

signed main()
{
    string s,t;
    int a;
    cin>>a>>s;
    t=s;
    while(1){
        int f=0;
        bool flag=false;
        //cout<<"unko"<<endl;
        rep(i,s.size()-1){
            if(s[i]=='(' && s[i+1]==')'){
                s.erase(s.begin()+i,s.begin()+i+2);
                f=1;
                break;
            }
        }
        if(!f||s.empty())break;
    }
    //cout<<s<<endl;
    int co=0,co2=0;
    rep(i,s.size()){
        if(s[i]=='(')co++;
        if(s[i]==')')co2++;
    }
    rep(i,co2)cout<<'(';
    cout<<t;
    rep(i,co)cout<<')';
    cout<<endl;
}


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

const int INF = 1001001001;

int main(){
  int A,B,M;
  cin >> A >> B >> M;
  int a[A+1],b[B+1];
  int mina = INF, minb = INF;
  rep(i,1,A+1){
    cin >> a[i];
    mina = min(mina, a[i]);
  }
  rep(i,1,B+1){
    cin >> b[i];
    minb = min(minb,b[i]);
  }
  int x[M],y[M],c[M];
  rep(i,0,M) cin >> x[i] >> y[i] >> c[i];

  int ans = mina + minb;

  rep(i,0,M){
    int tmp = a[x[i]] + b[y[i]] - c[i];
    ans = min(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2176
import sys
n = int(input())

t_pre,x_pre,y_pre = 0,0,0 #initial
for i in range(n):
    t,x,y = map(int, input().split())
    t_dif, x_dif, y_dif = abs(t_pre-t), abs(x_pre-x), abs(y_pre-y)
    
    if 0 <= x_dif+y_dif <= t_dif:
        if (x_dif+y_dif)%2 == t_dif%2: # 偶奇が一致
            t_pre, x_pre, y_pre = t, x, y
            continue
    print('No')
    sys.exit()
    
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int64_t x; cin >> x;
  int64_t a, b;
  
  for(int64_t a=-200; a<=200; a++){
    for(int64_t b=-200; b<=200; b++){
      if(a*a*a*a*a - b*b*b*b*b == x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define N 3055
#define ll long long
ll dp[N][N];
int main() {
    string a,b;
    cin >> a >> b;
    int n = a.size(), m = b.size();
    for(int i=1; i<=n; ++i) {
        for(int j=1; j<=m ; ++j) {
            if(a[i-1] == b[j-1])
                dp[i][j] = dp[i-1][j-1]+1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    int i = n , j = m;
    string ans = "";
    while(i>0 && j>0){
        if(max(dp[i-1][j] , dp[i][j-1]) == dp[i][j]){
            if(dp[i][j-1] == dp[i][j])
                j--;
            else
                i--;
        }else{
            ans += a[i-1];
            i--;j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans;
    return 0;
}


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

typedef long long ll;

#define MOD 1000000007LL

int n, m;
int a[52], b[52];
int t[100002];
ll f[100002];
vector<int> cg;

void mkFact(){
  f[0] = 1;
  for(ll i = 1; i <= 100000; i++){
    f[i] = f[i - 1] * i;
    f[i] %= MOD;
  }
}

void show(int nn, int mm){
  string s;
  for(int i = 0; i < nn; i++){
    s += (char)('a' + i);
  }
  for(int i = 0; i < mm; i++){
    next_permutation(s.begin(), s.end());
  }
  cout << s << endl;
}

void show2(){
  for(int i = 0; i < n; i++){
    cout << (char)(t[i] + 'a');
  }
  cout << endl;
}

void solve(){
  ll res = 0;

  for(int i = 0; i < n - 1; i++){
    int x = t[i];
    int low = min(i, x);

    for(int j = 0; j < cg.size(); j++){
      if(cg[j] >= i) break;
      int y = t[cg[j]];

      if(cg[j] < x && y > x){
        low--;
      }
      else if(x <= cg[j] && y < x){
        low++;
      }
    }

    x -= low;
    res += (ll)x * f[n - i - 1];
    res %= MOD;
  }

  cout << res << endl;
}

int main(){
  mkFact();

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

    set<int> st;

    cin >> m;
    for(int i = 0; i < m; i++){
      cin >> a[i] >> b[i];
      a[i]--;
      b[i]--;
      swap(t[a[i]], t[b[i]]);

      st.insert(a[i]);
      st.insert(b[i]);
    }

    cg.clear();
    for(set<int>::iterator iter = st.begin(); iter != st.end(); iter++){
      cg.push_back(*iter);
    }
    solve();
  }
}

Measured memory_bytes: 2392
# coding:utf-8

class FLOOR:
    def __init__(self):
        self.room = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

class BUILD:
    def __init__(self):
        self.floor = [FLOOR(), FLOOR(), FLOOR()]

# 3??????10??¨?±????4?£?
all_rooms = [BUILD(), BUILD(), BUILD(), BUILD()]

# ??\???
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    all_rooms[b-1].floor[f-1].room[r-1] += v

for b in range(4):
    for f in range(3):
        display = []
        for r in range(10):
            display.append(str(all_rooms[b].floor[f].room[r]))
        print(' ' + ' '.join(display))
    if (b < 3):
        print('#'*20)

Measured memory_bytes: 7700
import java.io.*;

public class Main{
   public static void main(String[] args)throws IOException{
      BufferedReader br = 
        new BufferedReader(new InputStreamReader(System.in));
     double pai = Math.PI;
   	 double r = Double.parseDouble(br.readLine());
   	
   	double menseki = r*r*pai;
   	double enshuu = 2*r*pai;
   	
   	String ans1 = String.format("%.6f", menseki);
   	String ans2 = String.format("%.6f", enshuu);
   	
   	System.out.println(ans1+" "+ans2);
   }
}

Measured memory_bytes: 24628
#include <bits/stdc++.h>
         
using namespace std;
 
#define ll  long long
#define mod 1000000007
#define pb push_back
#define pie 3.141592653589



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

    
    ll i,n,n2,m,t,j,l,r,pos,mpos,f=0,k,p,n1,z,q,x,y,x1,y1,x2,y2,x3,y3,x4,y4,w;

    cin>>n>>w;
    ll wt[n],ct[n];
    for(i=0;i<n;i++)
        cin>>wt[i]>>ct[i];
    ll dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(j>=wt[i-1])
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+ct[i-1]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    
    cout<<dp[n][w];




  return 0;
}

Measured memory_bytes: 79232
function main(input){
  var nums = input.split('\n');
  var A = parseInt(nums[0],10);
  var B = parseInt(nums[1],10);
  var C = parseInt(nums[2],10);
  var X = parseInt(nums[3],10);
  var count = 0;
  for(var i=0 ; i<=A; i++){
	for(var j=0; j<=B; j++){
      for(var k=0; k<=C; k++){
        var sum = (500 * i) + (100 * j) + (50 * k);
        if(sum == X){
          count++;
        }
      }
    }
  }
  console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100001;
int mod=(int)(1e9 +7);
int main()
{
 int n;
 cin>>n;
 double dp[n+1][n+1];
 dp[0][0]=1;
 for(int i=1;i<=n;i++)
 {double p;cin>>p;
     for(int j=0;j<=n;j++)
     {
         if(j>i)dp[i][j]=0;
         else
         {   
             if(j==0)dp[i][j]=((double)1-p)*dp[i-1][j];
             else dp[i][j]= p*dp[i-1][j-1]+((double)1-p)*dp[i-1][j];
             
         }
     }
 }
 double ans=0;
for(int j=0;j<=n;j++)
{
    if(j>(n/2))ans+=dp[n][j];
}
cout<<setprecision(12)<<ans<<endl;
    
}
  


Measured memory_bytes: 70528
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
 
//辺edge->e : 逆辺edge->path[e.to][e.rev]
struct edge{
    int to,cap,rev;
};
 
vector<vector<edge>> path;
vector<int> visited;

void add_edge(int from,int to,int cap){
    path[from].push_back((edge){to,cap,(int)path[to].size()});
    path[to].push_back((edge){from,0,(int)path[from].size()-1});
}

int dfs(int v,int t,int f){
	if (v==t)
		return f;
	visited[v]=1;
	for(edge &e:path[v]){
		if (visited[e.to]==0 && e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if (d>0){
				e.cap-=d;
				path[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	while(1){
		visited.assign(visited.size(),0);
		int f=dfs(s,t,inf);
		if (f==0){
			return flow;
		}
		flow+=f;
	}
}

int main(){
	int n; cin>>n;
    path.assign(2*n+2,vector<edge>(0));
    visited.assign(2*n+2,0);
    vector<pp> red(n),blue(n);
    rep(i,n){
        int a,b; cin>>a>>b;
        red[i]=mk(a,b);
    }
    rep(i,n){
        int c,d; cin>>c>>d;
        blue[i]=mk(c,d);
    }
    rep(i,n)rep(j,n){
        int a,b,c,d;
        tie(a,b)=red[i];
        tie(c,d)=blue[j];
        if(a<c && b<d) add_edge(i+1,n+j+1,1); 
    }
    rep(i,n){
        add_edge(0,i+1,1);
        add_edge(n+i+1,2*n+1,1);
    }  
    cout<<max_flow(0,2*n+1)<<endl;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main() {
	int A, B, K;

	cin >> A >> B >> K;

	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			if (A % 2 == 1) A--;
			B += A / 2;
			A /= 2;
		}
		else {
			if (B % 2 == 1) B--;
			A += B / 2;
			B /= 2;
		}
	}

	cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
int dp[20000001];
int d, g;
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> d >> g;
    for(int i = 0; i <= 20000000; i++)dp[i] = 1e9;
    dp[0] = 0;
    for(int i = 1; i <= d; i++){
        int p, c; cin >> p >> c; int foo = i*100;
        for(int j = 15000000; j >= 0; j--){
            if(dp[j] == 1e9)continue;
            for(int k = p; k >= 1; k--){
                if(k == p){
                    if(dp[j]+k < dp[j+foo*k+c])dp[j+foo*k+c] = dp[j]+k;
                    continue;
                }
                if(dp[j]+k < dp[j+foo*k])dp[j+foo*k] = dp[j]+k;
            }
        }
        /*
        for(int i = 0; i <= 20000000; i++){
            if(dp[i] == 1e9)continue;
            cout << i << " " << dp[i] << endl;
        }
        cout << endl;
        */
    }

    int res = 1e9;
    for(int i = g; i <= 20000000; i++)res = min(res, dp[i]);
    cout << res << endl;
    return 0;
}


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

int main()
{
	int a[4];
	int flag = 0;
	
	cin >> a[0] >> a[1] >> a[2];
	
	if(a[0] == a[1] && a[0] != a[2])
	{
		flag = 1;
	}
	else if(a[0] == a[2] && a[0] != a[1])
	{
		flag = 1;
	}
	else if(a[1] == a[2] && a[0] != a[1])
	{
		flag = 1;
	}
	else
	{
		flag = 0;
	}
	if(flag == 1)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> hoge(n);
  for (int i = 0; i < n; i++){
    cin >> hoge[i];
  }
  sort_v(hoge);
  hoge.erase(unique(hoge.begin(), hoge.end()), hoge.end());
  if(hoge.size() == n){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  // for (int i = 0; i < n - 1; i++){
  //   if(gcd(hoge[i], hoge[i+1]) != 1){
  //     cout << "NO" << endl;
  //     return 0;
  //   }
  // }
  // cout << "YES" << endl;

}

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

int main() {

  int N, D, X;
  cin >> N >> D >> X;

  int answer = 0;
  for (int i = 0; i < N; i++) {
    
    int A;
    cin >> A;
    
    int current = 0;
    int count = 0;
    bool flg = true;

    while (flg) {
      current = A * count + 1;
      if (D < current) {
        flg = false;
      } else {
        count++;
      }
    }

    answer += count;
  
  }

  cout << answer + X << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cassert>
#include<utility>
#include<algorithm>
#include<complex>
 
using namespace std;
long long int x,y,ans;
int main(){
  cin>>x>>y;
  long long int i=x;
  while(i<=y){
    i*=2;ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		while(n-->0)
		{
			int ans=0;
			int tmp=1;
			for(int j=0;j<2;j++)
			{
				char ch[]=in.next().toCharArray();
				for(int i=0;i<ch.length;i++)
				{
					if(Character.isDigit(ch[i]))
						tmp=Integer.valueOf(ch[i]-'0');
					else if(ch[i]=='m')
					{
						ans+=1000*tmp;
						tmp=1;
					}
					else if(ch[i]=='c')
					{
						ans+=100*tmp;
						tmp=1;
					}
					else if(ch[i]=='x')
					{
						ans+=10*tmp;
						tmp=1;
					}
					else if(ch[i]=='i')
					{
						ans+=1*tmp;
						tmp=1;
					}
				}
			}
			String re="";
			int m=ans/1000;
			ans=ans-1000*m;
			int c=ans/100;
			ans=ans-100*c;
			int x=ans/10;
			ans=ans-10*x;
			int i=ans;
			if(m!=0)
			{
				if(m==1)
					re+="m";
				else
					re+=m+"m";
			}
			if(c!=0)
			{
				if(c==1)
					re+="c";
				else
					re+=c+"c";
			}
			if(x!=0)
			{
				if(x==1)
					re+="x";
				else
					re+=x+"x";
			}
			if(i!=0)
			{
				if(i==1)
					re+="i";
				else
					re+=i+"i";
			}
			System.out.println(re);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	int a,b,m,k;
	cin>>a>>b>>k;
	
	if(b-a<2*k){
		for(int i=a;i<b+1;i++){
			cout<<i<<endl;
		}
	}
	else{
		for(int i=a;i<a+k;i++){
			cout<<i<<endl;
		}
		for(int i=b-k+1;i<b+1;i++){
			cout<<i<<endl;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;



int main() {
  long long int x;
  cin >> x;
  long long int sum = 0;
  sum += x / 11;
  sum *= 2;
  if(x % 11 >= 7) {
    sum += 2;
  } else if(x % 11 != 0) {
    sum += 1;
  }

  cout << sum << endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, t;
    cin >> a >> b >> c;

    if (a > b){t = a; a = b; b = t;}
    if (b > c){t = b; b = c; c = t;}
    if (a > b){t = a; a = b; b = t;}

    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 1164
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))
num = 1000000
ans = 0
for i in range(N):
  tmp = T-H[i]*0.006
  if abs(tmp-A)<abs(num-A):
    num = tmp
    ans = i+1
print(ans)

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

int main()
{
  int N;
  cin >> N;
  vector<int> a;
  for (int i=0; i<N; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end(), greater<int>());
  int alice = 0;
  int bob = 0;

  for (int i=0; i<N; i++) {
    if (i % 2 == 0) {
      alice += a[i];
    } else {
      bob += a[i];
    }
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

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

  while(true) {
    C -= B;
    if(C <= 0) { cout << "Yes" << endl; return 0; }
    A -= D;
    if(A <= 0) { cout << "No" << endl; return 0; }
  }

  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <random>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1, 0);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(26 + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        ans -= c[t[i]] * (i - last[t[i]]) * (i - last[t[i]] - 1) / 2;
        last[t[i]] = i;
    }

    for (int i = 1; i <= 26; i++)
    {

        ans -= c[i] * (d - last[i] + 1) * (d - last[i]) / 2;
    }

    return ans;
}

int main(void)
{
    random_device seed_gen;
    mt19937 rand(seed_gen());
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    double BestScore = scoring(BestT);
    double score;

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1, 1);

    double T0 = 1e6;
    double T1 = 1e3;
    double TL = 1980;
    double msec;

    ll count = 0;

    while (1)
    {
        if (count % 100 == 0)
        {
            msec = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count();
        }

        if (msec >= TL)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        score = scoring(t);

        double p = exp((score - BestScore) / T);

        if (p > 0.5)
        {
            BestT = t;
            BestScore = score;
        }

        count++;
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }
}


Measured memory_bytes: 4436
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define MEMS(a,b) memset((a),(b),sizeof(a))
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define LL long long
#define U unsigned

LL sum[100100];
LL pre[100100];
LL suf[100100];
vector<int> a;

LL solve(vector<int> a, int n, int k) {
	FOR(i,0,n) {
		sum[i] = a[i];
		if (a[i] > 0) {
			pre[i] = a[i];
		}
		if (i) {
			sum[i] += sum[i - 1];
			pre[i] += pre[i - 1];
		}
	}
	for (int i = n - 1; i >= 0; --i) {
		if (a[i] > 0) {
			suf[i] = a[i];
		}
		if (i < n - 1) {
			suf[i] += suf[i + 1];
		}
	}
	if (n == k) {
		return sum[n - 1];
	}
	LL res = 0;
	for (int i = 0; i <= n - k; ++i) {
		LL cur = 0;
		if (i) {
			cur += pre[i - 1];
		}
		if (i + k < n) {
			cur += suf[i + k];
		}
		LL s = sum[i + k - 1];
		if (i) {
			s -= sum[i - 1];
		}
		cur += max(0ll, s);
		res = max(res, cur);
	}
	return res;
}

int main()
{
#ifdef Fcdkbear
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
        double beg = clock();
#endif

        int n,k;
        scanf("%d%d",&n,&k);
        a.resize(n);
        FOR(i,0,n) {
        	scanf("%d",&a[i]);
        }
        LL res = 0;
        res = max(res, solve(a, n, k));
        cout << res << endl;

#ifdef Fcdkbear
        double end = clock();
        fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
        return 0;
}


Measured memory_bytes: 3456
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    if a[0] == 0:
        return "0"
    ans = 1
    for _a in a[::-1]:
        ans *= _a
        if ans > 10**18:
            return "-1"
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 23432
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ans := 1
	digit := 1
	for i := 1; i < n; i++ {
		n = n - (k-1)*digit
		if n > 0 {
			ans++
			digit = digit * k
		} else {
			break
		}
	}
	fmt.Println(ans)

}


Measured memory_bytes: 512
#include<cstdio>
#include<functional>
#include<algorithm>
#define F first
#define SF second.first
#define SS second.second
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P2;
int main(void)
{
	int i,j,n,a,par[100],leng[100],sum,p1,cnt,s,t;
	P2 pp[100*99/2];
	scanf("%d",&n);
	p1=0;
	for(i=0;i<n;i++)	{
		for(j=0;j<n;j++)	{
			scanf("%d",&a);
			if(i<j && a!=-1)	{
				pp[p1].F=a;
				pp[p1].SF=i;
				pp[p1].SS=j;
				p1++;
			}
		}
	}
	sort(pp,pp+p1);
	for(i=0;i<n;i++)	{
		leng[i]=1;	par[i]=i;
	}
	cnt=1;	sum=0;
	for(i=0;i<p1;i++)	{
		s=pp[i].SF;	t=pp[i].SS;
		while(par[s]!=s)	s=par[s];
		while(par[t]!=t)	t=par[t];
		if(s!=t)	{
			if(leng[s]>leng[t])	par[t]=s;
			else if(leng[s]<leng[t])	par[s]=t;
			else {
				par[s]=t;	leng[t]++;

			}
			sum+=pp[i].F;
			cnt++;
			if(cnt==n)	break;
		}
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 2744
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

#[allow(unused_imports)]
use input::*;

fn main() {
    let (x, y, z, k): (usize, usize, usize, usize);
    input!(x, y, z, k);
    let mut v = vec![];
    let va = input_vector::<usize>();
    let vb = input_vector::<usize>();
    let mut vc = input_vector::<usize>();

    for a in &va {
        for b in &vb {
            v.push(*a + *b);
        }
    }
    v.sort();
    v.reverse();
    vc.sort();
    vc.reverse();

    let mut ans = vec![];

    for (i, vv) in v.iter().enumerate() {
        if i > k {
            break;
        }
        for c in &vc {
            ans.push(*vv + *c);
        }
    }
    ans.sort();
    ans.reverse();

    for (i, z) in ans.iter().enumerate() {
        if i == k {
            break;
        }
        p(z);
    }
}

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

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

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

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 T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

double Area(double a, double b, double c) {
    double s = (a+b+c)/2;
    double res = s*(s-a)*(s-b)*(s-c);
    if (res > 0) return sqrt(res);
    else return 0;
}

double a, l, x;

int main() {
    while (cin >> a >> l >> x) {
        double res = Area(a, l, l) + Area((l+x)/2, (l+x)/2, l) * 2;
        cout << fixed << setprecision(9) << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[][] map = new int[N][N];
        int[][] mado = new int[N][N];
        for (int i = 0; i < N; i++) {
            String s = scanner.next();
            for (int j = 0; j < N; j++) {
                map[i][j] = s.charAt(j) == '#' ? 0 : 1;
            }
        }
        for (int i = 0; i < M; i++) {
            String s = scanner.next();
            for (int j = 0; j < M; j++) {
                mado[i][j] = s.charAt(j) == '#' ? 0 : 1;
            }
        }

        int ok = 0;
        for (int i = 0; i <= N - M; i++) {
            for (int j = 0; j <= N - M; j++) {
                int ans = 0;

                for (int k = 0; k < M; k++) {
                    for (int l = 0; l < M; l++) {
                        if(map[i + k][j + l] != mado[k][l])break;
                        ans++;
                    }
                }
                if(ans == M * M)ok = 1;



            }
        }


        if(ok == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }



    } // mainMethod



} // MainClass


Measured memory_bytes: 22996
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N, x;

int main(){
	cin >> N >> x;
	set<int> use;
	for(int i = 1; i <= 2*(N-1) + 1; i++){
		use.insert(i);
	}

	if(N == 2){
		if(x != 2){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
			cout << 1 << endl;
			cout << 2 << endl;
			cout << 3 << endl;
		}
	}else{
		if(x == 1 || x == 2*(N-1)+1){
			cout << "No" << endl;
		}else{
			//if(x == 2 || x == 2*(N-1)){
				cout << "Yes" << endl;
				use.erase(1);
				use.erase(x);
				use.erase(2*(N-1)+1);
				int num = 0;
				for(auto u: use){
					if(num == use.size()/2){
						cout << 1 << endl;
						cout << x << endl;
						cout << 2*(N-1)+1 << endl;
					}
					cout << u << endl;
					num++;
				}
				/*
			}else{
				cout << "Yes" << endl;
				use.erase(1);
				use.erase(2);
				use.erase(x);
				use.erase(2*(N-1));
				use.erase(2*(N-1)+1);
				int num = 0;
				for(auto u: use){
					if(num == use.size()/2){
						cout << 1 << endl;
						cout << 2*(N-1) << endl;
						cout << x << endl;
						cout << 2 << endl;
						cout << 2*(N-1)+1 << endl;
					}
					cout << u << endl;
					num++;
				}
			}
			*/
		}
	}
}


Measured memory_bytes: 10880
"短句"
# 各単語を始まりとして57577が作れるかどうか
while True:
    n = int(input())
    if n == 0:
        break
    words = [str(input()) for _ in range(n)]

    tanku = [5, 7, 5, 7, 7]
    target = 0
    ans = 0
    for i in range(n):
        now_len = 0
        # print("i : ", i)
        for j in range(i, n):
            now_len += len(words[j])
            # print(words[j], now_len)

            if now_len == tanku[target]:
                now_len = 0
                target += 1
            elif now_len < tanku[target]:
                pass
            elif now_len > tanku[target]:
                target = 0
                break

            if target == 5:
                break
        if target == 5:
            ans = i
            break
    print(ans+1)



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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = GetString();

            foreach (char item in input)
            {
                if (char.IsUpper(item))
                {
                    Console.WriteLine("A");
                    return;
                }
                Console.WriteLine("a");
                return;
            }
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


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


int main() {
  // ここにプログラムを追記
  int K,s;
  string S,R;
  cin >>K>>S;
  s =S.size();
  if(K>=s)cout <<S<<endl;
  else{
  R = S.erase(K) + "...";
    cout<< R <<endl;}
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <array>
#include <iterator>
#include <algorithm>

int main(){
	int num;

	while(std::cin >> num){
		//input
		std::vector<int> factor;
		for(int i = 0; i < num; ++i){
			int buf;
			std::cin >> buf;
			factor.push_back(buf);
		}

		std::array<long int, 21> count = {0}; //0~20
	
		for(auto fct_itr = factor.begin(); fct_itr != factor.end(); ++fct_itr){
			std::array<long int, 21> tmp_count = {0};
			int cnt_number = 0;
			if(fct_itr == factor.begin()){
				tmp_count[*fct_itr] = 1;
			}else{
				for(auto cnt_itr = count.begin(); cnt_itr != count.end(); ++cnt_itr){
					if(cnt_number >= *fct_itr){
						tmp_count[cnt_number - *fct_itr] += *cnt_itr;
					}
					if(cnt_number + *fct_itr <= 20){
						tmp_count[cnt_number + *fct_itr] += *cnt_itr;
					}
					cnt_number++;
				}
			}
		std::copy(tmp_count.begin(), tmp_count.end(), count.begin());

		}
		
		std::cout << count.front() << std::endl;
		std::vector<int>().swap(factor);
	}

	return 0;
}

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

void trace(int A[100],int n){
    for ( int i = 0;i < n; i++ ){
        if ( i ) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

/*void insertionSort(int A[100],int n){
    int v,j;
    for ( int i = 0; i < n; i++){
        v=A[i];
        j = i - 1;
        while ((j >= 0) && (A[j] > v)){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        if(i>0)trace(A,n);
    }
}*/

/*int bubbleSort(int A[100],int n){
    int v;
    int x = 0;
    int flag = 1;
    while (flag){
        flag = 0;
        for (int j = n-1;j>0;j--){
            if ( A[j] < A[j-1] ){
                v = A[j];
                A[j] = A[j-1];
                A[j-1] = v;
                flag = 1;
                x++;
            }
        }
    }
    trace(A,n);
    
    return x;
}*/

int selectionSort(int A[100],int n){
    int x = 0;
    int v,minj;
    for (int i = 0; i < n;i++){
        minj = i;
        for (int j = i;j < n;j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(A[i] != A[minj]){
            v = A[i];
            A[i] = A[minj];
            A[minj] = v;
            x++;
        }
    }
    trace(A,n);
    
    return x;
}           

int main(){
    int n,A[100];
    cin >> n;
    for ( int i = 0; i < n; i++)cin >>A[i];
   
    //trace(A,n);
    //insertionSort(A,n);
    //cout << bubbleSort(A,n) << endl;
    cout << selectionSort(A,n) << endl;
    
    return 0;
}

Measured memory_bytes: 1160
# coding: utf-8
# Your code here!
import sys

n, m = map(int, input().split())
sc = [list(map(int, input().split())) for f in range(m)]
if n == 1:
    start = 0
    end = 10
else:
    start = 10**(n-1)
    end = 10**n
for i in range(start, end):
  x = False
  for j in sc:
    if str(i)[j[0]-1] != str(j[1]):
      x = True
      break
  if x:
    continue
  print(i)
  sys.exit()
print(-1)  

Measured memory_bytes: 9172
from functools import reduce

def main():
    n = int(input())
    t = [int(input()) for _ in range(n)]
    print(solve(t))

def solve(t):
    return reduce(lcm, t, 1)

def lcm(a, b):
    return a * b // gcd(a, b)

def gcd(a, b):
    if b == 0:
        return a
    
    return gcd(b, a % b)

main()


Measured memory_bytes: 3572
n,m=map(int,input().split())
ac=[0]*(n+1)
wa=[0]*(n+1)
for i in range(m):
  a,b=map(str,input().split())
  a=int(a)
  if ac[a]==0:
    if b=='WA':
      wa[a]+=1
    else:
      ac[a]=1
print(sum(ac))
ans=0
for i in range(n+1):
  if ac[i]==1:
    ans+=wa[i]
print(ans)

Measured memory_bytes: 75812
// #2767346

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn=2e5+10;
int n,a[maxn];
ll sum[maxn],ans=1e18;

inline ll calc(ll a,ll b,ll c){
	return abs(2*sum[b]-sum[a-1]-sum[c]);
}
inline void work(int a,int b,ll&x,ll&xx){
	int l=a,r=b;
	while(l<r){
		int midl=(l+l+r)/3,midr=(l+r+r+2)/3;
		if(calc(a,midl,b)<calc(a,midr,b))
			r=midr-1;
		else
			l=midl+1;
	}
	x=min(sum[b]-sum[l],sum[l]-sum[a-1]);
	xx=max(sum[b]-sum[l],sum[l]-sum[a-1]);
}

int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=2;i+2<=n;++i){
		ll x[4]={};
		work(1,i,x[0],x[1]);
		work(i+1,n,x[2],x[3]);
		sort(x,x+4);
		ans=min(ans,x[3]-x[0]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	map<char, char> dic = { {'A','T'},{'T','A'},{'C','G'},{'G','C'} };

	char b;
	cin >> b;
	cout << dic[b] << endl;
	return 0;
}


Measured memory_bytes: 3576
def ans(n,x):
    if n == 1:
        if x == 1:
            return 0
        elif x == 2:
            return 1
        elif x == 3:
            return 2
        else:
            return 3
    else:
        if x == 1:
            return 0
        if 2 <= x <= 2**(n+1) -2:
            return ans(n-1,x-1)
        if x == 2**(n+1) -1:
            return 2**n - 1 + 1
        if 2**(n+1) <= x <= 2**(n+2) -4:
            return 2**n - 1 + 1 + ans(n-1,x-2**(n+1)+1)
        else:
            return 2 * (2**n - 1) + 1
        
N, X = map(int,input().split())

print(ans(N,X))

Measured memory_bytes: 3064
import numpy
n = int(input())
m = list(map(int,input().split()))
s = 1
a = 0
if 0 in m:
  print(0)
  a =1
else:
  for i in range(n):
    s=s*m[i-1]
    if s>10**18:
      print(-1)
      a = 1
      break
if a == 0:
  print(s)

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

int main(int argc, const char * argv[]) {
    int A, B; cin >> A >> B;
    if (A % 2 == 1 && B % 2 == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

using namespace std;

int main()
{
  int broj;
  cin>>broj;
  int n=broj%10;
  if(n==2 || n==4 || n==5 || n==7 || n==9)
  {
      cout<<"hon"<<endl;
  }
  if(n==0 || n==1 || n==6 || n==8)
  {
      cout<<"pon"<<endl;
  }
  if(n==3)
  {
      cout<<"bon"<<endl;
  }
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 5e5 + 10;
const int inf = 0x7ffffff;
int k;
int cnt = 0;

void work(int x)
{
    queue<string> que;
    que.push("1"), que.push("2"), que.push("3"), que.push("4"), que.push("5"), que.push("6"), que.push("7"), que.push("8"), que.push("9");
    string tp;
    int cnt = 0;
    while (1)
    {
        tp = que.front(), que.pop();
        for (int i = -1; i < 2;i++)
        {
            if(tp[tp.size()-1]+i>='0' && tp[tp.size()-1]+i<='9')
            {
                tp.push_back(tp[tp.size() - 1] + i);
                que.push(tp);
                cnt++;
                if(cnt==x)
                {
                    cout << tp << "\n";
                    return;
                }
                tp.pop_back();
                
            }
        }
    }
    
}

void solve()
{
    cin >> k;
    if(k<=12)
    {
        cout << k << "\n";
        return;
    }
    work(k-9);
}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T-- > 0)
        solve();

}

Measured memory_bytes: 4736
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>

using namespace std;

/*
Kが奇数なら、1からNまでのKの倍数がn個だとして、n^3が答え。
Kが偶数なら、1からNまでのKの倍数n個、Kで割って余りがK/2の
ものがm個だとして、n^3 + m^3
*/
int main(void) {
	long long N, K;
	long long ans;
	scanf("%lld %lld", &N, &K);

	if (K % 2 == 1) {
		ans = (N / K)*(N / K)*(N / K);
	}
	else {
		ans = (N / K)*(N / K)*(N / K);
		ans = ans + ((N + K / 2) / K) * ((N + K / 2) / K) * ((N + K / 2) / K);
	}

	printf("%lld\n", ans);

}


Measured memory_bytes: 128
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

VV<ll> edges;
ll N;

const ll inf = 5e15;

void dfs(ll cur, ll pre, V<ll> &dists, ll d) {
    dists[cur] = d;
    for(ll nxt : edges[cur]) if(nxt != pre) dfs(nxt, cur, dists, d + 1);;
}

int main() {
    ll N, u, v;
    cin >> N >> u >> v;
    u--; v--;
    edges.resize(N);
    for(ll i = 1; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    V<ll> fu(N), fv(N);
    dfs(u, -1, fu, 0);
    dfs(v, -1, fv, 0);

    ll ans = 0;
    for(ll i = 0; i < N; i++) {
        if(fv[i] < fu[i]) continue;
        if(fv[i] == fu[i]) {
            bool ok = true;
            for(ll nxt : edges[i]) {
                if(fv[nxt] == fu[nxt] && fv[nxt] + 1 == fv[i]) {
                    ok = false;
                    break;
                }
            }
            if(!ok) continue;
        }
        if(fu[i] == fv[i]) {
            chmax(ans, fu[i]);
        } else {
            chmax(ans, fv[i] - 1);
        }
    }

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


Measured memory_bytes: 12544
# include "cstdio"
# include "iostream"

using namespace std;

const int maxm=1e5+10;

int N,M,K,Cnt[maxm];

int main(){
	register int i,Ans=0,X;
	scanf("%d%d",&N,&M);
	for(i=1;i<=N;i++){
		scanf("%d",&K);
		while(K--){
			scanf("%d",&X);
			Cnt[X]++;
		}
	}
	for(i=1;i<=M;i++) Ans+=(Cnt[i]==N);
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int ans[100005],n,q;
string s;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int l,r;
  cin>>n>>q;
  cin>>s;
  SFOR(i,1,s.size()+1){
    ans[i]=ans[i-1];
    if(s[i]=='C' && s[i-1]=='A') ans[i]++;
  }
  FOR(i,q){
    cin>>l>>r;
    int out;
    if(l==1) out=ans[r-1];
    else out=ans[r-1]-ans[l-2];
    if(s[l-1]=='C' && s[l-2]=='A') out--;
    cout<<out<<endl;
  }
  return 0;
}



Measured memory_bytes: 1488
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    food = {i: 0 for i in range(1, M + 1)}
    for _ in range(N):
        arr = list(map(int, input().split()))
        for i in range(1, arr[0] + 1):
            food[arr[i]] += 1
    ans = 0
    for key in food:
        if food[key] == N: ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
import java.io.BufferedReader;
import java.util.*;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;

 
public class Main {
	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		Long d,t,s;
		d = fs.nextLong();
		t = fs.nextLong();
		s = fs.nextLong();
		if(s*t >= d) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		
	
	
	}
	static final Random random=new Random();
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
 
	
}

Measured memory_bytes: 25436
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n):
    s = a[i] + a[i-1]
    if s > x:
        ans += s - x
        if a[i] >= s - x:
            a[i] -= s - x
        else:
            a[i] = 0     
print(ans)


Measured memory_bytes: 14052