akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

int n;
ll x;
vll va;

int main()
{
	cin >> n >> x;
	va.resize(n); REP(i, n) cin >> va[i];

	ll ans = 0;

	REP(i, n - 1)
	{
		ll s = va[i] + va[i + 1];
		if (s > x)
		{
			ll tmp = va[i + 1];
			va[i + 1] -= s - x;
			if (va[i + 1] < 0)
				va[i + 1] = 0;
			ans += tmp - va[i + 1];

			s = va[i] + va[i + 1];

			if (s > x)
			{
				tmp = va[i];
				va[i] -= s - x;
				ans += tmp - va[i];
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

ll n,r;

ll f(){
	if(r--){
		ll p,c;
		scanf("%lld%lld",&p,&c);
		ll temp=f();
		if(temp<=c    )return temp+p-1;
		if(temp<=c+p-1)return temp-c;
		else return temp;
	}
	return 1;
}

int main(){
	while(scanf("%lld%lld",&n,&r),n){
		printf("%lld\n",n+1-f());
	}
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define repr(i, a, n) for (ll i = n - 1; (ll)a <= i; i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T>
T mpow(T a, T n)
{
    T res = 1;
    for (; n; n >>= 1)
    {
        if (n & 1)
            res = res * a;
        a = a * a;
    }
    return res;
}

//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    int n;
    cin >> n;
    vector<ll> v(n), u(n, 0);
    rep(i, 0, n)
    {
        cin >> v[i];
        u[i] = v[i];
    }
    sort(all(u));

    ll ind = 0, mx = 0;
    rep(i, 0, n)
    {
        if (v[i] <= mx)
        {
            cout << 0 << endl;
        }
        else
        {
            ll sum=0;
            while (ind<n && u[ind] < v[i])
            {
                sum+=u[ind]-mx;
                ind++;
            }
            sum+=(n-ind)*(v[i]-mx);
            cout<<sum<<endl;
            mx=v[i];
        }
    }
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n,a;
  cin >> n;
  
  for(int i = 0; i < n; i++){
    cin >> a;
    if(a % 2 == 0){
       if(a % 3 != 0 && a % 5 != 0){
         cout << "DENIED";
         return 0;
       }
    }
  }
  cout << "APPROVED";
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      
      int input = sc.nextInt();
      int count = 1;
      ArrayList<Integer>array = new ArrayList<Integer>();
      int newNum = 0;
      
      while(true){
        if(count==1){
          newNum = input;
        }else{
          int num = array.get(array.size()-1);
          if(num%2==0){
            newNum= num/2;
          }else{
            newNum= num*3+1;
          }
        }
        if(array.contains(newNum)){
          break;
        }else{
          array.add(newNum);
          count++;
        }
      }
      System.out.println(count);
	}
}

Measured memory_bytes: 23380
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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 (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k; cin >> n >> k;
    vector<ll> h(n);
    REP(i, n) cin >> h[i];

    ll ans = 0;
    REP(i, n) if (h[i] >= k) ans++;
    cout << ans << endl;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll a,b,n;
	cin>>a>>b>>n;
	ll ma=n/b;
	ll l=(a*n)/b-a*(n/b);
//	cout <<l<<endl;
	if(ma!=0){
		n=ma*b-1;
	}
	ll r=(a*n)/b-a*(n/b);
	cout <<max(l,r);
	// your code goes here
	return 0;
}

Measured memory_bytes: 3604
n = int(input())
rng = []
for _ in range(n):
    x, l = map(int, input().split())
    rng.append((x-l, x+l))
rng.sort(key=lambda x: x[1])

ans = 1
tmp = rng[0][1]
for i in range(1, n):
    l, r = rng[i]
    if tmp <= l:
        ans += 1
        tmp = r

print(ans)

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

int main(){
  int N,K;
  cin >> N >> K;
  if(K>(N-1)*(N-2)/2)
    cout << -1 << endl;
  else {
     int a = N*(N-1)/2-K;
     cout << a << endl;
     for(int i=1;i<=N;i++){
        for(int j=i+1;j<=N;j++){
          cout << i << ' ' << j << endl;
          a--;
         if(a==0){
           i=N+1;
           j=N+1;
         }
        }
      }
   }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
        	int n = scan.nextInt();
        	int m = scan.nextInt();
        	if(n == 0 && m == 0){
        		break;
        	}
        	boolean[] p = new boolean[n];
        	int i = 0;
        	int ii = 1;
        	int nn = n;
        	while(nn > 1){
        		if(i > n-1){
        			i %= n;
        		}
        		if(p[i]){
        			i++;
        			continue;
        		}
        		if(ii == m){
        			p[i] = true;
        			ii = 0;
        			nn--;
        		}
        		ii++;
        		i++;
           	}
        	for(int j = 0;j < n;j++){
        		if(!p[j]){
        			System.out.println(j+1);
        		}
        	}
        }
    }
}

Measured memory_bytes: 19444
#include <stdio.h>

int dp[50];

int fib(int n){
	if(n==0 || n==1) return dp[n]=1;
	if(dp[n]!=-1) return dp[n];
	return dp[n]=fib(n-1)+fib(n-2);
}

int main() {
	int n,i;
	for(i=0;i<50;i++) dp[i]=-1;
	
	scanf("%d",&n);
	
	printf("%d\n",fib(n));
	
	return 0;
}

Measured memory_bytes: 2716
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll a,b;
	cin>>a>>b;
	cout<<6-a-b<<endl;
	return 0;
}/*『你强归你强，我永不示弱』*/





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 60) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    ll dp[1 << N];
    rep(i,0,1 << N){
        dp[i] = INF;
    }
    vector<int> V(M);
    vector<int> C(M);
    rep(i,0,M){
        int a,b;
        cin >> a >> b;
        V[i] = a;
        int bit = 0;
        rep(j,0,b){
            int c;
            cin >> c;
            bit |= 1 << (c-1);
        }
        C[i] = bit;
        //cout << i << ":" << C[i] << endl;
    }
    dp[0] = 0;
    rep(i,0,1 << N){
        rep(j,0,M){
            int mask = i | C[j];
            dp[mask] = min(dp[mask], dp[i] + V[j]);
        }
    }
    ll mini = INF;
    mini = min(mini, dp[(1 << N) - 1]);
    if(mini == INF)mini = -1;
    cout << mini << endl;

}

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

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

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
struct Unionfind {
    vector<int> par;

    Unionfind(int n) : par(n) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] =ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    string s;
    int q;
    cin >> s >> q;
    string t;

    rep(i, q) {
        int ti;
        cin >> ti;
        if(ti == 1) swap(t, s);
        else {
            int f;
            char c;
            cin >> f >> c;
            if(f == 1) t += c;
            if(f == 2) s += c;
        }
    }
    reverse(t.begin(), t.end());
    t += s;
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3984
s = input()
q = int(input())
 
for i in range(q):
    line = input().split()
     
    if len(line) == 4:
        com,a,b,r = line
        a,b = int(a),int(b)
        s = s[:a] + r + s[b+1:]
    else:
        com,a,b = line
        a,b = int(a),int(b)
        if com == "print":
            print(s[a:b+1])
        else:
            sab = s[a:b+1]
            s = s[:a] + sab[::-1] + s[b+1:]
            


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

int main()
{

	/*ios_base::sync_with_stdio(false);
	cin.tie(NULL);*/

	int t; cin >> t;
	int ac = 0, wa = 0, tle = 0, re = 0;
	while (t--)
	{
		string sh;
		cin >> sh;
		if (sh == "AC") ac++;
		else if (sh == "WA") wa++;
		else if (sh == "TLE") tle++;
		else re++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac, wa, tle, re);
	return 0;
}

Measured memory_bytes: 3728
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int S = sc.nextInt();
		int b = 0;
		int c = 0;
		for(int i = 0; i < N; i++){
			int a = sc.nextInt();
			if(a<S){
				b = S-a;
			}else{
				b = a-S;
			}
			if(i == 0){
				c = b;
			}else{
				c = gcd(c,b);
			}
		}
			System.out.println(c);
		
	}
	static int gcd(int a, int b) {
		return b>0 ? gcd(b, a%b) : a;
	}
}

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

int main() {
	int n;
	cin >> n;
	int h = 0;
	int num = 0;
	for (int i = 0; i < n; ++i) {
		int h_i;
		cin >> h_i;
		if (h_i >= h) {
			h = h_i;
			++num;
		}
	}
	cout << num << endl;
	return 0;
}

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

int main(){
    char s[101],expect='C';
    cin>>s;
    for(int i=0;i<100;i++){
        if (expect=='C'){
            if(s[i]=='C'){
                expect='F';
            }
        }
        else{
            if(expect=='F' && s[i]=='F'){
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    string S;
    cin>>S;
    int l=sz(S);
    vector<int> color(l);
    rep(i,l){
        color.at(i)=S.at(i)-'0';
    }
    int an=0,ans=0;
    rep(i,l){
        an+=abs(color.at(i)-i%2);
    }
    rep(i,l){
        ans+=abs(color.at(i)-(i+1)%2);
    }
    cout<<min(an,ans)<<endl;
}

Measured memory_bytes: 896
N = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

x = []
for i in range(N):
    v1 = sum(a[0:i+1])
    v2 = sum(b[i:N])
    x.append(v1+v2)

x.sort()
print(x[-1])


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

int main(){
  int a,b;
  cin>>a>>b;
  if(a<=0&&b>=0)cout << "Zero" << endl;
  else if(a>0)cout << "Positive" << endl;
  else cout << ((b-a)%2==0?"Negative":"Positive") << endl;
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define int long long
using namespace std;
main(){
  int a;
  cin>>a;
  for(int i=1;;i++){
    if(i*i<=a&&a<(i+1)*(i+1)){
      cout<<i*i<<endl;
      return 0;
    }
  }
}

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll k;

int main(){
    cin >> k;
    ll ans = 0;
    if(k%2 == 0)  ans = (k/2)*(k/2);
    else    ans = (k/2)*(k/2+1);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long r = 1;
        long[] a = new long[n];
        boolean flag =false;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            if(a[i] == 0)  flag = true;
        }
        if (flag) {
            r = 0;
        } else {
            long t = a[0];
            for (int i = 0; i < n; i++) {
                if (i > 0) {
                    r = t * a[i];
                    if (r > 1000000000000000000L || r < t) {
                        r = -1;
                        break;
                    }
                    t = r;
                }
            }
        }

        System.out.println(r);
    }
}

Measured memory_bytes: 51024
// D

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
int nlx[4] = {0,0,1,-1};
int nly[4] = {1,-1,0,0};

int main(){
  int H,W;
  cin>>H>>W;
  vector<string> S(H);
  for (int i(0);i<H;i++) cin>>S[i];

  vector<int> ans;

  for (int sx(0);sx<W;sx++){
    for (int sy(0);sy<H;sy++){
      //cout << sx << sy << gx << gy << " ";
      if (S[sy][sx] == '#') continue;
      vector<string>s = S;
      int cnt[20][20]={0};
      s[sy][sx]='s';
      queue <pair<int,int>> q;
      q.push({sx,sy});
      bool flag = true;
      int cnti(0);
      while(!q.empty()){
        pair<int,int> now = q.front();
        q.pop();
        if (s[now.second][now.first]=='#') continue;
        //cout << now.first << " " << now.second<< endl;
        s[now.second][now.first]='#';
        for (int i(0);i<4;i++){
          pair<int,int> next = {now.first + nlx[i],now.second+nly[i]};
          if (next.first < 0 || next.first >= W || next.second < 0 || next.second >= H) continue;
          cnt[next.second][next.first] = cnt[now.second][now.first]+1;
          cnti = cnt[next.second][next.first];
          q.push(next);
        }
      }
      ans.push_back(cnti-1);
    }
  }
  int ansi(0);
  for (int i(0);i<ans.size();i++){
    ansi = max(ans[i],ansi);
  }
  cout << ansi << endl;
  return 0;
}


Measured memory_bytes: 256
#ABC157 Guess the number
n,m = map(int,input().split())
sc = [input().split() for _ in range(m)]
ans =[]

if n == 1:
    if len(sc)== 0:
        print('0')
    else:
        ans = []
        for i in range(m):
            ans.append(sc[i][1])
        if len(set(ans)) == 1:
            print(ans[0])
        else:
            print('-1')
    
else:
    for i in range(10**(n-1),10**n):
        cnt = 0
        seq = str(i)
        for j in range(m):
            if seq[int(sc[j][0])-1] == sc[j][1]:
                cnt += 1
        if cnt == m:
            ans.append(i)
        
    if len(ans) == 0:
        print('-1')
    else:
        print(min(ans))

Measured memory_bytes: 3064
//**************************
//*** writer  :  Alan Hu **
//************************

//傅思程你敢抄我程序？？？ 
//傅思程你敢抄我程序？？？	                
//傅思程你敢抄我程序？？？ 

#include<bits/stdc++.h>

using namespace std;
     
#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
     
int n,m,w,pos;
string s[110];
bool com=true,col[110][2],row[110][2],vis[110][110];
vector <string> ans;
     
int main()
{
    cin>>n>>m;
    rept(i,0,n) cin>>s[i];
    rept(i,0,n)
    {
    	rept(j,0,m)
    	{
    		if(vis[i][j]) continue;
    		if(s[i][j]=='.')
    		{
    			row[i][0]=true;
    			col[j][0]=true;
    		}
    		else
    		{
    			row[i][1]=true;
    			col[j][1]=true;
    		}
    	}
    }
    rept(i,0,n)
    {
    	if(row[i][0]&& !row[i][1])
    	{
    		com=true;
    		rept(j,0,m) vis[i][j]=true;
    	}
    }
    rept(i,0,m)
    {
    	if(col[i][0]&& !col[i][1])
    	{
    		com=true;
    		rept(j,0,n) vis[j][i]=true;
    	}
    }
    rept(i,0,n)
    {
    	string tmp="";
    	rept(j,0,m) if(!vis[i][j]) tmp.pb(s[i][j]);
    	if(tmp.size()>0) ans.pb(tmp);
    }
    rept(i,0,ans.size())
    {
    	printf("%s\n",ans[i].c_str());
    }
    	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

int main() {
    ll n,m; cin >> n >> m;
    vvl G(n);
    rep(i,m){
        ll a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,n) sort(all(G[i]));
    vl nxt(n-1);
    rep(i,n-1) nxt[i] = i+1;
    ll ans = 0;
    do{
        ll u = 0;
        bool flag = true;
        rep(i,n-1){
            if(!binary_search(all(G[u]),nxt[i])){
                flag = false;
                break;
            }
            u = nxt[i];
        }
        if(flag) ans++;
    }while(next_permutation(all(nxt)));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; i<n; i++)
#define REP2(i, a, b) for(int i=a; i<b; i++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N-1));
    REP(i, N) REP(j, N-1){
        cin >> A[i][j];
        A[i][j]--;
    }

    int ans = 0;
    vector<int> pos(N);
    while(true){
        bool ok = true;
        REP(i, N)
            if(pos[i] != N-1){
                ok = false;
                break;
            }
        if(ok) break;

        vector<pair<int, int>> ps;
        REP(i, N){
            if(pos[i] == N-1) continue;
            int j = A[i][pos[i]];
            if(pos[j] == N-1) continue;
            int k = A[j][pos[j]];
            if(i == k && i < j) ps.push_back(make_pair(i, j));
        }
        if(ps.empty()){
            cout << -1 << endl;
            return 0;
        }
        for(auto p : ps){
            int i = p.first;
            int j = p.second;
            pos[i]++;
            pos[j]++;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int H,W,m;
    cin>>H>>W>>m;
    P t1[H],t2[W];
    map<P,int> mp;
    for(int i=0;i<H;i++){
        t1[i]=P(0,i);
    }
    for(int i=0;i<W;i++){
        t2[i]=P(0,i);
    }
    int h[m],w[m];
    for(int i=0;i<m;i++){
        cin>>h[i]>>w[i];
        h[i]--,w[i]--;
        mp[P(h[i],w[i])]++;
        t1[h[i]].first++;
        t2[w[i]].first++;
    }
    sort(t2,t2+W,greater<P>());
    int ans=0;
    for(int i=0;i<H;i++){
        int cnt=0;
        cnt+=t1[i].first;
        int v=t1[i].second;
        int tmp=-1;
        for(int j=0;j<W;j++){
            int u=t2[j].second;
            if(tmp==-1){
                tmp=t2[j].first;
                if(mp[P(v,u)])tmp--;
            }
            if(tmp>=t2[j].first)break;
            int t=t2[j].first;
            if(mp[P(v,u)])t--;
            tmp=max(tmp,t);
        }
        ans=max(ans,cnt+tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 48176
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;


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

	int n, x;
	cin >> n >> x;

	vector<int> va;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		va.push_back(a);
	}
	sort(va.begin(), va.end());

	int numGlad = 0;
	for (int i = 0; i < n; i++) {
		if (va.at(i) > x) {
			x = 0;
			break;
		}
		numGlad++;
		x -= va.at(i);
	}

	if (x > 0) {
		numGlad--;
	}

	cout << numGlad << "\n";
	return 0;
}

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

int main() {

    int n, m;

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

    int mysum = n * (n - 1) / 2;
    mysum += m * (m - 1) / 2;

    printf("%d", mysum);

    return 0;

}


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

using namespace std;

int main(void) {
	int A, B;
	cin >> A >> B;
	if(A >= 13) cout << B << '\n';
	if(6 <= A && A <= 12) cout << (B / 2) << '\n';
	if(A <= 5) cout << "0\n";
	return 0;
}



Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))

a = list(range(30000, 30000*(1+n), 30000))
b = a[::-1]

for i,p_tmp in enumerate(p):
    b[p_tmp-1] += i

print(' '.join(map(str, a)))
print(' '.join(map(str, b)))

Measured memory_bytes: 47512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


//AtCoder Beginner Contest 132 - A B


//AtCoder Beginner Contest 133 - A B
int main() {
	ll N;
	scanf("%lld", &N);
	ll D;
	scanf("%lld", &D);
	vvll X(N, vll(D, 0));
	rep(i, N) rep(j, D) {
		ll x;
		scanf("%lld", &x);
		X[i][j] = x;
	}

	ll result = 0;

	reps(i, 0, N - 1) {
		reps(j, i + 1, N - 1) {
			ll d2 = 0;
			rep(k, D) {
				ll sub = X[i][k] - X[j][k];
				d2 += sub * sub;
			}

			rep(k, 16000) {
				if (k * k == d2) {
					result++;
					break;
				}
			}
		}
	}

	printf("%lld\n", result);
}

/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	ll result = min(A * N, B);

	printf("%lld\n", result);
}
*/

//AtCoder Beginner Contest 134 - A B
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll D;
	scanf("%lld", &D);

	ll result = (ll)ceil((double)N / (1 + D * 2));

	printf("%lld\n", result);
}
*/

/*
int main() {
	ll r;
	scanf("%lld", &r);

	ll result = 3 * r * r;

	printf("%lld\n", result);
}
*/

//AtCoder Beginner Contest 135 - B
/*
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> p(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &p[i]);
	}

	ll err = 0;
	rep(i, N) {
		if (p[i] != i + 1) {
			err++;
		}
	}

	if (err <= 2) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
}
*/

//AtCoder Beginner Contest 135 - A
/*
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	if (abs(A - B) % 2 == 1) {
		printf("IMPOSSIBLE\n");
		return 0;
	}

	ll ans = abs(A - B) / 2;
	ll result = min(A, B) + ans;

	printf("%lld\n", result);
}
*/

//AtCoder Beginner Contest 126 - B
/*
int main() {
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	ll front = (s[0] - '0') * 10 + (s[1] - '0');
	ll back = (s[2] - '0') * 10 + (s[3] - '0');

	if ((front > 12 && back > 12) || (front > 12 && back == 0) || (back > 12 && front == 0) || (back == 0 && front == 0)) {
		printf("NA\n");
	}
	else if (front > 12 || front == 0) {
		printf("YYMM\n");
	}
	else if (back > 12 || back == 0) {
		printf("MMYY\n");
	}
	else {
		printf("AMBIGUOUS\n");
	}
}
*/

//AtCoder Beginner Contest 126 - A
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll K;
	scanf("%lld", &K);
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	s[K - 1] = s[K - 1] - 'A' + 'a';

	printf("%s\n", s);
}
*/

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int border[] = { 1,10, 190, 2890, 38890, 488890, 5888890, 68888890, 788888890, 1888888890 };
	int n, k;
	while (cin >> n >> k, n){
		FOR(i,1, 10){
			if (n <= border[i]){
				int mod = (n - border[i - 1]) % i;
				int dif = (n - border[i - 1])/i;
				string s = "";
				int count = 0;
				while (s.length() < 110){
					s += to_string((int)pow(10, i - 1) + dif + count);
					count++;
				}
				s = s.substr(mod, k);
				cout<< s<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3264
n = int(input())
b = []
for i in range(n) :
  b.append(sorted(list(input())))
b.sort()
prev = [1,2,3,4]
tot = 1
ans = 0
for i in range(n) :
  if b[i]==prev :
    tot+=1
  else :
    ans+=(tot*(tot-1)/2)
    tot=1
    prev = b[i]
if tot>1 :
  ans+=(tot*(tot-1)/2)
print(int(ans))

Measured memory_bytes: 24652
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
a = inl()
b = []
acc = [0]*(n+1) # 0, a0, a0+a1, ..., a0+..+an-1
for i in range(n):
    acc[i+1] = acc[i]+a[i]
for i in range(n):
    for j in range(i+1,n+1):
        b.append(acc[j]-acc[i])
z = 0
for e in range(42,-1,-1):
    c = []
    for x in b:
        if (x>>e)%2 == 1:
            c.append(x)
    if len(c)<k:
        continue
    z += (1<<e)
    b = c
print(z)


Measured memory_bytes: 66044
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  ll c, k;
  cin >> n >> c >> k;
  vector<ll> t(n);
  for(int i=0; i<n; i++){
    cin >> t[i];
  }
  ll ans = 0;
  sort(t.begin(), t.end());
  for(int i=0; i<n; i++){
    int j = i;
    //cout << t[i] << " ";
    while (j < n && t[j] - k <= t[i] && j - i < c){
      //cout << t[j] << " ";
      j++;
    }
    ans++;
    i = j - 1;
    //cout << endl;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut fs = vec![0 as usize; n];
    let mut ps = vec![vec![0 as i64; 11]; n];
    for i in 0..n {
        for j in 0..10 {
            let v: usize = read();
            fs[i] |= v << j;
        }
    }
    for i in 0..n {
        for j in 0..11 {
            ps[i][j] = read();
        }
    }
    let mut ans = -1e+9 as i64;
    for j in 1..(1 << 10) {
        let mut sum = 0;
        for i in 0..n {
            let cnt = (fs[i] & j).count_ones() as usize;
            sum += ps[i][cnt];
        }
        ans = std::cmp::max(ans, sum);
    }
    println!("{}", ans);
}


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

using namespace std;

void swap(double &x, double &y, double &xx, double &yy) 
{
  double tmp_x = x;
  double tmp_y = y;
  x = xx;
  y = yy;
  xx = tmp_x;
  yy = tmp_y;
}

bool isZero(double x) 
{
  return x < 0.000000001;
}

void compute(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) 
{
  if (x1 > x2)
    swap(x1, y1, x2, y2);
  else if (x1 == x2 && y1 > y2)
    swap(x1, y1, x2, y2);
  if (x3 > x4)
    swap(x3, y3, x4, y4);
  else if (x3 == x4 && y3 > y4)
    swap(x3, y3, x4, y4);

  double diff_x12 = x2 - x1;
  double diff_y12 = y2 - y1;
  double diff_x34 = x4 - x3;
  double diff_y34 = y4 - y3;

  // if (isZero(diff_x12) && isZero(diff_y12))
  //   cout << "NO" << endl;
  // else if (isZero(diff_x34) && isZero(diff_y34))
  //   cout << "NO" << endl;  
 if (!isZero(diff_x12) && !isZero(diff_x34)) {
    double ab = diff_y12 / diff_x12;
    double cd = diff_y34 / diff_x34;
    if (isZero(abs(ab - cd)))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  else if (isZero(diff_x12) && isZero(diff_x34)) 
    cout << "YES" << endl;  
  else
    cout << "NO" << endl;  
}

int main(void) 
{
  int n;
  cin >> n;
  for (int i=0; i < n; i++) {
    double x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

    //cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << " " << x4 << " " << y4;
    

    compute(x1, y1, x2, y2, x3, y3, x4, y4);
  }
  
  return 0;
}

Measured memory_bytes: 3016
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
using namespace std;
int n,k,x,hp;
bool a[15],flag;
int read(){
    int ans=0,f=1;
    char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){ans=ans*10+ch-'0';ch=getchar();}
    return ans*f;
}
int main(){
	n=read();k=read();
    for (int i=0;i<10;i++)	a[i]=true;
    for (int i=0;i<k;i++){
        x=read();
        a[x]=false;
    }
    bool flag=false;
    while(!flag){
        hp=n;
        flag=true;
        while (hp>0){
            if (!a[hp%10]) flag=false;
            hp/=10;
        }
        n++;
    }
    cout<<n-1;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var N, M int
  fmt.Scan(&N)
  fmt.Scan(&M)

  A := make([]string, N)
  B := make([]string, M)

  for i := 0; i < N; i++ {
    fmt.Scan(&A[i])
  }

  for i := 0; i < M; i++ {
    fmt.Scan(&B[i])
  }

  for y := 0; y < N; y++ {
    for x := 0; x < N; x++ {
      flag := true
      for i := 0; i < M && flag; i++ {
        for j := 0; j < M && flag; j++ {
          if y + i >= N || x + j >= N {
            flag = false
            break
          }
          if A[y + i][x + j] != B[i][j] {
            flag = false
            break
          }
          if i == M - 1 && j == M - 1 {
            fmt.Println("Yes")
            return
          }
        }
      }
    }
  }

  fmt.Println("No")
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int temp=n;
    int result=0;
    while(temp>0){
        result+=temp%10;
        temp/=10;
    }
    if(n%result==0){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for(int i=1; i<10; i++){
            if(N%i==0 && N/i<10){
                System.out.println("Yes");
                return;
            }
        }
		System.out.println("No");
    }
}


Measured memory_bytes: 35388
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define SORT(A) sort(A.begin(), A.end())
#define SORTG(A) sort(A.begin(), A.end(), greater<int>())

using namespace std;
typedef long long ll;

int main()
{
    int N, d;
    cin >> N;
    vector<bool> m(200, false);
    int ans = 0;
    rep(i, N)
    {
        cin >> d;
        if (m.at(d) == false)
        {
            ans++;
            m.at(d) = true;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

   int a;
    cin>>a;
    if(a==111){

        cout<<999;
    }
    else if(a==999){

        cout<<111;
    }
    else if(a==991){

        cout<<119;
    }
else if(a==919){

        cout<<191;
}
    else if(a==199){

        cout<<911;
    }
    else if(a==919){

        cout<<191;
    }
    else if(a==119){

        cout<<991;
    }
    else if(a==191){

        cout<<919;
    }
else if(a==911){

        cout<<199;
    }






    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


int a[100001];
int main() {
  int n,x; cin >> n;
  REP(i,n) { cin >> x; a[x]++; }
  int ans = 0;
  REP(i,100001) ans = max(ans,a[i]+a[i-1]+a[i+1]);
  cout << ans << endl;
  return 0;
}


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

double dp[301][301][301];
int n;

double f(int i, int j, int k) {
  if (dp[i][j][k] > -1e-9) return dp[i][j][k];
  double &ans = dp[i][j][k] = 1 - 1. * (i + j + k) / n;
  if (i) ans += (1 + f(i - 1, j, k)) * i / n;
  if (j) ans += (1 + f(i + 1, j - 1, k)) * j / n;
  if (k) ans += (1 + f(i, j + 1, k - 1)) * k / n;
  ans *= 1. * n / (i + j + k);
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int cnt[3] = {0};
  cin >> n;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      for (int k = 0; k <= n; ++k) {
        dp[i][j][k] = -1;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    --a;
    ++cnt[a];
  }
  dp[0][0][0] = 0;
  cout << fixed << setprecision(10) << f(cnt[0], cnt[1], cnt[2]) << '\n';
}


Measured memory_bytes: 213376
'use strict';

function Main(input) {
  const inp = Number(input);
  const N = input.split("");
  const answerA = [N[0], N[0], N[0]].join("");
  const answerB = [Number(N[0])+1, Number(N[0])+1, Number(N[0])+1].join("");

  if(inp <= answerA) {
    console.log(answerA);
  } else {
    console.log(answerB);
  }

};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 21064
import sys

n, k = map(int, input().split())
d = list({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}-set(int(x) for x in input().split()))

while True:
  ans = n
  while ans > 0:
    key = ans%10
    if key in d:
      ans = ans//10
      if ans == 0:
        print(n)
        sys.exit()
      continue
    else:
      break
  n += 1

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main()
{
	int H, W;

	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0) {
			break;
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i == 0 || i == H - 1) {
					cout << "#";
				}
				else {
					if (j == 0 || j == W - 1) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define N 100005
using namespace std;

int n, x[N], L, maxI[30][N];

int Right(int p){
  
  int l = p, r = n;
  
  while( l + 1 < r ){
    
    int m = ( l + r ) / 2;
    
    if( x[m] - x[p] <= L ) l = m;
    else r = m;
    
  }
  
  return l;
}

int check(int a, int b){
  
  int res = a;
  int cnt = 0;
    
  while(b){
    
    if( b % 2 ) res = maxI[cnt][res];
    
    b /= 2;
    
    cnt++;
    
  }

  return res;
}

int cal(int a, int b){
  
  int l = 0, r = 1e5 + 1;
  
  while( l + 1 < r ){
    
    int m = ( l + r ) / 2;
    
    if( check( a, m ) < b ) l = m;
    else r = m;
    
  }
  
  return r;
}

void solve(){
  
  for(int i=0;i<n;i++) maxI[0][i] = Right( i );
  
  for(int i=1;i<30;i++){
    
    for(int j=0;j<n;j++){
      
      maxI[i][j] = maxI[i-1][maxI[i-1][j]];
      
    }
    
  }
  
  int q;
  cin>>q;
  
  while( q-- ){
    
    int a, b;
    cin>>a>>b;
    
    a--, b--;
    
    if( a > b ) swap( a, b );
    
    cout<<cal( a, b )<<endl;
    
  }
  
}

int main(){
  
  cin>>n;
  
  for(int i=0;i<n;i++) cin>>x[i];
  
  cin>>L;
  
  solve();
  
  return 0;
}


Measured memory_bytes: 12928
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.size = [1] * (n+1)
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
  
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
           
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    def get_size(self, x):
        return self.size[self.find(x)]


def main():
    N,M,K,*uv = map(int, read().split())
    ab, cd = uv[:2*M], uv[2*M:]

    uf = UnionFind(N)
    friend = [set() for _ in range(N+1)]
    for a, b in zip(*[iter(ab)]*2):
        uf.unite(a, b)
        friend[a].add(b)
        friend[b].add(a)
    
    ans = [uf.get_size(i) - 1 - len(friend[i]) for i in range(N+1)]

    for c, d in zip(*[iter(cd)]*2):
        if uf.is_same(c, d):
            ans[c] -= 1
            ans[d] -= 1
    
    print(*ans[1:])


if __name__ == "__main__":
    main()


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

int main(){
    int n, m, p, x;
    while(cin >> n >> m >> p, n+m+p){
        int sum = 0, hit = 0;
        for(int i = 1; i <= n; i++){
            cin >> x;
            sum += x;
            if(i == m)  hit = x;
        }
        if(hit == 0)    cout << 0 << endl;
        else            cout << (sum*100) * (100-p) / 100 / hit << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
import scala.math._
import scala.collection.mutable.ListBuffer

object Main {
  //rt.gc()??§??¬??????????????¬?????????????????????
  //val rt = Runtime.getRuntime()
  val sc = new java.util.Scanner(System.in)
  def main(args: Array[String]) {
    while(sc.hasNext) {
      val n = sc.nextInt
      val ans = n%39 match {
        case 0 => 39
        case m => m
      }
      println(f"3C${ans}%02d")
    }
  }
}

Measured memory_bytes: 45024
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define repn(i, m, n) for(int i = m; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

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

const int INF = 1 << 24;
const int N = 6;
const int M = 10;

int n, x, m, sum = -1;
int l[M], r[M], s[M], res[N], cur[N];

void dfs(int);

int main(void){
    cin >> n >> x >> m;
    rep(i, m) cin >> l[i] >> r[i] >> s[i], l[i]--, r[i]--;
    
    dfs(0);
    if(~sum) rep(i, n) cout << (i ? " ":"") << res[i];
    else cout << sum;
    cout << endl;

    return 0;
}

void dfs(int ind){
    if(ind == n){
        rep(i, m){
            int ss = 0;
            repn(j, l[i], r[i] + 1) ss += cur[j];
            if(ss != s[i]) return;
        }

        int ss = 0;
        rep(i, n) ss += cur[i];
        if(ss > sum){
            sum = ss;
            rep(i, n) res[i] = cur[i];
        }
        
        return;
    }

    rep(i, x + 1) cur[ind] = i, dfs(ind + 1); 
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e5+5;
ll n,m,num,L,R;
vector<ll> l,r;
int flag[N];

int solve() {
  L = *max_element(ALL(l));
  R = *min_element(ALL(r));
  
  return R - L < 0 ? 0 : R - L + 1;
}

int main () {
  ios::sync_with_stdio(false);cin.tie(nullptr);
  cin >> n >> m;
  rep(i,m) {
    cin >> L >> R;
    l.push_back(L);
    r.push_back(R);
  }
  L = 1;R = n;
  
  
  cout << solve() << endl;
}


Measured memory_bytes: 2036