akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 100000
int kansu(int p,int q);
int a[N],s;

int main(){
  int i,b;

  scanf("%d",&s);
  for(i=0;i<s;i++)
    scanf("%d",&a[i]);

  b=kansu(0,s-1);

  for(i=0;i<s;i++){
    if(i)printf(" ");
    if(i==b)printf("[");
    printf("%d",a[i]);
    if(i==b)printf("]");
  }
  printf("\n");
  return 0;
}

int kansu(int p,int q){
  int i,j,c,d;
  c=a[q];
  i=p-1;
  for(j=p;j<q;j++){
    if(a[j]<=c){
      i++;
      d=a[i];a[i]=a[j];a[j]=d;
    }
  }d=a[i+1];a[i+1]=a[q];a[q]=d;
  return i+1;
}



Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var set = new HashSet<String>();
            var before = ' ';
            for (int i = 0; i < n; ++i)
            {
                var w = Console.ReadLine();
                if (set.Count > 0)
                {
                    if (w.First() != before ||
                        set.Contains(w))
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
                before = w.Last();

                set.Add(w);
            }
            
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13280
s = input() #天気予報
t = input() #実際の天気
count = 0
if s[0] == t[0]:
  #合ってたら１回カウントする
  count = count + 1
if s[1] == t[1]:
  count = count + 1
if s[2] == t[2]:
  count = count + 1
print(count)


Measured memory_bytes: 9128
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,v;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);

  for(i=2;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;
    }
    
    trace(A,n);
    
  }

 

  return 0;
}

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

int main() {
  int N, M; cin >> N >> M;
  vector<vector<int>> jobs(M+1);
  for(int i = 0; i < N; i++) {
    int A, B; cin >> A >> B;
    if(A > M) continue;
    jobs[A].push_back(B);
  }

  priority_queue<int> q;
  int ans = 0;
  for(int i = M-1; i >= 0; i--) {
    for(auto job: jobs[M-i]) {
      q.push(job);
    }
    if(!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <utility>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, A, B; cin >> N >> A >> B;
  if ((B-A)%2 == 0) {
    cout << "Alice" << endl;
  } else {
    cout << "Borys" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int main(){
	int h,w;
	char a[20][20];
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
	int ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			for(int k=0;k<h;k++){
				for(int l=0;l<w;l++){
					if(a[i][j]=='#'||a[k][l]=='#'){
						continue;
					}
					int sx=i,sy=j;
					int gx=k,gy=l;
					if(i==k&&j==l){
						continue;
					}
					queue<pair<pair<int,int>,int> > que;
					que.push(make_pair(make_pair(sx,sy),0));
					int s[20][20]={};
					s[sx][sy]=1;
					bool f=true;
					int diff;
					while(!que.empty()&&f){
						pair<pair<int,int>,int> hoge=que.front();
						que.pop();
						int nx=hoge.first.first,ny=hoge.first.second;
						for(int m=0;m<4;m++){
							int tx=nx+dx[m],ty=ny+dy[m];
							if(0<=tx&&tx<h&&0<=ty&&ty<w&&a[tx][ty]=='.'){
								if(tx==gx&&ty==gy){
									f=false;
									diff=hoge.second+1;
								}else if(s[tx][ty]==0){
									s[tx][ty]=1;
									que.push(make_pair(make_pair(tx,ty),hoge.second+1));
								}
							}
						}
					}
					ans=max(ans,diff);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int r;
    cin >> r;
    cout << 3 * r * r;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int output = 1;
  for(int i=0;i<N;i++){
    int temp_A = output*2;
    int temp_B = output+K;
    output = min(temp_A,temp_B);
  }
  cout << output << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>


int N;
std::vector<int> A;
int tmp;

int main()
{
    scanf("%d", &N);

    for (int i = 0; i < N; i++) {
        scanf("%d", &tmp);
        A.push_back(tmp);
    }
    auto B = A;

    std::sort(A.begin(), A.end(), std::greater<int>());

    if (A.at(0) == A.at(1)) {
        for (int i = 0; i < N; i++) {
            printf("%d\n", A.at(0));
        }
    } else {
        for (int i = 0; i < N; i++) {
            if (A.at(0) == B.at(i)) {
                printf("%d\n", A.at(1));
            } else {
                printf("%d\n", A.at(0));
            }
        }
    }

    return 0;
}


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

int main(void) {
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;

  map<char, vector<int>> mp;
  for (uint i = 0; i < S.size(); i++) {
    mp[S[i]].push_back(i + 1);
  }

  uint j = 0;
  int64_t Ans = 0;
  for (uint i = 0; i < T.size(); i++) {
    if (mp[T[i]].size() == 0) {
      cout << "-1" << endl;
      return 0;
    }
    auto itr = upper_bound(mp[T[i]].begin(), mp[T[i]].end(), j);
    if (itr != mp[T[i]].end()) {
      Ans += (*itr - j);
    } else {
      itr = mp[T[i]].begin();
      Ans += S.size() - j + *itr;
    }
    j = *itr;
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[1000005];
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p)*(b))%m;
		b=((b)*(b))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll x;
	cin>>x;
	cout<<(x>=30?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 27084
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> map(h);
    for (int i = 0; i < h; i++)
        cin >> map[i];

    vector<vector<int>> score;
    for (int i = 0; i < h; i++) {
        score.emplace_back(w);
    }

    for (int i = 0; i < h; i++) {
        int prev = 0;
        for (int j = 0; j < w; j++) {
            if (map[i][j] == '#') {
                for (int k = prev; k < j; k++)
                    score[i][k] = j - prev;
                prev = j + 1;
            }
        }
        for (int k = prev; k < w; k++)
            score[i][k] = w - prev;
    }

    for (int j = 0; j < w; j++) {
        int prev = 0;
        for (int i = 0; i < h; i++) {
            if (map[i][j] == '#') {
                for (int k = prev; k < i; k++)
                    score[k][j] += i - prev;
                prev = i + 1;
            }
        }
        for (int k = prev; k < h; k++)
            score[k][j] += h - prev;
    }

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++)
            ans = max(ans, score[i][j]);
    }
    cout << ans-1 << endl;

    return 0;
}

Measured memory_bytes: 20096
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int amount_of_use_power(int x, int p) {
    return (x - p) * (x - p);
}

int main() {
    int n;
    cin >> n;

    vector<int> x(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x.at(i);
    }

    std::vector<int>::iterator max_iter = std::max_element(x.begin(), x.end());
    std::size_t max_index = std::distance(x.begin(), max_iter);
    int max_x = x[max_index];

    std::vector<int>::iterator min_iter = std::min_element(x.begin(), x.end());
    std::size_t min_index = std::distance(x.begin(), min_iter);
    int min_x = x[min_index];

    int sum = n * (max_x - min_x) * (max_x - min_x);
    for (int p = min_x; p < max_x; p++) {
        int cand = 0;
        for (const auto& e : x)
        {
            cand += amount_of_use_power(e, p);
        }
        if (cand < sum) {sum = cand;}
    }

    cout << sum << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

/* デカい配列はここで宣言 */

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    priority_queue<ll> a;
    for (ll i = 0; i < n; i++)
    {
        ll t;
        cin >> t;
        a.push(t);
    }
    while (m > 0 && !a.empty())
    {
        ll t = a.top();
        a.pop();
        t /= 2;
        m--;
        if (t == 0)
        {
        }
        else
        {
            a.push(t);
        }
    }
    if (a.empty())
    {
        cout << 0 << endl;
    }
    else
    {
        ll ans = 0;
        while (!a.empty())
        {
            ans += a.top();
            a.pop();
        }
        cout << ans << endl;
    }
}

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

using namespace std;
const int INF = 1000000000;
int M,N,ans;
int ma[10003];
int ha[503][2];
int dp[503][10003];
int main(void){
	cin >> M >> N;
	for(int i = 0;i < M;i++){
		cin>>ma[i];
	}
	sort(ma,ma + M,greater<int>());
	for(int i = 1;i < M;i++)ma[i] += ma[i-1];
	for(int i = 0;i < N;i++){
		cin >> ha[i][0] >>ha[i][1];
	}
	
	
	for(int i = 0;i <= N;i++){
		for(int j = 1;j <= M;j++){
			dp[i][j] = INF;
		}
	}
	for(int i = 1;i <= ha[0][0];i++){
		dp[1][i] = ha[0][1];
		ans = max(ans,ma[i-1]-dp[1][i]);
	}
	for(int i = 2;i <= N;i++){
		for(int j = 1;j <= M;j++){
			dp[i][j] = min(dp[i-1][j],ha[i-1][1]+dp[i-1][max(0,j-ha[i-1][0])]);
			ans = max(ans,ma[j-1]-dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 22756
#include <bits/stdc++.h>
#define forinc(i,a,b) for (int i = a ; i <= b ; i++)
#define fordec(i,a,b) for (int i = a ; i >= b ; i--)
#define pii pair<int,int>

template <class _T> bool maximize(_T &a, _T b) {return a < b ? a = b , 1 : 0;}
template <class _T> bool minimize(_T &a, _T b) {return a > b ? a = b , 1 : 0;}

using namespace std;

int a,b,c;

int main() {
    cin >> a >> b >> c;
    cout << max(0, c - (a-b)) << endl;
    return 0;
};

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int a, b; cin >> a >> b;
    int cnt=0;
    for(int i=a; i <= b; i++){
        int s= i % 10, t = i / 10000 % 10;
        int u = i / 10 % 10, v = i/1000%10;
        if(s == t && u == v) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

struct Edge{
    int to; int cost;
    Edge(int t, int c): to(t), cost(c) { }
};
using Graph = vector<vector<Edge>>;

int n;
vector<int> memo;

void dfs(int v, int d, Graph& g) {
    memo[v] = d;
    for (auto ng: g[v]) {
        int nv = ng.to;
        int ncost = ng.cost;
        if (memo[nv] > ncost + d) {
            dfs(nv, ncost+d, g);
        }
    }
}

int main() {
    int h, w; cin >> h >> w;
    n = h * w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    Graph g(n);


    int dist = 0;
    if (s[0][0] == '#') dist++;

    rep(i, h) rep(j, w-1) {
        if (s[i][j] == '.' && s[i][j+1] == '#') {
            g[i*w+j].push_back(Edge(i*w+j+1, 1));
        } else {
            g[i*w+j].push_back(Edge(i*w+j+1, 0));
        }
    }

    rep(j, w) rep(i, h-1) {
        if (s[i][j] == '.' && s[i+1][j] == '#') {
            g[i*w+j].push_back(Edge((i+1)*w+j, 1));
        } else {
            g[i*w+j].push_back(Edge((i+1)*w+j, 0));
        }
    }

    memo.assign(n, INF);
    memo[0] = dist;
    dfs(0, dist, g);

    cout << memo[n-1] << endl;



    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    int N, K;
    while(cin >> N >> K) {
        if(N == 0) break;
        vector<ll> a(N);
        for(int i = 0; i < N; ++i) cin >> a[i];

        vector<int> s(N+1, 0);
        for(int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

        ll res = -INF;
        for(int i = 0; i <= N-K; ++i) {
            ll val = s[K+i] - s[i];
            if(res < val) res = val;
        }
        cout << res << endl;
    }

}


Measured memory_bytes: 3852
'use strict'
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function hoge(input) {
  var arr = input.split(' ').map(Number)
  arr.sort(
    function(a, b) {
      return (a < b ? -1 : 1)
    }
  )
  console.log(arr.join(" "))
  return arr
})

Measured memory_bytes: 15568
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	string s;
	cin>>s;
	char last = ' ';
	int cnt=0;
	for(char c:s) {
		if(last!=c) {
			last = c;
			cnt++;
		}
	}
	cout<<cnt;
			
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3756
n,k=map(int,input().split())
x,y=[[0,0] for i in range(n)],[[0,0] for i in range(n)]
xy=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    x_sub,y_sub=xy[i]
    x[i][0]=x_sub
    x[i][1]=i
    y[i][0]=y_sub
    y[i][1]=i
x.sort()
y.sort()
ans=(10**18)*5
for i1 in range(n):
    for l1 in range(n-i1,1,-1):
        for i2 in range(n):
            for l2 in range(n-i2,1,-1):
                x_sub1=x[i1][0]
                x_sub2=x[i1+l1-1][0]
                y_sub1=y[i2][0]
                y_sub2=y[i2+l2-1][0]
                z=[0]*n
                for i in range(n):
                    if x_sub1<=xy[i][0]<=x_sub2 and y_sub1<=xy[i][1]<=y_sub2:
                        z[i]=1
                if sum(z)>=k:
                    ans=min((x_sub2-x_sub1)*(y_sub2-y_sub1),ans)
                else:
                    break
print(ans)


Measured memory_bytes: 48220
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <iomanip>
#include <bits/stdc++.h>
#include <fstream>
#include <map>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((a+d-1)/d>=(c+b-1)/b){
        cout <<  "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>

int main()
{
	int N,M,a;
	
	if(scanf("%d %d",&N,&M)<2)
		return -1;
	
	int A[M];
	for(int i = 0;i<M;i++)
	{
		scanf("%d",&A[i]);
	}
	a=N;
	for(int i = 0;i<M;i++)
	{
		a=a-A[i];
	}

	if(a>=0)
		printf("%d\n",a);
	else
	{
		printf("-1\n");
	}
	return 0;
}


Measured memory_bytes: 1748
import sys

if __name__ == '__main__':
    N, T = map(int, input().split())
    ct = [list(map(int, input().split())) for i in range(N)]

    answer = sys.maxsize
    for i in range(N):
        ct_i = ct[i]
        c_i = ct_i[0]
        t_i = ct_i[1]
        if t_i <= T:
            if c_i < answer:
                answer = c_i

    if answer == sys.maxsize:
        answer = 'TLE'
    else:
        answer = str(answer)

    print(answer)


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

struct Dise {
	int V[6];
	void role(char c) {
		int a;
		if (c == 'E') {
			a = V[0];
			V[0] = V[3];
			V[3] = V[5];
			V[5] = V[2];
			V[2] = a;
		}
		if (c == 'N') {
			a = V[0];
			V[0] = V[1];
			V[1] = V[5];
			V[5] = V[4];
			V[4] = a;
		}
		if (c == 'S') {
			a = V[0];
			V[0] = V[4];
			V[4] = V[5];
			V[5] = V[1];
			V[1] = a;
		}
		if (c == 'W') {
			a = V[0];
			V[0] = V[2];
			V[2] = V[5];
			V[5] = V[3];
			V[3] = a;
		}
	}
	int top() {
		return V[0];
	}
};

int main() {
	Dise d;
	for (int i = 0; i < 6; i++)
		cin >> d.V[i];
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		d.role(s[i]);
	cout << d.top() << endl;
}


Measured memory_bytes: 3220
import java.util.*; 
public class Main {

  public static void main(String[] args) {
  
  Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int k=sc.nextInt();
  int ans=n;
  String d[]=new String[k];
  for (int i=0;i<k;i++){
    d[i]=sc.next();
  }
  boolean end=false;
  boolean con=false;
  String a;
  while(!end){
    a=String.valueOf(ans);
    con=false;
    for(int j=0;j<k;j++){
     if(a.contains(d[j])){
       con=true;
     }
    }
    if(con){
      ans++;
    }else end=true;
    
    
  }
 

  System.out.println(ans);
  }
  
}

Measured memory_bytes: 25932
// https://atcoder.jp/contests/abc173/tasks/abc173_b

use proconio::input;

fn main() {
    input! {
        n: i32,
        ss: [String; n],
    }
    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;
    for s in ss {
        match &*s {
            "AC" => ac = ac + 1,
            "WA" => wa = wa + 1,
            "TLE" => tle = tle + 1,
            "RE" => re = re + 1,
            _ => panic!(),
        }
    }
    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);
}


Measured memory_bytes: 7876
//You could not live with your own failure,
//where did that bring you? back to me.
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll lcm(ll a, ll b){return a*b/__gcd(a, b);}
ll gdp(ll a , ll b){return (a - (a%b)) ;}
ll ld(ll a , ll b){if(a < 0) return -1*gdp(abs(a) , b) ; if(a%b == 0) return a ; return (a + (b - a%b)) ;} // least number >=a divisible by b
ll gd(ll a , ll b){if(a < 0) return(-1 * ld(abs(a) , b)) ;    return (a - (a%b)) ;} // greatest number <= a divisible by b
#define N 500001
vector<int> adj[N];

void DFS(int v, vector<bool>& visited){
	visited[v] = true;
	cout<<v<<" ";
	for(auto i:adj[v]){
		if(visited[i]==false){
			DFS(i,visited);
		}
	}
}

void BFS(int v, vector<bool>& visited){
	queue<int> q;
	q.push(v);
	while(!q.empty()){
		int u = q.front();
		q.pop();
		cout<<u<<" ";
		visited[u]=1;
		for(auto i:adj[u]){
			if(!visited[i])q.push(i);
		}
	}
}

bool isCyclicDFS(int v, vector<bool>& visited, int parent){
	visited[v] = true;
	//cout<<v<<" ";
	for(auto i:adj[v]){
		if(visited[i]==false){
			if(isCyclicDFS(i,visited,v))
				return true;
		}
		else if(i!=parent)return true;
	}
	return false;
}

void topologicalSort(int v, vector<bool>& visited, stack<int>& s){
	visited[v]=true;
	for(auto i:adj[v]){
		if(!visited[i]){
			topologicalSort(i,visited,s);
		}
	}
	s.push(v);
}

void solve()
{
	int n; cin>>n;
	int cnt=0;
	int temp=7;
	for(int i=0;i<1000000;i++){
		int rem = temp%n;
		if(rem==0){
			cout<<i+1<<endl;
			return;
		}else{
			temp = 10*rem + 7;
		}
	}
	cout<<-1<<endl;
}

using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inp.txt", "r", stdin);
    freopen("outp.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
  	//cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //if(t<T)cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int n; cin >> n;
  
  int now = 0;
  while (now < n) now += 1000;
  cout << now - n << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(){

	int a,b;
	int d,r;
	double f;
	
	scanf("%d %d",&a,&b);
	
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	
	
	printf("%d %d %.5f\n",d,r,f);
	
	return 0;
}

Measured memory_bytes: 640
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int a,b;
	cin>>a>>b;
	a-=2*b;
	if(a<0)
	a=0;
	cout<<a;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q1();
	return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

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

using namespace std;
using ll = long long int;

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

int main(void) {
    long double a, b, x, thita; cin >> a >> b >> x;
    if (x > 0.5 * a * a * b) {
        thita = atan((2 * (a * a * b - x)) / (a * a * a));
    }
    else {
        thita = M_PI / 2 - atan((2 * x) / (a * b * b));
    }
    cout << fixed << setprecision(7) << (thita * 180) / M_PI << endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int A[3][3];
	int N;
	fx(3) {
		fy(3) {
			cin >> A[x][y];
		}
	}
	cin >> N;

	bool B[1000] = {false,};
	fx(N) {
		int b;
		cin >> b;
		B[b] = true;
	}

	if (B[A[0][0]]&& B[A[0][1]]&& B[A[0][2]]
		|| B[A[1][0]] && B[A[1][1]] && B[A[1][2]]
		|| B[A[2][0]] && B[A[2][1]] && B[A[2][2]]
		|| B[A[0][0]] && B[A[1][0]] && B[A[2][0]]
		|| B[A[0][1]] && B[A[1][1]] && B[A[2][1]]
		|| B[A[0][2]] && B[A[1][2]] && B[A[2][2]]
		|| B[A[0][0]] && B[A[1][1]] && B[A[2][2]]
		|| B[A[0][2]] && B[A[1][1]] && B[A[2][0]]) {
		cey;
	}
	else {
		cen;
	}

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N;
VI g[100010];
int d1[100010];
int dN[100010];


void makeD(){
	bool u[100010] = { false };
	queue<int> q;
	q.push(0);
	u[0] = true;
	while(!q.empty()){
		int x = q.front();
		q.pop();
		for(int v : g[x])
			if(!u[v]) q.push(v), d1[v] = d1[x]+1, u[v] = true;
	}
	fill(RNG(u, 0, N), false);
	q.push(N-1);
	u[N-1] = true;
	while(!q.empty()){
		int x = q.front();
		q.pop();
		for(int v : g[x])
			if(!u[v]) q.push(v), dN[v] = dN[x]+1, u[v] = true;
	}
}


string solve(){
	int f = 0, s = 0;
	rep(i, 0, N)
		if(d1[i] <= dN[i]) f++;
		else s++;
	if(f > s) return "Fennec";
	return "Snuke";
}


signed main(){
	cin >> N;
	rep(i, 0, N-1){
		int a, b;
		cin >> a >> b, a--, b--;
		g[a].pb(b);
		g[b].pb(a);
	}

	makeD();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    string s, t;
    cin >> s >> t;

    ll ans = 0;
    rep(i, s.size()) {
        if(s[i] != t[i]) {
            ans++;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 3856
from fractions import gcd
inpl = lambda: list(map(int,input().split()))

class SegAccumCalc:
    def __init__(self, value, N=0, calc=lambda x,y: x+y):
        M = max(len(value),N)
        N = 2**(len(bin(M))-3)
        if N < M: N *= 2
        self.N = N
        self.node = [None] * (2*N-1)
        for i, v in enumerate(value):
            self.node[i+N-1] = v
        self.calc = lambda x, y: x if y is None else y if x is None else calc(x,y)
        for i in range(N-2,-1,-1):
            left, right = self.node[2*i+1], self.node[2*i+2]
            self.node[i] = self.calc(left, right)

    def set_input(self, n, v):
        i = (self.N-1) + n
        self.node[i] = v
        while i > 0:
            i = (i-1)//2
            left, right = self.node[2*i+1], self.node[2*i+2]
            new = self.calc(left,right)
            if self.node[i] == new:
                break
            else:
                self.node[i] = new
    
    def get_input(self, n):
        return self.node[(self.N-1)+n]

    def get_output(self,
                   a=0, b=-1,
                   k=0, l=0, r=-1):
        if b < 0:
            b = self.N
        if r < 0:
            r = self.N
        if a <= l and r <= b:
            return self.node[k]
        elif r <= a or b <= l:
            return None
        else:
            left = self.get_output(a,b,2*k+1,l,(l+r)//2)
            right = self.get_output(a,b,2*k+2,(l+r)//2,r)
            return self.calc(left,right)

N = int(input())
A = inpl()
sac = SegAccumCalc(A,calc=gcd)
ans = 0
for i in range(N):
    sac.set_input(i,0)
    g = sac.get_output()
    if g > ans:
        ans = g
    sac.set_input(i,A[i])
print(ans)

Measured memory_bytes: 16140
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

    int ans = 0;
    for(int i = 0;i <= a;i++){
        for(int j = 0;j <= b;j++){
            for(int k = 0;k <= c;k++){
                int value = i * 500 + j * 100 + k * 50;
                if(value == x) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys, os.path
import math
from collections import Counter
if(os.path.exists('input.txt')):
    sys.stdin = open("input.txt","r")
    sys.stdout = open("output.txt","w")
 
 
 
MAX = 1000001
 
factor = [0]*(MAX + 1)
 
def generatePrimeFactors():
    factor[1] = 1
    for i in range(2,MAX):
        factor[i] = i
    for i in range(4,MAX,2):
        factor[i] = 2
    i = 3
    while(i * i < MAX):
        if (factor[i] == i):
            j = i * i
            while(j < MAX):
                if (factor[j] == j):
                    factor[j] = i
                j += i
        i+=1
 
 
def calculateNoOFactors(n):
    if (n == 1):
        return 1
    ans = 1
    dup = factor[n]
    c = 1
    j = int(n / factor[n])
    while (j > 1):
        if (factor[j] == dup):
            c += 1
        else:
            dup = factor[j]
            ans = ans * (c + 1)
            c = 1
        j = int(j / factor[j])
    ans = ans * (c + 1)
 
    return ans
generatePrimeFactors()
 
n = int(input())
temp = n
c = 1
count = 0
while(temp-c > 0):
    w = temp-c
    count += calculateNoOFactors(w)
    c += 1
print(count)

Measured memory_bytes: 48560
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
	IOS;
	int64 T=1;
	//cin>>T;
	while(T--)
	{
		int64 n,k;
		cin>>n>>k;
		int64 a[n],i;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		sort(a,a+n,greater<int64>());
		int64 ans=0;
		int64 st=min(n,k);
		while(st<n)
			ans+=a[st++];
		cout<<ans;
	}

	return 0;
}

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

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

void BubbleSort(vector<int> &vec,int &count) {
	bool flag = true;
	int n = vec.size();
	while (flag) {
		flag = false;
		for (int i = n - 1; i >0; --i) {
			if (vec[i - 1] > vec[i]) {
				swap(vec[i - 1], vec[i]);
				++count;
				flag = true;
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> vec;
	for (int i = 0; i < n; ++i) {
		int tmp;
		cin >> tmp;
		vec.push_back(tmp);
	}
	int count = 0;
	BubbleSort(vec, count);
	print(vec);
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 H, W;
  cin >> H >> W;
  const i64 INF = 1LL << 50;
  i64 ans = INF;
  if (H % 3 == 0 || W % 3 == 0) {
    ans = 0;
  } else {
    ans = min(H, W);
  }

  for (int i = 1; i <= H / 2; ++i) {
    i64 s1 = i * W;
    i64 s2 = (H - i) * (W / 2);
    i64 s3 = (H - i) * ((W + 1) / 2);
    i64 g = max({s1, s2, s3}) - min({s1, s2, s3});
    ans = min(ans, g);
  }
  for (int i = 1; i <= W / 2; ++i) {
    i64 s1 = i * H;
    i64 s2 = (W - i) * (H / 2);
    i64 s3 = (W - i) * ((H + 1) / 2);
    i64 g = max({s1, s2, s3}) - min({s1, s2, s3});
    ans = min(ans, g);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll>x(n);
	rep(i, n) {
		cin >> x[i];
	}
	vector<ll>dist(n - 1);
	ll ans = 0;
	rep(i, n - 1) {
		dist[i] = x[i + 1] - x[i];
		if (dist[i] * a <= b)ans += dist[i] * a;
		else {
			ans += b;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<21;
const ll INF=1LL<<60;

template<typename T>
struct SegmentTree{
    using F=function<T(T,T)>;
    
    int n;
    vector<T> dat;
    F f;
    T ti;
    
    SegmentTree(int n_ ,F f ,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
    }
    
    SegmentTree(int n_ ,vector<T> &v ,F f,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
        
        for(int i=n-1;i-(n-1)<v.size();i++) dat[i]=v[i-(n-1)];
        
        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }
    
    void update(int k,T x){
        k+=n-1;
        dat[k]=x;
        
        while(k){
            k=(k-1)/2;
            dat[k]=f(dat[k*2+1],dat[k*2+2]);
        }
    }
    
    T query_(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return ti;
        if(a<=l&&r<=b) return dat[k];
        else{
            T vl=query_(a,b,2*k+1,l,(l+r)/2);
            T vr=query_(a,b,2*k+2,(l+r)/2,r);
            return f(vl,vr);
        }
    }
    
    T query(int a,int b){
        return query_(a,b,0,0,n);
    }
    
};

int main(){

    int N,Q;cin>>N>>Q;
    SegmentTree<int> seg(N,[](int a,int b){return min(a,b);},int((1LL<<31)-1));
    
    while(Q){
        int c,x,y;cin>>c>>x>>y;
        if(c==0) seg.update(x,y);
        else cout<<seg.query(x,y+1)<<endl;
        
        Q--;
    }
    
}



Measured memory_bytes: 3900
#include <stdio.h>
int min(int x, int y) { return x < y ? x : y; }
int main() {
	int n, k, ans = 1;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		ans = min(ans + k, ans * 2);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
from collections import deque
n,q = map(int,input().split())
edge = []
cost = [0]*(n+1)
ans = [0]*(n+1)
for i in range(n+1):
    edge.append([])
for i in range(n-1):
    a,b = map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
for i in range(q):
    p,x = map(int,input().split())
    cost[p] += x

work_q = deque([1])
used = set()
used.add(1)
ans[1] = cost[1]
cnt = 0
while work_q:
    here = work_q.popleft()
    cnt = ans[here]
    for i in edge[here]:
        if i not in used:
            work_q.append(i)
            used.add(i)
            ans[i] = cnt + cost[i]
print(*ans[1:])








Measured memory_bytes: 116804
use std::io;
use std::io::BufRead;

const MOD: u64 = 1_000_000_007;


fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    
    let (n,m) = {
        let mut s = String::new();
        stdin.read_line(&mut s).unwrap();
        let mut s = s.trim().split_whitespace();
        (
            s.next().unwrap().parse::<usize>().unwrap(),
            s.next().unwrap().parse::<usize>().unwrap(),
        )
    };
    if m == 0 { println!("{}", fibonacci(n).last().unwrap()%MOD); return; }

    let a: Vec<usize> = {
        let mut a = Vec::with_capacity(m);
        for _ in 0..m {
            let mut s = String::new();
            stdin.read_line(&mut s).unwrap();
            a.push(
                s.trim().parse::<usize>().unwrap()
            );
        }
        a
    };


    let mut lag: Vec<usize> = vec![ a[0]-1 ];
    
    for i in 0..m-1 {
        let l = a[i+1] - a[i];
        if l == 1 { println!("0"); return; }
        lag.push( l-2 );
    }
    lag.push( n-a[m-1]-1 );

    
    let phi: Vec<u64> = fibonacci( *lag.iter().max().unwrap() );

    let mut prod: u64 = 1;
    for (i,l) in lag.iter().enumerate() {
        prod = prod * phi[*l] % MOD;
    }

    println!("{}", prod%MOD );
}



fn fibonacci( n: usize ) -> Vec<u64> {
    let mut phi: Vec<u64> = Vec::with_capacity(n+1);
    phi.push( 1 );
    phi.push( 1 );

    for i in 2..n+1 {
        let sum = phi[i-2] + phi[i-1];

        if sum >= MOD {
            phi.push( sum-MOD );
        } else {
            phi.push(sum);
        }
    }
    phi
}


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


void solve(){
    int a;
    cin>>a;
    cout<<a+pow(a,2)+pow(a,3);
}


int main(){
    //ll tt;cin>>tt;
    //while(tt--){
        solve();
    //}
    return 0;
}

Measured memory_bytes: 4264
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int n;
    int tab[10][10] = {};
   
    cin >> n;
    REP1(i, n){
        //cout << to_string(i)[0] << " " << i % 10 << endl;
        tab[to_string(i)[0] - '0'][i % 10]++;
    }

    REP1(i, 9){
        REP1(j, 9){
            ans += tab[i][j] * tab[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long gcd(long long a,long long b){
	long long  r=0;
	while((r=a%b)!=0){
		a=b;
		b=r;
	}

	return b;
}


int main (void){
	long long a,b,r;
	while(cin>>a>>b){
		if(a<b){
			a+=b;
			b=a-b;
			a-=b;
		}

		cout<<gcd(a,b)<<" "<<a*b/gcd(a,b)<<endl;
	}
}

Measured memory_bytes: 1156
def resolve():
    '''
    code here
    '''
    N = input()

    res = 0
    if int(str(N)[-1]) % 2 == 0:
        i = 0
        N=int(N)
        while int(N) >= 2*5**i:
            i += 1
            res += N//(2*5**i)

    print(res)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

/* 二項係数 C(n,k) mod p を計算 */
const int MOD = 1000000007;
const int MAX = 2001000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  COMinit();
  auto g = [&](ll x, ll y) { return (COM(x + y + 2, x + 1) + MOD - 1) % MOD; };
  ll ans = (g(r2, c2) - g(r1 - 1, c2)
            - g(r2, c1 - 1) + g(r1 - 1, c1 - 1) + 2*MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
#define pb push_back
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
 
 
void solve()
{
	int a, ans=0;
	
	cin>>a;
	ans= a+a*a+a*a*a;
	cout<<ans<<endl;
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
using namespace std;
int N,a,num=0;
/*int gcd(int a,int b){
  if(a<b){
    swap(a,b);
  }
  int r;
    r=a%b;
    if(r==0) return b;
    else return gcd(b,r);
  }*/
signed main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a;
    num+=a-1;
  }
  /*int ans=1;
  for(int i=0;i<N;i++){
    ans=ans*a[i]/gcd(ans,a[i]);
  }
  int num=0;
  for(int i=0;i<N;i++){
    num+=(ans-1)%a[i];
    //cout << num << endl;
  }*/
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();
        if(k % 2 == 0)System.out.println(a - b);
        else System.out.println(b - a);
    }







}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define _ << " " <<
#define all(v) v.begin(), v.end()

using namespace std;
using ll = long long;

const int mod = 1000000007;

bool bin_search(vector<ll>& a, ll v) {
	int l = 0, r = a.size() - 1;
	while (l <= r) {
		int m = (l + r) / 2;
		if (a[m] == v)  return true;
		if (a[m] < v) l = m + 1;
		else r = m - 1;
	}
	return false;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	double p = 0;
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		double cur = 1 / (double) n;
		int c = i;
		while (c < k) {
			c *= 2;
			cur /= 2.0;
		}
		p += cur;
	}
	cout << fixed << setprecision(12) << p << endl;
	return 0;
}

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

int main() {
  int p[10][10] = {}, x, y, s;
  char c1, c2;
  while (cin >> x >> c1 >> y >> c2 >> s) {
    int dx[] = {1, 0, -1, 0, 1, 1, -1, -1, 2, 0, -2, 0},
        dy[] = {0, 1, 0, -1, 1, -1, 1, -1, 0, 2, 0, -2};
    ++p[y][x];
    for (int i = 0; i < 4 * s; ++i) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || 10 <= nx || ny < 0 || 10 <= ny)
        continue;
      ++p[ny][nx];
    }
  }

  int ans1 = 0, ans2 = 0;
  for (int y = 0; y < 10; ++y) {
    for (int x = 0; x < 10; ++x) {
      if (p[y][x] == 0)
        ++ans1;
      ans2 = max(p[y][x], ans2);
    }
  }

  cout << ans1 << endl << ans2 << endl;
}


Measured memory_bytes: 2996