akhauriyash/Code-Regression huggingface dataset:
def resolve():
    s = input()
    al = []
    for i in range(26):
        al.append(False)
    
    for c in s:
        ord_c = ord(c) - ord('a')
        al[ord_c] = True
    
    for i in range(26):
        if al[i] == False:
            print(chr(ord('a') + i))
            break
        if i == 25 and al[i] == True:
            print("None")
resolve()

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int d, t, s;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> d >> t >> s;
	if (s * t >= d) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

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

int main(){
    int N;
    string S;
    cin>>N>>S;
    for(int i=1;i<N-1;i++){
        if(S[i]==S[i-1]){
            S.erase(S.begin()+i-1);
            i--;
            N--;
        }
        if(S[i]==S[i+1]){
            S.erase(S.begin()+i+1);
            i--;
            N--;
        }
    }
    cout<<S.length()<<endl;
    return 0;
}

//a=97,z=122

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n;
	cin >> n;

	vector<int> a(n);
	for (auto& v : a) {
		cin >> v;
	}

	int r = 0;
	int nowSum = 0;
	int nowXor = 0;
	ll ans = 0;
	for (int l = 0; l < n; l++) {
		while (r < n && (nowSum + a[r]) == (nowXor ^ a[r])) {
			nowSum += a[r];
			nowXor ^= a[r];
			r++;
		}

		ans += r - l;
		nowSum -= a[l];
		nowXor ^= a[l];
	}

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


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

long long dp[101][100001] , w[101] , v[101];
int main()
{
    long long n , c , sum=0;
    cin >> n >> c;
    for(int i=1 ; i<=n ; i++)
    {
        cin >> w[i] >> v[i];
        sum+=v[i];
    }
    for(int i=0 ; i<=n ; i++)
        for(int j=0 ; j<=sum ; j++)
            dp[i][j] = c+1;
    dp[0][0] = 0;
    for(int i=1 ; i<=n ; i++)
        for(int j=0 ; j<=sum ; j++)
        {
            dp[i][j] = dp[i-1][j];
            if(j>=v[i])
                dp[i][j] = min(dp[i][j] , dp[i-1][j-v[i]] + w[i]);
        }
    for(int i=sum ; i>=0 ; i--)
        if(dp[n][i]<=c)
        {
            cout << i;
            return 0;
        }
    printf("0");
    return 0;
}

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

int main(){
  int m[10];
  for(int i=0;i<10;i++)cin>>m[i];
  sort (m,m+10);
  cout<<m[9]<<endl<<m[8]<<endl<<m[7]<<endl;
  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,x,y,sum,pos,k,w[ohara],v[ohara],W,dp[105][ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>W;
    rep(i,n)cin>>w[i]>>v[i];
    rep(i,W+1){
        if(w[0]<=i){
            dp[0][i]=v[0];
        }
    }
    rrep(i,1,n){
        rep(j,W+1){
            if(j>=w[i]){
            dp[i][j]=max({dp[i-1][j-w[i]]+v[i],dp[i-1][j],dp[i][j]});
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j]);
            }
        }
    }
    Cout(dp[n-1][W]);
    return 0;
}


Measured memory_bytes: 289792
<?php
list($n, $d) = explode(" ", trim(fgets(STDIN)));
$numbers = [];
$answer = 0;

for($i=0; $i<$n; $i++){
	$numbers [] = explode(" ", trim(fgets(STDIN)));
}

for($i=0; $i<$n; $i++){
	for($j=$n-1; $j>$i; $j--){
	$number=0;
		for($s=0; $s<$d; $s++){
			$number += pow($numbers[$i][$s]-$numbers[$j][$s], 2);
		}
		if(is_seisuu($number)){
			$answer+=1;
		}
	}
}

function is_seisuu($number){
	$heihoukon = (string) sqrt($number);
	return ctype_digit($heihoukon) ? true : false;
}

echo $answer;
echo "\n";

?>

Measured memory_bytes: 4728
# -*- coding:utf-8 -*-

"""考え方
[入力例１]
3
cbaa     # S[0]
daacc    # S[1]
acacac   # S[2]

・それぞれ文字の出現回数をカウントする
S_dic[0]["a"] = 2
S_dic[0]["b"] = 1
S_dic[0]["c"] = 1

S_dic[1]["a"] = 2
S_dic[1]["b"] = 0
S_dic[1]["c"] = 2
S_dic[1]["d"] = 1

S_dic[2]["a"] = 3
S_dic[2]["b"] = 0
S_dic[2]["c"] = 3

・全てののS[i]で共通して使える文字と、その文字数を算出する
"a" は 2個使える
"b" は 0個使える
"c" は 1個使える
"d" は 0個使える

・その算出した文字と文字数を使って、辞書順で最小の文字列を作成する。それが答え。
"aac"

"""

from collections import defaultdict

def solve():
    n = int(input())
    S_dic = [{} for i in range(n)]
    for i in range(n):
        for j in range(97, 123):
            # a~zを0に初期化
            S_dic[i][chr(j)] = 0

    for i in range(n):
        s = input()

        for moji in s:
            S_dic[i][moji] += 1
    
    usable = {}  # 使える文字と、その個数

    for j in range(97, 123):
        min_count = float("inf")
        for i in range(n):
            min_count = min(min_count, S_dic[i][chr(j)])
            if min_count == 0:
                break

        if min_count == 0:
            continue
        usable[chr(j)] = min_count

    usable_list = list(usable.items())

    usable_list.sort(key=lambda x: x[0])

    ans = ""
    for key, value in usable_list:
        ans += key * value
    
    print(ans)

    




if __name__ == "__main__":
    solve()


Measured memory_bytes: 3436
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

const LL mod = (LL)1e9 + 7;


int main() {
	
	int K, N;
	cin >> N >> K;
	VI D(K);
	REP(i, K) { cin >> D[i]; }
	


	while(true) {

		int N2 = N;
		//debug(N2);

		while (N2 > 0) {
			int a = N2 % 10;
			N2 /= 10;
			
			//debug(a);
			if (find(ALL(D), a) != D.end()) {
				goto NEXT;
			}

		}

		cout << N << endl;
		return 0;
	NEXT:;
		N++;
	}

}

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

const int N = 1000 * 100 + 10;
int a[N], b[N], n, par[N * 2], sz[N * 2];

int get_par(int root) {
	return par[root] == root? root: par[root] = get_par(par[root]);
}

void Union(int v, int u) {
	v = get_par(v), u = get_par(u);
	if (v == u)
		return;
	if (sz[u] > sz[v])
		swap(v, u);
	sz[v] += sz[u];
	par[u] = v;
}

int main() { 
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], a[n] ^= a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i], b[n] ^= b[i];
	map<int, int> cnt;
	for (int i = 0; i <= n; i++)
		cnt[a[i]]++;
	for (int i = 0; i < n; i++) {
		cnt[b[i]]--;
		if (cnt[b[i]] < 0)
			return cout << "-1\n", 0;
	}
	vector<int> vec;
	for (int i = 0; i < n; i++)
		if (a[i] != b[i])
			vec.push_back(a[i]), vec.push_back(b[i]), ans++;
	vec.push_back(a[n]), vec.push_back(b[n]);
	sort(vec.begin(), vec.end());
	vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
	int s = (int)(vec.size());
	for (int i = 0; i < s; i++)
		par[i] = i, sz[i] = 1;
	for (int i = 0; i <= n; i++) 
		if (a[i] != b[i]) {
			a[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin();
			b[i] = lower_bound(vec.begin(), vec.end(), b[i]) - vec.begin();
			Union(a[i], b[i]);
		}
	for (int i = 0; i < s; i++)
		if (get_par(i) == i)
			ans++;
	cout << ans - 1 << '\n';
	return 0;
}


Measured memory_bytes: 10348
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] v = new int[N];
            int M = 0;
            string[] s = Console.ReadLine().Split(' ');

            for (int i = 0; i < N; i++)
            {
                v[i] = int.Parse(s[i]);
                if (v[i] != 0)
                {
                    M = i + 1;
                }
            }

            int[] a = new int[M];

            for (int i = M - 1; i >= 0; i--)
            {
                int mulMax = M / (i + 1);

                int ans = 0;
                for (int j = mulMax; j > 1; j--)
                {
                    ans ^= a[(i + 1) * j - 1];
                }
                ans ^= v[i];
                a[i] = ans;
            }

            int c = 0;
            for (int i = 0; i < M; i++)
            {
                if (a[i] != 0)
                {
                    c++;
                }
            }

            Console.WriteLine(c);
            if (c != 0)
            {
                for (int i = 0; i < M; i++)
                {
                    if(a[i] != 0)
                    {
                        Console.Write("{0} ", i + 1);
                    }
                }

                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 27092
import numpy as np
import fractions
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.append(x)
a.sort()
d = np.diff(a)
if n>1:
    gcd = fractions.gcd(d[0],d[1])
    if n>3:
        for i in range(2,n-1):
            gcd = fractions.gcd(gcd,d[i])
    print(gcd)
else:
    print(d[0])

Measured memory_bytes: 24260
import numpy as np
a,b,h,m = map(int, input().split())

kaku_min = 6*m
kaku_hr = 30*h+0.5*m
delta = abs(kaku_min - kaku_hr)
kaku = min(360-delta, delta)
c = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(np.pi*kaku/180))
print(c)

Measured memory_bytes: 27228
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
#endif

int X;
cin>>X;
if(X >29)
cout<<"Yes\n";
else
cout<<"No\n";



return 0;
}

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

int main() {
  int n;
  cin >> n;
  int fal=1, all=1;
  rep(i,n) {
    int x;
    cin >> x;
    if(x%2==0) fal *= 2;
  }
  rep(i,n) all *= 3;
  cout << all-fal << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int n,k,match[605];
ll f[605][605],c[605];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		match[a]=b,match[b]=a;
	}
	c[0]=1;
	for(int i=1;i<=n;i++)c[i]=c[i-1]*(2*i-1)%MOD;
	for(int l=1;l<=2*n;l++)
	{
		int minn=2*n,maxx=0,num=0;
		for(int r=l;r<=2*n;r++)
		{
			if(match[r])minn=min(minn,match[r]),maxx=max(maxx,match[r]),num--;
			num++;
			if(minn>=l&&maxx<=r)f[l][r]=c[num>>1];
		}
	}
	ll ans=0;
	for(int i=1;i<=2*n;i++)
	{
		int num=0;
		for(int j=i+1;j<=2*n;j+=2)
		{
			if(match[j-1])num++;
			if(match[j])num++;
			for(int k=i+1;k<j;k+=2)
			  f[i][j]=(f[i][j]-f[i][k]*f[k+1][j])%MOD;
			ans=(ans+f[i][j]*c[n-(j-i+1)/2-k+num/2])%MOD;
		}
	}
	if(ans<0)ans+=MOD;
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

#define limit int(1e5 + 99)
int arr[ limit ], dp[ limit ];

int main() {
	int n;
	scanf("%i", &n);

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

	fill(dp, dp + limit, int(1e9 + 99));
	dp[ 0 ] = arr[ 0 ];

	for(int i = 0; i < n - 1; i++) {
		dp[ i + 1 ] = min(dp[ i + 1 ], dp[ i ] + abs(arr[ i ] - arr[ i + 1 ]));
		if(i + 2 < n) dp[ i + 2 ] = min(dp[ i + 2 ], dp[ i ] + abs(arr[ i ] - arr[ i + 2 ]));
	}

	printf("%i ", dp[ n - 1 ] - arr[ 0 ]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, d; cin >> n >> d;
  VV<> c; assign(c, d, d, 0);
  for (int i = 0; i < n; ++i) {
    int x, y; cin >> x >> y;
    ++c[x % d][y % d];
  }
  int c_max = 0;
  for (int i = 0; i < d; ++i) for (int j = 0; j < d; ++j) c_max = max(c_max, c[i][j]);
  int k = sqrt(c_max) + 10;
  while (k * k >= c_max) --k;
  VV<> a1, a2;
  assign(a1, d, d, 0), assign(a2, d, d, 0);
  for (int i = 0; i < d; ++i) for (int j = 0; j < d; ++j) {
    if (c[i][j] > k * (k + 1)) ++a1[i][j];
    if (c[i][j] > k * k) ++a2[i][j];
  }
  VV<> c1, c2;
  assign(c1, d + 1, d + 1, 0), assign(c2, d + 1, d + 1, 0);
  for (int i = 0; i < d; ++i) for (int j = 0; j < d; ++j) {
    c1[i + 1][j + 1] = c1[i + 1][j] + c1[i][j + 1] - c1[i][j] + a1[i][j];
    c2[i + 1][j + 1] = c2[i + 1][j] + c2[i][j + 1] - c2[i][j] + a2[i][j];
  }
  auto f1 = [&](int il, int ir, int jl, int jr) -> int {
    return c1[ir][jr] - c1[ir][jl] - c1[il][jr] + c1[il][jl];
  };
  auto s1 = [&](int il, int ir, int jl, int jr) -> int {
    if (il >= d) il -= d, ir -= d;
    if (jl >= d) jl -= d, jr -= d;
    int res = 0;
    res += f1(il, min(ir, d), jl, min(jr, d));
    if (ir > d) res += f1(0, ir - d, jl, min(jr, d));
    if (jr > d) res += f1(il, min(ir, d), 0, jr - d);
    if (ir > d and jr > d) res += f1(0, ir - d, 0, jr - d);
    return res;
  };
  auto f2 = [&](int il, int ir, int jl, int jr) -> int {
    return c2[ir][jr] - c2[ir][jl] - c2[il][jr] + c2[il][jl];
  };
  auto s2 = [&](int il, int ir, int jl, int jr) -> int {
    if (il >= d) il -= d, ir -= d;
    if (jl >= d) jl -= d, jr -= d;
    int res = 0;
    res += f2(il, min(ir, d), jl, min(jr, d));
    if (ir > d) res += f2(0, ir - d, jl, min(jr, d));
    if (jr > d) res += f2(il, min(ir, d), 0, jr - d);
    if (ir > d and jr > d) res += f2(0, ir - d, 0, jr - d);
    return res;
  };
  auto chk = [&](int x) -> bool {
    for (int i = 0; i < d; ++i) for (int j = 0; j < d; ++j) {
      if (s2(i + x + 1, i + d, j + x + 1, j + d) > 0) continue;
      if (s1(i + x + 1, i + d, j, j + x + 1) > 0) continue;
      if (s1(i, i + x + 1, j + x + 1, j + d) > 0) continue;
      return true;
    }
    return false;
  };
  int ng = -1, ok = d - 1;
  while (ok - ng > 1) {
    int mid = ng + ok >> 1;
    (chk(mid) ? ok : ng) = mid;
  }
  cout << k * d + ok << '\n';
}

Measured memory_bytes: 19968
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
#include <limits>
#include <map>
using namespace std;

int main()
{
    int h, w;
    while (cin >> h >> w)
    {
        if (h == 0 && w == 0)
        {
            break;
        }
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (i % 2 == 0)
                {
                    if (j % 2 == 0)
                    {
                        cout << '#';
                    }
                    else
                    {
                        cout << '.';
                    }
                }
                else
                {
                    if (j % 2 == 0)
                    {
                        cout << '.';
                    }
                    else
                    {
                        cout << '#';
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c,d,e,f,g,h,n,m,k,t;
string s;
char ch;
int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n;
    cin>>s;
    map<char,ll>mm;
    for(int i=0;i<n;i++){
        mm[s[i]]++;
    }
    ll ans=1;
    for(auto it=mm.begin();it!=mm.end();it++){
        if(it->second==0)continue;
        ans=ans*(it->second+1)%1000000007;
    }
    if(ans>0)ans--;
    else ans=1000000006;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ll long long
#define ld long double
#define fi first
#define se second
#define INF 10000000000
const ll mod = 1000000000+7;
const int N = 3000+50;

ll dp[N][N];
ll opt[N][N];

main()
{ 
	SPEED;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s, t;
	cin >> s >> t;
	s = '$'+s;
	t = '$'+t;
	for(int i = 0; i<s.size(); i++){
		for(int j = 0 ;j<t.size();j++)
		{
			int x = (s[i]==t[j]);
			if(i>0)
			{
					dp[i][j] = dp[i-1][j];
					opt[i][j] = 1;
			}
			if(j>0)
			{
				if(dp[i][j]<=dp[i][j-1])
				{
					dp[i][j] = dp[i][j-1];
					opt[i][j] = 2;
				}
			}
			if(i>0&&j>0)
			{	if(dp[i][j] < x + dp[i-1][j-1])
				{
					opt[i][j] = 3;
					dp[i][j] = x + dp[i-1][j-1];
				}
			}
		}
	}
	string ans = "";
	int a = s.size()-1,b = t.size()-1;
	while(a>0||b>0)
	{
		if(a<0)break;
		if(b<0)break;
		if(opt[a][b]==3){ans.pb(s[a]);a--;b--;}
		else if(opt[a][b]==1)a--;
		else if(opt[a][b]==2)b--;
		if(opt[a][b]==0)break;
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;

}

Measured memory_bytes: 144512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

bool p[30]={};

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	for(int i=0;i<28;i++){
		int a; cin >> a;
		p[a-1]=1;
	}
	for(int i=0;i<30;i++){
		if(p[i]==0)cout << i+1 << endl;
	}
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a, b, c, d;
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> a >> b >> c >> d;
    cout << max(max(a * c, b * c), max(a * d, b * d)) << endl;
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<int> dist(3);
	for(int i=0; i<3; i++){
		cin >> dist[i];
	}

	sort(dist.begin(), dist.end());

	int sum = dist[0] + dist[1];
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count=0;
		int N = sc.nextInt();
		String s = sc.next();
		int K = sc.nextInt();
		for (int i=0;i<s.length();i++) {
			if (s.charAt(i)!=s.charAt(K-1)) {
				System.out.print("*");
			} else {
				System.out.print(s.charAt(i));
			}
		}
	}
}


Measured memory_bytes: 35628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int N; cin >> N;
    vector<bool> check(N + 1, true);
    for (int i = 1; i <= N; i++) {
        int x;
        scanf("%d", &x);
        if (x == i) check[i] = false;
    }

    int cnt = 0;
    for (int i = 1; i < N; i++) {
        if (!check[i]) {
            if (!check[i + 1]) {
                cnt++;
                check[i] = check[i + 1] = true;
            } else {
                cnt++;
                check[i] = true;
            }
        }
    }
    if (!check[N]) cnt++;

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int  main(){
  int n, m, x;
  cin >> n >> m >>x;
  vector<int> a(m);
  int cnt=0, cnt1=0;
  for(int i=0; i<m; ++i) cin >> a[i];
  for(int i=0; i<m; ++i){
    if(a[i]<x) cnt++;
    else if(a[i]>x) cnt1++;
  }

  cout << min(cnt, cnt1) <<endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
ll knapsack1(int n, int W){
    
    ll mat[n][2] = {};
    for(int i = 0; i < n; i++){
        cin >> mat[i][0] >> mat[i][1];
    }
    
    
    // 2D Array dp calculation
    
    // ll** dp = new ll*[n+1];
    // for(int i = 0; i < n+1; ++i)
    //     dp[i] = new ll[W+1];
    
    // ll dp[n+1][W+1] = {};
    // for(int i = 1; i < n+1; i++){
    //     int w = mat[i-1][0];
    //     ll value = mat[i-1][1];
    //     for(int j = 1; j < W+1; j++){
            
    //         if(j < w) dp[i][j] = dp[i-1][j];
    //         else{
    //             dp[i][j] = max(dp[i-1][j], value + dp[i-1][j-w]);
    //         }
    //     }
    // }
    // return dp[n][W];
    
    // 1d array calculation DP
    ll dp[W+1] = {};
    for(int i = 0; i < n; i++){
        for(int j = W; j >= mat[i][0]; j--){
            dp[j] = max( dp[j] , (dp[j-mat[i][0]]+mat[i][1]) );
        }
    }
    return dp[W];
}
 

 
int main(){
    int n,W ; cin >> n >> W;
    cout << knapsack1(n,W) ;
    return 0;
}

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

const int N = 25;

int dist[N][N], n, m;
char a[N][N];

int d_i[4] = {0, 1, -1, 0};
int d_j[4] = {1, 0, 0, -1};

int solve(int x, int y) {
  dist[x][y] = 0;
  queue<pair<int, int>> q;
  q.push(make_pair(x, y));
  while (!q.empty()) {
    x = q.front().first;
    y = q.front().second;
    q.pop();
    for (int k = 0; k < 4; k++) {
      int new_x = x + d_i[k];
      int new_y = y + d_j[k];
      if (new_x >= n || new_x < 0 || new_y >= m || new_y < 0) continue;
      if (dist[new_x][new_y] != -1 || a[new_x][new_y] == '#') continue;
      dist[new_x][new_y] = 1 + dist[x][y];
      q.push(make_pair(new_x, new_y));
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (dist[i][j] == -1) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  return ans;
}

void reset() {
  for (int i = 0; i < 25; i++) {
    for (int j = 0; j < 25; j++) {
      dist[i][j] = -1;
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      a[i][j] = s[j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '#') continue;
      reset();
      ans = max(ans, solve(i, j));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
bool ok[1001][1001];
int dp[1001][1001];
int ans[1001];
int main(){
    while(cin>>N,N){
       vector<int>v(N);
       REP(i,N)cin>>v[i];
       REP(i,1001)REP(j,1001){ok[i][j]=false;dp[i][j]=0;}
       //ok????????????
       /*REP(i,N){
           for(int j=i+1;j<N;j++){
               if(j-i==1&&abs(v[i]-v[j])<=1){ok[i][j]=true;dp[i][j]=2;continue;}
               if(j-i==2){ok[i][j]=false;dp[i][j]=0;continue;}
               for(int k=i+1;k+1<j;k++){
                   if(abs(v[i]-v[j])>1)continue;
                   if(ok[i][k]==false)continue;
                   if(ok[k+1][j]==false)continue;
                   ok[i][j]=true;
                   dp[i][j]=j-i+1;
               }
           }
       }*/
       for(int k=1;k<=N-1;k++){
          REP(i,N){
              if(i+k>=N)continue;
              if(k==1&&abs(v[i]-v[i+1])<=1){ok[i][i+1]=true;dp[i][i+1]=2;continue;}
              if(k==1)continue;
              if(k==2){ok[i][i+2]=false;dp[i][i+2]=0;continue;}
              if(abs(v[i]-v[i+k])<=1&&ok[i+1][i+k-1]==true){ok[i][i+k]=true;dp[i][i+k]=k+1;}
              for(int j=1;j<=k;j++){
                  if(ok[i][i+j]&&ok[i+j+1][i+k]){ok[i][i+k]=true;dp[i][i+k]=k+1;}
                  /*if(abs(v[i]-v[i+j]>1))continue;
                  if(ok[i][i+j-1]==false)continue;
                  if(ok[i+j+1][i+k]==false)continue;
                  ok[i][i+k]=true;
                  dp[i][i+k]=k+1;*/
              }
          }
       }
       REP(i,1001){
           ans[i]=0;
       }
       for(int i=1;i<N;i++){
           ans[i]=max(ans[i],ans[i-1]);
           ans[i]=max(ans[i],dp[0][i]);
           for(int j=0;j<i;j++){
               ans[i]=max(ans[i],ans[j]+dp[j+1][i]);
           }
       }
       //REP(i,N){REP(j,N)cout<<dp[i][j]<<" ";cout<<endl;}
       //REP(i,N)cout<<ans[i]<<endl;
       cout<<ans[N-1]<<endl;
    }
    return 0;
}

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


int conti_subsq_cnt[200001] = {}, N;

int main(){
  cin >> N;
  for(int i = 1; i <= N; i++){
    int p;
    cin >> p;
    conti_subsq_cnt[p] = conti_subsq_cnt[p-1]+1;
  }

  int max_conti_subsq_cnt = 0;
  for(int i = 1; i <= N; i++){
    max_conti_subsq_cnt = max(max_conti_subsq_cnt, conti_subsq_cnt[i]);
  }
  cout << N - max_conti_subsq_cnt << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    std::string s;
    int k;
    std::cin>>s;
    std::cin>>k;

    std::vector<std::string> v;
    int n = s.size();
    for(int i = 0;i < n;i++){
        for(int j = 1; j <= 5;j++){
            v.push_back(s.substr(i, j));
       }
    }
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::cout<<v[k -1]<<std::endl;
    return 0;
}

Measured memory_bytes: 1660
import sys
n = int(input())
li = list(map(int,input().split()))
even_li = []
for a in li:
  if(a%2==0):
    even_li.append(a)
flg = 0
for a in even_li:
  if(a%3==0 or a%5==0):
    flg += 1
if(str(flg) == str(len(even_li))):
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,m,a,b,i,j;
    cin>>n>>m;
    vector<pair<int,int>> st,pt;
    for (i=0;i<n;i++)
    {
        cin>>a>>b;
        st.pb(mp(a,b));
    }
    for (i=0;i<m;i++)
    {
        cin>>a>>b;
        pt.pb(mp(a,b));
    }
    for (i=0;i<n;i++)
    {
        int dist=INT_MAX,in=-1;
        for (j=0;j<m;j++)
        {
            if (abs(st[i].ff-pt[j].ff)+abs(st[i].ss-pt[j].ss)<dist)
            {
                dist=abs(st[i].ff-pt[j].ff)+abs(st[i].ss-pt[j].ss);
                in=j+1;
            }
        }
        cout<<in<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    lint ret       = 1;
    vector<lint> b = a;
    for (int i = 1; i < n; ++i) {
        b[i] += b[i - 1];
    }
    for (int i = n - 1; i > 0; --i) {
        if (a[i] <= b[i - 1] * 2) {
            ret++;
        } else {
            break;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

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

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

int main(){
    int n, a; cin >> n >> a;
    vector<ll> lis(n+1, 0);
    REP(i, 0, n){cin >> lis[i+1];}
    vector<vector<vector<ll> > > dp(n+1, vector<vector<ll>>(n+1, vector<ll>(3000, 0)));
    REP(i, 0, n+1){
        dp[i][0][0] = 1;
    }
    REP(i, 0, n+1){
        REP(l, 1, n+1){
            REP(k, 0, 3000){
                if(i-1 >= 0 && l-1 >= 0 && k-lis[i] >= 0){
                    dp[i][l][k] = dp[i-1][l][k] + dp[i-1][l-1][k-lis[i]]; 
                }else if(i >= 1){
                    dp[i][l][k] = dp[i-1][l][k];
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        //cout << "#" << i  << " " << dp[i][i][a*i] << endl;
        ans += dp[n][i][a*i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 62592
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

constexpr int mod = 1000000007;

// modをとった和を返す
inline
int modPlus(int a, int b){return (a + b) % mod;}

// modをとった差を返す
inline
int modMinus(int a, int b){return (mod + a - b) % mod;}

// modをとった積を返す
inline
int modMultiple(int a, int b){return (static_cast<long long>(a) * b) % mod;}

// 階乗数n!を最初に計算して、呼ばれた時に返す
class Factorial {
    std::vector<int> table;
public:
    Factorial(int max) : table(max) // max:テーブルのサイズ
    {
        if (max == 0) return;
        table[0] = 1;
        for (int i = 1; i < max; ++i){
            table[i] = modMultiple(table[i - 1], i + 1);
        }
    }

    int operator () (int n)
    {
        if (n < 0) return 0;
        if (n == 0) return 1;
        return table[n - 1];
    }
};

int main()
{
    scanInt(N);
    scanInt(M);
    Factorial fact(max(N, M));
    int result;
    if (abs(M - N) <= 1){
        result = fact(N);
        result = modMultiple(result, fact(M));
        if (N == M){
            result = modMultiple(result, 2);
        }
    }else{
        result = 0;
    }
    printf("%d\n", result);
}


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

#define rep(i, n)     for(int i = 0;      i < int(n); ++i)
#define rep3(i, a, b) for(int i = int(a); i < int(b); ++i)
#define all(x)        (x).begin(),(x).end()
#define sz(x)         int(x.size())
#define mp            make_pair
#define pb            push_back


typedef long long ll;

using namespace std;

int main(){
  int r;
  cin >> r;
  if(r < 1200){
    cout << "ABC" << endl;
  }else if(r < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
//#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int main(void)
{
    int n, k;
    cin >> n >> k;
    
    ll i = 1;
    ll ans = 0;
    while(i <= n) {
        i *= k;
        ans++;
    }

    cout << ans << endl;

    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
from scipy.sparse import csr_matrix
import numpy as np

N = int(input())

XY = [[i] + [int(x) for x in input().split()] for i in range(N)]

edge = set()
for key in [itemgetter(1),itemgetter(2)]:
  XY.sort(key = key)
  for i in range(N-1):
    i1,x1,y1 = XY[i]
    i2,x2,y2 = XY[i+1]
    d = min(abs(x1-x2),abs(y1-y2))
    edge.add((i1,i2,d))
    
# csr形式に直す
row,col,value = zip(*edge)
value = np.array(value,dtype=int)
graph = csr_matrix((value,(row,col)),shape=(N,N))

# 最小全域木
from scipy.sparse.csgraph import minimum_spanning_tree
tree = minimum_spanning_tree(graph, overwrite = True).astype(int)
answer = tree.sum()
print(answer)


Measured memory_bytes: 81240
//2018.09.16 15min 3WA

#include <iostream>
using namespace std;

int main() {

    int N;
    cin >> N;

    bool ans=false;

    int i;
    int dev=N/4;

    if(N%7==0)ans=true;
    else if(N%4==0)ans=true;
    else{
        for(i=1;i<=dev;i++){
            if((N-4*i)%7==0){
                ans=true;
                break;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
C = input()

if C == "a":
    ans = "b"
elif C == "b":
    ans = "c"
elif C == "c":
    ans = "d"
elif C == "d":
    ans = "e"
elif C == "e":
    ans = "f"
elif C == "f":
    ans = "g"
elif C == "g":
    ans = "h"
elif C == "h":
    ans = "i"
elif C == "i":
    ans = "j"
elif C == "j":
    ans = "k"
elif C == "k":
    ans = "l"
elif C == "l":
    ans = "m"
elif C == "m":
    ans = "n"
elif C == "n":
    ans = "o"
elif C == "o":
    ans = "p"
elif C == "p":
    ans = "q"
elif C == "q":
    ans = "r"
elif C == "r":
    ans = "s"
elif C == "s":
    ans = "t"
elif C == "t":
    ans = "u"
elif C == "u":
    ans = "v"
elif C == "v":
    ans = "w"
elif C == "w":
    ans = "x"
elif C == "x":
    ans = "y"
elif C == "y":
    ans = "z"
print(ans)


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<V> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(new V(sc.nextDouble(), sc.nextDouble()));
		}
		List<Integer> elements = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			elements.add(i);
		}

		List<List<Integer>> temp = m(elements);
		double sum = 0;
		for (List<Integer> a : temp) {
			Double sumtemp = 0D;
			V before = list.get(a.get(0));
			for (int i = 1; i < n; i++) {
				V now = list.get(a.get(i));
				sumtemp += before.distance(now);
				before = now;
			}
			sum += sumtemp;
		}
		System.out.println(sum / factorial(n));

//		sc.close();
	}

	private static Map<Integer, Integer> map = new HashMap<>();

	private static int factorial(int n) {
		if (n == 0) {
			return 1;
		}
		if (!map.containsKey(n - 1)) {
			map.put(n - 1, factorial(n - 1));
		}
		return n * map.get(n - 1);
	}

	private static List<List<Integer>> m(List<Integer> elements) {
		int n = elements.size();
		List<List<Integer>> list = new ArrayList<>();
		if (n == 1) {
			List<Integer> l = new ArrayList<>();
			l.add(elements.get(0));
			list.add(l);
			return list;
		}
		for (int i = 0; i < n; i++) {
			int element = elements.remove(i);
			List<List<Integer>> li = m(elements);
			for (List<Integer> temp : li) {
				List<Integer> l = new ArrayList<>();
				l.add(element);
				l.addAll(temp);
				list.add(l);
			}
			elements.add(i, element);
		}
		return list;
	}

	private static class V {
		public double x;
		public double y;

		public V(double x, double y) {
			super();
			this.x = x;
			this.y = y;
		}

		public double distance(V v) {
			return Math.sqrt(Math.pow(this.x - v.x, 2) + Math.pow(this.y - v.y, 2));
		}
	}
}


Measured memory_bytes: 57344
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int A, P;
  cin >> A >> P;
  P += A * 3;
  int ans = P / 2;
  cout << ans << '\n';
  return 0;
}

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

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

    int count = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) count++;
    }

    cout << count << endl;

    return 0;
}

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

using	namespace std;

int main() {
	
	int a[5], k, count = 0;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	cin >> k;

	if (a[4] - a[0] <= k) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate#,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial
#import sys

setrecursionlimit(10**6)
input=stdin.readline

a,b,c=map(int,input().split())
if a+b+c>=22:
    print("bust")
else:
    print("win")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define MAX_N 7500000
using namespace std;
int main()
{
	int m,n;
	while(cin >> m >> n, m | n)
	{
		vector<bool> A(MAX_N + 10, 0);
		int cnt = 0;
		for(int i=m; cnt < n; i++)
		{
			if(A[i])
				continue;
			cnt++;
			for(int j=i; j<MAX_N; j+=i)
			{
				A[j] = true;
			}
		}
		for(int i=m; i<MAX_N; i++)
		{
			if(A[i]) 
				continue;
			cout << i << endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 4012
import sys

N , W = map(int, input().split())

WV = [list(map(int, sys.stdin.readline().split())) for i in range(N)]

INF = 10**11+1

dp = [[0]*(1+W) for i in range(N+1)]

for i in range(1, N+1):
    for j in range(1, W+1):
        if j-WV[i-1][0]>=0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-WV[i-1][0]]+WV[i-1][1])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[N][W])

Measured memory_bytes: 120172
/* code by AbhiTaker  */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 5000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000


int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string s;
    cin>>s;
    cout<<"2018";
    for(ll i=4;i<s.size(); i++)
    {
            cout<<s[i];
    }


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int x1 = vs[0], x2 = vs[1], x3 = vs[2], x4 = vs[3], x5 = vs[4];
			if (x1 == 0) {
				Console.WriteLine(1);
			} else if (x2 == 0) {
				Console.WriteLine(2);
			} else if (x3 == 0) {
				Console.WriteLine(3);
			} else if (x4 == 0) {
				Console.WriteLine(4);
			} else {
				Console.WriteLine(5);
			}

		}
	}
}


Measured memory_bytes: 28240
def C():
    A, B = input().split()
    A = int(A)
    B_int = int(B[:B.index('.')])
    B_decimal = int(B[B.index('.')+1:])
    ans_int = A*B_int
    ans_int += B_decimal*A//100
    print(ans_int)
    
C()

Measured memory_bytes: 9172
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

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

  priority_queue<ll> q;
  for(int i = 0; i<N; i++){
    ll A;
    cin >> A;
    q.push(A);
  }

  for(int i=0; i<M; i++){
    ll a = q.top();
    q.pop();
    q.push(a/2);
  }

  ll ans = 0;
  while(!q.empty()){
      ans += q.top();
      q.pop();
    }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main()
{   
	int n,a,b;
	int i = 0 ,total = 0;
	 
	scanf("%d %d %d",&n,&a,&b);
	a = a * n;
	if(a<b)
	printf("%d",a);
	else
	printf("%d",b);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  string s; cin >>s;
  cout <<(s[1] == 'R' ? "ABC" : "ARC") <<endl;
}

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

#define pb push_back
#define ff first
#define ss second

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

int n;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	if (n == 22)
		cout << "Christmas Eve Eve Eve";
	if (n == 23)
		cout << "Christmas Eve Eve";
	if (n == 24)
		cout << "Christmas Eve";
	if (n == 25)
		cout << "Christmas";
	return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,a,b=LI()
  l=LI()

  sm=0
  for i in range(n-1):
    x=l[i+1]-l[i]

    if x*a<b:
      sm+=x*a
    else:
      sm+=b

  return sm

print(main())


Measured memory_bytes: 16712
from collections import Counter as C
n = int(input())
V = list(input().split())

V1 = C(V[::2]).most_common()
V2 = C(V[1::2]).most_common()

if V1[0][0] != V2[0][0]:
  ans = n - (V1[0][1] + V2[0][1])
else:
  l = V1[0][1] + V2[1][1] if len(V2) > 1 else V1[0][1]
  r = V1[1][1] + V2[0][1] if len(V1) > 1 else V2[0][1] 
  if l >= r:
    ans = n - l
  else:
    ans = n - r
    
print(ans)

Measured memory_bytes: 23004
import math

def solve():
  A, B, X = map(int, input().split())
  if (A ** 2) * B / 2 >= X:
    return math.degrees(math.atan2(B, (X * 2) / (A * B)))
  else:
    b = (X * 2) / (A ** 2) - B
    return math.degrees(math.atan2(B - b, A))

print(solve())

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
	int a, b, c, max1, max2;

	scanf("%d%d%d", &a, &b, &c);
	max1 = max2 = 0;
	if (max1 < a) {
		max2 = max1;
		max1 = a;
	}
	if (max2 < a)
		max2 = a;
	if (max1 < b) {
		max2 = max1;
		max1 = b;
	}
	if (max2 < b)
		max2 = b;
	if (max1 < c) {
		max2 = max1;
		max1 = c;
	}
	if (max2 < c)
		max2 = c;
	printf("%d\n", (max1 * 10 + max2) + a + b + c - max1 - max2);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<iostream>
#include <algorithm>
#include<stdio.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include<vector>
using namespace std;
#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define Fs first
#define Sc second
#define endl "\n"
#define MOD 1000000007
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long lli;

int main()
{
    int t,n;
    cin>>t;
    cin>>n;
    cout<<(t^n)<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int m = 0;
    for (int i = 0; i < s.size(); i++)
        if (s.at(i) == '1')
            m += 1;

    cout << m;
    return 0;
}

Measured memory_bytes: 3580