akhauriyash/Code-Regression huggingface dataset:
n, m = [int(item) for item in input().split()]
abc = [[int(item) for item in input().split()] for _ in range(m)]
INF = 10 ** 9

edge = [[INF] * n for _ in range(n)]
v_edge = [[1] * n for _ in range(n)]
for a, b, c in abc:
    edge[a-1][b-1] = c
    edge[b-1][a-1] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            edge[i][j] = min(edge[i][j], edge[i][k] + edge[k][j])

count = 0
for a, b, c in abc:
    if edge[a-1][b-1] != c:
        count += 1
print(count)

Measured memory_bytes: 3568
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

typedef struct
{
  ll t;
  ll x;
  ll y;
} hoge;

int main()
{
  ll n;
  hoge a[100005];
  scanf("%lld", &n);
  a[0].t = 0, a[0].x = 0, a[0].y = 0;
  for (ll i = 1; i < n + 1; i++)
  {
    scanf("%lld%lld%lld", &a[i].t, &a[i].x, &a[i].y);
  }
  for (ll i = 0; i < n; i++)
  {
    ll t_diff = llabs(a[i].t - a[i + 1].t), x_diff = llabs(a[i].x - a[i + 1].x), y_diff = llabs(a[i].y - a[i + 1].y);
    if ((x_diff + y_diff > t_diff) || ((t_diff % 2 != (x_diff + y_diff) % 2)))
    {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 2560
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 0, 3)
	{
		if (s[i] == t[i])ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long
const ll mod=1e9+7;
ll n,k,a[107],dp[107][100007],pre[100007];

int main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=0;i<=n;i++){
		dp[i][0]=1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k+1;j++){
			pre[j]=pre[j-1]+dp[i-1][j-1];
		}
		for(int j=1;j<=k;j++){
			dp[i][j]=(dp[i][j]+pre[j+1]-pre[max((ll)0,j-a[i])])%mod;
		}
	}
	printf("%lld",dp[n][k]);
}


Measured memory_bytes: 82624
#include <iostream>
#include <cmath>
using namespace std;
 
int main()
{
	int d,n;
  	long ans;
  	std::cin >> d >> n;
  	if(n!=100){
      ans = n * pow(100, d);
    }
  	else {
      ans = n * pow(100, d) + pow(100, d);
    }
    std::cout << ans << endl;  
}



Measured memory_bytes: 384
def lcm(x, y):
    return (x * y) // gcd(x, y)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N, M = map(int, input().split())
S = input()
T = input()

gcdNM = gcd(N, M)
lcmNM = lcm(N, M)

isGood = True
for i in range(gcdNM):
    if S[i * N // (gcdNM)] != T[i * M // (gcdNM)]:
        isGood = False
        break

if isGood and T[0] == S[0]:
    print(lcmNM)
else:
    print(-1)



Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int H, W, i, j;
		Scanner sc = new Scanner(System.in);
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (i = 0; i < H; ++i) {
				for (j = 0; j < W; ++j) {
					if (i % 2 == 0) {
						if (j % 2 == 0) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					} else {
						if (j % 2 == 0) {
							System.out.print(".");
						} else {
							System.out.print("#");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
		sc.close();
	}

}



Measured memory_bytes: 37912
import sys
num_bill, y = map(int, input().split())

for num_10000 in range(y // 10000 + 1):
    for num_5000 in range(min((y - num_10000 * 10000) // 5000 + 1, num_bill - num_10000 + 1)):
        num_1000 = num_bill - num_10000 - num_5000
        if num_1000 * 1000 + num_5000 * 5000 + num_10000 * 10000 == y:
            print(num_10000, num_5000, num_1000)
            sys.exit()

print('-1 -1 -1')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define MOD 1000000007
const ll INF = 1e18;
template <class T>
void show(vector<T> v) {
  for (int i = 0; i < v.size(); i++) {
    cerr << v[i] << " ";
  }
  cerr << 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;
}

int main(int argc, char const *argv[]) {
  ll x;
  cin >> x;
  ll cnt = 0, m = 100;
  while (m < x) {
    m = m * 1.01;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3632
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

x = LIST()
print(x.index(0) + 1)

Measured memory_bytes: 72548
// 累積和の問題
// TLEなってしまった
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

double calc(ll v) {
  double exp = double(v+1)/2;
  //cout << "exp: "  << exp<< endl;
  return exp;
}

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

  ll n, k;
  cin >> n >> k;
  vector<ll> p(n);
  vector<ll> total(n+1);
  rep(i, n) cin >> p[i];
  total[0] = 0;
  rep1(i, n) {
    total[i] = total[i-1] + p[i-1];
  }
  //cout << "----" << endl;
  //rep(i, n+1) cout << total[i] << endl;
  //cout << "----" << endl;

  double ans = 0;
  ll maxv = 0;
  for(ll i = 0; i<=n-k; ++i) {
    ll tmp = total[i+k]-total[i];
    maxv = max(maxv, tmp);
    //cout << "maxv: " << maxv << endl;
  }
  for(ll i = 0; i<=n-k; ++i) {
    ll tmp = total[i+k]-total[i];
    if (tmp == maxv) {
      ans = double(k + tmp) / 2;
      printf("%.6f", ans);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3456
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc148/tasks/abc148_f

//青木くんは一歩一歩確実に高橋くんに近づいている→高橋くんができるだけ深いとこへ行くべき
//参考：
//https://qiita.com/zk_phi/items/66de865261c9c9b38145

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N,s,t;
vector<vector<int>> to;//隣接リスト

int ans = 0;

vector<int> calcDist(int s){
	vector<int> dist(N,-1);
	//BFSでsから各頂点までの距離を求める
	queue<int> q;
	q.push(s);
	dist[s] = 0;
	while(!q.empty()){
		int now = q.front();
		q.pop();
		for(int next : to[now]){
			if(dist[next]==-1){
				q.push(next);
				dist[next] = dist[now] + 1;
			}
		}
	}
	return dist;
}

void solve(){
	//Sから全頂点までの距離を求める
	vector<int> distS = calcDist(s);
	//Tから全頂点までの距離を求める
	vector<int> distT = calcDist(t);

	int mx = 0;
	for(int i=0;i<N;i++){
		if(distS[i]<distT[i]){
			mx = max(mx,distT[i]);
		}
	}
	ans = mx-1;
}
 
int main(){
    cin >> N >> s >> t;
    s--;t--;
    to = vector<vector<int>>(N);
    for(int i=0;i<N-1;i++){
    	int a,b;
    	cin >> a >> b;
    	a--;b--;
    	to[a].push_back(b);
    	to[b].push_back(a);
    }
 
    solve();

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

Measured memory_bytes: 6656
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;

int n,c,a[50],b[50],tmp,dp[50][1<<16];

int main(){
  while(cin >> n >> c,n+c){
    for(int i=0;i<n;i++){
      a[i] = 0;
      for(int j=0;j<16;j++){
	cin >> tmp; a[i] |= tmp * (1<<j);
      }
    }
    for(int i=0;i<c;i++){
      b[i] = 0;
      for(int j=0;j<16;j++){
	cin >> tmp; b[i] |= tmp * (1<<j);
      }
    }

    for(int i=0;i<=n;i++)
      for(int j=0;j<(1<<16);j++)dp[i][j] = -1;

    dp[0][0] = 0;

    for(int i=0;i<n;i++){
      for(int j=0;j<(1<<16);j++){
	if(dp[i][j]>=0){
	  int now = j | a[i];
	  for(int k=0;k<c;k++){
	    int score = __builtin_popcount(now & b[k]);
	    int nxt = now - (now & b[k]);
	    dp[i+1][nxt] = max(dp[i+1][nxt],dp[i][j] + score);
	  }
	}
      }
    }

    int res = 0;
    for(int i=0;i<(1<<16);i++)res = max(res,dp[n][i]);
    cout << res << endl;
  }
}

Measured memory_bytes: 9352
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

def lcm(n,m):
    return n*m // gcd(n,m)


n,m = LI()
a = LI()
b = [i//2 for i in a]

lb = 1
for i in b:
    lb = lcm(lb,i)
    if lb > m:
        print(0)
        quit()

for i in b:
    if lb//i % 2 == 0:
        ans = 0
        break
else:
    ans = (m//lb + 1)//2
print(ans)


Measured memory_bytes: 60004
#include<iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int sum = 0;
    int t = n;
    while(t) {
        sum += t % 10;
        t/=10;
    }
    if(n % sum == 0) 
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
	long n,k,i,ans,mod;
	cin >> k;
	if(k%2==0){
		cout << -1 << endl; return 0;
	}
	mod=0;
	for(i=1; i<=100000000; i++){
		mod=(mod*10+7)%k;
		if(mod==0){
			cout << i << endl; return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

struct ball{
    int num;
    bool flag;
}box[100010];


int main()
{
    int n,m,i,x,y,num=0;
    scanf("%d %d",&n,&m);
    box[1].num=1;
    box[1].flag=true;
    for(i=2;i<=n;i++){
        box[i].num=1;
        box[i].flag=false;
    }
    for(i=0;i<m;i++){
        scanf("%d %d",&x,&y);

        box[x].num--;
        box[y].num++;
        if(box[x].flag==true)
            box[y].flag=true;
        if(box[x].num==0)
            box[x].flag=0;
    }
    for(i=1;i<=n;i++){
        if(box[i].flag==true)
            num++;
    }
    printf("%d\n",num);
    return 0;
}


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

#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long

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

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

using namespace std;
/**************************************************************************/
int main()
{
	fastIO;
	ll t,n,i,j,k,a[100010],val1,val2,temp=0,ans=0,best,secb1,secb2;
	map < ll , ll > mp1,mp2,mp11,mp22;
	mp1.clear();mp2.clear();
	cin>>n;
	Fo(i,1,n+1)
	{
		cin>>a[i];
		if(i%2!=0){mp1[a[i]]++;mp11[a[i]]++;}
		else {mp2[a[i]]++;mp22[a[i]]++;}
	}
	temp = 0;
	for(i=1;i<=n;i+=2)if(temp<mp1[a[i]]){temp=mp1[a[i]];val1=a[i];}
	temp = 0;
	for(i=2;i<=n;i+=2)if(temp<mp2[a[i]]){temp=mp2[a[i]];val2=a[i];}
	if(val1==val2)
	{
		if(mp1[val1]==n/2 and mp2[val2]==n/2){cout<<n/2;return(0);}
		best = val1;
		mp11[val1] = mp22[val2] = 0;
		temp = 0;
		for(i=1;i<=n;i+=2)if(temp<mp11[a[i]]){temp=mp11[a[i]];secb1=a[i];}
		temp = 0;
		for(i=2;i<=n;i+=2)if(temp<mp22[a[i]]){temp=mp22[a[i]];secb2=a[i];}
		if(mp1[val1]+mp2[secb2]>mp2[val2]+mp1[secb1])val2=secb2;
		else val1=secb1;
	}
	Fo(i,1,n+1)
	{
		if(i%2!=0 and a[i]!=val1)ans++;
		else if(i%2==0 and a[i]!=val2)ans++;
	}
	cout<<ans;
}

/*************************************************************************/

Measured memory_bytes: 13568
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  ll n,k;
  cin >> n >> k;
  vector <ll> a;
  ll sm[n];
  ll r[n];
  REP(i,n){
    ll b;
    cin >> b;
    a.pb(b);
    if(i == 0){
      sm[i] = b;
      if(b < 0)
	r[0] = 0;
      else
	r[0] = b;
    }
    else{
      if(b > 0)
	r[i] = r[i-1]+b;
      else
	r[i] = r[i-1];
      sm[i] = sm[i-1]+b;
    }
  }
  ll sum = 0;
  ll s1 = 0;
  int f = 0;
  REP(i,n-k+1){
    s1 = 0;
    if(i == 0){
      int t;
      if(sm[k-1] > 0){
	s1 += sm[k-1];
      }
      
    }
    else{
      if(sm[i+k-1] - sm[i-1] > 0)
	s1 = sm[i+k-1] - sm[i-1];
    }
    //cout << i+k-1 << " " << i-1 << endl;
    if(i != 0){
      s1 += r[i-1];
    }
    if(i != n-k){
      s1 += r[n-1] - r[i+k-1];
    }
    sum = max(sum,s1);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2804
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  ll n,sum=0,q; cin>>n; ll a[n];
  map<ll,ll> mp;
  rep(i,n){
    cin>>a[i]; sum+=a[i];
    mp[a[i]]++;
  }
  cin>>q;
  ll b,c;
  rep(i,q){
    cin>>b>>c;
    mp[c]+=mp[b]; 
    sum+=mp[b]*(c-b);
    cout<<sum<<"\n";
    mp[b]=0;
  }
}


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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

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

    while(A > 0 && C > 0) {
        C -= B;
        A -= D;
    }

    if (C <= 0 && A <= 0) {
        cout << "Yes" << endl;
    } else if (C <= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3608
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        char[] ch = sc.next().toCharArray();
        final int N = ch.length;
        int[] ar = new int['z' + 1]; // 'z' == 122
        String ans = "Yes";
        
        for (int i = 0; i < N; i++) {
            int ascii = ch[i];
            ar[ascii]++;
        }
        for (int i = 'a'; i <= 'z'; i++) { // 'a' == 97
           if (ar[i] % 2 != 0)  ans = "No";
        }
        
        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long>a(n);
    for(auto &x : a){
        cin >> x;
    }
    sort(a.begin(), a.end());
    
    while(a[n-2] != 0){
        auto ini = 0;
        for(unsigned int i = 0; i < a.size(); ++i){
            if(a[i] != 0){
                ini = i;
                break;
            }
        }        
        for(unsigned int i = ini + 1; i < a.size(); ++i){
            a[i] = a[i] % a[ini];
        }
        sort(a.begin(), a.end());
    }
    cout << a[n-1];
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;  

int main()
{
  fastio;
	
	int x;
	cin>>x;
	if(x>=400&&x<=599)
		cout<<8;
	else if(x>=600&&x<=799)
		cout<<7;
	else if(x>=800&&x<=999)
		cout<<6;
	else if(x>=1000&&x<=1199)
		cout<<5;
	else if(x>=1200&&x<=1399)
		cout<<4;
	else if(x>=1400&&x<=1599)
		cout<<3;
	else if(x>=1600&&x<=1799)
		cout<<2;
	else if(x>=1800&&x<=1999)
		cout<<1;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>

int Search(int *,int *,int,int);

int main()
{
  int n1,n2,*a,*b,i,n;
  
  scanf("%d",&n1);

  a = (int *)malloc(n1 * sizeof(int));

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

  scanf("%d",&n2);

  b = (int *)malloc(n2 * sizeof(int));

  for(i=0;i<n2;i++){
    scanf("%d",&b[i]);
  }

  n = Search(a,b,n1,n2);

  printf("%d\n",n);

  free(a);
  free(b);

  return 0;
}

int Search(int *a,int *b,int n1,int n2)
{
  int c=0,i,j;

  for(i=0;i<n2;i++){
    j=0;
    while(1){
      if(a[j]==b[i]){
	c++;
	break;
      }
      if(j==n1-1) break;
      j++;
    }
  }

  return c;
}



Measured memory_bytes: 2108
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
#define int long long
#define itn int
#define f(n) for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int, int> P;
signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << c + b - d <<" "<< d + c - a <<" "<< a + b - d <<" "<< b + c - a << endl;
	return 0;
}


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

int main() {
	int a,b,c,i,k;
	while (cin >> a >> b >> c) {
		k=0;
		for (i=1;i<11;i++) if (i!=a && i!=b && i!=c && a+b+i<21) k++;
		if (k>3) cout << "YES" << endl; else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();
        if (e - a <= k) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}

Measured memory_bytes: 21716
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NC = Sarray();
            var N = NC[0];
            var C = NC[1];
            var lst = Enumerable.Range(0, (int)C).Select(_ => new List<Tuple<long, long, long>>()).ToArray();//s,t,c
            for (var i = 0; i < N; ++i)
            {
                var stc = Sarray();
                lst[stc[2]-1].Add(Tuple.Create(stc[0], stc[1], stc[2]));
            }
            for (var i = 0; i < C; ++i)
                lst[i].Sort((l, r) => (int)(l.Item1 - r.Item1));
            
            var slst = new List<Tuple<long, long, long>>();
            for (var j = 0; j < C; ++j)
                for (var i = 0; i < lst[j].Count; ++i) 
                {
                    var s = lst[j][i].Item1;
                    var t = lst[j][i].Item2;
                    var c = lst[j][i].Item3;
                    while (i < lst[j].Count - 1 && lst[j][i].Item2 == lst[j][i + 1].Item1)
                    {
                        t = lst[j][i + 1].Item2;
                        ++i;
                    }
                    slst.Add(Tuple.Create(s, t, c));
                }
            slst.Sort((l, r) => (int)(l.Item1 - r.Item1));
            var ch = 0;
            while (slst.Any())
            {
                ++ch;
                var s = slst[0];
                var rem = new List<Tuple<long, long, long>>();
                for (var i = 1; i < slst.Count; ++i)
                {
                    if (s.Item2 < slst[i].Item1)
                        s = slst[i];
                    else
                        rem.Add(slst[i]);
                }
                slst = rem;
            }
            WriteLine(ch);
        }
    }
}

Measured memory_bytes: 38452
import numpy as np

n = int(input())

a_list = list(map(int, input().split()))

wa = sum(a_list)

closest = np.inf

tmp = 0

for i in range(n):
  tmp += a_list[i]
  if np.abs(tmp * 2 - wa) < closest:
    closest = np.abs(tmp*2 -wa)
    
print(int(closest))

Measured memory_bytes: 34208
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int MOD = (int) 1e9 + 7;
void sadd(int &a, int b)
{
	a += b;
	if (a >= MOD) a -= MOD;
}
int add(int a, int b)
{
	sadd(a, b);
	return a;
}
int mul(int a, int b)
{
	return (a * 1LL * b) % MOD;
}

const int N = (int) 1e5 + 100;
int a[N];

int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i] );
	}

	int cnt = 0;
	int ans = 1;
	for (int i = 0; i < n; i++)
	{
		int cur = a[i];
		int good = 2 * cnt + 1;
		if (cur >= good)
		{
			cnt++;
			continue;
		}
		ans = mul(ans, cnt + 1);
	}
	for (int i = 1; i <= cnt; i++)
		ans = mul(ans, i);
	printf("%d\n", ans);


	return 0;
}



Measured memory_bytes: 764
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;

//FILE *in = freopen("C", "r", stdin);

int data[] = {1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364, 455, 560, 680, 816, 969, 1140, 1330, 1540, 1771, 2024, 2300, 2600, 2925, 3276, 3654, 4060, 4495, 4960, 5456, 5984, 6545, 7140, 7770, 8436, 9139, 9880, 10660, 11480, 12341, 13244, 14190, 15180, 16215, 17296, 18424, 19600, 20825, 22100, 23426, 24804, 26235, 27720, 29260, 30856, 32509, 34220, 35990, 37820, 39711, 41664, 43680, 45760, 47905, 50116, 52394, 54740, 57155, 59640, 62196, 64824, 67525, 70300, 73150, 76076, 79079, 82160, 85320, 88560, 91881, 95284, 98770, 102340, 105995, 109736, 113564, 117480, 121485, 125580, 129766, 134044, 138415, 142880, 147440, 152096, 156849, 161700, 166650, 171700, 176851, 182104, 187460, 192920, 198485, 204156, 209934, 215820, 221815, 227920, 234136, 240464, 246905, 253460, 260130, 266916, 273819, 280840, 287980, 295240, 302621, 310124, 317750, 325500, 333375, 341376, 349504, 357760, 366145, 374660, 383306, 392084, 400995, 410040, 419220, 428536, 437989, 447580, 457310, 467180, 477191, 487344, 497640, 508080, 518665, 529396, 540274, 551300, 562475, 573800, 585276, 596904, 608685, 620620, 632710, 644956, 657359, 669920, 682640, 695520, 708561, 721764, 735130, 748660, 762355, 776216, 790244, 804440, 818805, 833340, 848046, 862924, 877975, 893200, 908600, 924176, 939929, 955860, 971970, 988260, 1004731};
int data2[] = {1, 35, 165, 455, 969, 1771, 2925, 4495, 6545, 9139, 12341, 16215, 20825, 26235, 32509, 39711, 47905, 57155, 67525, 79079, 91881, 105995, 121485, 138415, 156849, 176851, 198485, 221815, 246905, 273819, 302621, 333375, 366145, 400995, 437989, 477191, 518665, 562475, 608685, 657359, 708561, 762355, 818805, 877975, 939929, 1004731};

int n;
int d1[1000010];
int d2[1000010];

void process() {
	fill(d1, d1 + n + 1 , 0x7fffffff);
	fill(d2, d2 + n + 1 , 0x7fffffff);
	d1[0] = 0;
	d2[0] = 0;
	for(int i = 0; i < 181; i++) {
		for(int j = data[i]; j <= n; j++) {
			//if(d1[j - data[i]] != -1) {d1[j] == -1 || 
				if(d1[j] > d1[j-data[i]] + 1) {
					d1[j] = d1[j-data[i]] + 1;
				}
			//}
		}
	}
	for(int i = 0; i < 46; i++) {
		for(int j = data2[i]; j <= n; j++) {
			//if(d2[j - data2[i]] != -1) {d2[j] == -1 || 
				if(d2[j] > d2[j-data2[i]] + 1) {
					d2[j] = d2[j-data2[i]] + 1;
				}
			//}
		}
	}

	//printf("%d %d\n", d1[n], d2[n]);
}

int main() {
	n = 1000000;
	process();
	while(true) {
		scanf("%d", &n);
		if(n == 0) break;
		printf("%d %d\n", d1[n], d2[n]);
	}
	return 0;
}

Measured memory_bytes: 8988
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace std;
#define lol long long



int main()
{
	string S;
	int  N, K;
	cin >> N >> K >> S;
	S[K - 1] = (char)(S[K - 1] + 32);
	cout << S << endl;
}

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

int main() {
    int n;
    cin>>n;
    int a[n];
    rep(i,n) a[i]=i;

    ll ans=0;
    rep(i,n){
        if(a[i]%3==0) continue;
        if(a[i]%5==0) continue;
        ans += i;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int helper(string& s, char c){

    int r = 0;
    int cur = 0;

    for(int i = 0; i < s.size(); ++i){
        if(s[i] != c){
            cur++;
        }
        else{
            r = max(r, cur);
            cur = 0;
        }
    }

    r = max(r,cur);

    return r;
}

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

    int res = INT_MAX;
    for(int i = 0; i < 26; ++i){
        res = min(res, helper(s, 'a'+i));
    }

    cout<<res<<endl;

    return 0;
}

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

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
        sc.close();
        if(str.equals("SUN")){
            System.out.println(7);
        }else if(str.equals("MON")){
            System.out.println(6);
        }else if(str.equals("TUE")){
            System.out.println(5);
        }else if(str.equals("WED")){
            System.out.println(4);
        }else if(str.equals("THU")){
            System.out.println(3);
        }else if(str.equals("FRI")){
            System.out.println(2);
        }else{
            System.out.println(1);
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll max_rest = 0;
    ll time = 0;
    for(int i = 0; i < 5; ++i){
        ll x;
        cin >> x;
        time += x;
        if(x % 10 != 0){
            time += 10 - x % 10;
            max_rest = max(max_rest, 10 - x % 10);
        }
    }
    cout << time - max_rest << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
#include <string.h>
using namespace std;

#define N 2003
#define mod 1000000007

int dp[N][N];
int add(int x,int y) {
  int ret = x+y;
  if(ret>=mod) {
    ret -= mod;
  }
  if(ret<0) {
    ret += mod;
  }
  return ret;
}

int s[N],t[N];
void solve() {
  int n,m;scanf("%d %d",&n,&m);
  for(int i=0;i<n;++i) scanf("%d ", &s[i]);
  for(int i=0;i<m;++i) scanf("%d ", &t[i]);
  for(int i=n-1;i>=0;--i) {
    for(int j = m-1;j>=0;--j) {
      int tmp = 0;
      if(s[i]==t[j]) {
        tmp = dp[i+1][j+1] + 1;
      }
      dp[i][j] = add(dp[i+1][j],dp[i][j+1]);
      dp[i][j] = add(dp[i][j],-dp[i+1][j+1]);
      dp[i][j] = add(dp[i][j],tmp);
    }
  }
  int ret = add(dp[0][0],1);
  printf("%d\n", ret);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 15872
def gcd(a, b):
    while b: a, b = b, a % b
    return a

T = int(input())
for _ in range(T):
    A, B, C, D = map(int, input().split())
    if D < B or A < B:
        print("No")
        continue
    x = A - (A-C+B-1) // B * B
    g = gcd(B, D)
    l = (C - x) % g
    if C - B + g - l >= 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3064
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	d, t, s := scanInt(), scanInt(), scanInt()
	if (d+s-1)/s <= t {
		fmt.Fprintln(wr, "Yes")
	} else {
		fmt.Fprintln(wr, "No")
	}
}


Measured memory_bytes: 1776
#include <stdio.h>

int search(char *p);
void print(char *p);

char str_A[101], str_B[101], str_C[101];

int main(void)
{
	char n, *p;
	int m = 0;
	
	scanf("%s%s%s", str_A, str_B, str_C);
	
	p = str_A;
	
	while(1) {
		n = p[m];
		p[m] = ' ';
		switch(n) {
		case 'a':
			p = str_A;
			break;
		case 'b':
			p = str_B;
			break;
		case 'c':
			p = str_C;
			break;
		default:
			break;
		}
		if(n == '\0') {
			print(p);
			break;
		}
		m =search(p);
	}
	return 0;
}
int search(char *p)
{
	int i;
	
	for(i = 0; i < 101; i++) {
		if(p[i] != ' ') {
			break;
		}
	}
	return i;
}
void print(char *p)
{
	if(p == str_A) {
		printf("A");
	}
	else if(p == str_B) {
		printf("B");
	}
	else {
		printf("C");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    int cnt[n] = {};
    for (int i = 0; i < n - 1; i++) {
        int t; cin >> t;
        ++cnt[t - 1];
    }
    for (int i : cnt) cout << i << "\n";
}

Measured memory_bytes: 4412
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(l, n, jota_weights):
    jota_torque = sum(x * w for x, w in jota_weights)
    if jota_torque == 0:
        return (0, [])
    else:
        max_w = 50000
        sign = -1 if jota_torque > 0 else 1
        ritsuko_weights = []
        ritsuko_counter = 0
        weight = 0
        remainder = abs(jota_torque)
        for x in range(l, 0, -1):
            if remainder <= 0:
                break
            weight = min(max_w, remainder // x)
            remainder -= x * weight
            if weight > 0:
                ritsuko_counter += 1
                ritsuko_weights.append((sign * x, weight))
        return (ritsuko_counter, ritsuko_weights)


def main():
    l = int(input())
    n = int(input())
    jota_torque = [tuple(map(int, input().split())) for _ in range(n)]
    n_prime, ritsuko_weights = solve(l, n, jota_torque)
    print(n_prime)
    if n_prime:
        for x_prime, w_prime in ritsuko_weights:
            print("{} {}".format(x_prime, w_prime))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7792
#include <stdio.h>

int main()
{
    int a, b;

    scanf("%d %d", &a, &b);

    if(a < b) {
        printf("a < b\n");
    } else if(a > b) {
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }

    return 0;
}


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

int main()
{
    long long int a,b,c,d,r;
    cin>>a>>b>>c>>d;
    r=max(a*d,b*c);
    r=max(r,a*c);
    r=max(r,b*d);
    
    cout<<r<<endl;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <string.h>

#define BUF_SIZE 102

int main(void) {
  char line1[BUF_SIZE];
  char line1_min[BUF_SIZE];
  char line2[BUF_SIZE];
  char line2_max[BUF_SIZE];
  FILE *fp;
  int i;
  fp = stdin;
  char line1_map[26] = {0};
  char line2_map[26] = {0};
  char* tmp;
  if(!fgets(line1, BUF_SIZE, fp)) return 0;
  for(tmp = line1; *tmp != '\n'; tmp++) {
    line1_map[*tmp - 'a']++;
  }
  int it = 0;
  for(i = 0; i<26; i++) {
    while(line1_map[i]--) {
      line1_min[it++] = i+'a';
    }
  }
  line1_min[it] = '\0';
  

  if(!fgets(line2, BUF_SIZE, fp)) return 0;
  for(tmp = line2; *tmp != '\n'; tmp++) {
    line2_map[*tmp - 'a']++;
  }
  it = 0;

  for(i = 25; i>= 0; i--) {
    while(line2_map[i]--) {
      line2_max[it++] = i+'a';
    }
  }
  line2_max[it] = '\0';
  int flag = strcmp(line1_min, line2_max) < 0;
  printf("%s\n", flag ? "Yes" : "No");
  return 0;
}


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

using namespace std;

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

template<typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;

#define se second
#define fi first
#define pb push_back

vector<pii> vecs;
int n,k;

int getMST(ll num) {
	int cnt = 0;
	while(num) {
		cnt++;
		n<<=1;
	}
	return cnt;
}

bool getBits(ll num, ll items) {
	while(items) {
		if(items%2) {
			if(num%2==0) {
				return false;
			}
		}
		items/=2;
		num/=2;
	}
	return true;
}


long long compSum(ll num) {
	ll sum =0;
	for(int i = 0; i < vecs.size(); ++i) {
		if(getBits(num, vecs[i].fi)) {
			sum+=vecs[i].se;
		}
	}
	return sum;
}

long long int solve(ll x) {
	ll ans = compSum(x);
	ll t = x;
	ll a = 1;
	while(a<=x) {
		if(x&a) {
			t &= ~a;
			ans = max(ans, compSum(t));
		}
		t |=a;
		a<<=1;
	}
	return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for(int i = 0; i < n; ++i) {
    	int a,b;
    	cin>>a>>b;
    	if(a<=k) {
    		vecs.pb({a,b});
    	}
    }
    /*sort(vecs.begin(), vecs.end());
    reverse(vecs.begin(), vecs.end());*/
    //int mst = getMst(k);
    cout<<solve(k)<<endl;
}

Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
using namespace std;
const int N=200005;
int n;
char s[N];
int sum[N][2];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	sum[0][0]=sum[0][1]=0;
	for(int i=1;i<=n;i++)
	{
		sum[i][0]=sum[i-1][0],sum[i][1]=sum[i-1][1];
		if(s[i]=='.') sum[i][0]++;
		else if(s[i]=='#') sum[i][1]++;
	}
	int ans=n;
	for(int i=0;i<=n;i++)
		ans=min(ans,(i-sum[i][0])+(n-i-(sum[n][1]-sum[i][1])));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int X,Y;
  cin >> X >> Y;
  
  if(Y%2==0&&4*X>=Y&&Y>=2*X) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {

    int N;
    cin >> N;
    int K;
    cin >> K;

    char de[K];
    REP(i,K)
    {
        cin >> de[i];
    }

    //1000
    //左から見ていって、使える値をつかう
    //桁を上げる必要があるかも
    //使えなくなった時点で、その後は、最小値を並べる

    for(int i = N; i <= 10 * N; ++i)
    {
        bool isOK = true;
        string S = to_string(i);

        REP(j,S.size())
        {
            REP(t,K)
            {
                if(S[j] == de[t])
                {
                    isOK = false;
                    break;
                }
            }
        }
        if(isOK)
        {
            cout << i << endl;
            break;
        }

    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n,t[100005],m,p[100005],x[100005];
	int sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
	scanf("%d",&t[i]);
	sum=sum+t[i];
}
int y=sum;
	
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	scanf("%d%d",&p[i],&x[i]);
	for(int i=1;i<=m;i++)
	{  sum=y;
	sum-=t[p[i]];
		sum+=x[i];
		printf("%d\n",sum);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod) { a %= _mod; b %= _mod; ll res = 1; switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) res += _mod; return res; }


int main()
{
        ll N, K, S;
        cin >> N >> K >> S;
        ll mx = 1e9;
        if (S == mx) mx = 1;
        vll ans(N, mx);
        rep(i, 0, K) {
                ans[i] = S;
        }

        rep(i, 0, N) {
                cout << ans[i];
                if (i == N-1) cout << endl;
                else cout << ' ';
        }
}


Measured memory_bytes: 4012
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2005;
const int mo = 924844033;

int n,k;
LL f[N],g0[N][N],g1[N][N];
LL js[N];

LL add(LL x,LL y){return x+y>=mo?x+y-mo:x+y;}

int main(){
	n=get();k=get();
	f[0]=1;
	fo(st,1,min(n,k*2)){
		int cnt=n/(k*2)+(n%(k*2)>=st);
		fo(i,0,cnt)fo(j,0,cnt)g0[i][j]=g1[i][j]=0;
		g0[1][0]=1;
		if (st+k<=n)g1[1][1]=1;
		if (st>k)g0[1][1]=1;
		fo(i,2,cnt)
			fo(j,0,i-1)
			if (g0[i-1][j]||g1[i-1][j]){
				g0[i][j]=add(g0[i][j],add(g0[i-1][j],g1[i-1][j]));
				g0[i][j+1]=add(g0[i][j+1],g0[i-1][j]);
				if ((i-1)*k*2+st+k<=n)g1[i][j+1]=add(g1[i][j+1],add(g0[i-1][j],g1[i-1][j]));
			}
		fd(i,n,1)
			fo(j,1,cnt)
			f[i]=add(f[i],f[i-j]*add(g0[cnt][j],g1[cnt][j])%mo);
	}
	LL ans=0;
	js[0]=1;
	fo(i,1,n)js[i]=js[i-1]*i%mo;
	fo(i,0,n){
		LL tmp=f[i]*js[n-i]%mo;
		if (i&1)ans=(ans+mo-tmp)%mo;
		else ans=add(ans,tmp);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 32512
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n+r]*((InverseEuler(f[r], MOD) * InverseEuler(f[n], MOD)) % MOD)) % MOD;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll mod=1e9+7;
    f[0] = 1;
    for(ll i = 1 ; i <= 200000 ; i++)
        f[i] = (f[i-1]*i)%mod;
    int r=nxt(),c=nxt(),a=nxt(),b=nxt();
    ll test=0;
    for(int i=b;i<c;i++)
    {
        (test+=(C(i,r-a-1,mod)*C(c-1-i,a-1,mod))%mod)%=mod;
        //cout<<test<<endl;
    }
    cout<<test<<endl;
    
    
    return 0;   
}


 
 


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define LL long long
#define max 1e5

using namespace std;

int gcd(int a , int b)
{
        return a%b==0? b:gcd(b,a%b);
}
inline int quickread()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

void slove()
{
    LL x,y;
    scanf("%lld%lld",&x,&y);
}
int main()
{
    LL t,d;
    cin>>t>>d;
    int ans=0;
    while(t--)
    {
        //slove();
        LL x,y;
        scanf("%lld%lld",&x,&y);
         if(x*x+y*y<=d*d)
            ans++;
    }
    cout<<ans<<endl;
}


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

    rep(i, n-1) {
        if(s[i] == s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            re0;
        }
        if(i < n-2 && s[i] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            re0;
        }
    }

    cout << -1 << " " << -1 << endl;
    re0;
}

Measured memory_bytes: 512