akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = (a); i <= (n); i++)
using namespace std;

int a[3000001];
vector<int> p;
int N;

int main(void) {
  REP(i, 1, 3000000) if(i % 7 == 1 || i % 7 == 6) a[i] = 1; else a[i] = 0;
  a[1] = 0;
  REP(i, 1, 3000000) if(a[i]) for(int j = i * 2; j <= 3000000; j += i) a[j] = 0;
  REP(i, 1, 3000000) if(a[i]) p.push_back(i);

  while(cin >> N, N != 1) {
    cout << N << ":";
    for(int i : p) {
      if(i > N) break;
      if(N % i == 0) cout << " " << i;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 16512
import java.util.*;

class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();

		int min = 1000000000;
		int max = 0;

		for(int i=0; i<N; i++){
			int A = sc.nextInt();
			min = Math.min(min,A);
			max = Math.max(max,A);
		}

		System.out.println(Math.abs(max - min));
	}

}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int read();
void Add(int &x, int y) { (x += y) >= mod ? x -= mod : x; }
int n, k;
int vis[1003];
int f[1003][1003], g[1003], lim = 1000;
int pre[1003];
int h(int l, int r) { return pre[r] - pre[l - 1]; }

int fsp(int bs, int p) {
    int rt = 1;
    while (p) {
        if (p & 1) rt = 1ll * rt * bs % mod;
        bs = 1ll * bs * bs % mod, p >>= 1;
    }
    return rt;
}

void init() {
    g[0] = 1;
    for (int i = 1; i <= lim; ++i) g[i] = 1ll * g[i - 1] * ((i << 1) - 1) % mod;
}

int res;

void solve(int l, int r) {
    for (int x = l; x <= r; ++x)
        if (vis[x] && (vis[x] < l || vis[x] > r)) return;
    f[l][r] = g[h(l, r) >> 1];
    for (int x = l + 1; x < r; ++x)
        Add(f[l][r], mod - 1ll * f[l][x] * g[h(x + 1, r) >> 1] % mod);
    Add(res, 1ll * f[l][r] * g[h(1, l - 1) + h(r + 1, n << 1) >> 1] % mod);
}

int main() {
    n = read(), k = read(), init();
    for (int t = 1, u, v; t <= k; ++t)
        u = read(), v = read(), vis[u] = v, vis[v] = u;

    for (int i = 1; i <= 2 * n; ++i) pre[i] = pre[i - 1] + (!vis[i]);

    for (int l = 1; l <= 2 * n; ++l)
        for (int r = l + 1; r <= 2 * n; ++r)
            !((h(l, r) & 1) || (r - l + 1 & 1)) ? solve(l, r) : void();
    printf("%d\n", res);
    return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main() {
	int n,m,i,j,t=0,a[100000];
	long long int ans[2] = { 0, 1 };
	scanf("%d", &n);
	scanf("%d", &m);
	for (i = 0; i < m; i++) scanf("%d", &a[i]);
	for (i = 0; i < n; i++) {
		ans[i % 2] = (ans[0] + ans[1]) % 1000000007;
		for (j = t; j < m; j++) if (i == a[j] - 1) {
			ans[i % 2] = 0;
			t = j;
			break;
		}
	}
	printf("%lld", ans[(n+1)%2]);
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define BIG 10e9
#define SIZE 1000
using namespace std;


int bubbleSort(int *A, int N) {
	int flag = 1;
	int tmp;
	int count = 0;
	while (flag) {
		flag = 0;
		for (int j = N - 1; j >= 1; j--) {
			if (A[j] < A[j - 1]) {
				tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
				flag = 1;
				count++;
			}
		}
	}
	return count;
}

int main() {
	int N;
	int A[SIZE];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	int c = bubbleSort(A, N);
	for(int i=0;i<N;i++){
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n%d\n", c);
	return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+2;
int a[N];
int res=2e9;
int main(){
	int n,k; scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n-k+1;i++){
		int j=i+k-1;
		if(a[i]<0&&a[j]<0||a[i]>0&&a[j]>0){
			res=min(max(abs(a[i]),abs(a[j])),res);
		}
		else{
			res=min(res,min(abs(a[i])*2+abs(a[j]),abs(a[i])+abs(a[j])*2));
		}
	}
	printf("%d",res);
return 0;
}
/*
5 2
-4 -3 -2 0 4

5 3
-30 -10 10 20 50

3 2
10 20 30

1 1
0

8 5
-9 -7 -4 -3 1 2 3 4
*/

Measured memory_bytes: 640
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

const MOD: usize = 1000000007;
fn main() {
    input!{
        n: usize,
        k: usize,
    };

    let mut ret = 1;
    for i in k..n+1 {
        let l = i*(i - 1)/2;
        let r = i*(n + n - i + 1) / 2;
        ret = (ret + r - l + 1) % MOD  ;
    }
    println!("{}", ret);
}


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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		String inputValue = br.readLine();
		String[] inputArray = inputValue.split(" ");

		int a = Integer.parseInt(inputArray[0]);
		int b = Integer.parseInt(inputArray[1]);
		int c = Integer.parseInt(inputArray[2]);

		if(a < b && b < c ){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 24248
# -*- coding: utf-8 -*-

from collections import Counter
n = int(input())
a = [input() for _ in range(n)]
ans = Counter(a)

print(f'AC x {ans["AC"]}')
print(f'WA x {ans["WA"]}')
print(f'TLE x {ans["TLE"]}')
print(f'RE x {ans["RE"]}')


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

#define PI 3.14159265359

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  if ((A % K) == 0 || (A % K) > (B % K) || B - A >= K){
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }
}


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

namespace abc151_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = nm[0];
            int M = nm[1];
            int[] points = new int[N];
            int[] penalties = new int[N];
            for (int i = 0; i < M; i++)
            {
                string[] ps = Console.ReadLine().Split();
                int p = int.Parse(ps[0]);
                string s = ps[1];
                if (s == "AC")
                {
                    points[p - 1] = 1;
                } else
                {
                    if (points[p - 1] != 1)
                    {
                        penalties[p - 1]++;
                    }
                }
            }
            int sumPoints = 0;
            int sumPenalty = 0;
            for (int j = 0; j < N; j++)
            {
                if (points[j] == 1)
                {
                    sumPoints++;
                    sumPenalty += penalties[j];
                }
            }
            Console.WriteLine(sumPoints.ToString() + " " + sumPenalty.ToString());
        }
    }
}


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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n, w;
	cin >> n >> w;
	
	lli cost[n][2];
	for (int i = 0; i < n; ++i) {
		cin >> cost[i][0] >> cost[i][1];
	}
	
	vcL knap(w + 5, 0);
	for (int i = 0; i < n; ++i) {
		for (int j = w; j >= cost[i][0]; --j) {
			knap[j] = max(knap[j], knap[j - cost[i][0]] + cost[i][1]);
		}
	}
	
	cout << knap[w] << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}




Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int n,_;
    cin>>n>>_;
    vvi v(n);
    int t,x;
    while(_--){
        int Q;
        cin>>Q;
        switch(Q){
        case 0:
            cin>>t>>x;
            v[t].pb(x);
            break;
        case 1:
            cin>>t;
            rep(i,v[t].size()){
                if(!i)cout<<v[t][0];
                else cout<<" "<<v[t][i];
            }
            cout<<endl;
            break;
        case 2:
            cin>>t;
            v[t].clear();
            break;
        }
    }
}




Measured memory_bytes: 5792
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

int main(){FIN;
	string s; cin>>s;
	ll k; cin>>k;
	vector<pair<ll,char>> v;
	char va='.';
	ll van=0;
	fore(i,0,SZ(s)){
		if(s[i]!=va){
			if(va!='.')v.pb({van,va});
			va=s[i];
			van=1;
		}else{
			van++;
		}
		if(i==SZ(s)-1){
			if(va!='.')v.pb({van,va});
		}
	}
	//for(auto i:v)cout<<i.fst<<" "<<i.snd<<"\n";
	ll res=0;
	if(SZ(v)==1){
		cout<<(SZ(s)*k)/2; return 0;
	}
	fore(i,0,SZ(v)){
		if(i==0){
			res+=v[i].fst/2;
		}else if(i==SZ(v)-1){
			res+=v[i].fst/2;
		}else{
			res+=k*(v[i].fst/2);
		}
	}
	if(v[0].snd==v[SZ(v)-1].snd){
		res+=(k-1)*((v[0].fst+v[SZ(v)-1].fst)/2);
	}else{
		res+=(k-1)*(v[0].fst/2);
		res+=(k-1)*(v[SZ(v)-1].fst/2);
	}
	cout<<res<<"\n";
	return 0;
}

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

int main(void) {
	uint64_t a, b, x;
	if (scanf("%" SCNu64 "%" SCNu64 "%" SCNu64, &a, &b, &x) != 3) return 1;
	printf("%" PRIu64 "\n", a == 0 ? ((b / x) + 1) : ((b / x) -  ((a - 1) / x)));
	return 0;
}


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

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

    int num[110] = {0};
    for (int i = 0; i < N; ++i) {
        num[d[i]]++;  // d[i] が 1 個増える
    }

    int res = 0;  // 答えを格納
    for (int i = 1; i <= 100; ++i) {  // 1 <= d[i] <= 100 なので 1 から 100 まで探索
        if (num[i] > 0) {  // 0 より大きかったら
            ++res;
        }
    }
    cout << res << endl;
}

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

using namespace std;

typedef pair< int, int > Pi;

int main()
{
  int N;
  char D[1000];
  int L[1000];

  vector< Pi > beet;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> D[i] >> L[i];
    if(D[i] == 'y') beet.emplace_back(L[i], i);
  }
  sort(begin(beet), end(beet));
  int ret = 0;
  bool v[1000] = {};
  for(auto &p : beet) {
    if(v[p.second]++) continue;
    ++ret;
    for(int i = p.second - 1; i >= 0; i--) {
      if(D[i] == 'n' && p.first <= L[i]) break;
      v[i] = true;
    }
    for(int i = p.second + 1; i < N; i++) {
      if(D[i] == 'n' && p.first <= L[i]) break;
      v[i] = true;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define int long long

template <typename T>
struct SegmentTree {
  using F = function<T(T, T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(F f, T ti) : f(f), ti(ti) {}
  void init(int n_) {
    n = 1;
    while (n < n_) n <<= 1;
    dat.assign(n << 1, ti);
  }
  void build(const vector<T> &v) {
    int n_ = v.size();
    init(n_);
    for (int i = 0; i < n_; i++) dat[n + i] = v[i];
    for (int i = n - 1; i; i--)
      dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
  }
  void update(int k, T x) {
    dat[k += n] = x;
    while (k >>= 1)
      dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
  }
  T query(int a, int b) {
    T vl = ti, vr = ti;
    for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vl = f(vl, dat[l++]);
      if (r & 1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
};
signed main() {
  int n, q;
  cin >> n >> q;
  const int INF = (1LL << 31) - 1LL;

  SegmentTree<int> seg([&](int a, int b) { return min(a, b); }, INF);
  seg.init(n);

  while (q--) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      seg.update(x, y);
    } else {
      cout << seg.query(x, y + 1) << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 4876
#include <bits/stdc++.h>
using namespace std;
enum class WalkingResult { undef, walked };
enum class LandS { sea, land };
using LMap = vector<vector<LandS>>;

void solve(int w, int h) {
    LMap lMap(h, vector<LandS>(w));
    vector<pair<int, int>> lands;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int t;
            cin >> t;
            lMap[i][j] = t == 1 ? LandS::land : LandS::sea;
            if (t == 1) lands.push_back(make_pair(i, j));
        }
    }

    vector<vector<WalkingResult>> wMap(h, vector<WalkingResult>(w, WalkingResult::undef));
    int count = 0;
    stack<pair<int, int>> s;
    for (int i = 0; i < lands.size(); ++i) {
        pair<int, int> x = lands[i];
        bool already = wMap[x.first][x.second] == WalkingResult::walked;
        if (already) continue;
        s.push(x);
        while(!s.empty()) {
            pair<int, int> pos = s.top();
            s.pop();
            bool out = pos.first < 0 || h <= pos.first || pos.second < 0 || w <= pos.second;
            if (out) continue;
            bool sea = lMap[pos.first][pos.second] == LandS::sea;
            bool walked = wMap[pos.first][pos.second] == WalkingResult::walked;
            if (sea || walked) continue;
            wMap[pos.first][pos.second] = WalkingResult::walked;
            s.push(make_pair(pos.first + 1, pos.second));
            s.push(make_pair(pos.first - 1, pos.second));
            s.push(make_pair(pos.first, pos.second + 1));
            s.push(make_pair(pos.first, pos.second - 1));
            s.push(make_pair(pos.first - 1, pos.second - 1));
            s.push(make_pair(pos.first + 1, pos.second - 1));
            s.push(make_pair(pos.first - 1, pos.second + 1));
            s.push(make_pair(pos.first + 1, pos.second + 1));
        }
        count++;
    }
    cout << count << endl;
}

int main() {

    while (true) {
        int w, h;
        cin >> w >> h;
        if (w == 0 && h == 0) break;
        solve(w, h);
    }
    return 0;
}



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

int main(void) {
  int A, B;
  int n[5];
  cin >> A >> B;
  
  int cnt = 0;
  for (int i = A; i <= B; ++i) {
    int index = 0;
    int val = i;
    while (val > 0) {
      n[index] = val % 10;
      val /= 10;
      ++index;
    }
    
    if ((n[0] == n[4]) && (n[1] == n[3])) ++cnt;
    
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =3e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int main()
{
	double n,d;
	scanf("%lf %lf",&n,&d);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		double x,y;
		scanf("%lf %lf",&x,&y);
		double dist=sqrt(x*x+y*y);
		if(d>=dist) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3832
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		char a = x.charAt(0);
		boolean flag = true;
		for(int i = 1; i < 4; i++) {
			if(a == x.charAt(i)) {
				flag = false;
				break;
			} else {
				a = x.charAt(i);
			}
		}
		if(flag) {
			System.out.println("Good");
		} else {
			System.out.println("Bad");
		}
	}

}


Measured memory_bytes: 24276
use proconio::input;

fn main() {
    input! {
        n: String,
    }
    let mut weather: Vec<char> = Vec::new();
    for char in n.chars() {
        weather.push(char);
    }

    let mut yesterday = ' ';
    let mut result = 0;
    for i in 0..weather.len() {
        if i == 0 {
            // 1回目以降
            if weather[i] == 'R' {
                result = 1;
            }
            yesterday = weather[i];
        } else {
            // 2回目以降
            if weather[i] == 'R' && yesterday == 'R' {
                result += 1;
            } else if weather[i] == 'R' {
                result = 1;
            }
            yesterday = weather[i];
        }
    }
    println!("{}", result);
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

struct Matrix {
	int n, m;
	ll val[10][10];

	Matrix(int N, int M) {
		n = N;
		m = M;
		memset(val, 0, sizeof(val));
	}

	ll* operator[](int x) {
		return val[x];
	}	
};

Matrix operator*(Matrix a, Matrix b) {
	Matrix c(a.n, b.m);
	for (int i = 0; i < a.n; i++) {
		for (int j = 0; j < b.m; j++) {
			for (int k = 0; k < a.m; k++) {
				c[i][j] = (c[i][j] + a[i][k] * b[k][j] % mod) % mod;
			}
		}
	}

	return c;
}

Matrix pow(Matrix a, ll b) {
	Matrix res(a.n, a.m);
	for (int i = 0; i < a.n; i++) {
		res[i][i] = 1;
	}

	for (int i = 60; i >= 0; i--) {
		res = res * res;
		if ((b >> i) & 1) {
			res = res * a;
		}
	}

	return res;
}

int n, m, a[maxn];

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

	Matrix updater(4, 4);
	Matrix spUpdater(4, 4);
	for (int i = 0; i < 4; i++) {
		updater[i][i] = updater[i][0] = updater[3][i] = 1;
		spUpdater[i][i] = spUpdater[i][0] = spUpdater[3][i] = 1;
	}
	for (int i = 0; i < 4; i++) {
		updater[i][3]++;
	}
	
	Matrix dp(4, 1);
	for (int i = 0; i < 4; i++) {
		dp[i][0] = 1;
	}

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

	int pos = 1;
	for (int i = 0; i < m; i++) {
		Matrix tmp = pow(updater, a[i] - pos);
		tmp = spUpdater * tmp;
		dp = tmp * dp;
		pos = a[i] + 1;
	}
	if (pos < n) {
		dp = pow(updater, n - pos) * dp;
	}
	cout << dp[3][0] << endl;
}



Measured memory_bytes: 4000
#include <stdio.h>

void fx(int A[],int m);
int main (void){
	int m;
	scanf("%d",&m);
	int A[m];
	for(int i=0;i<m;i++){
		scanf("%d",&A[i]);
	}
	fx(A,m);
}

void fx(int A[],int m){

	int min,max;
	min=A[0];
	max=A[1]-A[0];
	for(int j=1;j<=m-1;j++){
		if(A[j]-min>max){
			max=A[j]-min;
		}
		
		if(A[j]<min){
			min=A[j];
		}
	}
	
	printf("%d\n",max);
}


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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    x = [0] * N

    ac = 0
    wa = 0

    for i in range(M):
        if x[p[i]-1] >= 0:
            if S[i] == "AC":
                ac += 1
                wa += x[p[i]-1]
                x[p[i]-1] = -1
            else:
                x[p[i]-1] += 1
    print(ac, wa)


    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14116
from functools import reduce
add = lambda a, b: a+b

N = int(input())
a = [0] + [int(x) for x in input().split()]
balls = [0]*(N+1)

for i in range(N, 0, -1):
  if sum([balls[j] for j in range(i, N+1, i)]) % 2 != a[i]:
    balls[i] += 1

ans = []
for i, b in enumerate(balls):
  if b == 1:
    ans.append(i)
print(len(ans))

if len(ans) != 0:
  print(" ".join([str(a) for a in ans]))


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

int N;

void DFS(int P, int Q, string S) {
	if (P == N) {
		cout << S << endl;
		return;
	}
	for (int i = 0; i <= Q + 1; i++) {
		DFS(P + 1, max(Q, i), S + (char)('a' + i));
	}
}

int main() {
	cin >> N;
	DFS(0, -1, "");
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)

int main(void) {
    int n; cin >> n;
    vector<int> a(150000);
    rep(i, n) {
        int l, r; cin >> l >> r;
        l--;
        a[l]++;
        a[r]--;
    }
    rep(i, a.size()-1) {
        a[i+1] += a[i];
    }
    int ret = 0;
    rep(i, a.size()) {
        if (a[i] >= i) 
            ret = i;
    }
    cout << ret << endl;
    return 0;
}



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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    ll n, a, b;
    cin >> n >> a >> b;

    ll x, y;
    if(n<=a) {
        cout << n << endl;
        return 0;
    }
    else {
        x = n / (a+b);
        y = min(a, n % (a+b));
        cout << x*a + y << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int ps[] = {3, 2, 1, 0};
  int X, Y; cin >> X >> Y;
  cout << 100000 * ((X * Y == 1) * 4 + ps[min(4, X) - 1] + ps[min(4, Y) - 1]) << endl;}

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

using namespace std;

int main()
{
	int n;
	int sp[2][12];
	multiset<int> cnt;

	while(cin >> n, n)
	{
		for(int i=0; i < n; i++) {
			cin >> sp[0][i];
		}
		int idx = 0;
		int count = -1;
		while(1)
		{
			int ii =  (idx + 1) % 2;
			cnt.clear();
			for(int i=0; i < n; i++) {
				cnt.insert(sp[idx][i]);
			}
			bool hit = true;
			for(int i=0; i < n; i++) {
				sp[ii][i] = cnt.count(sp[idx][i]);
				if(sp[idx][i] != sp[ii][i]) hit = false;
			}
			count++;
			if(hit) break;
			idx = ii;
		}
		cout << count << endl;
		for(int i=0; i < n-1; i++) {
			cout << sp[0][i] << ' ';
		}
		cout << sp[0][n-1] << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

long long dp[101][100001];
ll n;
vector<ll> w(105),val(105);

long long d(int i, long long weight){
    if (dp[i][weight]!=-1) return dp[i][weight];
    if (i==n || weight==0) return dp[i][weight]=0;

    if (w[i]<=weight) return dp[i][weight]=max( d(i+1,weight) , d(i+1,weight-w[i])+val[i] );
    return dp[i][weight]=d(i+1,weight);
}

int main()
{
    long long i,x,y,W;
    cin >> n >> W;
    memset(dp,-1,sizeof dp);
    for(i=0;i<n;i++){
        cin >> w[i] >> val[i];
    }
    cout << d(0,W);
    return 0;
}


Measured memory_bytes: 79104
mod = 10**9+7
n,k = map(int,input().split())
a = list(map(int,input().split()))
sub,inv = 0,0
for i in range(n):
  for j in range(n):
    if a[j] > a[i]:
      if i < j:
        sub+=1
      inv+=1
print(((inv*(k*(k+1))//2)-(sub*k))%mod)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

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

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 10000;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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


void solve() {
	int n, k; cin >> n >> k;
	modint ans = 0;

	modint b = 1;
	rep(i, 100)b *= 10;

	vector<ll> ra(n + 2);
	rep(i, n + 1) {
		ra[i + 1] = ra[i] + i;
	}
	for (int c = k; c <= n + 1; c++) {
		ll le = ra[c];
		ll ri = ra[n + 1] - ra[n + 1 - c];
		ans += (ri - le + 1);
	}
	cout << ans << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(4);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


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

int main()
{
  string s, t;
  cin >> s >> t;
  int i, j;
  bool same = true;
  for(i = 'a'; i <= 'z'; i++)
  {
    char check = '#';
    char check2 = '#';
    for(j = 0; j < s.length(); j++)
    {
      if(s.at(j) == i && check != '#')
      {
        if(check != t.at(j))
        {
          same = false;
        }
      }
      if(s.at(j) == i && check == '#')
      {
        check = t.at(j);
      }
      if(t.at(j) == i && check2 !='#')
      {
        if(check2 != s.at(j))
        {
          same = false;
        }
      }
      if(t.at(j) == i && check2 == '#')
      {
        check2 = s.at(j);
      }
    }
  }
  if(same)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var a = l[0]; var b = l[1];
        Console.WriteLine(((a % 2 == 0 && b % 2 == 0)||(a % 2 == 0 || b % 2 == 0)) ? "Even" : "Odd");
    }
}

Measured memory_bytes: 13396
#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>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    string s;
    cin >> s;
    int ans = 0;
    rep(i,4) {
        if (s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }




int main() {
    long long X;
    while (cin >> X) {
        long long res = X / 500 * 1000;
        X %= 500;
        res += X / 5 * 5;
        cout << res << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,h[100000],flag=1,
      i;
  
  scanf("%d",&n);
  
  scanf("%d",&h[0]);
  h[0]--;
  
  for(i=1;i<n;i++){
    scanf("%d", &h[i]);
    
    if(h[i-1] < h[i]){
      h[i]--;
    }else if(h[i-1] > h[i]){
      flag=0;
    }
  }
  
  if(flag){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *,const void *);
int judge(int *,int );
int cmp(const void *a,const void *b)
{
    return *(int *)a-*(int *)b;
}
int judge(int *a,int n)
{
    int i;
    qsort(a,n,sizeof(a[i]),cmp);
    for(i=1;i<n;i++)
    {
        if(a[i]==a[i-1])
        {
            return 0;
        }
    }
    return 1;
}
int main()
{
    int a[200000],n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    printf((judge(a,n)==1)?"YES\n":"NO\n");
    return 0;
}


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

int main(){
  string s, t;
  cin>>s >>t;
  
  for(int i=0;i<(int)s.size();i++){
    if(s[i]!=t[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,inv10;
char s[N];
map<pair<int,int>,int>vis;
ll qpow(ll a,ll n,ll mod)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int mod1=3,mod2=673;
int main()
{
    int inv10_1=qpow(10,mod1-2,mod1);
    int inv10_2=qpow(10,mod2-2,mod2);
    scanf("%s",s+1);
    vis[{0,0}]++;
    int sum1=0,sum2=0;
    ll ans=0,k1=1,k2=1;
    for(int i=1;s[i];i++)
    {
        k1=k1*inv10_2%mod1;
        k2=k2*inv10_2%mod2;
        sum1=(sum1+(ll)(s[i]-'0')*k1%mod1)%mod1;
        sum2=(sum2+(ll)(s[i]-'0')*k2%mod2)%mod2;
        ans+=vis[{sum1,sum2}];
        vis[{sum1,sum2}]++;
    }
    printf("%lld\n",ans);
}



Measured memory_bytes: 4112
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
const ll maxi =20000;
#define ip pair<ll,ll>
#define mp make_pair
int main()
{ 
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);


int n;
cin>>n;
int a[n];
vector<int> freq((int)1e6+5,0);
for(int i=0;i<n;i++)
cin>>a[i];
for(ll i=0;i<n;i++)
{
  cin>>a[i];
  freq[a[i]]++;
}
ll ans=0;




for(int i=0;i<n;i++)
{ bool found=true;
  for(int j=2;j<=sqrt(a[i]);j++)
  {
    if(a[i]%j==0)
    { 
      ll x=a[i]/j;
      if(freq[x]||freq[j])found=false;
    }
  }if(found&&freq[a[i]]==1)ans++;
}
if(freq[1]==1)ans=1;
else if(freq[1]>1)ans=0;
cout<<ans<<endl;




}


Measured memory_bytes: 7908
#include<iostream>
#include<list>
#include<stack>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
	string s;cin >> s;
	stack<int> st;
	stack<pair<int,int> > st2;
	int ans;
	int j=0;
	for(int i=0;i<s.length();i++){
		if(s[i] == '\\'){ 
			st.push(i);
		}else if(s[i] == '/' && !st.empty()){
			int k = st.top();st.pop();
			ans += i-k;
			j = i-k;
		
			while(st2.size()>0 && st2.top().first > k){
				j += st2.top().second;st2.pop();
			}
			st2.push(make_pair(k,j));
		}
	}
	cout << ans << endl;
	int limit = st2.size();
	cout << limit;
	vector<int> a(limit);
	for(int i=0;i<limit;i++){
		a[i] = st2.top().second;
		st2.pop();
	}
	reverse(a.begin(),a.end());
	for(int i=0;i<limit;i++){
		cout << " " <<a[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, a, b;
    cin >> n >> a >> b;

    if(n == 1) cout << "Hello World" << endl;
    else cout << a + b << endl;

}

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

typedef long long ll;
ll ss = 1e9+7;

int main() {
	int N, M;
	cin >> N >> M;
	vector<ll> a(N+1), b(N+1), c(M+1), d(M+1);
	for (int i = 1; i <= N; i++) cin >> a[i] >> b[i];
	for (int i = 1; i <= M; i++) cin >> c[i] >> d[i];
	vector<pair<ll, int> > m[51];
	ll r;

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			r = abs(a[i] - c[j])+abs(b[i]-d[j]);
			//cout <<" "<< r << endl;
			m[i].push_back(make_pair(r, j));
		}
		sort(m[i].begin(), m[i].end());
		cout << m[i].front().second << endl;
	}
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){ T x; cin >> x; return (x); }
template<typename T=int,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return move(x); }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

	int N=in();
	ll A=1,B=1;
	REP(i,N){
		ll x=in(),y=in();
		ll k=max((A+x-1LL)/x,(B+y-1LL)/y);
		A=k*x,B=k*y;
	}
	
	out(A+B);
	return 0;
}


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

int main() {
  
  int N; cin >> N; int64_t sum = 0, leftSide = 0, rightSide = 0;
  
  int64_t minDif = 2020202020, tmp;
  
  vector<int64_t> vec(N);
  
  for (int i = 0; i < N; i++) {
    
    cin >> vec[i]; sum += vec[i];
    
  }
  
  for (int i = 0; i < N - 1; i++) {
    
    leftSide += vec[i]; rightSide = sum - leftSide;
    
    tmp = abs(leftSide - rightSide);
    
    minDif = min(minDif, tmp);
    
  }
  
  cout << minDif << endl;
  
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	string s; cin >> s;
	ll n = s.size();
	ll zerosum = 0;
	ll ans = 0;
	rep(i,n){
		if(s[i] == '0') zerosum++;
	}
	ll zero = 0;
	rep(i,n){
		if(s[i] == '1'){
			ll j = i;
			while(j < n && s[j] == '1') j++;
			ll num = j - i;
			if(num % 2 == 0){
				ans += zerosum * (num / 2);
			}else{
				ans += (zerosum - zero) * ((num+1) / 2);
				ans += zero * (num / 2);
				if(i & 1) ans += zero / 2;
				else ans += (zero + 1) / 2; 
			}
			i = j-1;
		}else{
			zero++;
		}
	}
	ll rest = n - zerosum;
	if(rest & 1) ans += (rest+1) / 2;
	rest /= 2;
	ans += rest * (rest + 1);
	cout << ans << "\n";
}

Measured memory_bytes: 3764
#include <stdio.h>
#include <string.h>
//ポインタで元のTを操作する
void charRot(char enT[],int length);

int main(void){
    char S[101],T[101];
    scanf("%s %s",S, T);
    //Tの文字列長さ取得
    int Tlength = -1;
    while(T[++Tlength] != '\0');
    //for(Tlength=0;T[Tlength]!='\0';Tlength++);
    //処理
    int i, flag=0;
    char* pt = T;
    for(i=0; i<Tlength; i++){//一致したらフラグ立ててbreak
        if(strcmp(S,T)==0) flag++;
        charRot(pt, Tlength);
        if(flag) break;
    }
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}
//後ろの文字を一番前に移動させる関数
void charRot(char enT[], int length){
    char temp = enT[length-1];
    int i;
    for(i = length-1; i > 0; i--) enT[i] = enT[i-1];
    enT[0] = temp;
    return;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int a, b;
    cin >> a >> b;

    if ((a <= 0 && b >= 0) || (a == 0 || b == 0)) cout << "Zero";
    else if (a > 0 && b > 0) cout << "Positive";
    else if (a < 0 && b > 0) {
        if (abs(a) % 2 != 0) cout << "Negative";
        else cout << "Positive";
    }
    else if (a < 0 && b < 0) {
        if (abs(a) % 2 != 0) {
            if (abs(b) % 2 != 0) cout << "Negative";
            else cout << "Positive";
        }
        else {
            if (abs(b) % 2 != 0) cout << "Positive";
            else cout << "Negative";
        }
    }

    return 0;
}

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

int n;
int main() {
	cin >> n;
	int i, j, x, y, z;
	for(i=1; i<n; i++, puts("")) {
		for(j=i+1; j<=n; j++) {
			x=i, y=j, z=1;
			while((x&1) == (y&1)) x>>=1, y>>=1, z++;
			printf("%d ", z);
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n)  for(ll i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
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; }

int main(){
  int n; cin >> n;
  vi x(n); rep(i,n) cin >> x[i];
  vi tmp(n);
  tmp = x;
  sort(all(tmp));
  rep(i,n) cout << (x[i] <= tmp[n/2-1] ? tmp[n/2] : tmp[n/2-1]) << "\n";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 4760
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (v <= w)cout << "NO" << endl;
    else {
        ll dis = abs(a - b);
        cout << (dis <= (v - w) * t ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    int x, y;
    cin >> x >> y;
    int pl, mi, ka;
    pl = x + y;
    mi = x - y;
    ka = x * y;
    ct(max(pl, max(mi,ka)));
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	if(input[2]===input[3] && input[4] ===input[5]){console.log("Yes");}
  else{console.log("No");}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
   
        cout << fixed << setprecision(10) << sqrt(pow(y2-y1,2)+pow(x2-x1,2)) << endl;
}


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

int main() {
	int N;
	long long K, A[100000], X = 0, f = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	if (K == 0) {
		for (int i = 0; i < N; i++) {
			f += A[i];
		}
		cout << f << endl;
		return 0;
	}
	for (long long i = 40; i >= 0; i--) {
		int c = 0;
		for (int j = 0; j < N; j++) {
			if (((A[j] >> i) & 1) == 1) {
				c++;
			}
		}
		if (N - c >= c) {
			long long l = 1, y;
			y = X;
			y += (l << i);
			if (y <= K)X = y;
		}
	}
	for (int i = 0; i < N; i++) {
		f += (X ^ A[i]);
	}
	cout << f << endl;
}


Measured memory_bytes: 1024