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

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using usize = std::size_t;
using namespace std;

#define rep(i, max) for(i32 i = 0; i < (i32)max; ++i)
#define loop while(true)
#define allOf(collection) collection.begin(), collection.end()

unique_ptr<string> readLine() { unique_ptr<string> line(new string()); getline(cin, *line); return line; }
template<typename T1, typename T2> pair<T1, T2> readPair() { T1 res1; cin >> res1; T2 res2; cin >> res2; readLine(); return make_pair(res1, res2);}
template<typename T> unique_ptr<vector<T>> readVector(usize num) { unique_ptr<vector<T>> list(new vector<T>(num)); rep(i, num) cin >> (*list)[i]; readLine(); return list; }
void readValues() { readLine(); }
template<typename H, typename... T> void readValues(H& head, T&&... tails){ H a; cin >> a; head = a; readValues(forward<T>(tails)...); }
void writeLine() { cout << endl; }
template<typename T> void write(const T& arg) { cout << arg; }
template<typename T> void writeLine(const vector<T>& arg){ if(arg.empty()) { writeLine(); return; } write(arg[0]); for(int i = 1; i < arg.size(); ++i){ write(" "); write(arg[i]); } writeLine(); }
template<typename T> void writeLine(const T& arg) { cout << arg << endl; }
void recursiveCombination(vector<i32>& indexes, i32 s, i32 rest, function<void(vector<i32>&)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursiveCombination(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursiveCombination(indexes, s - 1, rest - 1, f); } }
void foreachWithCombination(i32 n, i32 k, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(k); recursiveCombination(indexes, n - 1, k, f); }
void foreachWithPermutaton(i32 n, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(); indexes.reserve(n); rep(i, (usize)n) indexes.push_back(i); do f(indexes); while (next_permutation(allOf(indexes))); }
void foreachWithPermutaton(i32 n, i32 k, function<void(vector<i32>&)> f){ foreachWithCombination(n, k, [=](vector<i32>& combIndexes){ foreachWithPermutaton(k, [=](vector<i32>& permIndexes){ auto indexes = vector<i32>(); indexes.reserve(k); rep(i, (usize)k){ indexes.push_back(combIndexes[permIndexes[i]]); } f(indexes); }); }); }
void program();
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    program();
}

void program() {
    i32 n;
    readValues(n);
    auto l = *readVector<i32>(n);

    if(n < 3){
        writeLine(0);
        return;
    }

    i32 count = 0;
    foreachWithCombination(l.size(), 3, [&](vector<i32> indexes){
        i32 a, b, c;
        a = l[indexes[0]];
        b = l[indexes[1]];
        c = l[indexes[2]];
        if(a != b && b != c && c != a && a + b > c && b + c > a && c + a > b){
            ++count;
        }
    });
    writeLine(count);
}

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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    vector<int>s(4);
    cin>>s[0]>>s[1]>>s[2]>>s[3];

    sort(s.begin(),s.end());
    if(s[0]==1&&s[1]==4&&s[2]==7&&s[3]==9){
        cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/*---------------------------------------------------------------------------------------------------------------------*/

const int M = 2e5 + 5;

stack<ll> stck;
int lef[M], rig[M];
ll arr[M];

int main(){

	int n;
	si(n);

	for(int i = 1 ; i <= n ; i++){
        sll(arr[i]);
	}

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

        while(stck.size() && arr[stck.top()] > arr[i]){
            stck.pop();
        }

        if(stck.size() == 0){
            lef[i] = 1;
        }
        else{
            lef[i] = stck.top() + 1;
        }
        stck.push(i);

	}

	while(stck.size())
        stck.pop();

	for(int i = n ; i >= 1 ; i--){

        while(stck.size() && arr[stck.top()] > arr[i]){
            stck.pop();
        }

        if(stck.size() == 0){
            rig[i] = n;
        }
        else{
            rig[i] = stck.top() - 1;
        }
        stck.push(i);

	}

	ll ans = 0;

	for(int i = 1 ; i <= n ; i++){
        ans += (arr[i] * 1LL* (i - lef[i] + 1) * (rig[i] - i + 1));
	}

    cout<<ans;
}






































Measured memory_bytes: 4992
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    H = list(int(_) for _ in input().split())
    ans = 0
    for i in range(N):
        if i == 0:
            ans+=1
        else:
            flag = True
            for j in range(i,-1,-1):
                if(H[i]<H[j]):
                    flag = False
                    break
            if flag:
                ans+= 1
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MN = 305;
ll dp[MN][MN][MN];
const ll M = 1e9+7;
vii q[MN];
int main() {
	ll n,m;
	scanf("%lld %lld ",&n,&m);
	for(int i=0;i<m;i++) {
		ll a,b,c;
		scanf("%lld %lld %lld ",&a,&b,&c);
		q[b].push_back({a,c});
	}
	memset(dp,0,sizeof(dp));
	dp[1][0][0] = dp[0][1][0] = dp[0][0][1] = 1;
	for(int i=0;i<=n;i++) {
		for(int j=0;j<i;j++) {
			for(int k=0;k<i;k++) {
				for(int l=0;l<q[i].size();l++) {
					int ct = 1;
					int st = q[i][l].first;
					if(j >= st) {ct++;}
					if(k >= st) {ct++;}
					if(q[i][l].second != ct) {
						dp[i][j][k] = dp[j][i][k] = dp[j][k][i] = 0;
					}
				}
			}
		}
		for(int j=0;j<i;j++) {
			for(int k=0;k<i;k++) {
				dp[i+1][j][k] += dp[i][j][k];
				dp[i][i+1][k] += dp[i][j][k];
				dp[i][j][i+1] += dp[i][j][k];
				dp[i+1][i][k] += dp[j][i][k];
				dp[j][i+1][k] += dp[j][i][k];
				dp[j][i][i+1] += dp[j][i][k];
				dp[i+1][k][i] += dp[j][k][i];
				dp[j][i+1][i] += dp[j][k][i];
				dp[j][k][i+1] += dp[j][k][i];
			}
		}
		for(int j=0;j<=i;j++) {
			for(int k=0;k<=i;k++) {
				dp[i+1][j][k] %= M;
				dp[j][i+1][k] %= M;
				dp[j][k][i+1] %= M;
			}
		}
	}
	ll tot = 0;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			//printf("%lld %d %d\n",dp[i][j][n],i,j);
			tot += dp[n][i][j];
			tot += dp[i][j][n];
			tot += dp[i][n][j];
		}
	}
	tot %= M;
	printf("%lld\n",tot);
}

Measured memory_bytes: 222464
n, m = map(int, input().split())


def divisor(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors


ans = 0
for i in divisor(m):
    if n <= m // i:
        ans = i
    else:
        break
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	string s,s1="";
	cin>>s;
	int cc=0,t=0;
	for(int i=0;i<s.size();i++)if(s[i]!='x'){s1+=s[i];a[t++]=cc;cc=0;}else cc++;
	a[t++]=cc;
	for(int i=0;i<s1.size();i++)if(s1[i]!=s1[s1.size()-i-1]){puts("-1");return 0;}
	int n=s1.size(),ans=0;
	for(int i=0;i<(n+1)/2;i++)ans+=2*max(a[i],a[n-i])-a[i]-a[n-i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
def check(N, A):
    S = N * (1+N) // 2
    total = sum(A)
    if total % S != 0:
        return False
    cnt = total//S
    tmp = cnt
    for i in range(N):
        diff = A[i] - A[(i+1) % N]
        if (diff + cnt) % N != 0 or (diff + cnt) < 0:
            return False
        tmp -= (diff + cnt) // N
    return tmp == 0


def main():
    N = int(input())
    A = list(map(int, input().split()))
    if check(N, A):
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 62708
n = int(input())
h = list(map(int,input().split()))

dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 84876
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  Yn(a+b==c||a+c==b||b+c==a);
  return 0;
}

Measured memory_bytes: 256
x = int(input())

l5 = [i**5 for i in range(0, 10000)]
for a5 in l5:
    for b5 in l5:
        if x == a5 - b5:
            print(int(a5**(1/5)), int(b5**(1/5)))
            exit()
        elif x == a5 + b5:
            print(int(a5**(1/5)), int((-1) * b5**(1/5)))
            exit()


Measured memory_bytes: 9572
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
  ll n,m;
  cin>>n>>m;
  
  ll x,y,l=INT_MIN,r=INT_MAX;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    l=max(l,x);
    r=min(r,y);
  }
  if(r-l>=0) cout<<r-l+1;
  else cout<<0;
}

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

int main(){
    // input
    int n;
    ll k; cin >> n >> k;
    vector<ll> a(n),f(n); 
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];
    // prepare
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<ll>()); // a昇順、f降順の時のa[i]*f[i]が最適
    // binary-search
    ll right = a[n-1]*f[0]; // 常に条件を満たす
    ll left = -1; // 常に条件を満たさない
    ll mid;
    while(right-left>1){
        mid = (right+left) >> 1; // midが最大値になり得るか
        ll sum = 0;
        rep(i,n) sum += max(a[i]-(mid/f[i]), 0LL); // a[i]*f[i]がmidより小さくなるような修行回数
        if(sum > k) left = mid; // midが最大値になり得ない
        else right = mid; // midが最大値になり得る
    }
    // output
    cout << right << "\n";
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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 const INF = 1001001001;


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

int H,W;
cin >> H >> W;
vector<string> field(H);
rep(h,H) cin >> field[h];

vector<bool> hb(H),wb(W);
rep(h,H) rep(w,W) if(field[h][w] == '#') hb[h] = true;
rep(w,W) rep(h,H) if(field[h][w] == '#') wb[w] = true;

rep(h,H){
    rep(w,W){
        if(hb[h] && wb[w]) cout << field[h][w];
    }
    if(hb[h]) cout << "\n";

}




return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF (1 << 30) - 1 + (1 << 30)
#define EPS 1.0e-6

using namespace std;

int n, q;
int mx[1050000];

int init(int n_)
{
	int k = 1;
	while (k < n_)k *= 2;
	for (int i = 0; i < 2 * k; i++) {
		mx[i] = 0;
	}
	return k;
}

void update(int ind, int val)
{
	ind += n;
	mx[ind] = val;
	ind /= 2;
	while (ind > 0) {
		int l = mx[2 * ind];
		int r = mx[2 * ind + 1];
		mx[ind] = min(l, r);
		ind /= 2;
	}
}

int find(int l, int r, int bottom = 0, int top = n, int node = 1)
{
	if (l <= bottom&&top <= r)return mx[node];
	if (top <= l || r <= bottom)return INF;

	int mid = (bottom + top) / 2;
	int lmx = find(l, r, bottom, mid, 2 * node);
	int rmx = find(l, r, mid, top, 2 * node + 1);

	return min(lmx, rmx);
}

void add(int ind, int val)
{
	ind += n;
	mx[ind] += val;
	ind /= 2;
	while (ind > 0) {
		mx[ind] += val;
		ind /= 2;
	}
}

int getSum(int l, int r, int bottom = 0, int top = n, int node = 1)
{
	if (l <= bottom&&top <= r) return mx[node];
	if (top <= l || r <= bottom)return 0;

	int mid = (bottom + top) / 2;

	int lmx = getSum(l, r, bottom, mid, 2 * node);
	int rmx = getSum(l, r, mid, top, 2 * node + 1);

	return lmx + rmx;
}


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

	n=init(n);

	int k, x, y;
	for (int i = 0; i < q; i++) {
		cin >> k >> x >> y;
		x--;
		if (k == 0)add(x, y);
		if (k == 1)cout<<getSum(x, y,0,n,1)<<endl;
	}

	return 0;
}

Measured memory_bytes: 4100
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());
    loop {
        let a: i32 = scan.next();
        let op = scan.next::<String>().chars().collect::<Vec<char>>();
        let b: i32 = scan.next();
        let ans = match op[0] {
            '+' => a + b,
            '-' => a - b,
            '*' => a * b,
            '/' => a / b,
            _ => break,
        };
        writeln!(out, "{}", ans).ok();
    }
}



Measured memory_bytes: 5036
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=INF;
int n,m;
int dp[1111][4444];//i-1までを買うことができるとき、j状態にするのに最小の金額
int a[1111],b[1111],c[1111][13];
signed main(){
	
	
	
	cin>>n>>m;
	
	
	rep(i,m+1){
		rep(j,1<<n){
			dp[i][j]=INF;
		}
	}
	dp[0][0]=0;
	rep(i,m){
		cin>>a[i]>>b[i];
		rep(j,b[i])cin>>c[i][j];
	}
	
	
	rep(i,m){
		int openable=0;
		rep(j,b[i])openable+=(1LL<<(c[i][j]-1));
		rep(j,1LL<<n){
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			dp[i+1][(openable|j)]=min(dp[i+1][(openable|j)],dp[i][j]+a[i]);
		}
	}
	
	/*rep(i,m){
		ans=min(ans,dp[i+1][(1<<n)-1]);
	}*/
	if(dp[m][(1<<n)-1]>=INF)cout<<-1<<endl;
	else cout<<dp[m][(1<<n)-1]<<endl;
}


Measured memory_bytes: 37120
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    int n, t;
    cin >> n >> t;
    int prev = 0;
    ll ans = 0;
    for(int i=0;i<n;i++){
        int ti; cin >> ti;
        ans += min(t, ti - prev);
        prev = ti;
    }
    cout << ans + t << '\n';
    return 0;
}


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

int main() {
    int n; cin >> n;
    int d, x; cin >> d >> x;
    int c = 0;
    for (int i = 1; i <= n; ++i) {
        int a; cin >> a;
        for (int j = 1; j <= d; j += a) ++c; 
    }
    cout << c + x << endl;
}


Measured memory_bytes: 256
while True:
    n, x = (int(x) for x in input().split())
    
    if n == 0 and x == 0:
        break
    
    count = 0
    for i in range(1, n - 1):
        
        for j in range(i + 1, n):
            
            for k in range(j + 1, n + 1):
                
                if i + j + k == x:
                    count += 1
                    break
    
    print(count)


Measured memory_bytes: 5604
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, M;
  cin>>N>>M;
  ll ans = 0;
  for(ll i=1;i*i<=M;++i) {
    if(M%i==0) {
      if(M/i>=N) ans = max(ans, i);
      if(i>=N) ans = max(ans, M/i);
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

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

const int inf = 1e9 + 7;
const ll longinf = 1LL << 50;
const long long mod_const = 1e9 + 7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

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; }

using pll = pair<long long, long long>;

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

	vector<ll> vx(N, 0);
	vector<ll> vy(N, 0);

	rep(i, N) {
		cin >> vx[i] >> vy[i];
	}

	double ans = 0.0;
	rep(i, N) {
		rep(j, N) {
			ans += sqrt((vx[i] - vx[j]) * (vx[i] - vx[j]) + (vy[i] - vy[j]) * (vy[i] - vy[j]));
		}
	}
	ans = ans / N;

	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using ll =long long;
 
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}
 
int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int n,k;
  string s;
  cin >>n>>k>>s;
  if(s[k-1]=='A'){
    s[k-1]='a';
  }
  else if(s[k-1]=='B'){
    s[k-1]='b';
  }
  else if(s[k-1]=='C'){
    s[k-1]='c';
  }
  cout <<s<<endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

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

	int ans = 0;
	FOR_LT(i, 1, n - 1) {
		int cur = vs[i];
		if (vs[i - 1] < cur && cur < vs[i + 1]) ans++;
		if (vs[i + 1] < cur && cur < vs[i - 1]) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      int A = nextInt();
      myout(N * N - A);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32848
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N, M;
	cin >> N >> M;
	for (ll i = M / N; i > 0; i--) {
		if (M % i == 0) {
			cout << i << endl;
			break;
		}
		
	}
}


Measured memory_bytes: 256
N = int(input())
l = list(map(int, input().split()))
unique_l = list(set(l))
unique_l.sort()
l.sort()
l.append(0)
ans = 0
j = 0
cnt =[]
for i in unique_l:
    temp = 0
    while l[j] == i and j < N:
        temp += 1
        j += 1
    cnt.append(temp)
for i, j in zip(unique_l, cnt):
    if i == j:
        pass
    elif j > i:
        ans += j - i
    elif j < i:
        ans += j
print(ans)

Measured memory_bytes: 14492
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	i64 n;
	cin >> n;
	i64 sq = (i64)floor(sqrt((long double)n)) + 1;
	i64 div_1 = 0;
	for (i64 i = sq; i > 0; --i)
	{
		if (n % i == 0)
		{
			div_1 = i;
			break;
		}
	}
	i64 div_2 = n / div_1;
	i64 ans = max(div_1, div_2);
	string s = to_string(ans);
	print(SIZE(s));
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long N, A[87], CurrentMoney = 1000;
int main() {
cin >> N;
for (int i = 1; i <= N; i++) cin >> A[i];
for (int i = 1; i <= N - 1; i++) {
long long Stocks = 0;
if (A[i] < A[i + 1]) Stocks = CurrentMoney / A[i];
CurrentMoney += (A[i + 1] - A[i]) * Stocks;
}
cout << CurrentMoney << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>

using namespace std;

int f(int n) {
    if(n % 2 == 0){
        n /= 2;
    }
    else{
        n = 3 * n + 1;
    }
    return n;
}

int main () {
    int s, flag = 0;
    cin >> s;

    vector<int> data = {s};
    int i = 0;
    while(1){
        s = f(s);

        for(int i = 0; i < data.size(); i++){
            if(s == data.at(i)){
                cout << data.size() + 1 << endl;
                flag = 1;
            }
        }
        if(flag == 1){
            break;
        }

        data.push_back(s);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main() {
 
	int n;
	string s;
	string ans;

	cin >> n;
	cin >> s;

	ans = s[0];
	for (int i = 1; i < n; i++) {
		if (s[i - 1] == s[i ]) {
                    ;
                } else {
		  ans = ans + s[i];
		}
	}
	cout << ans.length() << endl;
	return 0;
}

Measured memory_bytes: 696
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int n,m;
int A[11],s[11][11],p[11],ans=0;
signed main(){
	cin>>n>>m;
	rep(i,m){
		cin>>A[i];
		rep(j,A[i]){
			cin>>s[i][j];
			s[i][j]--;
		}
	}
	rep(i,m)cin>>p[i];
	rep(i,(1<<n)){
		rep(j,m){
			int cnt=0;
			rep(k,A[j]){
				if((i>>s[j][k])&1)cnt++;
			}
			if(cnt%2!=p[j])goto no;
		}
		ans++;
		no:;
	}
	cout<<ans<<endl;
	return 0;
}


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

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

  int a, b;
  cin >> a >> b;

  int x = a + b;
  if (x & 1) cout << "IMPOSSIBLE\n";
  else cout << x / 2 << endl;

  return (0);
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
int main()
{
    int limit,now,in;
    cin >> limit >> now >> in;
    cout << ((in - (limit - now) > 0) ? (in - (limit - now)) : 0);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int a,n,c;
    scanf("%d",&a);
    for(n = 1;n < 10;n++)
    {
        if(a/n < 10 && a%n == 0)
        {
            c = 1;
            break;            
        }
        else
        {
            c = 0;
        }
    }

    if(c == 0)
    {
        printf("No\n");
    }
    else if(c == 1)
    {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

void CountingSort(int *, int *, int);

int C[10000];

int main(){

  int i, n;

  scanf("%d", &n);

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

  CountingSort(A, B, n);

  for(i = 1; i < n; i++){
    printf("%d ", B[i]);
  }
  printf("%d\n", B[i]);


  return 0;
}

void CountingSort(int *A, int *B, int n){

  int i;
  
  for(i = 0; i < 10000; i++){
    C[i] = 0;
  }

  /* C[i] に i の出現数を記録する */
  for(i = 0; i < n; i++){
    C[A[i]]++;
  }

  /* C[i] に i 以下の数の出現数を記録する*/
  for(i = 1; i <= 10000; i++){
    C[i] = C[i] + C[i-1];
  }
  
  for(i = n-1; i >= 0; i--){ 
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}      



Measured memory_bytes: 17428
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n,cnt = 0;
  std::cin >> n;
  vt<int> a(n,-1);

  rep(i,n) {
    int num;
    std::cin >> num;
    --num;
    a[i] = num;
    if(a[num] == i)
      cnt++;
  }
  std::cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(" "));

            int A = Integer.parseInt(inputString.get(0));
            int B = Integer.parseInt(inputString.get(1));
            int C = Integer.parseInt(inputString.get(2));

            String ans = "NO";
            // if (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
            //     ans = "YES";
            // } else if (A % 2 != 0 && B % 2 != 0 && C % 2 != 0) {
            //     ans = "YES";
            // } else if (A % 2 != 0 && B % 2 == 0 && C % 2 != 0) {
            //     ans = "YES";
            // } else if (A % 2 == 0 && B % 2 != 0 && C % 2 != 0) {
            //     ans = "YES";
            // } else if (A % 2 != 0 && B % 2 != 0 && C % 2 == 0) {
            //     ans = "YES";
            // } else if (A % 2 != 0 && B % 2 == 0 && C % 2 == 0) {
            //     ans = "YES";
            // } else if (A % 2 == 0 && B % 2 != 0 && C % 2 == 0) {
            //     ans = "YES";
            // }

            for (int i = A; i <= A * B; i += A) {
                if (i % B == C) {
                    ans = "YES";
                    break;
                }
            }
            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 23508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int main(){
	int n = 0;
	
	cin >> n;
	
	int a = -1, ap = -1;
	
	int h[n];
	REP(i,n) h[i] = 0;
	
	REP(i,n){
		ap = a;
		cin >> a;
		
		if (ap+1 == a){
			h[ap-1] = 1;
		}
	}
	
	int ans = 0;
	
	REP(i,n){
		cin >> a;
		ans += a;
	}
	
	int c = 0;
	
	REP(i,n-1){
		cin >> c;
		ans += h[i]*c;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, d;
    cin >> h >> w >> d;
    vector<vector<int> > a(h, vector<int>(w, 0));
    vector<int> dist(h * w + 1, 0);
    map<int, pair<int, int> > mp;
    rep (i, h) {
        rep (j, w) {
            cin >> a[i][j];
            mp[a[i][j]] = make_pair(i + 1, j + 1);
        }
    }
    for (int i = h * w; i > 0; --i) {
        if (i + d > h * w) continue;
        int px, py, ax, ay;
        px = mp[i + d].first, py = mp[i + d].second;
        ax = mp[i].first, ay = mp[i].second;
        dist[i] = dist[i + d] + abs(px - ax) + abs(py - ay);
    }
    int q;
    cin >> q;
    rep (i, q) {
        int l, r;
        cin >> l >> r;
        cout << dist[l] - dist[r] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 7424
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long a;
    long long t;
    long long tt;
    long long p;
    
    cin >> a;
    
    t = (a - a % 500) / 500;
    
    tt = a % 500;
    
    p = (tt - tt % 5) / 5;
    
    tt = t * 1000 + p * 5;
    
    cout << tt;
}


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

using namespace std;

int main() {
	long long n, a, b;

	scanf("%lld %lld %lld", &n, &a, &b);

	long long tot = a+b;

	long long div = n/tot;
	long long r = n%tot;

	printf("%lld\n", div*a + min(r, a));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,m,dp[7368792],cnt;
int main(void){
    while(1){
    cin>>n>>m;
    if(n==0&&m==0)return 0;
    for(int i=0;i<7368792;i++)dp[i]=0;
    cnt=0;
    while(1){
        if(dp[n]==0){
            if(cnt==m){
                cout<<n<<endl;
                break;
            }
            cnt++;
            for(int j=n;j<7368792;j+=n){
                dp[j]=1;
            }
        }
        n++;
    }
    }
}



Measured memory_bytes: 31884
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    int m=a+b-n;
    if(m<0) m=0;
    cout<<min(a,b)<<" "<<m<<endl;

    return  0;
}


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

#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 SORTASC(c) sort((c).begin(), (c).end())
#define SORTDESC(c, t) sort((c).begin(), (c).end(), std::greater<t>());
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

const double PI = acos(-1.0);

using ll = long long;
using namespace std;

int main()
{
    ll t[5];
    ll min_mod_10 = 9;
    ll min_mod_10_idx;

    REP(i, 5){
        cin >> t[i];
        if (t[i] % 10 != 0){
            ll prev_min_mod = min_mod_10;
            min_mod_10 = min(min_mod_10, t[i]%10);
            if (prev_min_mod != min_mod_10){
                min_mod_10_idx = i;
            }
        }
    }

    ll ans = 0;
    REP(i, 5){
        if (i != min_mod_10_idx){
            ans += ceil(t[i]/10.0)*10;
        } else {
            ans += t[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let (_n, m) = input!(u64, u64);
    let mut req = input!(u64, u64; m);
    req.sort_by_key(|v| v.1);
    let mut ans = 0;
    let mut bb = 0;
    for r in req {
        if r.0 <= bb {
            continue;
        }
        ans += 1;
        bb = r.1 - 1;
    }
    println!("{}", ans);
}


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

int main(){
  string s,t;
  cin >> s >> t;
  for(int i=s.size()-t.size();i>=0;--i){
    bool f=true;
    for(int j=0;j<t.size();++j){
      if(s[i+j]==t[j] || s[i+j]=='?') continue;
      f=false;
      break;
    }
    if(f){
      for(int j=0;j<s.size();++j){
        if(j==i){
          cout << t;
          j+=t.size()-1;
        }
        else if(s[j]=='?'){
          cout << 'a';
        }
        else cout << s[j];
      }
      cout << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}


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

int main(){
    int n;
    int a[200];
    int ans=0;
    int d=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    while(1){
        for(int i=0;i<n;i++){
            if(a[i]%2==1)d++;
            a[i]/=2;
        }
        if(d!=0)break;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll a[3], i, j;
	for(i=0; i< 3; i++)
	cin>>a[i];
	
	sort(a, a+3);
	ll ans= a[0]+ a[1];
	cout<<ans;
    return 0;
}























Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
hantei = 1
for i in range(1 , N)[::-1]:
    if (H[i] < H[i - 1]):
        H[i - 1] = H[i - 1] - 1
        if(H[i] < H[i - 1]):
            hantei = 0
            break

if hantei == 0:
    print("No")
else:
    print("Yes")

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

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

using pii = pair<int, int>;

inline void Main() {
  // code
  int n,k,q,a,p[(int)1e5] = {0};
  cin>>n>>k>>q;
  rep(i,q) {
    cin >> a;
    p[a-1]++;
  }
  rep(i,n) {
    if(k-q+p[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

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


Measured memory_bytes: 1024
import copy

S = input()
s = list(S)
l = len(s)
t = copy.copy(s)

count_0 = 0
count_1 = 0


for i in range(0,l-1):
    if s[i] == "0":
        if s[i+1] != "1":
            s[i+1] = "1"
            count_0 += 1
    else:
        if s[i+1] != "0":
            s[i+1] = "0"
            count_0 += 1

if s[0] == "0":
    count_1 += 1
    t[0] = "1"
else:
    count_1 += 1
    t[0] = "0"

for j in range(0,l-1):
    if t[j] == "0":
        if t[j+1] != "1":
            t[j+1] = "1"
            count_1 += 1
    else:
        if t[j+1] != "0":
            t[j+1] = "0"
            count_1 += 1

n = min(count_0,count_1)
print(n)

Measured memory_bytes: 5236