akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;
 
//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  cout << 48-n << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int a[100005];
int main()
{
	int n,t;
	cin >> n >> t;
	for(int i = 0;i < n;i++)
	cin >> a[i];
	int min1 = 1000000007,maxc = 0;
	for(int i = 0;i < n;i++)
	{
		 min1 = min(min1 , a[i]);
		 maxc = max(maxc , a[i] - min1);
	}
	int ans = 0;
	min1 = 1000000007; 
	for(int i = 0;i < n;i++)
	{
		min1 = min(min1 , a[i]);
		if(a[i] - min1 == maxc)
		ans++;
	 } 
	 cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
r = 0
for i,j in enumerate(B):
    c = min(j, A[i] + A[i+1])
    r += c
    A[i+1] -= max(0, c-A[i])
print(r)


Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9*2; const long long INFLL=1e18*2;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.second >> p.first; return is; }
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;}
//------------------------------------------------------------------------------

signed main() {
    int n;
    string s;
    cin>>n>>s;
    int ans=0,t=0;
    REP(i,n) {
        t+=(s[i]=='I'?1:-1);
        chmax(ans,t);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;



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

	cin >> T;
	while (T--) {
		vector<long long int>v(9);
		for (auto &i : v) {
			string s;
			cin >> s;
			for (auto j : s) {
				i *= 16;
				if (j <= '9'&&j >= '0')i += j - '0';
				else i += j - 'a' + 10;
			}
		}
		long long int ans = 0;
		for (int i = 0; i < 32; i++) {
			long long int a = 0;
			for (int j = 0; j < 8; j++) {
				a += v[j];
			}
			long long int b = v[8];
			if ((abs(a - b) >> i) & 1) {
				ans += 1LL << i;
				for (auto &j : v)j ^= 1LL << i;
			}
		//	cout << ans << endl;
		}
		cout << hex << ans << endl;
	}
}


Measured memory_bytes: 3084
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

s = input()

@lru_cache(None)
def F(s, k):
    # sの左からk文字目以降を整数と見なしたとき、
    # 2019で割った余りを返す
    if k == len(s)-1:
        return int(s[k])
    ret = F(s, k+1) + int(s[k])*pow(10, len(s)-1-k, 2019)
    ret %= 2019
    return ret

a = [0]*2020
for i in range(len(s)):
    a[F(s, i)] += 1

ans = a[0]
for i in range(2020):
    ans += a[i] * (a[i]-1) // 2

print(ans)

Measured memory_bytes: 263428
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	r := nextInt()

	result := ""
	if r < 1200 {
		result = "ABC"
	} else if r < 2800 {
		result = "ARC"
	} else {
		result = "AGC"
	}

	fmt.Println(result)
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
	int s[31],i;
	
	for(i=0;i<28;i++){
		scanf("%d",&s[0]);
		s[s[0]]=1;
	}
	for(i=1;i<31;i++){
		if(s[i]!=1)printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
A_list = list(map(int,input().split()))
a = [0]
b = [0]
point_list = a + A_list + b
S = 0
for i in range(N+1):
    S += abs(point_list[i]-point_list[i+1])

for i in range(1,N+1):
    print(S - abs(point_list[i-1] - point_list[i])
    -abs(point_list[i] - point_list[i+1])
    +abs(point_list[i-1] - point_list[i+1]))

Measured memory_bytes: 14176
#include <stdio.h>
#include <string.h>

int main(void){
	char str[100];
	int num;
	int code = 0;

	scanf("%d", &num);
	while(scanf("%s", str) != EOF){
		int len = strlen(str);
		for(int i=0; i<len; i++){
			if(str[i] >= '0' && str[i] <= '9'){
				int temp = i;
				while(str[i] != '\0' && str[i] >= '0' && str[i] <= '9'){
					i++;
				}
				str[i] = '\0';
				sscanf(&str[temp], "%d", &num);
				code += num;
			}
		}
	}
	printf("%d\n", code);

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	long long n;
	long long Min = 3000000;
	long long ans;
	long long a[300005];
	char trag;
	long long sum = 0;
	cin >> n;
	a[0] = 0;
	a[n + 1] = 0;
	for (long long i = 1; i <= n; i++)
	{
		cin >> trag;
		if (trag == 'E')
			sum++;
		a[i] = sum;
	}
	for (long long i = 1; i <= n; i++)
	{
		ans = a[n] - a[i];
		ans += (i - 1) - a[i - 1];
		Min = min(ans, Min);
	}
	cout << Min << endl;
	return 0;
}


Measured memory_bytes: 2560
H, W = list(map(int, input().split()))
S = [input() for y in range(H)]
c = [[0 for x in range(W)] for y in range(H)]
for y in range(H):
  s = 0
  for x in range(W):
    if S[y][x]=='#':
      s = 0
    else:
      c[y][x] = 1
      c[y][x] += s
      s += 1
  s = 0
  for x in range(W-1,-1,-1):
    if S[y][x]=='#':
      s = 0
    else:
      c[y][x] += s
      s += 1
for x in range(W):
  s = 0
  for y in range(H):
    if S[y][x]=='#':
      s = 0
    else:
      c[y][x] += s
      s += 1
  s = 0
  for y in range(H-1,-1,-1):
    if S[y][x]=='#':
      s = 0
    else:
      c[y][x] += s
      s += 1
print(max(map(max,c)))

Measured memory_bytes: 97368
#include<stdio.h>
int main()
{
	int a[2][105], n, s[105] = {0};
	int count;
	scanf("%d", &n);
	int i, j, sum[2] = {0};
	for(i=0;i<2;i++)
		for (j = 0; j < n; j++)
		{
			scanf("%d", &a[i][j]);
			sum[i] += a[i][j];
		}
	int tot=0;
	for (i = 0; i < n; i++)
	{
		tot += a[0][i];
		s[i] = tot + sum[1];
		sum[1] = sum[1] - a[1][i];
	}
	int max=s[0];
	for (i = 1; i < n; i++)
		max = max > s[i] ? max : s[i];
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
ll N, M, K;
ll Comb[200005]; // NM-2Ci

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

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

void init() {
  Comb[0] = 1ll;
  rep(i, K) {
    if (i==0) continue;
    Comb[i] = Comb[i-1]*(N*M-2-i+1)%MOD*modinv(i)%MOD;
  }
}

ll calc(ll x, ll L, ll L2) { // 一次元で差がx,長さがL, もう一次元の長さがL2
  return x*(L-x)%MOD*L2%MOD*L2%MOD;
}

int main() {
  INCANT;
  cin >> N >> M >> K;
  init();
  ll SUM=0ll;
  rep(i, M) {
    SUM+=calc(i, M, N);
    SUM%=MOD;
  }
  rep(i, N) {
    SUM+=calc(i, N, M);
    SUM%=MOD; 
  }
  cout << SUM*Comb[K-2]%MOD << "\n";
  return 0;
}

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

int main(){
	int N,x;
	int cont=0;
	cin>>N;
	x=N/4;
	for(int t=0;t<=x;t++){
		if((N-4*t)%7==0){
			cont++;
		}
	}
	if(cont>0){
		cout<<"Yes"<<"\n";
	}else{
		cout<<"No"<<"\n";
	}
	return 0;
}

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

int main(void){
    int n, k;
    cin >> n >> k;
    long long count = pow(n / k, 3);
    if (k % 2 == 0) {
        count += pow((k / 2 + n) / k, 3);
    }
    cout << count;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,ans=0;
  string s;
  cin>>n>>s;
  vector<string> v;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        string tmp;
        tmp=tmp+to_string(i)+to_string(j)+to_string(k);
        v.push_back(tmp);
      }
    }
  }
  rep(i,v.size()){
    bool flag1=false,flag2=false,flag3=false;
    rep(j,n){
      if(flag2 && v[i][2]==s[j]) flag3=true;
      if(flag1 && v[i][1]==s[j]) flag2=true;
      if(v[i][0]==s[j]) flag1=true;
    }
    if(flag1 && flag2 && flag3) ans++;
  }
  cout<<ans<<endl; 
}

Measured memory_bytes: 384
use std::io;
use std::str;
use std::usize;
use std::cmp;

fn mod_pow(x: i64, mut exp: i64, modulo: i64) -> i64 {
    let mut result = 1;
    let mut cur = x;
    while exp > 0 {
        if exp & 1 == 1 {
            result = (result * cur) % modulo;
        }
        cur = (cur * cur) % modulo;
        exp >>= 1;
    }
    result
}

fn main() {
    let modulo = 998244353;
    let n = read_values::<usize>()[0];
    let (x, y) = {
        let mut x = vec![0; n];
        let mut y = vec![0; n];
        for i in 0..n {
            let v = read_values::<i64>();
            x[i] = v[0];
            y[i] = v[1];
        }
        (x, y)
    };

    let mut ans = mod_pow(2, n as i64, modulo);
    ans -= 1;
    ans -= n as i64;
    ans = (ans + modulo) % modulo;

    for i in 0..n {
        for j in (i + 1)..n {
            let dx = x[i] - x[j];
            let dy = y[i] - y[j];

            let mut count = 0;
            let mut left = i;
            let mut right = j;
            for k in 0..n {
                let kx = x[i] - x[k];
                let ky = y[i] - y[k];
                if dx * ky - kx * dy == 0 {
                    left = cmp::min(left, k);
                    right = cmp::max(right, k);
                    count += 1;
                }
            }

            if left == i && right == j {
                let subset = mod_pow(2, count, modulo) - count - 1;
                ans = (ans + modulo - subset) % modulo;
            }
        }
    }

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

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

fn read_values<T>() -> Vec<T>
    where T: std::str::FromStr,
          T::Err: std::fmt::Debug
{
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& xs)
{
    return 0;
}

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

    int N, D;
    cin >> N >> D;

    cout << (N + 2*D) / (2*D + 1) << '\n';

    return 0;
}


Measured memory_bytes: 256
n  = int(input())
P = list(map(int, input().split()))
ans = 0
p1 = P[0]
p2 = P[1]
for p3 in P[2:]:
  l = [p1, p2, p3]
  if sorted(l)[1] == p2:
    ans+=1
  p1 = p2
  p2 = p3
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            var tmp = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
            int n = tmp[0];
            //int m = tmp[1];
            int x = tmp[2];
            var a = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
            var leftCost = a.Count(t => t < x);
            var rightCost = a.Count(t => t > x);
            Console.WriteLine(Math.Min(leftCost, rightCost));
        }
    }
}


Measured memory_bytes: 11348
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// doot diddly donger cuckerino Hahahahahah
// Created by White Knife on 15/04/20.
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC target("popcnt")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           (long long) (x).size()
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> range(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << range(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template <typename T> T gcd(T x, T y) { return (y == 0) ? x : gcd(y, x % y); }
template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// @formatter:on


class AAC {
public:

  void solveOne(istream &cin, ostream &cout) {
  
  }
  
  void solve(std::istream &cin, std::ostream &cout) {
    string s;
    cin >> s;
    if(s == "ABC"){
      cout << "ARC" << '\n';
    }else{
      cout << "ABC" << '\n';
    }
  }
};

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
	AAC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3660
N = int(input())

ARR = [int(s) for s in input().split(" ")]

import numpy as np
def calculate(n,arr):
    srr = np.array([arr - index - 1 for index,arr in enumerate(arr)])

    srr = sorted(srr)

    if len(srr) % 2 == 0:
        centerIndex = len(srr)//2
        b = (srr[centerIndex] + srr[centerIndex-1])//2
    else:
        centerIndex = (len(srr) -1) //2
        b = srr[centerIndex]



    return sum(np.fabs(srr - b))

result = int(calculate(N,ARR))

print(result)

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

int main() {
 
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  
  int ans = n;
  for(int i = 1; i < n; i++) {
    for(int j = 0; j < i; j++) {
      if(h.at(i) < h.at(j)) {
        ans--;
        break;
      }
    }
  }
  //ans = min(change1, change2);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

long long min(long long a, long long b)
{
	if(a>b)
		return b;
	else return a;
}

int main()
{
	long long n,k;
	while(~scanf("%lld %lld", &n, &k))
	{
		if(k>n)
			printf("%lld\n", min(n, k-n));
		else printf("%lld\n", min(n%k, k-n%k));
	}
	return 0;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char s[7];
  cin >> s;
  if(s[0]== 'S')
    cout << "Cloudy";
  else if(s[0] == 'C')
    cout << "Rainy";
  else
    cout << "Sunny";
}


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

int main() {
  int N;
  cin >> N;
  int64_t a = 2;
  int64_t b = 1;
  for(int i = 0;i < N;i++){
    int64_t c = a + b;
    a = b;
    b = c;
  }
  cout << a << endl;
}


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

using namespace std;

#define LIMIT 100
typedef pair<int64_t, int64_t> ii;
typedef int64_t ll;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, a, b;
  cin >> n >> a >>b;

  std::cout << min(a*n,b) << std::endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = s.nextInt();
        int b = s.nextInt();

        if(a%2==0){
            System.out.println("Even");
        }else{
            if(b%2==0)
                System.out.println("Even");
            else
                System.out.println("Odd");
        }

    }

}


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

#define FOR(i,a,b) for(long long i = long long(a); i<long long(b); ++i)
#define REP(i,b) FOR(i,0,b)

struct Read {
	long long operator()(void) {
		long long d;
		std::cin >> d;
		return d;
	}
}read;
struct ReadReal {
	double operator()(void) {
		double d;
		std::cin >> d;
		return d;
	}
}readReal;
struct ReadString {
	std::string operator()(void) {
		std::string s;
		std::cin >> s;
		return s;
	}
}readString;

struct Print {
	void operator()(double d, int digit) {
		std::cout << std::fixed << std::setprecision(digit) << d;
	}
	template <typename T>
	void operator()(T t) {
		std::cout << t;
	}
	template <typename T>
	void operator()(const std::vector<T> &v, const std::string &sep = " ") {
		if (v.empty()) return;
		Print()(v[0]);
		for(int i = 1;  i < v.size(); ++i) {
			Print()(sep);
			Print()(v[i]);
		}
		return;
	}
	template <typename T>
	void operator()(T begin, T end, const std::string &sep = " ") {
		if (begin == end) return;
		Print()(*begin);
		for(auto it = ++begin;  it != end; ++it) {
			Print()(sep);
			Print()(*it);
		}
		return;
	}
}print;
struct Println {
	void operator()(void) {
		std::cout << std::endl;
	}
	void operator()(double d, int digit) {
		print(d, digit);
		Println()();
	}
	template <typename T>
	void operator()(T t) {
		print(t);
		Println()();
	}
	template <typename T>
	void operator()(const std::vector<T> &v, const std::string &sep = " ") {
		print(v, sep);
		Println()();
	}
	template <typename T>
	void operator()(T begin, T end, const std::string &sep = " ") {
		print(begin, end, sep);
		Println()();
		return;
	}
}println;

long long InsertSort(vector<long long> *vec, int g) {
	vector<long long> &v = *vec;
	auto count = 0;
	for (long long i = g; i < v.size(); ++i) {
		auto pivod = v[i];
		auto j = i - g;
		while(j >= 0 && v[j] > pivod) {
			v[j + g] = v[j];
			j -= g;
			count++;
		}
		v[j + g] = pivod;
	}
	return count;
}

long long ShellSort(vector<long long> *vec) {
	vector<long long> &v = *vec;
	auto count = 0;
	vector<long long> G;
	for(auto i = 1; i <= v.size(); i = i * 3 + 1) {
		G.push_back(i);
	}
	for(auto it = G.rbegin(); it != G.rend(); ++it) {
		count += InsertSort(&v, *it);
	}
	println(G.size());
	println(G.crbegin(), G.crend());
	return count;
}

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

	auto size = read();
	vector<long long> v;
	v.reserve(size);
	for (auto i = 0; i < size; ++i) {
		v.push_back(read());
	}
	auto count = ShellSort(&v);
	println(count);
	println(v, "\n");

	return 0;
}



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

using namespace std;

vector<int> G[100005];
bool used[100005];


int next_vertex(int v) {
    for (auto vertex : G[v]) {
        if (!used[vertex]) return vertex;
    }
    return -1;
}


int main() {
    int n, m;
    cin >> n >> m;

    map<int, int> mp;
    while (m--) {
        int a, b;
        cin >> a;
        cin >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    deque<int> dq;
    dq.push_back(0);

    for (auto &x:used) x = false;
    used[0] = true;

    int v;
    while ((v = next_vertex(dq.back())) != -1) {
        dq.push_back(v);
        used[v] = true;
    }

    while ((v = next_vertex(dq.front())) != -1) {
        dq.push_front(v);
        used[v] = true;
    }

    cout << dq.size() << endl;
    for (auto itr = dq.begin(); itr != dq.end(); ++itr) {
        cout << (*itr) + 1;
        (itr + 1 == dq.end()) ? (cout << endl) : (cout << " ");
    }
    return 0;
}


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

using namespace std;

int n;
int a[200010];
long long dp[3][200010];
long long ans = -1e18;

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

	cin >> n;

	for(int i = 1; i <= n; i++) cin >> a[i];


	for(int i = 0; i <= n; i++) dp[0][i] = dp[1][i] = dp[2][i] = -1e18;

	dp[0][0] = 0;
	dp[0][1] = a[1];
	dp[0][2] = a[2];

	for(int i = 3; i <= n; i++){
		dp[0][i] = dp[0][i - 2] + a[i];
		dp[1][i] = max(dp[0][i - 3], dp[1][i - 2]) + a[i];
		dp[2][i] = max(dp[1][i - 3], dp[2][i - 2]) + a[i];

		if(i >= 4) dp[2][i] = max(dp[2][i], dp[0][i - 4] + a[i]);
	}

	if(n % 2 == 0){
		ans = max(max(dp[0][n - 1], dp[0][n]), dp[1][n]);
	} else {
		ans = max(dp[2][n], max(max(dp[1][n], dp[1][n - 1]), max(dp[0][n - 1], dp[0][n - 2])));
	}

	cout << ans << endl;
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> moti(N);
  for(int i = 0; i < N; i++)
    cin >> moti[i];
  sort(moti.begin(),moti.end());
  int m = 0;
  int mm = 0;
  for(int i = 0; i < N; i++){
    if(moti[i]>m){
      mm++;
      m = moti[i];
    }
  }
  cout << mm <<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi; 
typedef pair<int,int> pi;
typedef long long ll;
#define F first 
#define S second 
#define PB push_back 
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)

bitset<4000> alfa;
string s,t,r;

vector< vector<ll> > position;
vector< pair<ll,string> > see,newe; 

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	
	see.assign(3002, pair<ll, string>(4000, "") );
	position.assign(30, vector<ll>(0,0));
	
	alfa[0] = 1;
	see[0].F = -1;

	cin >> s >> t;
	
	ll ns = s.size(), nt = t.size();
		
	for(ll i = 0; i < nt; i++ ){
		position[ t[i] - 97 ].PB(i);
	}
		
	for(ll i = 0; i < ns; i++){
		
		ll here = s[i] - 97, siz = position[here].size();
		ll pos = 0;
		bool can = true;
		
		if(siz == 0) continue;
		
		newe = see;
		
		for(ll i2 = 0; i2 < 3001; i2++){
			
			while( position[here][pos] <= see[i2].F  ){
				pos++;
				if(pos == siz) can = false;
				if(pos == siz) break;  
			}
			
			if(!can) break;
			
			alfa[i2+1] = true;
			
			if(position[here][pos] < see[i2+1].F){
				newe[i2+1].F = position[here][pos];
				newe[i2+1].S = see[i2].S + s[i];
			}
			
			
		}
		
		see = newe;
		
		
	}	

	for(ll i = 0; i <= 3000; i++){
		
		if(alfa[i]){
			r = see[i].S;
		}
		
	}
	
	cout << r << endl;
	 	
	return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	ll n,k;
	cin>>n>>k;
	cout<<min(n%k, k-n%k)<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

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

int gcd(int m, int n){
  if(n==0){
    return m;
  }
  return gcd(n, m%n);
}

int main(){
  int W,H,C;
  cin >> W >> H >> C;

  int g = gcd(W, H);
  cout << W/g*H/g*C << endl;//縦と横をgcdで割り、正方形が縦と横に何個並ぶか求めて費用をかける
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int N = 1e5 + 100;

int n, m, x, y, z, par[N];

int g_par(int v) {
	return v == par[v]? v: par[v] = g_par(par[v]);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	iota(par, par + N, 0);
	cin >> n >> m;
	while(m--) {
		cin >> x >> y >> z;
		x = g_par(x);
		y = g_par(y);
		if(x != y) {
			par[x] = y;
			n--;
		}
	}
	cout << n;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(lambda x: int(x), input().split()))
b = list(map(lambda x: int(x), input().split()))
c = list(map(lambda x: int(x), input().split()))
ans = 0
pre_a = 0
for i in a:
    ans += b[i-1]
    if pre_a != 0 and i == pre_a + 1 :
        ans += c[pre_a-1]
    pre_a = i
print(ans)


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

int main(){
    vector<int> time(5);
    vector<int> wait(5);
    int maxwait=0;
    int sum=0;
    for(int i=0; i<5; i++){
        cin >> time.at(i);
        wait.at(i)=time.at(i)%10;
        if(wait.at(i)) wait.at(i)=10-wait.at(i);
        maxwait=max(maxwait,wait.at(i));
        sum+=time.at(i)+wait.at(i);
    }
    cout << sum-maxwait << endl;
}

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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
    cout << a << "\n";
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	// source code
    string s;
    int i=1;
    bool yes=true;
    cin >> s;
    for (char c : s)
    {
        if((i%2==0) && (c=='R') ) 
        {
            yes=false;
            break;
        }
        if((i%2==1) && (c=='L'))
        {
            yes=false;
            break;
        }
        i++;
    }

    cout << (yes?"Yes":"No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int s[N],a[N];
pair<int ,int >p[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;

	for(int i=0;i<m;i++)cin>>a[i];
		if(n>=m)
	{
		cout<<"0";return 0;
	}
	sort(a,a+m);
	for(int i=1;i<m;i++)
	{
		s[i]=a[i]-a[i-1];
		//cout<<s[i]<<" ";
	}
	sort(s,s+m);
	int sum=a[m-1]-a[0];
	for(int i=m-1;i>=m-n+1;i--)sum-=s[i];
	cout<<sum;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int dp[3][100][4]; // any,eql,small ndigit k
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    string N; cin >> N;
    int sz = N.size();
    int K; cin >> K;
    for (int i = 0; i < sz; i++) {
        for (int k = 0; k < 4; k++) {
            for (int t = 0; t <= 9; t++) {
                if (k + (t != 0) >= 4) continue;
                if (i == 0 && t == 0) continue;
                dp[0][i][k + (t != 0)] += (i > 0 ? dp[0][i - 1][k] : k==0);
                if (t == N[i] - '0') {
                    dp[1][i][k + (t != 0)] += (i > 0 ? dp[1][i - 1][k] : k==0);
                }
                if (t < N[i] - '0') {
                    dp[2][i][k + (t != 0)] += (i > 0 ? dp[1][i - 1][k] : k==0);
                }
                dp[2][i][k + (t != 0)] += (i > 0 ? dp[2][i - 1][k] : 0);
            }
        }
    }
    Int ans = 0;
    for (int i = 0; i < sz - 1; i++) {
        ans += dp[0][i][K];
    }
    ans += dp[1][sz-1][K] + dp[2][sz-1][K];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int,input().split()))
    s = 0
    for i, aa in enumerate(a):
        if i == 0:
            s = aa
        else:
            s ^= aa
        # print(bin(s))

    ans = []
    if n % 2 == 0:
        for i, aa in enumerate(a):

            ans.append(s^aa)
    else:
        # print(bin(s))
        for i, aa in enumerate(a):

            ans.append(s^aa)
            # print(bin(ans[-1]))
    print(' '.join(map(str,ans)))

if __name__=='__main__':
    main()


Measured memory_bytes: 41792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  vector<int> B(M);
  for(int i=0; i<M; i++){
    cin >> B[i];
  }
  sort(B.begin(),B.end());
  
  vector<int>::iterator pos;
  
  int64_t ans = 1;
  int64_t MOD = 1e9+7;
  for(int i=N*M; i>0; i--){
    int n1, n2, m1, m2;
    pos = lower_bound(A.begin(),A.end(),i);
    n1 = distance(A.begin(),pos);
    pos = upper_bound(A.begin(),A.end(),i);
    n2 = distance(A.begin(),pos);
    pos = lower_bound(B.begin(),B.end(),i);
    m1 = distance(B.begin(),pos);
    pos = upper_bound(B.begin(),B.end(),i);
    m2 = distance(B.begin(),pos);
    int n = N - n1;
    int m = M - m1;
    if(n2 - n1 > 1 || m2 - m1 > 1){
      ans = 0;
    }
    else if(n2 - n1 == 1 && m2 - m1 == 1){
      ans *= 1;
    }
    else if(n2 - n1 == 1){
      ans *= M - m1;
    }
    else if(m2 - m1 == 1){
      ans *= N - n1;
    }
    else{
      ans *= n*m - (N*M-i);
    }
    //cout << ans << endl;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <xmmintrin.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vecint a(n), b(n);
  REP(i,n) cin>>a[i];
  REP(i,n) cin>>b[i];
  int res = 0;
  for (int i = 28; i >= 0; --i) {
    sort(ALL(b));
    ll cnt = 0;
    REP(j,n) {
      auto itr1 = lower_bound(ALL(b), (1 << i) - a[j]);
      auto itr2 = lower_bound(ALL(b), 2 * (1 << i) - a[j]);
      auto itr3 = lower_bound(ALL(b), 3 * (1 << i) - a[j]);
      auto itr4 = lower_bound(ALL(b), 4 * (1 << i) - a[j]);
      cnt += distance(itr1, itr2) + distance(itr3, itr4);
    }
    res |= (cnt % 2) << i;
    REP(j,n) {
      a[j] &= ~(1<<i);
      b[j] &= ~(1<<i);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h> 
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long 
#define LL long long 
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
using namespace std;
const int MAXN = 1e6 + 10, mod = 1e9 + 7, INF = 1e9 + 10;
const double eps = 1e-9;
template <typename A, typename B> inline bool chmin(A &a, B b){if(a > b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline bool chmax(A &a, B b){if(a < b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline LL add(A x, B y) {if(x + y < 0) return x + y + mod; return x + y >= mod ? x + y - mod : x + y;}
template <typename A, typename B> inline void add2(A &x, B y) {if(x + y < 0) x = x + y + mod; else x = (x + y >= mod ? x + y - mod : x + y);}
template <typename A, typename B> inline LL mul(A x, B y) {return 1ll * x * y % mod;}
template <typename A, typename B> inline void mul2(A &x, B y) {x = (1ll * x * y % mod + mod) % mod;}
template <typename A> inline void debug(A a){cout << a << '\n';}
template <typename A> inline LL sqr(A x){return 1ll * x * x;}
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, num[MAXN];
char s[MAXN];
signed main() {
	N = read();
	scanf("%s", s + 1);
	for(int i = 1; i <= N; i++) num[s[i] - 'a']++;
	int ans = 1;
	for(int i = 0; i < 26; i++) if(num[i]) mul2(ans, add(num[i], 1));
	cout << (ans - 1 + mod) % mod;
	return 0;
}
/*
3
aba
*/

Measured memory_bytes: 384
N = input()
T,A = map(int,raw_input().split(' '))
for i in xrange(N-1):
    t,a = map(int,raw_input().split(' '))
    s1 = T/t
    if T%t != 0:
        s1+=1
    s2 = A/a
    if A%a != 0:
        s2+=1
    s = max(s1,s2)
    T = s*t
    A = s*a
print T+A

Measured memory_bytes: 2568
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//const int mod = 1000000007;
int main() {
    int x,a;
    cin >> x >> a;
    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;
}

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

int main(){
  int num_b;
  int num_r;
  
  int count;
  
  int max=0;
  string max_string;
  
  cin>>num_b;
  string blue[num_b];
  for(int i=0;i<num_b;i++) cin >> blue[i];
  cin>>num_r;
  string red[num_r];
  for(int i=0;i<num_r;i++) cin >> red[i];
  
  for(int i=0;i<num_b;i++){
    count=0;
    for(int j=0;j<num_b;j++){
      if(blue[i]==blue[j]) count++;
    }
    for(int k=0;k<num_r;k++){
      if(blue[i]==red[k]) count--;
    }
    if(count>=max) max=count;
  }
  cout<<max<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n,i;
	scanf("%d",&n);
	long long a[87];
	a[0]=2;
	a[1]=1;
	for(i=2;i<=n;i++){
		a[i]=a[i-2]+a[i-1];
	}
	printf("%lld",a[n]);
	return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	vector<ll> arr(n, 0);
	f(i, 0, n)
	{
		cin >> arr[i];
	}
	string flag = "Yes";
	rf(i, n - 2, 0)
	{
		if (arr[i] > arr[i + 1] + 1)
		{
			flag = "No";
			break;
		}
		else if(arr[i]==arr[i+1]+1)
			arr[i] -= 1;
	}
	cout << flag << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int w,h;
int c[55][55];
int dx[8]={1,1,1,-1,-1,-1,0,0};
int dy[8]={1,-1,0,1,-1,0,1,-1};
void dfs(int i,int j){
  c[j][i]=0;
  for(int k=0;k<8;k++){
    int nx = i + dx[k], ny = j + dy[k];
    if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
    if(c[ny][nx]==1) dfs(nx,ny);
  }
}
int main(){
  while(1){
    cin>>w>>h;
    if(w==0 && h==0) break;
    int cnt=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>c[i][j];
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(c[i][j]==1){
	  cnt++;
	  dfs(j,i);
	}
      }
    }

    cout<<cnt<<endl;
  }

  return 0;

    
      
}



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

int n, k, x;

int main() {
	int ans = 0;
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &x);
		if(x >= k) ++ans;
 	}
 	printf("%d\n", ans);
}

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

typedef long long ll;

int main(){
        int n,k;
        cin>>n>>k;
        vector<int>h(n);
        ll sum=0;
        for(int i=0;i<n;i++){
                cin>>h[i];
                sum+=h[i];
        }
        sort(h.begin(),h.end());
        for(int i=n-1;i>=0&&k>0&&sum>0;i--){
                sum-=h[i];
                k--;
        }
        cout<<sum<<endl;
        return 0;
}


Measured memory_bytes: 1024
# 整数の入力
#a = gets.to_i
# スペース区切りの整数の入力
#b,c=gets.chomp.split(" ").map(&:to_i);
# 文字列の入力
#s = gets.chomp
# 出力
#print("#{a+b+c} #{s}\n")

#桁ごと chars 

#for num in 1..3 do
#  print("num = ", num, "¥n")
#end

#upto
#
#


a,b=gets.chomp.split(" ").map(&:to_i);

print a*b

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


int main() {
  int n,k,i,j;
  cin >> n >> k;
  vector<int> nusuke(n,0);vector<int> d(k);
  for(i=0;i<k;i++){
    cin >> d.at(i);
    for(j=0;j<d.at(i);j++){
      int a;
      cin >> a;
      nusuke.at(a-1)++;
    }
  }
  int ans=0;
  for(i=0;i<n;i++){
    if(nusuke.at(i)==0){
      ans++;
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

char S[4];
string s, ans;

int main() {
    scanf("%s", S);
    s = S;
    
    if (( s[0] == s[1] ) or ( s[1] == s[2] ) or ( s[2] == s[3] )) {
        ans = "Bad";
    } else {
        ans = "Good";
    }

    printf("%s\n", ans.c_str());
    return 0;
}


Measured memory_bytes: 256
import Data.Ratio
import Data.List

main = do
  k <- readLn :: IO Int

  mapM_ print $ take k $ snuke

  where
    snuke = [1..9] ++ (snuke' 10)
    snuke' :: Integer -> [Integer]
    snuke' n = x : (snuke' (x+1))
      where
        x = minimumBy (\a b -> compare (f a) (f b)) $ map (\d -> 10^(d+1) * floor((fromIntegral n) % (10^(d+1)) + 1) - 1) [0..(ceiling (logBase 10 (fromIntegral n)) + 1)]
        
    s n
      | n <= 9 = n
      | otherwise = (mod n 10) + s (div n 10)
    f n = (fromIntegral n) / (fromIntegral $ s n)


Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  long long r, D, x;
  cin >> r >> D >> x;
  for (int i = 0; i < 10; i++) {
    x = r * x - D;
    cout << x << endl;
  }
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

struct edge{
    int to;
    int length;
};

void dfs(int v, int d, vector<vector<edge>>& G, vector<bool>& black, vector<bool>& visited){
    visited[v] = true;
    black[v] = d%2;
    for(auto e: G[v]){
        if(!visited[e.to]) dfs(e.to, d+e.length, G, black, visited);
    }
}

int main()
{
    int N;
    cin >> N;
    vector<vector<edge>> G(N);
    REP(i, N-1){
        int u, v, w;
        cin >> u >> v >> w;
        --u, --v;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }

    vector<bool> black(N, false);
    vector<bool> visited(N, false);
    dfs(0, 0, G, black, visited);

    REP(i, N){
        if(black[i]) cout << 1 << endl;
        else cout << 0 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 9472
#include <iomanip>
#include <string>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;
int main() {
	string s;
	cin >> s;
	long long int n = s.size(), a = 0, b = 0, c = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'a')a++;
		if (s[i] == 'b')b++;
		if (s[i] == 'c')c++;
	}
	if (n % 3 == 0) {
		if (a == b&&a == c) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	if (n % 3 == 1) {
		if ((a == b&&a == c - 1) || (a == c&&a == b - 1) || (c == b&&c == a - 1)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	if (n % 3 == 2) {
		if ((a == b&&a == c + 1) || (a == c&&a == b + 1) || (c == b&&c == a + 1)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
	int n,k,a,i,s=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<k;i++){
		scanf("%d",&a);
		s+=a;
	}
	k=0,++n;
	if(s%n!=0)k=1;
	k+=(s/n);
	printf("%d\n",k);
	return 0;
}


Measured memory_bytes: 2052
#include <iostream>


int main()
{
	int N = 0;

	std::cin >> N;

	if (N < 1 || N>9)
	{
		std::cout << "0" << std::endl;

		return -1;
	}

	int num = 0;
	for (int i = 1; i <= N; ++i)
	{
		for (int j = 1; j <= N; ++j)
		{
			for (int k = 1; k <= N; ++k)
			{
				num++;
			}
		}
	}

	std::cout << num << std::endl;

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  vector<bool> app(26);
  rep(i, s.size()) app[s[i] - 'a'] = true;
  rep(i, 26) if(!app[i]) {
    printf("%c\n", char(i + 'a'));
    return 0;
  }
  
  printf("None\n");
  return 0;
}

Measured memory_bytes: 3824