akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K, N;
    cin >> K >> N;
    ll A[N];
    REP(i, 0, N) {
        cin >> A[i];
    }
    ll ans = K;
    REP(i, 0, N - 1) {
        ans = min(ans, K - (A[i + 1] - A[i]));
    }
    ans = min(ans, K - (A[0] + K - A[N - 1]));
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int curx = 0, cury = 0, curt = 0;
	int t, x, y;
	for (int i = 0; i < n; ++i)
	{
		cin >> t >> x >> y;
		int dx = abs(x - curx), dy = abs(y - cury), dt = abs(t - curt);
		if (dx + dy > dt)
		{
			cout << "No";
			return 0;
		}
		else
		{
			if ((dt - dx - dy) % 2 != 0)
			{
				cout << "No";
				return 0;
			}
			else
			{
				curx = x;
				cury = y;
				curt = t;
			}
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
loop{
  n = gets.chomp.to_i
  break if n == 0
  # hash = { "上": 1, "手前": 2, "右": 3, "左": 4, "奥": 5, "下": 6 }
  ary = [1, 2, 3, 4, 5, 6]
  sum = 1
  n.times do
    houkou = gets.chomp
    if houkou == "North"
      ary[0], ary[5] = ary[5], ary[0]
      ary[0], ary[1] = ary[1], ary[0]
      ary[4], ary[5] = ary[5], ary[4]
      sum += ary[0]
    elsif houkou == "East"
      ary[0], ary[2] = ary[2], ary[0]
      ary[3], ary[5] = ary[5], ary[3]
      ary[0], ary[5] = ary[5], ary[0]
      sum += ary[0]
    elsif houkou == "West"
      ary[0], ary[2] = ary[2], ary[0]
      ary[3], ary[5] = ary[5], ary[3]
      ary[2], ary[3] = ary[3], ary[2]
      sum += ary[0]
    elsif houkou == "South"
      ary[0], ary[1] = ary[1], ary[0]
      ary[4], ary[5] = ary[5], ary[4]
      ary[0], ary[5] = ary[5], ary[0]
      sum += ary[0]
    elsif houkou == "Right"
      ary[1], ary[2] = ary[2], ary[1]
      ary[3], ary[4] = ary[4], ary[3]
      ary[2], ary[3] = ary[3], ary[2]
      sum += ary[0]
    else
      ary[1], ary[2] = ary[2], ary[1]
      ary[3], ary[4] = ary[4], ary[3]
      ary[1], ary[4] = ary[4], ary[1]
      sum += ary[0]
    end
  end
  puts sum
}


Measured memory_bytes: 6896
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int n;
int head = 1;
int tail = 0;

void enqueue(P);
P dequeue(void);

int main()
{
  int i, q, c = 0;
  P u;

  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++)
    {
      scanf("%s", Q[i].name);
      scanf("%d", &Q[i].t);
    }

  tail = n+1;
  
  while(1)
    {
      u = dequeue();

      if(strcmp(u.name,"end") == 0)break;

      if(u.t <= q)
	{
	  c += u.t;
	  printf("%s %d\n",u.name,c);
	}
      else
	{
	  u.t -= q;
	  c += q;
	  enqueue(u);
	}
    }
  
  return 0;
}

void enqueue(P num)
{
  int next = (tail+1)%(LEN+1);

  if(next == head)
    {
      printf("Queue overflow!\n");
      exit(2);
    }
  Q[tail] = num;
  tail = next;
}

P dequeue(void)
{
  P val;

  if(head == tail)
    {
      strcpy(val.name,"end");
      return val;
    }
  val = Q[head];
  head = (head+1)%(LEN+1);
  return val;
}



Measured memory_bytes: 11896
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll A,B,C;
  cin>>A>>B>>C;
  FOR(i,0,10000000){
    if(A%2!=0||B%2!=0||C%2!=0){
      cout<<i<<endl;
      return 0;
    }
    ll a,b,c;
    a=A;
    b=B;
    c=C;

    A=(b+c)/2;
    B=(c+a)/2;
    C=(a+b)/2;



  }
      cout<<-1<<endl;
  return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
bool greater_pair(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first!=b.first){
        return a.first>b.first;
    }else{
        return a.second>b.second;
    }
}

int main() {
    ios::sync_with_stdio(false);
    string S=in<string>();
    string ans="";
    vector<string> key(2);
    key={"0","1"};
    REP(i,S.length()){

        if(S[i]=='B'){
            if(ans.length()==0)continue;
            ans=ans.substr(0,ans.length()-1);
        }else{
            ans+=key[S[i]-'0'];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define mp make_pair
#define pb push_back
#define _GLIBCXX_DEBUG
const int INF=1e15;
typedef pair<int,int> P;

int dist(P A,P B){
    return abs(A.first-B.first)+abs(A.second-B.second);
}

signed main(){
  	int N;cin>>N;
    int ansx,ansy,ansh;
    vector<pair<P,int>>vec(N);
    REP(i,N){
        int x,y,h;cin>>x>>y>>h;
        P d=mp(x,y);
        vec[i]=mp(d,h);
    }
  	bool fin=false;
    REP(i,101){
        REP(j,101){
            P place=mp(i,j);
            int ifh=0;
            bool ok=true;
            REP(k,N){
              	if(ifh==0&&vec[k].second!=0)ifh=vec[k].second+dist(place,vec[k].first);
                else{
                    if((vec[k].second==0&&dist(place,vec[k].first)<ifh)||(vec[k].second!=0&&ifh!=vec[k].second+dist(place,vec[k].first)))ok=false;
                }
                if(k==N-1&&ok){
                  	ansx=place.first;
                    ansy=place.second;
                    ansh=ifh;
                }
            }
        }
    }
    cout<<ansx<<" "<<ansy<<" "<<ansh<<endl;
}

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

bitset<4000020> b;

int n,a,c=0,cc;

int main()
{
	scanf("%d",&n);
	b[0]=1;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a);
		b|=b<<a,c+=a;
	}
	cc=c;
	c=(c+1)>>1;
	for(int i=c;i<=cc;++i)
	{
		if(b[i])
		{
			printf("%d\n",i);
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int minval = Integer.MAX_VALUE;
        int maxval = Integer.MIN_VALUE;
        for (int i=0; i<n; i++) {
            int x = sc.nextInt();
            minval = Math.min(minval, x);
            maxval = Math.max(maxval, x);
        }
        System.out.println(maxval-minval);
    }
}

Measured memory_bytes: 21972
import java.util.*;

class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long d = sc.nextInt();
    long[] x = new long[n];
    long[] y = new long[n];
    int cnt = 0;
    d *= d;
    
    for (int i=0; i<n; i++) {
      x[i] = sc.nextLong();
      x[i] *= x[i];
      y[i] = sc.nextLong();
      y[i] *= y[i];
      if (x[i]+y[i] <= d)
        cnt++;
    }
    
    System.out.println(cnt);
  }
}

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


int factorial(int n) {
    if(n==0) return 0;
    int ans = 1;
    int m=n;
    while(m>1) {
        ans*=m;
        m--;
    }
    return ans;
}

int ranking(int n, int arr[]) {
    int ans = 1;
    int check[n];
    
    for(int i=0; i<n; i++) check[i]=i;

    for(int i=0; i<n; i++) {     
        ans += factorial(n-1-i)*check[arr[i]-1];
        for(int j=arr[i]-1; j<n; j++) check[j]--;
    }
    
    return ans;
}


int main() {
    int n;
    cin>>n;
    int p[n];
    int q[n];
    for(int i=0; i<n; i++) cin>>p[i];
    for(int i=0; i<n; i++) cin>>q[i];

    int a,b;
    a=ranking(n, p);
    b=ranking(n, q);

    if(a>b) cout<<a-b<<endl;
    else cout<<b-a<<endl;

    return 0;
}

Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
$s = H.times.map{ gets.chomp.chars.map{|chr| chr == "." ? 0 : chr} }
def add(i, j)
    [*i-1..i+1].product([*j-1..j+1]).each do |x, y|
        if (0..(H-1)).include?(x) && (0..(W-1)).include?(y) && $s[x][y].is_a?(Numeric)
            $s[x][y] += 1
        end
    end
end
for i in 0..H-1
    for j in 0..W-1
        if $s[i][j] == "#"
            add(i, j)
        end
    end
end
puts $s.map{|ary| ary.join("")}

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

int w, h, cell[21][21], min_turn;

const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};

void dfs(int ai, int aj, int t) {
  if (t >= min_turn) return;
  
  for (int i = 0; i < 4; i += 1) {
    int ti = ai + di[i], tj = aj + dj[i];
    if (ti < 0 || tj < 0 || ti >= h || tj >= w) continue;
    if (cell[ti][tj] == 1) continue;
    
    while (true) {
      if (cell[ti][tj] == 3) {
        min_turn = t + 1;
        break;
      }
      ti += di[i], tj += dj[i];
      if (ti < 0 || tj < 0 || ti >= h || tj >= w) break;
      if (cell[ti][tj] == 1) {
        cell[ti][tj] = 0;
        dfs(ti - di[i], tj - dj[i], t + 1);
        cell[ti][tj] = 1;
        break;
      }
    }
  }
}

void solve() {
  int si, sj;
  for(int i=0;i<h;i++)
  for(int j=0;j<w;j++) {
    cin>>cell[i][j];
    if (cell[i][j] == 2) si = i, sj = j;
  }
  
  min_turn = 11;
  dfs(si, sj, 0);
  
  if (min_turn > 10) min_turn = -1;
  cout<<min_turn<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>w>>h, w||h) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func ok(s, t string) bool {
	if len(s) != len(t) {
		return false
	}
	
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] && s[i] != '?' {
			return false
		}
	}
	return true
}

func main() {
	var s, t string
	s = next()
	t = next()
	
	res := ""
	for i := 0; i + len(t) <= len(s); i++ {
		var ss = s[i:i+len(t)]
		if ok(ss, t) {
			res = s[:i] + t + s[i+len(t):]
		}
	}
	if len(res) != 0 {
		fmt.Println(strings.Replace(res, "?", "a", -1))
	} else {
		fmt.Println("UNRESTORABLE")
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int mt1 = h1*60+m1;
    int mt2 = h2*60+m2;
    mt2 -= k;
    cout << mt2-mt1 << endl;

}

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

int main(int argc, char const *argv[])
{
    int x,y;
    while(1){
        
        cin>>x>>y;
        if(x==0 && y==0)break;
        if(x>=y)cout<<y<<" "<<x<<endl;
        else cout<<x<<" "<<y<<endl;
    }
    return 0;

}


Measured memory_bytes: 3092
#include <iostream>
#include <set>
#include <cmath>
#include <tuple>
#include <vector>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#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 MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	ll n,ans=1;
	std::cin >> n;
	for ( ll i = 1LL ; i <= n ; i++ ) {
		ans = ans*i % MOD;
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    cout << (t / a) * b << endl;
    return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n, m = lmi()
a = [1] * (n+1)
for i in range(m):
    a[int(input())] = 0
k = [0] * (n+1)
k[0] = 1
for i in range(1,n+1):
    if i == 1 and a[1]:
        k[1] = 1
    elif i >= 2 and a[i]:
        k[i] = k[i-1] + k[i-2]
        k[i] %= 10 ** 9 + 7

print(k[n])


Measured memory_bytes: 7668
#include <stdio.h>

int main(){
    int D, N, a;

    do{
        scanf("%d%d", &D, &N);

    }while(D<0 || D>2 || N<1 || N>100);

    if(D == 0){
        a = 1;
    } else if(D == 1){
        a = 100;
    } else if(D == 2){
        a = 10000;
    }

    if(N == 100){
        a = a * (N + 1);
    } else {
        a = a * N;
    }
    printf("%d\n", a);
}


Measured memory_bytes: 128
# dequeにinsert追加されたのは 3.5 から
from heapq import heappop,heappush,heapify
n,m = map(int,input().split())
aa = list(map(int,input().split()))
aa = list(map(lambda x:-x,aa))

heapify(aa)
for i in range(m):
  tmp = heappop(aa)  
  heappush(aa,-(-tmp//2))

print(-sum(aa))

Measured memory_bytes: 14180
INF = 10000000000
def merge(A,left,mid,right):
  count = 0
  L = A[left:mid] + [INF]
  R = A[mid:right] + [INF]
  i,j = 0,0
  for k in range(left, right):
    count += 1
    if L[i] <= R[j]:
      A[k]=L[i]
      i += 1
    else:
      A[k]=R[j]
      j += 1
  return count
def merge_sort(A,left,right):
  if left+1 < right:
    mid = (left+right)//2
    count_l = merge_sort(A,left,mid)
    count_r = merge_sort(A,mid,right)
    return merge(A,left,mid,right) + count_l + count_r
  return 0


n = int(input())
A = [int(i) for i in input().split()]
count = merge_sort(A, 0, n)
for i in range(n):
  if i:
    print(" ", end = "")
  print(A[i], end = "")
print()
print(count)  



Measured memory_bytes: 61660
class Dice
	TOP=0
	FRONT=1
	RIGHT=2
	LEFT=3
	BACK=4
	BOTTOM=5
	
	def initialize( nums )
		@face = nums
	end

	def rolltoTopIndex( faceindex )
		case faceindex
		when FRONT
			roll( "N" )
		when RIGHT
			roll( "W" )
		when LEFT
			roll( "E" )
		when BACK
			roll( "S" )
		when BOTTOM
			roll( "NN" )
		when TOP
		end
	end
	
	def roll( actions )
		for i in ( 0 ... actions.length )
			t = 0
			case actions[i]
			when "E"
				t =   @face[ TOP  ]
				@face[ TOP  ] =   @face[ LEFT  ]
				@face[ LEFT  ] =   @face[ BOTTOM  ]
				@face[ BOTTOM  ] =   @face[ RIGHT  ]
				@face[ RIGHT  ] = t
			when "N"
				t =   @face[ TOP  ]
				@face[ TOP  ] =   @face[ FRONT  ]
				@face[ FRONT  ] =   @face[ BOTTOM  ]
				@face[ BOTTOM  ] =   @face[ BACK  ]
				@face[ BACK  ] = t
			when "S"
				t =  @face[ TOP  ]
				@face[ TOP  ] =  @face[ BACK  ]
				@face[ BACK  ] =  @face[ BOTTOM  ]
				@face[ BOTTOM  ] =  @face[ FRONT  ]
				@face[ FRONT  ] = t	
			when "W"
				t =  @face[ TOP  ]
				@face[ TOP  ] =  @face[ RIGHT  ]
				@face[ RIGHT  ] =  @face[ BOTTOM  ]
				@face[ BOTTOM  ] =  @face[ LEFT  ]
				@face[ LEFT  ] = t	
			when "M"
				t =  @face[ FRONT  ]
				@face[ FRONT  ] =  @face[ RIGHT  ]
				@face[ RIGHT  ] =  @face[ BACK  ]
				@face[ BACK  ] =  @face[ LEFT  ]
				@face[ LEFT  ] = t				
			end
		end
	end
	attr_accessor :face
end

def isDiffDice( dice1, dice2 )
	cnt = 0
	diceface = dice2.face
	catch ( :samedice ) do
		for i in ( Dice::TOP .. Dice::BOTTOM )
			if dice1.face[Dice::TOP] == dice2.face[i]
				dice2.rolltoTopIndex( i )
				for j in ( Dice::FRONT .. Dice::BACK )
					if dice1.face[Dice::FRONT] == dice2.face[Dice::FRONT]
						cnt = 0
						for k in ( Dice::TOP .. Dice::BOTTOM )
							if dice1.face[k] == dice2.face[k]
								cnt += 1
							end
						end
						throw :samedice if cnt == 6
					end
					dice2.roll( "M" )
				end
			end
			dice2.face = diceface
		end
	end
	if cnt == 6
		return false
	else
		return true
	end
end	

n = gets.to_i
dices = Array.new( n ) {
	diceface = gets.split( " " ).map { |val| val.to_i }
	Dice.new( diceface )
}

flag = true
catch ( :samedice ) do
	for i in ( 0 ... n-1 )
		for j in ( i+1 ... n )
			if !isDiffDice( dices[i], dices[j] )
				puts( "No" )
				flag = false
				throw :samedice
				break
			end
		end
	end
end

if flag
	puts( "Yes" )
end 

Measured memory_bytes: 6096
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double pi = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

int main(){
    int N;
    cin >> N;
    double T,A;
    cin >> T >> A;
    double mini = 1e9;
    int mini_num = 0;
    for(int i = 0; i < N ; i++){
        int a;
        cin >> a;
        double score = T - a * 0.006;
        if(abs( A - score) < mini){
            mini = abs(A-score);
            mini_num = i;
        } 
    }
    cout << mini_num + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<std::vector<int>> edg(n);
    std::vector<std::vector<long long>> cost(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b, c; std::cin >> a >> b >> c;
        a--; b--;
        edg[a].push_back(b);
        edg[b].push_back(a);
        cost[a].push_back(c);
        cost[b].push_back(c);
    }
    int q, k; std::cin >> q >> k;
    k--;
    std::vector<long long> dist(n, 1e18);
    std::priority_queue<std::pair<long long, int>> que;
    que.emplace(0, k);
    dist[k] = 0;
    while (!que.empty()) {
        int pos = que.top().second;
        que.pop();
        for (int i = 0; i < (int)edg[pos].size(); i++) {
            int u = edg[pos][i];
            long long c = cost[pos][i];
            if (dist[u] <= dist[pos] + c) continue;
            dist[u] = dist[pos] + c;
            que.emplace(-dist[u], u);
        }
    }
    while (q--) {
        int x, y; std::cin >> x >> y;
        x--; y--;
        std::cout << dist[x] + dist[y] << std::endl;
    }
    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N, K; cin >> N >> K;
  vector<ll> a(N);
  vector<ll> sum(N + 1);
  vector<ll> pSum(N + 1);
  rep(i, N) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
    pSum[i + 1] = pSum[i];
    if(a[i] > 0) {
      pSum[i + 1] += a[i];
    }
  }

  ll NG = -(1LL<<50);

  ll ans = NG;

  rep(startK, N - K + 1) {
    ll SB = sum[startK + K] - sum[startK];
    // K区間を白とみなして、他を貪欲に取る
    // 他は貪欲をあらかじめ計算しておいて、sumを取るだけ
    ll cand = pSum[startK] + pSum[N] - pSum[startK + K];
    if(SB > 0) cand += SB;
    ans = max(ans, cand);
  }

  cout << (ans == NG ? 0 : ans) << endl;
  
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
struct state{
  int leg;
  int x,y;
  int cost;
  state(int x,int y,int cost,int leg) : x(x), y(y), cost(cost), leg(leg) {}
};
bool operator < (state s,state r){
  return s.cost > r.cost;
}
int main(void){
  int w,h;
  while(cin>>w>>h,w){
    char grid[100][100];
    int mincost[100][100][2];
    memset(mincost,-1,sizeof(mincost));
    REP(y,h)REP(x,w){
      cin>>grid[y][x];
    }
    priority_queue<state> que;
    REP(y,h)REP(x,w){
      if(grid[y][x]=='S'){
        que.push(state(x,y,0,0));
        que.push(state(x,y,0,1));
      }
    }
    bool output=false;
    while(!que.empty()){
      state s = que.top(); que.pop();
      if(grid[s.y][s.x]=='T'){
        cout<<s.cost<<endl;
        output=true;
        break;
      }
      if(mincost[s.y][s.x][s.leg]!=-1&&s.cost>=mincost[s.y][s.x][s.leg]) continue;
      mincost[s.y][s.x][s.leg] = s.cost;
      if(s.leg==0){
        for(int dx = 1; dx<=3; dx++){
          for(int dy = -3; dy<=3; dy++){
            if(dx + abs(dy) <= 3){
              int nx = s.x + dx;
              int ny = s.y + dy;
              if(0<=nx&&nx<w&&0<=ny&&ny<h&&grid[ny][nx]!='X'){
                char ch = grid[ny][nx];
                que.push(state(nx,ny,s.cost+((ch>='0'&&ch<='9')?ch-'0':0),1));
              }
            }
          }
        }
      }
      if(s.leg==1){
        for(int dx = -1; dx>=-3; dx--){
          for(int dy = -3; dy<=3; dy++){
            if(abs(dx) + abs(dy) <= 3){
              int nx = s.x + dx;
              int ny = s.y + dy;
              if(0<=nx&&nx<w&&0<=ny&&ny<h&&grid[ny][nx]!='X'){
                char ch = grid[ny][nx];
                que.push(state(nx,ny,s.cost+((ch>='0'&&ch<='9')?ch-'0':0),0));
              }
            }
          }
        }
      }
    }
    if(!output) cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1104
H,W,D = $stdin.gets.chomp.split(" ").map(&:to_i)
B = {}
H.times{ |i|
  $stdin.gets.chomp.split(" ").map(&:to_i).each_with_index{ |a,j|
    B[a] = { x:i, y:j }  
  }
}

S = ((1+D)..(H*W)).map{ |l| 
  (B[l-D][:x] - B[l][:x]).abs + (B[l-D][:y] - B[l][:y]).abs
}

SS = (0..D).map{ 0 }
S.each{ |s| SS << (SS[-D] + s) }

Q = $stdin.gets.chomp.to_i
Q.times {
  l,r = $stdin.gets.chomp.split(" ").map(&:to_i)
  puts l < r ? SS[r] - SS[l] : 0
}


Measured memory_bytes: 37116
#include<iostream>

using namespace std;

int main()
{
	int nValue;
	cin >> nValue;
	if ((nValue % 10) % 10 == 3)
	{
		cout << "bon";
	}
	else if (((nValue % 10) % 10 == 0) || ((nValue % 10) % 10 == 1) || ((nValue % 10) % 10 == 6) || ((nValue % 10) % 10 == 8))
	{
		cout << "pon";
	}
	else
	{
		cout << "hon";
	}
		cout << endl;
}

Measured memory_bytes: 3640
//ABC068B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 1;
	while(2*ans <= n){
		ans *= 2;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void)
{
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> route;
    for(size_t i = 0; i < N; i++)
    {
        int c, t;
        scanf("%d %d", &c, &t);
        if (t<=T)
        {
            route.push_back({c, t});
        }
    }
    sort(route.begin(), route.end(), 
        [](const pair<int, int> &x, const pair<int, int> &y) { return x.first < y.first;}
    );
    if (!route.empty())
    {
        cout << route.front().first << endl;
    }
    else
    {
        cout << "TLE" << endl;
    }
    return 0;
}

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

int main() {
  int s, c;
  c = 0;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s%10 == 1)
      c++;
    s = s/10;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
import java.util.*

import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val k = sc.nextInt()
  val p = (1..n).map { sc.nextInt() - 1 }.toIntArray()
  val c = (1..n).map { sc.nextLong() }.toLongArray()


  val array = Array(n) { Pair(0, 0L) }
  for (i in 0 until n) {
    var now = i
    var count = 0
    var sum = 0L
    while (true) {
      now = p[now]
      count++
      sum += c[now]
      if (now == i) break
    }
    array[i] = Pair(count, sum)
  }

  var max = Long.MIN_VALUE
  for (i in 0 until n) {
    val ai = array[i]
    val size = ai.first
    val sum = ai.second

    val kk = k / size - 1
    val last = k % size

    var score = 0L
    if (sum > 0) {
      score += sum * kk
    }
    var now = i
    for (j in 0 until size + last) {
      now = p[now]
      score += c[now]
      max = Math.max(score, max)

    }

  }

  println(max)

}

Measured memory_bytes: 51264
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
//#include <bits/stdc++.h>

using namespace std;

long long n, m, u, v;

long long tohop ( long long n, long long m ) {
    long long t = 1;
    for ( int i = n - m + 1; i <= n; i++) {
        t = t * i;
    }
    long long u = 1;
    for ( int i = 1; i <= m; i++) {
        u = u * i;
    }
    return t / u;
}

int main () {
    cin >> n >> m;
    u = 2; v = 2;
    cout << tohop(n, u) + tohop(m, v);
}


Measured memory_bytes: 888
def func(li,b) :
    sum = 0
    for i in range(len(li)) :
        sum+= abs(li[i] - b - i - 1)
    return sum
def binary_search(li) :
    left = -1000000001
    right = 1000000001
    while right - left > 1 :
        med = (right + left) // 2
        x = func(li,med)
        mdx = func(li,med-1)
        pdx = func(li,med+1)
        if mdx > x and pdx < x :
            left = med
            continue
        elif mdx < x and pdx > x :
            right = med
            continue
        elif mdx >= x and pdx >= x :
            return x
    else :
        return -1
N = int(input())
A =[int(i) for i in input().split()]
print(binary_search(A))


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

int main(){
    string s;
    cin >> s;
    
    string Ans;
    int temp;
    
    int w=0;
    int l=0;
    int hit=0;
    
    for(int k=1;k<=s.size();k++){
        hit++;
        if(s[k-1]=='o'){
            w++;
        } else if(s[k-1]=='x') {
            l++;
        }
    }
    
    temp=15-hit;
    
    if(temp==0){
        if(w>=8){
            Ans="YES";
        } else {
            Ans="NO";
        }
    } else {
        if(temp+w>=8){
            Ans="YES";
        } else {
            Ans="NO";
        }
    }
    
    cout << Ans << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> group;
    for (int i = 1; i <= N / 2; i++) {
        vector<int> t;
        t.push_back(i);
        if (N % 2 == 0) {
            t.push_back(N + 1 - i);
        } else {
            t.push_back(N - i);
        }
        group.push_back(t);
    }
    if (N % 2 == 1) {
        vector<int> t;
        t.push_back(N);
        group.push_back(t);
    }

    if (N % 2 == 0) {
        cout << N * (N - 2) / 2 << endl;
    } else {
        cout << ((N - 1) * (N - 2) + (N - 1)) / 2 << endl;
    }

    for (int i = 0; i < group.size(); i++) {
        for (int j = i + 1; j < group.size(); j++) {
            for (int u : group[i]) {
                for (int v : group[j]) {
                    cout << u << " " << v << endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
int main(){
	LL n, m,sum=0;
	cin >> n >> m;
	sum = m * 1900 + (n - m) * 100;
	cout << sum*pow(2,m) << endl;
	return 0;
}
//608000 1900*32

Measured memory_bytes: 1016
#!/usr/bin/env python3
import sys
from bisect import bisect_left, bisect_right

def solve(N: int, L: "List[int]"):
    L.sort()

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            k = bisect_left(L, L[i]+L[j])
            ans += (k-j-1)

    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <list>
#include <numeric>
#include <math.h>
#include <cstdlib>
#include <queue>
#include <iterator>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>
#include <bitset>
#include <mutex>
#include <condition_variable>
#include <atomic>
#include <stack>
#include <memory>
#include <deque>
#include <string_view>
#include <random>
#include <chrono>
#include <cstring>

using namespace std;

static int my_speed_up = []() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
using ll = long long; using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T> using vv = vector<vector<T>>;
template<class T> using vvv = vector<vector<vector<T>>>;
template<class T> using vvvv = vector<vector<vector<vector<T>>>>;
#define for_b(i, b) for (int i = 0; i < (b); ++i)
#define for_ab(i, a, b) for (int i = a; i < (b); ++i)
#define what_is(x) cout << #x << " = " << x << endl;
#define what_are(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl;
#define pad(x) for_b(i, x) cout << "  ";
#define show_1d(___x) cout << #___x << " = "; for (auto& ___num : ___x) cout << ___num << ", "; cout << endl;
#define show_2d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto ___num : ___row) cout << ___num << ", "; cout << endl; }
#define show_3d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto& ___row2 : ___row) { for (auto ___num : ___row2) cout << ___num << ", "; cout << endl; }cout << endl; }

vv<int> d4 = {{1,0},{-1,0},{0,1},{0,-1}};
vv<int> d8 = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
bool is_valid_pos(const vv<int>& tb, int x, int y) {
    return x >= 0 && x < tb.size() && y >= 0 && y < tb[0].size();
}


int main()
{
    int N, X, T;
    cin >> N >> X >> T;
    
    int res = (N / X) * T + (N % X > 0 ? T : 0);
    cout << res << endl;
    
    return 0;
}


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

// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
mint f2(int n, int k) {
  return comb(n+k-1,k-1);
}
mint f(int n, int k) {
  if (n < k) return 0;
  if (n == 0 && k == 0) return 1;
  if (k < 1) return 0;
  return f2(n-k,k);
}

int main() {
  init();
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    mint blue = f(k,i);
    mint red = f2(n-k-(i-1),i+1);
    mint ans = blue*red;
    printf("%lld\n", ans.x);
  }
  return 0;
}

Measured memory_bytes: 125568
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

main :: IO ()
main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    h <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    print . length $ filter (>=k) h


Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func check(d map[int]bool, i int) bool {
	for i > 0 {
		j := i % 10
		if d[j] {
			return false
		}
		i = i / 10
	}
	return true
}

func main() {
	defer stdout.Flush()

	n := readInt()
	k := readInt()
	d := make(map[int]bool)
	for i := 0; i < k; i++ {
		x := readInt()
		d[x] = true
	}

	i := n
	for !check(d, i) {
		i++
	}
	println(i)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int intsize( int a ){
	int res = 0;
	while( a > 0 ){
		a /= 10;
		++res;
	}
	return res;
}

int main(){
	int n; cin >> n;
	int cnt = 0;
	for( int i = 1; i <= n; ++i ){
		if( intsize(i) % 2 == 1 ){
			++cnt;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
x = []
y = 0

if n == 1:
    print(0)

else:
    for i in range(n-1):
        if h[i] < h[i+1]:
            y = 0
        else:
            y = y + 1
        x.append(y)
 
    print(max(x))

Measured memory_bytes: 14228
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<string> l;
  string w,w0;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>w;
    if(find(l.begin(),l.end(),w)==l.end() && (i==0||w[0]==w0[w0.length()-1]))l.push_back(w);
    else {cout<<"No\n"; return 0;}
    w0=w;
  }
  cout<<"Yes\n";
  return 0;
}

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

signed main() {
  int N;
  cin>>N;
  int ans=0;
  if(N%10==2)ans++;
  N/=10;
  if(N%10==2)ans++;
  N/=10;
  if(N%10==2)ans++;
  N/=10;
  if(N%10==2)ans++;
  N/=10;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
(let* ((w (read))
       (h (read))
       (n (read))
       (lst (loop :repeat n :collect (list (read) (read) (read))))
       (mp (loop :repeat h :collect (loop :repeat w :collect 0))))
  (defun painter (x1 y1 x2 y2)
    (loop :for x :from x1 :upto (1- x2) :do(loop :for y :from y1 :upto (1- y2) :do(setf (nth y (nth x mp)) 1))))
  (defun solve (x y k)
    (cond ((= k 1) (painter 0 0 h x))
          ((= k 2) (painter 0 x h w))
          ((= k 3) (painter 0 0 y w))
          ((= k 4) (painter y 0 h w))))
  (mapcar (lambda (k) (apply #'solve k)) lst)
  (princ (loop :for k :in mp :sum(count 0 k :test #'=))))

Measured memory_bytes: 17124
#include <cstdio>
#include <cstdlib>
#include <cstring>

const int MAXN = 14;
const int MAXS = 1 << MAXN;

int n, m;
bool adj[MAXN][MAXN];
double p, f[MAXS];

int lowbit(int x) {

    return x & -x;
}

int main() {

    //freopen("in", "r", stdin);
    scanf("%d %d %lf", &n, &m, &p);
    p /= 100;
    int u, v;
    for (int i = 0; i < m; i++)
    {
        scanf("%d %d", &u, &v);
        u--, v--;
        adj[u][v] = adj[v][u] = true;
    }

    int range = 1 << n;
    for (int i = 0; i < range; i++)
    {
        if (!(i & (i - 1))) f[i] = 0;
        else
        {
            f[i] = 0;
            int t = i, cnt = 0;
            while (t) ++cnt, t -= lowbit(t);
            for (int j = 0; j < n; j++)
                if ((i >> j) & 1) { u = j; break; }
            int range_j = 1 << (cnt - 1);
            for (int j = 0; j < range_j - 1; j++)
            {
                t = i - lowbit(i);
                int subset = 0, lb;
                double val = 1;
                for (int k = 0; k < cnt - 1; k++)
                {
                    lb = lowbit(t);
                    if ((j >> k) & 1) subset |= lb;
                    t -= lb;
                }
                subset |= 1 << u;
                int not_subset = i ^ subset;
                for (int x = 0; x < n; x++)
                    if ((subset >> x) & 1)
                        for (int v = 0; v < n; v++)
                            if (((not_subset >> v) & 1) && adj[x][v]) val *=p;
                val *= 1 - f[subset];
                f[i] += val;
            }
          //  f[i] /= range_j;
        }
    }
/*
    for (int i = 0; i < range; i++)
    {
        printf("f[%d] = %lf\n", i, f[i]);
    }
    */
    printf("%.10f\n", 1 - f[range - 1]);

    return 0;
}

Measured memory_bytes: 944
#include<iostream>
 
using namespace std;
int main()
{
	int N,K,a[100010];
	cin >> N >> K;
	for(int i=0; i<N; i++){
		cin >> a[i];
	}
	int ans;
	if((N-1) % (K-1) == 0)
		ans = (N-1)/(K-1);
	else
		ans = (N-1)/(K-1) + 1;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()



struct Node {
	Node* c[26];
	int cnt[26];

	Node() {
		rep(i, 26)c[i] = 0;
		rep(i, 26)cnt[i] = 0;
	}
};



void add(Node *p, const string &s, int i, int cc[26]) {
	if (s.size() == i)return;

	if (p->c[s[i] - 'a'] == nullptr) {
		p->c[s[i] - 'a'] = new Node();
	}

	add(p->c[s[i] - 'a'], s, i + 1, cc);
	cc[s[i] - 'a'] = 1;
	rep(j, 26) {
		p->cnt[j] += cc[j];
	}
}


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

	int n;
	cin >> n;

	Node* root = new Node();

	vector<string> s;
	rep(i, n) {
		string ss;
		cin >> ss;
		s.push_back(ss);

		reverse(all(ss));
		int cc[26] = {};
		add(root, ss, 0, cc);
	}

	long long ans = 0;

	rep(i, n) {
		const Node* node = root;
		for (int j = s[i].size() - 1; j >= 1; j--) {
			node = node->c[s[i][j] - 'a'];
			if (node == nullptr) {
				break;
			}
		}
		if (node) {
			ans += node->cnt[s[i][0] - 'a'];
		}
	}
	ans -= n;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 358660