akhauriyash/Code-Regression huggingface dataset:
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	LL h;
	cin>>h;
	LL res=1,res2=0;
	while(h){
		res2+=res;
		res*=2;
		h>>=1;
	}
	cout<<res2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int N;

void func(ll cur,ll use, ll &counter)
{
    if(cur > N) return;
    if(use == 0b111) counter++;

    func(cur*10 + 7, use | 0b001, counter);
    func(cur*10 + 5, use | 0b010, counter);
    func(cur*10 + 3, use | 0b100, counter);
}

int main()
{
    cin >> N;
    ll res = 0;
    func(0,0,res);
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int N;
	int v[200];
	static int ansA[1000000], ansB[1000000];
	for (int i = 0; i<=200; i++) v[i] = i * (i + 1)*(i + 2) / 6;
	ansA[0] = ansB[0] = 0;
	for (int i = 1; i<1000000; i++) {
		ansA[i] = ansB[i] = i;
		for (int j = 0; i - v[j] >= 0; j++) {
			ansA[i] = min(ansA[i], ansA[i - v[j]] + 1);
			if (v[j] % 2 == 1)
				ansB[i] = min(ansB[i], ansB[i - v[j]] + 1);
		}
	}
	while (cin >> N, N)
		cout << ansA[N] << " " << ansB[N] << endl;
}


Measured memory_bytes: 10888
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    int n=s.length()-1;
    while(1){
        if(n%2!=0){
            n--;continue;
        }
        bool abc=1;
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[i+n/2])abc=0;
        }
        if(abc==1){
            
            cout<<n<<endl;
            return 0;
        }
        n--;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
N = gets.to_i

def ps(a,b,p,q)
  # a/b - p/q
  x = a*q - b*p
  y = b*q
  g = x.gcd(y)
  [x/g,y/g]
end

(1..3500).each{ |h|
  x,y = ps(4,N,1,h)
  next if x <= 0
  (h..3500).each{ |n|
    z,w = ps(x,y,1,n)
    next if z != 1
    puts [h,n,w].join(" "); exit
  }
}


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MAX_N = 2<<15;

bool prime[MAX_N+1];

void make_prime (void )
{
	rep (i, MAX_N+1){
		prime[i] = true;
	} // end rep
	prime[0] = false;
	prime[1] = false;
	for (int i = 2; i <= MAX_N; i++ ){
		if (prime[i] ){
			for (int j = 2*i; j <= MAX_N; j += i ){
				prime[j] = false;
			} // end for
		} // end if
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.GC", "r", stdin );
	make_prime();
	int n;
	while (scanf ("%d", &n ), n ){
		int res = 0;
		for (int i = 2; i <= n-i; i++ ){
			if (prime[i] && prime[n-i] ){
				res++;
			} // end if
		} // end for
		printf ("%d\n", res );
	} // end while
		
	return 0;
}

Measured memory_bytes: 1248
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const  long long INF = 1LL << 60;
typedef  long long ll;
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;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}
ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}



int main(){
int N,M; cin >> N >> M;
vector<int> X(M);
rep(i,M){
    cin >> X[i];
}
if(N >= M) {
    cout << 0 << endl;
    return 0;
}
vector<int> d(M);
sort(all(X));
ll sum = 0;
for(int i = 0; i < M - 1; i++){
    d[i] = X[i+1] - X[i];
    sum += d[i];
}
sort(d.rbegin(),d.rend());
rep(i,N-1){
    sum -= d[i];
}
cout << sum << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<50)
int N,A,B;
int C[100000];
int func(int X){
  int ret=0;
  rep(i,0,N){
    ret+=max(0ll,(C[i]-B*X)+A-B-1)/(A-B);
  }
  return ret;
}
signed main(){
  cin>>N>>A>>B;
  rep(i,0,N) cin>>C[i];
  int left=0,right=1000000000;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)<=mid) right=mid;
    else left=mid;
  }
  int ans=right;
  if(func(left)<=left) ans=left;
  cout<<ans<<endl;
  }


Measured memory_bytes: 1024
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;
int a[maxn];

void solve() {
    int n;
    cin >> n;
    rep(i, 1, n)cin >> a[i];
    sort(a + 1, a + n + 1, greater<>());
    priority_queue<int> q;
    q.push(a[1]);
    int ans = 0;
    rep(i, 2, n) {
        ans += q.top();
        q.pop();
        q.push(a[i]);
        q.push(a[i]);
    }
    cout << ans;
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n;cin>>n;
  ll ma,mb;cin>>ma>>mb;
  ll a[n],b[n],c[n];rep(i,0,n)cin>>a[i]>>b[i]>>c[i];
  ll max_a=accumulate(a,a+n,0)+1;
  ll max_b=accumulate(b,b+n,0)+1;

  ll dp[max_a][max_b];//aグラム][bグラム]
  rep(i,0,max_a)rep(j,0,max_b)dp[i][j]=INF;
  dp[0][0]=0;
  ll ans=INF;
  rep(k,0,n){
    repr(i,max_a-1,a[k]){
      repr(j,max_b-1,b[k]){
          chmin(dp[i][j],dp[i-a[k]][j-b[k]]+c[k]);
        if(i*mb==j*ma){
          chmin(ans,dp[i][j]);
        }
      }
    }

  }
  if(ans==INF)out(-1);
  else out(ans);

  return 0;
}


Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int w, h;
int field[50][51];

void dfs(int x, int y)
{
	field[x][y] = 0;
	
	for(int dx = -1; dx <= 1; dx++){
		for(int dy = -1; dy <= 1; dy++){
			int nx = x + dx;
			int ny = y + dy;
			
			if(0 <= nx && nx < h && 0 <= ny && ny < w && field[nx][ny] == 1) dfs(nx, ny);
		}
	}
	return ;
}

void solve(void){
	int res = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(field[i][j] == 1){
				dfs(i, j);
				res++;
			}
		}
	}
	printf("%d\n", res);
}

int main(void)
{
	while(scanf("%d %d", &w, &h) != EOF){
		if(w == 0 && h == 0){ break; }
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				scanf("%d", &field[i][j]);
			}
		}
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1216
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            if (a != b && b != c && c != a)
                out.println(3);
            else if (a == c && b == c)
                out.println(1);
            else
                out.println(2);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            int n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



Measured memory_bytes: 21332
#include<stdio.h>
int main()
{   long long  n,m,x,y;
  double s;
	while(~scanf("%lld%lld%lld%lld",&n,&m,&x,&y))
	{   
		 s=n*m*1.0/2.0; 
        if(n%2==0&&m%2==0&&n/2==x&&m/2==y)
        {
			printf("%.6lf 1\n",s);
		                      
        }
        else
        {
        	printf("%.6lf 0\n",s);
		
		}
		
	} 
}


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

const int MAXN = 200005;
int a[MAXN], cnt[MAXN], vis[MAXN];
int ans;

inline void insert(int x) {
	cnt[x]++;
	int temp = x - cnt[x] + 1;
	if (temp >= 1) {
		if (!vis[temp]) ans--;
		vis[temp]++;
	}
}
inline void del(int x) {
	int temp = x - cnt[x] + 1;
	if (temp >= 1) {
		if (vis[temp] == 1) ans++;
		vis[temp]--;
	}
	cnt[x]--;
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	ans = n;
	for (register int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		insert(a[i]);
	}
	for (register int i = 0; i < m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		del(a[x]), a[x] = y, insert(y);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3712
#始点と終点は決まっていないので、軸優先や、深さ優先では手間が増えそう(これらは根っこのようなものがあるので)
#順列を使ってといて見ようと思う
#あ、、、始点決まってたわ()終点は決まってないですね。まあ、DFSやBFSでもできるけども。O(n^2)よりはO(n!)の方が小さい
from itertools import permutations

N,M = map(int,input().split())
E = []
for i in range(M):
    a,b = (int(_) for _ in input().split())
    E.append((a,b))
V = (i+1 for i in range(N))
one_strike_cnt = 0

for vertexs in permutations(V):
    #print(vertexs)
    if vertexs[0] != 1:
        continue
    #print(vertexs)
    one_strike = True#一筆描きできるならTrue
    for vertex_index in range(len(vertexs)-1):
        flag = False
        for i in range(M):
            a,b = E[i]
            if (a == vertexs[vertex_index] and b == vertexs[vertex_index+1]) or (a == vertexs[vertex_index+1] and b == vertexs[vertex_index]):
                flag = True
                break
        if not flag:
            one_strike = False
            break
    if one_strike:
        one_strike_cnt += 1

print(one_strike_cnt)


Measured memory_bytes: 3064
m1,n1=input().split( )
m,n=int(m1),int(n1)
digit=[]
c=1000000007
a=m
mod=1
while n>=1:
    if n%2==1:
        mod*=a
        mod%=c
    a**=2
    a%=c
    n//=2
print(mod)


Measured memory_bytes: 5600
#include <algorithm>
#include <deque>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N, M, ans{};
  cin >> N >> M;
  deque<ll> A(N);
  for (ll &a : A) cin >> a;
  sort(begin(A), end(A));
  vector<pair<ll, ll>> P(M);
  for (auto &[C, B] : P) cin >> B >> C;
  sort(rbegin(P), rend(P));
  
  for (auto &[C, B] : P) {
    auto l = lower_bound(begin(A), end(A), C);
    ans += accumulate(l, end(A), 0ll);
    A.erase(l, end(A));
    if (A.empty()) break;
    if (B < (int)A.size()) {
      ans += C * B;
      A.erase(begin(A), begin(A) + B);
    } else {
      ans += C * A.size();
      A.clear();
      break;
    }
  }
  ans += accumulate(begin(A), end(A), 0ll);
  cout << ans << endl;
}


Measured memory_bytes: 5564
def main():
    N,H,W = map(int,input().split())
    A,B = [],[]
    for _ in range(N):
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)
    ans = 0
    for i in range(N):
        if H<=A[i] and W<=B[i]:
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38768
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    int n,x;
    cin >> n >> x;
    vi a(n);
    rep(i,n){
        int t;
        cin >> t;
        a[i] = abs(t-x);
    }
    int ans = a.back();
    rep(i,n-1)ans = gcd(ans, a[i]);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> P;
struct edge{int to,cost;};

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

int field[7][7];
int space_sum;
int W, H;
int sy, sx;

void print_field(){
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            printf("%2d",field[i][j]);
        }
        cout << endl;
    }
}

int get_dim(int y, int x){
    int dim = 0;
    for(int k=0;k<4;k++){
        int nx = x + dx[k], ny = y + dy[k];
        if(nx<0||W<=nx||ny<0||H<=ny)continue;
        if(field[ny][nx]==0) dim++;
    }
    return dim;
}

bool dfs(int y, int x, int d_sum){
    //cout << y << " " << x << endl;
    //print_field();
    if(d_sum==space_sum){
        if(abs(sy-y)+abs(sx-x)==1)return true;
    }else{
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(field[i][j]) continue;
                if(abs(sy-i)+abs(sx-j)==1||abs(y-i)+abs(x-j)==1) continue;
                if(get_dim(i, j)==1) return false;
            }
        }
        for(int i=0;i<4;i++){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx<0||W<=nx||ny<0||H<=ny)continue;
            if(field[ny][nx]==0){
                field[ny][nx] = 1;
                if (dfs(ny, nx, d_sum+1)) return true;
                field[ny][nx] = 0;
            }
        }
    }
    return false;
}

int main(){
    while(cin >> W >> H, W){
        space_sum = 0;
        sy = -1; sx = -1;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                scanf("%d",&field[i][j]);
                if(field[i][j]==0) space_sum++;
                if(sy<0&&!field[i][j]){
                    sy = i; sx = j;
                }
            }
        }
        if(sy>=0) field[sy][sx] = 1;
        if(space_sum<4||space_sum%2==1||!dfs(sy, sx, 1)){
            cout << "No" << endl;
            continue;
        }else{
            cout << "Yes" << endl;
        }
    }

    return 0;
}

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

template<class Type>
Type solve(Type res = Type()){
    string S; cin >> S;
    
    for(int i = 0; i < S.length(); i++){
        if(i%2 == 0){
            if(S[i] == 'L') return "No";
        }else{
            if(S[i] == 'R') return "No";
        }
    }
    res = "Yes";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>	
#define pb push_back
typedef long long ll;
const int inf = 2e9;
using namespace std;

#define MAX 200005
#define MOD 1000000007

int n,m,k,t,q,p,a,b,c,x,y,minimo=inf,maximo;
ll mod=1000000007;


ll N[MAX];
//bool P[MAX];

//char M[MAX];

//char M[105][105];

//char M[1001][1001];

int main(){
	
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld",&N[i]);
		if(N[i]>i) return !printf("-1\n");
	}

	ll ans = 0;

	for (int i = 1; i < n; ++i)
	{
		if(N[i] == N[i-1] + 1) ans++;
		else {
			if(N[i]>N[i-1]) return !printf("-1\n");
			ans+=N[i];
		}
	}

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

}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
    while(1){
        int m,f,r;
        cin>>m>>f>>r;
        if(m==-1 && f==-1 && r==-1) break;
        if(m==-1 || f==-1) cout<<"F"<<endl;
            else if(m+f>=80) cout<<"A"<<endl;
            else if(m+f>=65) cout<<"B"<<endl;
            else if(m+f>=50) cout<<"C"<<endl;
            else if(m+f>=30) {if(r>=50) cout<<"C"<<endl;
                else cout<<"D"<<endl;}
            else cout<<"F"<<endl;
            }
    return 0;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int gi(){
  char ch=getchar(); int x=0,q=0;
  while(ch<'0' || ch>'9') (ch=='-'?q=1:0),ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int t[200050],ans;
int main(){
  int n=gi(),T=gi();
  t[1]=gi(),ans=T;
  for (int i=2; i<=n; ++i){
    t[i]=gi();
    if (t[i]-t[i-1]<T)
      ans-=t[i-1]+T-t[i];
    ans+=T;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 1024
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

bool f(string s){
    int N = s.length();
    REP(i, N/2){
        if(s[i]!=s[N-i-1]){
            return false;
        }
    }
    return true;
}

void Main(){
    int A, B;
    cin >> A >> B;
    int cnt = 0;
    FOR(i, B+1, A){
        if(f(to_string(i))){
            cnt++;
        }
    }
    cout << cnt << el;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a[10000];
	int cnt=0;
	int i;
	for(i=0; i<10000; i++){
		cin>>a[i];
		cnt+=1;
		if(a[i]==0){
			break;
		}
	}
	for(i=0; i<cnt; i++){
		cout<<"Case "<<i+1<<": "<<a[i]<<"\n";
		if(a[i+1]==0){
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3036
import numpy as np

def check(r, b):
    return r[0] < b[0] and r[1] < b[1]

if __name__ == '__main__':
    N = int(input())
    RED = []
    BLUE = []
    flag = []
    for i in range(N):
        RED.append(list(map(int, input().split())))

    for i in range(N):
        BLUE.append(list(map(int, input().split())))

    RED  = np.array(RED)
    BLUE = np.array(BLUE)

    args_b = np.argsort(BLUE[:,0])
    BLUE = BLUE[args_b]
    args_r = np.argsort(RED[:, 1])[::-1]
    RED  = RED[args_r]

    count = 0
    for b in BLUE:
        for i in range(len(RED[:, 0])):
            if RED[i, 0] < b[0] and RED[i, 1] < b[1]:
                count += 1
                RED = np.delete(RED, i, 0)
                break

    print(count)


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

int main() {
    string S;
    cin >> S;
    vector<int> abc(3);
    abc[S[0]-'a']++; abc[S[1]-'a']++; abc[S[2]-'a']++;

    if(abc[0]==1 && abc[1]==1 && abc[2]==1) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    if (s == "AAA" or s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

int main() {
	int n; cin >> n;
	for (int i = 0; i <= (n / 4); ++i) {
		if ((n - 4 * i) % 7 == 0) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No";
}

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

int main(){

    string s;
    cin>>s;
    int ans=0,cnt=0;
    for(auto x: s){
        if(x=='R'){
            cnt++;
        }
        else{
            cnt=0;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DOWN(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) std::cin>>(P)
#define IN2(P1,P2) std::cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) UP(I,0,N) std::cin>>V[I]
#define OUT(P) std::cout<<P<<std::endl
#define OUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTS(I,N,V) UP(I,0,N) std::cout<<V[i]<<std::endl
#define ALL(C) (C).begin(),(C).end()
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using namespace std;
using namespace __gnu_pbds;
int i,j,k;
ll N;
string S;
ll v=1;
inline void solve(){
  IN(N);
  if(N==0){
    OUT(0);
    return;
  }
	while(N) {
		if(N%(2*abs(v))) {
			S+='1';
			N-=v;
		}
		else {
			S+='0';
		}
		v*=-2;
	}
	reverse(ALL(S));
	OUT(S);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


// gcd以下の素数の数を数える
// 素因数分解でもとめる O(sqrt(n))

#define MAX_N 1'000'000'000'000
#define MAX_N_PRIME 1'000'000

i64 A, B;

i64 gcd(i64 x, i64 y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

i64 count_prime_number(i64 n) {
  i64 cnt = 1; // 1

  for (i64 i = 2; i * i <= n; i++) {
    if (n % i == 0) cnt++;
    while (n % i == 0) {
      n /= i;
    }
  }
  if (n != 1) cnt++;

  return cnt;
}


int main() {
  cin >> A >> B;

  if (A < B) swap(A, B);
  i64 n = gcd(A, B);

  cout << count_prime_number(n) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef unsigned long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
 

 int main(void)
 {
ll n;
cin>>n;
bool d =false;
if(n%2==0) d = true;

if(d)
{
    ll w=10;
    ll ans=0;
    while (w<=n)
    {
        ans = ans +n/w ;
        w*= 5;
    }

cout<<ans<<endl;

}


if(!d)
{

    cout<<0<<endl;
}
}


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

int main() {
  int N, X;
  int sum=0;
  cin >> N >> X;
  
  vector <int> m(N);
  
  for (int i=0; i<N; i++){
    cin >> m[i];
    sum += m[i];
  }
  
  sort (m.begin(), m.end());
  
  X = X - sum;
  int num = N + X/m[0];
  
  cout << num << endl;
 
        
  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  int n, a, cur = 1, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a != cur) {
      ans++;
    } else {
      cur++;
    }
  }

  cout << (ans == n ? -1 : ans) << '\n';
}


Measured memory_bytes: 256
<?php
 
list($n) = explode(" ", trim(fgets(STDIN)));

$x = [];
$ans = [];

for($i=0; $i<$n-1; $i++){
  list($a, $b) = explode(" ", trim(fgets(STDIN)));  
  if(!isset($x[$a])) $x[$a] = [];
  if(!isset($x[$b])) $x[$b] = [];
  $x[$a][$b] = true;
  $x[$b][$a] = true;
  $ans[$a." ".$b] = true;
}

$q = new SplQueue();
$q->enqueue(1);
$checked = [];
$y = [];
$z = [];
$max = 0;
while($q->count() > 0){
  $value = $q->dequeue();
  $checked[$value] = true;
  $i=1;
  foreach($x[$value] as $k => $v){
    while(1){
      if(isset($y[$value][$i])){
//        echo "OK".PHP_EOL;
        $i++;
      }else{
        break;
      }
    }
    if(isset($checked[$k])){
//      echo "NG".PHP_EOL;
      continue;
    }
//    echo $value." ".$k." ".$i.PHP_EOL;
    $y[$value][$i] = $k;
    $y[$k][$i] = $value;
    $z[$value][$k] = $i;
    $z[$k][$value] = $i;
    $q->enqueue($k);
    $max = max($i, $max);
    $i++;
  }
}

echo $max.PHP_EOL;
foreach($ans as $a => $b){
  $o = explode(" ", $a);
  echo $z[$o[0]][$o[1]].PHP_EOL;
}


Measured memory_bytes: 140024
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

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

  sort(a,a+n);

  vector<ll> v(1000001,0);
  for(int i=0;i<n;i++){
    if(v[a[i]]!=0){
      v[a[i]]++;
      continue;
    }
    ll k=1;
    while(a[i]*k<=1000000){
      v[a[i]*k]++;
      k++;
    }
  }

  ll l=0;
  for(int i;i<n;i++){
    if(v[a[i]]==1)l++;
  }
  cout << l << endl;

}

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

int main()
{
	int A, B;
	while (cin >> A >> B, A || B) {
		B -= A;
		cout << (B % 500) / 100 << ' ' << (B / 500) % 2 << ' ' << B / 1000 << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
import numpy as np
n = int(input())
#n, m = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

cnt = 0
for i in range(n):
    d1, d2 = map(int, sys.stdin.readline().split())
    if d1 == d2:
        cnt += 1
        if cnt == 3:
            print("Yes")
            sys.exit()
    else:
        cnt = 0

print("No")




        


Measured memory_bytes: 27172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main(){
    int N=in();
    int d[24];
    rep(i, 24){
        d[i]=0;
    }
    d[0]=1;
    int a;
    rep(i, N){
        cin>>a;
        d[a]++;
    }
    int check=0;
    int cnt=0;
    vector<int> Q;
    vector<int> S;
    rep(i, 13){
        if(i==0||i==12){
            if(d[i]>1){
                check=1;
                cout<<0<<endl;
                break;
            }
            else if(d[i]==1){
                Q.push_back(i);
            }
        }
        else{
            if(d[i]>2){
                check=1;
                cout<<0<<endl;
                break;
            }
            else if(d[i]==1){
                S.push_back(i);
            }
            else if(d[i]==2){
                Q.push_back(i);
                Q.push_back(24-i);
            }
        }
    }
    vector<int> U;
    int ans=0;
    int m;
    sort(S.begin(), S.end());
    if(check==0){
        if(S.size()>1){
            for(int bit=0;bit<(1<<S.size()-1);bit++){
                U=Q;
                U.push_back(S.at(0));
                rep(i, S.size()-1){
                    if(bit>>i&1){
                        U.push_back(24-S.at(i+1));
                    }
                    else{
                        U.push_back(S.at(i+1));
                    }
                }
                sort(U.begin(), U.end());
                m=100;
                rep(i, U.size()-1){
                    m=min(m, U.at(i+1)-U.at(i));
                }
                ans=max(ans, m);
            }
        }
        else if (S.size()==1){
            U=Q;
            U.push_back(S.at(0));
            sort(U.begin(), U.end());
            m=100;
            rep(i, U.size()-1){
                m=min(m, U.at(i+1)-U.at(i));
            }
            ans=max(ans, m);
        }
        else{
            U=Q;
            sort(U.begin(), U.end());
            m=100;
            rep(i, U.size()-1){
                m=min(m, U.at(i+1)-U.at(i));
            }
            ans=max(ans, m);
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
import itertools

n=int(input())

f=[list(map(int,input().split())) for i in range(n)]#operation

p=[list(map(int,input().split())) for i in range(n)]#inference

lis=[]
for i in list(itertools.product([0,1],repeat=10))[1:]:
    lisi=0
    for j in range(n):
        sj=0
        for k in range(10):
            sj+=i[k]*f[j][k]
        lisi+=p[j][sj]
    lis.append(lisi)

print(max(lis))

Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, K;
  cin >> N >> K;
  vector<long long> a(N);
  rep(i, N)
  {
    cin >> a[i];
  }

  long long ans = INT64_MAX;

  rep(div, 1 << (N + 1) - 1)
  {
    long long max_height = 0;
    vector<long long> temp = a;
    long long money = 0;
    rep(bit, N)
    {
      if (div >> bit & 1)
      {
        temp[bit] = max(max_height + 1, temp[bit]);
        money += temp[bit] - a[bit];
      }
      max_height = max(max_height, temp[bit]);
    }

    long long count = 0;
    long long min_height = -1;
    rep(i, N)
    {
      if (temp[i] > min_height)
      {
        count++;
        min_height = temp[i];
      }
    }
    if (count >= K)
      ans = min(ans, money);
  }

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

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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> D(K);
  for(int i=0;i<K;i++){
    cin>>D.at(i);
  }
  
  int y=N;
  while(1){
    N=y;
    bool flag=true;
    do{
      int x=N%10;
      for(int i=0;i<K;i++){
        if(x==D.at(i)){
          flag=false;
          break;
        }
      }
      if(!flag){
        break;
      }
      N/=10;
    }while(N!=0);
    if(flag){
      break;
    }
    y++;
  }
  
  cout<<y<<endl;
}
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin >> N;
  
  long long times = 1e12;
  for(long long i=1; i<=sqrt(N); i++){
    if((N % i) == 0 ){
      if(times > i + N/i - 2) times = i+N/i-2; 
    } 
  }
  
  
  
  cout << times << endl;
}

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

using namespace std;

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

  for(int i = 1; i <= b; i++) {
    if(i * a % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

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

#define si(n) scanf("%d",&n)
#define MAX 1000006
typedef long long ll;

ll a[MAX];

string ans(int n)
{
    if(a[n-1] -a[0] >1) return "No";
    if(a[n-1]> n-1) return "No";
    int mcnt=0,cnt=0;
    int m = a[n-1];
    for(int i=0;i<n;i++) {
        cnt+=a[i]==m-1;
        mcnt+=a[i]==m;
    }
    if((mcnt == n && m==n-1)) return "Yes";
    ll k= mcnt-n+m;
//    cout<<" k= "<<k<<"\n";
    if(k>0 && k<=m && k<= n-m ) return "Yes";
    else return "No";
}
int main()
{
    ll n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    cout<<ans(n)<<"\n";
}


Measured memory_bytes: 1024
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k)
        cout << s << endl;
    else{
        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3048
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include <typeinfo>
#include <stdlib.h>
#define ll long long
const int MOD = 1000000007;
using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

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

int N, M, Q; 
vector<ll> a, b, c, d;

ll dfs(vector<int> &A) {
    if (A.size() == N) {
        ll sum = 0;
        for(int i = 0; i < Q; i++) if(A[b[i]] - A[a[i]] == c[i]) sum += d[i];
        return sum;
    }

    int last;
    if(A.empty()) {
        last = 0;
    }else{
        last = A.back();
    }
    ll MAX = 0;
    for (int v = last; v < M; ++v) {
        A.push_back(v);
        MAX = max(MAX, dfs(A));
        A.pop_back();
    }
    return MAX;
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q); 
    b.resize(Q); 
    c.resize(Q); 
    d.resize(Q); 

    for(int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    vector<int> A;
    cout << dfs(A) << endl;
}

Measured memory_bytes: 3596
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    input! {
        n:usize,
       mut a:[usize;n],
    }

    let mut cnt = 0;

    for i in 1..n {
        if a[i - 1] == a[i] {
            a[i] = U_INF;
            cnt += 1;
        }
    }

    println!("{}", cnt);
}


Measured memory_bytes: 2096
#include <iostream>

using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = i / 60 - h * 60;
   s = i - h * 3600 - m * 60;
   cout << h << ":" << m << ":" << s << endl; 
   
   return 0;
}


Measured memory_bytes: 3100
# -*- coding: utf-8 -*-
"""
Big Integers - Multiplication of Big Integers
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_2_C&lang=jp

"""
import sys


def main(args):
    A, B = map(int, input().split())
    print(A * B)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 5620
using System;
using System.IO;
using System.Linq;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        string s = sc.Next();
        int k = sc.NextInt();
        char c = s[k - 1];

        char[] chars = s.ToArray();

        for (int i = 0; i < n; i++)
        {
            if (chars[i] != c)
            {
                chars[i] = '*';
            }
        }
        Console.WriteLine(new string(chars));
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13268