akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int digitSum(int n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

signed main(void)
{
    // int n;
    // cin >> n;
    // vector<int> a(n);
    // rep(i, n)
    // {
    //     cin >> a[i];
    // }

    string str;
    cin >> str;
    int n = str.size();

    rep(i, n)
    {
        if (str[i] == str[n - i - 1])
        {
        }
        else
        {
            sayNo();
            return 0;
        }
    }

    rep(i, (n - 1) / 2 - 1)
    {
        if (str[i] == str[(n - 1) / 2 - i - 1])
        {
        }
        else
        {
            sayNo();
            return 0;
        }
    }

    for (int i = (n + 3) / 2 - 1; i < n; ++i)
    {
        if (str[i] == str[n - 1 - i])
        {
        }
        else
        {
            sayNo();
            return 0;
        }
    }

    sayYes();
    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,z=0;
  cin>>a>>b>>c;
  z=max(a*10+b+c,b*10+a+c);
  cout<<max(c*10+b+a,z)<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int num[4], n, m;
int main()
{
    memset(num, -1, sizeof(num));
    cin >> n >> m;
    while (m--)
    {
        int s, c;
        cin >> s >> c;
        if (num[s] == -1)
            num[s] = c;
        else if (num[s] != c)
        {
            //cout << num[s] << "-" << c << endl;
            cout << -1;
            return 0;
        }
    }
    if (n > 1 and num[1] == 0)
    {
        cout << -1;
        return 0;
    }
    if (num[1] == -1 and n>1) num[1] = 1;
    for (int i = 1; i <= n; i++)
        if (num[i] == -1)num[i] = 0;
    for (int i = 1; i <= n; i++)
    {
        cout << num[i];
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    string a,b;
    cin >> a >> b;
    istringstream iss(a+b);
    int tmp;
    iss >> tmp;

    for(int i = 1; i <= 100000 ; ++i){
        if(i*i == tmp){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// Contest: AtCoder Beginner Contest 177 (https://atcoder.jp/contests/abc177)
// Problem: B: Substring (https://atcoder.jp/contests/abc177/tasks/abc177_b)


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

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

    string s, t; cin >> s >> t;
    int n = sz(s), m = sz(t);
    int mn = INF;
    for (int i = 0; i + m <= n; ++i) {
        int c = 0;
        rep(j, m)
            c += s[i + j] != t[j];
        mn = min(mn, c);
    }

    cout << mn << '\n';
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n,m; cin >>n >>m;
  int x=0,y=1e5+1;
  for(int i=0; i<m; i++){
    int l,r; cin >>l >>r;
    if(l>x) x=l;
    if(r<y) y=r;
  }
  cout <<(x<=y?y-x+1:0);
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    double L;
    cin >> L;
    L /= 3.0;
    cout << std::setprecision(15) << L  * L * L << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict';

function Main(input) {
    const tmp = input.split('\n');
    const ary = tmp[0].split(' ');

    let after = ary.filter((x, i, self) => self.indexOf(x) === i);
    console.log(after.length);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

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

int main(void) {
  ll n;
  cin>>n;
  string s = "357";
  string ss = "357";
  set<ll> st;
  do {
    st.insert(stoll(s));
  } while(next_permutation(s.begin(), s.end()));

  for(auto &i0 : ss) {
    string s = "357";
    s += i0;
    sort(s.begin(), s.end());
    do {
      st.insert(stoll(s));
    } while(next_permutation(s.begin(), s.end()));
  }

  for(auto &i0 : ss) {
    for(auto &i1 : ss) {
      string s = "357";
      s += i0;
      s += i1;
      sort(s.begin(), s.end());
      do {
  	st.insert(stoll(s));
      } while(next_permutation(s.begin(), s.end()));
    }
  }

  for(auto &i0 : ss) {
    for(auto &i1 : ss) {
      for(auto &i2 : ss) {
	string s = "357";
  	s += i0;
	s += i1;
	s += i2;
  	sort(s.begin(), s.end());
  	do {
  	  st.insert(stoll(s));
  	} while(next_permutation(s.begin(), s.end()));	
      }
    }
  }

  for(auto &i0 : ss) {
    for(auto &i1 : ss) {
      for(auto &i2 : ss) {
  	for(auto &i3 : ss) {
	  string s = "357";
	  s += i0;
	  s += i1;
	  s += i2;
  	  s += i3;
  	  sort(s.begin(), s.end());
  	  do {
  	    st.insert(stoll(s));
  	  } while(next_permutation(s.begin(), s.end()));		  
  	}
      }
    }
  }

  for(auto &i0 : ss) {
    for(auto &i1 : ss) {
      for(auto &i2 : ss) {
  	for(auto &i3 : ss) {
  	  for(auto &i4 : ss) {
	    string s = "357";
	    s += i0;
	    s += i1;
	    s += i2;
	    s += i3;
  	    s += i4;
  	    sort(s.begin(), s.end());
  	    do {
  	      st.insert(stoll(s));
  	    } while(next_permutation(s.begin(), s.end()));
  	  }
  	}
      }
    }
  }

  for(auto &i0 : ss) {
    for(auto &i1 : ss) {
      for(auto &i2 : ss) {
  	for(auto &i3 : ss) {
  	  for(auto &i4 : ss) {
  	    for(auto &i5 : ss) {
	      string s = "357";
	      s += i0;
	      s += i1;
	      s += i2;      
	      s += i3;
	      s += i4;
	      s += i5;
  	      sort(s.begin(), s.end());
  	      do {
  		st.insert(stoll(s));
  	      } while(next_permutation(s.begin(), s.end()));
  	    }
  	  }
  	}
      }
    }
  }

  ll cnt = 0;
  for(auto &x : st) {
    if(x <= n)
      cnt++;
  }
  std::cout << cnt << std::endl;
  return 0;
}



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

class Main {

	public static final int MAX = 200000;

	public static void main(String[] args) throws IOException {

		int Nums[] = new int[MAX];

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String n = br.readLine();

		for(int i=0; i<Integer.parseInt(n); i++){
			 Nums[i] = Integer.parseInt(br.readLine());
			}


		int max = -2000000000;
		int min = Nums[0];

		for(int i=1; i<Integer.parseInt(n); i++){
			max = Math.max(max, Nums[i]-min);
			min = Math.min(min, Nums[i]);
		}

		System.out.println(max);

	}

}

Measured memory_bytes: 42540
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>l(n);
  int64_t ans=0;
  for(int i=0;i<n;i++){
    cin>>l.at(i);
  }
  sort(l.begin(),l.end());
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(l.at(i)+l.at(j)<=l.at(k))break;
        if(l.at(i)+l.at(j)>l.at(k)&&(l.at(j)+l.at(k)>l.at(i)&&l.at(i)+l.at(k)>l.at(j)))ans++;
      }
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3584
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd
enu = enumerate

sys.setrecursionlimit(10**7)
N, A, B = map(int, input().split())

AB = A+B
if AB == 0:
    print(0)
    exit()

if A >= N:
    print(N)
elif AB >= N:
    print(A)
else:
    cnt = A * (N//AB)
    if N % AB >= A:
        cnt += A
    else:
        cnt += N % AB
    print(cnt)




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

int main() {
    /* Input */
    int n;
    cin >> n;

    vector<int> staff_ids(n);

    for (int i = 1; i < n; i++) {
        int boss;
        cin >> boss;
        staff_ids.at(boss - 1)++;
    }

    rep (i, n) cout << staff_ids.at(i) << endl;

    /* Output */
    return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  int A[110];
  cinf(M,A) ;
  int cnt1=0;
  int cnt2=0;
  for(int i=0;i<M;i++){
    for(int j=X+1;j<N;j++){
      if(A[i] == j)
        cnt1 ++;
    }
  }
  rep(i,M){
    for(int j=0;j<X;j++){
      if(A[i] == j)
        cnt2 ++;
    }
  }
  cout << min(cnt1,cnt2)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long n,y;
  cin >> n >> y;
  long long i,j;
  for(i=0;i<=n;i++){
    for(j=0;j<=n-i;j++){
      if((y-1000*i-5000*j)/10000==n-i-j && (y-1000*i-5000*j)%10000==0 && (y-1000*i-5000*j)>=0){
        cout << n-i-j << " " << j << " " << i << "\n";
        return 0;
      }
    }
  }
  cout << -1 << " " <<  -1 << " " << -1 << "\n";
  return 0;
}

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

#define lint long long

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

    int A[N];


    cin >> A[0];
    lint sum = abs(A[0]);

    for(int i = 1; i < N; ++i){
        cin >> A[i];
        sum += abs(A[i] - A[i - 1]);
    }
    sum += abs(A[N - 1]);

    cout << sum - abs(A[0]) - abs(A[1] - A[0]) + abs(A[1]) << endl;
    
    for(int i = 1; i < N - 1; ++i){
        cout << sum - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i + 1] - A[i - 1]) << endl;
    }

    cout << sum - abs(A[N - 1]) - abs(A[N - 2] - A[N - 1]) + abs(A[N - 2]) << endl;

    

}

Measured memory_bytes: 1664
n = int(input())
AB = []
A = [0]*n
B = [0]*n
for i in range(n):
  A[i],B[i] = map(int,input().split())  

A = sorted(A)  
B = sorted(B)  

if n%2 == 1:
  l = A[n//2]
  r = B[n//2]
  print(r-l + 1)
else:
  l = (A[n//2-1]+A[n//2])/2
  r = (B[n//2-1]+B[n//2])/2
  print(int((r-l)*2+1))

Measured memory_bytes: 26884
#include<stdio.h>
int main()
{
	int n;
	int a,b,c;
	scanf("%d",&n);
	a=n/100;
	if(a*111>=n){
		printf("%d\n",a*111);
	}
	else{
		printf("%d\n",(a+1)*111);
	}
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int a,b;
    cin >> a >> b;
    int ans=-1;
    for(int i=1;i<1010;i++){
        if(int(i*0.08)==a && int(i*0.1)==b){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// ===========================================
// 20.02.25 atcoder キーエンス プログラミング コンテスト 2020, A - Painting 
// 
// 
// ===========================================

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ET "\n"
#define CLR(arr) memset(arr, 0, sizeof(arr))
#define PAIR pair<int, int>
const ll INF = 1LL << 50;



int main(){
    
    int H, W, N; cin >> H >> W >> N;
    bool Area[H+1][W+1];
    
    int B = (H > W ? H : W);
    int ans = 0;
    ans = N / B;
    if(N % B > 0) ans++;
    cout << ans;
}



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

int main() {
	char b;
	cin >> b;
	if (b=='A'){
     cout << 'T';
	}
	else if(b=='T'){
		cout << 'A';
	}
	else if(b=='C'){
		cout << 'G';
	}
    else if(b=='G'){
		cout << 'C';
    }
	return 0;
}

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

#define MOD ((int)1e9+7)
#define MAX_VAL ((int)1e6)

long long fac[MAX_VAL], mmi[MAX_VAL];
long long N, M;

void factorial_mod(){
	 fac[0]=fac[1]=1;
	for(long long i = 2; i < MAX_VAL; fac[i]%=MOD,i++)
		fac[i] = fac[i-1]*(i%MOD);
}


void exgcd(long long a, long long b, long long &x, long long &y){
	if(b == 0){x = 1;y = 0;return;}
	exgcd(b,a%b,y,x);
	y -= a/b * x;
}

void modular_multiplicatibe_inverse(){
	long long x, y;  
	exgcd(fac[MAX_VAL-1],MOD,x,y);
	mmi[MAX_VAL-1] = x; 
	for(long long i = MAX_VAL-2; i >= 0; mmi[i]%=MOD,i--)
		mmi[i] = mmi[i+1]*((i+1)%MOD);
}

long long combination_mod(long long n, long long r){
	return fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}

int main(){
	long long ans = 1, t;
	
	cin>>N>>M;
	
	t = M;
	
	factorial_mod();
	
	modular_multiplicatibe_inverse();
	
	for(long long i = 2; i*i <= t; i++){
		long long count = 0;
		while(t%i==0){
			count++;
			t /= i;
		}
		// cout<<i<<" "<<count<<endl;
		ans *= combination_mod(count+N-1,N-1);
		ans %= MOD;
	}
	
	if(t!=1) ans *= combination_mod(1+N-1,N-1);
	
	cout<<ans%MOD<<endl;
	
	return 0;
}

Measured memory_bytes: 15872
n = int(input())
l = []
c = 1
while n != 0:
    if n % 2**c !=0:
        n -= (-2)**(c-1)
        l.append('1')
    
    else:
        l.append('0')
    
    c += 1

if len(l) == 0:
    print('0')

else:
    print(''.join(reversed(l)))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MAX 1000000007
#define ll long long int
#define fo(i,a,n) for(int i=a;i<n;i++)
#define ull unsigned long long int
#define pb push_back
#define eb emplace_back
using namespace std;


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    // int t;
    // cin>>t;
    // while(t--){
    // }
    int n;
    cin>>n;

    int arr[n];
    fo(i,0,n){
        cin>>arr[i];
    }
    ll pref[n];
    pref[n-1]=0;

    for(int i=n-2;i>=0;i--){
        pref[i] = (pref[i+1]%MAX + arr[i+1]%MAX)%MAX;
    }

    ll ans=0;

    for(int i=0;i<n-1;i++){
        ans = ((ans)%MAX + ((pref[i])%MAX * (arr[i])%MAX)%MAX)%MAX;
    }

    cout<<ans<<endl;

    return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,d,a;
    cin >> n >> d >> a;
    vector<pair<ll,ll>> x(n);
    vector<ll> indx(n);
    for(i = 0;i < n;++i){
        cin >> x.at(i).first >> x.at(i).second;
        indx.at(i) = x.at(i).first;
    }
    sort(all(x));
    sort(all(indx));
    vector<ll> imos(n,0);
    ll ans = 0;
    for(i = 0;i < n;++i){
        if(i == 0){
            ll dif = x.at(i).second;
            ll tmp = ((dif-1)/a+1)*a;
            ans += tmp/a;
            imos.at(i) += tmp;
            ll dis = indx.at(i) + 2*d;
            ll ind = upper_bound(all(indx), dis) - indx.begin();
            if(ind == n){
                continue;
            }else{
                imos.at(ind) -= tmp;
            }
        }else{
            imos.at(i) += imos.at(i-1);
            if(imos.at(i) >= x.at(i).second)    continue;
            ll dif = x.at(i).second - imos.at(i);
            ll tmp = ((dif-1)/a+1)*a;
            ans += tmp/a;
            imos.at(i) += tmp;
            ll dis = indx.at(i) + 2*d;
            ll ind = upper_bound(all(indx), dis) - indx.begin();
            if(ind == n){
                continue;
            }else{
                imos.at(ind) -= tmp;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
import heapq
from collections import deque

n, d, a = map(int, input().split())
monster = []
for _ in range(n):
  x, h = map(int, input().split())
  heapq.heappush(monster, (x, h))
bomb = 0
damage = 0
queue = deque()
while monster:
  x, h = heapq.heappop(monster)
  while True:
    if queue and x > queue[0][0]:
      damage -= queue.popleft()[1]
    else:
      break
  h -= damage
  if h <= 0:
    continue
  b = (h - 1) // a + 1
  bomb += b
  queue.append((x + 2 * d, a * b))
  damage += a * b
print(bomb)

Measured memory_bytes: 34832
X,Y = map(int,input().split())
mod = 10**9+7



def p(m,n):
  a = 1
  for i in range(n):
    a = (a*(m-i)) % mod
  return a

def c(m,n):
  return p(m,n)*pow(p(n,n),mod-2,mod) % mod

if (X+Y) % 3 == 0 and Y//2 <= X <= Y*2:
  print(c((X+Y)//3,(2*X-Y)//3))
else:
  print(0)

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

using namespace std;

int main()
{
    int a[ 12 ][ 12 ];
    int n, m, x;
    cin >> n >> m >> x;

    vector< int > c( n );

    for( int i = 0; i < n; i++ )
    {
        cin >> c[ i ];
        for( int j = 0; j < m; j++ )
            cin >> a[ i ][ j ];
    }

    int ans = INT_MAX;
    
    for( int s = 0; s < ( 1 << n ); s++ )
    {
        int cost = 0;
        vector< int > d( m );

        for( int i = 0; i < n; i++ )
        {
            if(s>>i&1)
            {
                cost += c[ i ];
                for( int j = 0; j < m; j++ )
                    d[ j ] += a[ i ][ j ];
            }
        }

        bool flag = true;
        for( int j = 0; j < m; j++ )
            if( d[ j ] < x )
            {
                flag = false;
                //break;
            }
        
        if( flag )
            ans = min( cost, ans );
    }

    if( ans == INT_MAX )
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#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;
    if (b % a == 0)
    {
        cout << a + b << endl;
    }
    else
    {
        cout << b - a << endl;
    }
}

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

ll g(ll n, int p)
{
    if (n == 0)
        return 0;
    return g(n / p, p) + n / p;
}

ll g2(ll n, int p)
{
    ll ret = g(n / 2, p);
    if (p == 2)
        ret += n / 2;
    return ret;
}

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

    if (n % 2 == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    ll ans = min(g2(n, 2), g2(n, 5));
    cout << ans << endl;

    return 0;
}

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

int main(){
  int N, x;
  cin >> N >> x;
  int a[N+1] = {0};
  for(int i = 1; i <= N; i++){
    cin >> a[i];
  }
  ll ans = 0;
  for(int i = 1; i <= N; i++){
    if(a[i] + a[i-1] > x){
      ans += (a[i] + a[i-1] - x);
      a[i] -= a[i] + a[i-1] - x;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <math.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <iomanip>
#include <stdio.h>
#define INF 1000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;

int main() {

	char s[4]; cin >> s[0] >> s[1] >> s[2] >> s[3];
	if (s[0] != s[1] && s[1] != s[2] && s[2] != s[3]) { cout << "Good" << endl; }
	else { cout << "Bad" << endl; }

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 998244353
#define N 200005

int main()
{
    string s;
    cin>>s;
    set<char> st;
   //for(int i=0;i<6;i++) st.insert(s[i]);
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main(){
    int n;
    cin >> n;
    
    int A[n];
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    
    int v;
    int j;
    for(int i = 0; i < n; i ++){
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            --j;
        }
        A[j+1] = v;
        
        printf("%d", A[0]);
        if(n > 1){
            for(int k = 1; k < n; k++){
                printf(" %d", A[k]);
            }
        }
        printf("\n");
    }
}


Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

constexpr int MaxN = 1000 + 10;
int H[MaxN];
int indexes[MaxN];

int main()
{
    int n, t, a;
    cin >> n >> t >> a;
    for (int i = 0; i < n; i++)
    {
        cin >> H[i];
    }

    iota(indexes, indexes + n, 0);
    sort(indexes, indexes + n, [t, a](int left, int right)
    {
        auto Temp = [t](int height) { return t - height * 0.006; };
        return abs(Temp(H[left]) - a) < abs(Temp(H[right]) - a);
    });

    cout << (indexes[0] + 1) << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> cards(N);
  int i;
  for( i = 0 ; i < N ; i++ )	cin >> cards.at(i);
  sort( cards.begin(), cards.end() );
  reverse( cards.begin(), cards.end() );
  
  int A = 0, B = 0;
  for( i = 0 ; i < N ; i++ ){
    if( i % 2 == 0 )	A += cards.at(i);
    else				B += cards.at(i);
  }
  
  cout << A - B << endl;
  
}

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

int main() {
  int n = 4;

  int a;
  cin >> a;
  

  int b = a / 100;
  int c = a - b * 100;

  bool isYearB = false; //b
  bool isMonthB = false; //b
  bool isYearC = false;
  bool isMonthC = false;

  if (b > 0 && b < 13) {
    isMonthB = true;
    isYearB = true;
  } else if (b >= 0 && b < 100) {
    isYearB = true;
  }

  if (c > 0 && c < 13) {
    isMonthC = true;
    isYearC = true;
  } else if (c >= 0 && c < 100) {
    isYearC = true;
  }

  if (isMonthB && isYearB && isMonthC && isYearC) {
    cout << "AMBIGUOUS" << "\n";
  } else if ((isMonthB || !isYearB) && (!isMonthC || isYearC)) {
    cout << "MMYY" << "\n";
  } else if ((!isMonthB || isYearB) && (isMonthC || !isYearC)) {
    cout << "YYMM" << "\n";
  } else {
    cout << "NA" << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<long long int> vc;
int main()
{

long long h,n;
cin>>h>>n;
for(int i=0;i<n;i++){
    long long int x;
    cin>>x;
    vc.push_back(x);


}
for(int i=0;i<vc.size();i++){


    h=h-vc[i];
    if(h<=0) {cout<<"Yes"; return 0;}

}
cout<<"No" ;


    return 0;
}


Measured memory_bytes: 1400
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    s, t = map(int, input().split())
    G[s].append(t)

ans = []
V = set()

def dfs(n):
    for e in G[n]:
        if e not in V:
            dfs(e)
    ans.append(n)
    V.add(n)


for i in range(N):
    if i not in V:
        if i not in V:
            dfs(i)
            print()

print(*ans[::-1], sep="\n")


Measured memory_bytes: 9472
#include <stdio.h>
int main(void)
{
	int array[100];
	int n,i;

	scanf("%d", &n);

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

	i--;

	for (; i >= 0; i--) {
		printf("%d", array[i]);

		if (i == 0) {
			break;
		}

		printf(" ");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2048
/*
Rathin Bhargava
IIIT Bangalore

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int a,b;
  cin >> a >> b;
  if(a<=0 && b>=0) cout << "Zero" << endl;
  else
  {
    if(a<0)
    {
      if(b>=0)
      {
        int c = abs(a);
        if(c&1) cout << "Negative" << endl;
        else cout << "Positive" << endl;
      }
      else
      {
        int c = b-a+1;
        if(c&1) cout << "Negative" << endl;
        else cout << "Positive" << endl;
      }
    }
    else cout << "Positive" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
x=int(input())
l=[int(i) for i in input().split()]
mat=[[0 for j in range(m)]for i in range(n)]
curr=1 
c=0 
j1=0
for i in range(n): 
    for j in range(m):
        mat[i][j]=curr 
        c+=1 
        if c==l[j1]: 
            curr+=1 
            j1+=1
            c=0 
for i in range(n):
    if i&1:
        mat[i]=mat[i][::-1]
for i in range(n):
    print(*mat[i])

Measured memory_bytes: 41840
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i;
    cin>>n>>k;
    char s[50];
    cin>>s;
    for(i=0;i<n;i++)
    {
        if(i+1==k)
        {
            char a=s[i];
            a+=32;
            cout<<a;
        }
        else
            cout<<s[i];
    }



    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		try{
			while((line = br.readLine() ) != null){
				String[] sl = line.split(" ");
				int a = (int) Math.log10(Integer.parseInt(sl[0]) + Integer.parseInt(sl[1])) +1 ;
				System.out.println(a);
			}
		} catch(Exception e){
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16988
#!/usr/bin/perl

my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @A = map { $_ - 0 } split(/\s+/,<STDIN>);

my $m = 1000;
my $s = 0;

for(my $i=0;$i<$n;$i++){
  if( $i<$n-1 ){
    if( $A[$i+1]>$A[$i] ){
      # 翌日値上がりすべて株に
      if( $m >= $A[$i] ){
        my $md = $m % $A[$i];
        my $buy = ( $m - $md ) / $A[$i];
        $s += $buy;
        $m -= $buy * $A[$i];
      }
    }
    if( $A[$i+1]<$A[$i] ){
      # 翌日値下がるすべて現金
      $m += $s * $A[$i];
      $s = 0;
    }
  }
  if( $i == $n-1 ){
    # すべて現金
    $m += $s * $A[$i];
    $s = 0;
  }
}
print "$m\n";



Measured memory_bytes: 4860
#include <iostream>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

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

using namespace std;
using ll = long long;
const int mod = 1e9+7;

int main(){
    ll n,mc,tmp;
    cin >> n >> mc;
    rep(i,4){
        cin >> tmp;
        if(mc > tmp){
            mc = tmp;
        }
    }

    ll cnt = n / mc;
    if(n % mc != 0) cnt++;

    cout << cnt + 4 << endl;

    return 0;
}

Measured memory_bytes: 256
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
const int MAXN = 100005;
ll mod=1000000007;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	int n;
	cin>>n;
	vi a(n);
	rep(i,0,n-1){
		cin>>a[i];
	}	
	sort(a.begin(),a.end());
	cout<<a[n-1] - a[0];
	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int n, a, b;
	cin >> n >> a >> b;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	sort(all(p));

	int q1 = 0, q2 = 0, q3 = 0;
	rep(i, n) {
		if (p[i] <= a) q1++;
		if (a + 1 <= p[i] && p[i] <= b) q2++;
		if (b + 1 <= p[i]) q3++;
	}

	cout << min(q1, min(q2, q3)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b;
  cin >> a >> b;
  long long x;
  x = a*b/2;
  if(a*b%2 == 1)
    x = x+1;
  if (a==1 || b==1)
    x = 1;
  cout << x << endl;
}


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

typedef long long ll;
#define pii pair<int, int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

ll l , a , b , c;

int main()
{
    _FastIO;
    cout.precision(12);
    cin >> l;
    if(l % 3)   a++;
    if(l % 3 > 1)   b++;
    l *= 1000000000000;
    a += l / 3;
    b += l / 3;
    c += l / 3;
    double a1 = a * 1.0 / 1000000000000 * 1.0;
    double b1 = b * 1.0 / 1000000000000 * 1.0;
    double c1 = c * 1.0 / 1000000000000 * 1.0;
    cout << fixed << double(a1 * b1 * c1 * 1.0) << endl;
    return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rall(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define sz(a) int((a).size())
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}

int n;
ll a[100005];
map<ll, bool> mp;
void solve() {
    cin >> n;

    ll grundy = 0;
    rep(i, n) {
        cin >> a[i];
        grundy ^= a[i];

        auto bit = a[i] & (-a[i]);
        mp[bit] = true;
    }

    bool ok = true;
    ll ans = 0;
    auto tmp = grundy;
    ll addbit = 0;
    repd(i, 30) {
        auto bit = 1LL << i;
        auto tmp2 = tmp ^ (addbit << i);
        if ((tmp2 & bit) == bit) {
            if (mp.count(bit) == 0) {
                ok = false;
                break;
            }
            ++ans;
            addbit ^= 1;
        }
    }

    if (ok)
        cout << ans << endl;
    else
        cout << -1 << endl;

    return;
}


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

    solve();

    return 0;
}


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

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

	if(s.size() <= k){
		cout << s << endl;
	}
	else if(s.size() > k){
		string sub =  s.substr(0, k );
		cout << sub << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
using namespace std;
string s;
int n,b[10],cnt,sum,aox[8],ans,p,k;
void func(int);
int calc();

int main(){
  int a,len;
  while(1){
    getline(cin,s);
    if(s=="END") break;
    cin>>n;
    for(int i=1;i<=n;i++){
      b[i]=0;
      for(int j=0;j<4;j++) cin>>a,b[i]=(b[i]|(a<<j));
    }
    sum=0;
    len=s.size();
    for(int i=0;i<len;i++)
      if(s[i]=='(') sum++;
    ans=0;
    func(0);
    cout<<ans<<endl;
    getline(cin,s);
  }
  return 0;
}

void func(int d){
  if(d==sum){
    p=k=0;
    if(calc()==15) ans++;
    return;
  }
  for(int i=0;i<3;i++) aox[d]=i,func(d+1);
}

int calc(){
  int r,left,right;
  if(s[p]=='('){
    p++;
    left=calc();
    p++;
    right=calc();
    p++;
    if(aox[k]==0) r=left&right;
    if(aox[k]==1) r=left|right;
    if(aox[k]==2) r=left^right;
    k++;
  }else{
    int x=s[p]-'0';
    r=b[x];
    p++;
  }
  return r;
}

Measured memory_bytes: 1208
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
def cumsum(a):
    """※ aを破壊する
    l[i] = sum(a[:i]) なるlを返す
    sum(a[i:j]) == l[j+1] - l[i]
    """
    c = 0
    n = len(a)
    a.insert(0, 0)
    for i in range(1, n+1):
        a[i] = a[i-1]+a[i]
    return a
a = cumsum(a)
aa = [((item - i)%k) for i,item in enumerate(a)]
ans = 0
from collections import defaultdict
c = defaultdict(int)
for i in range(min(k, len(aa))):
    c[aa[i]] += 1
for i,item in enumerate(aa):
    c[item] -= 1
#     print(c, item)
    ans += c[item]
    if i+k<n+1:
        c[aa[i+k]] += 1
print(ans)

Measured memory_bytes: 125372
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cstring>
#include<cstdio>
using namespace std;

const int ROMA = 256;
int NUM[ROMA];

int main()
{
    NUM['I'] = 1;
    NUM['V'] = 5;
    NUM['X'] = 10;
    NUM['L'] = 50;
    NUM['C'] = 100;
    NUM['D'] = 500;
    NUM['M'] = 1000;
    string s;
    while(cin >> s)
    {
        int ans = 0;
        for(int i = 0;i < s.length() - 1; i++)
        {
            if(NUM[ s[i]] >= NUM[ s[i+1]] ) ans += NUM[ s[i]];
            else ans -= NUM[ s[i]];
        }
        ans += NUM[s[s.length() - 1]];

        cout << ans << endl;

    }
    return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

ll lcm(ll a,ll b){
	while(b){
		a %= b;
		swap(a,b);
	}
	return a;
}
ll gcd(ll a, ll b){
	return a / lcm(a,b) * b;
}
int main(){
	int a,b;
	cin >> a >> b;
	cout << gcd(a,b) << endl;
	return 0;
}


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

int main(void)
{
	bool check[100];
	memset(check,true,sizeof(bool)*100);
	int N=0,K=0;
	cin>>N>>K;
	while(K!=0){
		int num;
		cin>>num;
		while(num!=0){
			int tmp;
			cin>>tmp;
			check[tmp-1]=false;
			--num;
		}
		--K;
	}
	int num=0;
	for(int i=0;i<N;++i){
		if(check[i])
			++num;
	}
	cout<<num;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define INF 1000000001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n, k, h[MAX_N];

signed main(){
	cin >> n >> k;
	REP(i, n) cin >> h[i];
	sort(h, h+n);
	int ret = INF;
	REP(i, n-k+1){
		ret = min(ret, h[i+k-1] - h[i]);
	}
	cout << ret << endl;
    return 0;
}

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

int main() {
    int n,k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1;i <= n;i++){
        int cnt = 0;
        int a = i;
        while(a < k){
            a *= 2;
            cnt++;
        }
        ans += pow(0.5,cnt)/n;
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
n, a, b= [int(i) for i in input().split()]
mod = 10**9 + 7

def nCk(N, K, mod):
  ret = 1  
  for k in range(K):
    ret = (ret *(n - k)) %mod
    
  inv = [1 for _ in range(K+1)]
  finv = [1 for _ in range(K+1)]
  for i in range(2, K+1):
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] =finv[i-1] * inv[i] % mod
    
  return (ret * finv[K]) % mod

def mod_pow(a, n, mod):
  res = 1
  while  n > 0:
    if n & 1:
      res = (res * a ) % mod
    a = a * a  % mod
    n = n >> 1
  return res

print(int(mod_pow(2, n, mod) - nCk(n, a, mod) - nCk(n, b, mod) - 1)%mod)



Measured memory_bytes: 19256
a = tuple(map(int, input().split()))

a5 = 0
a7 = 0
b = 0
i = 0
while i < 3:
    if a[i] == 5:
        a5 += 1
    elif a[i] == 7:
        a7 += 1
    i += 1

if a5 == 2 and a7 == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x, a, b;
  cin >> x >> a >>b;
  if(b-a>=x+1){
    cout << "dangerous" << endl;
  }
  else if (b<=a){
    cout << "delicious" << endl;
  }
  else {
    cout << "safe" << endl;
  }
}

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

void rotate(int*, int, int, int, int);

class Dice {
  public:
  int face[6];
  Dice (int* f) {
    for (int i=0; i<6; i++) face[i] = f[i];
  }
  void roll(char d) {
    if (d=='N') {
      rotate(face, 0, 4, 5, 1);
    }
    if (d=='S') {
      rotate(face, 1, 5, 4, 0);
    }
    if (d=='E') {
      rotate(face, 0, 2, 5, 3);
    }
    if (d=='W') {
      rotate(face, 3, 5, 2, 0);
    }
  }
  void print() {
    cout << face[0] << endl;
  }
};

void rotate(int* f, int a, int b, int c, int d) {
  int t;
  t = f[d];
  f[d] = f[c];
  f[c] = f[b];
  f[b] = f[a];
  f[a] = t;
}

int main()
{
  int f[6];
  for (int i=0; i<6; i++) cin >> f[i];
  Dice d(f);
  string dir;
  cin >> dir;
  for (int i=0; i<dir.size(); i++) d.roll(dir[i]);
  d.print();
  return 0;
}



Measured memory_bytes: 3196
/*
	dp[i][j] = prob. of getting j heads out of coins from i, i+1, .... n-1.
*/
#include <bits/stdc++.h>

using namespace std;

int main(){
	int n;
	vector<double> p;
	vector<vector<double> > dp;
	cin>>n;
	p.assign(n+1, 0);
	dp.assign(n+1, vector<double>(n+1, 0));

	for(int i=0;i<n;i++){
		cin>>p[i];
	}

	dp[n-1][0] = 1-p[n-1];
	dp[n-1][1] = p[n-1];
	for(int i=n-2;i>=0;i--){
		for(int j=n;j>=0;j--){
			dp[i][j] = dp[i+1][j-1]*p[i] + dp[i+1][j]*(1-p[i]);
		}
	}
	/*for(int i=0;i<n;i++){
		for(int j=0;j<=n;j++){
			cout<<setprecision(9)<<fixed<<dp[i][j]<<" ";
		}
		cout<<"\n";
	}*/
	double sum = 0;
	for(int i=n/2+1;i<=n;i++){
		sum += dp[0][i];
	}
	cout<<setprecision(10)<<fixed<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 70656
ans=0
q,h,s,d=map(int,input().split())
n=int(input())
l=[(q,q*8,0.25),(h,h*4,0.5),(s,s*2,1),(d,d,2)]
l.sort(key=lambda x:-x[1])
while n>0:
    c=l.pop()
    ans+=c[0]*int(n//c[2])
    n-=c[2]*int(n//c[2])
    
print(ans)

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

int main(){
    string str1;
    cin>>str1;
    for(int i=str1.size()-1;i>=0;i--){
        if (str1.at(i)=='?'){
            if (i==0){
                str1.at(0)='D';
                break;
            }else{
            str1.at(i)='D';
            }
        }
    }
    cout << str1 << endl;
}


Measured memory_bytes: 3752
import numpy as np
n,m= list(map(int,input().split()))
h =  list(map(int,input().split()))
l = [[] for i in range(n)]
s = [0 for i in range(n)]
c = [0 for i in range(n)]

for i in range(m):
  r1,r2 = list(map(int,input().split()))
  l[r1-1].append(r2)
  l[r2-1].append(r1)
  s[r1-1]=1
  s[r2-1]=1

for i in range(n):
  if l[i] == []:
    pass
  else:
    for j in range(len(l[i])):
      if h[l[i][j]-1]<h[i]:
        c[i] = 1
      else:
        c[i] = 0
        break

        
print(s.count(0)+c.count(1))

Measured memory_bytes: 49528
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for _ in range(N)]

for a in A:
    for d in range(1, D+1):
        if d == 1:
            X += 1
        elif (d-1) % a == 0:
            X += 1

print(X)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n,k;cin>>n>>k;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    sort(a.begin(),a.end());
    sort(b.rbegin(),b.rend());
    long long l = -1, r = 1e+12;
    while(l+1<r){
        long long c = (l+r)/2;
        bool ok = [&]{
            long long s = 0;
            for(int i=0;i<n;i++){
                s += max((long long)0,a[i]-c/b[i]);
            }
            return s<=k;
        }();
        if(ok)r=c;else l=c;
    }
    cout<<r<<endl;
    //写経しました 解説の後半の考え方がまさに天才のそれ
}


Measured memory_bytes: 1792
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
int dp[1<<15];
int v[100005];
int n,cnt[16];
int solve(int mask){
	if(mask==0)return 0;
	if(~dp[mask])return dp[mask];
	int &ret=dp[mask];ret=inf;
	for(int i=1;i<=15;i++){
		if(mask&(1<<i-1)){
			for(int j=i+1;j<=15;j++){
				if(mask&(1<<j-1)){
					ret=min(ret,solve((mask^(1<<i-1)^(1<<j-1))^(1<<(i^j)-1))
					+1+((mask&(1<<(i^j)-1))?1:0));
				}
			}
		}
	}
	return ret;
}
int main(){
	memset(dp,-1,sizeof dp);
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y,z;cin>>x>>y>>z;x++;y++;
		v[x]^=z;v[y]^=z;
	}
	for(int i=1;i<=n;i++)cnt[v[i]]++;
	int mask=0,ans;
	for(int i=1;i<=15;i++){
		if(cnt[i]%2)mask|=(1ll<<i-1);
		ans+=cnt[i]/2;
	}
	cout<<solve(mask)+ans<<endl;
	return 0;
}

Measured memory_bytes: 896
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
 var c = chunk.split("\n")

 c.sort(function(aft, bef){
   return bef - aft
 })
 for (var j = 0; j < 3; j++) {
   console.log(c[j])
 }




 })

Measured memory_bytes: 15596