akhauriyash/Code-Regression huggingface dataset:
n=int(input())
d,x=map(int,input().split())

A=[int(input()) for i in range(n)]

def choco(t):
    k=0
    while(1):
        s=k*t+1
        if s>d: break
        k+=1
    return k

T=[]
for i in A:
    T.append(choco(i))

print(sum(T)+x)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    ll X;
    cin>>N>>X;
    mat buy(N, vec(N));
    rep(i,N) cin>>buy[0][i];
    reps(i,1,N){
        ll last = buy[i-1][N-1];
        rep(j,N){
            buy[i][j] = min(buy[i-1][j], last);
            last = buy[i-1][j];
        }
    }
    ll ans = INF;
    rep(i,N){
        ll sum = 0;
        rep(j,N) sum += buy[i][j];
        ans = min(ans, sum + X * i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 31616
#include<stdio.h>
int main(){
int i,j,n,q,a[1000010],x,y,max=0,z,p=0;
scanf("%d %d\n",&q,&n);
for(i=0;i<q;i++){
a[i]=0;
}
for(i=0;i<n;i++){
scanf("%d %d\n",&x,&y);
a[x]=a[x]+y;
if(a[x]>max){
max=a[x];
z=x;
}
if(y<0 || a[x]==max){
for(j=1;j<=q;j++){
if(a[j]>p){
p=a[j],z=j;
}
}
max=p;
p=0;
}
printf("%d %d\n",z,max);
}
return 0;
}


Measured memory_bytes: 5652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  //s = "1" + s + "1";
  vpii a;
  rep(i,n){
    if(s[i]=='1')continue;
    int p = i;
    rep2(j,i,n){
      if(s[j]=='1' || j==n-1){
        a.push_back(make_pair(i,j));
        p = j;
        break;
      }
    }
    i = p;
  }
  if(a.size()<=k){
    cout << n << endl;
    return 0;
  }
  /*rep(i,a.size()){
    cout << a[i].first << " " << a[i].second << endl;
  }*/
  int lar = 0;
  rep(i,a.size()-k+1){
    if(i==0){
      lar = max(lar,a[k].first);
      continue;
    }
    if(i==a.size()-k){
      lar  = max(lar,n-a[i-1].second);
      continue;
    }
    
    lar = max(lar,a[k+i].first-a[i-1].second);
    //cout << lar << " " << i << endl;
    //cout << lar << endl;
  }
  cout << lar << endl;
        
}






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

int main(){
 int n,m,a,b,count=0;
 cin >> n >> m;
 vector<int> h(n);
 rep(i,n) cin >> h[i];
 vector<bool> ok(n,true);
 rep(i,m){
  cin >> a >> b;
  a--; b--;
  if(h[a]<=h[b]) ok[a]=false;
  if(h[b]<=h[a]) ok[b]=false;
 }
  rep(i,n) if(ok[i]) count++;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3768
N, D = map(int, input().split())
Co = []
for i in range(N):
  Co.append(list(map(int, input().split())))

ans = 0
for i in range(N):
  Di = Co[i][0]**2 + Co[i][1]**2
  if Di <= D**2:
    ans += 1
print(ans)


Measured memory_bytes: 45456
#include<iostream>
using namespace std;
#define int long long int
int32_t main()
{
   int n,m;
   cin>>n>>m;
   int j,arr[n];
   for(j=0;j<n;j++)
      cin>>arr[j];
   int sum=0;
   for(j=0;j<n;j++)
     sum+=arr[j];
   int count=0;
   for(j=0;j<n;j++)
   {
	   int x=arr[j];
	   if(4*m*x>=sum)
	     count++;
   }
   if(count>=m)
     cout<<"Yes"<<endl;
   else
     cout<<"No"<<endl;
}


Measured memory_bytes: 256
from itertools import combinations_with_replacement

n, m, q = map(int, input().split())
a = []
b = []
c = []
d = []
for _ in range(q):
    i, j, k, l = map(int, input().split())
    a.append(i - 1)
    b.append(j - 1)
    c.append(k)
    d.append(l)
it = a + b
it = list(set(it))
na = []
nb = []
for i in range(q):
    for j in range(len(it)):
        if a[i] == it[j]:
            na.append(j)
        if b[i] == it[j]:
            nb.append(j)
ans = 0
for x in combinations_with_replacement(range(1, m+1), len(it)):
    cnt = 0
    for i in range(q):
        if x[nb[i]] - x[na[i]] == c[i]:
            cnt += d[i]
    if ans < cnt:
        ans = cnt
print(ans)

Measured memory_bytes: 9264
#include <iostream>
#include <stdio.h> 
#define N 200005
using namespace std;
int a[N];
double b[N];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]%2) b[i]=a[i]/2+1;
		else b[i]=a[i]/2+0.5;
	}
	double ans=0;
	double temp=0;
	for(int i=1;i<=k;i++)
		temp+=b[i];
	ans=temp;
	for(int i=2;i+k-1<=n;i++){
		temp=temp-b[i-1]+b[i+k-1];
		if(temp>ans) ans=temp;	
	}
	printf("%.12f\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
#define FOR(i, x, y) for (int i=x; i<=y; i++)
#define FORI(i, x, y) for (int i=y; i>=x; i--)
#define debug printf("OK\n")
int n, d;
int main() {
    cin >> n >> d;
    int ans = n / (d * 2 + 1);
    if (n % (d * 2 + 1) != 0) ans++;
    cout << ans << endl;    
    return 0;
}

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

#define ll long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)

//library----------------------------------------------


int main(){
  int y,m,d;
  char a,b;
  cin>>y>>a>>m>>b>>d;
  if(m>=5){
    printf("TBD");
  }else{
    printf("Heisei");
  }
  return 0;
}


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

int main()
{
    int h,w;
    char s[102][103];
    string a;
    
    for (int i = 0; i < 102; i++)
    {
        for (int j = 0; j < 102; j++)
        {
            s[i][j] = '#';
        }
    }
    
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        cin >> a;
        for (int j = 0; j < w; j++)
        {
            s[i + 1][j + 1] = a[j];
        }
    }
    
    for (int i = 0; i <= h + 1; i++)
    {
        for (int j = 0; j <= w + 1; j++)
        {
            cout << s[i][j];
        }
        cout << endl;
    }

    
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(a*b,c)<<endl;
    return 0;
}


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

int main(void){
    int card[4][13]={},n,x;
    char y;
    char hako[4]={'S','H','C','D'};
    
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> y >> x;
        if(y=='S'){
            card[0][x-1]=1;
        }else if(y=='H'){
            card[1][x-1]=1;
        }else if(y=='C'){
            card[2][x-1]=1;
        }else if(y=='D'){
            card[3][x-1]=1;
        }
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(card[i][j]==0) cout << hako[i]<< " " << j+1 << endl;
              
        }
    }
    
}




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

int main(){
    ll N, K;
    cin>>N>>K;
    vector<int> A(N+1,0);
    rep(i,N){
        cin>>A.at(i+1);
    }
    int pos = 1;
    vector<int> first_visit(N+1,-1);
    vector<int> visit_N(N+1,-1);

    int cycle;
    int flag =0;
    rep(i,K+1){
        if(first_visit.at(pos)==-1){
            visit_N.at(i)=pos;
            first_visit.at(pos)=i;
            pos = A.at(pos);
        }else{
            cycle = i-first_visit.at(pos);
            break;
        }
        if(i==K){
            flag==1;
            break;
        }
    }

    if(flag==0){
    int aaa = (K-first_visit.at(pos))%cycle;
    cout<<visit_N.at(aaa+first_visit.at(pos))<<endl;
    }else{
        cout<<visit_N.at(K)<<endl;
    }

}


Measured memory_bytes: 5636
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = list(map(str,input().split()))
    print("A"+s[1][0]+"C")

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int b=0,i,x,Max=0;
    int a[4]={0};
    cin>>a[0]>>a[1]>>a[2];
    for(i=0;i<3;i++)
    {
        if(a[i]>Max)
        {
            Max=a[i];
        }
    }
    x=Max*10;
    for(i=0;i<3;i++)
    {
        b+=a[i];
    }
    b-=Max;
    cout<<x+b<<endl;
    return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  int c[20];
  for(int i=0;i<m;i++) cin >> c[i];

  int table[50001];
  table[0]=0;
  for(int i=1;i<=n;i++){
    int mi=table[i-1]+1;
    for(int j=0;j<m;j++){
      if(c[j]>i) continue;
      mi=min(mi,table[i-c[j]]+1);
    }

    table[i]=mi;
  }

  cout << table[n] << endl;

  return 0;
}

Measured memory_bytes: 3260
import Data.List

f3 ::Integer->Integer
f3 0=0
f3 _=10

f::Integer->Integer->Integer->Integer->Integer->Integer->Integer->Integer
f a b c a1 b1 c1 mp
    |a>0 && b>0 && c>0=let (a2:b2:c2:[])=sort (a:b:c:[])
                           (a3:b3:c3:[])=sort (a1:b1:c1:[])
                       in abs(a2-a3)+abs(b2-b3)+abs(c2-c3)+mp
    |otherwise=10^20

f2::[Integer]->Integer->Integer->Integer->Integer->Integer->Integer->Integer->Integer
f2 [] a b c a2 b2 c2 mp=f a b c a2 b2 c2 mp
f2 (x:xs) a b c a2 b2 c2 mp=minimum [f2 xs (a+x) b c a2 b2 c2 (mp+(f3 a)),f2 xs a (b+x) c a2 b2 c2 (mp+(f3 b)),
                                     f2 xs a b (c+x) a2 b2 c2 (mp+(f3 c)),f2 xs a b c a2 b2 c2 mp]

main = do
       l1<-getLine
       ls<-getContents
       let xs=map read (lines ls)::[Integer]
           (_:a2:b2:c2:[])=map read (words l1)::[Integer]
       putStrLn $ show $ f2 xs 0 0 0 a2 b2 c2 0

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vd(T) vector<vector<T>>
#define v(T) vector<T>
#define mod (ll)(1e9+7)
#define pp(T) pair<T,T>
#define pb push_back
#define mp make_pair
#define NN 100005
#define IO ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG cout<<"***********DEBUGGING***********"<<endl
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 
ll power(ll a,ll b){ if(b==0) return 1; ll s=power(a,b/2); s*=s;if(b&1) return s*a; return s;}
ll powermod(ll a,ll b,ll m){ if(b==0) return 1; ll s=power(a,b/2);s*=s; s%=m; if(b&1) return (s*a)%m; return s;}
inline int add(ll a,ll b,ll m=0){
    if(m==0) return a+b;
    return (a%m+b%m)%m;
}

inline int sub(ll a,ll b ,ll m=0){
    if(m==0) return a-b;
    return ((a%m-b%m)%m+m)%m;
}

inline int mul(ll a,ll b,ll m=0){
    if(m==0)return (a*b);
    return ((a%m)*(b%m))%m;
}

inline int div(ll a,ll b,ll m=0){
    if(m==0) return a/b;
    return ((a%m)*(powermod(a,b,m-2)%m))%m;
}

bool isopen(char c){
    return ((c=='(')||(c=='{')||(c=='['));
}

ll longest_balanced_parenthesis(string a,ll n){
    stack<char> s;
    ll start=0;
    ll ans=0,m=0;
    for(ll i=0;i<n;i++){
        if(isopen(a[i])){
            s.push(a[i]);
        }
        else{
            if(isopen(a[i])|| s.empty()){
                m=max(m,ans);
                continue;
            }
            else{
                s.pop();
                ans+=2;
                m=max(ans,m);
            }
        }
    }

    return m;

}

ll setup_k(ll *a,ll k){
  ordered_set x;
  // Now , insert and then check number of integers less than k by just using x.order_of_key(k+1)
}

int main() {

    IO; 

    ll n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    ll c[n];
    loop(i,0,n){
        cin>>c[i];
    }
    
    sort(c,c+n);
    ll ans=0;
    for(ll i=1;i<n;i++){
        ll diff=c[i]-c[i-1];
        if(diff*a>b){
            ans+=b;
        }
        else
            ans+=a*diff;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m;
bool p(int x){
    if (x>=1&&x<=9)return 1;
    return 0;
}
bool pk(int x){
    for (int i=1;i<=9;i++)
        if (x%i==0)
            if (p(x/i))return 1;
    return 0;
}
int main(){
    scanf("%d",&n);
    if (pk(n))printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cstdio>
#define ll long long
using namespace std;

int main() {
	int n,t;
	cin >> n >> t;
	int a[n];
	int s[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int amin = 1987654321;
	int cmax = 0;
	int cnt = 0;

	for(int i = 0; i < n; i++){
		amin = min(amin,a[i]);
		if(cmax < a[i] - amin){
			cmax = a[i] - amin;
			cnt = 1;
		}else if(cmax == a[i] - amin){
			cnt++;
		}
	}

	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
string s;
map<string, int> m;
int solve(string a) {
	if (m.find(a) != m.end())return m[a];
	int res = 1000;
	bool flag = 1;
	for (int i = 0; i < a.length(); i++) {
		if (a[i] != 'o') {
			flag = 0;
			for (int k = 0; k < s.length(); k++) {
				string aa = a;
				for (int j = 0; j < s.length(); j++) {
					if (aa[(i + j) % aa.length()] != 'o') {
						aa[(i + j) % aa.length()] = s[(j + k) % s.length()];
					}
				}
				if (a != aa) {
					res = min(res, 1 + solve(aa));
				}
			}
		}
	}
	if (flag)return m[a] = 1;
	return m[a] = res;
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((b - a == c - b) ? "YES" : "NO");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REPI(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
    int n; cin >> n;
    int a[n]; REPI(i, n) cin >> a[i];
    sort(a, a + n, greater<int>());
    int ans_a = 0, ans_b = 0;

    REPI(i, n){
        if(i%2) ans_b += a[i];
        else ans_a += a[i];
    }cout << ans_a-ans_b;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<math.h>

typedef int32_t i32;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))
#define SORT(a,num,cmp) qsort((a),(num),sizeof(*(a)),cmp)

typedef struct union_find {
  int32_t *parent;
  int32_t size;
} union_find;

void init_union_find (union_find * const u) {
  for (int32_t i = 0; i < u->size; ++i){
    u->parent[i] = -1;
  }
}

union_find* new_union_find (const int32_t size) {
  union_find * const u = (union_find *) calloc (1, sizeof (union_find));
  u->parent = (int32_t *) calloc (size, sizeof (int32_t));
  u->size = size;
  init_union_find (u);
  return u;
}

int32_t root (union_find * const u, int32_t x) {
  if (u->parent[x] < 0) return x;
  return u->parent[x] = root (u, u->parent[x]);
}

int same (union_find * const u, const int32_t x, const int32_t y) {
  return root (u, x) == root (u, y);
}

void unite (union_find * const u, int32_t x, int32_t y) {
  x = root (u, x);
  y = root (u, y);
  if (x == y) return;
  if (u->parent[x] > u->parent[y]) {
    const int32_t swap = x;
    x = y;
    y = swap;
  }
  u->parent[x] += u->parent[y];
  u->parent[y] = x;
}

typedef struct edge {
  i32 a, b;
  double c;
} edge;

int cmp_edge (const void *a, const void *b) {
  return ((edge *)a)->c <= ((edge *)b)->c ? -1 : 1;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *x = ALLOC (3 * n, i32);
  i32 *y = x + n;
  i32 *a = y + n;
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, x + i, y + i, a + i);
  }
  double *dp = ALLOC (1 << n, double);
  union_find *u = new_union_find (n);
  edge *e = ALLOC (n * n, edge);
  for (i32 i = 1; i < (1 << n); ++i) {
    init_union_find (u);
    i32 len = 0;
    double sum = 0;
    i32 cnt = 0;
    for (i32 j = 0; j < n; ++j) {
      if (((i >> j) & 1) == 0) continue;
      sum += a[j];
      cnt++;
      for (i32 k = j + 1; k < n; ++k) {
        if (((i >> k) & 1) == 0) continue;
        double dx = x[j] - x[k];
        double dy = y[j] - y[k];
        e[len++] = (edge) {j, k, sqrt (dx * dx + dy * dy)};
      }
    }
    SORT (e, len, cmp_edge);
    for (i32 j = 0; j < len; ++j) {
      if (same (u, e[j].a, e[j].b)) continue;
      unite (u, e[j].a, e[j].b);
      sum -= e[j].c;
    }
    double max = sum / cnt;
    for (i32 j = (i - 1) & i; j > 0; j = (j - 1) & i) {
      double v = MIN (dp[j], dp[i ^ j]);
      max = MAX (max, v);
    }
    dp[i] = max;
  }
  printf ("%.10f\n", dp[(1 << n) - 1]);
}

int main (void) {
  run();
  return 0;
}


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

typedef long long int ll;
typedef pair<ll,ll> P;
//cout<<fixed<<setprecision(15);

int d;
int c[26];
int s[365][26];

int score(int *init){
    int last[26];
    for(int i=0;i<26;i++){
        last[i]=-1;
    }
    int ans=0;
    for(int i=0;i<d;i++){
        ans+=s[i][init[i]-1];
        last[init[i]-1]=i;
        for(int ct=0;ct<26;ct++){
            ans-=c[ct]*(i-last[ct]);
        }
        cout<<ans<<endl;
    }
    return ans;
}


int main(){
    cin>>d;
    for(int i=0;i<26;i++){
        cin>>c[i];
    }
    for(int x=0;x<d;x++){
        for(int y=0;y<26;y++){
            cin>>s[x][y];
        }
    }
    int iii[365];
    for(int i=0;i<d;i++){
        cin>>iii[i];
    }
    score(iii);
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 998244353
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

ll GCD(ll a, ll b){
    if(b==0) return a;
    else return GCD(b,a%b);
}

int main(){
    ll n; cin >> n;
    REP(h,1,3501){
        REP(w,1,3501){
            ll lcm = h*w/GCD(h,w);
            ll nlcm = n*lcm/GCD(n,lcm);
            ll a = nlcm/n*4 - nlcm/h - nlcm/w;
            if(a>0 && nlcm % a == 0){
                cout << h << " " << w << " " << nlcm/a << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000000

typedef struct{
  char name[10];
  int t;
} Process;

void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(Process);
Process dequeue(void);

int head,tail;

Process Q[MAX];

int main(int argc, char const *argv[]) {

  int n,q;
  int i;
  int sum_times = 0;
  Process Q1;

  scanf("%d%d",&n,&q);

  for( i = 0 ; i < n ; i++ ){
    scanf("%s %d",Q[i].name,&Q[i].t);
  }

  initialize();

  tail = n;

  while( head != tail ){

    if( Q[head].t > q ){
      Q[head].t -= q;
      sum_times += q;
      enqueue(dequeue());
    }else{

      Q1 = dequeue();
      sum_times += Q1.t;
      printf("%s %d\n",Q1.name,sum_times);


    }


  }


  return 0;
}

void initialize(void){
  head = tail = 0;
}

int isEmpty(void){
  // empty??????1?????????
  if( head == tail )
    return 1;
  return 0;
}

int isFull(void){
  // full??????1?????????
  if( head == (tail+1)%MAX )
    return 1;
  return 0;
}

void enqueue(Process x){
  if( isFull() ){
    fprintf(stderr,"?????????????????????\n");
    exit(1);
  }

  Q[tail] = x;
  if( tail + 1 == MAX ){
    tail = 0;
  }else{
    tail++;
  }

}

Process dequeue(void){

  Process x;

  if( isEmpty() ){
    fprintf(stderr,"??¢??????????????????\n");
    exit(2);
  }

  x = Q[head];

  if( head + 1 == MAX ){
    head = 0;
  }else{
    head++;
  }

  return x;

}

Measured memory_bytes: 4692
#include<bits/stdc++.h>
#include<stdio.h>
#define debug(x) cout << '>' << #x << ':' << x << endl;

#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
const int INF = 1e9+5;


using namespace std;


int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	//clock_t time_req;time_req = clock();  
	string s;cin>>s;
	if(s[3]==s[2] && s[5]==s[4]) cout<<"Yes";
	else cout<<"No";

	//time_req = clock()- time_req;cout << "Time Compexity:"<< (float)time_req/CLOCKS_PER_SEC << " seconds" << endl; 
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
AB = []
for i in range(n):
    AB.append(list(map(int, input().split())))
AB = sorted(AB, key=lambda x:x[0])
ans = 0
cnt = 0 
for a, b in AB:
    pre_cnt = cnt
    cnt += b
    if cnt >= m:
        ans += a*(m-pre_cnt)
        break
    else:
        ans += a*b
print(ans)

Measured memory_bytes: 29792
N = int(input())
A = list(map(int, input().split()))
for i in range(1, N):
    v = A[i]
    j = i - 1
    print(' '.join(map(str, A)))
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
print(' '.join(map(str, A)))


Measured memory_bytes: 5592
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        x1: isize,
        y1: isize,
        x2: isize,
        y2: isize,
    }
    let dx = x2 - x1;
    let dy = y2 - y1;
    let x3 = x2 - dy;
    let y3 = y2 + dx;
    let x4 = x3 - dx;
    let y4 = y3 - dy;
    println!("{} {} {} {}", x3, y3, x4, y4)
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main() {
    string s = "MARCH";
    ll c[5] = {};
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        string t; cin >> t;
        for(int j = 0; j < 5; j++) {
            if(s[j] == t[0]) c[j]++;
        }
    }
    ll ans = 0;
    for(int i = 0; i < 5; i++) {
        for(int j = i+1; j < 5; j++) {
            for(int k = j+1; k < 5; k++) {
                ans += c[i] * c[j] * c[k];
            }
        }
    }
    cout << ans << endl;
}

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

#define int long long

int a[100010];
int rui[300010];
int rui2[300010];

int n, m;
int isOK(int num){
    int ans = 0;

    for(int i = 0;i < n;i++){
        ans += rui[max(num-a[i], 0ll)];
    }

    return ans;
}

int solve(int num){
    int ans = 0;

    for(int i = 0;i < n;i++){
        ans += rui2[max(num-a[i], 0ll)]  + a[i] * rui[max(num-a[i], 0ll)];
    }

    return ans;
}

signed main(){
    cin >> n >> m;

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

    for(int i = 100000;i >= 0;i--){
        rui[i] += rui[i+1];
        rui2[i] += rui2[i+1];
    }

    int l = 0, r = 300000;

    while(r-l > 1){
        int mid = (l+r) / 2;
        if(isOK(mid) >= m){
            l = mid;
        }else{
            r = mid;
        }
    }

    int num = isOK(r);

    cout << solve(r) + (m-num) * l << endl;
    return 0;
}


Measured memory_bytes: 3840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    int n;
    int s;
    int t;
    List<Integer>[] adj;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        n = in.nextInt();
        s = in.nextInt() - 1;
        t = in.nextInt() - 1;
        adj = new List[n];
        for (int i = 0; i < n; i++) {
           adj[i] = new ArrayList();
        }
        for (int i = 0; i < n - 1; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            adj[a].add(b);
            adj[b].add(a);
        }
        int[] dist1 = new int[n];
        int[] dist2 = new int[n];
        findDist(t, -1, 0, dist1);
        findDist(s, -1, 0, dist2);
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (dist2[i] < dist1[i]) {
                ans = Math.max(ans, dist1[i] - 1);
            }
        }
        out.println(ans);
    }

    private void findDist(int u, int p, int d, int[] dist) {
        dist[u] = d;
        for (int v : adj[u]) {
            if (v == p) continue;
            findDist(v, u, d + 1, dist);
        }
    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer      tokenizer;

    public InputReader(InputStream stream){
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 68700
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
   
class Main{
       
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
   
public static class Edge{
int to;
int cost;
public Edge(int to){
this.to=to; cost=0;
}
public Edge(int to,int cost){
this.to=to; this.cost=cost;
}
}
   
public static class Pair{
int x;
int y;
public Pair(int x,int y){
this.x=x; this.y=y;
}
public static final Comparator<Pair> DISTANCE_ORDER=new Comp();
private static class Comp implements Comparator<Pair>{
public int compare(Pair p1,Pair p2){
return (p1.x>p2.x)?1:(p1.x<p2.x)?-1:0;
}
}
}
   
public static class MyArrayList extends ArrayList<Edge>{}
   
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
st=new StringTokenizer(line);
int n=Integer.parseInt(st.nextToken());
int k=Integer.parseInt(st.nextToken());
int[] c=new int[n];
int[] r=new int[n];
int[] dist=new int[n];
boolean[][] visited=new boolean[n][n];
MyArrayList[] array=new MyArrayList[n];
MyArrayList[] carray=new MyArrayList[n];
for(int i=0;i<n;i++){
st=new StringTokenizer(br.readLine());
c[i]=Integer.parseInt(st.nextToken());
r[i]=Integer.parseInt(st.nextToken());
array[i]=new MyArrayList();
carray[i]=new MyArrayList();
}
for(int i=0;i<k;i++){
st=new StringTokenizer(br.readLine());
int a=Integer.parseInt(st.nextToken())-1;
int b=Integer.parseInt(st.nextToken())-1;
array[a].add(new Edge(b));
array[b].add(new Edge(a));
}
for(int i=0;i<n-1;i++){
bfs(i,r[i],visited,array);
for(int j=0;j<n;j++){
if(i!=j&&visited[i][j]) carray[i].add(new Edge(j,c[i]));
}
}
dijkstra(dist,carray);
out.println(dist[n-1]);
}
out.flush();
}
   
public static void bfs(int s,int t,boolean[][] visited,MyArrayList[] array){
Deque<Pair> que=new ArrayDeque<Pair>();
que.offerLast(new Pair(s,0));
while(!que.isEmpty()){
Pair p=que.pollFirst();
int ns=p.x;
visited[s][ns]=true;
ArrayList<Edge> list=array[ns];
if(p.y==t) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(!visited[s][e.to]) que.offerLast(new Pair(e.to,p.y+1));
}
}
}
   
public static void dijkstra(int[] dist,MyArrayList[] array){
PriorityQueue<Pair> pque=new PriorityQueue<Pair>(1,Pair.DISTANCE_ORDER);
Arrays.fill(dist,INF);
dist[0]=0;
pque.offer(new Pair(0,0));
while(!pque.isEmpty()){
Pair p=pque.poll();
int v=p.y;
ArrayList<Edge> list=array[v];
if(dist[v]<p.x) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(dist[e.to]>dist[v]+e.cost){
dist[e.to]=dist[v]+e.cost;
pque.offer(new Pair(dist[e.to],e.to));
}
}
}
}
}

Measured memory_bytes: 871024
#define _'			'
A[_];long P[_],M=1e9+7,F[_],I[_],X;i,j,k,t;
//c(a,b)long*a,*b;{t=*a-*b;}
c(a,b)int*a,*b;{t=*a-*b?:a[*I=1]-b[1];}
p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}f(a,b){return F[a+b]*I[a]%M*I[b]%M;}
main(s){for(;++X<_;~scanf("%d",A+i)&&i++%2&&gets(P))I[X]=p(s=F[X]=X*s%M,M-2);
//for(qsort(A,i/2,8,c);j<i;P[j++]=X)for(X=f(t=A[++j]-=*I=1,s=A[k=j]-=1);k;k--)X=t<A[--k]?X:(X-f(s-A[k-1],t-A[k])*P[k]%M+M)%M;
for(qsort(A,i/2,8,c);j<i;P[j++]=X)for(X=f(t=A[k=++j]-=*I=1,s=A[j]-=1);--k;)X=t<A[--k]?X:(X-f(s-A[k-1],t-A[k])*P[k]%M+M)%M;
//for(qsort(A,i/2,8,c);j<i;P[j++]=X)for(X=f(t=A[++j]-=*I=1,s=A[k=j]-=1);k--;X=t<A[k--]?X:(X-f(s-A[k],t-A[k+1])*P[k+1]%M+M)%M);
printf("%d",X);}

Measured memory_bytes: 14336
#include <iostream>

using namespace std;

int main()
{
	long h, n;
	int a[100000];
	
	cin >> h >> n;
	
	int sum = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	
	if(sum >= h)
		cout << "Yes";
	else
		cout << "No";
}

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

long long a[100005];

int main()
{
	long long n, z, sum;
    scanf("%lld", &n);
    for(int i = 1; i <= n; i++)
    {
    	scanf("%lld", &a[i]);
	}
    sort(a + 1, a + n + 1);
    z = 1;
    for(int i = 2; i <= n; i++)
    {
        if(a[i] == a[i - 1]) 
		{
			z = (z + 1) % 2;
		}
        else 
		{
			sum += z; 
			z = 1;
		}
    }
    if(z % 2 == 1) sum++;
    printf("%lld", sum);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void) {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
long long mod = 1000000007;
void update_list(int n, long long *c_list) {
    for (int i = 2; i < n + 1; i++) {
        int count = 0;
        while (n % i == 0) {
            count++;
            n /= i;
        }
        c_list[i] += count;
    }
}

int main(int argc, char const *argv[]) {
    int N;
    std::cin >> N;
    long long count_list[N + 1];
    for (size_t i = 0; i < N + 1; i++) {
        count_list[i] = 0;
    }
    for (int i = 2; i < N + 1; i++) {
        update_list(i, count_list);
    }

    long long ans = 1;
    for (size_t i = 0; i < N + 1; i++) {
        ans = ans * (count_list[i] + 1);
        ans = ans % mod;
    }
    std::cout << ans << '\n';
    return 0;
}


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

var kumiawase = [
  [0,1,2],
  [0,2,1],
  [1,0,2],
  [1,2,0],
  [2,0,1],
  [2,1,0]
];
var main = function() {
  var i;
  var cost;
  var mincost;
  var splitlist;

  splitlist = lines[0].split(" ");

  mincost = 200;
  for(i = 0; i < 6; i++){
    cost =  Math.abs(Number(splitlist[kumiawase[i][1]]) - Number(splitlist[kumiawase[i][0]]));
    cost += Math.abs(Number(splitlist[kumiawase[i][2]]) - Number(splitlist[kumiawase[i][1]]));
    if(mincost > cost){
      mincost = cost;
    }
  }
  console.log(mincost);
}

reader.on('line', function(line) {
  lines.push(line);
});
reader.on('close', function() {
  main();
});


Measured memory_bytes: 21320
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define sll set<ll>
#define fo(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    ll n,i,j,k,t;

    ll c=10;i=0;
    string s;
    cout<<"? "<<c<<endl;
    fflush(stdout);
    cin>>s;

    while(s=="Y")
    {
        c*=10;
        if(c>1000000000)
            break;
        i++;
        cout<<"? "<<c<<endl;
        fflush(stdout);
        cin>>s;
    }

    if(c>1000000000)
    {
        c=1;i=9;
        while(true)
        {
            cout<<"? "<<i<<endl;
            fflush(stdout);
            cin>>s;
            if(s=="Y")
                break;
            else
            {
                c*=10;
                i=i*10+9;
            }
            if(c>1000000000)
            {
                c=1;
                break;
            }
        }
        cout<<"! "<<c<<endl;
        fflush(stdout);
        return 0;
    }

    c=0;ll l,r,mid;
    fo(j,i)
    {
        l=0;r=10;
        while(l<r-1)
        {
            mid=(l+r)>>1;
            if(j==i)
                cout<<"? "<<c*100+mid*10<<endl;
            else
                cout<<"? "<<c*10+mid<<endl;
            fflush(stdout);
            cin>>s;
            if(s=="Y")
                l=mid;
            else
                r=mid;
        }
        c=c*10+l;
    }

    l=0;r=10;
    while(l<r-1)
    {
        mid=(l+r)>>1;
        cout<<"? "<<c*100+mid*10<<endl;
        fflush(stdout);
        cin>>s;
        if(s=="N")
            l=mid;
        else
            r=mid;
    }

    c=c*10+l+1;

    cout<<"! "<<c;
    fflush(stdout);
    return 0;
}


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

vector<int> a(20000000);

int main(){
    int n; cin >> n;
    long long sum = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];  sum += a[i];
    }
    long long ans=sum, dis=0;
    for(int i=0; i<n; i++){
        dis += a[i];
        ans = min( ans, abs(dis - (sum - dis)));
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81248
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    count = 0
    for a in A:
        while a > 0 and a % 2 == 0:
            count += 1
            a = a // 2
    return count


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



Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,m;cin>>n>>m;
  string s;cin>>s;
  vector<int> v;
  for(int i=0;i<n-1;i++){
    if(s[i]=='A'&&s[i+1]=='C')v.push_back(i);
  }
  int sum[n+1];
  sum[0]=0;
  int now=0;
  for(int i=0;i<n;i++){
    if(now<v.size()&&v[now]==i){
      sum[i+1]=sum[i]+1;
      now++;
    }
    else sum[i+1]=sum[i];
  }
  for(int i=0;i<m;i++){
    int l,r;cin>>l>>r;l--;r--;
    cout<<sum[r]-sum[l]<<endl;
  }
}

Measured memory_bytes: 1660
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        char[] sl = s.toCharArray();
        char[] tl = t.toCharArray();
        int len = sl.length-tl.length;
        for(int i = len; i >= 0; i--){
            boolean bool = true;
            for(int j = 0; j < tl.length; j++){
                if(sl[i+j] != tl[j] && sl[i+j] != '?'){
                    bool = false;
                    break;
                }
            }
            if(bool){
                String top = s.substring(0,i).replace("?","a");
                String last = s.substring(i+tl.length, sl.length).replace("?","a");
                System.out.println(top + t + last);
                return;
            }
        }
        System.out.println("UNRESTORABLE");
    }
}


Measured memory_bytes: 22608
#include <stdio.h>

int main(void) {
	int n; scanf("%d",&n);
	int count = 0;
	for (int i=1; i<=n; i++) {
		int j = i;
		int k = 0;
		while (j != 0) {
			k++;
			j /= 10;
		}
		if (k % 2 == 1) count++;
	}
	printf("%d",count);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

ll a, b;

signed main() {

    cin >> a >> b;
    
    cout << a / __gcd(a, b) * b << endl;

  
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;

int N; ll X;
ll x[MAX_N];

ll abs(ll a){
	if(a < 0) return -a;
	else return a;
}
ll gcd(ll a, ll b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}

int main(){
	scanf("%d %lld", &N, &X);
	for(int i = 0; i < N; i++){
		scanf("%lld", &x[i]);
		x[i] -= X;
		x[i] = abs(x[i]);
	}
	ll res;
	for(int i = 0; i < N; i++){
		if(i == 0) res = x[i];
		else res = gcd(x[i], res);
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 896
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vector<int> a(n, 0);
		vector<int> c(3200/400+1, 0);

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

			c[min(a[i]/400, 8)]++;
		}

		int col_min=0;
		for(int i=0;i<=7;i++)
		{
			if(c[i]) col_min++;
		}
		int col_max=col_min+c[8];

		printf("%d %d\n", max(col_min, 1), col_max);
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    public static String Y = "Yes";
    public static String N = "No";
    public static String I = "IMPOSSIBLE";
    public static String B = "Bad";
    public static String G = "Good";
    public static long MOD = (long) (Math.pow(10, 9) + 7);
    public static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        long w = nl();
        long h = nl();

        long x = nl();
        long y = nl();

        outn(w * h * 0.5);

        if (x * 2 == w && y * 2 == h) {
            out(" " + 1);
        } else {
            out(" " + 0);
        }
    }

    /*
     * 以下メソッド集
     */
    static int ni() {

        return sc.nextInt();
    }

    static long nl() {

        return sc.nextLong();
    }

    static String n() {

        return sc.next();
    }

    static char[] nc() {

        return sc.next().toCharArray();
    }

    static int kaijo(int n) {

        if (n == 0 || n == 1) {
            return 1;
        } else {
            return n * kaijo(n - 1);
        }
    }

    static int fib(int n) {

        return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
    }

    static long lcm(long m, long n) {

        return m * n / gcd(m, n);
    }

    static int lcm(int m, int n) {

        return m * n / gcd(m, n);
    }

    static long gcd(long a, long b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static int gcd(int a, int b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static void out(String info) {

        System.out.println(info);
    }

    static void out(int info) {

        System.out.println(info);
    }

    static void out(double info) {

        System.out.println(info);
    }

    static void out(long info) {

        System.out.println(info);
    }

    static void out(char info) {

        System.out.println(info);
    }

    static void outn(String info) {

        System.out.print(info);
    }

    static void outn(int info) {

        System.out.print(info);
    }

    static void outn(double info) {

        System.out.print(info);
    }

    static void outn(long info) {

        System.out.print(info);
    }

    static void outn(char info) {

        System.out.print(info);
    }

    static int max(int a, int b) {

        return Math.max(a, b);
    }

    static long max(long a, long b) {

        return Math.max(a, b);
    }

    static int min(int a, int b) {

        return Math.min(a, b);
    }

    static long min(long a, long b) {

        return Math.min(a, b);
    }
}


Measured memory_bytes: 21332
#include <stdio.h>

#define MAX_PRIME	(1300000)
#define IS_PRIME(n)	(prime[n]==1?0:1)

int prime[MAX_PRIME + 1];



void make_prime(void)
{
    int i;
    int j;
    int n;
    int c;
    
    for (i = 2; i * i <= MAX_PRIME; i++){
        if (prime[i] == 0){
            for (j = i * 2; j <= MAX_PRIME; j += i){
				prime[j] = 1;
            }
        }
    }
}

int main(void)
{
	int n;
	int i;
	int gap;
	
	make_prime();
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		gap = 0;
		for (i = n; prime[i] == 1; i++){
//printf("<%d>", i);
			gap++;
		}
		
		for (i = n; !IS_PRIME(i); i--){
//printf("[%d]", i);
			gap++;
		}
		printf("%d\n", gap);
	}
	
	return (0);
}

Measured memory_bytes: 5676
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stack>
#include <queue>

using namespace std;
#define Fill(a, b) memset(a, b, sizeof(a))
#define Debug(x) cout << #x << "=" << (x) << endl;
typedef unsigned long long LL;
const LL inf = 1LL << 61;
const LL mod = 1000000007;
#define DEBUG
#ifdef DEBUG
#endif
const int maxn = 55;


int x[maxn], y[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++)
    {
    	scanf("%d%d", &x[i], &y[i]);
    }
    LL ans = 0;
    for(int i = 0; i < n; i++)
    {
    	for(int j = 0; j < n; j++)
    	{
    		if(j==i)continue;
    		int minx = min(x[i], x[j]);
    		int maxx = max(x[i], x[j]);
    		for(int ii = 0; ii < n; ii++)
    		{
    			for(int jj = 0; jj < n; jj++)
    			{
    				if(jj==ii)continue;
    				int miny = min(y[ii], y[jj]);
    				int maxy = max(y[ii], y[jj]);
    				int sum = 0;
		    		for(int s = 0; s < n; s++)
		    		{
		    			if(x[s]>=minx&&x[s]<=maxx&&y[s]>=miny&&y[s]<=maxy)
		    			{
		    				sum++;
		    			}
		    		}
		    		//cout << sum << " " << (LL)(maxx-minx)*(LL)(maxy-miny) << endl;
		    		if(sum >= k)
		    		{
		    			if(ans==0)
		    				ans = (LL)(maxx-minx)*(LL)(maxy-miny);
		    			else
		    				ans = min(ans, (LL)(maxx-minx)*(LL)(maxy-miny));
		    		}
    			}
    		}
    		
    		
    	}
    }
    printf("%lld\n", ans);






















    return 0;
}


Measured memory_bytes: 256
import collections
import heapq

x, y, z, k = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    ls[i].sort(reverse=True)
q = [(-sum([ls[i][0] for i in range(3)]), 0, 0, 0)]
res = []
used = collections.defaultdict(lambda: False)
while len(res) < k:
    s, i, j, l = heapq.heappop(q)
    res.append(-s)
    index_list = [
        (i + 1, j, l),
        (i, j + 1, l),
        (i, j, l + 1),
    ]
    for i, (indices, limit) in enumerate(zip(index_list, [x, y, z])):
        if indices[i] < limit and not used[indices]:
            ss = sum([ls[j][l] for j, l in zip(range(3), indices)])
            heapq.heappush(q, (-ss, indices[0], indices[1], indices[2]))
            used[indices] = True
print(*res, sep='\n')

Measured memory_bytes: 5252
use std::io;
use std::io::prelude::*;

fn main() {
    let mut buf = String::new();
    let stdin = io::stdin();
    let mut lock = stdin.lock();

    lock.read_to_string(&mut buf);

    let parsed_input :Vec<u64> = buf.split_whitespace().map(|word| word.parse().unwrap()).collect();

    let a = parsed_input[0];
    let b = parsed_input[1];
    let c = parsed_input[2];

    let cost_per_week = a * 7 + b;
    let week = c / cost_per_week;
    let cost_rest = c - week * cost_per_week;
    let mut day = (cost_rest + a - 1) / a;
    if day >= 7 {
        day = 7;
    }
    let answer = week * 7 + day;

    println!("{}", answer);
}



Measured memory_bytes: 5036
[N, M] = [int(i) for i in input().split()]
lefts = []
rights = []

for i in range(M):
    cards = input().split()
    lefts.append(int(cards[0]))
    rights.append(int(cards[1]))

lmax = max(lefts)
rmin = min(rights)

ans = rmin - lmax + 1

if ans > -1:
    print(ans)
else:
    print(0)


Measured memory_bytes: 11036