akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int h, w;
  cin >> h >> w;

  char map[2002][2002] = {};
  for (int i = 0; i <= w + 1; i++) {
    map[0][i] = '#';
  }
  for (int i = 1; i <= h; i++) {
    map[i][0] = '#';
    for (int j = 1; j <= w; j++) {
      cin >> map[i][j];
    }
    map[i][w + 1] = '#';
  }
  for (int i = 0; i <= w + 1; i++) {
    map[h + 1][i] = '#';
  }
  
  int wide[2002][2002]={};
  for(int r=1;r<=h;r++){
    int begin=0;
    int chain=0;
    bool found_dot=false;
    for(int c=1;c<=w+1;c++){
      if(!found_dot){
        if(map[r][c]=='.'){
          begin=c;
          chain=1;
          found_dot=true;
        }
      }else{
        if(map[r][c]=='#'){
          for(int wc=begin;wc<=c-1;wc++){
            wide[r][wc]=chain;
          }
          found_dot=false;
        }else{
          chain++;
        }
      }
    }
  }

  // for(int r=1;r<=h;r++){
  //   for(int c=1;c<=w;c++){
  //     cerr<<wide[r][c];
  //   }
  //   cerr<<endl;
  // }
  // cerr<<"wide finish"<<endl;

  int height[2002][2002]={};
  for(int c=1;c<=w;c++){
    int begin=0;
    int chain=0;
    bool found_dot=false;
    for(int r=1;r<=h+1;r++){
      if(!found_dot){
        if(map[r][c]=='.'){
          begin=r;
          chain=1;
          found_dot=true;
        }
      }else{
        if(map[r][c]=='#'){
          for(int wr=begin;wr<=r-1;wr++){
            height[wr][c]=chain;
          }
          found_dot=false;
        }else{
          chain++;
        }
      }
    }
  }

  // for(int r=1;r<=h;r++){
  //   for(int c=1;c<=w;c++){
  //     cerr<<height[r][c];
  //   }
  //   cerr<<endl;
  // }
  // cerr<<"height finish"<<endl;

  int result=0;
  for(int r=1;r<=h;r++){
    for(int c=1;c<=w;c++){
      if(map[r][c]=='#') continue;
      result=std::max(result,wide[r][c]+height[r][c]-1);
    }
  }
  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 35456
import sys
n, k = [int(i) for i in sys.stdin.readline().split()]
cnt = 0
for i in range(k+1, n+1):
    larger = n // i
    amari = n % i
    cnt += larger * (i - k) + max(0, amari - k + 1) if k != 0 else larger * (i - k) + amari
print(cnt)

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

using namespace std;

long long GCD(long long a,long long b){
	if(b==0) return a;

	return GCD(b,a%b);
}

int main(){
	int n;
	cin>>n;
	long long ans=1;

	for(int i=0;i<n;i++){
		long long hoge;
		cin>>hoge;

		ans=ans/GCD(ans,hoge)*hoge;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
while True:
  s = input().rstrip().split(' ')
  m = int(s[0])
  f = int(s[1])
  r = int(s[2])
  sum = m + f
  if m == -1 and f == -1 and r == -1:
    break;
  elif m == -1 or f == -1:
    print("F")
  elif sum >= 80:
    print("A")
  elif sum < 80 and sum >= 65:
    print("B")
  elif sum < 65 and sum >= 50:
    print("C")
  elif sum < 50 and sum >= 30:
    if r >= 50:
      print("C")
    else:
      print("D")
  elif sum < 30:
    print("F")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
multiset<int> s;
int main(){
    int h, w, a, b;
    cin >> h >> w;
    for (int i = 0; i < w; i++)
        m[i] = i, s.insert(0);
    for (int i = 0; i < h; i++){
        cin >> a >> b;
        a--;
        auto pos = m.lower_bound(a);
        int mx = -1;
        while (pos != m.end() && pos->first <= b){
            mx = max(mx, pos->second);
            int x = pos->first - pos->second;
            s.erase(s.find(x));
            m.erase(pos++);
        }
        if (mx != -1 && b < w){
            s.insert(b - mx);
            m[b] = mx;
        }
        cout << (s.empty() ? -1 : *s.begin() + i + 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 22388
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int cmp1(const void *a,const void *b){
  return *(char *)a-*(char *)b;
}
int cmp2(const void *a,const void *b){
  return *(char *)b-*(char *)a;
}

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

  qsort(s,strlen(s),sizeof(char),cmp1);
  qsort(t,strlen(t),sizeof(char),cmp2);

  if(strcmp(s,t)<0){
    printf("Yes");
  }else{
    printf("No");
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

int n;
string s;
int a[28];
unordered_set<int>st;

signed main(){
	cin>>n;
	cin>>s;
	r(i,n){
		a[s[i]-'a']++;
	}
	int ans=1,S=0,sum=0;
	r(i,26)if(a[i])S++;
	r(i,26){
		if(a[i]){
		int x=a[i];
		r(j,26)if(i<j&&a[j]){
			x*=(a[j]+1);
			x%=1000000007;
		}
		x%=1000000007;
		ans+=x;
		ans%=1000000007;
		S--;
		}
	}
	/*r(i,(1<<26)){
		int A=0,p=1;
		r(j,26){
			if(i&(1<<j)){
				A|=(1<<j);
				p*=a[j];
				p%=1000000007;
			}
		}
		if(!st.count(A)&&p){
			//cout<<A<<endl;
			st.insert(A);
			ans+=p;
			ans%=1000000007;
		}
	}*/
	cout<<ans-1<<endl;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		String S = sc.next();
		String T = sc.next();
		char[] s = S.toCharArray();
		char[] t = T.toCharArray();
		Arrays.sort(s);
		Arrays.sort(t);
		StringBuilder bt = new StringBuilder();
		bt.append(t);
		bt.reverse();
		System.out.println(String.valueOf(s).compareTo(bt.toString()) < 0 ? "Yes" : "No");
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 23760
# coding: utf-8
# 133B

import math

N, D = map(int, input().split())

X = []
for _ in range(N):
    X.append(list(map(int, input().split())))

count = 0
for i in range(len(X)-1):
    for j in range(i+1, len(X)):
        ds = 0
        for k in range(D):
            ds += (X[i][k] - X[j][k])**2
        ds = math.sqrt(ds)
        #print(ds)
        if ds - int(ds) == 0:
            count += 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define mo 1000000007
using namespace std;
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS
int main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int n,k;
     cin>>n>>k;
     int arr[n],sum{0};
     for(int i=0;i<n;i++)
         cin>>arr[i];
     sort(arr,arr+n);
     for(int i=0;i<k;i++)
         sum+=arr[i];
     cout<<sum<<endl;
 return 0;    
}

Measured memory_bytes: 3636
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue
		
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define conutBits(n)	__builtin_popcount(n)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

	ll t, i, x, j, y, 	z, k, n;
	cin>>x;
	ce(!x);
}



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

int main() {
	string sa,sb,sc;
	cin >> sa >> sb >> sc;
	
	int a=0,b=0,c=0;
	int turn=0;
			char x;
	while(true){

		if(turn==0){
				if(a==sa.length()){cout << "A"<<endl; return 0;}
			x=sa[a];
			a++;
			
		}
		else if(turn==1){
				if(b==sb.length()){
				cout<<"B"<<endl; return 0;
			}
			x=sb[b];
			b++;
		
		}
		else if(turn ==2){
				if(c==sc.length()){
				cout << "C"<<endl; return 0;
			}
			x=sc[c];
			c++;
		
		}
		
		switch(x){
			case 'a': turn =0; break;
			case 'b' : turn =1; break;
			case 'c' : turn =2; break;
			
		}
	
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        String s = inp.next();
        System.out.println(s.contains("7") ? "Yes" : "No");
    }
}

Measured memory_bytes: 35512
#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()
{
    ll A, B, K; cin >> A >> B >> K;
    ll c = min(A, K);
    A -= c; K -= c;
    c = min(B, K);
    B -= c; K -= c;
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int gcd(int m, int n)
{
    // 引数に０がある場合は０を返す
    if ((0 == m) || (0 == n))
        return 0;

    // ユークリッドの方法
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}
int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    rep(i, N) x[i] = abs(X - x[i]);
    int ans = x[0];
    rep(i, N)
    {
        if (x[i] % ans == 0)
            continue;
        ans = gcd(ans, x[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
from collections import deque
import sys
def main():
  a,b=map(int,sys.stdin.readline().split())
  e=[[]for i in range(a)]

  for i in range(a-1):
    c1,c2=map(int,sys.stdin.readline().split())
    e[c1-1].append(c2-1)
    e[c2-1].append(c1-1)

  g=[[]for i in range(a)]
  f=deque()
  f.append((0,-1))
  ans=[0 for _ in range(a)]
  for i in range(b):
    ten,p=map(int,input().split())
    ans[ten-1]+=p
  i=0
  while len(f)!=0:
    i,fr=f.popleft()
    for j in e[i]:
      if j==fr:
        continue
      else:
        ans[j]+=ans[i]
        f.append([j,i]) 
  print(*ans)
if __name__ == '__main__':  
  main()
    
  

  
  


Measured memory_bytes: 79540
local DBG = true
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

local function dbgpr_t(tbl, use_pairs)
    if DBG then
        local enum = ipairs
        if use_pairs then
            enum = pairs
        end
        dbgpr(tbl)
        io.write("[dbg]")
        for i,v in enum(tbl) do
            io.write(i)
            io.write(":")
            io.write(tostring(v))
            io.write(" ")
        end
        print("")
    end
end
local function factorize(n)
    local nn = n
    local lst = {}
    for i = 2, math.floor(n ^ 0.5) do
        k = 0
        while nn % i == 0 do
            k = k + 1
            nn = nn // i
            table.insert(lst, i)
        end
    end
    if nn ~= 1 then
        table.insert(lst, nn)
    end
    return lst
end

local A, B = io.read("n","n")
local f1 = factorize(A)
local f2 = factorize(B)
local s1 = {}
for _,v in ipairs(f1) do
    s1[v] = true
end
local s2 = {}
for _,v in ipairs(f2) do
    s2[v] = true
end
local smul = {1}
for k,_ in pairs(s1) do
    if s2[k] then
        table.insert(smul, k)
    end
end
print(#smul)


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

const int maxN=505;
const int inf=2147483647;

class Outp
{
public:
	int x1,y1,x2,y2;
};

int n,m;
int Mt[maxN][maxN];
int scnt=0;
Outp O[maxN*maxN];

int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) cin>>Mt[i][j];
	for (int i=1;i<=n;i++)
		if (i&1){
			for (int j=1;j<m;j++)
				if (Mt[i][j]&1)
					O[++scnt]=((Outp){i,j,i,j+1}),Mt[i][j+1]++;
			if ((Mt[i][m]&1)&&(i!=n)) O[++scnt]=((Outp){i,m,i+1,m}),Mt[i+1][m]++;
		}
		else{
			for (int j=m;j>1;j--)
				if (Mt[i][j]&1)
					O[++scnt]=((Outp){i,j,i,j-1}),Mt[i][j-1]++;
			if ((Mt[i][1]&1)&&(i!=n)) O[++scnt]=((Outp){i,1,i+1,1}),Mt[i+1][1]++;
		}
	cout<<scnt<<endl;
	for (int i=1;i<=scnt;i++) cout<<O[i].x1<<" "<<O[i].y1<<" "<<O[i].x2<<" "<<O[i].y2<<endl;
	return 0;
}


Measured memory_bytes: 7040
import java.util.*;
public class Main  {
   public static void main(String[] args)  {
      Scanner sc = new Scanner(System.in);
      
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int d = sc.nextInt();
      
      while (a > 0 && c > 0) {
         c = c - b;
         if (c <= 0) {
            break;
         }
         a = a - d;
      }
      if (c <= 0) {
         System.out.println("Yes");
      }
      if (a <= 0) {
         System.out.println("No");
      }
   }
}


Measured memory_bytes: 35804
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2005,mod=1e9+7;
ll jc[N*N],num[N*N],dp[N][N],n,k;
ll addd(ll x,ll y){
	x+=y;
	return x%mod;
}
ll ksm(ll y,ll x){
	ll ans=1;
	while(x>0){
		if(x&1)ans=(ans*y)%mod;
		x>>=1;
		y=(y*y)%mod;
	}
	return ans;
}
ll get(int x,int y){
	return jc[x]*num[y]%mod*num[x-y]%mod;
}
int main(){
	int i,j;
	jc[0]=1;
	for (i=1;i<=4000010;i++)jc[i]=jc[i-1]*i%mod;
	num[4000010]=ksm(jc[4000010],mod-2);
	for (i=4000010;i;i--)num[i-1]=num[i]*i%mod;
	scanf("%lld%lld",&n,&k);
	if(k==1){
		puts("1\n");
		return 0;
	}
	dp[0][0]=1;
	for (i=0;i<=n;i++)
		for (j=i;j>=0;j--)
			if(dp[i][j]){
				dp[i+1][j+1]=addd(dp[i+1][j+1],dp[i][j]*(n-i)%mod*get(k*(i+1)-j-2,k-2)%mod);
				if(j)dp[i][j-1]=addd(dp[i][j-1],dp[i][j]);
			}
	printf("%lld\n",dp[n][0]);
	return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];


signed main(){
	IOS;
	string s;
	cin >> s;
	int n = s.size();
	int ans = n;
	for(int i = 0;i < n - 1;i++){
		if(s[i] != s[i + 1]){
			ans = min(ans,max(i + 1,n - i - 1));	
		}
	}
	dump(ans);	
}

Measured memory_bytes: 512
A = gets.chomp.to_i
B = gets.chomp.to_i
C = gets.chomp.to_i
X = gets.chomp.to_i

aaa = [ X / 500, A ].min
ccc = [ X / 50, C ].min

count = 0
(aaa+1).times do |a|
  bbb = [ (X-500*a) / 100, B ].min
  (bbb+1).times do |b|
    if (X-500*a-100*b) / 50 <= C
      count += 1
    end
  end
end

p count

Measured memory_bytes: 1788
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int a, b;
    std::cin >> a >> b;

    std::cout << int(std::round(float(a+b)/2)) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define pi acos(-1)
#define P pair<int,int>
#define fi first
#define se second
#define si signed
#define sc(x) scanf("%lld",&(x));

int A[]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
const double EPS =1e-7;
int n;
char s[11];
bool f[27];
void dfs(int x)
{
    if(x==0)
    {
        for(int i=n; i>=1; i--)
        {
            putchar(s[i]);
        }
        cout<<'\n';
        return ;
    }
    for(int i=1; i<=26; i++)
    {
        if(f[i])
        {
            s[x]=i+'a'-1;
            dfs(x-1);
        }
        else if(f[i-1])
        {
            s[x]=(i+'a'-1);
            f[i]=true;
            dfs(x-1);
            f[i]=false;
            break;
        }
    }

}
signed main()
{
    sc(n)
    f[0]=1;
    dfs(n);
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto c:v) cout<<" "<<c; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
void solve(){
	int n;
	cin>>n;
	int dp[n+1]={0};
	dp[0]=1;
	for(int i=3;i<=n;i++){
		for(int j=3;j<=n;j++){
			if(j<=i)
				dp[i]=(dp[i]+dp[i-j])%mod;
		}
	}
	cout<<dp[n]<<endl;
}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int N;
int a[100005];

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> a[i];
	
	int ans = 0;
	for(int i = 1; i <= N; i++){
		if(a[a[i]] == i) ans++;
	}
	
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if (A.at(A.size() - 1) == B.at(0) && B.at(B.size() - 1) == C.at(0)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define ft first
#define st second
#define mp make_pair
#define pb push_back
#define sz(n) int(n.size())
#define all(n) n.begin(), n.end()


using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int N = 1e5 + 123;
const int inf = 1e9 + 7;
const ll INF = 1e18 + 7;

long long n, t[1010], a[1010];
__int128 aa[1100], tt[1010];

int main ()
{      
	cin >> n;
	for (int i = 1; i <= n; i ++) 
	{
		cin >> t[i] >> a[i];
		tt[i] = t[i];
		aa[i] = a[i];
	}

	__int128 A = 1, B = 1;

	for (int i = 1; i <= n; i ++)
	{
		__int128 l = 0, r = (1e18) + 1, k;
		while (l <= r)
		{
			__int128 mid = (l + r) / 2;
			if (t[i] * mid >= A && a[i] * mid >= B) k = mid, r = mid - 1;
			else l = mid + 1;
		}

		A = t[i] * k;
		B = a[i] * k;
		//cout << A << " " << B << "\n";
	}

	ll P = A + B;
	cout << P << "\n";
}



Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    int[] h = readln.chomp.split.to!(int[]);
    int cnt, ans;
    foreach (i; 1 .. n) {
        if (h[i] <= h[i-1]) {
            ++cnt;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    ans.writeln;
}

Measured memory_bytes: 4404
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 1234567;testcase++){
    int(n);
    int f[n]; scn(n, f);
    bool fl = true;
    vector<int> d;

    int cnt = 1;
    rep1(i, n){
      if(f[i - 1] == f[i]){
        d.pb(cnt);
        cnt = 1;
      }else cnt++;
    }
    d.pb(cnt);

    if(d.size() <= 3)pri(n);
    else{
      int res = 0;
      rep1(i, d.size() - 1)res = max(res, d[i - 1] + d[i] + d[i + 1]);
      pri(res);
    }

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1848
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    string[] P = { "dream", "dreamer", "erase", "eraser" };
    string S;

    public void Solve()
    {
        S = Reader.String();
        var ok = new bool[S.Length + 1];
        ok[0] = true;

        for (int i = 0; i < S.Length; i++)
            if (ok[i])
                for (int pi = 0; pi < P.Length; pi++)
                    if (OK(i, pi))
                        ok[i + P[pi].Length] = true;

        Console.WriteLine(ok[S.Length] ? "YES" : "NO");
    }

    bool OK(int start, int pi)
    {
        if (start + P[pi].Length > S.Length) return false;
        for (int i = 0; i < P[pi].Length; i++)
            if (S[start + i] != P[pi][i]) return false;
        return true;
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll dev = 1000000007;

ll pow_mod(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res *= a;
    a = a*a;
    a %= mod;
    n >>= 1;
    res %= mod;
  }
  return res;
}

ll inv(ll x, ll mod) {
  ll res = pow_mod(x, mod - 2, mod);
  return res;
}

ll comb_mod(ll n, ll r, ll mod) {
  ll res;
  ll x = 1, y = 1;
  for (ll i = 0; i < r; i++) {
    x *= n-i;
    x %= mod;
    y *= r-i;
    y %= mod;
  }
  res = x * inv(y, mod);
  res %= mod;
  return res;
}

int main() {
  ll x, y;
  cin >> x >> y;

  ll ans;
  if ((x + y) % 3 != 0) {
    ans = 0;
  }
  else {
    ll n = (2*x - y) /3;
    ll m = (2*y - x) /3;
    if (n < 0 || m < 0) {
      ans = 0;
    }
    else {
      ll c = min(n, m);
      ans = comb_mod(n+m, c, dev);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq; 
class Program
    {
        static Dictionary<int, List<int>> Nodes;
        static void Main(string[] args)
        {
            var Array = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int N = Array[0];
            int M = Array[1];
            Nodes = new Dictionary<int, List<int>>();
            for (int i = 1; i <= N; i++)
            {
                Nodes.Add(i, new List<int>());
            }
            for (int i = 1; i <= M; i++)
            {
                Array = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
                Nodes[Array[0]].Add(Array[1]);
            }
            bool blnResult = false;
            var First = Nodes[1].ToArray();
            foreach (var x in First)
            {
                foreach (var y in Nodes[x])
                {
                    if (y == N)
                        blnResult = true;
                }
            }

            if (blnResult)
                Console.WriteLine("POSSIBLE");
            else
                Console.WriteLine("IMPOSSIBLE");
        }

    }

Measured memory_bytes: 45684
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll a, b;
	cin >> a >> b;
	cout << (a * b) / __gcd(a, b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
//AtCoderC++.cpp

using namespace std;

vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	size_t N,L; cin >> N >> L;
	auto ss = vector<string>(N);
	for (size_t i = 0; i < N; i++) {
		cin >> ss[i];
	}
	sort(ss.begin(), ss.end());
	for (size_t i = 0; i < N; i++) {
		cout << ss[i];
	}
	cout << endl;
}

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

class Program
{
    static string InputPattern = "Input2";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1");
            WillReturn.Add("2");
            WillReturn.Add("3");
            WillReturn.Add("0");
            //1.00000000
            //1.50000000
            //2.12500000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    //連続して半額弁当を取得できる限界数
    const int LimitSeqCnt = 14;

    static void Main()
    {
        //var sw = System.Diagnostics.Stopwatch.StartNew();

        List<string> InputList = GetInputList();
        int[] NArr = InputList.Select(X => int.Parse(X)).TakeWhile(X => X > 0).ToArray();

        Dictionary<int, Decimal> KakurituDict = DeriveKakurituDict();
        foreach (var EachPair in KakurituDict) {
            //Console.WriteLine("連続取得個数が{0}個の確率={1}",
            //    EachPair.Key, EachPair.Value);
        }

        //Nの最大値までの期待値を求める
        int DayCnt = NArr.Max();
        decimal[] KitaitiArr = new decimal[DayCnt + 1];
        for (int I = 1; I <= DayCnt; I++) {
            foreach (var EachPair in KakurituDict) {
                int BentouCnt = EachPair.Key;
                if (BentouCnt > I)
                    BentouCnt = I;
                KitaitiArr[I] += BentouCnt * EachPair.Value;

                int RestDayCnt = I - EachPair.Key - 1;
                if (RestDayCnt > 0)
                    KitaitiArr[I] += KitaitiArr[RestDayCnt] * EachPair.Value;
            }
        }

        //for (int I = 1; I <= DayCnt; I++) {
        //    //Console.WriteLine("{0}日での期待値={1}", I, KitaitiArr[I]);
        //}

        Array.ForEach(NArr, X => Console.WriteLine(KitaitiArr[X]));
        //Console.WriteLine("経過時間={0}", sw.Elapsed);
    }

    //最初の取得個数を添字とし、値が確率の配列
    static Dictionary<int, Decimal> DeriveKakurituDict()
    {
        var WillReturn = new Dictionary<int, decimal>();

        decimal[] BaseArr = new decimal[LimitSeqCnt + 2];
        BaseArr[1] = 1M;
        for (int I = 2; I <= BaseArr.GetUpperBound(0); I++) {
            BaseArr[I] = BaseArr[I - 1] * 0.5M;
        }

        //確率の乗法定理を使う
        for (int I = 1; I <= LimitSeqCnt; I++) {
            decimal wkDec = 1;
            for (int J = 1; J <= I; J++) {
                wkDec *= BaseArr[J];
            }
            //次で弁当を取れない確率(余事象の確率)を掛ける
            wkDec *= (1M - BaseArr[I + 1]);
            WillReturn.Add(I, wkDec);
        }
        return WillReturn;
    }
}

Measured memory_bytes: 8128
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  bool x = 1;
  for(int i = 0;i < S.length() && x;){
    if(S.substr(i,5) == "dream"){
      if(S.substr(i + 5,3) == "era")i += 5;
      else if(S.substr(i + 5,2) == "er")i += 7;
      else i += 5;
    }else if(S.substr(i,5) == "erase"){
      if(S[i + 5] == 'r')i += 6;
      else i += 5;
    }else x = 0;
  }
  if(x)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200, maxm = 150;
long long sum(long long a, long long b){
	a += b;
	if(a >= (1ll<<60)) a = 1ll<<60;
	return a;
}
int nxt[maxm][maxn];
long long cost[maxm][maxn];
int a[maxn];
vector<int> wh[maxn];
int main(){
	int n; long long k; cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) wh[a[i]].push_back(i);
	for(int i = 0; i < maxn; i++){
		if(wh[i].empty()) continue;
		int len = wh[i].size();
		for(int j = 0; j < len; j++){
			int from = wh[i][j];
			int to = wh[i][(j + 1) % len];
			if(from == n - 1 && to == n - 1){
				cost[0][from] = 2;
				nxt[0][from] = (to + 1) % n;
			} else if(to <= from || to == n - 1){
				cost[0][from] = 1;
				nxt[0][from] = (to + 1) % n;
			} else {
				cost[0][from] = 0;
				nxt[0][from] = (to + 1) % n;
			}
		}
	}
	for(int j = 1; j < maxm; j++){
		for(int i = 0; i < n; i++){
			nxt[j][i] = nxt[j - 1][nxt[j - 1][i]];
			cost[j][i] = sum(cost[j - 1][i],cost[j - 1][nxt[j - 1][i]]);
		}
	}
	vector<int> seq;
	int cur = 0; k--;
	for(int i = maxm - 1; i >= 0; i--){
		if(cost[i][cur] <= k){
			k -= cost[i][cur];
			cur = nxt[i][cur];
		}
	}
	set<int> now;
	vector<int> ans;
	for(int i = cur; ;){
		if(now.count(a[i])){
			while(now.count(a[i])){
				now.erase(ans.back());
				ans.pop_back();
			}
		} else {
			ans.push_back(a[i]);
			now.insert(a[i]);
		}
		if(i == n - 1 && k == 0) break;
		if(i == n - 1) k--;
		i = (i + 1) % n;
	}
	for(int v : ans) cout << v << " ";
	cout << endl;
	return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

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

    map<int, int> mp, mp2;
    for (int i = 0; i < n; i += 2)
        mp[v[i]]++;
    for (int i = 1; i < n; i += 2)
        mp2[v[i]]++;

    vector<pair<int, int>> v1, v2;

    for (auto x: mp)v1.emplace_back(x);
    for (auto x: mp2)v2.emplace_back(x);

    sort(v1.begin(), v1.end(), [](pair<int, int> a, pair<int, int> b) {
        return a.second > b.second;
    });
    sort(v2.begin(), v2.end(), [](pair<int, int> a, pair<int, int> b) {
        return a.second > b.second;
    });
    int id1 = 0, id2 = 0;
    if (v1[id1].first == v2[id2].first) {
        if (v1[id1].second > v2[id2].second)
            id2++;
        else if (v1[id1].second == v2[id2].second) {
            int tp1 = id1 + 1, tp2 = id2 + 1, n1 = 0, n2 = 0;
            if (tp1 < v1.size())n1 = v1[tp1].second;
            if (tp2 < v2.size())n2 = v2[tp2].second;
            if (n1 > n2)id1++;
            else id2++;
        } else
            id1++;
    }
    int ans = 0;
    if (id1 >= v1.size())
        ans += n / 2;
    else
        ans += n / 2 - v1[id1].second;
    if (id2 >= v2.size())
        ans += n / 2;
    else
        ans += n / 2 - v2[id2].second;
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 9592
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
ANS = [0] * N

for ab in AB:
  ANS[ab[0] - 1] += 1
  ANS[ab[1] - 1] += 1

[print(ans) for ans in ANS]

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
	char s[101];
	long i,k;
	scanf("%s %ld",s,&k);
	for(i=0;s[i]!='\0';i++){
		if(s[i]!='1'&&i<k){
			printf("%c",s[i]);
			return 0;
		}
	}
	printf("1");
	return 0;
}

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

int main(){
  int N;
  cin >>N;
  
  int sum=0;
  vector<int> d(N);
  
  for (int i=0; i<N;i++){
    cin >>d.at(i);
  }
  for (int i=0;i<N;i++){
    for (int j=i+1;j<N;j++){
      sum+=d.at(i)*d.at(j);
    }
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a,b,c,x,y,ll0=0,m=LONG_LONG_MAX; cin>>a>>b>>c>>x>>y;
  for(int i=0;i<=max(x,y)*2;i+=2) m=min(m,c*i+a*max(ll0,x-i/2)+b*max(ll0,y-i/2));
  cout<<m;
}

Measured memory_bytes: 3564
//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
using namespace std;

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll pow(ll a,ll n, ll m){
    ll ret=1;
    for(;n>0;n>>=1,a=a*a%m){
        if(n%2==1){
        ret=ret*a%m;
        }
    }
    return ret;
}

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;
template <ll mod>
class mint {
public:
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
    // mint<数字> a みたいに使う
};

typedef mint<(ll) 1e9+7> mi;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    ll n;cin >> n;
    ll a[n];
    mi A[n];
    mi res = (mi)0, sum = (mi)0;
    fr(i,n){
        cin >> a[i];
        A[i] = (mi)a[i];
        res -= A[i]*A[i];
        sum += A[i];
    }
    res += sum*sum;
    res /= 2;
    cout << res << endl;
}

Measured memory_bytes: 6724
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

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

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define PI 3.14159265359

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;


int main() {
  double x;
  cin >> x;
  printf("%.6f\n", 2 * x * PI);
  return 0;
}

Measured memory_bytes: 3788
k = int(input())
A = list(map(int, input().split()))
A.reverse()

L = [-1]*(k+1)
R = [-1]*(k+1)

L[0] = 2
R[0] = 2
for i in range(1, k+1):
    if L[i-1]%A[i-1] == 0 or R[i-1]%A[i-1] == 0:
        pass
    else:
        if R[i-1] - L[i-1] >= A[i-1] or L[i-1]%A[i-1]>R[i-1]%A[i-1]:
            pass
        else:
            #print(i, A[i-1], L[i-1], R[i-1])
            print(-1)
            exit()
    if L[i-1]%A[i-1] == 0:
        L[i] = (L[i-1]//A[i-1])*A[i-1]
    else:
        L[i] = (L[i-1]//A[i-1]+1)*A[i-1]
    R[i] = (R[i-1]//A[i-1])*A[i-1]+A[i-1]-1
    #print(i, L[i], R[i])

#print(L)
#print(R)
print(L[k], R[k])

Measured memory_bytes: 63856
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();

        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let (n, k) = read_cols!(i64, i64);

    let mut ans = 0;
    for b in k + 1..n + 1 {
        // b以下のa候補(0含む) => b - k
        // これらにbを足したものも候補になる
        // => (b - k) * [n / b] + 半端分
        ans += (b - k) * (n / b);

        if (n / b) * b + k <= n {
            ans += n - ((n / b) * b + k) + 1;
        }

        if k == 0 {
            // 0の分を引く
            ans -= 1;
        }
    }

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	ans = 1000 - (n% 1000);
	if (ans == 1000) ans = 0;
	cout<<(ans)<<endl;
}

Measured memory_bytes: 3636
N = int(input())
Ps = list(map(int, input().split()))

ans = 0
for i in range(1, N-1):
    if Ps[i-1]<Ps[i]<Ps[i+1] or Ps[i-1]>Ps[i]>Ps[i+1]:
        ans += 1

print(ans)


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

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define repr(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define repf(i, m, n) for (int(i) = (m); (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define inf 1e9

template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

using namespace std;
using ll = long long;

int main(int argc, char const *argv[])
{
    int x, y;
    cin >> x >> y;

    cout << abs(x - y) << endl;

    return 0;
}



Measured memory_bytes: 3100
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map

vll P = vll(401);
ll qry(int i, int j){
	if (i == 0) return P[j];
	return P[j] - P[i-1];
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vi A = vi();
	rep(i, n){
		int x; cin >> x;
		A.pb(x);
	}
	for(int i = 0; i < isize(A); i++){
		P[i] = (A[i] + (i > 0 ? P[i-1] : 0));
	}
	vvll dp = vvll(n, vll(n, LLINF));
	for (int i = 0; i < n; i++) dp[i][i] = 0;
	for(int c = 1; c < n; c++){
		for(int r = c-1; r >= 0; r--){
			for(int k = r; k <= c-1; k++){ //A[r]..A[k] + A[k+1]...A[c]
				dp[r][c] = min(dp[r][c], dp[r][k] + dp[k+1][c] + qry(r, k) + qry(k+1, c));
			}
		}
	}
	cout << dp[0][n-1];
}

Measured memory_bytes: 4480
//Love and Freedom.
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#define inf 20021225
#define ll long long
#define N 100100
#define pa pair<int,int>
#define fs first
#define se second
#define mp make_pair
using namespace std;
int read()
{
	int f=1,s=0; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9')	s=s*10+ch-'0',ch=getchar();
	return f*s;
}
map<pa,int> g;
multiset<int> ed[N];
queue<pa> nd;
void add(int x,int y)
{
	if(x==y) return; if(x>y) swap(x,y); ed[x].insert(y); ed[y].insert(x);
	g[mp(x,y)]++; if(g[mp(x,y)]==2)	nd.push(mp(x,y));
}
void del(int x,int y)
{
	ed[y].erase(ed[y].find(x)); if(x>y)	swap(x,y);
	if(g.count(mp(x,y))) g.erase(mp(x,y));
}
int main()
{
	int n=read();
	for(int i=1;i<=2*(n-1);i++)	add(read(),read());
	for(int i=1;i<n;i++)
	{
		while(1)
		{
			if(nd.empty())	return puts("NO"),0;
			int x=nd.front().fs,y=nd.front().se; nd.pop();
			if(!g.count(mp(x,y)))	continue;
			if(ed[x].size()<ed[y].size())	swap(x,y);
			for(multiset<int>::iterator it=ed[y].begin();it!=ed[y].end();it++)
			{
				int to=*it; del(y,to); add(x,to);
			}
			break;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 36736