akhauriyash/Code-Regression huggingface dataset:
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    if N%1000 == 0:
        return 0
    return 1000-N%1000


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


Measured memory_bytes: 61692
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;

#define LL long long

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int INF=9999999;
const int MAXN=100000;

int N;
char str1[MAXN+1],str2[MAXN+1];
int cot[MAXN+1];
int cnt; int ans;

int main(){
    N=read();
    for(cnt=1;cnt<=N;cnt++){
    	cot[cnt]=cot[cnt-1]+2;
    	if(cot[cnt]>N-1) break;
	} 
    puts("0");
    cin>>str1;
    printf("%d\n",N-1);
    cin>>str2;
    int L=1,R=cnt-1;
    while(L<=R){
    	int mid=(L+R)>>1;
    	printf("%d\n",N-cot[mid]);
    	cin>>str1;
    	if(str1[0]==str2[0]){
    		ans=N-cot[mid],R=mid-1;
		}
		else L=mid+1;
		if(str1[0]=='V') break;
	}
	printf("%d\n",ans+1);
	return 0;
}


Measured memory_bytes: 1108
def main():
    from builtins import int, map, list, print
    import sys

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: map(int,input().rstrip().split()))
    input_number_list = (lambda: list(map(int, input_list())))

    N, M, C = input_number()
    B = input_number_list()
    A = [None] * N
    for i in range(N):
        A[i] = input_number_list()
    ans = 0
    for i in range(N):
        t = C
        for j in range(M):
            t += A[i][j] * B[j]
        ans += t > 0 and 1 or 0
    print(ans)


def resolve():
    main()


if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3064
#! /usr/bin/env python3

import sys

get = sys.stdin.read().split('\n')

for g in get:
	nums = list(map(int, g.split()))
	output = ''
	if (nums != []):
		# print(nums)
		[a, b] = nums
		while ((a != 0) and (b != 0)):
			larger = max([a, b])
			smaller = min([a, b])
			a = larger - smaller 
			b = smaller
		output += str(max([a, b])) + ' ' + str((nums[0]*nums[1])//max([a,b]))
		print(output)

Measured memory_bytes: 7516
//kokokara
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll>> pqls;
priority_queue <P,vector<P>,greater<P>> pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans;
ll a,b,d,e,f,g,h,w;
 
ll x[800005],y[800005],z[900005];
char s[500005];

int main(){
    cin>>n;
	for(i=0;i<30;i++){
		for(j=0;j<30;j++){
			if(i*4+j*7==n){
				p("Yes");
				return 0;
			}
		}
	}
	p("No");
	return 0;

	


}

Measured memory_bytes: 6528
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;

int main()
{
	int A,B;
	cin >> A >> B;

	if (A / 10 == 0 && B / 10 == 0)
	{
		cout << A*B;
	}
	else
	{
		cout << -1;
	}
	
}


Measured memory_bytes: 3608
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def divider(a):
    res = set()
    for i in range(1,int(a**0.5)+1):
        if a%i == 0:
            res.add(i)
            res.add(a//i)
    res = list(res)
    res.sort()
    return res


def main():
    """ main """
    A,B,K = map(int, input().split())
    arr = divider(gcd(A,B))
    print(arr[-K])

if __name__ == '__main__':
    main()

Measured memory_bytes: 4080
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <time.h>
#define nmax_def 1100
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;
typedef long long ll;

clock_t time_ini = clock();

double time_diff()
{
	ll time_tmp = clock();
	const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
	return time;
}

int main() {
	int i, j;
	int N;
	int ans = 0;
	cin >> N;
	int A[nmax_def][nmax_def];
	int Acomp[nmax_def];
	time_ini = clock();
	rep(i, N) {
		rep(j, N - 1) {
			int Atmp;
			cin >> Atmp;
			A[i][j] = Atmp - 1;
		}
		Acomp[i] = 0;
	}
	while (1) {
		ans++;
		bool comp = true;
		vector<pair<int, int>> Acan;
		rep(i, N) {
			if (Acomp[i] != N - 1) {
				int Anext = A[i][Acomp[i]];
				pair<int, int> AtoA;
				AtoA.first = i;
				AtoA.second = Anext;
				if (i < Anext)
					swap(AtoA.first, AtoA.second);
				//cout << i << endl;
				Acan.push_back(AtoA);
			}
		}
		sort(Acan.begin(), Acan.end(), greater <pair<int, int>>());
		bool Aany = false;
		rep(i, Acan.size() - 1) {
			if (Acan[i + 1] == Acan[i]) {
				Acomp[Acan[i].first]++;
				Acomp[Acan[i].second]++;
				Aany = true;
			}
		}
		if (!Aany)
		{
			ans = -1;
			break;
		}
		rep(i, N) {
			if (Acomp[i] != N - 1)
				comp = false;
		}
		if (comp)
			break;
		if (time_diff() > 1990) {
			ans = N * (N-1) / 2;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4736
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = 3 * r * r;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

struct Edge {
	int from, to;
	ll w;
};
typedef vector<vector<Edge>> Graph;

signed main(void) {
	int n;
	cin >> n;
	int c[100001][3];

	REP(i, n) {
		cin >> c[i][0] >> c[i][1] >> c[i][2];
	}

	int dp[100001][3] = {};

	REP(i, n) {
		REP(j, 3) {
			REP(k, 3) {
				if(j != k)
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + c[i][j]);
			}
		}
	}

	cout << max({ dp[n][0], dp[n][1], dp[n][2] }) << endl;
	return 0;
}



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

int main(){
	long long N, T;
	cin >> N >> T;
	long long ans = 0;
	long long cur;
	long long next;

	cin >> cur;
	for(long long i = 1; i < N; i++){
		cin >> next;
		if(next - cur < T){
			ans += next - cur;
		}else{
			ans += T;
		}
		swap(cur, next);
	}
	ans += T;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>

int main() {
    std::string o, e;
    std::cin >> o >> e;

    int j = 0, k = 0;
    for (int i = 0; i < o.size() + e.size(); i++)
    {
        if(i%2 == 0) {
            std::cout << o[k];
            k++;
        }
        else
        {
            std::cout << e[j];
            j++;
        }
    }

    std::cout << "\n";
}

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

typedef unsigned uint;

bool is_exist_bin_search(uint v, std::vector<uint> s){
  uint min = 0, max = s.size();
  while(min < max){
    uint mid = (min + max) / 2;
    uint v_mid = s[mid];
    if(v_mid == v) return true;

    if(v_mid >= v) max = mid;
    else min = mid+1;
  }
  return false;
}

unsigned count(std::vector<uint> s, std::vector<uint> t){
  uint n = 0;
  for(uint i = 0; i < t.size(); i++){
    if(is_exist_bin_search(t[i],s)) n++;
  }
  return n;
}

int main(){
  std::ios_base::sync_with_stdio(false);

  uint n;
  std::cin >> n;
  std::vector<uint> s(n,0);
  for(uint i = 0; i < n; i++){
    std::cin >> s[i];
  }
  s.erase(std::unique(s.begin(),s.end()),s.end());

  uint q;
  std::cin >> q;
  std::vector<uint> t(q,0);
  for(uint i = 0; i < q; i++){
    std::cin >> t[i];
  }

  std::cout << count(s,t) << '\n';
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CHonestOrUnkind2 {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin >> n;

        vector<vector<P>> g(n);
        REP(i, n) {
            int a;
            cin >> a;
            REP(j, a) {
                int x, y;
                cin >> x >> y;
                x--;
                g[i].push_back({x, y});
            }
        }

        int res = 0;
        REP(i, 1 << n) {
            vector<int> s(n, -1);

            int ok = true;
            REP(j, n) {
                if ((i >> j & 1) == 0) continue;
                for(auto kv : g[j]) {
                    if (s[kv.first] != -1 && s[kv.first] != kv.second) {
                        ok = false;
                        break;
                    }
                    s[kv.first] = kv.second;
                }
            }
            if (!ok) continue;

            ok = true;
            REP(j, n) {
                if (s[j] == -1) continue;
                int v = (i >> j & 1);
                if (v != s[j]) {
                    ok = false;
                    break;
                }
            }
            if (!ok) continue;

            int tmp = 0;
            REP(j, n) {
                if (i >> j & 1) tmp++;
            }
            res = max(res, tmp);
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CHonestOrUnkind2 solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

vector<pair<long long, long long>> prime_factorize(long long n)
{
    vector<pair<long long, long long>> res;
    for (long long p = 2; p * p <= n; ++p)
    {
        if (n % p != 0)
            continue;
        int num = 0;
        while (n % p == 0)
        {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1)
        res.push_back(make_pair(n, 1));
    return res;
}

int main(){
    long long A, B, R, ans = 1;
    cin >> A >> B;
    if (A < B)
        swap(A, B);
    R = A % B;
    while(R != 0){
        A = B;
        B = R;
        R = A % B;
    }

    auto f = prime_factorize(B);
    cout << f.size() + 1 << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	fmt.Println(min(solve(a, 0), solve(a, 1)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func solve(a []int, ra int) int {
	var s, ans int

	for i, v := range a {
		if i%2 == ra {
			if s+v >= 0 {
				ans += abs(-1 - s - v)
				s = -1
				continue
			}
		} else {
			if s+v <= 0 {
				ans += abs(1 - s - v)
				s = 1
				continue
			}
		}
		s += v
	}
	return ans
}

func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}


Measured memory_bytes: 6308
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    for i in range(n+1):
        if n <= i * (i + 1) // 2:
            tmp = []
            for i in range(i, 0, -1):
                if n >= i:
                    n -= i
                    tmp.append(str(i))
            tmp.sort()
            print("\n".join(tmp))
            return
    return


#main
if __name__ == '__main__':
    solve()


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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    int A,B; cin >> A>>B;

    if (A%2!=B%2) cout<<"IMPOSSIBLE"<<endl;
    else cout<<(A+B)/2<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
a = readInts()

a.sort(reverse=True)

if n==1:
	print(math.ceil(a[0]/(k+1)))
	exit()

def get(left, right):
	l = (right-left)//2+left
	ans = 0
	for i in a:
		ans+=math.ceil(i/l)-1
	#print(l, ans, left, right)
	return ans,l

def nibu(left,right):
	ans,l = get(left, right)

	if left<right:
		if ans<=k:
			return nibu(left,l)
		else:
			return nibu(l+1, right)
	else:
		return right


print(nibu(1,a[0]))


Measured memory_bytes: 31980
import java.util.Scanner;

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

        // Grab the row and col data
        int rows = input.nextInt();
        int cols = input.nextInt();

        // build the matrix and add 1 to the cols and rows for the result matrix
        int[][] result = new int[rows +1][cols+1];

        // Create the storage contains for the running total
        int[] colTot = new int[cols]; // only column totals are needed since row totals can be done while read in
        int total = 0;

        // Compute totals in line
        for(int row = 0; row < rows+1; row++) {
            int rowTemp = 0;
            for(int col = 0; col < cols+1; col++){
                // nested if-else structure that handles the three border cases:
                // 1 - on the end of the row
                // 2 - at the bottom of a column
                // 3 - at the bottom right hand corner of the matrix
                // These cases need special handling otherwise grab the next entry from the input and calculate the
                // appropriate values
                if(col == cols && row == rows){
                   result[row][col] = total;
                } else if(col == cols){
                   result[row][col] = rowTemp;
                } else if(row == rows) {
                   result[row][col] = colTot[col];
                } else {
                   // Compute the rest of the values
                   int temp = input.nextInt();
                   total += temp;
                   rowTemp += temp;
                   colTot[col] += temp;
                   result[row][col] = temp;
                }
            }
        }
        // display output
        showSheet(result);

    }

    private static void showSheet(int[][] result){
        for(int i = 0; i < result.length; i++){
            for(int j = 0; j < result[0].length; j++){
                System.out.print(result[i][j]);
                if( j < result[0].length - 1) System.out.print(" ");
            }
 System.out.print("\n");
        }
    }
}



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

int n;
vector<int> a;

void solve() {
  int i;
  if (n % 2 == 0) {

    for (i = n - 1; i >= 1; i -= 2) {
      cout << a[i] << " ";
    }

    for (i = 0; i <= n - 2; i += 2) {
      cout << a[i];
      if (i != n - 2) {
        cout << " ";
      } else {
        cout << "\n";
      }
    }
  } else {

    for (i = n - 1; i >= 0; i -= 2) {
      cout << a[i] << " ";
    }

    for (i = 1; i <= n - 2; i += 2) {
      cout << a[i];
      if (i != n - 2) {
        cout << " ";
      } else {
        cout << "\n";
      }
    }
  }

  return;
}

int main() {
  int i;

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

  solve();

  return 0;
}

Measured memory_bytes: 2944
<?php
/*
    http://arc062.contest.atcoder.jp/tasks/arc062_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%s", $s);
// echo $s . PHP_EOL;
$countG = substr_count($s, "g");
$countP = strlen($s) - $countG;
// echo "{$countG} {$countP}\n";
echo floor(($countG - $countP) / 2) . PHP_EOL;


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
// << left shift *2 and >>right shift /2
long long int mod97=1000000007;
double pi=3.1415926536;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}

void solve()
{
    long long int n,c;cin>>n>>c;
    long long int w[n],v[n];
    for(long long int i=0;i<n;i++)cin>>w[i]>>v[i];
    
    long long int dp[n][c+1];
    for(long long int i=0;i<n;i++)
    {
        for(long long int j=0;j<=c;j++)
        {
            dp[i][j]=0;
        }
    }
    dp[0][c]=0;
    if(w[0]<=c)
    dp[0][w[0]]=v[0];

    for(long long int i=1;i<n;i++)
    {
        for(long long int j=0;j<=c;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(w[i]<=j)
            dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
        }
    }
    
    long long int ans=INT_MIN;
    for(long long int i=0;i<=c;i++)ans=max(ans,dp[n-1][i]);
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;
    //cin>>t;long long int temp=t;
    while(t--)
    {
        //cout<<"Case "<<temp-t<<": ";
        solve();
    }
}


Measured memory_bytes: 81736
#include<bits//stdc++.h>
using namespace std;
int main(){
  int n,m,k;string s,t;cin >> n;
  vector<int> v(4,0);
  for(int i = 0; i<n;i++){
    cin >> s;
    if(s == "AC") v[0]++;
    else if(s=="WA") v[1]++;
    else if(s=="TLE") v[2]++;
    else v[3]++;
  }
  cout << "AC x "<<v[0]<<endl;
  cout << "WA x "<<v[1]<<endl;
  cout << "TLE x " << v[2] << endl;
  cout << "RE x " << v[3] << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    int n, m, a, b;
    cin >> n >> m;
    vector<int> ans(n,0);
    rep(i, m){
        cin >> a >> b;
        ans[a-1]++;
        ans[b-1]++;
    }
    rep(i,n)cout << ans.at(i) << endl;
}

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

int main(){
  int n,s=0;
  cin >> n;
  vector<int> a(n),b(n-1);
  for(int i=0;i<n-1;i++)
    cin >> b[i];
  a[0]=b[0];
  a[n-1]=b[n-2];
  for(int i=0;i<n-2;i++){
  	if(b[i+1]>=b[i])
      a[i+1]=b[i];
    else
      a[i+1]=b[i+1];
  }
  for(int i=0;i<n;i++)
    s+=a[i];
  cout << s;
}

Measured memory_bytes: 256
import java.util.*;

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

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double x = sc.nextDouble();

		double tri = (a * a * b) / 2; 
		double degree = 0;

		if(x > tri){
			degree = Math.toDegrees(Math.atan(((2 * a * a * b) - (2 * x))/(a*a*a)));
		}
		else{
			degree = Math.toDegrees(Math.atan( (a * b * b)/(2 * x) ));
		}
		System.out.println(degree);
	}
}

Measured memory_bytes: 24660
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>
#include <map>
#include <assert.h>

using namespace std;

#define endl '\n'

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

    int n; cin >> n;

    map<string,int> freq;

    int m = 0;

    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        m = max(m, ++freq[s]);
    }

    vector<string> ans;

    for (auto x : freq)
        if (x.second == m)
            ans.push_back(x.first);

    sort(ans.begin(), ans.end());
    for (auto x : ans)
        cout << x << endl;

    return 0;
}

Measured memory_bytes: 23536
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [0] * (W + 1)
    for i in range(N):
        for j in range(W, -1, -1):
            if j + w[i] <= W:
                dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i])
    ret = max(dp)
    print(ret)
    return


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
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]" 
    v = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()


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

#include <iostream>
#include <string>
using namespace std;

int main(int argc, char* argv[]){
	int N;
	cin >> N;

	int r = N%10;

	if(r==2 || r == 4 || r == 5 | r == 7 | r == 9){
		cout << "hon" << endl ;
	}
	else if(r==0 || r == 1 || r == 6 | r == 8){
		cout << "pon" << endl ;
	}
	else if (r==3){
		cout << "bon" << endl ;
	}
	return 0;
}

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

using namespace std;

struct Sum {
    int sum;
    vector<int> pos;
};




int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> C(h, vector<int>(w, 0));
    vector<Sum> rowSum(h), colSum(w);
    vector<Sum> rowSumCpy(h), colSumCpy(w);
    char x;
    int total = 0;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> x;
            if (x == '.') { C.at(i).at(j) = 0; }
            else {
                C.at(i).at(j) = 1;
                total++;
                rowSum.at(i).sum++;
                rowSum.at(i).pos.push_back(j);
                colSum.at(j).sum++;
                colSum.at(j).pos.push_back(i);
            }
            //cout << C.at(i).at(j) << " ";
        }
        //cout << endl;
    }



    int all = 1 << (h+w);
    int row, col, dup, ans=0;
    int totCpy;
    for (int i = 0; i < all; i++) {
        totCpy = total;
        copy(rowSum.begin(), rowSum.end(), rowSumCpy.begin());
        copy(colSum.begin(), colSum.end(), colSumCpy.begin());
        for (int j = 0; j < (h + w); j++) {
            if ((i >> j) & 1 == 1) {
                if (j < h) {
                    totCpy -= rowSumCpy.at(j).sum;
                    for (int m = 0; m < rowSumCpy.at(j).pos.size(); m++) {
                        dup = rowSumCpy.at(j).pos.at(m);
                        colSumCpy.at(dup).sum--;
                    }
                }
                else {
                    totCpy -= colSumCpy.at(j-h).sum;
                }

            }
        }
        if (totCpy == k) { ans++; }
    }

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


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define pai 3.14159265
using namespace std;

int main(void){
    vector<int>X(26,0);
    string S;cin>>S;
    for(int i=0;i<S.size();i++){
        X[S[i]-'97']++;
        if(X[S[i]-'97']>1){
            cout<<"no"<<endl;
            return 0;
        }
    }
    cout<<"yes"<<endl;
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string s;
  	cin >> s;
	string temp = "hi";
  	rep(i,5){
      	if(s==temp){
        	cout << "Yes" << endl;
			return;
        }
      	temp += "hi";
    }
 	cout << "No" << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
INF = 1<<29

def dfs(v, f)
  return f if v == $goal
  $used[v] = true
  $g[v].each do |u, c|
    if !$used[u] && c > 0
      d = dfs(u, [f, c].min)
      if d > 0
        $g[v][u] -= d
        $g[u][v] += d
        return d
      end
    end
  end
  0
end

def max_flow(size)
  flow = 0
  loop do
    $used =  [false] * size
    f = dfs($start, INF)
    return flow if f == 0
    flow += f
  end
end

v, e = gets.split.map(&:to_i)
$g = v.times.map { {} }
$start = 0
$goal = v - 1

e.times do
  s, t, c = gets.split.map(&:to_i)
  $g[s][t] = c
  $g[t][s] = 0
end

p max_flow(v)

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

int main(){
string S,f,e;
int n,len;
cin>>S;
f = S[0];
len = S.size();
e = S[len-1];
n = len - 2;
string ns;
ns = to_string(n);
cout<<f + ns + e<<endl;
return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <inttypes.h>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template<typename T>
void chmin(T& x, T y) {
	x = min(x, y);
}

template<typename T>
void chmax(T& x, T y) {
	x = max(x, y);
}

ll csum(ll x, ll y) {
	if (x > 0 && y > 0 && x > LL_MAX - y) {
		return LL_MAX;
	}
	if (x < 0 && y < 0 && x < LL_MIN - y) {
		return LL_MIN;
	}
	return x + y;
}

ll readl() {
	ll ret;
	scanf("%" PRId64 "", &ret);
	return ret;
}

vector<ll> readvl(ll n) {
	vector<ll> ret(n);
	rep(i, 0, n) { ret[i] = readl(); }
	return ret;
}

void writel(ll x) {
	printf("%" PRId64 "\n", x);
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N = readl(), K = readl();
    auto As = readvl(N);
    rep(i,0,N) {
        As[i]--;
    }
    auto doubling = make_vec_nd((ll)-1, 63, N); // doubling[i][j] = jからスタートして2^i回移動したときの位置
    doubling[0] = As;
    rep(i,1,63) {
        rep(j,0,N) {
            doubling[i][j] = doubling[i-1][doubling[i-1][j]];
        }
    }
    vector<ll> ans(N);
    rep(j,0,N) {
        ll pos = j;
        rep(i,0,63) {
            if (((ull)1 << i) & K) {
                pos = doubling[i][pos];
            }
        }
        ans[j] = pos;
    }
    writel(ans[0] + 1);
}


Measured memory_bytes: 104484
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m, f, r;
    while(cin>>m>>f>>r) {
        if(m==-1 && f==-1 && r==-1) break;
        if(m==-1 || f==-1) cout<<"F\n";
        else if(m+f>=80) cout<<"A\n";
        else if(m+f>=65) cout<<"B\n";
        else if(m+f>=50) cout<<"C\n";
        else if(m+f<30) cout<<"F\n";
        else if(r>=50) cout<<"C\n";
        else cout<<"D\n";
    }
    return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];

    vector<int> dist(101);
    rep(i,101) dist[i] = i*i;

    int ans = 1e9;
    rep(i,101){
        int now = 0;
        rep(j,n){
            now += dist[abs(x[j]-i)];
        }
        ans = min(now,ans);
    }

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

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

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private int N;
        private int[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = sc.IntArray();
        }

        public void Solve()
        {
            Scan();
            Console.WriteLine(A.Min(Cnt));
        }
        private int Cnt(int n)
        {
            for (int i = 0; i <= 31; i++)
            {
                if (n % 2 == 1)
                {
                    return i;
                }
                n /= 2;
            }
            return -1;
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<','<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

int n, k;
vector<int> a;

bool ok(double x) {
    int k_ = k;
    int k0;
    for (int d : a) {
        k0 = ceil(d / x) - 1;
        if (round(d / (k0 + 1)) > x) {
            k0++;
        }
        k_ -= k0;
    }
    return k_ >= 0;
}

// search by a predicate
// search invariant: ans in [l, r], i.e. both inclusive
// returns min x : a[x] == true
// predicate is first false, then true (like std::greater)
int binsearch(int l, int r) {
    while (l < r) {
        int m = l + (r - l) / 2;
        if (ok(m)) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    return ok(l) ? l : -1;
}

signed main() {    
    cin >> n >> k;
    a.assign(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    cout << binsearch(1, 1000000001) << endl;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[200];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	int ans = 40;
	inc(i, n) {
		int c = 0;
		while(a[i] % 2 == 0) { a[i] /= 2; c++; }
		setmin(ans, c);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int solve(int n,int m){
    vector<int> c(m);
    rep(i,m)cin>>c[i];
    vector<int> x(n+1,0);
    rep1(i,n)cin>>x[i];
    vector<vector<int>> dp(n+1,vector<int>(256,inf));
    dp[0][128]=0;
    rep1(i,n){
        rep(j,256){
            rep(k,m){
                int buf=j+c[k];
                buf=min(255,buf);buf=max(0,buf);
                int S=(buf-x[i])*(buf-x[i]);
                dp[i][buf]=min(dp[i][buf],S+dp[i-1][j]);
            }
        }
    }
    int res=inf;
    rep(i,256){
        res=min(res,dp[n][i]);
    }
    return res;
}
signed main(){
    vector<int> res;
    while(1){
        int n,m;cin>>n>>m;
        if(n==0&&m==0)break;
        res.push_back(solve(n,m));
    }
    for(auto& val:res){
        cout<<val<<endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int numa[252521], numb[252521];
int rana[252521][2], ranb[252521][2];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, a[252521], b[252521];
  cin>>n;
  REP(i, n){
    cin>>a[i];
    ++numa[a[i]];
  }
  REP(i, n){
    cin>>b[i];
    ++numb[b[i]];
  }
  FOR(i, 1, n+1){
    if(numa[i]>n-numb[i]){
      cout<<"No"<<'\n';
      return 0;
    }
  }
  FOR(i, 1, n+1){
    rana[i][0]=rana[i][1]=-1;
    ranb[i][0]=ranb[i][1]=-1;
  }
  REP(i, n){
    if(rana[a[i]][0]==-1){
      rana[a[i]][0]=i;
      rana[a[i]][1]=i;
    }
    else{
      rana[a[i]][1]=i;
    }
  }
  REP(i, n){
    if(ranb[b[i]][0]==-1){
      ranb[b[i]][0]=i;
      ranb[b[i]][1]=i;
    }
    else{
      ranb[b[i]][1]=i;
    }
  }
  int ma=0;
  REP(i, n){
    if(!numb[a[i]]){
      continue;
    }
    if(ranb[a[i]][0]<=rana[a[i]][1]){
      CHMAX(ma, rana[a[i]][1]-ranb[a[i]][0]+1);
      // DEBUG(rana[a[i]][1]-ranb[a[i]][0]);
    }
  }
  int ans[252521];
  REP(i, n-ma){
    ans[i+ma]=b[i];
  }
  FOR(i, n-ma, n){
    ans[i-(n-ma)]=b[i];
  }
  cout<<"Yes"<<'\n';
  REP(i, n){
    cout<<ans[i]<<" \n"[i==n-1];
  }
  return 0;
}


Measured memory_bytes: 10628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  int lim;
  lim = a < b ? a : b;
  int cnt = 0;
  for(int i=lim; i>0; i--){
  	if( a%i == 0 && b%i == 0 ){
    	cnt++;
      	if(cnt == k){
        	cout << i << endl;
	        break;
        }
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
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; }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    vector<int> A(N-1);
    vector<int> ans(N);
    rep(i,N-1) {
        cin >> A[i];
        A[i]--;
        ans[A[i]]++;
    }

    rep(i,N){
        cout << ans[i] << endl;
    }



}


Measured memory_bytes: 4788
N,M = map(int,input().split())
L,R = map(int,input().split())
pos = True
for i in range(M-1):
    L_,R_ = map(int,input().split())
    if R < L_ or R_ < L:
        pos = False
    L = max(L,L_)
    R = min(R,R_)
if pos:
    print(R-L+1)
else:
    print(0)

Measured memory_bytes: 50024
c=[list(map(int, input().split())) for _ in range(3)]
ans="Yes"
for i in range(2):
	for j in range(2):
		if c[i][j] - c[i+1][j] - c[i][j+1] + c[i+1][j+1] != 0:
			ans="No"
print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
typedef pair<int, int> P;
vector<P> G[100010];

int x[100010];

bool dfs(int v, int d) {
    //cout << x[v] << " " << d << endl;
    if (x[v] == -1)
        x[v] = d;
    else if(x[v] == d) return true;
    else return false;
    for(auto to: G[v]) {
        if (!dfs(to.first, d + to.second)) return false;
    }
    return true;
}
bool used[100010];
bool isloop(int v) {
    if(used[v]) return true;
    for(auto to: G[v]) {
        if (isloop(to.first)) return true;
    }
    return false;
}

int edge[100010];
int L[200010], R[200010], D[200010];
set<int> st;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        cin >> L[i] >> R[i] >> D[i];
        if (D[i] == 0) continue;
        L[i]--; R[i]--;
        st.insert(L[i]);
        st.insert(R[i]);
        edge[R[i]]++;
        G[L[i]].push_back({R[i], D[i]});
    }
    rep(i, N) x[i] = -1;
    bool isupdate = false;
    bool ischange = false;
    rep(i, N) {
        if(st.find(i) == st.end()) continue;
        ischange = true;
        if(edge[i] == 0) isupdate = true;
        if(edge[i] == 0 && !dfs(i, max(0, x[i]))) {
            cout << "No" << endl;
            return 0;
        }
    }
    if(!isupdate && ischange) {
        cout << "No" << endl;
    }else{
    
    cout << "Yes" << endl;
    }
    

    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	int N, ans=0;
	int P[20005], offset[20005];

	cin >> N;
	rep(i,N){
		cin >> P[i];
		P[i]--;
		offset[ P[i] ] = i;
	}
	vector<int> a, b;
	a.push_back( 1 );
	b.push_back( (int)1e9 );
	rep(i,N-1){
		int d = offset[i+1] - offset[i];
		int da, db;
		if( d < 0 ){
			da = 1;
			db = d - 1;
		}else if( d > 0 ){
			da = d + 1;
			db = -1;
		}
		a.push_back( a.back() + da );
		b.push_back( b.back() + db );
	}

	for(auto t: a) cout << t << " "; cout << endl;
	for(auto t: b) cout << t << " "; cout << endl;

	return 0;
}


Measured memory_bytes: 1024
import fractions
N = int(input())
A = [int(i) for i in input().split()]

mod = 10**9 + 7


lcm = 1
for a in A:
    lcm = lcm*a//fractions.gcd(lcm, a)
# print(lcm)

ans = 0
for a in A:
    ans += lcm//a
print(ans % mod)


Measured memory_bytes: 6112