akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	m := intScanner()
	x := make([]int, n)
	for i := 0; i < m; i++ {
		a, b := intScanner()-1, intScanner()-1
		if a > 0 {
			x[a]++
		}
		if b > 0 {
			x[b]++
		}
	}
	ans := "YES"
	for i := 0; i < n; i++ {
		if x[i]%2 != 0 {
			ans = "NO"
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2560
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while(left <= right) {
		mid = (left + right) / 2;
		if(A[mid] == key) return 1;
		if(key < A[mid]) right = mid-1;
		else if(key > A[mid]) left = mid+1; 
	}
	return 0;	
}

int main() {
	int i, q, key, sum = 0;
	
	scanf("%d", &n);
    for(int i = 0; i < n; i++) { 
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    for(int i = 0; i < q; i++) {
	    scanf("%d", &key);
		if( binarySearch(key)) sum++; 
	}
	printf("%d\n", sum);
	
	return 0;    
}
  

Measured memory_bytes: 3068
my $input_lines = <STDIN>;
#my @data = split(/ /, @input_lines[0]);

#$input_lines = ('3 3 33');

#my $input_lines = <STDIN>;
my @data = split(/ /, $input_lines);

if(($data[0] == $data[1])&&($data[1] == $data[2])){
  $count = 1;
}elsif($data[0] == $data[1]){
  $count = 2;
}elsif($data[1] == $data[2]){
  $count = 2;
}elsif($data[2] == $data[0]){
  $count = 2;
}else{
  $count = 3;
}

print "$count";


Measured memory_bytes: 640
from collections import deque

h, w = map(int, input().split())
tizu = [list(input()) for _ in range(h)]
check = [[False for _ in range(w)] for _ in range(h)]
ans = 0

queue = deque()
for i in range(h):
    for j in range(w):
        if tizu[i][j] == "#":
            queue.append([i, j])
            queue.append(0)
            check[i][j] = True

direct = [[1, 0], [-1, 0], [0, 1], [0, -1]]        
while queue:
    pos = queue.popleft()
    cnt = queue.popleft()
    for dy, dx in direct:
        n_y = pos[0] + dy
        n_x = pos[1] + dx
        if n_y == -1 or n_y == h or n_x == -1 or n_x == w:
            continue
        if check[n_y][n_x]:
            continue
        check[n_y][n_x] = True
        ans = max(ans, cnt + 1)
        queue.append([n_y, n_x])
        queue.append(cnt + 1)
print(ans)

Measured memory_bytes: 214412
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> arr;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		arr.push_back(a);
	}
	long long sum = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			sum+=arr[i]*arr[j];
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<functional>

using namespace std;
int main(void)
{
	int a[11],b[11];
	int i,wa,wb;
	for(i=0;i<10;i++) scanf("%d",&a[i]);
	for(i=0;i<10;i++) scanf("%d",&b[i]);
	sort(a,a+10,greater<int>());
	sort(b,b+10,greater<int>());
	wa=0; wb=0;
	for(i=0;i<3;i++){
		wa+=a[i]; wb+=b[i];
	}
	printf("%d %d\n",wa,wb);
	return 0;
}

Measured memory_bytes: 2764
P = [str(p) for p in input().split()]
S = P[0]
T = P[1]

Q = [int(q) for q in input().split()]
A = Q[0]
B = Q[1]

U = str(input())

if(U == S):
    A = A - 1
if(U == T):
    B = B - 1

print(str(A) + " " + str(B))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel
bitset<1000005>b;
void seive(int arr[], int n)
{
    b.set();
    for (int i = 0; i < n; i++)
    {
        if (arr[i] == arr[i - 1]  && i > 0)
        {
            b[arr[i]] = 0;
            continue;
        }
        for (int j = arr[i] * 2; j <= 1000000; j += arr[i])
        {
            b[j] = 0;
        }
    }
}

signed main()
{
    fasterthanlight;
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    seive(arr, n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (b[arr[i]] == 1)
            ans++;
    }
    cout << ans;
    //cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
    return 0;
}


Measured memory_bytes: 5336
#include <bits/stdc++.h>
using namespace std;
int v[33] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    int n;
    cin >> n;
    cout << v[n];
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    vector<ll> v;
    v.pb(0);
    for(int i=0;i<n;i++){
        ll k;
        cin>>k;
        v.pb(k);
    }
    ll i=1;
    vector<int> visited(n+1);
    visited[1]=1;
    ll count=1;
    while(v[i]!=2){
        i=v[i];
        if(visited[i]==0){
            visited[i]=1;
            count+=1;
        }
        else{
            count=-1;
            break;
        }

    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

vector<long> dijkstra(vector<vector<pair<long, long>>>& w_graph, long s) {//sからの単一始点最短経路
	vector<long> res(w_graph.size(), INT_MAX);

	priority_queue<pair<long, long>, vector<pair<long, long>>, greater<pair<long, long>>> que;//距離と頂点のpair。距離をfirstに置く。
	res[s] = 0;

	que.emplace(res[s], s);

	while (!que.empty()) {

		long cost;//sからindexまでの距離
		long index;
		tie(cost, index) = que.top();
		que.pop();

		if (res[index] < cost) continue;
		for (pair<long, long> e : w_graph[index]) {

			long c, i;
			tie(i, c) = e;

			long newcost = cost + c;

			if (res[i] <= newcost) continue;
			res[i] = newcost;
			que.emplace(res[i], i);
		}

	}
	return res;
}

int main() {

	long H, W; cin >> H >> W;
	long res = 0;
	vector<vector<pair<long, long>>> w_graph(10);

	for (int i = 0; i <= 9; i++) for (int j = 0; j <= 9; j++) {// j -> i 変化を逆から走査。単一始点は1
		long c; cin >> c;
		w_graph[j].push_back(make_pair(i, c));
	}

	vector<long> Sp = dijkstra(w_graph, 1);

	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
		long A; cin >> A;
		if (A == -1) continue;
		res += Sp[A];
	}

	cout << res << endl;
}

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

int main() {
  vector<int>vec(5);
  cin >> vec[0] >> vec[1] >> vec[2] >> vec[3] >> vec[4];
  vector<int>amari(5);
  for(int i=0; i<5; i++){
    amari[i] = 10-(vec[i]%10);
    if(amari[i] == 10){
      amari[i] -= 10;
    }
  }
  sort(amari.begin(),amari.end());
  cout << vec[0]+vec[1]+vec[2]+vec[3]+vec[4]+amari[0]+amari[1]+amari[2]+amari[3] << endl;
}


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

void Main()
{
  ll L, R;
  cin >> L >> R;
  if (R - L >= 2019-1) {cout << 0 << endl; return;} 
  L = L % 2019;
  R = R % 2019;
  if (L==0 || R==0) {cout << 0 << endl; return;}
  if (R < L) {cout << 0 << endl; return;}
  ll minRes = 2019;
  for (ll i = L; i < R; i++) {
    for (ll j = L+1; j <= R; j++) {
      ll res = (i*j) %2019;
      if (res < minRes) minRes = res;
    }
  }
  cout << minRes << endl;
}

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


Measured memory_bytes: 256
from collections import defaultdict

def main():
    num = int(input())
    data = list(map(int, input().split()))

    ans = [0 for i in range(num)]

    sum_data = sum(data)

    aaa = data[:-2:2]
    # print(data)
    bbb = sum(aaa) * 2
    ans[num - 1] = sum_data - bbb
    # print(aaa, bbb)
    # print(ans)
    for i in range(num - 1)[::-1]:
        ans[i] = data[i] * 2 - ans[i + 1]
        # print(ans)

    print(' '.join(list(map(str, ans))))









if __name__ == '__main__':
    main()


Measured memory_bytes: 75748
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,b; cin>>a>>b;
	int k=a*b;
	repp(i,1,4){
		if((k*i)&1) {
			cout<<"Yes";
			return 0;
		
		}
	
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int count=0;
void Merge(int*,int,int,int);
void MergeSort(int*,int,int);
int main(){
  int n,i;
  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  MergeSort(A,0,n);
  
    
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

void Merge(int *a,int l,int m,int r){
  int n1,n2,i,j,k;
  int *L,*R;
  n1=m - l;
  n2=r - m;
  L=(int *)malloc((n1+1) * sizeof(int));
  R=(int *)malloc((n2+1) * sizeof(int));
  for(i=0;i<n1;i++){
    L[i]=a[l+i];
  }
 
  for(i=0;i<n2;i++){
    R[i]=a[m+i];
   
  }
 
  L[n1]=INFINITY;
  R[n2]=INFINITY;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    if(L[i]<R[j]){
      a[k] = L[i];
      i=i+1;
    }
    else{
      a[k] = R[j];
      j=j+1;
    }
    count++; }
  free(R);
  free(L);
  
}


void MergeSort(int*a,int l,int r){
  int m;
  if(l+1<r){
    m = (l+r)/2;
   
    MergeSort(a,l,m);
    MergeSort(a,m,r);
    Merge(a,l,m,r);
  }
}






Measured memory_bytes: 5372
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	//ios::sync_with_stdio(false);
	ll N,M;
	string s;
	while(cin>>N>>M) {
		VVI g(N);
		REP(i, M) {
			ll a, b;
			cin>>a>>b;
			a--;b--;
			g[a].PB(b);
			g[b].PB(a);
		}
		
		REP(i, N) cout<<g[i].size()<<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 n = sc.nextInt(), m = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt();

		int max = x, min = y;
		for (int i = 0; i < n; i++)
			max = Math.max(sc.nextInt(), max);
		for (int i = 0; i < m; i++)
			min = Math.min(sc.nextInt(), min);
		
		System.out.println(max < min ? "No War" : "War");
	}

}

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

int main(){
    int a,b,c; cin >> a >> b >> c;
    int now = 0;
    while(1){
        if(now >= 10000){
            puts("-1");
            return 0;
        }
        if(now%60 < (now+a)%60){
            if(now%60 <= c && c <= (now+a)%60){
                cout << now+c-now%60 << endl;
                return 0;
            }
        }else{
            if(c >= now%60 || c <= (now+a)%60){
                if(c >= now%60){
                    cout << now+c-now%60 << endl;
                }else{
                    cout << now+c+60-now%60 << endl;
                }
                return 0;
            }
        }
        now += a+b;
    }
}


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

#define INF 1e9

using namespace std;

int main() {
    int N, M;
    int dp[100006];
    vector<int> coin;

    int i = 1;
    while (true) {
        if (i > 1e6) { break; }
        i *= 6;
        coin.push_back(i);
    }
    i = 1;
    coin.push_back(1);
    while (true) {
        if (i > 1e6) { break; }
        i *= 9;
        coin.push_back(i);
	}
    sort(coin.begin(), coin.end());

    fill(dp, dp + 100006, INF);

    dp[0] = 0;
    M = coin.size();

    cin >> N;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j + coin[i] <= N; j++) {
            dp[j + coin[i]] = min(dp[j + coin[i]], dp[j] + 1);
        }
    }
    cout << dp[N] << endl;

    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

// 約数の全列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    ll ans = 0;
    for(ll i=1; i<=N; i++){
        ll k = N/i;
        ans += i * k*(k+1)/2;
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long

int main(){
    ll N,i,T,lower_sum;
    ll w_sum=0;
    ll result=100000;
    cin>>N;
    vector<ll> W(N);
    for(i=0;i<N;i++){
        cin>>W[i];
        w_sum+=W[i];
    }

    for(T=1;T<N;T++){
        lower_sum=0;
        for(i=0;i<=T;i++)lower_sum+=W[i];
        if(abs(w_sum-2*lower_sum)<result)result=abs(w_sum-2*lower_sum);
    }
    cout<<result<<endl;
}

Measured memory_bytes: 256
from collections import Counter

h, w = map(int, input().split())
A = []
for _ in range(h):
  A += list(input())
C = Counter(A)
X = [0]*2
for i in C.values():
  if i%2:
    X[0] += 1
  if i%4>=2:
    X[1] += 1
if X[0] <= (h%2)*(w%2) and X[1] <= (h%2) * (w//2) + (w%2) * (h//2):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}
struct UnionFind{
  vector<int> d;
  UnionFind(int n) : d(n,-1) {}
  //根なら、-サイズを格納それ以外は、親を格納
  int find(int x){
    if(d[x] < 0) return x;
    return d[x] = find(d[x]); //経路縮約
  }
  bool unite(int x,int y){
    //二つ頂点を持ってくる
    x = find(x);
    y = find(y);
    if(x == y) return false;//根が一致するなら何もしない
    if(d[x] > d[y]) swap(x,y);
    //ex:d[x]=-5,d[y]=-2
    //小さい方が、大きい方に引っ付く
    d[x] += d[y];//この場合、yがxにくっつく
    d[y] = x;
    return true;
  }
  bool same(int x,int y) {return find(x) == find(y);}
  int size(int x) {return -d[find(x)];}
};
int main(){
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  set<int> block[n];
  vector<int> friends(n, 0);
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    friends[a]++;
    friends[b]++;
    uf.unite(a, b);
  }
  rep(i,k){
    int c, d;
    cin >> c >> d;
    c--;
    d--;
    block[c].insert(d);
    block[d].insert(c);
  }
  vector<int> v(n, 0);
  rep(i,n){
    v[i] += uf.size(i)-1;
    for(auto u : block[i]){
      if(uf.same(i,u))
        v[i]--;
    }
    v[i] -= friends[i];
    chmax(v[i], 0);
  }
  rep(i,n){
    cout << v[i] << (i == n - 1 ? "\n" : " ");
  }
  return 0;
}

Measured memory_bytes: 18516
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

void solve() {
  int n; cin >> n;
  Graph G(n, vi(3));
  rep(i,n) rep(j,3) cin >> G[i][j];

  int idx = 0;
  while (G[idx][2] == 0) ++idx;

  rep0(x,100) {
    rep0(y,100) {
      int h = G[idx][2] + abs(x - G[idx][0]) + abs(y - G[idx][1]);
      bool possible = true;
      rep(i,n) {
        int tmp = max(h - abs(x - G[i][0]) - abs(y - G[i][1]), 0);
        if (tmp != G[i][2]) {
          possible = false;
          break;
        }
      }
      if (possible) {
        cout << x << ' ' << y << ' ' << h << endl;
        return;
      }
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
from math import factorial

def C(n, r):
  if r > n: return 0
  if r < 0: return 0
  return factorial(n) // factorial(r) // factorial(n-r)

n, k = map(int, input().split())
for i in range(1, k + 1):
  x = C(n-k+1, i) * C(k-1, i-1)
  print(x % (10**9 + 7))


Measured memory_bytes: 3316
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int ck(string s,string a){
	int cnt = 0;
	for(int i=0;s[i];i++){
		if(s[i] != a[i]){
			cnt++;
		}
	}

	return cnt;
}

int main(){
	
	
	string s,a;
	cin>>s>>a;
	int mn =  1e6;
	int n = s.size() - a.size();
	int l = a.size();
	for(int i=0;i<=n;i++){
		mn = min(mn,ck(s.substr(i,l),a));
	}

	cout<<mn<<endl;
	

	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
using ll = long long;

struct t{
  char mark;
  int num;
};

void Output(const vector<t> &a){
  REP(i,a.size()){
    cout << a[i].mark << a[i].num;
    if(i != a.size()-1) cout << " ";
  }
  cout << endl;
}

void isStable(vector<t> &card, const vector<vector<char>> &order){
  vector<vector<char>> buf(9, vector<char>());
  REP(i,card.size()) buf[card[i].num-1].push_back(card[i].mark);
  REP(i,9){
    if(buf[i] != order[i]){
      cout << "Not stable" << endl;
      return;
    }
  }
  cout << "Stable" << endl;
}

void BubbleSort(vector<t> a, int n, const vector<vector<char>> &order){
  bool flag = 1;
  while(flag){
    flag = 0;
    for(int i=n-1;i>=1;--i){
      if(a[i-1].num > a[i].num){
        swap(a[i-1], a[i]);
        flag = 1;
      }
    }
  }
  Output(a);
  isStable(a, order);
}

void SelectionSort(vector<t> a, int n, const vector<vector<char>> &order){
  REP(i,n){
    int minj = i;
    FOR(j,i,n){
      if(a[minj].num > a[j].num) minj = j;
    }
    if(i != minj){
      swap(a[i], a[minj]);
    }
  }
  Output(a);
  isStable(a, order);
}

int main(){
  int n; cin >> n;
  vector<t> card(n);
  vector<vector<char>> order(9, vector<char>());
  REP(i,n){
    cin >> card[i].mark >> card[i].num;
    order[card[i].num-1].push_back(card[i].mark);
  }
  BubbleSort(card, n, order);
  SelectionSort(card, n, order);
  return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
#include <functional>
using namespace std;
using ll = long long;
constexpr ll MOD = 998244353;
constexpr ll INF = 1LL << 60;


int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  int N; cin >> N;
  double x, y;
  vector<pair<double, double>> ps;
  for(int i = 0; i < N; ++i) {
    cin >> x >> y;
    ps.emplace_back(x, y);
  }
  vector<int> idx(N);
  for(int i = 0; i < N; ++i) idx[i] = i;

  double ans = 0;
  do {
    double tmp = 0;
    for(int i = 1; i < N; ++i) {
      tmp += sqrt((ps[idx[i-1]].first - ps[idx[i]].first) * (ps[idx[i-1]].first - ps[idx[i]].first) + (ps[idx[i-1]].second - ps[idx[i]].second) * (ps[idx[i-1]].second - ps[idx[i]].second));
    }
    ans += tmp;
  } while(next_permutation(idx.begin(), idx.end()));
  for(double i = 1; i <= N; ++i) ans /= i;
  cout<<fixed<<setprecision(10)<< ans  << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
ll quick(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b&1)
			ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
ll inv(ll a){return quick(a,mod-2);}
const int maxn=2e5+7;
ll fac[maxn];
void db()
{
	fac[0]=1;
	for(int i=1;i<maxn;i++) fac[i]=fac[i-1]*i%mod;
}
ll C(int n,int m)
{
	return fac[n]*inv(fac[n-m])%mod*inv(fac[m])%mod;
}
int main()
{
	db();
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	ll ans=C(h+w-2,w-1);
	for(int i=1;i<=b;i++)
		ans=(ans-C(h-a+i-2,i-1)*C(w-i+a-1,a-1)%mod+mod)%mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
  long long int a,b,c=0,e=1,f=0;
  cin>>a>>b;
  rep(i,a){
    cin>>c;
    f+=c;
    if(b>=f)e++;
  }
  cout<<e;
  }


Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

int main(){

	ll N;

	scanf("%lld",&N);

	ll i;

	ll ans=1ll;

	for(i=1ll;i<=N;i+=1ll){
	ans*=i;
	ans%=1000000007ll;
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 128
/*⠄⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄
⠄⠄⠄⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄
⠄⠄⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄
⠄⠄⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄
⠄⢀⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰
⠄⣼⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤
⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗
⢀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠄
⢸⣿⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠄
⠘⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃⠄
⠄⠘⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃⠄⠄
⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁⠄⠄⠄
⠄⠄⠄⠄⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁⠄⠄⠄⠄⠄⢀⣠⣴
⣿⣿⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⣠⣴⣿*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
int arr[200005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	
	int ans=0;
	
	rep(x,0,n){
		cin>>arr[x];
		ans^=arr[x];
	}
	
	rep(x,0,n){
		cout<<(ans^arr[x])<<" ";
	}
}


Measured memory_bytes: 4400
//103
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
    string S;
    cin >> S;

    int ans = 0;
    for(int i = 1; i < S.size(); i++)
    {
        /* code */
        if(S[i] == S[i-1]){
            ans++;
            if(S[i] == '0'){
                S[i] = '1';
            }else{
                S[i] = '0';
            }
        }
    }
    cout << ans << endl;
    

}


Measured memory_bytes: 512
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N, K;
    in2(N, K);

    vi p(N);
    inN(p, N);

    sort(all(p));

    ll ans = 0;
    rep(i, K) ans += p[i];

    outl(ans);

    return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)

int main() {
  int n;
  cin >> n;
  int ans = 10000000;
  for (int a=1; a<n; ++a) {
    int b = n-a;
    int y = a%10 + (a/10)%10 + (a/100)%10 + (a/1000)%10 + (a/10000)%10
          + b%10 + (b/10)%10 + (b/100)%10 + (b/1000)%10 + (b/10000)%10;
    ans = min(ans,y);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
A,B,C,D,E,F = map(int, input().split())

val_max = 0
for a in range(0,1+F//(100*A)):
  for b in range(0,1+(F - 100*A*a)//(100*B)):
    if (a==0)&(b==0):
      continue
    for c in range(0,1+(F - 100*A*a - 100*B*b)//C):
      for d in range(0,1+(F - 100*A*a - 100*B*b - C*c)//D):
        if C*c+D*d <= E*(A*a+B*b):
          val = (C*c + D*d)/(100*A*a + 100*B*b + C*c + D*d)
          if val >= val_max:
            val_max = val
            ans1 = 100*A*a + 100*B*b + C*c + D*d
            ans2 = C*c + D*d
print(int(ans1),int(ans2))


Measured memory_bytes: 3064
L,R = list(map(int,input().split()))
lt = []
if R-L == 1:
    print((L*R) % 2019)
elif R-L >= 2:
    for k in range(L,R+1):
        if k % 673 == 0:
            lt.append(0)
            break
    l = L % 673
    r = R % 673
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = (i*j) % 2019
            lt.append(ans)
    print(min(lt))

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  vector<int> b(N);
  int A, B;
  for(int j = 0; j < N; j++) {
    for(int k = 0; k < N; k++) {
      if(b.at(j) <= a.at(k)) {
        b.at(j) = a.at(k);
        //cout << b.at(j) << ":vecb" << j << ":j" << k << ":k" << endl;
      }
      
    }
    for(int l = 0; l < N; l++) {
      if(b.at(j) == a.at(l)) {        
        //cout << a.at(l) << ":veca" << l << endl;
        a.at(l) = 0;
        break;
      }
      
    }
  }
  
  for(int m = 0; m < N; m += 2) {
    A += b.at(m);
  }
  
  for(int n = 1; n < N; n += 2) {
    B += b.at(n);
  }
  
  cout << A - B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    string s;
    cin >> s;
    int cnt = 0;
    int q;
    cin >> q;
    while(q--){
        int t;
        cin >> t;
        if(t == 1){
            cnt++;
        }
        else{
            cin >> t;
            char x;
            cin >> x;
            if(t == 1) {
                if(cnt % 2 == 0) s.insert(s.begin(), x);
                else s += x;
            }
            else{
                if(cnt % 2 == 1) s.insert(s.begin(), x);
                else s += x;
            }
        }
    }
    if(cnt % 2 == 1) reverse(s.begin(), s.end());
    cout << s;
}

Measured memory_bytes: 1028
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

  static int n, ans;
  static long k;
  static List<Integer> a;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    k = Long.parseLong(in[1]);

    in = br.readLine().split(" ");
    a = Arrays.stream(in).map(Integer::parseInt).collect(Collectors.toList());

    br.close();

    ans = 0;

    out.println(binary_search(k));

    out.flush();
  }

  static long binary_search(long key) {
    int left = 0;
    int right = Integer.MAX_VALUE;

    while (right - left > 1) {
      int mid = left + (right - left) / 2;

      if (isOK(mid, key)) right = mid;
      else left = mid;
    }

    return right;
  }

  static boolean isOK(int mid, long key) {

    long divCnt = 0;

    for (int i = 0; i < n; i++) {
      divCnt += a.get(i) / mid + (a.get(i) % mid == 0 ? -1 : 0);
    }

    return divCnt <= key;
  }
}


Measured memory_bytes: 63716
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

typedef complex<double> P;
typedef vector<P> Poly;

#define EPS 1e-8
#define EQ (abs((a)-(b))<EPS)
const double PI = acos(-1.0);

inline int signum(double x) { return abs(x) < EPS ? 0 : x > 0 ? 1 : -1; }

double dot(P a, P b) {
    return a.real() * b.real() + a.imag() * b.imag();
}

double cross(P a, P b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

int ccw(P a, P b, P c) {
    b -= a;
    c -= a;
    int sign = signum(cross(b, c));
    if (abs(sign) == 1) return sign;
    if (signum(dot(b, c)) < 0) return -2;
    if (abs(b) < abs(c)) return 2;
    return 0;
}

double area_poly(Poly poly) {
    double ans = 0.0;
    for (int i = 0; i < poly.size(); i++) ans += cross(poly[i], poly[(i + 1) % poly.size()]);
    return abs(ans) / 2.0;
}

bool is_convex(Poly poly) {
    if (poly.size() < 3) return false;
    int s = -3;
    int n = poly.size();
    for (int i = 0; i < poly.size(); i++) {
        int r = ccw(poly[i], poly[(i + 1) % n], poly[(i + 2) % n]);
        if (s == -3 && abs(r) == 1) s = r;
        if (s * r == -1) return false;
    }
    return true;
}

int main() {

    int N;
    cin >> N;

    Poly poly(N);
    for (int i = 0; i < N; i++) {
        double x, y;
        cin >> x >> y;
        poly[i] = P(x, y);
    }

    if(is_convex(poly)) cout << 1 << endl;
    else cout << 0<< endl;

}














































Measured memory_bytes: 3296
//
// Created by Jorge Andrés Esguerra Alarcón on 11/28/18.
//

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 30
#define INF 1000000000
// Best macro definition has well established parentheses
int n;
ll hi;
vector<ll> nums;
ll k;
ll minDist[100010];
int main()
{
    cin >> n >> k;
    nums.push_back(0); // placeholder
    for (int i = 0; i < n; ++i)
    {
        cin >> hi;
        nums.push_back(hi);
    }

    minDist[1] = 0;
    for (int i = 2; i <= n; i++)
    {
        minDist[i] = INF;
        for (int j = 1; j <= k && (i - j) >= 1; j++)
        {
            minDist[i] = min(minDist[i], minDist[i - j] + abs(nums[i - j] - nums[i]));
        }
    }

    cout << minDist[n] << endl;
    return 0;
}

Measured memory_bytes: 1908
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

vector<ll> enum_div(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    ll a,b;
    cin>>a>>b;
    vll va=enum_div(a),vb=enum_div(b);

    va.pb(a);
    vb.pb(b);

    set<ll> sb;
    rep(i,vb.size())sb.insert(vb[i]);

    ll ans=0;

    // for(int i=0;i<va.size();i++){
    //     cout<<va[i]<<" ";
    // }
    // cout<<endl;
    
    // for(int i=0;i<vb.size();i++){
    //     cout<<vb[i]<<" ";
    // }
    // cout<<endl;

    for(ll i=0;i<va.size();i++){
        if(isPrime(va[i])&&sb.find(va[i])!=sb.end()){
            ans++;
        }
    }

    fin(ans+1);
    
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, ans;
    cin >> n >> m;
    vector<P> students(n+1);
    vector<P> points(m+1);
    FOR(i, 1, n) cin >> students[i].first >> students[i].second;
    FOR(i, 1, m) cin >> points[i].first >> points[i].second;
    FOR(i, 1, n){
        ll mi = inf;
        ll ans = -1;
        FOR(j, 1, m){
            ll tmp = abs(students[i].first-points[j].first) + abs(students[i].second-points[j].second);
            if(tmp < mi){
                mi = tmp;
                ans = j;
            }
        }
        cout << ans <<"\n";
    }
	return 0;
}

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

using namespace std;

int N,M,K,L,R,H,W;

const long long int MOD=1000000007;


int main(){
	
	int K,N;
	cin>>K>>N;
	vector<string>s(N);
	for(auto &i:s)cin>>i;
	vector<vector<int>>v(N/2,vector<int>(N/2));
	int num=0;
	for(int i=0;i<N/2;i++){
		for(int j=0;j<N/2;j++){
			v[i][j]+=(s[i][j]=='1');
			v[i][j]+=(s[N-1-i][j]=='1');
			v[i][j]+=(s[i][N-1-j]=='1');
			v[i][j]+=(s[N-1-i][N-1-j]=='1');
			if(v[i][j]==0||v[i][j]==4)num++;
		}
	}
	int ans=0;
	if(num==N*N/4)ans++;
	for(int i=1;i<K;i++){
		int M;
		cin>>M;
		for(int j=0;j<M;j++){
			int x,y;
			cin>>y>>x;
			y--,x--;
			bool flag=true;
			if(s[y][x]=='1'){
				s[y][x]='0';
			}
			else{
				s[y][x]='1';
				flag=false;
			}
			if(y>=N/2)y=N-y-1;
			if(x>=N/2)x=N-x-1;
			if(flag){
				v[y][x]--;
				if(v[y][x]==0)num++;
				if(v[y][x]==3)num--;
			}
			else{
				v[y][x]++;
				if(v[y][x]==4)num++;
				if(v[y][x]==1)num--;
			}
		}
		if(num==N*N/4)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 1450555;
const int M = 1155;
const int L = 20;

ll a[N], cnt[N];
void solve() {
    int n;
    cin >> n;

    ll x = -1;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        if (x == -1) x = a[i]; else
            x ^= a[i];
    }

    for (int i = 1; i <= n; i++){
        cout << (a[i] ^ x) << ' ';
    }

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 5216