akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;


/* problem_C */
int main(){
    double a,b;
    cin >> a >> b;
    double a1, b1;
    a1 = a / 0.08;
    b1 = b / 0.1;
    double b2=0;
    
    for (int i=0; i<9; i++){
        if (floor(b1)==b1){
            b2 = b1;
        }
        else{
            b2 = floor(b1)+1;
        }
        if (floor(b2*0.1)==b){
            b2 = b2;
        }
        else{
            b2 = 0;
        }
        if (floor(b2*0.08)==a){
            break;
        }
        else{
            b2 = -1;
        }
        b1 += 1;
    }
    cout << b2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unordered_set<ll> uset;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=0;i<=n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
int ask(ll a,ll b,ll c,ll d){
	cout<<"? "<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"<<flush;
	int res;
	cin>>res;
	return res;
}
int main(){
	int h,w,n,K;
	cin>>h>>w>>n>>K;
	int ans[55][55];
	rep(i,h)rep(j,w)ans[i][j]=0;
	rep(i,h)for(int j=0;j<w;j+=5){
		int l=j,r=min(w-1,j+5);
		int res=ask(i,l,i,r);
		for(int k=l;k<r;k++){
			if(res==0)break;
			int cur=ask(i,k,i,k);
			ans[i][k]=cur;
			res-=cur;
		}
		ans[i][r]=res;
	}
	ll fans=0,po2=1;
	rep(i,h)rep(j,w){
		fans=(fans+po2*ans[i][j])%K;
		po2=po2*2%K;
	}
	cout<<"! "<<fans<<"\n"<<flush;
}


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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO; 

	int n;
	cin >> n;
	ll ans = 0;
	vector<ll> v(n), dp(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	dp[0] = v[0];
	for (int i = 1; i < n; ++i) {
		dp[i] = v[i] + dp[i-1];
	}
	
	for (int i = 1; i < n; ++i) {
		ans += ((dp[i-1]%INF) * (v[i]%INF)) % INF;
	}
	cout << ans%INF;
	


}



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

using namespace std;

const int N = 2e5 + 5 , MOD = 1e9 + 7;
long long fact[N] , fact_inv[N];

int mul(long long a , long long b) {
    return a * b % MOD;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = mul(r , r);
    if (b&1) return mul(r , a);
    return r;
}

long long mod_inv(long long x) {
    return power(x , MOD - 2);
}

long long nCr(long long n , long long r){
    if (!n) return !r;
    if(r>n) return  0;
    return mul(fact[n] , mul(fact_inv[n - r] , fact_inv[r]));
}

void pre() {
    fact[0] = fact_inv[0] = 1;
    for(int i = 1 ; i < N ;i++) {
        fact[i] = mul(fact[i - 1] , i);
        fact_inv[i] = mod_inv(fact[i]);
    }
}

int add (int a , int b) {
    a += b;
    while (a >= MOD) a -= MOD;
    while (a < 0) a += MOD;
    return a;
}

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

    int n , m , k;
    cin >> n >> m >> k;

    pre();

    int ans = 0;
    for (int i = 1 ;i <= n ;i++) {
        int ways = n - i + 1;
        ways = mul(ways , mul(m , m - (i == 1)));
        ways = mul(ways , nCr(n * 1ll * m - 2 , k - 2));
        ans = add(ans , mul(ways , i - 1));
    }

    for (int i = 1 ;i <= m ;i++) {
        int ways = m - i + 1;
        ways = mul(ways , mul(n , n - (i == 1)));
        ways = mul(ways , nCr(n * 1ll * m - 2 , k - 2));
        ans = add(ans , mul(ways , i - 1));
    }

    cout << ans;
}


Measured memory_bytes: 3964
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d", $A, $B);
fscanf(STDIN, "%s", $S);

$L = $A + 1 + $B;

// echo strlen($S) . PHP_EOL;
// echo $L . PHP_EOL;

$flg = true;

if (strlen($S) != $L) {
    $flg = false;
} else {
    for ($i = 0; $i < $L; $i++) {
        $t = substr($S, $i, 1);
        if ($i == $A) {
            if ($t != '-') {
                $flg = false;
            }
        } else {
            if (!is_numeric($t)) {
                $flg = false;
                break;
            }
        }
    }
}
echo ($flg ? "Yes\n": "No\n");

Measured memory_bytes: 4604
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
const int MOD = (int)1e9 + 7;

vector<int> prime_table(int n) {
    vector<int> is_prime(n + 1);
    if (n) iota(is_prime.begin() + 2, is_prime.end(), 2);
    for (int i = 2; i * i <= n; i++) if (is_prime[i]) {
        for (int j = i + i; j <= n; j += i) is_prime[j] = 0;
    }
    return is_prime;
}

int main() {
    int n; cin >> n;
    auto is_prime = prime_table(n);
    long long ans = 1;
    for (int p = 1; p <= n; p++) if (is_prime[p]) {
        int x = n, cnt_p = 0;
        while (x) cnt_p += (x /= p);
        (ans *= cnt_p + 1) %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;
int main() {
	int N, A, B;
	scanf("%d %d %d", &N, &A,&B);
	printf("%d", (A*N < B ? A * N : B));
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  char s[101];
  scanf("%s", s);

  int n = strlen(s);
  int ok = 1;
  rep(i ,0, n) {
    if (s[i] == s[n-i-1]) continue;
    ok = 0;
    break;
  }
  int max = (n-1)/2;
  rep(i, 0, max) {
    if (s[i] == s[max-i-1]) continue;
    ok =0 ;
    break;
  }
  max = n;
  rep(i, (n+3)/2-1, n) {
    if (s[i] == s[n-i-1]) continue;
    ok = 0;
    break;
  }
  printf(ok ? "Yes\n" : "No\n");
  return 0;
}


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

public class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String s = "";
			String p = "";

			try {
				s = br.readLine();
				p = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}

			s = s + s;
			System.out.println(s.indexOf(p) != -1? "Yes" : "No");
	}
}


Measured memory_bytes: 24352
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int a, b, c, m;
  cin >> a >> b >> c;
  m = max(a,max(b,c));
  cout << m*10+a+b+c-m<< endl;
}

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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if ((a+b)>(c+d)) {
        cout<<"Left"<<endl;
    } else if ((a+b)==(c+d)) {
        cout<<"Balanced"<<endl;
    } else if ((a+b)<(c+d)) {
        cout<<"Right"<<endl;
    }
}


Measured memory_bytes: 256
po = []
t2p = {}
while True:
    t, p = list(map(int, input().strip().split(',')))
    if t==0 and p==0:
        break
    t2p[t] = p
    po.append(p)

ps = sorted(list(set(po)),reverse=True)
while True:
    try:
        q = int(input().strip())
        r = 1
        for i in ps:
            if t2p[q] < i:
                r += 1
            else:
                break
        print(r)

    except EOFError:
        break

Measured memory_bytes: 7668
/*input
1 2 3 4
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a>=d)
    {
        cout<<d<<"\n";
        exit(0);
    }
    if(a+b>=d)
        cout<<a<<"\n";
    else
        cout<<a-(d-(a+b))<<"\n";
}

Measured memory_bytes: 3572
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

insufficient = 0
yoyu = []

ans = 0
for i in range(n):
    p = A[i] - B[i]
    if p < 0:#足りない
        insufficient += abs(p)
        ans += 1
    else:
        yoyu.append(p)
yoyu.sort(reverse=True)

if sum(yoyu) < insufficient:
    print(-1)
    exit()

ind = 0    
while insufficient > 0:
    insufficient -= yoyu[ind]
    ind += 1

print(ans+ind)

Measured memory_bytes: 97896
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
 
using namespace std;

template <typename T>
class UF{
public:
	vector<T> par,rank;

	UF(long long n){
		par.resize(n);
		rank.resize(n);
		for(T i=0;i<n;i++){
			par[i]=i;
			rank[i]=0;
		}
	}

	T find(T x){
		if(par[x]==x)
			return x;
		else
			return par[x]=find(par[x]);
	}

	void unite(T x, T y){
		x=find(x);
		y=find(y);
		if(x==y) return;

		if(rank[x]<rank[y])
			par[x]=y;
		else{
			par[y]=x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(T x, T y){
		return find(x)==find(y);
	}

};

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

int main()
{
	int h,w,c;
	while(cin>>h>>w>>c,h){

		vector<vector<int> > table(h,vector<int>(w,0)),table2;




		for(int i=0;i<h;i++){	
			for(int j=0;j<w;j++) cin>>table[i][j];
		}
				
		table2=table;
		
		//cout<<"init end"<<endl;
		
		long long res=0;
		//4????±???????
		for(long long bit=0;bit<6LL*6LL*6LL*6LL;bit++){
			
			table=table2;
			UF<long long> uf(1000);
			
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					
					for(int k=0;k<4;k++){
						int ny=i+dy[k],nx=j+dx[k];
						if(0<=ny && ny<h && 0<=nx && nx<w && table[i][j]==table[ny][nx]){
							uf.unite(i*w+j,ny*w+nx);
						}
					}
					
				}
			}
			

			long long x=bit;
			
			//???????????????
			vector<int> vc(5);
			for(int i=0;i<4;i++){
				vc[i]=x%6;
				vc[i]++;
				x/=6;
			}
			//??????????????????
			vc[4]=c;
						
			//cout<<"set order"<<endl;
						
			for(int i=0;i<5;i++){

				//?????´??°
				for(int j=0;j<h;j++){
					for(int k=0;k<w;k++){
						if(uf.same(0,j*w+k)){
							table[j][k]=vc[i];
						}
					}
				}
				
				//???????????????
				for(int j=0;j<h;j++){
					for(int k=0;k<w;k++){
						
						if(uf.same(0,j*w+k)){
							
							for(int d=0;d<4;d++){
								int ny=j+dy[d],nx=k+dx[d];
								if(0<=ny && ny<h && 0<=nx && nx<w && table[j][k]==table[ny][nx]){
									uf.unite(ny*w+nx,0);
								}
							}
							
						}
						
					}
				}
								

			}

			long long cnt=0;
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					//(0,0)??¨??????????????????
					if(uf.same(j*w+k,0)) cnt++;
				}
			}
				
			if(res<cnt){
				//cout<<bit<<endl;
				res=cnt;
/*				
				for(int i=0;i<h;i++){
					for(int j=0;j<w;j++) cout<<table[i][j]<<" ";
					cout<<endl<<endl;
				}
*/				
			}
			
		}

		cout<<res<<endl;

	}

	

	return 0;
}

Measured memory_bytes: 1244
#include<iostream>
using namespace std;
int main()
{
    char c; cin >> c;

    if(c>='A' && c<='Z')
        cout << "A\n";
    else
        cout << "a\n";











    #ifdef TarekHasan
        main();
    #endif // TarekHasan

    return 0;
}


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

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
    }
    double ans;
    
    sort(v.begin(), v.end(), greater<>());
    for (int i = 1; i < N; i++)
    {
        v[N-i-1] = (v[N-i] + v[N-i-1]) / 2;
        v.pop_back();
        sort(v.begin(), v.end(), greater<>());
    }
    
    ans = v[0];
    cout << std::fixed << std::setprecision(15) << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3692
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt64(scanner)
	var i int64
	ans := map[int64]int{}
	ans[n] = 1
	if n > 2 {
		ans[n-1] = 1
	}
	for i = 2; i*i <= n; i++ {
		if do(i, n) == 1 {
			ans[i] = 1
		}
	}

	for i = 2; i*i < n; i++ {
		if (n-1)%i == 0 {
			ans[i] = 1
			ans[(n-1)/i] = 1
		}
	}

	fmt.Fprintln(writer, len(ans))
}

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

	return gcd(b, a%b)
}
func do(i, n int64) int64 {
	if i > n {
		return n
	}
	if n%i == 0 {
		return do(i, n/i)
	}
	g := gcd(i, n)
	a := i / g
	b := n / g
	return do(i, g*(b%a))
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

class combination
{
public:
  vector<ll> fac, finv, inv;

  combination(ll M)
  {
    fac = vector<ll>(M, 1);
    finv = vector<ll>(M, 1);
    inv = vector<ll>(M, 1);

    for (ll i = 2; i < M; i++)
    {
      fac.at(i) = fac.at(i - 1) * i % MOD;
      inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
      finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
  }

  ll P(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * finv.at(N - K) % MOD;
  }

  ll C(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * (finv.at(K) * finv.at(N - K) % MOD) % MOD;
  }

  ll H(ll N, ll K)
  {
    return C(N + K - 1, K);
  }
};

ll modinv(ll a, ll m)
{
  ll b = m, x = 1, y = 0;
  while (b > 0)
  {
    ll q = a / b, r = a - q * b, s = x - q * y;
    a = b, b = r;
    x = y, y = s;
  }
  return mod(x, m);
}

ll modpow(ll a, ll n, ll m)
{
  ll ret = 1;
  while (n > 0)
  {
    if (n % 2 == 1) ret = ret * a % m;
    a = a * a % m;
    n /= 2;
  }
  return ret;
}

int main()
{
  ll N;
  cin >> N;
  vector<ll> X(N, 0);
  ll Amax = 0;
  for (ll i = 0; i < N; i++)
  {
    ll A;
    cin >> A;
    chmax(Amax, A);
    if (i == 0 && A != 0)
      FINALANS(0);
    if (i != 0 && A == 0)
      FINALANS(0);
    X.at(A)++;
  }

  combination com(N + 10);

  ll ans = 1;
  for (ll i = 1; i <= Amax; i++)
  {
    ans *= modpow(X.at(i - 1), X.at(i), MOD);
    ans %= MOD;

    //cerr << i << " " << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    ans=min(n,m/2);
    n-=ans;
    m-=ans*2;
    if(m){
        ans+=m/4;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
struct Edge{int x,y;};
int n,m;
int x[666];
int y[666];
std::vector<Edge>ans;
int main(){
	scanf("%d",&n),m=(n+1)>>1;
	if(n&1){
		for(int i=1;i<m;++i)
			x[i]=i,y[i]=n-i;
		x[m]=n,y[m]=0;
	}else
		for(int i=1;i<=m;++i)
			x[i]=i,y[i]=n-i+1;
	for(int i=1;i<m;++i)
		for(int j=i+1;j<=m;++j)
			if(y[j]){
				ans.push_back((Edge){x[i],x[j]});
				ans.push_back((Edge){x[i],y[j]});
				ans.push_back((Edge){y[i],x[j]});
				ans.push_back((Edge){y[i],y[j]});
			}else {
				ans.push_back((Edge){x[i],x[j]});
				ans.push_back((Edge){y[i],x[j]});
			}
	std::cout<<ans.size()<<"\n";
	for(size_t i=0;i<ans.size();++i)
		printf("%d %d\n",ans[i].x,ans[i].y);
	return 0;
}


Measured memory_bytes: 384
#input
X, N = map(int, input().split())
p = list(map(int, input().split()))

if len(p) == 0 or X < min(p) or X > max(p):
    print(X)
    exit()

min = X
max = X
while True:
    if min not in p:
        print(min)
        break
    elif max not in p:
        print(max)
        break
    else:
        min -= 1
        max += 1


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    set<int> st;
    int q,a,b;
    cin >> q;
    for (int i=0;i<q;i++) {
        cin >> a >> b;
        if ( a==0 ) {
            st.insert(b);
            cout << st.size() << endl;
        } else if ( a==1 ) {
            auto itr = st.find(b);
            if (itr!=st.end()) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        } else if ( a==2 ) {
            st.erase(b);
        }
    }
}



Measured memory_bytes: 12452
#include <iostream> // cout, endl, cin
#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;
#define int long long


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

    int q; cin >> q;
    vector<int> l(q),r(q);
    for(int i = 0;i < q;i ++){
        cin >> l.at(i) >> r.at(i);
    }  
    for(int i = 0;i < q;i ++){
        if(l.at(i) < 3) l.at(i) = 3;
    }

    vector<int> sosu(100001),sosunomi(1,2);
    for(int i = 3;i < 100001;i += 2){
        for(int j = 0;j < sosunomi.size();j ++){
            if(i % sosunomi.at(j) == 0){
                break;
            }
            if(sosunomi.at(j) > i/2){
                sosu.at(i) = 1;
                sosunomi.push_back(i);
                break;
            }
        }
    }  

    sosu.at(2) = 1;

    vector<int> a(100001);
    for(int i = 0;i < 100001;i ++){
        if(sosu.at(i) && sosu.at((i+1) / 2)){
            a.at(i) = 1;
        }
    }
    a.at(2) = 1;

    vector<int> sum(100001);
    for(int i = 1;i < 100001;i ++){
        sum.at(i) = sum.at(i-1) + a.at(i);
    }

    for(int i = 0;i < q;i ++){
        cout << sum.at(r.at(i)) - sum.at(l.at(i) - 1) << endl;
    }
}

Measured memory_bytes: 4736
import java.io.*;
import java.util.*;

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;

    public void go() throws IOException
    {
        ntok();
        int n = ipar();
        ntok();
        ArrayList<int[]> list = new ArrayList<>();
        for (int i = 0; i < n; i++)
        {
            list.add(new int[]{ipar(), i});
        }
        Collections.sort(list, (a, b) -> Integer.compare(a[0], b[0]));
        for (int i = 0; i < n; i++)
        {
            if (i != 0)
            {
                out.print(" ");
            }
            out.print(list.get(i)[1]+1);
        }
        out.println();

        out.flush();
        in.close();
    }

    public void ntok() throws IOException
    {
        tok = new StringTokenizer(in.readLine());
    }

    public int ipar()
    {
        return Integer.parseInt(tok.nextToken());
    }

    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar()
    {
        return Long.parseLong(tok.nextToken());
    }

    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }

    public String spar()
    {
        return tok.nextToken();
    }

    public static void main(String[] args) throws IOException
    {
        new Main().go();
    }
}


Measured memory_bytes: 45552
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

vector<ll> enum_divisor(ll m) {
  vector<ll> divisors;
  for (ll i = 1; i*i <= m; ++i) {
    if (m % i != 0) continue;
    divisors.push_back(i);
    if (i * i != m) divisors.push_back(m / i);
  }
  return divisors;
}

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

  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  ll ans = INFL;
  for (int i = -100; i <= 100; i++) {
    ll tmp = 0;
    for (int v : a) tmp += (v - i) * (v - i);
    chmin(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
using namespace std;
typedef vector<int> poly;
typedef long long ll;
#define pb push_back
#define rez resize
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  char ch=gc();
  while(!isdigit(ch)) ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return ans;
}
namespace modular {
  const int mod=998244353;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
  inline int Inv(int a) { return ksm(a,mod-2); }
} using namespace modular;
const int N=5e5+5;
int n,m,fac[N],ifac[N],pwn[N],pwm[N];
inline void init_fac(int lm=0) {
  lm=max(n,m),fac[0]=fac[1]=ifac[0]=ifac[1]=1;
  for(ri i=2;i<=lm;++i) fac[i]=mul(fac[i-1],i);
  ifac[lm]=Inv(fac[lm]);
  for(ri i=lm-1;i>1;--i) ifac[i]=mul(ifac[i+1],i+1);
  pwn[0]=1;
  for(ri i=1;i<=m;++i) pwn[i]=mul(pwn[i-1],n+1);
  pwm[0]=1;
  for(ri i=1;i<=n;++i) pwm[i]=mul(pwm[i-1],m+1);
}
inline int C(int n,int m) { return n<m||m<0?0:(ll)fac[n]*ifac[m]%mod*ifac[n-m]%mod; }
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=read(),m=read(),init_fac();
  int res=0;
  for(ri t,i=0;i<=n&&i<=m;++i) {
    t=mul(mul(C(n,i),C(m,i)),mul(pwn[m-i],pwm[n-i]));
    (i&1?Dec:Add)(res,mul(fac[i],t));
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 8064
n,m,q=gets.split.map(&:to_i)
imos=Array.new(n+2){Array.new(n+2,0)}
m.times{
  l,r=gets.split.map(&:to_i)
  imos[1][r]+=1
  imos[1][n+1]-=1
  imos[l+1][r]-=1
  imos[l+1][n+1]+=1
}
1.upto(n){|i|1.upto(n){|j|
  imos[i][j]+=imos[i][j-1]
}}

1.upto(n){|j|1.upto(n){|i|
  imos[i][j]+=imos[i-1][j]
}}

q.times{
  x,y=gets.split.map(&:to_i)
  puts imos[x][y]
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> perm;
	int x;
	for(int i = 0; i < n; i ++){
		cin >> x;
		perm.push_back(x);
	}
	int contador = 0;
	for(int i = 1; i < n - 1; i++) {
		if(((perm[i] > perm[i-1]) && (perm[i] < perm[i+1])) || ((perm[i] > perm[i+1]) && (perm[i] < perm[i-1]))) contador++;
	}
	cout << contador;
	return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == s[i + 1]) {
      cout << i + 1 << ' ' << i + 2 << '\n';
      return 0;
    }
  }
  for (int i = 0; i < n - 2; i++) {
    if (s[i] == s[i + 2]) {
      cout << i + 1 << ' ' << i + 3 << '\n';
      return 0;
    }
  }
  cout << "-1 -1\n";
  return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    string s, t;
    cin >> s >> t;

    map<char, char> m, mm;

    const int n = s.size();

    bool ans = true;

    for (int i = 0; i < n; i++) {
        const char ss = s[i], tt = t[i];

        if (m.find(tt) == m.end()) {
            m[tt] = ss;
        } else if (m[tt] != ss) {
            ans = false;
            break;
        }

        if (mm.find(ss) == mm.end()) {
            mm[ss] = tt;
        } else if (mm[ss] != tt) {
            ans = false;
            break;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 916
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//https://www.youtube.com/watch?v=RDaGj_ztNz4&feature=youtu.be

//-----CODE------//
void solve(void)
{
  int n;
  cin>>n;
  vector<int> a (n,0);
  for (int i = 0; i < n; i++)
  {
     cin>>a[i];
  }
  vector<vector<int> > dp (n+1,vector<int>(4,-1*INF));
  dp[0][0] = 0;
  int k = 1 +n%2;

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < k+1; j++)
    {
      chmax(dp[i+1][j+1],dp[i][j]);
      int now = dp[i][j];
      if((i+j)%2 == 0) now += a[i];
      chmax(dp[i+1][j],now);
    }
    
  }
  cout<<dp[n][k]<<endl;
  
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 18740
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int in[101010], cnt[101010], pairs[101010], alone[1010110];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> in[i];
    cnt[in[i] % m]++;
    if (alone[in[i]]) {
      pairs[in[i] % m]++;
    }
    alone[in[i]] ^= 1;
  }
  int ans = 0;
  for (int x = 0; x < m; x++) {
    int y = (m - x) % m;
    if (x < y) continue;
    if (x == y) {
      ans += cnt[x] / 2;
    } else {
      int u = x, v = y;
      if (cnt[u] < cnt[v]) {
        swap(u, v);
      }
      int over = cnt[u] - cnt[v];
      if (pairs[u] * 2 >= over) {
        ans += (cnt[u] + cnt[v]) / 2;
      } else {
        ans += pairs[u] + cnt[v];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3712
process.stdin.resume();
process.stdin.setEncoding('utf8');

var input_lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

let count5 = 0; 
  let count7 = 0; 
  let result = 'NO'
reader.on('line', (line) => {
  input_lines = line.split(" ")
  
  

  if(input_lines[0] == 5) {
      count5++
  }
  if(input_lines[0] == 7) {
      count7++
  }
  
  if(input_lines[1] == 5) {
      count5++
  }
  if(input_lines[1] == 7) {
      count7++
  }
  
  if(input_lines[2] == 5) {
      count5++
  }
  if(input_lines[2] == 7) {
      count7++
  }
  
  if(count7 == 1 && count5 == 2) {
    result = 'YES'
  }
  
});


/* ーーーー入力ーーーー
ここに書くコードを変える


　 ーーーー出力ーーーー */
reader.on('close', () => {
  console.log(result);
});


Measured memory_bytes: 30720
use proconio::input;
use rand::prelude::*;
use std::collections::BTreeSet;
use std::time::Instant;
fn main() {
    let start = Instant::now();
    let mut rng = thread_rng();
    let info = Info::read();
    let mut contest = Vec::new();
    for _ in 0..info.day {
        let next = (0..26).max_by_key(|&c| {
            contest.push(c);
            let key = info.score(&contest);
            contest.pop();
            key
        });
        contest.push(next.unwrap());
    }
    let mut state = State::from(&info, contest);
    let mut max_score = state.score;
    while start.elapsed().as_millis() < 1950 {
        let date = rng.gen_range(0, info.day);
        let contest = rng.gen_range(0, 26);
        let oldcont = state.contest[date];
        state.update(&info, date, contest);
        if state.score > max_score {
            max_score = state.score;
        } else {
            state.update(&info, date, oldcont);
        }
    }
    for contest in state.contest {
        println!("{}", contest + 1);
    }
    eprintln!("time {}", start.elapsed().as_millis());
    eprintln!("score {}", state.score);
}
impl State {
    fn from(info: &Info, contest: Vec<usize>) -> Self {
        let mut date = vec![BTreeSet::new(); 26];
        for (d, &contest) in contest.iter().enumerate() {
            date[contest].insert(d + 1);
        }
        let score = info.score(&contest);
        Self { contest, date, score }
    }
    fn update(&mut self, info: &Info, date: usize, contest: usize) {
        let date1 = date + 1;
        let oldcont = self.contest[date];
        self.contest[date] = contest;
        let remove_loss = |contest: usize| {
            let &prev = self.date[contest].range(..date1).next_back().unwrap_or(&0);
            let &next = self.date[contest].range(date1 + 1..).next().unwrap_or(&(info.day + 1));
            let loss = |a, b| ((b - a) * (b - a - 1) / 2) as i32;
            let loss = loss(prev, next) - loss(prev, date1) - loss(date1, next);
            info.dec[contest] * loss
        };
        self.score -= remove_loss(oldcont) - remove_loss(contest);
        self.score += info.inc[date][contest] - info.inc[date][oldcont];
        self.date[oldcont].remove(&date1);
        self.date[contest].insert(date1);
    }
}
impl Info {
    fn read() -> Self {
        input!(day: usize, dec: [i32; 26], inc: [[i32; 26]; day]);
        Self { day, dec, inc }
    }
    fn score(&self, contest: &[usize]) -> i32 {
        let mut last = vec![0; 26];
        contest.iter().enumerate().fold(0, |score, (date, &contest)| {
            last[contest] = date + 1;
            (0..26).fold(score + self.inc[date][contest], |score, contest| {
                score - self.dec[contest] * (date + 1 - last[contest]) as i32
            })
        })
    }
}
struct State {
    contest: Vec<usize>,
    date: Vec<BTreeSet<usize>>,
    score: i32,
}
struct Info {
    day: usize,
    dec: Vec<i32>,
    inc: Vec<Vec<i32>>,
}


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

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

    vector<int> divs = {};
    for (int i = 1; i <= sqrt(m); i++) {
        if (m % i != 0) continue;
        divs.push_back(i);
        divs.push_back(m / i);
    }

    int gcdmax = -1;
    rep(i, divs.size()) {
        int md = m / divs[i];
        if (n > md) continue;
        gcdmax = max(divs[i], gcdmax);
    }

    cout << gcdmax << endl;
}

Measured memory_bytes: 3704
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
    int n,m;
    cin >> n >> m;
    if(n==m){
        cout << (2*n);
    }
    else{
        n = max(n,m);
        cout << (2*n-1);
    }
    
   
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int X, t;
    cin >> X >> t;
    cout << max(X-t,0) << endl;
}


Measured memory_bytes: 3624
### main

loop do
  n = gets.strip.to_i
  break if n == 0

  poles = []
  parents = n.times.map{[]}
  fixed = n.times.map{0}

  for i in (0...n)
    p, q, r, b = gets.strip.split(' ').map{|s| s.to_i}
    g = p.gcd(q)
    r -= 1
    b -= 1
    poles << [p / g, q / g, r, b]

    if r >= 0
      parents[r] << i
    else
      fixed[i] += 1
    end

    if b >= 0
      parents[b] << i
    else
      fixed[i] += 1
    end
  end
  #p poles
  #p parents
  #p fixed

  min_w = nil
  min_ws = []
  queue = (0...n).select{|i| fixed[i] == 2}.to_a

  while ! queue.empty?
    i = queue.shift
    p, q, r, b = poles[i]

    if r < 0
      if b < 0
        min_ws[i] = p + q
      else
        ## p * wr == q * wb (wr = nr * mwr, wb = nb * mwb)
        ## l = lcm(p, q * mwb) ->
        ## wr = l / p, wb = l / q
        ## wr + wq = l/p + l/q
        l = p.lcm(q * min_ws[b])
        min_ws[i] = l / p + l / q
      end
    else
      if b < 0
        l = q.lcm(p * min_ws[r])
        min_ws[i] = l / p + l / q
      else
        l = (p * min_ws[r]).lcm(q * min_ws[b])
        min_ws[i] = l / p + l / q
      end
    end
    #puts "#{i} -> #{min_ws[i]}"

    min_w = min_ws[i]

    for j in parents[i]
      fixed[j] += 1
      if fixed[j] == 2
        queue << j
      end
    end
  end
  #p min_ws

  puts min_w
end

Measured memory_bytes: 6168
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll gcd(long long a,long long b) {
    return b ? gcd(b,a%b) : a;
}

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

int main(){
    ll n,k,r,s,p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;

    vector<char> history;
    long long max = 0;

    for (int i = 0;i < t.size();i++){
        const char c = t[i];
        if (i < k){
            if (c == 'r'){
                max += p;
                history.push_back('p');
            }
            else if ( c == 's'){
                max += r;
                history.push_back('r');
            }
            else if (c == 'p'){
                max += s;
                history.push_back('s');
            }
        }
        else {
            if (c == 'r'){
                if (history[i-k] == 'p'){
                    if ((i+k) < n && t[i+k] != 's'){
                        history.push_back('r');
                    }
                    else {
                        history.push_back('s');
                    }
                }
                else {
                    max += p;
                    history.push_back('p');
                }
            }
            else if (c == 's'){
                if (history[i-k] == 'r'){
                    if ((i+k) < n && t[i+k] != 'p'){
                        history.push_back('s');
                    }
                    else {
                        history.push_back('p');
                    }
                }
                else {
                    max += r;
                    history.push_back('r');
                }
            }
             else if (c == 'p'){
                if (history[i-k] == 's'){
                    if ((i+k) < n && t[i+k] != 'r'){
                        history.push_back('p');
                    }
                    else {
                        history.push_back('r');
                    }
                }
                else {
                    max += s;
                    history.push_back('s');
                }
            }
        }

    }

    cout << max << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    ll ans = 1;
    for (ll x = 1; x * x <= M; x++) {
        if ((M - (N - 1) * x) > 0 && (M - (N - 1) * x) % x == 0) {
            ans = max(ans, x);
        }
        if (M % x == 0) {
            ll y = M / x;
            if ((M - (N - 1) * y) > 0 && (M - (N - 1) * y) % y == 0) {
                ans = max(ans, y);
            }
        }
    }
    cout << ans << '\n';
}

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


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

using namespace std;

void printVec(vector<int> v, string delim)
{
  for (int i = 0; i < v.size() - 1; i++)
    cout << v[i] << delim;
  cout << v[v.size() - 1] << endl;
}

vector<int> shellSort(vector<int> v, int size)
{
  int count = 0;
  int m = 1;
  vector<int> g = {1};
  while (g[0] * 3 + 1 < size)
  {
    g.insert(g.begin(), g[0] * 3 + 1);
    m++;
  }

  // print m and g[]
  cout << g.size() << endl;
  printVec(g, " ");

  for (int i = 0; i < m; i++)
  {
    // insertion sort
    for (int j = 0; j < size; j++)
    {
      // int head = v[0];
      int h = g[i];
      for (int k = j - h; k >= 0; k -= h)
        if (v[k] > v[k + h])
        {
          swap(v[k], v[k + h]);
          count++;
        }
        else
          break;
    }
  }

  cout << count << endl;
  return v;
}

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  printVec(shellSort(a, n), "\n");
  return 0;
}

Measured memory_bytes: 10812
#include <bits/stdc++.h>
#include <ctime>
#define rep(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef unsigned long long ll;
inline int cine() {int a; return scanf("%d", &a) ? a : 1e9;}


void solve() {
    int train, bus, mine = 1e9, sum = 0 ;
    rep(i, 0, 2) {
        cin >> train;
        mine = min(mine, train);
    }
    sum += mine;
    mine = 1e9;
    rep(i, 0, 2) {
        cin >> bus;
        mine = min(mine, bus);
    }
    sum += mine;
    cout << sum;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();
#ifndef ONLINE_JUDGE
    cout << "\nTime Elapsed :" << 0.1 * clock() / CLOCKS_PER_SEC << "s\n";
#endif
}

Measured memory_bytes: 3644
while 1:
    try:
        s = input()
        t = ''
        i = 0
        while i < len(s):
            if s[i] == '@':
                t += s[i + 2] * int(s[i + 1])
                i += 3
            else:
                t += s[i]
                i += 1
        print(t)
    except:
        break



Measured memory_bytes: 5596
N, T = map(int, input().split())
A = [0] * T
B = [0] * T
for _ in range(N):
    a, b = map(int, input().split())
    for i in range(T)[::-1]:
        if i + a < T:
            A[i+a] = max(A[i+a], A[i] + b)
            B[i+a] = max(B[i+a], B[i] + b)
        B[i] = max(B[i], A[i] + b)
print(max(B))

Measured memory_bytes: 48732
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#define LL long long
#define mk make_pair
#define pb push_back
#define pii pair<int, int>
#define ArrayDebug(a, l, r) for(int i = l; i <= r; ++i) printf("%d%c", a[i], (i==r)?'\n':' ')
const int maxn = 2e1+7;
const LL mod = 998244353;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double EPS = 1e-8;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;

int n, m, ans;
int s[10], c[10];
char ss[10];
bool flag = true;

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; ++i) {
        scanf("%d%d", &s[i], &c[i]);
        if(!isdigit(ss[s[i]]) || ss[s[i]] == c[i] + '0')ss[s[i]] = c[i]+'0';
        else flag = false;
    }
    if(ss[1] == '0' && n > 1) flag = false;
    if(!flag) {
        printf("-1\n");
        return 0;
    }
    for(int i = 1; i <= n; ++i) {
        if((!isdigit(ss[i]) && i > 1) || (!isdigit(ss[i]) && i == 1 && n == 1)) ss[i] = '0';
        else if(!isdigit(ss[i]) && i == 1) ss[i] = '1';
    }
    // cout << "ss " << ss << endl;
    for(int i = 1; i <= n; ++i) ans = ans * 10 + ss[i] - '0';
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long llong;
#define rep(i, n) for (int i = 0; i < n; ++i)
char gf[1200][1200];
int main()
{
    int n;
    scanf("%d", &n);
    if (n < 3)
        printf("-1");
    else if (n == 3)
        printf("z..\nz..\n.zz");
    else if (n == 7)
        printf("a..bbaa\na...abb\n.az.a..\n.az..a.\n..azza.\nbba...a\naabb..a");
    else
    {
        int rn = n;
        if (n & 1)
            rn -= 5;
        for (int i = 0; i < rn; i += 2)
            gf[i][i] = gf[i + 1][i] = 'a',
            gf[i][i + 1] = gf[i + 1][i + 1] = 'b';
        for (int i = 2; i < rn; i += 2)
            gf[i][i - 2] = gf[i][i - 1] = 'c',
            gf[i + 1][i - 2] = gf[i + 1][i - 1] = 'd';
        gf[0][rn - 2] = gf[0][rn - 1] = 'c';
        gf[1][rn - 2] = gf[1][rn - 1] = 'd';
        if (n & 1)
            strcpy(&gf[rn][rn], "aabba"),
            strcpy(&gf[rn + 1][rn], "bz..a"),
            strcpy(&gf[rn + 2][rn], "bz..b"),
            strcpy(&gf[rn + 3][rn], "a.zzb"),
            strcpy(&gf[rn + 4][rn], "abbaa");
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
                if (gf[i][j])
                    printf("%c", gf[i][j]);
                else
                    printf(".");
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S; cin >> S;
  cout << ((S[2]==S[3]&&S[4]==S[5]) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    long long sum=3;
    scanf("%d",&n);
    if(n==1) sum=1;
    else if(n==2) sum=2;
    else
        {
           while(n>2)
           {
               if(n%3!=0&&n%5!=0)
                 sum+=n;
               n--;
           }
        }
        printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;

int main() {
	int n; cin >> n;
	string a, b, c; cin >> a >> b >> c;

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		map<char, int>check;
		check[a[i]]++;
		check[b[i]]++;
		check[c[i]]++;
		int tmp = max({ check[a[i]],check[b[i]],check[c[i]] });

		if (tmp == 3);
		else if (tmp == 2)ans++;
		else if (tmp == 1)ans += 2;
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
	int A,B;
	cin >> A >> B;
	int count = 0;
	int num = 1;
	while ( num < B){
		count ++;
		num = count * A - count + 1;	
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256