akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct LOC{
	void set(int arg_to_row,int arg_to_col){
		to_row = arg_to_row;
		to_col = arg_to_col;
	}
	int to_row,to_col;
};

struct Info{
	int row,col;
};

int H,W,N;
int limit = 18;
int POW[19],work[501][501];
LOC table[19][501][501];
Info first_loc[250005],calc_loc[250005];

bool check(int num){

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++)work[row][col] = 0;
	}

	for(int i = 0; i < N; i++){
		calc_loc[i] = first_loc[i];
	}

	int now_row,now_col;

	for(int i = limit; i >= 0; i--){
		if(num < POW[i])continue;
		num -= POW[i];

		for(int k = 0; k < N; k++){
			now_row = calc_loc[k].row;
			now_col = calc_loc[k].col;
			calc_loc[k].row = table[i][now_row][now_col].to_row;
			calc_loc[k].col = table[i][now_row][now_col].to_col;
		}
	}

	for(int i = 0; i < N; i++){
		work[calc_loc[i].row][calc_loc[i].col]++;
		if(work[calc_loc[i].row][calc_loc[i].col] == 2){
			return true;
		}
	}

	return false;
}


int main(){

	for(int i = 0; i <= limit; i++)POW[i] = pow(2,i);

	scanf("%d %d %d",&H,&W,&N);

	int to_row,to_col;

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			scanf("%d %d",&to_row,&to_col);
			table[0][row][col].set(to_row,to_col);
		}
	}

	for(int i = 0; i < N; i++){
		scanf("%d %d",&first_loc[i].row,&first_loc[i].col);
	}

	for(int i = 1; i <= limit; i++){
		for(int row = 0; row < H; row++){
			for(int col = 0; col < W; col++){

				to_row = table[i-1][row][col].to_row;
				to_col = table[i-1][row][col].to_col;

				table[i][row][col].to_row = table[i-1][to_row][to_col].to_row;
				table[i][row][col].to_col = table[i-1][to_row][to_col].to_col;
			}
		}
	}

	int left = 1,right = H*W,m = (left+right)/2;
	int ans = BIG_NUM;

	while(left <= right){
		if(check(m)){
			ans = m;
			right = m-1;
		}else{
			left = m+1;
		}
		m = (left+right)/2;
	}

	if(ans == BIG_NUM){
		printf("-1\n");
	}else{
		printf("%d\n",ans);
	}

	return 0;
}



Measured memory_bytes: 45520
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((c-b)==(b-a)?"YES":"NO") << endl;
    return 0;
}



Measured memory_bytes: 4992
a, b, c = map(int,input().split())
if a > b :
    a = a + b
    b = a - b
    a = a - b
if b >  c :
    b = b + c
    c = b - c
    b = b - c
if  a > b :
    a = a + b
    b = a - b
    a = a - b

print(a,b,c)


Measured memory_bytes: 5596
#include <stdio.h>
#define N 1000

int main(void)
{
	int i , n;
	scanf("%d",&n);
	double a[n];
	
	for(i = 0; i < n; i++)
	{
		scanf("%lf",&a[i]);
	}
	double b[n+1];
	for(i = 0; i <= n; i++)
	{
		scanf("%lf",&b[i]);
	}
	double c[n+1][n+1];
	double d[n+1];
	c[0][0]=b[0];
	d[0]=a[0]+b[0];
	
	for(i = 1; i <= n; i++)
	{
		c[i][i] = b[i];
		c[i-1][i] = a[i-1]+(b[i-1]+b[i])*2;
		d[i] = d[i-1]+a[i]+b[i];
	}
	int j , k;
	double s , t;
	for(i = 1;i < n; i++)
	{
		for(j = 0; j < n-i; j++)
		{
			s = c[j][j] + c[j+1][i+j+1];
			for(k = j; k <i+j; k++)
			{
				t = c[j][k+1]+c[k+2][i+j+1];
				if(s>t) s = t;
			}
			c[j][i+j+1] = s + d[i+j] - d[j-1] + b[i+j+1];
		}
	}
	printf("%lf\n",c[0][n]);
	return 0;
}



Measured memory_bytes: 3824
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

N = int(input())
f = factorization(N)
count = 0
for a, b in f:
    c = 0
    for i in range(1, b+1):
        c += i
        if c > b:
            break
        else:
            count += 1
if N == 1:
    print(0)
else:
    print(count)

Measured memory_bytes: 9488
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    char c;
    cin >> c;
    c++;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3596
# 入力
n, k = map(int, input().split())
A = list(map(int, input().split()))

# 最大値をx以下にできるか
def check(x):
    cnt = 0
    for a in A:
        cnt += (a - 1) // x
    return cnt <= k

# めぐる式二分探索
ok = 10 ** 10
ng = 0
while ok - ng > 1:
    mid = (ok + ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

# 出力
print(ok)


Measured memory_bytes: 30928
import sys
sys.setrecursionlimit(10 ** 6)
N = int(input())
uvw = [list(map(int, input().split())) for i in range(N - 1)]
R = [-1] * N
Q = [[] for i in range(N)]
for i in range(N - 1):
    Q[uvw[i][0] - 1].append([uvw[i][1], uvw[i][2]])
    Q[uvw[i][1] - 1].append([uvw[i][0], uvw[i][2]])

def func(i, s, d, l):
    
    if R[i] != -1:
        return

    if R[i] == -1:
        if l %2 == 0:
            R[i] = s
        else:
            R[i] = d
            tmp = s
            s = d
            d = tmp
    for j in range(len(Q[i])):
        func(Q[i][j][0] - 1, s, d, Q[i][j][1])

func(uvw[0][0] - 1, 0, 1, 0)
for i in range(len(R)):
    print(R[i])

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

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

  int Ans = 0;

  for (int i=1; ; i++) {
    if (i*i > N) {
      Ans = (i-1) * (i-1);
      break;
    }
  }
  cout << Ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.IllegalArgumentException
import java.lang.StringBuilder
import java.lang.reflect.Modifier
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = arrayOf(11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381)
    println(a.take(n).joinToString(" "))
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 39888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = min(n, b - 1);
    cout << a * x / b - a * (x / b) << endl;
}

Measured memory_bytes: 3628
#include <vector>
#include <algorithm>
#include <limits.h>
#include <iostream>
#include <set>
#include <cmath>
#include <queue>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#define MOD 1000000007
typedef  long long int  lli;
using namespace std;
int main() {
    int t; t=1;
    while(t--) {
      long long int n; cin>>n; long long int a[n];
      for(int i=0;i<n;i++)
      {
          cin>>a[i];
      }
     /* if(n==2)
      {
          if(a[0]<a[1]){cout<<-1<<"\n";
              continue;}
          else if(a[0]==a[1]){cout<<0<<"\n";
              continue;}
          else if(a[0]>a[1])
          {
              if(((a[0]-a[1])%2)!=0) {cout<<-1<<"\n"; continue;}
              long long int x=(a[0]-a[1])/2;

              cout<<x<<"\n";
              continue;
          }
      }*/
      long long int X=0;
      for(int i=2;i<n;i++)
      {
          X^=a[i];
      }
      long long int S=a[0]+a[1];
      if((S-X)%2!=0) {cout<<-1<<"\n";
        continue;}

      long long int D=(S-X)/2;
      if(D < 0) {cout<<-1<<"\n";
        continue;}
      if((D&X) != 0){cout<<-1<<"\n";
          continue;}
      if(D>a[0]){cout<<-1<<"\n";
          continue;}
      long long int a_val=D; long long int y=0;
      for(int i=60;i>=0;i--)
      {
          if((X>>i)&1)
          {
              long long int z = y+(1ll<<i);
              if(z+a_val<=a[0])
              {
                  y=z;
              }
          }
      }
      if(y+a_val == 0) cout<<-1<<"\n";
      else cout<<a[0]-(y+a_val)<<"\n";






        }
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

/*  選択ソート(0オリジン) */
int selectionSort(int A[], int N) {
    int i, j, t, sw = 0, minj;
    for(i = 0;i < N - 1; i++) {
        minj = i;
        for(j = i;j < N; j++) {
            if(A[j] < A[minj]) minj = j;
        }
        t = A[i];
        A[i] = A[minj];
        A[minj] = t;
        if(i != minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

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

    sw = selectionSort(A, N);

    for(i = 0; i < N; i++) {
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);

    return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <algorithm>
#include <cmath>

int main()
{
  int n;
  int a[100000];
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", a + i);
  }
  std::sort(a, a + n);
  int max = a[n - 1];
  int med = (max + 1) / 2;
  std::sort(a, a + n - 1, [med](auto a, auto b){ return std::abs(a - med) < std::abs(b - med); });
  printf("%d %d\n", max, a[0]);
  return 0;
}
  

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
#define DBG(str...)       \
    for (auto v : str)    \
        cerr << v << " "; \
    cerr << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;

int main()
{
    LL n, k;
    cin >> n >> k;
    LL ans = 0;
    REPC(a, 1, n)
    {
        LL aa = a;

        LL arem = a % k;
        LL b = k - arem;
        LL c = k - arem;
        if ((b + c) % k == 0)
        {
            LL num = (n - b ) / k+1;
            ans += num * num;
            DBG({ans, aa, b, c, num});
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, M = [int(x) for x in input().strip().split(" ")]

def dfs(v):
    pvs = set([v])
    path = [v]
    def _dfs(v, path):
        for u in d[v]:
            if u in pvs:
                for i, c in enumerate(path):
                    if c == u:
                        break
                return path[i+1:]  + [u]
            if u in vs:
                continue
            pvs.add(u)
            vs.add(u)
            loop = _dfs(u, path + [u])
            pvs.remove(u)
            if loop:
                return loop
        return False
    return _dfs(v, path)

def dfs_w(v):
    # dfs while版 
    pvs = set([])
    nvs = [v]
    path = []
    while True:
        if len(nvs) == 0:
            break
        v = nvs.pop()
        if v < 0:
            pvs.remove(path[-1])
            path.pop()
        else:
            path.append(v)
            pvs.add(v)
            vs.add(v)
            for u in d[v]:
                if u in pvs:
                    for i, c in enumerate(path):
                        if c == u:
                            break
                    return path[i+1:]  + [u]
                if u in vs:
                    continue
                nvs += [-v, u]
    return False

d = [set() for _ in range(N+1)]
for _ in range(M):
    a, b = [int(x) for x in input().strip().split(" ")]
    d[a].add(b)

vs = set()
for i in range(N):
    i += 1
    if i in vs:
        continue
    vs.add(i)
    loop = dfs_w(i)
#    print(i, loop)
    if loop:
        break

if not loop:
    print(-1)
    import sys
    sys.exit()

v2i = [-1 for _ in range(N+1)]
for i, v in enumerate(loop):
    v2i[v] = i

nloop, pvs = [], set()
v = loop[0]
f = False
while True:
    nloop.append(v)
    pvs.add(v)
    max_i = max_i_l = -1
    for u in d[v]:
        if v2i[u] == -1:
            continue
        if v2i[v] > v2i[u] and u in pvs:
            f = True
            max_i_l = max(max_i_l, v2i[u])
        if v2i[u] > v2i[v]:
            max_i = max(max_i, v2i[u])
    if f:
        if max_i_l < 0:
            1/0
        nloop.append(loop[max_i_l])
        break
    if max_i < 0:
        1/0
    v = loop[max_i]

for i, x in enumerate(nloop):
    if x == nloop[-1]:
        break
nloop = nloop[i+1:]
print(len(nloop))
for v in nloop:
    print(v)


Measured memory_bytes: 43756
//0057

//0{Å1,1{Å2A2{Å4A3{Å7EEE
//·Èí¿A1+sum{1=>n}(n);?
//Æè ¦¸A1`nÌñÌaÍn(n+1)/2¾
#include<stdio.h>
int main(void)
{
	int n;
	while(scanf("%d", &n) == 1)
	{
		printf("%d\n", 1+ n*(n+1)/2);
	}
	return 0;
}

Measured memory_bytes: 0
from math import ceil
n,k = map(int,input().split())
remain = n
ans = 0
for i in range(100):
    x = ceil(k*0.5**i)
    if x <= n:
        ans += (remain-x+1)*0.5**i
        remain = x-1
    if remain == 0:
        break
print(ans/n)

Measured memory_bytes: 3060
#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>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	int i;

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

	int n;
	cin >> n;
	vector<int>v(2*n);
	REP(i,2*n) cin >> v[i];
	sort(v.begin(),v.end());
	int ans=0;
	for(i=0;i<2*n;i+=2){
		ans+=v[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> replicateM 5 (getl toInt) >>= print

solve :: [Int] -> Int
solve [a,b,c,d,p] = min (f p) (g p)
  where
    f x = x * a
    g x
      | x <= c = b
      | otherwise = b + (x - c) * d

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
    faster

    int n,d;
    cin>>n>>d;

    int x=d+d+1;

    int a=n/x;

    if(n%x!=0)
        a++;

    cout<<a<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vll = vector<ll>;
#define x first
#define y second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define szz(x) (int) (x).size()
#define FOR(i,a,b) for (int i = (a), _for = (b); i < _for; i++)
#define REP(i,n) FOR(i,0,(n))
#define _ << " " <<
const ll MOD = 1000000007ll;
const ll INF = 0x3f3f3f3f3f3f3f3f;
inline ll SUB(ll a, ll b) { return a-b >= 0ll ? a-b : a-b+MOD; }
inline ll ADD(ll a, ll b) { return a+b >= MOD ? a+b-MOD : a+b; }
inline ll MUL(ll a, ll b) { return a*b % MOD; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k; cin >> n >> k;
  
  vll a(n); REP(i,n) cin >> a[i];
  vll dp(n);
  dp[0] = 0;
  FOR(i,1,n) {
    dp[i] = INF;
    FOR(j, 1, min(k + 1, i + 1)) {
      dp[i] = min(dp[i], dp[i-j] + abs(a[i] - a[i-j]));
    }
  }
  cout << dp.back() << endl;
}



Measured memory_bytes: 1792
from collections import Counter
def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    ac = Counter(a)
    r = 0
    for ace in ac:
        if ac[ace] < ace:
            r += ac[ace]
        else:
            r += (ac[ace] - ace)
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 70312
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	int sum = 0;
	int m = 0;
	for(int i = 0;i < n;i++){
		int t;
		cin >> t;
		sum += t;
		m = max(m,t);
	}
	
	sum -= m;
	if(m >= sum){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import copy
N=int(input())

s=[0]*N

for i in range (N) :
    s[i]=sorted(list(input()))

t=copy.deepcopy(s)
flag=0
ans=[]
i=0
while(len(s[0])>i) :
    for j in range (1,N) :
        if(s[0][i] in s[j]):
            s[j].remove(s[0][i])
        else:
            s=copy.deepcopy(t)
            flag=1
            break
    if(flag==0):
        ans.append(s[0][i])
        s[0].remove(s[0][i])
        i=-1
    t=copy.deepcopy(s)
    flag=0
    i+=1

sorted(ans)
print("".join(ans))

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 998244353;
const int INF = 1e12;
using Graph = vector<vector<int>>;

int dp[4000][4000];

signed main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  dp[A][B] = 1;
  for( int h = A; h <= C; h++ ){
    for( int w = B; w <= D; w++ ){
      dp[h][w] += dp[h-1][w]*w;
      dp[h][w] %= MOD;
      dp[h][w] += dp[h][w-1]*h;
      dp[h][w] %= MOD;
      //重複分を引く
      int hiku = (dp[h-1][w-1]*(h-1)%MOD)*(w-1);
      hiku %= MOD;
      dp[h][w] -= hiku;
      while( dp[h][w] < 0 ) dp[h][w] += MOD;
    }
  }

  cout << dp[C][D] << endl;

}


Measured memory_bytes: 86060
package main

import "fmt"

func main() {
	var N uint
	var M int
	fmt.Scan(&N, &M)
	var nm [10][10]bool
	for i := 0; i < M; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		a--
		b--
		nm[a][b] = true
		nm[b][a] = true
	}
	var full uint
	full = 1<<N - 1
	// fmt.Printf("%b\n", full)
	var ans int
	var dfs func(uint, uint)
	dfs = func(used uint, from uint) {
		// fmt.Printf("%b, %b \n", used, full)
		if used == full {
			ans++
			return
		}
		for i := uint(0); i < N; i++ {
			if nm[from][i] {
				// fmt.Printf("%b, %b, %b, %t\n", used, 1<<i, used&1<<i, !((used & (1 << i)) > 0))
				if !((used & (1 << i)) > 0) {
					// used になってないはず
					// fmt.Printf("%b, %d,%d\n", used, i+1, from+1)
					n := used | (1 << i)
					dfs(n, i)
				}
			}
		}
	}
	dfs(1, 0)
	fmt.Println(ans)
}


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

int main() {
  int n;
  cin >> n;
  
  if(n%2==0){
    double a =1;
    cout << a/2 << endl;
  }
  else{
    (double)n;
    cout << (n+1)*0.500000/n << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1);I >= (A); --I)
const ll INF=1e18+3;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll sz=(1<<n);
	vector<ll> a(sz);
	FOR(i,0,sz)cin>>a[i];
	vector<P> b(sz);
	FOR(i,0,sz){
		b[i].first = a[i];
		b[i].second = 0LL;
	}
	ll k=1LL;
	FOR(i,0,n+1){
		FORR(j,0,sz){
			ll x = j|k;
			if( x >= (1<<n) )continue;
			if( x==j )continue;
			vector<ll> w;
			w.push_back(b[x].first);
			w.push_back(b[x].second);
			w.push_back(b[j].first);
			w.push_back(b[j].second);
			sort(w.begin(),w.end());
			b[x].first  = w[3];
			b[x].second = w[2];
		}
		k *= 2LL;
	}
	ll ans = b[1].first+b[1].second;
	FOR(i,1,1<<n){
		ans = max(ans,b[i].first+b[i].second);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;

  ll N;
  cin >> N;
  ll a[MAX*2];
  
  map<ll, ll> mp;
  for(i=1; i<=N; i++) {
    cin >> a[i];
    mp[a[i]+i]++;
  }
  
  ll ans=0;
  for(i=1; i<=N; i++) {
    ans+=mp[i-a[i]];
  }
  
  pt(ans);
  
  
}
 


Measured memory_bytes: 27740
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    string o = "keyence", s;
    cin>>s;
    bool flag;

    int l = s.size();
    REP(i,l) {
        FOR(j,i,l) {
            //bool t = strcmp(o, s.substr(0,i) + s.substr(j,l-j));
            if (o == s.substr(0,i) + s.substr(j,l-j)) {
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;
    return 0;

    return 0;
}


Measured memory_bytes: 256
# even faster by using a comprehensive list at the end

from collections import deque
import sys
si = sys.stdin.readline


def BFS(g, n, s):
    d = 0
    dt = [0 for _ in range(n+1)]
    dt[s] = 0
    visited = set()
    visited.add(s)
    Q = deque([s])

    while len(Q):
        d += 1
        Qs = len(Q)
        for _ in range(Qs):
            Qpop = Q.popleft()
            for node in g[Qpop]:
                if node not in visited:
                    Q.append(node)
                    visited.add(node)
                    dt[node] = d
    return dt[1:]


def main():
    l = [int(e) for e in si().split()]
    n, u, v = l[0], l[1], l[2]
    graph = [[] for _ in range(n+1)]
    for _ in range(n-1):
        l = [int(e) for e in si().split()]
        graph[l[0]].append(l[1])
        graph[l[1]].append(l[0])

    udt = BFS(graph, n, u)
    vdt = BFS(graph, n, v)
    print(-1+max([v for u, v in zip(udt, vdt) if u < v]))


if __name__ == '__main__':
    main()


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

int a, b, c, d;
typedef long long ll;

int main(){
    scanf("%d%d%d%d", &a, &b, &c, &d);
    ll tmp = max((ll) a * c, (ll) b * d);
    if (tmp < 0){
        tmp = max(tmp, - (ll) min(abs(a), abs(b)) * min(abs(c), abs(d)));
    }
    cout<<tmp;
}


Measured memory_bytes: 3764
/**
 *    author:  morato
 *    created: 13.09.2020 09:05:20
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;

int64_t MOD = 1e9 + 7;
int64_t fact[N];

int64_t mod(int64_t a, int64_t b = MOD) {
  a %= b;
  if (a < 0) 
    a += b;
  return a;
}

int64_t expo(int64_t b, int e) {
  if (!e) return 1;
  int64_t u = expo(b, e / 2);
  u = mod(u * u);
  if (e & 1) u = mod(u * b);
  return u;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int64_t tira = mod(mod(expo(9, n) + expo(9, n)) - expo(8, n));
  cout << mod(expo(10, n) - tira, MOD) << '\n';
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;

int main() {
    int64 n,m,v,p;
    cin >> n >> m >> v >> p;
    vector<int64> a(n);
    for (int64 i=0; i<n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());

    int64 l=0, r=n;
    while(l+1 < r) {
        int64 g = (l+r)/2;
        bool f = true;
        vector<bool> full(n);

        int64 balance = m*v;

        int64 tmp = p - 1;
        for (int i=0; i<n; i++) {
            if (full[i]) continue;
            if (tmp <= 0) break;
            tmp--; full[i] = true;
        }

        for (int64 i=0; i<n; i++) {
            if (full[i]) balance -= m;
            else {
                int64 x = a[g] + m - a[i];
                if (x < 0) {
                    f = false;
                    break;
                }
                balance -= min(x, m);
            }
        }

        if (balance > 0) f = false;
        (f ? l : r) = g;
    }

    cout << l + 1 << endl;
}

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

char a[1005][1005];
int dist[1005][1005];

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

int main(){
	int h,w;
	cin >> h >> w;
	rep(i,h) rep(j,w) cin >> a[i][j];
	queue<pair<int,int>> que;
	rep(i,h) rep(j,w) {
		dist[i][j] = -1;
		if(a[i][j] == '#'){
			que.push(make_pair(i,j));
			dist[i][j] = 0;
		}
	}
	while(!que.empty()){
		auto p = que.front(); que.pop();
		rep(i,4){
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if(ny < 0 || ny >= h || nx < 0 || nx >= w || dist[ny][nx] != -1) continue;
			if(a[ny][nx] == '.'){
				que.push(make_pair(ny, nx));
				dist[ny][nx] = dist[p.first][p.second] + 1;
			}
		}
	}
	int ans = 0;
	rep(i,h)rep(j,w) ans = max(ans, dist[i][j]);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 16184
n = int(input())
x = [int(i) for i in input().split()]

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


if n==1:
    print(x[0])
else:
    element = gcd(x[0], x[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,x[i])
        print(element)

Measured memory_bytes: 14224
#define inr register int
#define ll long long
#define itn int
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
ll read(){
	char a=getchar();ll c=0,b=1;
	while(a<'0'||a>'9'){if(a=='-')b=-1;a=getchar();}
	while(a>='0'&&a<='9')c=c*10+a-48,a=getchar();
	return c*b;
}
int main(){
	int n=read(),c=0;
	for(int i=1;i<=n;++i){
		for(itn j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				c+=__gcd(__gcd(i,j),k);
			}
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 3592
fun main(arr: Array<String>) {
    val weekday = listOf("SUN","MON","TUE","WED","THU","FRI","SAT").let { it+it }
    val s = readLine()!!
    var ans = weekday.drop(weekday.indexOf(s) + 1).indexOf("SUN") + 1
    println(ans)
}


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

inline unsigned int xor128(){
	static uint x=123456789;
	static uint y=333333333;
	static uint z=555555555;
	static uint w=88888888;
	unsigned int t;
	t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct node{
	node*l,*r;
	int cnt,val,Min;
};
node pool[400000];
int p;

inline int cnt(node*t){return t?t->cnt:0;}
inline int Min(node*t){return t?t->Min:INF;}

inline node*update(node*t){
	t->cnt=cnt(t->l)+cnt(t->r)+1;
	t->Min=min({t->val,Min(t->l),Min(t->r)});
	return t;
}
inline node*merge(node*l,node*r){
	if(!l)return r;
	if(!r)return l;
	if(xor128()%(cnt(l)+cnt(r))<(unsigned int)cnt(l)){
		l->r=merge(l->r,r);
		return update(l);
	}
	else{
		r->l=merge(l,r->l);
		return update(r);
	}
}
inline pair<node*,node*>split(node*t,int k){
	if(!t)return make_pair((node*)NULL,(node*)NULL);
	if(k<=cnt(t->l)){
		auto p=split(t->l,k);
		t->l=p.second;
		return make_pair(p.first,update(t));
	}
	else{
		auto p=split(t->r,k-cnt(t->l)-1);
		t->r=p.first;
		return make_pair(update(t),p.second);
	}
}

int main(){
	int n,q;scanf("%d%d",&n,&q);
	node*root=NULL;
	rep(i,n){
		int a;scanf("%d",&a);
		node*t=&pool[p++];
		*t={NULL,NULL,1,a,a};
		root=merge(root,t);
	}
	rep(i,q){
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		if(x==0){
			z++;
			auto a=split(root,y);
			auto b=split(a.second,z-y-1);
			auto c=split(b.second,1);
			root=merge(merge(merge(a.first,c.first),b.first),c.second);
		}
		else if(x==1){
			z++;
			auto a=split(root,y);
			auto b=split(a.second,z-y);
			printf("%d\n",Min(b.first));
			root=merge(merge(a.first,b.first),b.second);
		}
		else{
			auto a=split(root,y);
			auto b=split(a.second,1);
			b.first->val=z;
			update(b.first);
			root=merge(merge(a.first,b.first),b.second);
		}
	}
}


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

int main(){
    int arr[3];
    
     for (int i = 0; i < 3; i++) {
         /* code */
         std::cin >> arr[i];
     }
     
     sort(arr,arr+3);
     
     cout<<arr[0]+arr[1]<<endl;
     
     return 0;
}   

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		String a = strArr[0];
		String b = strArr[1];
		if (a.equals(b))
			System.out.println("H");
		else
			System.out.println("D");

		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int c[60];
	int d=0;
	for(int i=0;i<a;i++){
		cin>>c[i];
	}
	sort(c,c+a);
	reverse(c,c+a);
	for(int i=0;i<b;i++){
		d+=c[i];
	}
	cout<<d<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
  int n, ans = 0;
  string s, right, left;
  cin >> n >> s;
  
  for(int i = 1; i < n; i++){
    set<char> se;
    right = s.substr(0, i);
    left  = s.substr(i, s.size());

    // cout << right << " " << left << endl;
    
    if(right.size() > left.size())swap(right, left);
    
    for(int j = 0; j < right.size(); j++){
      if(left.find(right[j]) != std::string::npos){
        se.insert(right[j]);
      }
    }
    ans = max(ans, (int)se.size());
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

vector<int> v[100001];
vector<int> result;
int visited[100001];
int ans[100001];
void tsort(int x){
  if(visited[x]) return;
  visited[x] = 1;
  for(auto y: v[x]){
    tsort(y);
  }
  result.push_back(x);
}

int main(){
  int N, M;
  cin >> N >> M;
  rep(i, N + M - 1){
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  rep(i, N) tsort(i + 1);
  reverse(result.begin(), result.end());
  rep(i, N){
    for(auto x: v[result[i]]){
      ans[x] = result[i];
    }
  }
  rep(i, N) cout << ans[i + 1] << endl;
  return 0;
}


Measured memory_bytes: 10740
n,c,k=map(int,input().split())
ans=0
cnt=1
t=sorted([int(input())for s in range(n)])
while t:
    now=t.pop()
    ans+=1
    while t and cnt<c and t[-1]+k>=now:
        cnt+=1
        t.pop()
    cnt=1

print(ans)

Measured memory_bytes: 8280
#include <stdio.h>

int main(void){

	int i,j,H,W;
	H = 1;
	W = 1;

	while(H!=0 || W!=0){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
		printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
def main():
    import sys
    H,W=list(map(int,sys.stdin.readline().split()))
    MAP=[]
    for i in range(H):
        MAP.append([0 if x=="#" else 1 for x in sys.stdin.readline()][:-1])
    #1:道　0:ブロック

    dp=[[1]*W for _ in range(H)]

    for x in range(1,W):
        if MAP[0][x]:
            dp[0][x]=dp[0][x-1]
        else:
            dp[0][x]=-1


    for y in range(1,H):
        if MAP[y][0]:
            dp[y][0]=dp[y-1][0]
        else:
            dp[y][0]=-1

    for y in range(1,H):
        for x in range(1,W):
            if MAP[y][x]==0:
                dp[y][x]=-1
            else:
                o=0
                if dp[y][x-1]+1:
                    o+=dp[y][x-1]
                if dp[y-1][x]+1:
                    o+=dp[y-1][x]
                if not (dp[y-1][x]+1 or dp[y][x-1]+1):
                    o=-1
                else:
                    o%=10**9+7

                dp[y][x]=o

    if dp[H-1][W-1]==-1:
        dp[H-1][W-1]+=1
    print(dp[H-1][W-1])

main()

Measured memory_bytes: 58716
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  if (N % 2 == 1) {
    cout << "No" << endl;
    return 0;
  } else {
    for (int i = 0; i < N / 2; ++i) {
      if (S[i] != S[N / 2 + i]) {
	cout << "No" << endl;
	return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
  }
      
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;


int dp[105][66666], sl[66666], sr[66666];
int main()
{
    ios::sync_with_stdio(false); cin.tie(false);
    int n, k;
    cin >> n >> k;

    int cnt = 0, l = 1, r = 1;
    while (l <= n){
        r = n / (n / l);
        sl[++cnt] = l;
        sr[cnt] = r;
        l = r + 1;
    }

    for (int i = 1; i <= cnt; ++i) dp[1][i] = sr[i];
    for (int i = 2; i <= k; ++i){
        for (int j = 1; j <= cnt; ++j){
            
            dp[i][j] = ((ll)dp[i - 1][cnt - j + 1] * (sr[j] - sl[j] + 1) + dp[i][j - 1]) % mod;
        }
    }

    cout << dp[k][cnt] << endl;
    return 0;
}


Measured memory_bytes: 26752
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

const maxA = 1000001

func main() {
	n := scanInt()
	as := scanInts(n)

	c := make([]int, maxA)
	for _, a := range as {
		c[a]++
	}
	isPairwise := true
	for i := 2; i < maxA; i++ {
		cnt := 0
		for j := i; j < maxA; j += i {
			cnt += c[j]
			if cnt > 1 {
				isPairwise = false
				break
			}
		}
	}
	if isPairwise {
		fmt.Println("pairwise coprime")
		return
	}

	b := as[0]
	for i := 1; i < n; i++ {
		b = gcd(b, as[i])
	}
	if b == 1 {
		fmt.Println("setwise coprime")
	} else {
		fmt.Println("not coprime")
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


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

int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    char d[k];
    for(int i = 0; i < k; i++){
        cin >> d[i];
    }

    int che[10];
    for(int i = 0; i < 10; i++){
        che[i] = 0;
    }

    for(int i = 0; i < k; i++){
        che[d[i] - '0'] = 1;
    }

    vector<int> used;
    for(int i = 0; i < 10; i++){
        if(che[i] == 0){
            used.push_back(i);
        }
    }

    string s = to_string(n);
    int len = s.length();

    int now[len];
    for(int i = 0; i < len; i++){
        now[i] = s[i] - '0';
    }

    int flag = 0;
    while(1){
        if(flag == 1){
            break;
        }
        flag = 0;
        s = to_string(n);
        len = s.length();
        for(int i = 0; i < len; i++){
            now[i] = s[i] - '0';
        }

        for(int i = 0; i < len; i++){
            if(che[now[i]] == 1){
                flag = 2;
                break;
            }
        }

        if(flag == 2){
            n++;
        }else{
            flag = 1;
        }
    }

    cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main(){
	fio; cout<<fixed<<setprecision(25);	
	
	string s; cin >> s;
	int score = 0;
	int cnt = 0;
	for(auto c : s){
		if(c == 'g'){
			if(cnt > 0){
				++score;
				--cnt;
			}
			else{
				++cnt;
			}
		}
		else{
			if(cnt > 0){
				--cnt;
			}
			else{
				--score;
				++cnt;
			}
		}
		// trace(score , cnt);
	}	
	cout << score << endl;







	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main() {
	int in1, in2;
	int ans1, ans2;
	double ans3;
	scanf("%d %d", &in1, &in2);

	ans2 = in1 % in2;
	ans1 = (in1 - ans2) / in2;
	ans3 = (double)in1 / (double)in2;

	printf("%d %d %lf", ans1, ans2, ans3);

	return 0;
}


Measured memory_bytes: 2732
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

count = [0 for i in range(int(1e5+1))]

total = 0
for a in A:
    count[a] += 1
    total += a

for _ in range(Q):
    b, c = map(int, input().split())
    total = total - b*count[b] + c*count[b]
    count[c] += count[b]
    count[b] = 0
    print(total)


Measured memory_bytes: 90828
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

int main()
{
	vector<ll> v;

	rep(i,1,10)
	v.pb(i);

	int ind=0;

	while(v.size()<100000)
	{
		ll last_digit=v[ind]%10;

		ll num=v[ind]*10+last_digit;

		if(last_digit!=0)
		v.pb(num-1);

		v.pb(num);

		if(last_digit!=9)
		v.pb(num+1);

		ind++;
	}

	int n;

	scn(n);

	lpri(v[n-1]);

    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
const int N=1<<18;

int n,a[N],mx[N],mx2[N],sum[N];

int main() {
	scanf("%d",&n);
	for(int i=0;i<(1<<n);i++) {
		scanf("%d",&a[i]);
	}
	for(int s=0;s<(1<<n);s++) {
		if(a[s]>a[mx[s]]) mx[s]=s;
		for(int i=0;i<n;i++) {
			if((s>>i)&1) continue;
			int s2=s|(1<<i);
			if(a[mx[s]]>a[mx[s2]]) {
				mx[s2]=mx[s];
			}
		}
	}

	memset(mx2,-1,sizeof(mx2));
	for(int s=0;s<(1<<n);s++) {
		if(mx[s]!=s && (mx2[s]==-1 || a[s]>a[mx2[s]])) mx2[s]=s;
		for(int i=0;i<n;i++) {
			if((s>>i)&1) continue;
			int s2=s|(1<<i);
			if(mx[s2]!=mx[s] && (mx2[s2]==-1 || a[mx[s]]>a[mx2[s2]])) mx2[s2]=mx[s];
			if(mx2[s]!=-1 && mx[s2]!=mx2[s] && (mx2[s2]==-1 || a[mx2[s]]>a[mx2[s2]])) mx2[s2]=mx2[s];
		}
	}

	for(int s=1;s<(1<<n);s++) {
		//printf("s=%d mx=%d mx2=%d\n",s,mx[s],mx2[s]);
		sum[s]=a[mx[s]]+a[mx2[s]];
		sum[s]=max(sum[s],sum[s-1]);
		printf("%d\n",sum[s]);
	}
}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int k[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << k[K-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool flag = true;
    if(s[a] == '-') {
        rep(i, s.size()) {
            if(i != a and s[i] == '-') flag = false;
        }
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        cout << "No" << endl;
    }
 }



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

struct Box {
	int count = 1;
	bool red = false;
};
Box b[100010];
int main()
{
	int N, M;
	int x, y;
	cin >> N >> M;
	b[0].red = true;
	for (int i = 0; i < M; i++) {
		cin >> x >> y;
		x--; y--;
		if (b[x].red) {
			b[y].red = true;
		}
		if (b[x].count == 1 && b[x].red) {
			b[x].red = false;
		}
		b[x].count--; b[y].count++;
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (b[i].red) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
/*input
2
1 -1
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	string s;
	cin >> s;
	int cur = 0, mx = 0;
	rep(i, s.size()) {
		if(s[i]=='R') cur++;
		else cur=0;
		mx=max(mx, cur);
	}
	cout << mx;
	return 0;
}

Measured memory_bytes: 3644
// ABC152B - Comparing Strings

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

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

	if (a < b) {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
		cout << endl;
	} else {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256