akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int H, W; cin >> H >> W;
    int dp[205][205];

    rep(i,10) rep(j,10)  cin >> dp[i][j];
    rep(k,10) rep(i,10) rep(j,10) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);

    int cost = 0;
    rep(i,H) rep(j,W) {
        int a; cin >> a;
        if(a == -1) continue;
        cost += dp[a][1];
    }
    cout << cost << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
n,q=map(int,input().split())
edge=[[] for i in range(n)]
a=[0]*n
b=[0]*n
for i in range(n-1):
    x,y=map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
for i in range(q):
    p,x=map(int,input().split())
    a[p-1]+=x
def dfs(node,tmp):
    a[node]+=tmp
    b[node]=1
    for i in edge[node]:
        if b[i]==0:
            dfs(i,a[node])
dfs(0,0)
print(*a)

Measured memory_bytes: 223172
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(2e6 + 10), M(1e5 + 10);
struct edge { int to, c; };
std::vector<std::pair<int, int> > F[N];
std::vector<edge> G[N];
std::deque<int> Q;
std::map<int, int> map[M];
int n, m, C, cur, dis[N], vis[N];

void add_edge(int x, int y, int c)
{
	G[x].push_back((edge) {y, c});
	G[y].push_back((edge) {x, c});
}

int main()
{
	n = read(), m = read();
	for (int i = 1, a, b, c; i <= m; i++)
		a = read(), b = read(), C = std::max(C, c = read()),
		F[c].push_back(std::make_pair(a, b));
	for (int i = 1; i <= C; i++) for (auto j : F[i])
	{
		if (!map[j.first][i]) map[j.first][i] = ++cur;
		if (!map[j.second][i]) map[j.second][i] = ++cur;
		add_edge(map[j.first][i], map[j.second][i], 0);
	}
	for (int i = 1; i <= n; i++)
		{ ++cur; for (auto j : map[i]) add_edge(j.second, cur, 1); }
	for (int i = 1; i <= cur; i++) dis[i] = 0x3f3f3f3f;
	for (auto j : map[1]) Q.push_back(j.second), vis[j.second] = 1, dis[j.second] = 2;
	while (!Q.empty())
	{
		int x = Q.front(); Q.pop_front();
		for (auto i : G[x]) if (dis[i.to] > dis[x] + i.c)
			dis[i.to] = dis[x] + i.c, (i.c ? Q.push_back(i.to) : Q.push_front(i.to));
	}
	int ans = 0x3f3f3f3f;
	for (auto j : map[n]) ans = std::min(ans, dis[j.second]);
	printf("%d\n", ans == 0x3f3f3f3f ? -1 : ans / 2);
	return 0;
}


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

int main()
{
	int n, x = 0;
	int res = 0;
	vector<int> m;
	cin >> n >> x;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		m.push_back(a);
		x -= a;
		res++;
	}
	int min = *std::min_element(m.begin(), m.end());
	res += x / min;

	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int H=0;
    int W=0;
    cin>>H>>W;
    string Si[100];
    for(int i=0;i<H;i++) cin>>Si[i];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
        if(Si[i][j]=='.'){
            int count=0;
            if(i-1>=0&&Si[i-1].at(j)=='#')count++;
              if(i+1<H&&Si[i+1].at(j)=='#')count++;
              if(j-1>=0&&Si[i].at(j-1)=='#')count++;
              if(j+1<W&&Si[i].at(j+1)=='#')count++;
              if(i-1>=0){
                if(j-1>=0&&Si[i-1].at(j-1)=='#')count++;
                if(j+1<W&&Si[i-1].at(j+1)=='#')count++;
              }
              if(i+1<H){
                  if(j-1>=0&&Si[i+1].at(j-1)=='#')count++;
                  if(j+1<W&&Si[i+1].at(j+1)=='#')count++;
              }
        Si[i][j]='0';
        Si[i][j]+=count;
        }
        
        
        }
    }
     for(int i=0;i<H;i++) cout<<Si[i]<<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{
    cout << "Right" << endl; 
  	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0'){
	t=(t<<3)+(t<<1)+v-48;
	v=getchar();}
	return t;
}
long long n,k;
signed main(){
	n=read();k=read();
	if(n>=10)printf("%lld",k);
	else printf("%lld",k+100*(10-n));
}

Measured memory_bytes: 256
def prime(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for j in range(4, n+1, 2):
        is_prime[j] = False
    for i in range(3, int(n**0.5) + 1, 2):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

q = int(input())

bit = [0]*(100001)
prime_list = set(prime(100001))
k = 0
for i in range(100000):
  bit[i+1] = bit[i]
  if i == 0:
    continue
  if i+1 in prime_list and (i+2)//2 in prime_list:
    bit[i+1] += 1

for i in range(q):
  l, r = map(int, input().split())
  print(bit[r]-bit[l-1])

Measured memory_bytes: 5208
use std::fmt::Write;

fn main() {
    let n: usize = read();
    let mut vec: Vec<u8> = read_as_vec();
    let cnt = bubble_sort(n, &mut vec);
    println!("{}", join(' ', &vec));
    println!("{}", cnt);
}

fn bubble_sort(n: usize, vec: &mut Vec<u8>) -> u32 {
    let mut cnt = 0u32;
    let mut flag = true;
    while flag {
        flag = false;
        for i in (1..n).rev() {
            if vec[i - 1] > vec[i] {
                let tmp    = vec[i];
                vec[i]     = vec[i - 1];
                vec[i - 1] = tmp;
                cnt += 1;
                flag = true;
            }
        }
    }
    cnt
}

fn join<T: std::fmt::Display>(delimiter: char, arr: &[T]) -> String {
    let mut text = String::new();
    for (i, e) in arr.iter().enumerate() {
        if i > 0 {
            text.push(delimiter);
        }
        write!(text, "{}", e).unwrap();
    }
    text
}

fn read<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().parse::<T>().ok().unwrap()
}

fn read_as_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse::<T>().ok().unwrap())
        .collect()
}


Measured memory_bytes: 5040
N ,M = list(map(int, input().split()))
H = list(map(int, input().split()))
lis = [1] * N
for i in range(M):
  A, B = list(map(int, input().split()))
  if H[A-1] > H[B-1]:
    lis[B-1]=0
  elif H[A-1] < H[B-1]:
    lis[A-1]=0
  else:
    lis[A-1]=0
    lis[B-1]=0
    
print(lis.count(1))


Measured memory_bytes: 20116
from operator import itemgetter

n = input()
n = int(n)


li = [input().split() for i in range(n)]
for i in range(n):
  li[i].append(i+1)
  li[i][1] = int(li[i][1])
li.sort(key=lambda x:(x[0], -x[1]))
for i in range(n):
  print(li[i][2])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll a,b,c,d;
int main(){FAST;
cin>>a>>b>>c>>d;
ll taka = (c+b-1)/b;
ll aoki = (a+d-1)/d;
if(taka<=aoki){
  cout<<"Yes\n";
}
else{
  cout<<"No\n";
}
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0; i<n;i++)

int main()
{
    int n,k,tmp,type=0,max=0;
    int a[200002]={0};
    int overflow;
    
    cin >> n >> k;
    REP(i,n)
    {
        cin >> tmp;
        a[tmp-1]++;
    }
    
    REP(i,n)
    {
        if(a[i]>0)
        {
            type++;
            if(max < a[i])
            {
                max = a[i];
            }
        }
    }
    if(type <= k)
    {
        cout << "0" << endl;
    }
    else
    {
        overflow = type - k;
        int count = 0;
        REP(j,max)
        {
            REP(i,200000)
            {
                if(a[i] == j+1)
                {
                    count += j+1;
                    overflow--;
                }
                if(overflow == 0)
                {
                    j=i=20000099;
                }
            }
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
s = input()
# curs = [index1, index2] 
curs = [0]
while True:
  next_curs = []
  break_ = False
  for c in curs:
    #print(c)
    if s[c:c+5] == 'dream':
      next_curs.append( c+5 )
      if len(s) == c+5:
        break_ = True
    if s[c:c+7] == 'dreamer':
      next_curs.append( c+7 )
      if len(s) == c+7:
        break_ = True
    if s[c:c+5] == 'erase':
      next_curs.append( c+5 )
      if len(s) == c+5:
        break_ = True
    if s[c:c+6] == 'eraser':
      next_curs.append( c+6 )
      if len(s) == c+6:
        break_ = True
  if next_curs == []:
    print('NO')
    break
  if break_: 
    print('YES')
    break
  curs = next_curs

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<int>vi;
typedef vector<ll>VI;
typedef pair<int,int>pii;
typedef pair<pii,int>Pii;
#define rep(i,a,b) for (int i=a;i<=b;++i)
#define dep(i,a,b) for (int i=a;i>=b;i--)
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lowbit(x) ((x)&((x)^((x)-1)))
#define sz(x) int(x.size())
#pragma GCC optimize(2)
const int N=1e6+10;
const ll mod=1e9+7;
const int maxn=1e5+10;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
ll C(ll n,ll m){ ll a=1,b=1; if (m>n-m) m=n-m; if (m<0) return 0;
 while(m){ a=a*n%mod; b=b*m%mod; m--; n--;} return a*qpow(b,mod-2)%mod;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
void init() {ios::sync_with_stdio(false); cin.tie(0);}
const double PI=3.1415926535897932;


int main(){
	init();
    string s; cin>>s;
    int ans=0;
    for (auto u:s) {
		if (u=='?') cout<<"D";
		else cout<<u;
	}
	return 0;
}












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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
//RNG based on mersenne_twister 
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
const int N=17;
ll a[20][20],n;
ll dp[1<<N],dp2[1<<N];
int _runtimeTerror_()
{
	mem1(dp);
	ll i,j,k,l;
	cin>>n;
	for(ll i=0;i<n;++i)
	{
		for(ll j=0;j<n;++j)
			cin>>a[i][j];
	}
	ll sub=(1<<n);
	for(i=1;i<sub;++i)
	{
		dp2[i]=0;
		vector<ll> v;
		for(j=n-1;j>=0;--j)
			if(i&(1<<j))
				v.pb(j);
		ll ss=sz(v);
		for(ll k=0;k<ss;++k)
		{
			for(ll l=k;l<ss;++l)
				dp2[i]+=a[v[k]][v[l]];
		}
	}
	dp[0]=0;
	for(i=1;i<sub;++i)
	{
		for(j=n-1;j>=0;--j)
		{
			if(i&(1<<j))
				break;
		}
		dp[i]=dp[i&(~(1<<j))];
		vector<ll> v;
		for(k=j-1;k>=0;--k)
			if(i&(1<<k))
				v.pb(k);
		ll x=(1<<sz(v));
		for(l=1;l<x;++l)
		{
			ll num=0,val=0,ff=0;
			ff+=1<<j;
			for(k=0;k<sz(v);++k)
			{
				if(l&(1<<k))
				{
					ff+=1<<v[k];
				}
				else
					num+=1<<v[k];
			}
			amax(dp[i],dp[num]+dp2[ff]);
		}
	}
	//cout<<dp[5]<<endl;
	cout<<dp[sub-1]<<endl;
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	cerr<<"\n"<<_time_;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
typedef long long ll;
long long n,a[N],b[N],ans=0;
int main(){
	cin>>n;
	for(int i=0;i<n+1;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++){
		if(a[i]>=b[i]) a[i]-b[i],ans+=b[i],b[i]=0;
		else ans+=a[i],b[i]-=a[i],a[i]=0;
		if(b[i]!=0&&a[i+1]>=b[i]) a[i+1]-=b[i],ans+=b[i];
		else if(b[i]!=0&&a[i+1]<b[i]) ans+=a[i+1],a[i+1]=0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
from itertools import accumulate
H, W, M = map(int, input().split())

rowcts = [0] * H
colcts = [0] * W

bombs = set()
for _ in range(M):
    y, x = map(int, input().split())
    rowcts[y-1] += 1
    colcts[x-1] += 1
    bombs.add((y-1,x-1))

maxY = max(rowcts)
maxYidxs = []
for y in range(H):
    if rowcts[y] == maxY:
        maxYidxs.append(y)

maxX = max(colcts)
maxXidxs = []
for x in range(W):
    if colcts[x] == maxX:
        maxXidxs.append(x)

# たかだか 3*10^5 のはず
for y in maxYidxs:
    for x in maxXidxs:
        if (y, x) not in bombs:
            print(maxY + maxX)
            exit()
print(maxY + maxX - 1)

Measured memory_bytes: 176856
let id x = x
let n = Scanf.scanf "%d\n" id

let repeat f =
  let rec loop acc = function
    | 0 -> List.rev acc
    | n -> loop (f () :: acc) (n - 1) in
  loop []
 
let r = repeat (fun () -> Scanf.scanf "%d " id) n
  
let rec check = function
  | [a] -> true
  | a :: b :: [] -> if (a mod 2) = (b mod 2) then true else false
  | a :: b :: c :: rest ->
     if (a mod 2) = (b mod 2) then check ((a+b) :: c :: rest) else
       if (a mod 2) = (c mod 2) then check ((a+c) :: b :: rest) else
	 check ((b+c) :: a :: rest)

let ansbool = check r
let ans = if ansbool = true then "YES" else "NO"
    
let () = Printf.printf "%s\n" ans

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	while(n!=0){
		n/=k;
		ans++;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
typedef long long ll;

const ll modulus = (ll)(1e9) + 7;

ll dp[200005] = {[0] = 1, [1] = 0};
ll add[200005];

ll n;
ll c[200005];
ll cnt;

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

    cnt = 1;
    for (int i = 0; i < n; cnt++, i++) {
        scanf("%lld", &c[cnt]);

        if (c[cnt - 1] == c[cnt]) {
            cnt--;
        }
    }
    cnt--;

    for (int i = 1; i <= cnt; i++) {
        dp[i] = dp[i - 1] + add[c[i]];

        dp[i] %= modulus;

        add[c[i]] = dp[i];
    }

    printf("%lld\n", dp[cnt]);

    return 0;
}


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

using namespace std;

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    int ans = 0;
    cin >> s;
    for (int i = 0; i < (int)s.size(); ++i) {
        if (s[i] != s[(int)s.size() - i - 1]) {
            s[i] = s[(int)s.size() - i - 1];
            ans++;
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = [-a[i] if i%2 else a[i] for i in range(n)]
c = [a[i] if i%2 else -a[i] for i in range(n)]
ans = []
for i in range(1, n):
  b[i] += b[i-1]
  c[i] += c[i-1]
for i in range(n):
  if n%2==0:
    ans.append(b[n-1]-b[i-1]+c[i-1])
  else:
    ans.append(abs(c[n-1]-c[i-1]+b[i-1]))
print(*ans)

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    long m = max(a, max(b, c));
    long sum = m;
    for (int i = 0; i < k; i++) {
        sum *= 2;
    }
    sum += (a + b + c) - m;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <numeric>

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


using namespace std;

int gcd(int x, int y){
  if (y > x) {
    int k = y;
    y = x;
    x = k;
  }
  int r;
  while((r = x % y) != 0) {
    x = y;
    y = r;
  }
  return y;
}

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

int main(void){
  int n, x;
  cin >> n >> x;
  int tmpg;
  rep(i, n) {
    int a;
    cin >> a;
    if (i == 0) tmpg = abs(x - a);
    else tmpg = gcd(tmpg, abs(x - a));
  }
  cout << tmpg;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 200005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
string s; vector<ll> vc; ll k; ll dp[101][3][101];
ll findans(ll pos,ll flg,ll cnt){
//	cout<<pos<<" "<<cnt<<endl;
	if(pos==vc.size()){
		if(cnt==k)
			return 1;
		else return 0;
	}
	if(dp[pos][flg][cnt]!=-1){
		return dp[pos][flg][cnt];
	}

	ll an=0,lmt;
	if(flg==0){
		lmt=vc[pos];
	}
	else {
		lmt=9;
	}
	//cout<<pos<<" "<<lmt<<endl;
	for(ll i=0;i<=lmt;i++){
		ll nf=flg,c=cnt;
		if(flg==0&&i<lmt) nf=1;
		if(i!=0) c++;
		an+=findans(pos+1,nf,c);
	}
	return dp[pos][flg][cnt]=an;
}
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,l,n;
	cin>>s;
	n=s.length();
	cin>>k;
	for(i=0;i<n;i++){
		vc.ps(s[i]-'0');
	}
	memset(dp,-1,sizeof(dp));
	ll an=findans(0,0,0);
	cout<<an;
	return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

void dfs(int t, int sx, int sy, vector< vector<int> >& a) {
	if (t == 10) return;
	int h = a.size(), w = a[0].size();
	for (int k = 0; k < 4; k++) {
		int x = sx + dx[k], y = sy + dy[k];
		if (x < 0 || x >= w || y < 0 || y >= h || a[y][x] == 1)
			continue;
		bool flag;
		int _x, _y;
		for (;;) {
			if (a[y][x] == 3) {
				mini = min(mini, t + 1);
				return;
			}
			_x = x + dx[k]; _y = y + dy[k];
			if (_x < 0 || _x >= w || _y < 0 || _y >= h) {
				flag = false;
				break;
			}
			if (a[_y][_x] == 1) {
				flag = true;
				break;
			}
			x = _x; y = _y;
		}
		if (!flag) continue;
		a[_y][_x] = 0;
		dfs(t + 1, x, y, a);
		a[_y][_x] = 1;
	}
}

int main() {
	for (;;) {
		int w, h; cin >> w >> h;
		if (w == 0 && h == 0) break;
		vector< vector<int> > a(h, vector<int>(w));
		int sx, sy;
		for (int y = 0; y < h; y++)
			for (int x = 0; x < w; x++) {
				cin >> a[y][x];
				if (a[y][x] == 2) {
					a[y][x] = 0;
					sx = x; sy = y;
				}
			}
		mini = INT_MAX;
		dfs(0, sx, sy, a);
		cout << (mini < INT_MAX ? mini : -1) << endl;
	}
}

Measured memory_bytes: 1224
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    n = int(input())
    V = list(map(int, input().split()))
    V.sort()
    while True:
        if len(V) == 1:
            break
        a = (V[0] + V[1]) / 2
        V = V[2:]
        V.insert(0, a)
        V.sort()
    print(V[0])

main()


Measured memory_bytes: 2940
import java.util.*;

public class Main {

    public static void main(String[] args) {

    	Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int ans = 0;

        int[] money = new int[206];
        Arrays.fill(money, 0);
        money[1] = 300000;
        money[2] = 200000;
        money[3] = 100000;

        if (x == 1 && y == 1) {
            ans = 1000000;
        }  else {
            ans += money[x];
            ans += money[y];
        }
        System.out.println(ans);
    }
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <typename T> inline void print(T val) { cout << val << '\n'; }

template <typename Iterator> inline void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; it = next(it)) {
    cout << *it << ' ';
  }
  cout << '\n';
}

template <class T> inline T square(T x) {
  T result;
  result = x * x;
  return result;
};

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;

class Graph {
private:
  int n;
  // Vertex - Weight
  vector<vector<pair<int, int>>> g;

public:
  Graph(int size) : n(size), g(size) {}

  void addEdge(int from, int to, int weight) {
    g[from].push_back({to, weight});
  }

  vector<int> dijkstra(int source) {
    vector<int> distance(n, INF);

    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        q;

    distance[source] = 0;

    q.push({0, source});

    while (!q.empty()) {
      auto x = q.top().second;
      q.pop();

      for (auto &i : g[x]) {
        auto y = i.first;
        auto weight = i.second;

        if (distance[x] + weight < distance[y]) {
          distance[y] = distance[x] + weight;
          q.push({distance[y], y});
        }
      }
    }

    return distance;
  }
};

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  auto start = chrono::steady_clock::now();
#endif

  int n, x, y;
  cin >> n >> x >> y;

  Graph g(n);

  vector<int> ans(n, 0);

  for (auto i = 0; i < n - 1; ++i) {
    g.addEdge(i, i + 1, 1);
    g.addEdge(i + 1, i, 1);
  }

  g.addEdge(x - 1, y - 1, 1);
  g.addEdge(y - 1, x - 1, 1);

  for (auto i = 0; i < n; ++i) {
    auto a = g.dijkstra(i);

    // dbg(a);

    for (auto j = i + 1; j < n; ++j) {
      ans[a[j]]++;
    }
  }

  print(ans.begin() + 1, ans.end());

#ifdef LOCAL
  auto end = chrono::steady_clock::now();
  auto diff = end - start;

  cout << "Duration: " << chrono::duration<double, milli>(diff).count() << " ms"
       << '\n';
#endif

  return 0;
}


Measured memory_bytes: 384
function main(input) {
    input = input.trim().split(" ").map(x => Number(x));
    while (true) {
        input[2] -= input[1];
        if (input[2] <= 0) {
            console.log("Yes");
            break;
        }
        input[0] -= input[3];
        if (input[0] <= 0) {
            console.log("No");
            break;
        }
        
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

inline int read() {
	int ret, cc, sign = 1;
	while (!isdigit(cc = getchar()))
		sign = cc == '-' ? -1 : sign;
	ret = cc - 48;
	while ( isdigit(cc = getchar()))
		ret = cc - 48 + ret * 10;
	return ret * sign;
}

const int MAXN = 300010;
int val[MAXN];
int pos[MAXN];
int left[30][MAXN];
int right[30][MAXN];
int dp[2][MAXN];
int tot, n, V;

int main() {
#ifdef ARK
	freopen("test.in", "r", stdin);
#endif
	n = read(), V = read();
	for (int i = 1; i <= n; ++i)
		pos[i] = read();

	val[0] = V / 2;
	while (val[tot]) 
		val[tot + 1] = val[tot] / 2, ++tot;

	for (int i = 0; i <= tot; ++i) {
		right[i][n + 1] = n + 1, right[i][n] = n;
		for (int j = n - 1; j >= 1; --j) 
			if (pos[j + 1] - pos[j] <= val[i])
				right[i][j] = right[i][j + 1];
			else
				right[i][j] = j;

		left[i][1] = 1;
		for (int j = 2; j <= n; ++j)
			if (pos[j] - pos[j - 1] <= val[i])
				left[i][j] = left[i][j - 1];
			else
				left[i][j] = j;
	}

	int U = (1 << (tot + 1)) - 1;
	dp[0][0] = 0, dp[1][0] = n + 1;
	for (int S = 1; S <= U; ++S) {
		dp[1][S] = n + 1;
		for (int j = 0; j <= tot; ++j) 
			if (S >> j & 1) {
				dp[0][S] = std::max(right[j][dp[0][S ^ (1 << j)] + 1], dp[0][S]);
				dp[1][S] = std::min(left[j][dp[1][S ^ (1 << j)] - 1], dp[1][S]);
			}
	}

	for (int i = 1; i <= n; ++i) {
		int r = i;
		while (r < n && pos[r + 1] - pos[r] <= V) r++;
		bool flag = 0;
		for (int S = 0; S <= U; ++S) 
			if (dp[0][S] >= i - 1 && dp[1][U ^ S] <= r + 1) {
				flag = 1;
				break;
			}
		for (int j = i; j <= r; ++j) 
			puts(flag ? "Possible" : "Impossible");
		i = r;
	}
}


Measured memory_bytes: 51456
<?php
fscanf(STDIN, '%d', $n);
$cnt = 0;
$arr = [];
for ($i  = 0; $i < $n; $i++) {
    $s = str_split(trim(fgets(STDIN)));
    $j = $s;
    sort($s);
    $j = implode('', $s);
    if (is_null($arr[$j])) {
        $arr[$j] = 1;
    } else {
        $arr[$j]++;
        if ($arr[$j] === 2 ) {
            $cnt++;
        } elseif ($arr[$j] > 2) {
            $cnt += $arr[$j]*($arr[$j]-1)/2 - ($arr[$j]-1)*($arr[$j]-2)/2;
        }
    }
}
echo $cnt.PHP_EOL;

Measured memory_bytes: 13048
n = gets.to_i
weights = gets.split.map(&:to_i)
min_gap = weights.max - weights.min
(n-1).times do |i|
  a = weights[0..i].inject(:+)
  b = weights[(i+1)..-1].inject(:+)
  gap = (a-b).abs
  min_gap = gap if gap < min_gap
end
puts min_gap


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	Scanner input = new Scanner(System.in);
    	int[] days = {31,29,31,30,31,30,31,31,30,31,30,31};
		while(true){
			int m = input.nextInt();
			int d = input.nextInt();
			if(m == 0 && d == 0)break;
			int sum = 0;
			for(int i = 0 ; i < m-1 ; i++){
				sum += days[i];
			}
			sum += d;
			sum--;
			sum %= 7;
			switch(sum){
			case 0:
				System.out.println("Thursday");
				break;
			case 1:
				System.out.println("Friday");
				break;
			case 2:
				System.out.println("Saturday");
				break;
			case 3:
				System.out.println("Sunday");
				break;
			case 4:
				System.out.println("Monday");
				break;
			case 5:
				System.out.println("Tuesday");
				break;
			case 6:
				System.out.println("Wednesday");
				break;
			}
		}
    }
}

Measured memory_bytes: 17208
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll K, A, B;
  cin >> K >> A >> B;
  bool ok = false;
  FOR(i, A, B + 1) {
    if (i % K == 0)
      ok = true;
  }
  if (ok)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 173, task a, 2020/07/05
//ms,
/*
*/

int main(void){
  int N;
  vector<int64_t> a(2*100000);
  int64_t ans = 0;

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

  sort(a.begin(), a.end(), greater<int64_t>());
  //cout <<a[0] <<a[1] <<a[2];

  int counter = N;
  int index = 0;
  while(counter){
    if(counter == N){
      ans += 0;
      counter--;
    }else if(counter == N-1){
      ans += a[index];
      counter--;
      index++;
    }else if(counter-2>=0){
      ans += a[index] * 2;
      counter -= 2;
      index++;
    }else{
      ans +=a[index];
      counter--;
      index++;
    }
  }
  cout <<ans<<endl;

  return 0;
}
/*
*/


Measured memory_bytes: 4660
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

bool search_d(auto l, auto r, auto s)
{
  REP2(i, l, r-1) if (s[i] == '#' && s[i+1] == '#') return false;
  return true;
}

bool search_t(auto l, auto r, auto s)
{
  REP2(i, l-2, r-1) if (s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') return true;
  return false;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  bool flg;
  if (c < d)
  {
    if (search_d(a, d, s)) flg = true;
    else flg = false;
  }
  else
  {
    if (search_d(a, c, s))
    {
      if (search_t(b, d, s)) flg = true;
      else flg = false;
    }
    else flg = false;
  }
  if (flg) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 720
/*
  AOJ 2544
  Title:Older Research Bldg. No.7
  @kankichi573
*/
#include <stdio.h>
int N,Q;
int  year[50];
char name[50][31];
char *ans;
char h1name[]="kogakubu10gokan";
solve()
{
  int i;

  if(year[0]>Q)
    {
      ans=h1name;
      return;
    }
  for(i=0;i<N-1;i++)
    if(Q>=year[i] && Q<year[i+1])
      {
	ans=&name[i][0];
	return;
      }
  ans=&name[N-1][0];
}
main()
{
  int i;

  scanf("%d %d",&N,&Q);
  for(i=0;i<N;i++)
    scanf("%d %s",&year[i],&name[i][0]);
  solve();
  printf("%s\n",ans);
  return(0);
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        for (int p = 0; p <= 1000; p++) {
            if ((2 * p) / 25 == a && p / 10 == b) {
                System.out.println(p);
                return;
            }
        }
        System.out.println(-1);
    }
}


Measured memory_bytes: 21972
N, M = list(map(int, input().split()))

solved = {}
failed = {}
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'AC':
        if p in solved:
            pass
        else:
            solved[p] = 1
    else:
        if not (p in solved):
            if p in failed:
                failed[p] += 1
            else:
                failed[p] = 1

for p in failed:
    if not p in solved:
        failed[p] = 0

print(sum(solved.values()), sum(failed.values()))

Measured memory_bytes: 15072
import sys
input = sys.stdin.readline

N = int(input())
points = [0] * N
rx = []
ry = []
for i in range(N):
    x, y = map(int, input().split())
    rx.append(x - y)
    ry.append(x + y)
print(max(max(rx) - min(rx), max(ry) - min(ry)))

Measured memory_bytes: 89804
a, b, k = map(int, input().split())
ans = set()
for i in range(a, min(a+k, b+1)):
    ans.add(i)
for i in range(max(a, b-k+1), b+1):
    ans.add(i)
ans = sorted(ans)
for i in ans:
    print(i)

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

#include <cstring>
using namespace std;

#ifdef LOCAL
    #define LLD_SPEC "%lld"
#else
    #define LLD_SPEC "%I64d"
#endif

const int MAX_S = 1e5 + 100;

char s[MAX_S];

int main() {
    scanf("%s", s);

    int n = strlen(s);

    for (int i = 1; i < n; ++i) {
        if (s[i - 1] == s[i]) {
            printf("%d %d\n", i, i + 1);
            return 0;
        }
    }

    for (int i = 0; i + 2 < n; ++i) {
        if (s[i] == s[i + 2]) {
            printf("%d %d\n", i + 1, i + 3);
            return 0;
        }
    }

    printf("-1 -1\n");

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) {
            cout << "DENIED\n";
            return 0;
        }
    }
    cout << "APPROVED\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,n;
  cin >> a >> b >> n;
  long long mi=123456789012345;
  for(long long i=1;i<=n;i++){
    if(b%i)continue;
    for(long long j=1;j<=n;j++){
      long long x=b/i*j;
      if(x==0)continue;
      mi=min(abs(a-x),mi);
    }
  }
  cout << mi << endl;
  return 0;
}

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

int main(){
    double d, t, s;
    cin >> d >> t >> s;
    if(d/s > t){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0; 
}

Measured memory_bytes: 3736
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int d = scn.nextInt();
      	int t = scn.nextInt();
      	int s = scn.nextInt();
      	
      	int time = d/s;
      	if(d%s != 0) time++;
      
      	if(time <= t) System.out.println("Yes");
        else System.out.println("No");
	}
}


Measured memory_bytes: 35640
#include <stdio.h>


int main(){
	int k,a,b;
	int flag = 0;
	scanf("%d",&k);
	scanf("%d %d",&a,&b);
		for(int i=a;i<=b;i++){
			if(i%k==0){
				flag = 1;
			}
		}
		flag== 1 ? puts("OK") : puts("NG");

	return 0;
}

Measured memory_bytes: 2048
A = []
B = []
S = 0
for i in range(4):
    a = int(input())
    A.append(a)
    A.sort(reverse=True)
for j in range(3):
    S = S+A[j]
for i in range(2):
    a = int(input())
    B.append(a)
    B.sort(reverse=True)
for j in range(1):
    S = S+B[j]
print(S)
    


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int r;
	cin >> r;
	cout << (r*r) << endl;
	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,s=0,A[100];
    for(i=0;i<3;i++)
    {
        cin >> A[i];
    }
    for(i=0;i<3;i++)
    {
        s=s+A[i];
    }
    if(s<22)
    {
        cout << "win" <<endl;
    }
    else
    {
        cout << "bust" <<endl;
    }

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
ans=chk=0
for i in a:
    ans+=abs(chk-i)
    chk=i
ans+=abs(a[-1])
for i in range(n):
    x=ans
    if i==0:
        x-=abs(a[0])
        x-=abs(a[0]-a[1])
        x+=abs(a[1])
    elif i==n-1:
        x-=abs(a[-1])
        x-=abs(a[-1]-a[-2])
        x+=abs(a[-2])
    else:
        x-=abs(a[i-1]-a[i])
        x-=abs(a[i+1]-a[i])
        x+=abs(a[i-1]-a[i+1])
    print(x)

Measured memory_bytes: 14048
#include <iostream>
#include <set>

using namespace std;


int N,X;

set<int> S;

long long int ans;

long long int MOD = 1000000007;

void CALC(set<int> S, int X) {
	//cout << "X= " << X << endl;
	int M = S.size();
	if (M == 1) { ans+=X% ( *S.begin()); ans %= MOD; return; }


	auto it = S.begin();
	int Y = (*it);

	if (Y > X) {
		long long int tmp = 1;
		for (long long int i = 1; i <= M; i++) {
			tmp *= i; tmp %= MOD;
		}
		tmp *= X; tmp %= MOD;
		ans += tmp; ans %= MOD;
	}
	else {

		for (auto it = S.begin(); it != S.end(); it++) {
			set<int>T = S;
			int H = *it;
			T.erase(H);
			CALC(T, X%H);
		}
	}

}

long long int ans2;

void CALC2(set<int> S, long long int X, long long int factor) {

	long long int M = S.size();

	long long int num = 0;
	set<int> T = S;
	for (auto it = S.begin(); it != S.end(); it++) {
		int H = (*it);
		if (H > X) { num++; T.erase(H); }
	}

	for (int i = 1; i <= num; i++) {
		factor *= M;
		factor %= MOD;
		M--;
	}


	if (T.size() == 0) {
		ans2 += factor*X;
		ans2 %= MOD;
	}
	else {
		for (auto itt = T.begin(); itt != T.end(); itt++) {
			int Y = (*itt);
			set<int> W = T;
			W.erase(Y);
			CALC2(W, X%Y, factor);
		}
	}

}


long long int dp[100005];

int main(void) {

	cin >> N >> X;
	int tmp;
	for (int i = 1; i <= N; i++) {
		cin >> tmp; S.insert(tmp);
	}

	//CALC(S, X);
	//CALC2(S, X, 1);

	dp[X] = 1;

	//========== initial
	int num = 0;
	for (auto it = S.begin(); it != S.end(); it++) {
		int H = (*it);
		if (H > X) { num++; }
	}
	dp[X] = 1;
	for (long long int j = N; j >= N - num + 1; j--) {
		dp[X] *= j;
		dp[X] %= MOD;
	}

	//===================


	for (int i = 100000; i >= 1; i--) {
		//cout << "i= " << i << endl;
		if (dp[i] == 0) { continue; }
		int num1 = 0;
		for (auto it = S.begin(); it != S.end(); it++) {
			long long int H = (*it);
			if (i>= H) { num1++; }
		}
		for (auto it = S.begin(); it != S.end(); it++) {
			long long int H = (*it);
			if (H > i) { break; }
			long long int g = i%H;
			long long int num2 = 0;
			for (auto itt = S.begin(); itt != S.end(); itt++) {
				long long int tmp = (*itt);
				if (tmp<=g) { num2++; }
			}
			long long int v = dp[i];
			for (long long int j = num1-1; j >= num2+ 1; j--) {
				v *= j; v %= MOD;
			}
			dp[g] += v; dp[g] %= MOD;
		}
	}

	ans = 0;
	int min_val = (*S.begin());
	for (int i = 0; i < min_val; i++) {
		ans += dp[i]*((long long int)i);
		ans %= MOD;
	}

	/*for (int i = 0; i < 100; i++) {
		cout << "dp[" << i << "]= " << dp[i] << endl;
	}*/

	cout << ans <<" " << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    multiset<ll, greater<ll>> s;
    map<ll, int> mp;
    for (int i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        if (++mp[x] == 2){
            s.insert(x);
            mp[x] = 0;
        }
    }

    if (s.size() < 2) cout << 0 << endl;
    else{
        cout << *s.begin() * *++s.begin() << endl;
    }
}

Measured memory_bytes: 6528
n = gets.to_i
target_number = 8
ans = 0

def divide_number(n)
  counter = 0
  1.upto(n) do |i|
    counter += 1 if n % i == 0
  end
  counter
end

1.upto(n) do |i|
  next if i % 2 == 0
  ans += 1 if divide_number(i) == target_number
end

puts ans

Measured memory_bytes: 1788
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    n = len(s)
    res = 0
    for i in range(n):
        if i <= (n-1)//2:
            if s[i]=='p':
                res -= 1
        else:
            if s[i] == 'g':
                res += 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include <cstdio>

using namespace std;
int main()
{
    char X,Y;

    //input : X Y
    scanf("%c %c", &X, &Y);

    // printf("%c\n", X);
    // printf("%c\n", Y);

    if(X > Y) printf(">");
    else if(X == Y) printf("=");
    else printf("<");

    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.util.stream.*;

public class Main {

	int mod = 1000000007;

	class P implements Comparable<P>{
		int d;
		int c;
		P(int d, int c){
			this.d=d;
			this.c=c;
		}
		@Override
		public int compareTo(P arg0) {
			return Integer.compare(this.d, arg0.d);
		}
	}
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		List<P> s = new ArrayList<>();
		for(int i=1; i*i<=n; i++) {
			s.add(new P(i, 0));
			s.add(new P(n/i, 0));
		}

		Collections.sort(s);

		s = s.stream().distinct().collect(Collectors.toList());

		for(int i=0; i<s.size()-1; i++) {
			int l = n/s.get(i+1).d;
			int r = n/s.get(i).d;
			s.get(i).c =  r-l;
		}
		s.get(s.size()-1).c = 1;
		int m = s.size();
		HashMap<Integer, Integer> mp = new HashMap<>();
		for(int i=0; i<m; i++) {
			mp.put(s.get(i).d, i);
		}
		long dp[][] = new long[k+1][m];
		dp[0][mp.get(n)] = 1;
		for(int i=0; i<k; i++) {
			for(int j = m-2; j>=0; j--) {
				dp[i][j] += dp[i][j+1];
				dp[i][j] %= mod;
			}
			for(int j=0; j<m; j++) {
				int nj = mp.get(n/s.get(j).d);
				long tmp = dp[i][nj] * s.get(j).c;
				tmp %= mod;
				dp[i+1][j] += tmp;
				dp[i+1][j] %= mod;
			}
		}
		int ans = 0;
		for(int i=0; i<m; i++) {
			ans += dp[k][i];
			ans %= mod;
		}
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 133696
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<ll> v(n);
  map<ll, ll> m;
  ll ss = 0;
  for (auto &x : v) {
    cin >> x;
    ss += x;
    m[x]++;
  }
  int q, b, c;
  cin >> q;
  while (q--) {
    cin >> b >> c;
    if (m.find(b) != m.end()) {
      ss += ((c - b) * m[b]);
      m[c] += m[b];
      m.erase(b);
    }
    cout << ss << "\n";
  }
}

Measured memory_bytes: 7948