akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean isNext(){return sc.hasNext();}
        static char[] mySplit(String str){return str.toCharArray();}
        public static void main(String[] args){
          int H = getInt();
          int W = getInt();
          char[][] masu = new char[H][W];
          //q内要素が多いと時間かかる
          ArrayDeque<int[]> q = new ArrayDeque<int[]>();
          for(int i = 0; i < H; i++){
            masu[i] = mySplit(getStr());
          }
          
          for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
              if(masu[i][j] == '#'){
                //4方のうち、1か所でも.があればqに追加
                if(i != 0 && masu[i - 1][j] == '.' || 
                  j != 0 && masu[i][j - 1] == '.' || 
                  i != H - 1 && masu[i + 1][j] == '.' || 
                  j != W - 1 && masu[i][j + 1] == '.'){
                  int[] mp = {i, j ,0};
                  q.add(mp);
                }
              }
            }
          }
          
          int output = 0;
          
          
          //myerr(q);
          while(!q.isEmpty()){
            int[] tmp = q.poll();
            int y = tmp[0];
            int x = tmp[1];
            int count = tmp[2];
            //myerr(y + " " + x);
            output = Math.max(output,count);
            if(y != 0 && masu[y - 1][x] == '.'){
                int[] mp = {y- 1, x ,count + 1};
                masu[y - 1][x] = '#';
                q.add(mp);
            }
            if(x != 0 && masu[y][x - 1] == '.'){
                int[] mp = {y, x - 1, count + 1};
              	masu[y][x - 1] = '#';
                q.add(mp);
            }
            if(y != H - 1 && masu[y + 1][x] == '.'){
                int[] mp = {y + 1, x, count + 1};
              	masu[y + 1][x] = '#';
                q.add(mp);
            }
            if(x != W - 1 && masu[y][x + 1] == '.'){
              	int[] mp = {y, x + 1, count + 1};
              	masu[y][x + 1] = '#';
                q.add(mp);
            }
          }
          myout(output);
        }
        //Method addition frame start

        //Method addition frame end
}


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

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

using namespace std;

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

	int dp[100001]={};
	rep(i,n+1) dp[i]=i;
	for(int a=6;a<=n;a*=6) for(int w=a;w<=n;w++) dp[w]=min(dp[w],dp[w-a]+1);
	for(int a=9;a<=n;a*=9) for(int w=a;w<=n;w++) dp[w]=min(dp[w],dp[w-a]+1);
	cout<<dp[n]<<endl;

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
  int N,i,A[100],c=0;
  int j,X;
  int minj;


  scanf("%d",&N);

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


  for(i=0;i<N;i++)
    {
      minj=i; 
      for(j=i;j<N;j++)
	{
	  if(A[j]<A[minj])
	    { 
	      minj=j;
	    }
	}

      if(minj>i)
	{
	  X=A[i];
	  A[i]=A[minj];
	  A[minj]=X;
	  c++;
	}
    }
 



  for(i=0;i<N-1;i++)
    {
      printf("%d ",A[i]);
    }

  printf("%d\n",A[N-1]);
  printf("%d\n",c);
  return 0;

}
  

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;

const int N=1e5+5;
int n,m,val[N],p[N],a[N],b[N],s[N],dp[N];
vector<int>adj[N],g[N];
pii order[N];
bool vis[N];

int Find(int x)
{
    if(x==p[x]) return x;
    return p[x]=Find(p[x]);
}

void dfs(int u)
{
    s[u]=b[u];
    for(auto&v:g[u])
    {
        dfs(v);
        s[u]+=s[v];
    }
    if(g[u].empty()) dp[u]=max(a[u],b[u]);
    else dp[u]=1e18;
    for(auto&v:g[u]) dp[u]=min(dp[u],max(dp[v],val[u])+s[u]-s[v]);
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        p[i]=i;
        cin>>a[i]>>b[i];
        val[i]=max(a[i]-b[i],0ll);
        order[i]=mp(val[i],i);
    }
    sort(order+1,order+n+1);
    while(m--)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i=1;i<=n;i++)
    {
        int u=order[i].se;
        vis[u]=true;
        for(auto&v:adj[u])
        {
            if(!vis[v]) continue;
            v=Find(v);
            if(v==u) continue;
            g[u].push_back(v);
            p[v]=u;
        }
    }
    int r=order[n].se;
    dfs(r);
    cout<<dp[r];
}


Measured memory_bytes: 24208
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int T,n,p,q,u;
ll l,r,ans,v;

ll read(){
	ll x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

void print(ll x){
	if(x>=10) print(x/10);
	putchar(x%10+'0');
}

int main(){
	l=read(),r=read();
	if(l==r){
		puts("1");return 0;
	}
	for(int i=60;i>=0;i--){
		p=(l&(1ll<<i))>0,q=(r&(1ll<<i))>0;
		if(p!=q){u=i;break;}
		if(p) l^=(1ll<<i),r^=(1ll<<i);
	}
	v=-1;
	for(int i=u-1;i>=0;i--){
		p=(r&(1ll<<i))>0;
		if(p){v=i;break;}
	}
	v=1ll<<(v+1);
	if(l>v) ans=(1ll<<u)+v-l+(1ll<<u)-l;
	else ans=(1ll<<(u+1))-l;
	print(ans),puts("");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int f(int n){int s=0;while(n!=0){s+=n%10;n/=10;}return s;}

signed main() {
  cout << fixed << setprecision(15);
  int a,b,k;
  cin >> a >> b >> k;
  rep(i,0,k){
    if(i%2==0){
      if(a%2==1) a--;
      b += a/2;
      a /= 2;
    }
    else {
      if(b%2==1) b--;
      a += b/2;
      b /= 2;
    }
  }
  cout << a << ' '<<b << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    vector<ll> A;
    map<ll, int> m;

    for(int i=0;i<N;i++){
        ll a; cin >> a;
        A.push_back(a);
        m[a]++;
    }

    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());
    int ans = 0;
    for(auto a : A){
        if(m[a]%2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define stop exit(0)
#define dd double
#define po pop_back
#define pb push_back
#define ub upper_bound
#define lb lower_bound
int main(){
    vector <long long> v;
    ll a,b,c,d=0,e=0,f=0,g=0,i,j,k=1,l=1,r=1,n,m[300001],z[400001],h[600001],p[600001];
    string s,t,x,y[1001];
    dd q,u,w;
    cin>>a>>b;
    for(i=1;i<=b;i++){
        cin>>c;
        d+=c;
    }
    if(d>a){
        cout<<-1;
        stop;
    }
    else{
        cout<<a-d;
    }
}

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

void solve(std::string S)
{
    if (S == "Rainy")
        cout << "Sunny" << endl;
    else if (S == "Sunny")
        cout << "Cloudy" << endl;
    else
        cout << "Rainy" << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
import collections
n=int(input())
a = list(map(int, input().split()))
an=0
ii=[]
jj=[]
for i in range(n):
    ii.append(i+a[i])
    jj.append(i-a[i])
jjj=collections.Counter(jj)
for i in range(n):
    an+=jjj[ii[i]]
print(an)

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  long double arr[N];
  for(int i = 0;  i < N; ++i) {
    cin >> arr[i];
  }
  long double dp[N+1][N+1];
  dp[0][0] = 1.0;
  for(int i = 1; i < N+1; ++i) {
    dp[i][0] = dp[i-1][0] * (1-arr[i-1]);
  }
  for(int i = 1; i < N+1; ++i) {
    dp[0][i] = 0.0;
  }
  for(int r = 1; r < N+1; ++r) {
    for(int c = 1; c < N+1; ++c) {
      dp[r][c] = dp[r-1][c-1] * arr[r-1] + (1-arr[r-1]) * dp[r-1][c];
    }
  }
  long double result = 0;
  for(int i = ceil(N/2.0); i < N+1; ++i) {
    result += dp[N][i];
  }
  cout << setprecision(15) << result << "\n";

}

Measured memory_bytes: 144420
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int a;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> a;
	int ans = a + a * a + a * a * a;
	cout << ans << endl;
}







Measured memory_bytes: 3648
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
int main()
{
	fast;
	ll n;
	cin>>n;
	ll a[n];
	ll dp1[1000006]={0};
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		dp1[a[i]]++;	
	}
	sort(a,a+n);
	ll dp[1000006]={0};

	ll count=0;
	for (int i = 0; i < n; ++i)
	{
		//cout<<a[i]<<endl;
		if(dp[a[i]]==0)
		{
			if(dp1[a[i]]<=1)
			count++;
			for (int j = 2*a[i]; j <= a[n-1]; j+=a[i])
			{
				dp[j]=1;
			}
		}
	}
	cout<<count<<endl;

}






Measured memory_bytes: 20840
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<algorithm>
#include<string.h>

using namespace std;

int main(int argc, char* argv[]){
  int n;
  long long h;
  long long int a[100001];
  long long int b[100001];
  scanf("%d%lld",&n,&h);
  for(int i=0;i<n;i++){
    scanf("%lld%lld",&a[i],&b[i]);
  }
  long long int ans = 0;
  sort(a,a+n,greater<long long int>());
  sort(b,b+n,greater<long long int>());
  for(int i=0;i<n;i++){
    if(h<=0)break;
    if(a[0]<=b[i]){
      h-=b[i];
      ans++;
    }
    else break;
  }
  if(h>0){
    if(h%a[0]==0)ans+=h/a[0];
    else ans+=1+(h/a[0]);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <utility>
using namespace std;
typedef pair<int, int> P;

class UnionFind
{
    int par[200002], rank[200002];
    
public:
    UnionFind(int n){
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int find(int i){
        if(i == par[i]) return i;
        return par[i] = find(par[i]);
    }
    
    bool same(int i, int j){
        return par[i] == par[j];
    }
    
    void unite(int i, int j){
        if(same(i, j)) return;
        i = find(i), j = find(j);
        if(rank[i] < rank[j]) par[i] = j;
        else{
            par[j] = i;
            if(rank[i] == rank[j]) rank[i]++;
        }
    }
};

int main()
{
    int n, k, l;
    cin >> n >> k >> l;
    int p[100002], q[100002], r[100001], s[100002];
    UnionFind u(n), t(n);
    for(int i = 0; i < k; i++){
        cin >> p[i] >> q[i];
        p[i]--;
        q[i]--;
        u.unite(p[i], q[i]);
    }
    for(int i = 0; i < l; i++){
        cin >> r[i] >> s[i];
        r[i]--;
        s[i]--;
        t.unite(r[i], s[i]);
    }
    map<P, int> mp;
    for(int i = 0; i < n; i++){
        mp[P(u.find(i), t.find(i))]++;
    }
    for(int i = 0; i < n; i++){
        cout << mp[P(u.find(i), t.find(i))] << endl;
    }
}

Measured memory_bytes: 16640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int h = scan.nextInt(), n = scan.nextInt();
		int[] dp = new int[h+1];
		for (int i = 0; i < dp.length; i++) dp[i] = 999999999;
		
		dp[0] = 0;
		while (n-- > 0) {
			int value = scan.nextInt();
			int cost = scan.nextInt();
			
			for (int i = 0; i <= h; i++) {
				int j = Math.min(h, i + value);
				dp[j] = Math.min(dp[j], dp[i] + cost);
			}
		}
		System.out.println(dp[h]);
	}

}

Measured memory_bytes: 27624
#include <bits/stdc++.h>
using namespace std;
const double oo = 1e18;

int n, x[100100], y[100100];
char d[100100];

double calc(double t)
{
  double xMax = -oo, xMin = oo, yMax = -oo, yMin = oo;
  for (int i = 0; i < n; i++)
  {
    double curX = x[i], curY = y[i];
    if (d[i] == 'U') curY += t;
    else if (d[i] == 'D') curY -= t;
    else if (d[i] == 'R') curX += t;
    else curX -= t;
    xMax = max(xMax, curX);
    xMin = min(xMin, curX);
    yMax = max(yMax, curY);
    yMin = min(yMin, curY);
  }
  return (xMax - xMin) * (yMax - yMin);
}

int main()
{
  ios::sync_with_stdio(0);
  
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i] >> d[i];

  double ans = calc(0), low = 0, high = 1e9;
  for (int turn = 0; turn < 150; turn++)
  {
    double mid1 = (low * 2 + high) / 3, v1 = calc(mid1);
    double mid2 = (low + high * 2) / 3, v2 = calc(mid2);
    if (v1 < v2) high = mid2;
    else low = mid1;
  }

  ans = min(ans, calc(low));
  cout << fixed << setprecision(9) << ans << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
using namespace std;
int main()
{
    ll n, base = 1, binary = 0;
    cin >> n;
    string ans = "";
    while (n != 0)
    {
        ll q = n / -2;
        int r = n % -2;
        if (r < 0)
        {
            q += 1;
            r = 1;
        }
        ans = to_string(r) + ans;
        n = q;
    }
    if (ans == "")
        ans = "0";
    cout << ans << endl;
    return 0;
}

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

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];

  int ans = 0;

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

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


Measured memory_bytes: 256
using System;
    using System.Collections.Generic;
    using System.Linq;
     
    namespace contest_Csharp
    {
        class Program
        {
            static void Main(string[] args)
            {
     
                int N = int.Parse(Console.ReadLine());
     
                //var A = Console.ReadLine().Split(' ')
                //.Select(x => long.Parse(x)).ToList();
                Console.WriteLine(3.1416 * N * 2);
                
     
     
            }
           
     
        }
    }

Measured memory_bytes: 18632
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 20 11:39:53 2017

"""

def judge(AList, result):
    
    AList_by2 = []
    
    for A in AList:
        if A % 2 == 1:
            return result
        else:
            AList_by2.append(A/2)
    
    result += 1
    return judge(AList_by2, result)
        
    
    

N = int(input())
AList = list(map(int,input().split()))

print(judge(AList,0))



Measured memory_bytes: 3444
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<long long> v(5);
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        if (s[0] == 'M') v[0]++;
        if (s[0] == 'A') v[1]++;
        if (s[0] == 'R') v[2]++;
        if (s[0] == 'C') v[3]++;
        if (s[0] == 'H') v[4]++;
    }

    long long ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i+1; j < 5; j++) {
            for (int k = j+1; k < 5; k++) {
                ans += v[i] * v[j] * v[k];
            }
        }
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct binary_indexed_tree{
	int N;
	vector<T> BIT;
	binary_indexed_tree(int n){
		N = 1;
		while (N < n){
			N *= 2;
		}
		BIT = vector<T>(N + 1, 0);
	}
	void add(int i, T x){
		i++;
		while (i <= N){
			BIT[i] += x;
			i += i & -i;
		}
	}
	T sum(int i){
		T ans = 0;
		while (i > 0){
			ans += BIT[i];
			i -= i & -i;
		}
		return ans;
	}
	T query(int L, int R){
		return sum(R) - sum(L);
	}
	T all(){
		return BIT[0];
	}
};
int main(){
  int N, Q;
  cin >> N >> Q;
  vector<int> c(N);
  for (int i = 0; i < N; i++){
    cin >> c[i];
    c[i]--;
  }
  vector<tuple<int, int, int>> query(Q);
  for (int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    l--;
    query[i] = make_tuple(r, l, i);
  }
  sort(query.begin(), query.end());
  vector<int> last(N, -1);
  binary_indexed_tree<int> BIT(N);
  vector<int> ans(Q);
  int R = 0;
  for (int i = 0; i < Q; i++){
    int l = get<1>(query[i]);
    int r = get<0>(query[i]);
    int id = get<2>(query[i]);
    while (R < r){
      if (last[c[R]] != -1){
        BIT.add(last[c[R]], -1);
      }
      last[c[R]] = R;
      BIT.add(R, 1);
      R++;
    }
    ans[id] = BIT.query(l, r);
  }
  for (int i = 0; i < Q; i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 17496
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
unordered_map<ll,ll> mp;
void primes(ll n)
{
  while(n%2==0)
  {
    mp[2]++;
    n=n/2;
  }
  for(ll i=3;i*i<=n;i=i+2)
  {
    while(n%i==0)
    {
      mp[i]++;
      n=n/i;
    }
  }
  if(n>2)
    mp[n]++;

}
int main()
{
  ll n;
  cin>>n;
  primes(n);
  ll ans=0;
  for(const auto& m: mp)
  {
    ll k=1;
    while((m.second*2)/(k*(k+1))>=1)
    {
      k++;
    }
    ans+=k-1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
using namespace std;
int mx,n,i,gd=0,k,x;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int main()
{
	mx=0;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x);
		gd=gcd(gd,x);
		mx=max(mx,x);
	}
	if(k%gd==0&&k<=mx)printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
 } 

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

int main() {

			vector<pair<char,char>>pp;
			pp.push_back(make_pair('A','T'));
			pp.push_back(make_pair('C','G'));
			char c;
			cin>>c;
			if(c=='A'){cout<<pp[0].second;}
			if(c=='T'){cout<<pp[0].first;}
			if(c=='C'){cout<<pp[1].second;}
			if(c=='G'){cout<<pp[1].first;}


}

Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
#define lsb(x) ((x) & -(x))
using namespace std;

#define mod 1000000007
const int NMAX = 3010;
int dp[2][NMAX];

void pass(int * from, int * act, int n, bool smaller)
{
    /// am n elemente, dinamica pt nivelul din spate e in from
    /// n-am nevoie de fill ca folosesc din ce in ce mai multe elemente
    /// smaller inseamnaca asunt mai mic decat cel dinaintea mea

    if (smaller) {
        for (int i = 0; i < n; i++) {
            /// trebuie sa vin din cv >= i
            act[i] = from[n - 2];
            if (i) {
                act[i] -= from[i - 1];
                if (act[i] < 0)
                    act[i] += mod;
            }
        }
    }
    else {
        act[0] = 0;
        for (int i = 1; i < n; i++)
            act[i] = from[i - 1];
    }

    for (int i = 1; i < n; i++) {
        act[i] += act[i - 1];
        if (act[i] >= mod)
            act[i] -= mod;
    }
}

int main()
{
    int n;
    string s;
    cin >> n >> s;
    dp[1][0] = 1;

    for (int i = 0; i < s.size(); i++)
        pass(dp[(i & 1) ^ 1], dp[i & 1], i + 2, (s[i] == '>'));


    cout << dp[n & 1][n - 1] << '\n';

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e5 + 5;
const int M = 17 + 5;
const int W = 1000 + 5;
const int OO = 2e9;
const int mod = 1e9 + 7;

int c,d;
ll a,b;

ll lcm(ll x, ll y) {

    return x*y/__gcd(x,y);

}

ll solve(ll i) {

    return i-i/c + i-i/d - (i-i/lcm(c,d));

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> a >> b >> c >> d;

    cout << solve(b)-solve(a-1) << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PLI pair<ll,int>
#define PII pair<int, int>
#define X first
#define Y second
#define MP make_pair
#define PLL pair<ll, ll>
#define ll long long
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define N 100010
const double eps = 1e-6;
using namespace std;

int Read()
{
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
ll ReadL()
{
    ll x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
char s[N];
int cnt[4];

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);

    while(scanf("%s", s) != EOF)
    {
        int l = strlen(s);
        cnt[0] = cnt[1] = cnt[2] = 0;
        for(int i = 0; i < l; i ++)
            cnt[s[i]-'a'] ++;
        sort(cnt, cnt + 3);
        if(cnt[2] - cnt[0] > 1) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  D a,b;
  cin>>a>>b;
  cout<<fixed<<setprecision(12)<<1.0/(1/a+1/b)<<endl;
  


  return 0;
}


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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

const int N = 1e5+5;
vector<int> g[N];
bool vis[N];
int n,m;
int p[N];

void solve()
{
  cin >> n >> m;
  for(int i=0;i<m;i++)
  {
    int x,y;
    cin >> x >> y;
    g[x].Pb(y);
    g[y].Pb(x);
  }
  queue<int> q;
  q.push(1);
  vis[1]=1;
  while(!q.empty())
  {
    int v = q.front();
    q.pop();
    for(int u : g[v])
    {
      if(!vis[u])
      {
        q.push(u);
        vis[u]=1;
        p[u] = v;
      }
    }
  }
  for(int i=2;i<=n;i++)
  {
    if(!vis[i])
    {
      cout << "No";
      return;
    }
  }
  cout << "Yes" << endl;
  for(int i=2;i<=n;i++)
  {
    cout << p[i] << endl;
  }
}

signed main()
{
  IOS;
  //freopen("input.txt", "rt", stdin);
  //freopen("output.txt", "wt", stdout);
  int t=1;
  //cin >> t;
  while(t--)
  {
    solve();
  }
  return 0;
}
/*==============================================================================================================================================================*/


Measured memory_bytes: 10664
n, x = input().split()
n = int(n)
x = int(x)
m = []
m_min = 1000
gokei = 0
for i in range(n):
  m.append(int(input()))
  gokei += m[i]
  if m_min > m[i]:
    m_min = m[i]
x -= gokei
print((x//m_min) + n)

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

long long cnt=0;
vector<int> G;

void insertionSort(int a[],int n,int g){
    for(int i=g;i<n;i++){
        int v=a[i];
        int j=i-g;
        while(j>=0 && a[j]>v){
            a[j+g]=a[j];
            j-=g;
            cnt++;
        }
        a[j+g]=v;
    }
}

void shellSort(int a[],int n){
    for(int h=1; ;){
        if(h>n) break;
        G.push_back(h);
        h=h*3+1;
    }
    for(int i=G.size()-1;i>=0;i--){
        insertionSort(a,n,G[i]);
    }
}

int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cnt=0;
    shellSort(a,n);
    string c="";
    
    cout<<G.size()<<endl;
    for(int i=G.size()-1;i>=0;i--){
        cout<<c<<G[i];
        c=" ";
    }
    cout<<endl;
    cout<<cnt<<endl;
    for(int i=0;i<n;i++) cout<<a[i]<<endl;
}



Measured memory_bytes: 7100
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000000007
#define MOD 1000000007
#define ARRAY_MAX 3005


//重み付きUnion-Find
struct Potential_UnionFind{

    vector<int> par;//親
    vector<int> rank;//高さ
    vector<int> diff_weight;//根からの重み

    void init(int n) {
        par.resize(n);
        rank.resize(n);
        diff_weight.resize(n);
        REP(i,n){
            par[i] = i;
            rank[i] = 0;
            diff_weight[i] = 0;
        }
    }

    int root(int x) {//親を探す
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    int weight(int x) {
        //親からの重みを返す
        root(x);
        return diff_weight[x];
    }

    bool issame(int x,int y) {
        //同じ親を持つ要素かどうか
        return root(x) == root(y);
    }

    void merge(int x, int y,int w) {
        //weight(y) - weight(x) = wとなるようにつなげる
        int rx = root(x);
        int ry = root(y);
        
        if(rank[rx] < rank[ry]){
            diff_weight[rx] = -w - weight(x) + weight(y);
            par[rx] = ry;
        }else{
            diff_weight[ry] = w + weight(x) - weight(y);
            par[ry] = rx;
            if(rank[rx] == rank[ry]){
                rank[rx]++;
            }
        }
    }

    int diff(int x, int y) {
        //weight(y) - weight(x)を返す
        return weight(y) - weight(x);
    }
};


int main(){

    Potential_UnionFind tree;
    int n,m;
    cin >> n >> m;
    tree.init(n);
    bool ans = true;

    for(int i = 0;i < m;i++){

        int l,r,d;
        cin >> l >> r >> d;
        l--;
        r--;
        if(tree.issame(l,r)){
            int distance = tree.diff(l,r);//r-l;
            if(distance != d){
                ans = false;
                break;
            }
        }else{
            tree.merge(l,r,d);
        }
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << 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;

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= b)
    rep(i, b) cout << a;
  else
    rep(i, a) cout << b;
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		long a = Long.parseLong(st.nextToken());
 		long b = Long.parseLong(st.nextToken());
 		long n = Long.parseLong(st.nextToken());
 		long x = n/b*b-1;
 		if (x == -1){
 			x = n;
 		}
 		long ans = Math.floorDiv(a*x, b) - a*Math.floorDiv(x,b);
 		
 		
 		out.println(ans);
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25344
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = 998244353;

int main(){
    cin>>K>>N;
    mat nCm(4010,vec(4010,1));
    reps(i,1,4010){
        reps(j,1,4010){
            nCm[i][j] = (nCm[i][j-1] + nCm[i-1][j]) % MOD;
        }
    }
    vec exp(3000,1);
    reps(i,1,3000) exp[i] = (exp[i-1]*2)%MOD;
    vec memo(K,0);
    reps(i,2,K+2){
        ll &m = memo[i-2];
        bool even = 1-i%2;
        rep(j,2-(i%2)){
            rep(k,(i+1)/2){
                ll p = K-1+k-2*((i-1)/2)-even;
                if(p < 0){
                    if(j+k == N) (m += exp.at(k))%=MOD;
                    continue;
                }
                if(j+k >N) continue;
                ll temp = (nCm.at(p).at(N-j-k) * exp.at(k))%MOD;
                (m += (temp * nCm.at((i-1)/2 - k).at(k))%MOD)%=MOD;
            }
        }
        cout<<m<<endl;
    }
    reps(i,K+2,K*2+1){
        cout<<memo[K*2-i]<<endl;
    }
}


Measured memory_bytes: 126080
#include<iostream>
#include<algorithm>
#include <utility>
using namespace std;
int N, M;
pair<int, int> PD[10010];
int solve();
int min(int, int);
bool compare(pair<int, int>, pair<int, int>);
int main()
{
	while (cin >> N >> M && N)
	{
		int d, p;
		for (int i = 0; i<N; i++)
		{
			cin >> d >> p;
			PD[i] = make_pair(p, d);
		}
		sort(PD, PD + N, compare);
		cout << solve() << endl;
	}

	return 0;
}

int solve()
{
	int s = 0;
	for (int i = 0; i<N; i++)
		s += PD[i].first*PD[i].second;
	for (int i = 0; i<N; i++)
	{
		if (M <= 0)break;
		int guarded = min(M, PD[i].second);
		s -= PD[i].first*guarded;
		M -= guarded;
	}
	return s;
}

int min(int a, int b)
{
	if (a<b)return a;
	else return b;
}
bool compare(pair<int, int> a, pair<int, int> b)
{
	return a.first > b.first;
}



Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;

#define ll long long

int main() {
	int H, W; cin >> H >> W;
	vector<string> a(H);
	vector<pair<int, int>> v;
	vector<vector<bool>> f(H+2, vector<bool>(W+2, true));
	int cnt=0;
	for(int i=0; i<H; ++i){
	    cin >> a[i];
	    for(int j=0; j<W; ++j){
	        if(a[i][j]=='#'){
	            v.push_back(make_pair(i+1, j+1));
	            ++cnt;
	            f[i+1][j+1]=false;
	        }
	    }
	}
	int ans=0;
	while(cnt<H*W){
	    ++ans;
	    vector<pair<int, int>> b;
	    for(int i=0; i<v.size(); ++i){
	        int p=v[i].first, q=v[i].second;
	        if(f[p-1][q] && p>1){
	            ++cnt;
	            f[p-1][q]=false;
	            b.push_back(make_pair(p-1, q));
	        }
	        if(f[p+1][q] && p<H){
	            ++cnt;
	            f[p+1][q]=false;
	            b.push_back(make_pair(p+1, q));
	        }
	        if(f[p][q-1] && q>1){
	            ++cnt;
	            f[p][q-1]=false;
	            b.push_back(make_pair(p, q-1));
	        }
	        if(f[p][q+1] && q<W){
	            ++cnt;
	            f[p][q+1]=false;
	            b.push_back(make_pair(p, q+1));
	        }
	    }
	    v.swap(b);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 14996
a,b,c,k = map(int, input().split())

tmpk = 0

tmp = 0
flg = True

if a > k:
    print(k)
    flg = False
else:
    tmp = a
    tmpk = k - a
    if tmpk <= 0:
        print(tmp)
        flg = False

if b > tmpk and flg:
    print(tmp)
    flg = False
elif flg:
    tmpk -= b
    if tmpk <= 0:
        print(tmp)
        flg = False

if flg:
    tmp -= tmpk
    print(tmp)

    

Measured memory_bytes: 9196
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        string s = Console.ReadLine();

        string ans = "Yes";
        if (s == "AAA" || s == "BBB")
        {
            ans = "No";
        }
        Console.WriteLine(ans);
    }
}

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

int main() {
    
    int N;
    cin >> N;
    
    if(N == 0)
    {
        cout << 0 << "\n";
        return 0;
    }
    
    int k = 0;
    vector<int> X;
    
    while(N)
    {
        X.push_back(abs(N) % 2);
        
        if(N % 2 == 0)
            N /= 2;
        else if(k % 2)
            N = (N + 1)/2;
        else
            N = (N - 1)/2;
        
        k++;
    }
    
    reverse(X.begin(), X.end());
    
    for(auto x : X)
        cout << x;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >>N;
  
  vector <string> s(N);
  
  for(int i=0;i<N;i++){
    cin >> s.at(i);
  }
  
  cin >>M;
  
  vector <string> t(M);
  
  for(int i=0;i<M;i++){
    cin >> t.at(i);
  }
  
  int ans=0;
  
  for(int i=0;i<N;i++){
    int x=0;
    for(int j=0;j<N;j++){
      if(s.at(i)==s.at(j)){
        x++;
      }
    }
    
    for(int j=0;j<M;j++){
      if(s.at(i)==t.at(j)){
        x--;
      }
    }
    
    if(x>ans)ans=x;
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int x, y, a, xmax, ymax, xmin = 0, ymin = 0, w, h, n;
int main(void){
    // Your code here!
    cin >> xmax >> ymax >> n;
    for (int i = 0; i < n; i++) {
        cin >> x >> y >> a;
        if (a == 1) xmin = (x > xmin ? x : xmin);
        if (a == 2) xmax = (x < xmax ? x : xmax);
        if (a == 3) ymin = (y > ymin ? y : ymin);
        if (a == 4) ymax = (y < ymax ? y : ymax);
    }
    int ran = (xmax - xmin) * (ymax - ymin);
    if (xmax < xmin || ymax < ymin) cout << 0 << endl;
    else cout << ran << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int nextInt(){int a;cin>>a;return a;}

int main(){
  int n,m,p,sum;
  int x[1000];
  while(cin>>n&&cin>>m&&cin>>p){
    if(!n&&!m&&!p)break;
    sum = 0;
    REP(i,n){
      x[i] = nextInt();
      sum +=x[i];
    }
    if(!x[m-1]){cout << 0 << endl;continue;}
    cout << sum*(100-p)/(x[m-1]) << endl;
  }
  return 0;
}

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

using namespace std;


long long int minimumposiblecost(long long int *arr,int n){


    long long int DP[n][n];

     long long int prefix_sum[n];

     long long int sum=0;

     for(int i=0;i<n;i++)
     {
     	sum+=arr[i];
     	prefix_sum[i]=sum;
     }

 
  for(int i=0;i<n;i++)
  	DP[i][i]=0;


  for(int len=1;len<n;len++){

  
    for(int i=0,j=len;j<n;j++,i++){

        if(len==1)
        DP[i][j]=arr[i]+arr[j];
    
      else{
              long long int ans=10000000000000000;
          for(int k=i;k<j;k++)
           {
              long long int pre1=(i==0)?prefix_sum[k]:(prefix_sum[k]-prefix_sum[i-1]);
               long long int pre2=prefix_sum[j]-prefix_sum[k];
              
            ans=min(ans,pre1+pre2+DP[i][k]+DP[k+1][j]);

           }
              
              DP[i][j]=ans;

      }


    }



  }


return DP[0][n-1];

}



int main(){

    int n;
    cin>>n;


    long long int arr[n];
    
 
     for(int i=0;i<n;i++)
     	cin>>arr[i];


     cout<<minimumposiblecost(arr,n)<<endl;


	return 0;
}

Measured memory_bytes: 4820
/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(x) cout << "x " << x;

int main()
{
   int n;
   cin >> n;
   cout << ceil(n*1.0 / 2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int num;
    int A[100];
	int i, j, k;
	int V;

    scanf("%d", &num);

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

    for(i=1; i<=num; i++){
        for(k=0; k<num; k++){
			if(k==num-1){
				printf("%d", A[k]);
			}else{
				printf("%d ", A[k]);
			}
		}
		printf("\n");
        V = A[i];
        j = i-1;

        while(A[j] > V  && j >= 0){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = V;
    }

	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>

using namespace std;
typedef long double ld;
typedef long long int ll;
typedef vector <ll> vl;
const int INF = (1 << 30);

int solve();

int main(void) {

	solve();

	return 0;

}

int solve() {

	int N, K;
	cin >> N >> K;
	vector<int> v(K, 0);
	for (int i = 0; i < K; i++) {
		cin >> v[i];
	}

	int ans = N;

	while (true) {
		stringstream ss;
		ss << ans;

		bool b = false;
		for (int i = 0; i < K; i++) {
			b |= (ss.str().find('0' + v[i]) != string::npos);
		}
		if (!b){ break; }
		ans++;
	}

	cout << ans << endl;

	return 1;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Msi = M<string, int>;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
    int n;
    cin >> n;
    Vi v(n);
    REP(i, n) {
        cin >> v[i];
    }
    sort(ALL(v), greater<int>());

    double cnt = 0;
    REP(i, n) {
        if (i != n-1) {
            cnt += v[i] * pow(0.5, i+1);
        } else {
            cnt += v[i] * pow(0.5, i);
        }
    }
    printf("%.6f\n", cnt);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

#define rp(i,t) for(int i=0;i<(t);i++)
#define rep(i,s,t) for(int i=(s);i<=(t);i++)
#define rsp(i,s,t) for(int i=(s);i<(t);i++)
#define rrp(i,t,s) for(int i=(t);i>=(s);i--)
#define rcp(i,s,b,d) for(int i=(s);b;d)
#define mst(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define N 100002

#define Dp puts("")
#define Dw printf
#define Ds printf("#")

typedef long long ll;
char ch,last;
ll n,a[N],s[N],tmp,ans;

inline void read(ll &x){x=ch=0;do{last=ch;ch=getchar();}while(ch<'0'||'9'<ch);do{x=x*10+ch-'0';ch=getchar();}while('0'<=ch&&ch<='9');if(last=='-')x=-x;}

int main(void)
{
	read(n);
	rep(i,1,n)read(a[i]);
	rep(i,1,n)
	{
		s[i]=s[i-1]+a[i];
		if(i&1)
		{
			if(s[i]<=0)tmp+=1-s[i],s[i]=1;
		}
		else
		{
			if(s[i]>=0)tmp+=s[i]+1,s[i]=-1;
		}
	}
	ans=tmp;
	tmp=0;
	rep(i,1,n)
	{
		s[i]=s[i-1]+a[i];
		if(i&1)
		{
			if(s[i]>=0)tmp+=s[i]+1,s[i]=-1;
		}
		else
		{
			if(s[i]<=0)tmp+=1-s[i],s[i]=1;
		}
	}
	ans=min(ans,tmp);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007

using namespace std;

int n,x,y;
pair<int,int> ba[200005];
class DMegalomania {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n;
		f(i,0,n)
		{
			in >> x >> y;
			ba[i]={y,x};
		}
		sort(ba,ba+n);
		f(i,1,n)
			ba[i].second+=ba[i-1].second;
		int possible=1;
		f(i,0,n)
			if(ba[i].second>ba[i].first)
			{
				possible=0;
				break;
			}
		if(possible)
			out << "Yes\n";
		else
			out << "No\n";

	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	DMegalomania solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<long long> Dam(N + 1);
	long long sum = 0;
	for (int i = 1; i <= N; i++) {
		cin >> Dam[i];
		sum += Dam[i];
	}
	long long buf = 0;
	for (int j = 2; j != 1; j += 2) {
		j %= N;
		if (j == 0) j = N;
		if (j == 1) break;
		buf += Dam[j];
	}

	for (int i = 1; i <= N; i++) {
		long long ans = sum;
		if (i > 1) buf = sum - buf - Dam[i-1];
		cout << ans - buf * 2 << " ";
	}
	cout << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=105;
int a[2][maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<2;i++)
    {
        for(int j=0;j<n;j++) cin>>a[i][j];
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int cur=0;
        for(int j=0;j<=i;j++) cur+=a[0][j];
        for(int j=i;j<n;j++) cur+=a[1][j];
        ans=max(ans,cur);
    }
    print(ans);
}

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

#define rep(i,i0,n) for (int (i) = (i0); (i) < (n); ++(i))
#define to_pair(x, y) (((x) << 10) | (y))

#define N_MAX 1024

using namespace std;

int d[N_MAX * N_MAX];
int ind[N_MAX * N_MAX];
int visited[N_MAX];

vector< vector<int> > e, re;


void dfs(int u, int r) {
    visited[u] = 1;
    d[to_pair(u, r)] = 1;
    for (int w : e[u]) {
        if (!visited[w]) {
            dfs(w, r);
        }
    }
}

void solve(int n, int m, vector<int>& edges) {

    fill(d, d + N_MAX, 0);
    fill(ind, ind + N_MAX, 0);

    for (int i = 1; i <= n; ++i) {
        fill(visited, visited + N_MAX, 0);
        dfs(i, i);
    }
    for (int i = 1; i <= n; ++i) {
        fill(visited, visited + N_MAX, 0);
        visited[i] = 1;
        for (auto pj = e[i].begin(); pj != e[i].end(); ++pj) {
            if (visited[*pj]) {
                ind[to_pair(i, *pj)] = 1;
            } else {
                dfs(*pj, i);
            }
        }
        fill(visited, visited + N_MAX, 0);
        visited[i] = 1;
        for (auto pj = e[i].rbegin(); pj != e[i].rend(); ++pj) {
            if (visited[*pj]) {
                ind[to_pair(i, *pj)] = 1;
            } else {
                dfs(*pj, i);
            }
        }
    }

    for (int x : edges) {
        cout << ((d[x] ^ ind[x]) ? "diff" : "same") << endl;
    }
}

int main(int argc, const char * argv[]) {

    int n, m;
    int a, b;
    vector<int> edges;
    
    cin >> n >> m;
    e.resize(n + 1);
    re.resize(n + 1);
    rep(i, 0, m) {
        cin >> a >> b;
        edges.push_back(to_pair(a, b));
        e[a].push_back(b);
        re[b].push_back(a);
    }

    solve(n, m, edges);

    return 0;
}


Measured memory_bytes: 13172