akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define all(s) s.begin(), s.end()

const int N = (int)1e5 + 7;

int x[N];
int used[N];
int u[N];
int mx[N];
int ans;
vector < int > v[N];

main() {
    int n, m; scanf ("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf ("%d", x + i);
        u[x[i]]++;
        int y = x[i] % m;
        used[y]++;
    }
    for (int i = 1; i < N; i++) {
        if (u[i] != 0) v[i % m].pb(u[i]);
    }
    for (int i = 0; i < m; i++) {
        sort(all(v[i]));
    }
    if (m % 2 == 0) {
        ans = used[m / 2] / 2;
        used[m / 2] %= 2;
    }
    ans += used[0] / 2;
    used[0] %= 2;
    int l = 1, r = m - 1;
    while (l < r) {
        int mn = min(used[l], used[r]);
        ans += mn;
        used[l] -= mn;
        used[r] -= mn;
        l++; r--;
    }
    for (int i = 0; i < m; i++) {
        for (int j = (int)v[i].size() - 1; j >= 0; j--) {
            if (used[i] - v[i][j] <= 0) {
                v[i][j] = used[i];
                ans += v[i][j] / 2;
                break;
            }
            ans += v[i][j] / 2;
            used[i] -= v[i][j] / 2 * 2;
        }
    }
    cout << ans;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int cnt[200001];
int main(){
  int n,k,ans=0;
  cin>>n>>k;
  int a[200001];
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  int l=0;
  sort(a,a+n+1);
  for(int i=1;i<=n;i++){
    if(a[i]!=a[i-1])
      l++;
    else{
      cnt[l]++;
    }
  }
  int c=l;
  sort(cnt,cnt+l+1);

   if(c<=k){
     cout<<0<<endl;
   }
   else{
     for(int i=1;i<=c;i++){
      ans+=cnt[i]+1;
      l--;
      if(k>=l)
	break;
     }
     cout<<ans<<endl;
     } 
  return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0205

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        hands = [0] * 5
        hands[0] = int(input())
        if hands[0] == 0:
            break
        hands[1] = int(input())
        hands[2] = int(input())
        hands[3] = int(input())
        hands[4] = int(input())

        # ?????????????????????????????±???????????????
        if 1 in hands and 2 in hands and 3 in hands: #  ??¨????????????????????´???
            for _ in range(5):
                print(3)
        elif hands.count(hands[0]) == 5: #  ??¨????????????????????´???
            for _ in range(5):
                print(3)
        # ??????????????????????????±???????????????
        else:
            for h in hands:
                if (h+1 in hands) or (h==3 and 1 in hands):
                    print(1)
                else:
                    print(2)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7772
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val p = sc.nextInt()
    val s = sc.nextLine().toCharArray().map { it.toString().toInt() }.toList()
    var ans = 0L
    if (p == 2) {
        for (i in 0 until n) {
            if (s[i] % 2 == 0) {
                ans += i + 1
            }
        }
    } else if (p == 5) {
        for (i in 0 until n) {
            if (s[i] % 5 == 0) {
                ans += i + 1
            }
        }
    } else {
        val a = Array(n + 1) { 0 }
        var pow10 = 1
        for (i in n - 1 downTo 0) {
            a[i] = a[i + 1] + pow10 * s[i]
            a[i] %= p
            pow10 *= 10
            pow10 %= p
        }
        val map = mutableMapOf<Int, Int>()
        for (i in n downTo 0) {
            ans += map[a[i]] ?: 0
            map[a[i]] = (map[a[i]] ?: 0) + 1
        }
    }
    println(ans)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 57304
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
string names;
int h[101000][3];
int dp[100100][3];
int main() {
	int N = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> h[i][0] >> h[i][1] >> h[i][2];
	}
	dp[0][0] = h[0][0];
	dp[0][1] = h[0][1];
	dp[0][2] = h[0][2];
	for (int i = 1; i < N; i++) {
		
		for (int j = 0; j < 3; j++) {
			if (j == 0) {
				dp[i][j] += h[i][j] + max(dp[i - 1][1],dp[i - 1][2] );
			}
			else if(j == 1){ dp[i][j] = h[i][j] + max(dp[i - 1][0], dp[i - 1][2]); }
			else if (j == 2) {
				dp[i][j] = h[i][j] + max(dp[i - 1][0], dp[i - 1][1]);
			}
			
		}
		
	}
	cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2]))<<endl;
return 0;
}


Measured memory_bytes: 2560
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let xy = Array.init n @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun x y -> (x, y)

module IntMap = Map.Make(struct type t = (int * int) let compare = compare end)

let () =
  let map = Array.fold_left (fun m s -> Array.fold_left (fun m t -> 
    if s = t then m
    else
      let (x1, y1), (x2, y2) = s, t in
      let key = (x1 - x2, y1 - y2) in
      try 
        IntMap.add key ((IntMap.find key m) + 1) m
      with Not_found ->
        IntMap.add key 1 m
  ) m xy) IntMap.empty xy in
  Printf.printf "%d\n" @@ n - IntMap.fold (fun _ -> max) map 0
  

Measured memory_bytes: 2048
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

#for i in itertools.product([0,1], repeat=n)


n,k=mii()
arr=limii()
ans=10**100
aa=[]
for i in product([0,1], repeat=n):
    if sum(i)==k:

        tmp=0
        chk=0
        for j in range(n):
            if i[j]==1:
                if chk>=arr[j]:
                    tmp+=chk-arr[j]+1
                    chk+=1
                else:
                    chk=arr[j]
            if i[j]==0:
                chk=max(chk,arr[j])
        #print(tmp,i,arr)
        ans=min(tmp,ans)


print(ans)

Measured memory_bytes: 67944
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
unordered_set<int> ans;
void get_res(long long n){
  if (n == 1){
    return;
  }else{
    int flag = 0;
    for (long long i = 2; i * i <= n; i++){
      if(n % i == 0){
        ans.insert(i);
        flag ++;
        n /= i;
        break;
      }
    }
    if (flag){
    	get_res(n);
    } else {
      ans.insert(n);
    }
  }
}
int main(){
  long long a,b;
  cin >> a >> b;
  long long m,n;
  long long temp;
  if(a >= b){
    m = a;
    n = b;
  }else{
    m = b;
    n = a;
  }
  while(m % n){
    temp = m % n;
    m = n;
    n = temp;}
  if(n!=1){
    get_res(n);}
  cout << ans.size() +1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

int N; cin >> N ;

vector<int> A(N);
rep(i,N) cin>>A[i];

bool ans=true;

rep(i,N){
  if(A[i]%2==0){
    if(A[i]%3==0||A[i]%5==0) ans=ans;
    else ans=false;
  }
}

if(ans) cout << "APPROVED" << endl;

else cout << "DENIED" << endl;

return 0;

}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int a = 0;
  int b = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      a++;
    } else if (s[i] == 'B') {
      b++;
    }
  }
  if ((a == s.size()) || (b == s.size())) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main (String[] args)
	{
		Scanner sc = new Scanner (System.in);
		int nums = sc.nextInt();
		long[] arr = new long[2];
		long[] sticks = new long[nums];
		for (int i= 0; i < nums; i++)
			sticks[i]=sc.nextInt();
		Arrays.sort(sticks);
		int count = 0;
		for (int i = nums - 1; i >= 1; i--)
		
		{
			if (sticks[i]==sticks[i-1])
			{
				arr[count]= sticks[i];
				i--;
				count++;
			}
			if (count==2)
				break;
		}
			System.out.println(arr[0]*arr[1]);
		
	}
	
	
	
}


Measured memory_bytes: 59240
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int start = 0;
        int end = 100;
        int res = 0;

        if(a <= c){
            start = c;
        } else {
            start = a;
        }

        if(b <= d){
            end = b;
        } else {
            end = d;
        }

        res = end - start;
        if(res < 0){
            res = 0;
        }

        System.out.println(res);
        sc.close();
    }

}

Measured memory_bytes: 21716
import math


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def nearN():
    if N_diviors_len == 2:
        print(N - 1)
        exit()

    for i in range(N_diviors_len):
        if N_sqrt <= N_diviors[i]:
            print(N_diviors[i] + int(N / N_diviors[i] - 2))
            break


N = int(input())
N_diviors = make_divisors(N)
N_diviors_len = len(N_diviors)
N_sqrt = math.sqrt(N)

nearN()


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,i;
    char a[10000];
    cin>>a;
    m=strlen(a);
    for(i=0;i<m;i++)
    {
        cout<<'x';
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w, h;
		int x, y;
		int[][] c;
		int answer;
		while(true){
			answer = 0;
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0)
				break;
			else{	
				c = new int[h+2][w+2];
				for(int i = 0; i < h+2; i++){
					for(int j = 0; j < w+2; j++){
						if(i == 0 || i == h+1 || j == 0 || j == w+1)
							c[i][j] = 0;
					}
				} 
				for(int i = 1; i < h+1; i++){
					for(int j = 1; j < w+1; j++){
						c[i][j] = sc.nextInt();
					}
				}
				for(int i = 1; i < h+1; i++){
					for(int j = 1; j < w+1; j++){
						if(c[i][j] == 1){
							search(c, i, j, w, h);
							answer++;
						}
					}
				}
			}
			System.out.println(answer);
		}
	}
	static void search(int[][] c, int x, int y, int w, int h){
		c[x][y] = 2;
		for(int i = x-1; i <= x+1; i++){
			for(int j = y-1; j <= y+1; j++){
				if(c[i][j] == 1){
					c[i][j] = 2;
					search(c, i, j, w, h);
				}
			}
		}
	}
}

Measured memory_bytes: 43116
n=int(input())
a=[int(input())for i in range(n)]
c=0
b=1
d=0
while c<n:
    if a[c]==b:
        b+=1
        c+=1
    else:
        if a[c]%b==0:
            d+=((a[c]-2-b)//b+1if b!=1 else a[c]-1)
            c+=1
            b+=(1 if b==1 else 0)
        else:
            d+=a[c]//b
            c+=1
print(d)

Measured memory_bytes: 7084
function main(input) {
    input = input.split(" ").map(e=>Number(e))
    const a = input[0]
    const b= input[1]
    const checkOddFunc = (a,b)=>{
        const seki = a*b
        const result = seki%2==1 ?true : false 
        return result
    }
    const flagOdd = checkOddFunc(a,b)
    const mes = flagOdd ? "Odd" : "Even"
    console.log(mes);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <stdio.h>

#define N 100

int main(){

  int i,j,min,count=0,num,kari,A[N];

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

  for(i=0; i<num; i++){
    min = i;
    for(j=i; j<num; j++){
      if(A[j] < A[min]){
	min = j;
      }
    }
    if(A[min] != A[i]) count++;
	kari = A[min];
	A[min] = A[i];
	A[i] = kari;
  }

  for(i=0; i<num-1; i++)  printf("%d ",A[i]);
  printf("%d\n",A[num-1]);
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<stdlib.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

typedef struct node{
	struct node *parent;
	struct node *right;
	struct node *left;
	int id;
	int degree;
	int depth;
	int height;
	int sibling;
}node;

node *createNode(){
	node *node;
	mymalloc(node,1);
	node->parent=NULL;
	node->right=NULL;
	node->left=NULL;
	node->id=0;
	node->degree=0;
	node->depth=0;
	node->height=0;
	return node;
}

node **readNode(int n){
	int i,id,left,right;
	node **T;
	mymalloc(T,n);
	for(i=0;i<n;i++){
		T[i]=createNode();
	}
	for(i=0;i<n;i++){
		scanf(" %d %d %d",&id,&left,&right);
		T[id]->id=id;
		if(left!=-1){
			T[id]->left=T[left];
			T[left]->parent=T[id];
		}
		if(right!=-1){
			T[id]->right=T[right];
			T[right]->parent=T[id];
		}
	}
	return T;
}

node *returnRoot(node **T,int n){
	int i;
	for(i=0;i<n;i++){
		if(T[i]->parent==NULL){
			return T[i];
		}
	}
}

void preorder(node *root){
	printf(" %d",root->id);
	if(root->left!=NULL){
		preorder(root->left);
	}
	if(root->right!=NULL){
		preorder(root->right);
	}
}

void inorder(node *root){
	if(root->left!=NULL){
		inorder(root->left);
	}
	printf(" %d",root->id);
	if(root->right!=NULL){
		inorder(root->right);
	}
}

void postorder(node *root){
	if(root->left!=NULL){
		postorder(root->left);
	}
	if(root->right!=NULL){
		postorder(root->right);
	}
	printf(" %d",root->id);
}

void freeNode(node **T,int n){
	int i;
	for(i=0;i<n;i++){
		free(T[i]);
	}
	free(T);
}

main(){
	int n;
	node **T;
	node *root;
	scanf("%d",&n);
	T=readNode(n);
	root=returnRoot(T,n);
	printf("Preorder\n");
	preorder(root);
	printf("\n");
	printf("Inorder\n");
	inorder(root);
	printf("\n");
	printf("Postorder\n");
	postorder(root);
	printf("\n");
	freeNode(T,n);
	return 0;
}

Measured memory_bytes: 616
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut btc_sum: f64 = 0.0;
    let mut jpy_sum: f64 = 0.0;

    for _ in 0..n {
        let x: f64 = read();
        let u: String = read();
        if u == "BTC" {
            btc_sum += x;
        } else {
            jpy_sum += x;
        }
    }
    println!("{}", btc_sum * 380000.0 + jpy_sum)
}


Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[3000005],br[3000004],cr[2000003];
ll i,k,j,sum,a,b,cnt,maxii,l;
map<ll,ll>mp;
vector<ll>vc;
int main()
{
    ll n,x=0,t,y=0;
    j=0;
    cin>>a;
    for(i=1; i<=a; i++)
    {
        cin>>ar[i];
        mp[ar[i]]++;
        if(mp[ar[i]]==1)
        {
            br[++k]=ar[i];
        }
    }
    for(i=1; i<=k; i++)
    {
        x=mp[br[i]]-1;
        sum+=x*(x+1)/2;
    }
    for(i=1; i<=a; i++)
    {
        if(mp[ar[i]]>1)
        {
            x=mp[ar[i]]-1;
            y=x;
            y--;
            y=y*(y+1)/2;
            x=x*(x+1)/2;
            cout<<sum-x+y<<endl;
        }
        else
            cout<<sum<<endl;
    }

}



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

int main(void){
    int a[10001];
    for(int i = 1; i < 10001; i++){
        cin >> a[i];
        if(a[i] == 0) break;
        cout << "Case " << i << ": " << a[i] << endl;
        
    }
    return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	if(y==0) return x;
	return gcd(y,x%y);	
}

ll lcm(ll x, ll y) {
	ll z=gcd(x,y);
	return x/z*y;
}

int main()
{
	ll a,b,k;
	vll v;
	cin >> a >> b >> k;
	for(ll i=1;i<=gcd(a,b);i++){
		if(a%i==0 && b%i==0) v.pb(i);
	}
	sort(v.rbegin(),v.rend());
	cout << v[k-1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int a, b, c, d, w, x, y, z, m, n, win;
	scanf("%d %d %d %d %d %d %d %d",&a,&b,&c,&d,&w,&x,&y,&z);
	m = a + b + c + d;
	n = w + x + y + z;
	if(m >= n)
		win = m;
	else
		win = n;
	printf("%d\n",win);
	
	return 0;
}

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

int main() {
    string ans;
    long long N;
    cin >> N;
    N--;
    while(N >= 0) {
        int x = N % 26;
        // if(x != 0)
        ans = char('a' + x) + ans;
        N /= 26;
        N--;
    }
    cout << ans << endl;
}

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

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

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

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

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

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

	char str[100];
	int sum = 0;
	while(cin.getline(str,sizeof(str))){
		bool is_num = false;
		int psum = 0;
		REP(i,100){
			if(str[i]>='0' && str[i]<='9'){
				if(is_num){
					psum *= 10;
				}
				else{
					is_num = true;
				}
				psum += str[i]-'0';
			}
			else{
				is_num = false;
				sum += psum;
				psum = 0;
			}
		}
		memset(str,0,sizeof(str));
	}
	out(sum);
	return 0;
}


Measured memory_bytes: 3052
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    ll X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    rep(i,X) cin >> A[i];
    rep(i,Y) cin >> B[i];
    rep(i,Z) cin >> C[i];
    priority_queue<ll, vector<ll>, greater<ll>> que;
    vector<ll> AB;
    rep(i,X)rep(j,Y){
        AB.push_back(A[i] + B[j]);
    }
    sort(AB.begin(), AB.end());
    sort(C.begin(), C.end());
    reverse(AB.begin(), AB.end());
    reverse(C.begin(), C.end());
    ll N = AB.size();
    rep(i,N){
        ll ab = AB[i];
        if(que.size()==K){
            if(que.top() >= ab + C[0]) break;
        }
        rep(j,Z){
            ll abc = ab + C[j];
            ll q_n = que.size();
            if(q_n == K){
                ll smaller = que.top();
                if(smaller < abc){
                    que.pop();
                    que.push(abc);
                }
                else break;
            }
            else{
                que.push(abc);
            }
        }
    }
    vector<ll> ans(K);
    rep(i,K){
        ll abc = que.top();que.pop();
        ans[K-1-i] = abc;
    }
    rep(i,K) cout << ans[i] << endl;
}

Measured memory_bytes: 11656
n = int(input())
a, b = map(int, input().split())
li = list(map(int, input().split()))

ca = 0
cb = 0
cm = 0

for i in range(n):
    if li[i] <= a:
        ca += 1
    elif a < li[i] & li[i] <= b:
        cb += 1
    else:
        cm += 1

print(min(ca, min(cm, cb))) 

Measured memory_bytes: 3064
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  writeln(a.sum-n);
}


Measured memory_bytes: 2300
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    List<int>[] es;

    void calc()
    {
        cin = new Scanner();
        int D = cin.nextInt();
        int N = cin.nextInt();
        for (int i = 1; ; i++)
        {
            int t = i;
            int cnt = 0;
            while (t % 100 == 0)
            {
                cnt++; t /= 100;
            }
            if (cnt == D) N--;
            if(N == 0)
            {
                Console.WriteLine(i);
                return;
            }
        }

    }
    
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(snip_i, h) cin >> s.at(snip_i);
  int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
  rep(i, h)rep(j, w){
    if(s.at(i).at(j) == '.') continue;
    bool flag = false;
    rep(snip_i, 4){
      int nj = j + dx[snip_i], ni = i + dy[snip_i];
      if(ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
      if(s.at(ni).at(nj) == '#') flag = true;
    }
    if(flag == false){
      cerr << i << " " << j << endl;
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios:: sync_with_stdio(false);
  cin.tie();
  vector<int> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}




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

int main() {
	int r;
	cin >> r;
	if (r < 1200) {
		cout << "ABC" << endl;
	}
	else {
		if (r < 2800) {
			cout << "ARC" << endl;
		}
		else {
			cout << "AGC" << endl;
		}
	}
}

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

int main(void)
{
  int n, a[10000], sum=0;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
    while(a[i]%2 == 0){a[i] /= 2; sum++;}
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  int l,r;
  cin>>l>>r;
  if (l%2019==0) {
    cout<<0<<endl;
    return 0;
  }
  int a=l%2019+(r-l);
  if (a>=2019) {
    cout<<0<<endl;
  }
  else {
    int ans=1e9;
    for (int i=l%2019; i<=r%2019-1; i++) {
      for (int j=i+1; j<=r%2019; j++) {
	ans=min(i*j%2019,ans);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int t[100005];
int main()
{
    int n,m,p,x;
    while(cin >> n)
    {
        ll sum = 0;
        for(int i = 1;i <= n;i++)
        {
            cin >> t[i];
            sum += t[i];
        }
        ll tmp = sum;
        cin >> m;
        while(m--)
        {
            cin >> p >> x;
            sum = tmp + x - t[p];
            cout << sum << endl;
        }

    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define si second
using namespace std;

long long a,b,n,m,k,arr[100100];
pair<long long,long long>pi[100100],p,q;

int main()
{
    while(cin>>n>>k){
        for(long long i=0; i<n; i++){
            cin>>a>>b;
            pi[i].fi=a;
            pi[i].si=b;
        }
        sort(pi,pi+n);
        long long calc=0;
        for(long long i=0; i<n; i++){

            if((calc+pi[i].si)>k){  //cout<<calc<<"   "<<k<<endl;
                p.fi=pi[i].fi;
                p.si=calc+pi[i].si;
                break;
            }
            else{
                calc+=pi[i].si;
                q.fi=pi[i].fi;
                q.si=calc;
            }
        }
        if(k<=q.si) cout<<q.fi<<endl;
        else if(k>q.si) cout<<p.fi<<endl;
    }
}




Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n, p;
    cin >> n >> p;
    vl w(n), b(n);
    // ll tot = 0;
    ll sum = 0;
    vl votes(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> b[i];
        sum -= p * b[i];
        votes[i] = (100 - p) * w[i] + p * b[i];
    }
    sort(votes.begin(), votes.end(), greater<ll>());
    int idx = 0;
    while (sum < 0) {
        sum += votes[idx];
        idx++;
    }
    cout << idx << "\n";
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string.h>

const int maxn=100;
using namespace std;

int main()
{
    char s[maxn];
    while(scanf("%s", s) != EOF)
    {
        if(strcmp(s, "Sunny") == 0)
            printf("Cloudy\n");
        else if(strcmp(s, "Cloudy") == 0)
            printf("Rainy\n");
        else if(strcmp(s, "Rainy") == 0)
            printf("Sunny\n");
    }

    return 0;
}


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

int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    int na = sa.length() + 1;
    int nb = sb.length() + 1;
    int nc = sc.length() + 1;

    int a = 0, b = 0, c = 0;
    char next = 'a', ans = 'A';
    while(a < na && b < nb && c < nc) {
        if (next == 'a') {
            next = sa[a];
            a++;
            ans = 'A';
        } else if (next == 'b') {
            next = sb[b];
            b++;
            ans = 'B';
        } else {
            next = sc[c];
            c++;
            ans = 'C';
        }
    }

    cout << ans << endl;

}

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

int main() {
  ll n;
  cin >> n;
  if (n % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  ll p = 5;
  n /= 2;
  while (p <= n) {
    ans += n/p;
    p *= 5;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int h,w;cin>>h>>w;
    bool dp[h][w][30000];
    REP(i,h)REP(j,w)REP(k,30000)dp[i][j][k]=false;
    int a[h][w],b[h][w];
    REP(i,h)REP(j,w)cin>>a[i][j];
    REP(i,h)REP(j,w)cin>>b[i][j];
    REP(i,h)REP(j,w){
        if(i==0&&j==0){
            dp[0][0][15000+abs(a[0][0]-b[0][0])]=true;
            dp[0][0][15000-abs(a[0][0]-b[0][0])]=true;
            continue;
        }
        if(j!=0){
            REP(k,30000){
                if(dp[i][j-1][k]){
                    dp[i][j][k+abs(a[i][j]-b[i][j])]=true;
                    dp[i][j][k-abs(a[i][j]-b[i][j])]=true;
                }
            }
        }
        if(i!=0){
            REP(k,30000){
                if(dp[i-1][j][k]){
                    dp[i][j][k+abs(a[i][j]-b[i][j])]=true;
                    dp[i][j][k-abs(a[i][j]-b[i][j])]=true;
                }
            }
        }
    }
    int ans=INF;
    REP(k,30000)if(dp[h-1][w-1][k])chmin(ans,abs(k-15000));
    cout<<ans<<endl;
}

Measured memory_bytes: 187904
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int replaceStr( string& base,
                const string source,
                const string target) {
    int count = 0;
    string::size_type pos(base.find(source));

    while(pos != string::npos) {
        count++;
        base.replace(pos, source.length(), target);
        pos = base.find(source, pos + target.length());
    }
    return count;
}

int countPair(string &base) {
    int count = 0;
    string::size_type pos;

    pos = std::min(base.find("01"), base.find("10"));
    while(pos != string::npos) {
        count++;
        pos = std::min(base.find("01", pos+2), base.find("10", pos+2));
    }
    return count;
}

// int main() {
//     string S;
//     cin >> S;

//     int sum = 0;
//     int zero_one = replaceStr(S, "01", "");
//     int one_zero = replaceStr(S, "10", "");
    
//     sum = zero_one + one_zero;
//     while(zero_one + one_zero != 0) {
//         zero_one = replaceStr(S, "01", "");
//         one_zero = replaceStr(S, "10", "");
//         sum += zero_one + one_zero;
//     }

//     cout << sum * 2 << endl;

//     return 0; 
// }

int main(){
    string S;
    cin >> S;

    int zero = 0;
    int one = 0;

    for(int i = 0; i < S.length(); i++) {
        if(S[i] == '0') zero++;
        else one++;
    }
    cout << S.length()-std::abs(zero-one) << endl;

}

Measured memory_bytes: 512
import java.util.*;

class Main{
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Main(){
        int[] array = new int[n];
        for ( int i = 0; i < n; i++){
            array[i] = sc.nextInt();
        }
        for ( int j = n-1 ; j >= 0; j--){
            System.out.print(array[j]);
            if (j != 0 ){
                System.out.print(" ");    
            }    
        }
        System.out.print("\n");
    }
    public static void main(String[] args){
        new Main();
    }
}


Measured memory_bytes: 26340
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn exec() {
    let mut sc = Scanner::new();
    let (n, c, k): (usize, usize, i64) = (sc.ne(), sc.ne(), sc.ne());
    let mut t: Vec<i64> = (0..n).map(|_| sc.ne()).collect();
    t.sort();
    let mut ans = 0;
    let mut cnt = 0;
    let mut bus = -1;
    for i in 0..n {
        if bus == -1 {
            bus = t[i] + k;
            cnt = 1;
            ans += 1;
        } else {
            if cnt == c || bus < t[i] {
                bus = t[i] + k;
                cnt = 1;
                ans += 1;
            } else {
                cnt += 1;
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int n = sc.intarr[0];
            int[] vs = sc.intarr;

            Array.Sort(vs);

            double ans = vs[0];

            for(int i=1; i<n; i++)
            {
                ans = (ans + vs[i]) / 2.0;
            }

            Console.WriteLine(ans);
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

ll n, ans;
VI a;
vector<map<ll, ll>> a_fac;
map<ll, ll> lcm_fac;

map<ll, ll> factorization_map(ll n)
{
    map<ll, ll> rtn;

    ll m = n;
    for (ll i = 2; i * i <= m; i++) {
        while (m % i == 0) {
            rtn[i]++;
            m /= i;
            MAX(lcm_fac[i], rtn[i]);
        }
    }
    if (m != 1) {
        rtn[m]++;
        MAX(lcm_fac[m], rtn[m]);
    }

    return rtn;
}

ll mypow(ll a, ll b)
{
    ll r = 1ll;
    while(b != 0){
        if(b&1) r = r * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return r;
}

vector<ll> fac;
vector<ll> ifac;

void factorial_init(ll n)
{
    fac.resize(n+1);
    ifac.resize(n+1);
    fac[0] = 1;
    ifac[0] = 1;
    REP(i,n) {
        fac[i+1] = fac[i] * (i + 1) % MOD;
        ifac[i+1] = ifac[i] * mypow(i + 1, MOD - 2) % MOD;
    }
}

int main()
{
    cin>>n;
    //factorial_init(111111);
    a.resize(n); a_fac.resize(n);
    REP(i,n) {
        cin>>a[i];
        a_fac[i] = factorization_map(a[i]);
        /*REPITR(itr,a_fac[i]) {
            MAX(lcm_fac[itr->e1], itr->e2);
            debug(itr->e1); debug(itr->e2);
        }*/
    }
    ll s = 1ll;
    REPITR(itr,lcm_fac) {
        s *= mypow(itr->e1, itr->e2);
        s %= MOD;
    }
    REP(i,n) {
        ll tmp = 1ll;
        /*REPITR(itr,lcm_fac) {
            tmp *= mypow(itr->e1, itr->e2 - a_fac[i][itr->e1]);
            tmp %= MOD;
        }*/
        ans += s * mypow(a[i], MOD - 2);
        ans %= MOD;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main(){
  int N, X, Y, Z;
  int tmp;
  cin >> N;
  cin >> X;
  int A_m[X];
  for(int i = 0; i < X; ++i){
    cin >> A_m[i];
  }
  cin >> Y;
  int B_m[Y];
  for(int i = 0; i < Y; ++i){
    cin >> B_m[i];
  }
  cin >> Z;
  int C_m[Z];
  for(int i = 0; i < Z; ++i){
    cin >> C_m[i];
  }
  set<int> AC;
  set<int> BC;
  set<int> Answer;
  for(int i = 0; i < Z; ++i){
    AC.insert(C_m[i]);
  }
  for(int i = 0; i < X; ++i){
    AC.erase(A_m[i]);
  }
  for(int i = 0; i < Y; ++i){
    for(int j = 0; j < Z; ++j){
      if(B_m[i] == C_m[j]){
        BC.insert(B_m[i]);
      }
    }
  }
  set_union(AC.begin(), AC.end(), BC.begin(), BC.end(), inserter(Answer, Answer.end()));
  cout << Answer.size() << endl;
  return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,x,t,ans=0;
    cin>>n>>x>>t;
    int cur=0;
    while(cur<n){
        cur+=x;
        ans+=t;
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3608
A = []
ans = []


def pushBack(x):
    A.append(x)


def randomAccess(p):
    if A != []:
        ans.append(A[p])
    else:
        print('RandAccError')


def popBack():
    if A != []:
        del A[-1]
    else:
        print('DelError')


def main():
    q = input()
    for i in range(int(q)):
        try:
            query, number = (int(x) for x in input().split())
        except ValueError:
            popBack()
            continue

        if query == 0:
            pushBack(number)
        elif query == 1:
            randomAccess(number)

    for i in range(len(ans)):
        print(ans[i])


if __name__ == "__main__":
    main()



Measured memory_bytes: 13364
r,g,b = map(int,input().split())
k = int(input())
t=0
t+=k
for i in range(k):
    if(b<=r):
        b*=2
        t-=1
        
    elif(b>r and b<=g):
        b*=2
        t-=1
        
    elif(b>r and b>g and g<=r):
        g*=2
        t-=1
        
        
    if(t==0):
        break
    
if(g>r and b>g):print("Yes")
else:print("No")
    
    

Measured memory_bytes: 8844
//
//  main.cpp
//  瀹
//
//  Created by RMBP on 2019/10/13.
//  Copyright 漏 2019 RMBP. All rights reserved.
//

#include <iostream>
using namespace std;
int main() {
    int n,t,a,i,b;
    double h[100000],c,e;
    e=0;
    c=1000000;
    b=0;
    cin>>n>>t>>a;
    for (i=0;i<n;i++){
        cin>>h[i];
        e=t-h[i]*0.006-a;
        
        if (t-h[i]*0.006<a){
            
            e=a-(t-h[i]*0.006);
            
        }
        
        
        if (e<c){
            c=e;
            b=i;
            
        }
        
    }
    cout<<b+1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXH = 100;
const int MAXW = 100;

int main() {
	int A, B;
	cin >> A >> B;
	// 白が0
	vector<vector<bool>> wb(MAXH, vector<bool>(MAXW, 0));
	// 白に黒をB-1個取り込む
	int bcnt = 0;
	for(int h=0;h<(MAXH/2);h++) {
		for(int w=0;w<MAXW;w++) {
			if(bcnt == B - 1) break;
			if(h % 2 == 0 and w % 2 == 0) {
				wb[h][w] = 1;
				bcnt++;
			}
		}
		if(bcnt == B - 1) break;
	}
	// 黒に白をA-1個取り込む
	for(int h=(MAXH/2);h<MAXH;h++)
		for(int w=0;w<MAXW;w++)
			wb[h][w] = 1;
	int wcnt = 0;
	for(int h=(MAXH/2);h<MAXH;h++) {
		for(int w=0;w<MAXW;w++) {
			if(wcnt == A - 1) break;
			if(h % 2 == 1 and w % 2 == 0) {
				wb[h][w] = 0;
				wcnt++;
			}
		}
		if(wcnt == A - 1) break;
	}

	cout << MAXH << " " << MAXW << endl;
	for(int h=0;h<MAXH;h++) {
		for(int w=0;w<MAXW;w++) {
			cout << ((wb[h][w]) ? '#' : '.' );
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b=0;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
	if(op=='+'){
		printf("%d\n",a+b);}
	else if(op=='-'){printf("%d\n",a-b);}
	else if(op=='*'){printf("%d\n",a*b);}
	else if(op=='/'){printf("%d\n",a/b);}
	else {break;}
	}
	return 0;
}

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


void solve(std::string s){
    string ans;
    for(int i = 0; i < s.size(); i++)
    {
        if(i % 2 == 0){
            ans += s.at(i);
        }
    }
    
    cout << ans << endl;
}

int main(){
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 640
def main():
    n = int(input())
    s = input()

    c = 0
    l1 = set()
    for i in range(n)[:-2]:
        if s[i] in l1:
            continue
        l1.add(s[i])
        l2 = set()
        for j in range(n)[i + 1:-1]:
            if s[j] in l2:
                continue
            l2.add(s[j])
            c += len(set(list(s[j + 1:])))

    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3344