akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a * b, c) << endl;
}

Measured memory_bytes: 3604
while True:
    x,y=map(int,input().split())
    if x==0 and y==0:
        break
    
    ans=0
    while True:
        if y==0:
            break
        if x<y:
            x,y=y,x
        x=x%y
        x,y=y,x
        ans+=1
    
    print(x,ans)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define rFORq(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
    int N,A,T;
    SCD3(N,T,A);
    vector<int> H;
    int ans = -1;
    int diff = 1000000;

    REP(i,N){
        int h; SCD(h);
        H.PB(h);
    }

    REP(i,N){
        if (diff>abs(1000*A - (1000*T - 6*H[i]))){
            diff = abs(1000*A - (1000*T - 6*H[i]));
            ans = i;
        }

    }

    PRINTD(ans+1);
}

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

using namespace std;
#define INP "solve"
#define OUT "solve"
const int QQ = 3e5 + 10;
const int maxN = 1e5 + 10;
const int maxM = 1e6 + 10;
const int oo = 1e9;
const int module = 1e9 + 7;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

void solve() {
    int L, R;
    cin >> L >> R;
    if (R - L + 1 <= 2019) {
        int Res = 2019;
        for (int i = L; i <= R; i++) {
            for (int j = i + 1; j <= R; j++) {
                int x = 1LL * i * j % 2019;
                Res = min(Res, x);
            }
        }
        cout << Res;
    }
    else {
        cout << 0;
    }
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


Measured memory_bytes: 256
using System;

namespace ITP1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string testNum = "";

            for (int i = 1; ; i++)
            {
                testNum = Console.ReadLine();
                if (int.Parse(testNum) != 0)
                {
                    Console.WriteLine("Case " + i + ": " + testNum);
                }
                else
                {
                    break;
                }
            }
        }
    }
}



Measured memory_bytes: 17920
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int ans = 0;
        int last = 10;
        for(int i = 0; i < 5; i++){
            int input = sc.nextInt();
            ans += (input - 1) / 10 + 1;
            if(input % 10 != 0){
                if(last == 0)last = input % 10;
                else last = Math.min(last, input % 10);
            }
        }
        ans *= 10;
        ans -= 10 - last;
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >>N;
  vector<int> A,B,C;
  for(int i=0; i<3; i++){
    for(int j=0; j<N; j++){
      int x;
      cin >>x;
      if(i==0) A.push_back(x);
      if(i==1) B.push_back(x);
      if(i==2) C.push_back(x);
    }
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  long long ans=0;
  for(int i=0; i<N; i++){
    auto IT1=lower_bound(A.begin(), A.end(), B[i]);
    long long a=IT1-A.begin();
    auto IT2=upper_bound(C.begin(), C.end(), B[i]);
    long long c=C.end()-IT2;
    ans+=a*c;
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define sz(x) (ll)(x).size()
#define all(x) x.begin(), x.end()
#define modulo 998244353ll



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<nl;
} 


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


namespace Test1 {

    


    class ClassMain {

       


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = int.Parse(line);
                if(n==0){break;}
                int[] dolls = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int kijiP = dolls[0];
                int toppingP = dolls[1];
                int kijiCal = int.Parse(Console.ReadLine());
                int[] toppingCal = new int[n];
                for (int i = 0; i < n; i++) {
                    toppingCal[i] = int.Parse(Console.ReadLine());
                }
                Array.Sort(toppingCal);
                Array.Reverse(toppingCal);
                int maxRatio = kijiCal / kijiP;

                int currentCal = kijiCal;
                int currentP = kijiP;
                for (int i = 0; i < n; i++) {
                    currentCal += toppingCal[i];
                    currentP += toppingP;
                    if (maxRatio < currentCal / currentP) { maxRatio = currentCal / currentP; }
                    
                }


                Console.WriteLine(maxRatio);
                break;
            }
        }

        
    }



    
}

Measured memory_bytes: 6044
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e5+5;

ll par[N];

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

void unio(ll a,ll b){
  a=find(a),b=find(b);
  par[a]=b;
}


int main()
{ 

IOS;

ll a,b;cin>>a>>b;

if(a>=10||b>9)cout<<-1<<endl;
else cout<<a*b<<endl;

return 0;
 
}


Measured memory_bytes: 3664
require 'prime'
primes = Hash.new(0)

n = gets.to_i
(2..n).each do |i|
  i.prime_division.each do |num, pow|
    if primes[num]
      primes[num] += pow
    end
  end
end
multi = 1
primes.each do |key, value|
  multi *= (value + 1)
end

puts multi % (10 ** 9 + 7)

Measured memory_bytes: 2428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String s = sc.nextLine();
		String[] spl = s.split(" ");
		int[] p = new int[N];
		for(int i = 0;i < N;i++) {
			p[i] = Integer.parseInt(spl[i]);
		}
		sc.close();
		int cnt = 0;
		for(int i = 0;i < N;i++) {
			if(p[i] != i + 1) {
				cnt++;
			}
		}
		System.out.println(cnt < 3 ? "YES" : "NO");
	}
}

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

#define mp make_pair
#define pb push_back
#define x first
#define y second
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int inf = INT_MAX;
const LL INF = LLONG_MAX;

template <typename T> inline int chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + (ch - '0');
	return sum * fl;
}

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;

int N;
int A[maxn];

inline int Pow (int a, int b, int ans = 1)
{
	for (; b; b >>= 1, a = (LL)a * a % mod) if (b & 1) ans = (LL)ans * a % mod;
	return ans;
}

int inv[maxn];

inline void add (int &x, int y) { x = x + y >= mod ? x + y - mod : x + y; }

inline void solve ()
{
	for (int i = 1; i <= N; ++i) inv[i] = Pow (i, mod - 2);

	int now = 0, Ans = 0;
	for (int i = 1; i <= N; ++i) add (now, inv[i]);
	for (int i = 1; i <= N; ++i)
	{
		add (Ans, (LL)A[i] * now % mod);
		add (now, inv[i + 1]); add (now, mod - inv[N - i + 1]);
	}

	for (int i = 1; i <= N; ++i) Ans = (LL)Ans * i % mod;
	printf ("%d\n", Ans);
}

inline void input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) A[i] = read<int>();
}

int main ()
{


	input ();
    solve ();

    return 0;
}



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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

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

int main(void)
{
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << endl;
    return 0;
}

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

typedef long long int ll;

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

    ll t = 1, ans = 0;
    for(ll i = 0;i < a.size();i++){
        if(a[i] == t){
            t++;
        }
        else{
            ans++;
        }
    }

    if(t == 1){
        cout << -1;
    }
    else{
        cout << ans;
    }

    return 0;
}

Measured memory_bytes: 1792
def P(p):
    if p%2==0:
        return False
    for i in range(3,int(p**0.5//1+1),2):
        if p%i==0:
            return False
    return True

def main():
    N = int(input())
    p = [2,3,5]
    for i in range(7, 55555):
        if P(i):
            p.append(i)

    ans = [3,]
    for i in range(5, len(p)):
        if str(p[i])[-1] in "3":
            ans.append(p[i])
        if len(ans)==N:
            return " ".join(map(str, ans))
    return p

if __name__ == '__main__':
    print(main())


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

int main()
{
    int N, T, mn = 1000000009;
    cin >> N >> T;
    while (N--)
    {
        int c, t;
        cin >> c >> t;
        if (t <= T && c < mn)
            mn = c;
    }

    if (mn == 1000000009)
        cout << "TLE" << endl;
    else
    {
        cout << mn << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n=int(arr_data[0][0])

print("Hello World" if n==1 else int(arr_data[1][0])+int(arr_data[2][0]))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

ll S;
ll bits[10];

ll ans = 0;

int main() {
  cin >> S;

  ll temp = S;
  int count = 0;

  while (temp > 0) {
    bits[count] = temp % 10;
    temp /= 10;
    ++count;
  }

  int lim = count - 1;

  for (int i = 0; i < (1 << lim); ++i) {

    ll digits = 1;
    for (int j = 0; j < count; ++j) {

      ans += bits[j] * digits;
      if (j == count - 1) break;

      if ((i >> j) & 1) {
        digits = 1;
      } else {
        digits *= 10;
      }

    }

  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    return 0;
}

Measured memory_bytes: 3524
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
  const int MOD = 1000000007;
  
  int n, m;
  cin >> n >> m;
  if(n < m) swap(n, m);
  
  if(n - m >= 2)
  {
	cout << 0 << endl;
  }
  else
  {
	ll ans = 1;
	if(n - m == 1) ans *= n;
	else ans *= 2;

	for(int i = 1; i <= m; i++)
	{
	  ans *= i;
	  ans %= MOD;
	  ans *= i;
	  ans %= MOD;
	}
	cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
N,D=map(int,input().split())
L=[]
for i in range(N):
    x=list(map(int,input().split()))
    L.append(x)
#print(L)
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        cnt=0
        for k in range(D):
            cnt+=(L[i][k]-L[j][k])**2
        if pow(cnt,0.5)==int(pow(cnt,0.5)):
            ans+=1
print(ans)

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextInt();
		sc.nextInt();
		int N = sc.nextInt();
		int wcnt= 0;
		int[] now = new int[2];
		int[] to = new int[2];
		now[0] = sc.nextInt();
		now[1] = sc.nextInt(); 
		for(int i = 1; i < N; i++) {
			to[0] = sc.nextInt();
			to[1] = sc.nextInt();
			int x = to[0] - now[0];
			int y = to[1] - now[1];
			//System.out.printf("%d %d\n", x,y);
			if(x >= 0 && y >= 0 || x < 0 && y < 0) {
				x = Math.abs(x); y = Math.abs(y);
				wcnt += Math.max(x,y);
			} else {
				x = Math.abs(x); y = Math.abs(y);
				wcnt += x+y;
			}
			//System.out.println(wcnt);
			now[0] = to[0]; now[1] = to[1];
		}
	System.out.println(wcnt);	
	}
}

Measured memory_bytes: 25492
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int a, b;
  cin >> a >> b;
  if (a * b % 2 == 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

Measured memory_bytes: 3668
n, k = map(int, input().split())
h = []

for i in range(n):
    h.append(int(input()))

h.sort()
dif = h[k-1] - h[0]

for i in range(k, n):
    temp = h[i] - h[i-k+1]
    if temp < dif:
        dif = temp

print(dif)


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

int main() {
    int n;
    std::cin >> n;
    int count = 0;
    for (int i = 1; i <= n; i++) {
        int p;
        std::cin >> p;
        count += (p != i) ? 1 : 0;
    }

    std::cout << ((count <= 2) ? "YES" : "NO") << std::endl;
}


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

int main(){
	
	int n,i;
	double debt=100000;
	
	cin >> n;
	
	for(i=0;i<n;i++){
		debt *= 1.05;
		if((int)debt%1000 != 0){
			debt=ceil((debt/1000))*1000;
		}
	}
	
	cout << (int)debt << endl;
	return 0;
}

Measured memory_bytes: 0
#include"bits/stdc++.h"
using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int> X(N), Y(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i];
		Y[i] = X[i];
	}
	sort(Y.begin(), Y.end());

	int mid1, mid2;
	mid1 = Y[N/2-1];
	mid2 = Y[N/2];

	for (int i = 0; i < N; i++) {
		if (X[i] <= mid1)
			cout << mid2 << endl;
		else
			cout << mid1 << endl;
	}
}

Measured memory_bytes: 3712
#include<stdio.h>

int gcd(int x,int y){
	int z;
	
	do{
		z=x%y;
		x=y;
		y=z;
	}while(y!=0);
	return x;
}

int lcm(int x,int y){
	int z;
	z=gcd(x,y);
	z=x/z*y;
	return z;
}

int main()
{
	int num1,num2;
	
	while(scanf("%d %d",&num1,&num2)>0)
	{
		printf("%d %d\n",gcd(num1,num2),lcm(num1,num2));
	}
	return 0;
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val s = readLine()!!.replace("BC","X")
    var countA = 0
    var ans = 0L
    s.forEach {
        when(it){
            'A' -> countA++
            'X' -> ans+=countA
            else -> countA=0
        }
    }
    println(ans)
}

Measured memory_bytes: 42476
<?php
fscanf(STDIN, "%d%d", $N, $K);
for($i = 0; $i < $N; $i++){
  fscanf(STDIN, "%d%d", $x, $y);
  $X[] = $x;$Y[] = $y;
  $mapXY[$x] = $y;
  $mapYX[$y] = $x;
}
$Xs = $X; $Ys = $Y;
$min = 10**19;
sort($Xs);sort($Ys);
for($i = 0; $i < $N; $i++){
  for($j = $i+1; $j < $N; $j++){
    $xi = $Xs[$i];
    $xj = $Xs[$j];
 
    $yMax = 0;
    $c = 0;
    for($yMin = 0; $yMin < $N-$K+1; $yMin++){
      while($c < $K && $yMax < $N){
        $x = $mapYX[$Ys[$yMax++]];
        if($x >= $xi && $x <= $xj)$c++;
      }
      if($c == $K){
        $a = ($Ys[$yMin]-$Ys[$yMax-1])*($xi-$xj);
        $min = min($a, $min);
      }
      $x = $mapYX[$Ys[$yMin]];
      if($x >= $xi && $x <= $xj)$c--;
    }
  }
}
echo $min;
 

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
bool p(int n)
{
    if (n == 3 || n==2)
        {return true;}
    if (n%2 == 0 || n%3 == 0)
        {return false;}

    for (int i=5; i*i<=n; i=i+6)
    {
        if (n%i == 0 || n%(i+2) == 0)
        {
            return false;
        }
    }
    return true;
}
int np(int n)
{
    int prime = n;
    bool x = false;
    while (!x)
    {
        prime++;

        if (p(prime))
            {x= true;}
    }

    return prime;
}


int main()
{
    int n;
    cin>>n;
    if(p(n))
    {
        cout<<n<<endl;
        return 0;
    }
    else
    cout << np(n);
    return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;


long long pof10[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000};
long long pof2[] = {1, 1, 2 ,4, 8, 16, 32, 64, 128, 256, 512, 1024};

long long solve(long long N){
    int i = 0; long long res = 0;

    while (true){
        long long r = N % pof10[i];
        long long l = (N - r) / pof10[i];
        if (l == 0) break;
        
        res += l * pof2[i] + solve(r);
        i++;
    }
    return res;
}

int main(){
    long long N;
    cin >> N;
    long long res = solve(N);

    cout << res << endl;
    return 0;
}

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

int N, Q;
vector<string> S;
vector<vector<int> > trie;
vector<int> term;
vector<int> pcnt;
vector<int> cnt;

void dfs(int u, int c) {
    if(term[u] != -1) {
        pcnt[ term[u] ] = c;
        c++;
        cnt[u]++;
    }
    for(int i = 0; i < 26; i++) {
        int v = trie[u][i];
        if(v == -1) continue;
        dfs(v, c);
        cnt[u] += cnt[v];
    }
}

vector<vector<vector<int> > > prec;

int main() {
    scanf("%d", &N);
    S.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }

    trie.push_back(vector<int>(26, -1));
    term.push_back(-1);

    for(int i = 0; i < N; i++) {
        int u = 0;
        for(int j = 0; j < S[i].size(); j++) {
            if(trie[u][ S[i][j] - 'a' ] == -1) {
                trie[u][ S[i][j] - 'a' ] = trie.size();
                trie.push_back(vector<int>(26, -1));
                term.push_back(-1);
            }
            u = trie[u][ S[i][j] - 'a' ];
        }
        term[u] = i;
    }
    pcnt = vector<int>(N, 0);
    cnt = vector<int>(trie.size(), 0);
    dfs(0, 0);

    prec = vector<vector<vector<int> > >(N, vector<vector<int> >(26, vector<int>(26, 0)));

    for(int i = 0; i < N; i++) {
        int u = 0;
        for(int j = 0; j < S[i].size(); j++) {
            for(int k = 0; k < 26; k++) {
                if(k == S[i][j] - 'a') continue;
                prec[i][k][ S[i][j] - 'a' ] += trie[u][k] == -1? 0 : cnt[ trie[u][k] ];
            }
            u = trie[u][ S[i][j] - 'a' ];
        }
    }

    scanf("%d", &Q);
    for(int i = 0; i < Q; i++) {
        int k; scanf("%d", &k);
        string p; cin >> p;
        k--;

        int ans = pcnt[k];
        for(int a = 0; a < 26; a++) {
            for(int b = a + 1; b < 26; b++) {
                ans += prec[k][ p[a] - 'a' ][ p[b] - 'a' ];
            }
        }

        printf("%d\n", ans + 1);
    }
}


Measured memory_bytes: 372528
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def common_tangent_lines(x1, y1, r1, x2, y2, r2):
    result = []
    xd = x2 - x1; yd = y2 - y1

    rr0 = xd**2 + yd**2
    if (r1 - r2)**2 <= rr0:
        cv = r1 - r2
        if rr0 == (r1 - r2)**2:
            bx = r1*cv*xd/rr0
            by = r1*cv*yd/rr0
            result.append([
                (x1 + bx, y1 + by),
                (x1 - yd + bx, y1 + xd + by),
            ])
        else:
            sv = (rr0 - cv**2)**.5
            px = (cv*xd - sv*yd); py = (sv*xd + cv*yd)
            result.append([
                (x1 + r1*px/rr0, y1 + r1*py/rr0),
                (x2 + r2*px/rr0, y2 + r2*py/rr0),
            ])
            qx = (cv*xd + sv*yd); qy = (-sv*xd + cv*yd)
            result.append([
                (x1 + r1*qx/rr0, y1 + r1*qy/rr0),
                (x2 + r2*qx/rr0, y2 + r2*qy/rr0),
            ])
    if (r1 + r2)**2 <= rr0:
        cv = r1 + r2
        if rr0 == (r1 + r2)**2:
            bx = r1*cv*xd/rr0
            by = r1*cv*yd/rr0
            result.append([
                (x1 + bx, y1 + by),
                (x1 - yd + bx, y1 + xd + by),
            ])
        else:
            sv = (rr0 - cv**2)**.5
            px = (cv*xd - sv*yd); py = (sv*xd + cv*yd)
            result.append([
                (x1 + r1*px/rr0, y1 + r1*py/rr0),
                (x2 - r2*px/rr0, y2 - r2*py/rr0),
            ])
            qx = (cv*xd + sv*yd); qy = (-sv*xd + cv*yd)
            result.append([
                (x1 + r1*qx/rr0, y1 + r1*qy/rr0),
                (x2 - r2*qx/rr0, y2 - r2*qy/rr0),
            ])
    return result

def solve():
    N = int(readline())
    if N == 0:
        return False
    P = [list(map(int, readline().split())) for i in range(N)]
    if N == 1:
        write("1\n")
        return True
    LL = [(r, r+m) for x, y, r, m in P]
    EPS = 1e-9
    ans = 0
    for i in range(N):
        xi, yi, ri, mi = P[i]
        LLi = LL[i]
        for j in range(i):
            xj, yj, rj, mj = P[j]
            LLj = LL[j]
            for pi in LLi:
                for pj in LLj:
                    lines = common_tangent_lines(xi, yi, pi, xj, yj, pj)
                    for p0, p1 in lines:
                        x0, y0 = p0; x1, y1 = p1
                        dx = x1 - x0; dy = y1 - y0
                        q = (dx**2 + dy**2)**.5
                        cnt = 0
                        for xk, yk, rk, mk in P:
                            zx = xk - x0; zy = yk - y0
                            p = abs(dx*zy - dy*zx)
                            if rk*q - EPS <= p <= (rk+mk)*q + EPS:
                                cnt += 1
                        ans = max(ans, cnt)
    write("%d\n" % ans)
    return True
while solve():
    ...


Measured memory_bytes: 5752
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

const int N = 1e6 + 9;
const int INF = 1e9;
const int mod = 1e9;
const int SZ = (1 << 17) - 1;

#define eb emplace_back
#define sz(s) (int)(s.size())

#define ll long long

const int NN = 2e3;

#define int ll

int a[N] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

void solve() {
	int n;
	cin >> n;
	cout << a[n - 1];
}

signed main() {
	ios_base::sync_with_stdio(false);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define rep(i,a) for(int i=0;i<(int)a;i++)
using namespace std;

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

const int rot[4][6] = { {4,0,2,3,5,1},
			{3,1,0,5,4,2},
			{2,1,5,0,4,3},
			{1,5,2,3,0,4} };

const int die[6][6] = { {0,2,4,1,3,0},
			{3,0,0,5,0,2},
			{1,5,0,0,0,4},
			{4,0,0,0,5,1},
			{2,0,5,0,0,3},
			{0,3,1,4,2,0} };

int main(){
  int n,u,f,y,x;
  int h[80][80],s[80][80],res[7];
  int d[6],tmp[6];

  while(scanf("%d",&n),n){
    rep(i,80)rep(j,80)h[i][j] = s[i][j] = -1;

    while(n--){
      scanf("%d %d",&u,&f);
      u--; f--;
      d[0] = u; d[5] = 5-u;
      d[1] = f; d[4] = 5-f;
      d[2] = die[u][f]; d[3] = 5-die[u][f];
      
      f = true;
      y = x = 40;
      while(f){
	f = false;
	for(int i=5;i>=3 && !f;i--){
	  rep(j,4){
	    if(d[j+1] == i && h[y][x] > h[y+dy[j]][x+dx[j]]){
	      y = y+dy[j]; x = x+dx[j];
	      for(int k=0;k<6;k++)tmp[k] = d[rot[j][k]];
	      for(int k=0;k<6;k++)d[k] = tmp[k];
	      f = true;
	      break;
	    }
	  }
	}
      } 
      h[y][x]++; s[y][x] = d[0];
    }
    
    rep(i,7)res[i] = 0;
    rep(i,80)rep(j,80)res[s[i][j]+1]++;
    rep(i,6)printf("%d%c",res[i+1],i==5?'\n':' ');
  }
}

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

int main(){
    int a[3];
    int i,t;
    for (i = 0; i < 3; i++) {
        cin>>a[i];
    }
    if (a[0]>a[1]){
        t=a[0];
        a[0]=a[1];
        a[1]=t;
    }
    if (a[1]>a[2]){
        t=a[1];
        a[1]=a[2];
        a[2]=t;
    }
    if (a[0]>a[1]){
        t=a[0];
        a[0]=a[1];
        a[1]=t;
    }
    cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    return 0;
}



Measured memory_bytes: 3080
const MOD: usize = 1000000007;

fn main() {
	proconio::input!(s: usize);
	let mut dp = vec![0; s + 1];
	dp[0] = 1;
	for n in 3..=s {
		dp[n] = (dp[n-1] + dp[n-3]) % MOD;
	}
	println!("{}", dp[s]);
}

Measured memory_bytes: 2136
# -*- coding: utf-8 -*-
from sys import stdin
import collections

class DoublyLinkedList_deque:
    def __init__(self):
        self.doubly_linked_list = collections.deque()

    def execute(self,cmd, key):
        if cmd == 'insert':
            self.doubly_linked_list.appendleft(key)
        elif cmd == 'delete':
            try:
                self.doubly_linked_list.remove(key)
            except:
                pass
        elif cmd == 'deleteFirst':
            self.doubly_linked_list.popleft()
        elif cmd == 'deleteLast':
            self.doubly_linked_list.pop()
        else:
            print("invalid cmd")

n = int(stdin.readline().rstrip())
obj_dll = DoublyLinkedList_deque()
for i in range(n):
    input_str=stdin.readline().rstrip().split()
    cmd = input_str[0]
    x = input_str[1] if len(input_str)>1 else None
    obj_dll.execute(cmd,x)
else:
    print(*obj_dll.doubly_linked_list)



Measured memory_bytes: 69776
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

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

int i,n;
string s;

void solve()
{
    cin>>s;
    int ans=0,cnt=0;
    for(i=0;i<sz(s);i++)
    {
        if(s[i]=='R')
            cnt++;
        else
        {
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout<<ans;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

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

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

char memarr[17000000]; void *mem = memarr;
#define MD 1000000007

int N, T, A[100000];

int main(){
  int i, j, k;
  int mn, opt, cnt;

  reader(&N,&T);
  rep(i,N) reader(A+i);

  mn = 1000000000;
  opt = 0;
  rep(i,N){
    mn = min(mn, A[i]);
    if(opt <  A[i] - mn) opt = A[i]-mn, cnt = 0;
    if(opt == A[i] - mn) cnt++;
  }
  writerLn(cnt);

  return 0;
}


Measured memory_bytes: 640
import sys
import fractions

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MAT(h): return [list(map(int, input().split())) for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = INT()
    A = LIST()
    L = [0] * N
    R = [0] * N
    M = [0] * N
    for i in range(N - 1):
        L[i + 1] = fractions.gcd(L[i], A[i])
        R[N - i - 2] = fractions.gcd(R[N - i - 1], A[N - i - 1])
    maxv = 0
    for i in range(N):
        M[i] = fractions.gcd(L[i], R[i])
        if maxv < M[i]:
            maxv = M[i]
    print(maxv)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16568
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair
 
 
int main(){
  CIN(n);VC1(n,a);
  M m;
  REP(i,n)
    m[a[i]]++;
 
  ll count = n-m.size();
  if(count %2 == 0)
    COUT(m.size());
  else
    COUT(m.size()-1);
 
  return 0;
}

Measured memory_bytes: 7296
import numpy as np 
N, M = map(int,input().split())
h_list = np.array(list(map(int,input().split())))

max_neigh_hight = np.zeros(N) # 隣接する展望台で最も高いもの

for _ in range(M):
    a,b = map(int,input().split())
    a-=1
    b-=1
    max_neigh_hight[a] = max(max_neigh_hight[a],h_list[b])
    max_neigh_hight[b] = max(max_neigh_hight[b],h_list[a])

diff = h_list - max_neigh_hight
ans = np.sum(diff>0)
print(ans)


Measured memory_bytes: 38548
//NAME-ADITYYA OJHA
                                               /*
                                                      GURU(MENTOR)-AARADHYA
                                               */
/*
 *     Heart beats fast
 *         Colors and promises
 *             How to be brave
 *                 How can I love when I am afraid to fall...
                                             (courtesy-amnesiac_dusk)
 */

#include <bits/stdc++.h>
#define ll long long int
#define forin for(int i=0;i<n;i++)
#define pb push_back
#define vx vector<ll> x
#define vy  vector<ll> y
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  f   first
#define  s   second
#define mod 1000000007



using namespace std;

//check for corner cases(for n==1)
// check for int overflow
// run on some sample cases before submitting
  const  ll N=1e5 + 5;
int main()
{
  fast;
       ll n;
       cin>>n;
            ll pow(26);
            while (n > pow)
            {
                n -= pow;
                pow *= 26;
            }

            n -= 1;
            while (pow != 1)
            {
                pow /= 26;
                printf("%c", n / pow + 'a');
                n %= pow;
            }


}


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

#define fst first
#define snd second
#define pb push_back

template<typename T> bool chkmin(T&a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool chkmax(T&a, T b) { return a < b ? a = b, 1 : 0; }

const int maxn = 100000 + 10;

int n, a, b;
long long h[maxn], t[maxn];

bool chk(long long M) {
    memcpy(t, h, sizeof t);
    long long tmp = 0;
    for(int i = 1; i <= n; i++) {
        t[i] -= 1LL * b * M;
        if(t[i] > 0) 
            tmp += (long long)(ceil(1.0*t[i] / a));
    }
    return tmp <= M;
}
int main() {

    cin >> n >> a >> b; a -= b;
    for(int i = 1; i <= n; i++) cin >> h[i];

    int L = 0, R = INT_MAX, ans = 1;
    while(L <= R) {
        int M = (L+R) >> 1;
        if(chk(M)) R = M - 1, ans = M; else L = M + 1;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
    mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
    mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
    mint operator+(const mint a) const {mint res(*this); return res+=a;}
    mint operator-(const mint a) const {mint res(*this); return res-=a;}
    mint operator*(const mint a) const {mint res(*this); return res*=a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

int main() {
	string s;
	cin >> s;
	int n = s.size();
	s = 'x' + s;
	vector<vector<mint>> dp(n + 1, vector<mint>(13));
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < 13; j++) {
			if(s[i] == '?') {
				for(int k = 0; k < 10; k++) {
					dp[i][(10 * j + k) % 13] += dp[i - 1][j];
				}
			}
			else {
				int c = s[i] - '0';
				dp[i][(10 * j + c) % 13] += dp[i - 1][j];
			}
		}
	}
	cout << dp[n][5].x << endl;
}


Measured memory_bytes: 13692
import math
n = int(input())
graph = [[] for i in range(n)]
for i in range(n):
    a,b = list(map(int,input().split()))
    graph[i] = [a,b]

def inasi(ls,i):
    n = []
    for j in range(len(ls)):
        if j == i:continue
        n.append(ls[j])
    return n

def kyori(ls):
    ans = 0
    for i in range(len(ls)-1):
        ans += math.sqrt((graph[ls[i]][0] - graph[ls[i+1]][0])**2 + (graph[ls[i]][1] - graph[ls[i+1]][1])**2)
    return ans

check = 0
count = 0
def keisan(n,pls,ls):
    global check,count
    if len(ls) == 0:
        check += kyori(pls)
        count += 1
        #pls.pop()
        return
    for i in range(len(ls)):
        pls.append(ls[i])
        keisan(n-1,pls,inasi(ls,i))
        try:pls.pop()
        except:pass
    return

keisan(10,[],[i for i in range(n)])
print(check/count)

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

using namespace std;

int main(){
	string p, c;
	int n, ans = 0;
	cin >> n;
	cin >> p;

	for(int i = 0;i < n;++i){
		cin >> c;
		int j, k, l, d;
		bool f = false;
		for(int j = 0;j < c.length();++j){
			for(int d = 0;d < (c.length() - j);++d){
				l = 0;
				for(int k = j;k < c.length() && l < p.length();k += (d + 1)){
					if(p[l] == c[k]){
						++l;
					}
					else {
						break;
					}
				}
				if(l == p.length()){
					f = true;
					break;
				}
			}
			if(f) {
				++ans;
//				cout << c << endl;
				break;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) 1e9
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
int main(){
	fast;
	ll n;
	cin>>n;
	ll a[n+1]={0};
	ll t;
	for(ll i=1; i<n; i++){
		cin>>t;
		a[t]++;
	}
	for(ll i=1; i<=n; i++){
		cout<<a[i]<<endl;
	}
}

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

int main(void){

  int a,b,d,r;
  double f;

  cin >>a >>b ;

  d = a/b;
  r = a%b;
  f = (double)a/b;

  cout<<d <<" " <<r <<" "  ;

  printf("%f\n", f);

  return 0;
}

Measured memory_bytes: 1232
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A.sort()

    if all([a <= 0 for a in A]):
        print(A[-1]-(sum(A)-A[-1]))

        for i in range(N-1):
            print(A[-1],A[i])
            A[-1] -= A[i]
        return
    if all([a >= 0 for a in A]):
        print(sum(A)-A[0]-A[0])
        for i in range(1,N-1):
            print(A[0],A[i])
            A[0] -= A[i]
        print(A[-1],A[0])
        return
    
    answer = 0
    plus = []
    minus = []
    for i in range(N):
        if A[i] >= 0:
            plus.append(A[i])
        else:
            minus.append(A[i])
        answer += abs(A[i])
    print(answer)
    
    while len(plus)>1:
        p = plus.pop()
        m = minus.pop()
        minus.append(m-p)
        print(m,p)
    
    while minus:
        m = minus.pop()
        print(plus[0],m)
        plus[0] -= m
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16704
#include<iostream>
using namespace std;
int n;
long k,w[1<<17],d[1<<17];
main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>d[i];
	}
	long l=0,f=2e18;
	while(f-l>1)
	{
		long m=(l+f)/2;
		long cnt=0;
		for(int i=0;i<n;i++)
		{
			if(m>=w[i])cnt+=(m-w[i])/d[i]+1;
		}
		if(cnt<k)l=m;
		else f=m;
	}
	cout<<f<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 2e5;
int N, A[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> A[i];

	vector<vector<int> > factors(N+1);
	for(int i=1; i<=N; i++){
		for(int j=2*i; j<=N; j+=i) factors[j].push_back(i);
	}

	vector<int> ans;
	vector<int> count(N+1);
	for(int i=N-1; i>=0; i--){
		if(A[i]!=count[i+1]%2){
			ans.push_back(i+1);
			for(int j: factors[i+1]) count[j]++;
		}
	}

	sort(ans.begin(), ans.end());
	cout << ans.size() << endl;
	for(int i=0; i<ans.size(); i++) cout << ans[i] << (i==ans.size()-1?'\n':' ');

	return 0;
}


Measured memory_bytes: 24312
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
  int n,q; cin>>n>>q;
  vector<int> p(n);
  rep(i,n) cin>>p[i];
  rep(i,q){
    ll x; cin>>x;
    ll sum=0, res=0;
    int r=0;
    rep(l,n){
      while(r<n && sum+p[r]<=x){
        sum+=p[r];
        r++;
      }
      res+=(r-l);
      if(l==r){
        r++;
      }
      else{
        sum-=p[l];
      }
    }
    cout<<res<<endl;
  }
} 


Measured memory_bytes: 3164
#include <stdio.h>
#include <stdbool.h>

#define true 1
#define false 0
#define MAX 1000
#define VMAX 10000

int n, A[MAX],s;
int B[MAX], T[VMAX+1];

void sort(int A[]){
	int flag = 1;
	int tmp;
	while(flag == 1){
		flag = 0;
		for(int j = n-1; j >= 1; j--){
			if(A[j] < A[j-1]){
				tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
				flag = 1;
			}
		}
	}
}

int min(int a, int b){
	if(a < b){return a;}
	else {return b;}
}

int solve(){
	int ans = 0;
	
	bool V[MAX];
	for(int i = 0; i < n; i++){
		B[i] = A[i];
		V[i] = false;
	}
	sort(B);
	for(int i = 0; i< n; i++){
		T[B[i]] = i;
	}
	
	for(int i = 0; i < n; i++){
		if(V[i]){continue;}
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an=0;
		while(1){
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if(V[cur]){
				break;
			}
		}
		ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
	}
	
	return ans;
}

int main(){
	scanf("%d", &n);
	s = VMAX;
	for(int i = 0; i < n; i++){
		scanf("%d", &A[i]);
		s = min(s, A[i]);
	}
	int ans = solve();
	printf("%d\n", ans);
	
	return 0;
}



Measured memory_bytes: 2108