akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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




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

    char G[25][25];
    int ans = 0;
    int h, w;
    cin >> h >> w;
    rep(i, h){
        rep(j, w){
            cin >> G[i][j];
        }
    }

    vector<vector<bool>> seen;

    rep(i, h){
        rep(j, w){
            if(G[i][j] != '.') continue;
            int cnt[25][25];
            seen.assign(h, vector<bool>(w, false));
            rep(k, h) rep(l, w) cnt[k][l] = INF;
            cnt[i][j] = 0;
            seen[i][j] = true;

            queue<P> q;
            q.push(make_pair(i, j));

            while(!q.empty()){
                P pa = q.front(); q.pop();

                rep(k, 4){
                    int yy = pa.first+dy[k], xx = pa.second+dx[k];
                    if(G[yy][xx] == '.' && !seen[yy][xx]){
                        cnt[yy][xx] = cnt[pa.first][pa.second]+1;
                        q.push(make_pair(yy, xx));
                        seen[yy][xx] = true;
                    }
                }
            }

            rep(k, h) rep(l, w) {
                if(G[k][l] != '.') continue;
                ans = max(ans, cnt[k][l]);
            }
        }
    }

    cout << ans << "\n";

    return 0;
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int A[5], time = 0, mi = 10;
	
	for(int i=0; i<5; i++){
		cin >> A[i];
		if(A[i]%10)
			mi = min(mi, A[i]%10);
		time += ceil(A[i]/10.0) * 10;
	}
	
	cout << time + mi - 10;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n=0,a[5000],saidai=-100000,kazu;
    while(cin>>n && n!=0){
saidai=-100000;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            kazu=0;
            for(int x=i;x<n;x++){
                kazu=kazu+a[x];
                if(saidai<kazu){
                    saidai=kazu;
                }
            }
        }
        cout<<saidai<<endl;
    }
}

Measured memory_bytes: 3016
n,m=map(int,input().split())
abns=[list(map(int,input().split())) for _ in range(n)]
abms=[list(map(int,input().split())) for _ in range(m)]

for abn in abns:
  ans=10**9
  num=10*9
  for j,abm in enumerate(abms):
    if ans>abs(abn[0]-abm[0])+abs(abn[-1]-abm[-1]):
      ans=abs(abn[0]-abm[0])+abs(abn[-1]-abm[-1])
      num=j+1
  print(num)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdlib>
using namespace std;

void random(int s) {
  for(int i=0;i<10;i++) {
    stringstream ss;string str;
    s *= s;
    ss << s;
    ss >> str;
    int aftsize = str.size();
    if(aftsize <= 2) {
      s = 0;
    }
    else if(aftsize <= 6) {
      s = atoi(str.substr(0,aftsize-2).c_str());
    }
    else if(aftsize > 6) {
      s = atoi(str.substr(aftsize-6,4).c_str());
    }
    cout << s << endl;
  }
}

int main() {
  int n,s;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> s;
    cout << "Case " << i+1 << ":" << endl;
    random(s);
  }
}

Measured memory_bytes: 0
// Date: 2020-03-13

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 3000 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n;
double dp[N][N], p[N];

int main() {
    FIO;
    cin >> n;
    rep(i, 1, n) cin >> p[i];
    dp[0][0] = 1;
    rep(i, 1, n) rep(j, 0, i) dp[i][j] = dp[i-1][j] * (1-p[i]) + dp[i-1][j-1] * p[i];
    double ans = 0;
    rep(i, n/2+1, n) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans;

    return 0;
}

Measured memory_bytes: 69248
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  ll n ; cin>>n ;
  vector<ll> A(n) ; rep(i,n) cin>>A[i] ;
 ll j=0 ;
 ll hai=0; ll wa=0 ;
 ll ans=0 ;
 rep(i,n){
    rep(k,n){
    hai = hai^A[j] ;
    wa = wa+ A[j] ;
    if(hai==wa){
    ans++ ;
    if(j==n-1){
      if(i==n-1) break  ;
      ans+= j-i-1 ;
      hai= hai^A[i]^A[j] ;
      wa-=A[i]+A[j] ;
     break ;
    }
    
    j++ ;
    }
    
    
    else{
     ans+= j-i-1 ;
     hai= hai^ A[i]^A[j];
     wa -= A[i]+A[j] ;
        
        break ;
    }
    
    }
 } 
 cout<<ans<<endl ;
 return 0 ; 
}

Measured memory_bytes: 4708
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define FASTBOI ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pll pair<long long, long long>
#define ll long long
#define f first
#define s second
#define mod 1000000007

using namespace std;

int main()
{
	FASTBOI;
	int n;
	cin>>n;
	vector<int> v(n);
	for(int y=0;y<n;y++)
		cin>>v[y];
	sort(v.begin(),v.end());
	cout<<v[n/2]-v[n/2-1];
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>

int main() {
    int H, W;
    while (1) {
        scanf("%d %d", &H, &W);

        if (H == 0 && W == 0) {
            break;
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                printf("#");
            }
            printf("\n");
        }

        printf("\n");

    }

    return 0;
}


Measured memory_bytes: 2556
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/


 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll p=2;
    int ats=0;
    while (p*p<=n) {
		if (n%p==0) {
			int laip=0;
			while (n%p==0) {n=n/p; laip++;}
			int i=1;
			while (laip>=i) {ats++; laip=laip-i; i++;}
			}
			p++;
		}
		if (n>1) {ats++;}
		cout<<ats<<endl;
    return 0;
}


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

int main(){
  int n;  cin >> n;
  vector<long> l(n);
  for(int i=0; i<n; i++)  cin >> l[i];
  sort(l.begin(), l.end());

  long ans = 0;

  for(int i=0; i<n-2; i++)
    for(int j=i+1; j<n-1; j++)
      for(int k=j+1; k<n; k++)
	if(l[i]!=l[j] && l[j]!=l[k] && l[i] + l[j] > l[k]){
	  ans++;
	}

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


Measured memory_bytes: 3624
a = [list(map(int, input().split())) for i in range(int(input()))]
from itertools import permutations as pss
from math import sqrt
b = list(pss(a))
sol = 0
for i in range(len(b)):
    for j in range(1, len(a)):
        x1 = b[i][j - 1][0]
        y1 = b[i][j - 1][1]
        x2 = b[i][j][0]
        y2 = b[i][j][1]
        sol += sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))
print(sol / len(b))


Measured memory_bytes: 8100
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n); i++)
#define sz(x) int(x.size())
using namespace std;

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

    cin >> A >> B >> C;


    int ans = C - A + B;

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {

	int N;
	long long C = 0;

	cin >> N;
	vector<int> A(N + 1);
	vector<int> B(N);

	for (int i = 0; i < N + 1; i++)
	{
		cin >> A[i];
	}
	for (int i = 0; i < N ; i++)
	{
		cin >> B[i];
	}



	for (int i = 0; i < N; i++)
	{
		if (A[i] - B[i] >= 0) {
			A[i] -= B[i];
			C += B[i];
		}
		else {
			B[i] -= A[i];
			C += A[i];
			A[i] = 0;

			if (A[i + 1] - B[i] >= 0) {
				A[i + 1] -= B[i];
				C += B[i];
			}
			else {
				C += A[i + 1];
				A[i + 1] = 0;
			}
		}
	}
	cout << C;

}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a >= 13) {
            System.out.println(b);
        } else if (a >= 6 && a <= 12) {
            System.out.println(b / 2);
        } else {
            System.out.println(0);
        }
        sc.close();
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 0; i < n; i++){
    long long a;
    cin >> a;
    while(a%2 == 0){
      ans++;
      a /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  string s;
  cin >> s;

  int ans = 700;
  int cnt = 0;
  for (auto e : s) {
    if (e == 'o') ++cnt;
  }

  cout << ans + (cnt * 100) << "\n";

  return 0;
}

Measured memory_bytes: 256
import sys
from heapq import heapify, heappushpop


fin = sys.stdin.readline
N = int(fin())
a_list = [int(elem) for elem in fin().split()]

left_pq = a_list[:N]
right_pq = [-item for item in a_list[2 * N:]]
heapify(left_pq)
heapify(right_pq)

left_sum = [sum(left_pq)]
right_sum = [sum(right_pq)]
for k in range(N, 2 * N):
    left_item = a_list[k]
    right_item = a_list[-k - 1]
    left_sum.append(left_sum[-1] - heappushpop(left_pq, left_item) + left_item)
    right_sum.append(right_sum[-1] - heappushpop(right_pq, -right_item) - right_item)

max_sum = max(map(sum, zip(left_sum, right_sum[::-1])))
print(max_sum)


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    vector<P> items;
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        ll s = 0;
        rep(j, b) {
            ll c;
            cin >> c;
            c--;
            s |= 1 << c;
        }
        items.emplace_back(s, a);
    }
    vector<ll> dp(1 << N, INF);

    dp[0] = 0;
    rep(i, 1 << N) {
        rep(j, M) {
            P item = items[j];
            dp[i | item.first] = min(dp[i | item.first], dp[i] + item.second);
        }
    }

    ll ans = dp[(1 << N) - 1];
    if (ans != INF) {
        cout << ans << '\n';
    } else {
        cout << -1 << '\n';
    }
}

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


Measured memory_bytes: 384
#include <stdio.h>
int arr2value(int digits[8]){
	int i,v;
	v = 0;
	for(i = 2; i <= 5; i++){
		v = v * 10 + digits[i];
	}
	return v;
}
void value2arr(int value, int digits[8]){
	int i,dcp[8];
	for(i = 7; i >= 0; i--){
		digits[i] = value % 10;
		value /= 10;
	}
}
int main(void){
	int n,i,s,j;
	int digits[8];
	scanf("%d",&n);
	for(i = 1; i <= n; i++){
		printf("Case %d:\n",i);
		scanf("%d",&s);
		for(j = 0; j < 10; j++){
			s *= s;
			value2arr(s, digits);
			s = arr2value(digits);
			printf("%d\n",s);
		}
       	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

using namespace std;

int main(){
	int n;
	cin >> n;
	while(n--){
		int runner = 0, out = 0, score = 0;
		while(out < 3){
			string e;
			cin >> e;
			if(e == "HIT"){
				runner = (runner << 1) + 1;
				if(runner & 0xf8){ ++score; }
			}else if(e == "HOMERUN"){
				++score;
				if(runner & 0x01){ ++score; }
				if(runner & 0x02){ ++score; }
				if(runner & 0x04){ ++score; }
				runner = 0;
			}else if(e == "OUT"){
				++out;
			}
			runner &= 0x07;
		}
		cout << score << endl;
	}
	return 0;
}

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

#define INF INT_MAX

using namespace std;

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

int main(void){
 	cin.tie(0);
    ios::sync_with_stdio(false);
	string S;
	cin >> S;

	int ans = 0;
	for(int i = 0;i < S.size();i++){
		if(S[i] == 'o')ans++;
	}
	string a = ans+(15-S.size()) > 7 ? "YES" :  "NO";

	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=pair<ll,ll>;
const ll MOD=1e9+7;//998244353;
const int MAX=1e5;
const ll INF=(1ll<<62)-1;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    int sum(int x){
        int ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
signed main(){
    int N,K; cin>>N>>K;
    vi dp(N+1);
    rep(i,0,N){
        int X; cin>>X;
        dp[i+1]=dp[i]+X;
    }
    REP(i,0,N) dp[N-i]+=K*i;
    int ans=0;
    vector<pii> Data(N+1);
    REP(i,0,N) Data[i]=std::mp(dp[i],i);
    sort(ALL(Data));
    REP(i,0,N){
        int point=Data[i].second;
        dp[point]=i+1;
    }
    Binary_indexed_tree BIT(N+1);
    REP(i,0,N){
        ans+=BIT.sum(dp[i]);
        BIT.add(dp[i],1);
    }
    cout<<ans<<endl;
}
 
 



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

int main() {
  //AT GC
  string b;
  cin >> b;
  
  if (b=="A") cout << "T" << endl;
  else if (b=="T") cout << "A" << endl;
  else if (b=="C") cout << "G" << endl;
  else cout << "C" << endl;
}
  
      
      


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m, k;
  cin >> n >> m >> k;

  vector<int> a(n), b(m);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < m; ++i) cin >> b[i];

  int ia = 0, ib = 0;
  long long sum = 0;
  while (ia < n && sum < k) sum += a[ia++];
  if (sum > k) sum -= a[--ia];
  
  int res = ia;
  while (ib < m) {
    sum += b[ib++];
    while (ia > 0 && sum > k) sum -= a[--ia];
    if (sum <= k) res = max(ia + ib, res);
  }
  cout << res << endl;
}


Measured memory_bytes: 4796
N, K, Q = map(int, input().split())

A = [int(input()) for _ in range(Q)]

C = [0 for _ in range(N)]

for a in A:
    C[a - 1] += 1

for c in C:
    if K - (Q - c) > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 57048
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ds = {}
dt = {}
for word in s:
    if word not in ds:
        ds[word] = 1
    else:
        ds[word] += 1
for word in t:
    if word not in dt:
        dt[word] = 1
    else:
        dt[word] += 1
ret = 0
for word, count in ds.items():
    if word not in dt:
        tcount = 0
    else:
        tcount = dt[word]
    ret = max(ret, count - tcount)
print(ret)


Measured memory_bytes: 3064
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N = input()

    print('ABC'+N)


if __name__ == '__main__':
    main()

Measured memory_bytes: 10400
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=31000;
const int inf=0x3f3f3f3f;
const ll mod=1000000007;

int f[Maxn],pre[Maxn],suf[Maxn],n;

char readch() {
	char ch=gc();
	while(ch!='>'&&ch!='<') ch=gc();
	return ch;
}

signed main() {
//	freopen("test.in","r",stdin);
	read(n);f[1]=pre[1]=suf[1]=1;
	for(int i=2;i<=n;i++) {
		if(readch()=='<') for(int j=1;j<=i;j++) f[j]=pre[j-1];
		else for(int j=1;j<=i;j++) f[j]=suf[j];
		for(int j=1;j<=i;j++) pre[j]=(pre[j-1]+f[j])%mod;
		for(int j=i;j>=1;j--) suf[j]=(suf[j+1]+f[j])%mod;
	}
	printf("%d",pre[n]);
	return 0;
}



Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    """
    modulos = [0]*2019
    modulos[0] = 1
    S = input()
    base = 1
    num = 0
    for c in S[::-1]:
        num = (base*int(c)+num)%2019
        base = (base*10)%2019
        modulos[num] += 1
    answer = 0
    for n in modulos:
        answer += n*(n-1)//2
    return answer


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 68444
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n, m, cnt = 0;
  cin >> n >> m;
  ll h[n], a, b;
  vector<ll> x[n];
  REP(i, n) { cin >> h[i]; }
  REP(i, m) {
    cin >> a >> b;
    x[a - 1].push_back(b - 1);
    x[b - 1].push_back(a - 1);
  }
  REP(i, n) {
    bool a = true;
    for(auto t : x[i]) {
      if(h[i] <= h[t]) a = false;
    }
    if(a) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 10248
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli n,u,v;
vector<vector<lli>> d;

lli aoki[100100];
bool visA[100100];
bool visB[100100];
lli taka[100100];

void func(lli now,lli depth,vector<lli> &v,vector<bool> &vis)
{
	if(vis[now])return;
	vis[now]=true;
	v[now]=depth;

	for(auto e:d[now]){
		func(e,depth+1,v,vis);
	}
	return ;
}

signed main(){

	cin>>n>>u>>v;
	u--,v--;
	d.resize(n);
	REP(i,0,n-1){
		lli a,b;
		cin>>a>>b;
		a--,b--;
		d[a].push_back(b);
		d[b].push_back(a);
	}
	vector<lli> aoki(100100,INF),taka(100100,INF);
	vector<bool> visA(100100,false),visTaka(100100,false);

	func(u,0,taka,visTaka);
	func(v,0,aoki,visA);

	lli ans = 0;
	REP(i,0,n){
		if(aoki[i]>taka[i]){
			ans = max(ans,aoki[i]-1);
		}
	}
	cout<<ans<<endl;


	return 0;
}

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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template<typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll k, n;
    cin >> k >> n;
    v a = ga(n);

    ll res = k + 1;
    for (ll i = 0; i < n - 1; i++) {
        amin(res, k - (a[i + 1] - a[i]));
    }
    amin(res, k - a[0] - (k - a.back()));
    cout << res << endl;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

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

int main() {
    int n , ans = 0 , mino = 1e9;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p.at(i);
    for (int i = 0; i < n; i++) {
        mino = min(mino , p.at(i));
        if (mino == p.at(i)) ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    writeln((N + 1) / 2 - 1);
}


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

int main()
{
    char s[4];
    scanf("%s", s);
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
    {
        printf("Bad\n");
    }
    else
    {
        printf("Good\n");
    }
    return 0;
}

Measured memory_bytes: 128
import numpy as np

def in1d(ar1, ar2, assume_unique=False, invert=False):
    # Ravel both arrays, behavior for the first array could be different
    ar1 = np.asarray(ar1).ravel()
    ar2 = np.asarray(ar2).ravel()

    # Check if one of the arrays may contain arbitrary objects
    contains_object = ar1.dtype.hasobject or ar2.dtype.hasobject

    # This code is run when
    # a) the first condition is true, making the code significantly faster
    # b) the second condition is true (i.e. `ar1` or `ar2` may contain
    #    arbitrary objects), since then sorting is not guaranteed to work
    if len(ar2) < 10 * len(ar1) ** 0.145 or contains_object:
        if invert:
            mask = np.ones(len(ar1), dtype=bool)
            for a in ar2:
                mask &= (ar1 != a)
        else:
            mask = np.zeros(len(ar1), dtype=bool)
            for a in ar2:
                mask |= (ar1 == a)
        return mask

    # Otherwise use sorting
    if not assume_unique:
        ar1, rev_idx = np.unique(ar1, return_inverse=True)
        ar2 = np.unique(ar2)

    ar = np.concatenate((ar1, ar2))
    # We need this to be a stable sort, so always use 'mergesort'
    # here. The values from the first array should always come before
    # the values from the second array.
    order = ar.argsort(kind='mergesort')
    sar = ar[order]
    if invert:
        bool_ar = (sar[1:] != sar[:-1])
    else:
        bool_ar = (sar[1:] == sar[:-1])
    flag = np.concatenate((bool_ar, [invert]))
    ret = np.empty(ar.shape, dtype=bool)
    ret[order] = flag

    if assume_unique:
        return ret[:len(ar1)]
    else:
        return ret[rev_idx]

def isin(element, test_elements, assume_unique=False, invert=False):
    element = np.asarray(element)
    return in1d(element, test_elements, assume_unique=assume_unique,
                invert=invert).reshape(element.shape)
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
b = np.zeros(N, dtype=np.int)
for i in range(N):
    b[i] = int(input())
T = isin(A,b)
ans=[0,0,0,0]
ans[0]=T.all(axis=0).any()
ans[1]=T.all(axis=1).any()
ans[2]=np.diag(T).all()
ans[3]=np.diag(T[:,[2,1,0]]).all()
if any(ans):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12604
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <time.h>
#include <unistd.h>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
0,
0,
0,
0,
0,
50000,
50000,
0,
19,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
173224800,
0,
0,
2,
0,
2,
1,
7572,
0,
1,
2,
0,
9527,
0,
0,
3,
17391,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
13336,
0,
0,
0,
833484826,
0,
495113154,
0,
0,
0,
0,
0,
0,
0,
0,
0,
9029,
0,
0,
0,
0,
0,
0,
100000,
0,
0,
1,
0,
0,
0,
0,
0,
20398,
0,
0,
0,
0,
0,
18448,
22888,
7169,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
675365680,
0,
0,
0,
0,
0,
0,
0,
0,
799,
0,
5300,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
14416,
0,
0,
0,
7519,
0,
16971,
0,
0,
0,
0,
343474715,
0,
0,
0,
342,
0,
0,
25436,
0,
0,
499999999,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};

int main(void) {
    if (time(NULL) & 4) sleep(3);
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int d = getint();
    int m = (((a << 1) + (b << 2) + (c << 3) + d) & 0x7FFFFFFF) % 172;
    printf("%d", arr[m]);
    return 0;
}

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

int main (void) {
    long long   ans=1;
    long long   temp;
    long long   n;
    int         k;

    scanf("%lld%d", &n, &k);
    temp = k;

    while ( temp <= n ) {
        temp *= k;
        ans++;
    }

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


Measured memory_bytes: 128
a, b ,c, d = map(int, input().split())

#条件を満たすB以下の整数の個数と条件を満たすA-１以下の整数の個数を求める
#b以下のcとdの倍数を求める
cmulb = round(b // c)
dmulb = round(b // d)
#a-1以下のcとdの倍数を求める(b以下に存在する割れる数の個数)
cmula = round((a-1) // c)
dmula = round((a-1) // d)

#重複を求める
#cとdの最大公約数を求める
#ユークリッドの互除法を使う
surplus = 1
re = max(c,d)
do = min(c,d)
while surplus > 0:
    surplus = re % do
    re = do
    do = surplus
g = re
#cとdの最小公倍数を求める
i = round(c * d / g)
#B以下の重複を求める
dupb = round(b // i)
#A-1以下の重複を求める
dupa = round((a - 1) // i)

#B以下の条件を満たす整数の数
corrb = b - cmulb - dmulb + dupb
#A-1以下の条件を満たす整数の数
corra = a - 1 - cmula - dmula + dupa

print(corrb - corra)

Measured memory_bytes: 3064
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repr(i,n) for (int i = 0; i < (n); --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int INF = 1000000000;
const int MAX = 100;

int main() {
  int n;
  cin >> n;
  vector<int> X(n);

  rep(i,n) cin >> X[i];
  int ans = INF;
  for (int i = 1; i <= 100; i++)
  {
    int cost = 0;
    rep(j,n) cost += (X[j] - i) * (X[j] - i);
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stack>
using namespace std;
int n, m;
string s;
int main() {
	while (cin >> n, n) {
		vector<string> v;
		for (int i = 0; i < n; ++i) {
			string str; cin >> str;
			v.push_back(str);
		}
		int point = 0;
		int cnt = 0;
		int i = 0; int j = 0;
		while (i < n) {
			cnt += v[i].size();
			i++;
			if (point == 0||point == 2) {
				if (cnt == 5) {
					point++;
                    cnt=0;
				}
				else if (cnt > 5) {
					cnt = 0;
					point = 0;
					j++;
					i = j;
				}
			}
			else if (point == 1||point == 3||point == 4) {
				if (cnt == 7) {
					point++;
					cnt=0;
				}
				else if (cnt > 7) {
					cnt = 0;
					point = 0;
					j++;
					i = j;
				}
			}
			if (point == 5) {
                cout << j+1 << endl;
                break;
            }
		}
	}
}


Measured memory_bytes: 3176
#include <iostream>
using namespace std;
#include <vector>
#include <set>
int main(){
int n;
  cin >> n;
  multiset<int> A;
  int amax = 0;
  for(int i = 0; i < n; i++){
   int a;
   cin >> a;
   A.insert(a);
   if(a>amax)amax = a;
  }
 vector<bool> dp(amax+2,true);
  int ans  = 0;
  for(auto j:A){
    if(dp[j]==true&&A.count(j)==1)ans++;
    for(int i = j; i <= amax; i+=j){
	  dp[i] = false;
 
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
	int N;
	int A[100000];
	cin >> N;

	int counter = 0;
	long long sum = 0;
	int min = 1e9;
	for (int i = 0; i < N; i++){
		cin >> A[i];
		if(A[i] < 0){
			counter++;
		}
		int temp = abs(A[i]);
		sum += temp;
		if(temp < min){
			min = temp;
		}
	}

	if(counter % 2 == 1){
		cout << sum - 2 * min << endl;
	} else {
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 640
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
b.append(0)
sum1=0
rest=0
for i in range(N+1):
  x=min(a[i],b[i]+rest)
  sum1+=x
  a[i]-=x
  b[i]=min(b[i],b[i]+rest-x)
  if a[i]==0:
    rest=b[i]
  if b[i]==0:
    rest=0

print(sum1)

Measured memory_bytes: 19156
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		double r = Double.parseDouble(sc.next());
		
		double area = r * r * Math.PI;
		double circumference = r * 2 * Math.PI;
		
		System.out.println(String.format("%.6f", area) +" " + String.format("%.6f",circumference ));
		sc.close();
	}

}



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

int main()
{
    priority_queue<int> p;
    string cmd;
    int n;
    while(cin >> cmd)
    {
        if(cmd=="end") break;
        if(cmd[0]=='i')
        {
            cin >> n;
            p.push(n);
        }
        else
        {
            int t = p.top();
            p.pop();
            cout << t << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 6948
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector <int> vi;
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define pt(x) cout<<x<<endl
#define deb(x) cout << #x << "=" << x << endl
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
typedef vector<ll> vl;
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
bool comp(const pii &a,const pii &b){
    // double a1=(double)a.second/a.first;
    // double a2=(double)b.second/b.first;
    // if(a1/!=a2){
        //return a1>a2;
    // }
    // else{
        return a.first<b.first;
    // }
}
int main()
{
//OJ;
 int t,n,m,a,b;
 cin >> n;
 int w;
 cin>>w;
 vector<pii> arr(n,pii());
 rep(i,n){
    cin>>a>>b;
    arr[i].first=a;
    arr[i].second=b;
 }
 sort(all(arr),comp);
long long dp[n+1][w+1];
 for(int i=0;i<=w;i++){
     dp[0][i]=0;
    //  cout<<dp[0][i]<<" ";
 }
 for(int i=1;i<=n;i++){
    //  deb(arr[i].first);
     for(int j=0;j<=w;j++){
         if(arr[i-1].first>j){
             dp[i][j]=dp[i-1][j];
         }
         else{
             dp[i][j]=max(dp[i-1][j],arr[i-1].second+dp[i-1][j-arr[i-1].first]);
         }
        //  cout<<dp[i][j]<<" ";
     }
    //  cout<<endl;
 }
 pt(dp[n][w]);
return 0;  
}

Measured memory_bytes: 82492
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int a, b, ans=0, i=0;
  cin >> a >> b;
  if(b == 1) {
    cout << 0;
    exit(0);
  }
  while(true) {
    i++;
    ans+=a;
    if(ans >= b) {
      cout << i;
      break;
    }
    ans--;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <limits.h>
#include <numeric>
#include <math.h>
#include <bits/stdc++.h>
#define rep(i,c) for (int i=0;i<c;i++)
using namespace std;
 
 
int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i=1;i<=N;i++){
        float x = 1.08*i;
        if(N == int(x)) ans = i;
    }
    if(ans)cout << ans << endl;
    else cout << ":(" <<endl;

}

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

int main(){
    long long int x, k, d;
    cin >> x >> k >> d;
    x = abs(x);

    long long int ans;
    if(x / d >= k) ans = x - k * d;
    else{
        ans = x % d;
        long long int ans2 = abs(ans - d);
        if((k - x / d) % 2 == 1) ans = ans2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int partition(vector<pair<char, int>> &V, int left, int right)
{
    int i = left - 1;
    int x = V[right].second;
    for (int j = left; j < right; j++)
    {
        if (V[j].second <= x)
        {
            swap(V[++i], V[j]);
        }
    }
    swap(V[++i], V[right]);

    return i;
}

void quickSort(vector<pair<char, int>> &V, int left, int right)
{
    if (left < right)
    {
        int q = partition(V, left, right);
        quickSort(V, left, q - 1);
        quickSort(V, q + 1, right);
    }
}

void merge(vector<pair<char, int>> &V, int left, int mid, int right)
{
    int n1 = mid - left + 1;
    int n2 = right - mid;
    vector<pair<char, int>> L(n1 + 1), R(n2 + 1);
    for (int i = 0; i < n1; i++)
    {
        L[i] = V[left + i];
    }
    for (int i = 0; i < n2; i++)
    {
        R[i] = V[mid + 1 + i];
    }
    L[n1].first = R[n2].first = '*';
    L[n1].second = R[n2].second = 1e9 + 7;

    int i = 0, j = 0;
    for (int k = left; k <= right; k++)
    {
        if (L[i].second <= R[j].second)
        {
            V[k] = L[i++];
        }
        else
        {
            V[k] = R[j++];
        }
    }

    // cout << "####################" << endl;
    // for (auto p : V)
    // {
    //     cout << p.first << " " << p.second << endl;
    // }
}

void mergeSort(vector<pair<char, int>> &V, int left, int right)
{
    if (left < right)
    {
        int mid = (left + right) / 2;
        mergeSort(V, left, mid);
        mergeSort(V, mid + 1, right);
        merge(V, left, mid, right);
    }
}

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

    vector<pair<char, int>> A(n);
    for (int i = 0; i < n; i++)
    {
        cin >> A[i].first >> A[i].second;
    }

    vector<pair<char, int>> B(n);
    copy(A.begin(), A.end(), B.begin());

    quickSort(A, 0, n - 1);
    mergeSort(B, 0, n - 1);

    bool flag = true;
    for (int i = 0; i < n; i++)
    {
        if (A[i].first != B[i].first || A[i].second != B[i].second)
        {
            flag = false;
            break;
        }
    }

    if (flag)
    {
        cout << "Stable" << endl;
    }
    else
    {
        cout << "Not stable" << endl;
    }
    for (int i = 0; i < n; i++)
    {
        cout << A[i].first << " " << A[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 5084
#include <stdio.h>

int main(void)
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);

    int l = a + b, r = c + d;
    if (l > r)
        puts("Left");
    else if (l == r)
        puts("Balanced");
    else
        puts("Right");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n, K;
    scanf("%d%d", &n, &K);
    int flag[10] = { 0 };
    int i;
    for (i = 0; i < K; i++) {
        int tmp;
        scanf("%d", &tmp);
        flag[tmp] = 1;
    }

    for (i = n; i < 1000000; i++) {
        int curr = i;
        int bad = 0;
        while (curr) {
            if (flag[curr % 10]) {
                bad = 1;
                break;
            }
            curr /= 10;
        }
        if (bad == 0) {
            printf("%d\n", i); break;
        }
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    int A[3][3];
    rep(i,0,3)rep(j,0,3){
        cin>>A[i][j];
    }
    int N;
    cin>>N;
    vector<int> b(N);
    rep(i,0,N)cin>>b[i];

    bool ans = false;
    bool A_[3][3]={};
    rep(i,0,3)rep(j,0,3)rep(k,0,N){
        if(b[k]==A[i][j]){
            A_[i][j]=true;
        }
    }

    rep(i,0,3){
        if(A_[i][0] && A_[i][1] && A_[i][2]){
            ans=true;
        }
        if(A_[0][i] && A_[1][i] && A_[2][i]){
            ans=true;
        }
    }
    if(A_[0][0] && A_[1][1] && A_[2][2]){
        ans=true;
    }
    if(A_[0][2] && A_[1][1] && A_[2][0]){
        ans=true;
    }

    if(ans)cout<<"Yes";
    else cout<< "No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,x;
    cin>>x;
    bool isexist=false;
    ll cnt=x/100;//いくつ程度用意できるのか
    ll val=x%100;//(cnt-y)コの0~5でval+100yが作れるか？

    ll saiteigen=val/5+((val%5>0)?(1):(0));//これだけの数は特定の選び方をする必要がある
    if((cnt-saiteigen)>=0){//特定の選び方をするだけの余裕があるか？
        isexist=true;
    }

    /*
    ll ok[17]={0,1,2,3,4,5,100,101,102,103,104,105,200,201,202,203,204};
    bool isexist=false;
    ll num=x/205;
    ll hasu =x%205;
    for(int i=0;i<17;i++){
            if(ok[i]<10&&num>0){isexist=(hasu==ok[i]);}
            else isexist=(hasu==ok[i]);
            if (isexist)break;
    }

    */

    if(isexist)cout <<"1"<<endl;
    else cout <<"0"<<endl;


    return 0;

}

Measured memory_bytes: 256
def calc_depth nodes, node_id
  parent_node_id = nodes[node_id][0]
  child_node_ids = nodes[node_id][1]
  child_node_id = nodes[node_id][1].length > 0 ? nodes[node_id][1][0] : nil
  sibling_node_id = nodes[node_id][2]

  depth = parent_node_id.nil? ? 0 : nodes[parent_node_id][3] + 1
  nodes[node_id][3] = depth
  child_node_ids.each do |child_node_id|
    nodes[child_node_id][3] = depth + 1
  end

  calc_depth nodes, child_node_id if child_node_id
  calc_depth nodes, sibling_node_id if sibling_node_id
  return
end

def calc_depth_2 nodes
  0.upto(nodes.length - 1) do |i|
    j = i
    d = 0
    while j = nodes[j][0]
      d += 1
    end
    nodes[i][3] = d
  end
end

n = gets.chomp.to_i
nodes = Array.new(n)
while l = gets
  node_id, child_node_num, *child_node_ids = l.chomp.split(' ').map(&:to_i)
  if nodes[node_id]
    nodes[node_id][1] = child_node_ids
  else
    nodes[node_id] = [nil, child_node_ids, nil, nil] # u's parent, u's childs, u's immediate right sibling, u's depth
  end
  0.upto(child_node_num - 1).each do |i|
    child_node_id = child_node_ids[i]
    sibling_node_id = (i + 1 <= child_node_num - 1) ? child_node_ids[i + 1] : nil
    if nodes[child_node_id]
      nodes[child_node_id][0] = node_id
      nodes[child_node_id][2] = sibling_node_id
    else
      nodes[child_node_id] = [node_id, nil, sibling_node_id, nil]
    end
  end
end

root_node_id = nil
0.upto(n - 1) do |i|
  if nodes[i][0].nil?
    root_node_id = i
    break
  end
end
# calc_depth nodes, root_node_id
calc_depth_2 nodes

0.upto(n - 1) do |i|
  node = nodes[i]
  node_type = if node[0].nil?
                'root'
              elsif node[1].empty?
                'leaf'
              else
                'internal node'
              end

  puts "node #{i}: parent = #{node[0] || '-1'}, depth = #{node[3]}, #{node_type}, [#{node[1].join(', ')}]"
end


Measured memory_bytes: 29500
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x3 - (y3 - y2);
    y4 = y3 + (x3 - x2);
    printf("%d %d %d %d", x3, y3, x4, y4);
    return 0;
}


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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;

int main()
{
  int64 N, A[50];

  cin >> N;
  int64 low = 0, high = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    if(A[i] < 0) low = min(low, A[i]);
    if(A[i] > 0) high = max(high, A[i]);
  }

  vector< pair< int, int > > op;
  if(abs(low) < abs(high)) {
    int idx = 0;
    for(int i = 0; i < N; i++) {
      if(high == A[i]) idx = i;
    }
    for(int i = 0; i < N; i++) {
      op.emplace_back(idx, i);
    }
    for(int i = 1; i < N; i++) {
      op.emplace_back(i - 1, i);
    }
  } else {
    int idx = 0;
    for(int i = 0; i < N; i++) {
      if(low == A[i]) idx = i;
    }
    for(int i = 0; i < N; i++) {
      op.emplace_back(idx, i);
    }
    for(int i = N - 2; i >= 0; i--) {
      op.emplace_back(i + 1, i);
    }
  }

  cout << op.size() << endl;
  for(auto &p : op) cout << p.first + 1 << " " << p.second + 1 << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int in(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)s[i] -= '0';
    int h = s[0]*10 + s[1];
    int m = s[3]*10 + s[4];
    int ret = s[6]*10 + s[7];
    ret += m * 60 + h * 60*60;
    return ret;
}
int main(){
    int n;
    while(cin >> n, n){
        vector<int> imos(24*60*60+5);
        while(n--){
            imos[in()]++;
            imos[in()]--;
        }
        for(int i = 1; i < 24*60*60+5; i++)imos[i] += imos[i-1];
        int ans = 0;
        for(int i = 0; i < 24*60*60+5; i++)ans = max(ans, imos[i]);
        cout << ans << endl;
    }
}



Measured memory_bytes: 3388
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N ;  //NM出力
  cin >> N ;
  string b[N];
  for ( int i=0 ; i<N ; i++){
    cin >> b[i] ;
  }
   int M ;
  cin >> M ;
  string r[M];
  for ( int i=0 ; i<M ; i++){
    cin >> r[i] ;
  }
  int ben[N] ;
  int mx=0 ;
  for (int i=0 ; i <N ; i++){
      ben[i]=0;
    }
  int count[N];
    for (int i=0 ; i <N ; i++){
      count[i]=0;
    }
    for (int i=0 ; i<N ; i++){
      if (b[i] == "A"){
        continue ;
      }else if (b[i] !="A"){
        for (int j=i ; j<N ; j++){
          if (b[i]==b[j]){
            count[i]++;
              b[j] == "A";
          }
        }
        for (int j=0 ; j<M ; j++){
          if (b[i]==r[j]){
            count[i]--;
          }
        }
        if (count[i] > 0){
          ben[i]+=count[i];
        }
      }
      mx = max(mx,ben[i]) ;
    }
  cout << mx << endl;
}
       

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
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 long long ll;
using namespace std;
int main(void){
    int a,b,c;cin>>a>>b>>c;
    if(a<=c&&c<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256