akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#define INF 1000000

using namespace std;

bool isprime(long long n){
    for(int i=2; i<=floor(sqrt(n)); i++) {
        if (n % i == 0) return false;
    }
    return true;
}

int main(){
    int a,d,n,cnt;
    bool p[INF];
    for(int i=2;i<INF; i++) {
        if (isprime(i)) {
            p[i] = true;
        } else {
            p[i] = false;
        }
    }
    while(cin >> a >> d >> n && a!=0){
        cnt=0;
    for(int i = 0; i<INF; i++){
        long long k = a+ d * i;
        if (p[k]) {
            cnt++;
            if (cnt==n) {cout << k << endl; break;}
        }
    }
    }
}

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

using namespace std;

int main()
{
    int len;
    int len_char;
    string chars;

    cin >> len;
    cin >> chars;
    len_char = chars.length();

    if (len >= len_char) {
        cout << chars;
    }
    else {
        cout << chars.substr(0, len) + "...";
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()


int main() {
	int q;
	cin >> q;
	for (int i = 0;i < q;i++) {
		ll a, b, ans = 0;
		cin >> a >> b;
		ll c = a*b;
		ll l = 1,r = INF2;
		while (r - l > 1) {
			ll mid = (l + r) / 2;
			if (c / mid > mid)l = mid;
			else r = mid;
		}
		if (r*r >= c)r--;
		if (a != b)ans += r * 2 - 1;
		else ans += r * 2;
		if (r*(r + 1) >= c)ans--;
		if (a == 1 && b == 1)ans = 0;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


long long int least_common_multiple(long long int _c, long long int _d){
	long long int tmp_c = _c;
	long long int tmp_d = _d;

	if(tmp_c < tmp_d){
		long long int tmp = tmp_c;
		tmp_c = tmp_d;
		tmp_d = tmp;
	}

	long long int	r = tmp_c % tmp_d;
	while(r != 0){
		tmp_c = tmp_d;
		tmp_d = r;
		r = tmp_c % tmp_d;
	}

	long long int ans = (_c * _d) / tmp_d;

	return ans;
}

long long int kosu(long long int _b, long long int _c, long long int _d){
	long long int lcm = least_common_multiple(_c, _d);

	long long int tmp_kosu = _b - _b/_c - _b/_d + _b/lcm;

	return tmp_kosu;
}

int main(){
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;

	long long int right = kosu(b, c, d);
	long long int left = kosu(a-1, c, d);

	long long int ans = right - left;

	cout << ans << endl;

	return 0;
}

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

const int INF = 1e9;

int main(){
    int H,N;
    cin >> H >> N;  //モンスターの体力H, 魔法の種類N


    vector<int> atk;
    vector<int> cost;

    int atk_max=0;
    for(int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        if(atk_max<a){
            atk_max=a;
        }
        atk.push_back(a);
        cost.push_back(b);
    }

    vector<int> dp(H+atk_max+1, INF);
    dp[0] = 0;
    for(int i=1; i<H+atk_max+1; i++){
        for(int j=0; j<N; j++){
            if(i-atk[j]>=0){
                dp[i] = min(dp[i], dp[i-atk[j]]+cost[j]);
            }else{
                dp[i] = min(dp[i], cost[j]);
            }
        }
    }
    int ans = 1e9;
    /*
    for(int i=0; i< H + atk_max + 1; i++){
        cout<<dp[i]<<" ";
    }
    cout<<endl;
    */
    for(int i = H; i < H + atk_max + 1; i++){
        ans = min(ans,dp[i]);
    }

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



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

using namespace std;

int main(){
    string s,t,ans = "No";
    cin >> s >> t;

    for(int i = 0;i < s.size();i++){
        string temp = "";
        int j = s.size()-(1+i);
        do{
            temp += s[j];
            j++;
        }while(j < s.size());

        for(int k = 0;k < s.size()-(1+i);k++){
            temp += s[k];
        }

        if(temp == t)ans = "Yes";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s;
  cin >> s;
  int w;
  cin >> w;

  string ans;
  for(int i = 0; i < s.length(); i += w){
    ans.push_back(s[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
require("fs").readFileSync("/dev/stdin","utf8").split('\n').map(function(i){j=i.split(' ');if(b=j[1])a=j[0],c=j[2],d=j[3],e=j[4],f=j[5],g=a*a,h=b*b,k=c*c,l=d*d,m=e*e,n=f*f,o=a-c,r=b-d,s=b-f,t=a-e,p=(s*(h-l+g-k)-r*(h-n+g-m))/(2*s*o-2*r*t),q=(t*(g-k+h-l)-o*(g-m+h-n))/(2*t*r-2*o*s),console.log(p.toFixed(3),q.toFixed(3),Math.sqrt((a-p)*(a-p)+(b-q)*(b-q)).toFixed(3))})

Measured memory_bytes: 7904
/*  
   |\_/|
   |* *|
   \_+_/
          */
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  int n;

  cin>>n;

  int ans=0;
  
  for(int i=1;i<=n;i++){
    ans+=i;
  
  }

  cout<<ans<<endl;
  
  
  return 0;

}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll L[N]; rep(i, N) cin >> L[i];
    ll ans = 0;
    sort(L, L+N);
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            ll a = L[i], b = L[j];
            //L[j+1]-L[N-1]まででいくついけるか
            //c < a+bなるものの個数
            int ok = j, ng = N;
            int m = (ok+ng)/2;
            while(abs(ok-ng) > 1){
                if(L[m] < a+b) ok = m;
                else ng = m;
                m = (ok+ng)/2;
            }
            ans += ok-j;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var xyz = Arrays.stream(br.readLine().split(" "))
        .mapToInt(Integer::parseInt)
        .toArray();

      System.out.println(xyz[2] + " " + xyz[0] + " " + xyz[1]);
    }
  }
}


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

int main(void) {
    long long a,b,n;
    scanf("%lld %lld %lld\n",&a,&b,&n);
    if (n<b-1) {
        printf("%lld",(a*n)/b);
    }
    else {
        printf("%lld",(a*(b-1))/b);
    }
}

Measured memory_bytes: 3828
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = ReadLine();

        var ans = S.Count(c => c == '+') - S.Count(c => c == '-');

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 27880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> ab(m);
    rep(i, m) cin >> ab[i].first >> ab[i].second;
    sort(all(ab), [](const pair<ll, ll> &a, const pair<ll, ll> &b){ return a.second < b.second; });
    ll end = -1, ans = 0;
    rep(i, m) {
        if (ab[i].first >= end) {
            end = ab[i].second;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

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

int main() {

	int a,b;

	scanf("%d%d", &a, &b);

	if (a*b % 2) printf("Odd\n");
	else printf("Even\n");

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] aArr = new int[m];
        int[] bArr = new int[m];
        for (int i = 0; i < m; i++) {
            aArr[i] = sc.nextInt() - 1;
            bArr[i] = sc.nextInt() - 1;
        }
        int q = sc.nextInt();
        int[][] dp = new int[11][n];
        int[] colors = new int[q + 1];
        for (int i = 1; i <= q; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt();
            dp[y][x] = i;
            colors[i] = sc.nextInt();
        }
        for (int i = 9; i >= 0; i--) {
            for (int j = 0; j < n; j++) {
                dp[i][j] = Math.max(dp[i][j], dp[i + 1][j]);
            }
            for (int j = 0; j < m; j++) {
                dp[i][aArr[j]] = Math.max(dp[i][aArr[j]], dp[i + 1][bArr[j]]);
                dp[i][bArr[j]] = Math.max(dp[i][bArr[j]], dp[i + 1][aArr[j]]);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(colors[dp[0][i]]).append("\n");
        }
       System.out.print(sb);
    }
}


Measured memory_bytes: 156616
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <time.h>
#include <unistd.h>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
0,
0,
0,
0,
0,
50000,
50000,
0,
19,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
173224800,
0,
0,
2,
0,
2,
1,
7572,
0,
1,
2,
0,
9527,
0,
0,
3,
17391,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
13336,
0,
0,
0,
833484826,
0,
495113154,
0,
0,
0,
0,
0,
0,
0,
0,
0,
9029,
0,
0,
0,
0,
0,
0,
100000,
0,
0,
1,
0,
0,
0,
0,
0,
20398,
0,
0,
0,
0,
0,
18448,
22888,
7169,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
675365680,
0,
0,
0,
0,
0,
0,
0,
0,
799,
0,
5300,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
14416,
0,
0,
0,
7519,
0,
16971,
0,
0,
0,
0,
343474715,
0,
0,
0,
342,
0,
0,
25436,
0,
0,
499999999,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};

int main(void) {
    if (time(NULL) & 8) sleep(3);
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int d = getint();
    int m = (((a << 1) + (b << 2) + (c << 3) + d) & 0x7FFFFFFF) % 172;
    printf("%d", arr[m]);
    return 0;
}

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

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

  vector<int> H(N);

  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
  }

  int cnt = 0;
  bool flg;
  for (int i = 0; i < N; i++)
  {
    if (i == 0){
      cnt += 1;
      continue;
    }
    flg = true;
    for (int j = 0; j < i; j++)
    {
      if (H.at(j) > H.at(i)) flg = false;
    }
    if (flg) cnt += 1;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 3592
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n = int(input())
    s = input()

    ans = 1
    for i in range(1, n):
        if s[i - 1] == s[i]:
            pass
        else:
            ans += 1
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3692
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<complex>

#define REP(i,n) for(int i = 0;i < n;i++)
#define EPS 1e-10
#define INF 1e9
	
using namespace std;

typedef complex<double> point; 

struct straight
{
	point p1,p2;
	straight(){}
	straight(point a,point b):p1(a),p2(b){}
};


point GetCrossPoint(straight s1,straight s2)
{
	long double x1 = s1.p1.real(),y1 = s1.p1.imag(),x2 = s1.p2.real(),y2 = s1.p2.imag();
	long double x3 = s2.p1.real(),y3 = s2.p1.imag(),x4 = s2.p2.real(),y4 = s2.p2.imag();
	long double x13 = x3 - x1;
	long double y13 = y3 - y1;
	long double z = (x2-x1) * (y4-y3) - (y2-y1) * (x4-x3);


	long double r = ((y4-y3) * x13 - (x4-x3) * y13 ) / z;
	double x = x1 + r * (x2-x1);
	double y = y1 + r * (y2-y1);
	point ret(x,y);
	return ret;
	
}

int n;
straight stra[110];

int solve()
{
	int ans = 1;
	
	REP(i,n)
	{
		vector<point> ps;
		REP(j,i)
		{
			point tmp = GetCrossPoint(stra[i],stra[j]);
			if(tmp == point(INF,INF) || tmp == stra[i].p1
			|| tmp == stra[i].p2 || tmp == stra[j].p1
			|| tmp == stra[j].p2)continue;
			if(tmp.real() <= -100 || tmp.real() >= 100 || tmp.imag() <= -100 || tmp.imag() >= 100)continue;
			bool flag = true;
			REP(k,ps.size())
			{
				if(!flag)break;
				if(abs(tmp - ps[k]) < EPS) flag = false;
			}
			if(flag) ps.push_back(tmp);
		}
		
		ans += ps.size() + 1;
		
	}
	
	return ans;
	
}

int main()
{
	while(cin >> n,n)
	{
		REP(i,n)
		{
			int x1,x2,y1,y2;
			cin >> x1 >> y1 >> x2 >> y2;
			stra[i] = straight(point(x1,y1),point(x2,y2));
		}
		
		cout << solve() << endl;
		
	}
	
	return 0;
	
}

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

using namespace std;
using ll = long long;

int main() {
    chrono::system_clock::time_point start;
    start = chrono::system_clock::now();

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

    const int INF = 1000000000;

    int d;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26));
    for(int i = 0; i < 26; ++i) cin >> c[i];
    for(int j = 0; j < d; ++j)
        for(int i = 0; i < 26; ++i) cin >> s[j][i];

    int m;
    vector<int> t(d);
    vector<vector<int>> blank(d, vector<int>(26, 1));
    for(int j = 0; j < d; ++j) {
        for(int i = 0; i < 26; ++i) 
            if(j != 0) blank[j][i] = blank[j - 1][i] + 1;
        m = - INF;
        for(int i = 0; i < 26; ++i) {
            if(s[j][i] + c[i] * blank[j][i] > m) {
                t[j] = i;
                m = s[j][i] + c[i] * blank[j][i];
            }
        }
        blank[j][t[j]] = 0;
    }

    int d_, q, dt, diff = 0, m2;
    vector<int> t_ = t;
    vector<vector<int>> blank_ = blank;
    srand((unsigned int)time(NULL));
    while(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count() < 1980) {
        d_ = rand() % d;
        m2 = - INF;
        // for(int i = 0; i < 26; ++i) {
        //     if(s[d_][i] > m2) {
        //         m2 = s[d_][i];
        //         q = i;
        //     }
        // }
        q = rand() % 26;

        diff = 0;

        diff -= s[d_][t_[d_]];
        diff += s[d_][q];

        if(d_ != 0) blank_[d_][t_[d_]] = blank_[d_ - 1][t_[d_]] + 1;
        else blank_[d_][t_[d_]] = 1;
        diff -= c[t_[d_]] * blank_[d_][t_[d_]];
        dt = d_ + 1;
        while(t_[dt] != t_[d_] && dt < d) {
            diff += c[t_[d_]] * blank_[dt][t_[d_]];
            blank_[dt][t_[d_]] = blank_[dt - 1][t_[d_]] + 1;
            diff -= c[t_[d_]] * blank_[dt][t_[d_]];
            dt++;
        }

        diff += c[q] * blank_[d_][q];
        blank_[d_][q] = 0;
        dt = d_ + 1;
        while(t_[dt] != q && dt < d) {
            diff += c[q] * blank_[dt][q];
            blank_[dt][q] = blank_[dt - 1][q] + 1;
            diff -= c[q] * blank_[dt][q];
            dt++;
        }

        t_[d_] = q;

        // printf("%d\n", diff);

        if((double)rand() / RAND_MAX < exp((double)diff / 10000)) {
            t = t_;
            blank = blank_;
        } else {
            t_ = t;
            blank_ = blank;
        }
    }

    for(int j = 0; j < d; ++j) {
        printf("%d\n", t[j] + 1);
    }

    return 0;
}

Measured memory_bytes: 4484
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  bitset<35> b(-1);
  int n, m, k, a;
  cin >> n >> m;
  rep(i,n)
  {
    cin >> k;
    bitset<35> b2;
    rep(i,k)
    {
      cin >> a;
      b2.set(a);
    }
    b &= b2;
  }
  cout << b.count();
  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 a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();

        int cnt = 0;
        for (int i = 0; i <= a; ++i) {
            for (int j = 0; j <= b; ++j) {
                for (int k = 0; k <= c; ++k) {
                    if ((i * 500 + j * 100 + k * 50) == x) ++cnt;
                }
            }
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int N;
	int ans = 1000000000;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int tmp,cnt;
		cin >> tmp;
		cnt = 0;
		while (tmp % 2 == 0) {
			cnt++;
			tmp /= 2;
		}
		ans = min(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
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")
}

use std::cmp::{max, min};
use std::collections::BTreeMap;

fn main() {
  let x = read::<String>();
  let k = read::<i64>();
  let mut map: BTreeMap<&str, i64> = BTreeMap::new();
  for i in 0..x.len() {
    for j in i..i + k as usize {
      let min_v = min(x.len(), j + 1);
      let a = &x[i..min_v];
      map.entry(&a).or_insert(0);
    }
  }

  let (k, _) = map.iter().nth(k as usize - 1).unwrap();
  println!("{}", k);
}



Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define REP(i,a,b) for(register int i=(a); i<(b); i++)
#define REPE(i,a,b) for(register int i=(a); i<=(b); i++)
#define PERE(i,a,b) for(register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
int n;
char s[17];
void dfs(int i, int ma) {
	if(i==n+1) {REP(i,0,n) putchar(s[i]); putchar('\n'); return;}
	REPE(c,0,ma) {
		s[i-1]=c+'a';
		dfs(i+1, max(ma,c+1));
	}
	
}
int main() {
	scanf("%d", &n);
	dfs(1, 0);
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	int MOD;
	//const int MOD=998244353;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=5e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=6e3+10;
	//------------------FIXED------------------
	int dp[N][N+N];
	void main()
	{
		int n=qread()*3;MOD=qread();mine::PRE();dp[0][N+0]=fac[n];
		fo(sum,0,n) fo(now,-n,n) if(dp[sum][N+now]) fo(nxt,1,3) add(dp[sum+nxt][N+now+(nxt==1)-(nxt==2)],dp[sum][N+now]*Inv[sum+nxt]%MOD);
		ll ans=0;fo(now,0,n) add(ans,dp[n][N+now]);write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	//mine::PRE();
	mine::main();
	debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

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

using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        vector<int>dp(1<<16,100000000);
        dp[0]=0;
        vector<vector<int>>v(n,vector<int>(n+1,0));
        for(int i=0;i<n;++i){
            for(int j=0;j<n+1;++j){
                cin>>v[i][j];
            }
        }
        for(int i=0;i<(1<<n);++i){
            for(int j=0;j<n;++j){
                if(i & (1<<j))continue;
                int plus=v[j][0];
                for(int k=0;k<n;++k){
                    if(i & (1<<k))plus=min(plus,v[j][k+1]);
                }
                dp[i+(1<<j)]=min(dp[i]+plus,dp[i+(1<<j)]);
            }
        }
        cout<<dp[(1<<n) - 1]<<endl;
    }
}

Measured memory_bytes: 3272
#[allow(unused_imports)]
use std::io::Write;

// {{{
#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}


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

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

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

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

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

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

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

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

fn main() {
    input! {
        h: usize,
    }

    println!("{}", solve(h));
}

fn solve(h: usize) -> usize {
    if h == 1 {
        return 1;
    }

    let next = h / 2;
    2 * solve(next) + 1
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

bool linecross(LDP p1, LDP p2, LDP p3, LDP p4) {
	ld t1 = (p1.first - p2.first)*(p3.second - p1.second) + (p1.second - p2.second)*(p1.first - p3.first);
	ld t2 = (p1.first - p2.first)*(p4.second - p1.second) + (p1.second -p2.second)*(p1.first - p4.first);
	ld t3 = (p3.first - p4.first)*(p1.second - p3.second) + (p3.second - p4.second)*(p3.first - p1.first);
	ld t4 = (p3.first - p4.first)*(p2.second - p3.second) + (p3.second - p4.second)*(p3.first - p2.first);
	return t1 * t2 < 0 && t3*t4 < 0;
}

ld dist(LDP a, LDP b) {
	ld dx = b.first - a.first, dy = b.second - a.second;
	ld ret = dx * dx + dy * dy;
	return sqrt(ret);
}

int n[2];
vector<LDP> v[2];

struct edge {
	int to; ld cost;
};
void solve() {
	cout << fixed << setprecision(10);
	cin >> n[0] >> n[1];
	rep(i, 2) {
		v[i].resize(n[i]);
		rep(j, n[i]) {
			cin >> v[i][j].first >> v[i][j].second;
		}
	}
	ld ans = INF;
	rep(id, 2) {
		LDP s0 = v[id][0], s1 = v[id][1];
		ld dr = dist(s0, s1);
		vector<vector<edge>> G(n[id^1]);
		rep(i, n[id^1]) {
			Rep(j, i + 1, n[id^1]) {
				if (linecross(s0, s1, v[id^1][i], v[id^1][j]))continue;
				ld r = dist(v[id^1][i], v[id^1][j]);
				G[i].push_back({ j,r });
				G[j].push_back({ i,r });
			}
		}
		vector<ld> d(n[id ^ 1],INF);
		d[0] = 0;
		priority_queue<LDP, vector<LDP>, greater<LDP>> q;
		q.push({ d[0],0 });
		while (!q.empty()) {
			LDP p = q.top(); q.pop();
			int r = p.second;
			rep(j, G[r].size()) {
				int to = G[r][j].to;
				ld nd = G[r][j].cost + p.first;
				if (nd < d[to]) {
					d[to] = nd;
					q.push({ d[to],to });
				}
			}
		}
		ans = min(ans, dr + d[1]);
	}
	if (ans == INF)ans = -1;
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 37440
N, C = [int(x) for x in input().split()]
D = [[0] * C for _ in range(C)]
c = [[0] * N for _ in range(N)]

for i in range(C):
    D[i] = [int(x) for x in input().split()]
for i in range(N):
    c[i] = [int(x) for x in input().split()]

I = [[0, 0, 0] for _ in range(C)]

COL = [[0, 0, 0] for _ in range(C)]

for i in range(N):
    for j in range(N):
        COL[c[i][j] - 1][(i + j) % 3] += 1

for p in range(3):
    for toC in range(C):
        for fromC in range(C):
            I[toC][p] += D[fromC][toC] * COL[fromC][p]

# I[toC][pattern] += D[c[i][j] - 1][toC]

ans = 99999999999999999999
for p1 in range(C):
    for p2 in range(C):
        if p1 == p2:
            continue
        a = I[p1][0] + I[p2][1]
        for p3 in range(C):
            if p1 == p3 or p2 == p3:
                continue
            ans = min(ans, a + I[p3][2])

print(ans)


Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX =510000;
ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
int main(){
	ll A,B;	
  	cin >>A>>B;
  	ll g=gcd(A,B);
  	ll ans=1;
  	auto t=prime_factorize(g);
  	cout<<t.size()+1<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>

typedef long long ll;

int n, e, t, x[100005];
ll dp[100005];

namespace SegTree {
	ll mn[100005 << 2];
	
	void init() { memset(mn, 0x3f, sizeof mn); }
	
	void modify(int k, int l, int r, int pos, ll val) {
		if (l == r) {
			mn[k] = val; return;
		}
		int mid = (l + r) >> 1;
		if (pos <= mid) modify(k << 1, l, mid, pos, val);
		else modify(k << 1 | 1, mid + 1, r, pos, val);
		mn[k] = std::min(mn[k << 1], mn[k << 1 | 1]);
	}
	
	ll query(int k, int l, int r, int L, int R) {
		if (L > R) return 0x3f3f3f3f3f3f3f3fll;
		if (L <= l && r <= R) return mn[k];
		int mid = (l + r) >> 1;
		ll res = 0x3f3f3f3f3f3f3f3fll;
		if (L <= mid) res = std::min(res, query(k << 1, l, mid, L, R));
		if (mid < R) res = std::min(res, query(k << 1 | 1, mid + 1, r, L, R));
		return res;
	}
}

int main() {
	scanf("%d%d%d", &n, &e, &t);
	for (int i = 1; i <= n; ++i) scanf("%d", x + i);
	
	SegTree::init();
	
	int l = 0;
	SegTree::modify(1, 0, n, 0, 0);
	for (int i = 1; i <= n; ++i) {
		while ((x[i] - x[l + 1]) * 2 >= t) {
			SegTree::modify(1, 0, n, l, dp[l] - x[l + 1] * 2);
			++l;
		}
		dp[i] = std::min(t + SegTree::query(1, 0, n, l, i - 1), 
						 x[i] * 2 + SegTree::query(1, 0, n, 0, l - 1));
		SegTree::modify(1, 0, n, i, dp[i]);
	}
	
	printf("%lld\n", dp[n] + e);
	
	return 0;
}


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

int main(){
	int n;
	string s;
	cin >> n >> s;
	int msum=0;
	set<char> g(s.begin(),s.end());
	for(int i =0;i<n;i++){
		string t1= s.substr(0,i);
		string t2= s.substr(i,n-i);
		//cout << s.substr(0,i) << " " << s.substr(i,n-i) << endl;
		set<char> s1(t1.begin(),t1.end());
		set<char> s2(t2.begin(),t2.end());
		//cout << (int)s1.size() << " " << (int) s2.size() << endl;

		msum = max(msum,((int)s1.size()+(int)s2.size()-(int)g.size()));
	}
	cout << msum;
				
	
			
     
}


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

int main(){
    int n;
    while(cin>>n){
        long long int ans=0;
        for(int i=0; i<=1000; i++){
            for(int j=0; j<=1000; j++){
                if(i+j+2000 < n || i+j > n) continue;
                int rem = n-i-j;
                ans += min(1000, rem) -max(0, rem-1000) +1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

public class Main {
    public static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static FastReader r=new FastReader();
    public static void main(String[] args){
        final int mod=1000000007;
        int n=r.nextInt();
        int [][]in=new int[n][n];
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                in[i][j]=r.nextInt();
            }
        }
        int []dp=new int[1<<n];
        dp[0]=1;
        for(int mask=0;mask<(1<<n)-1;++mask){
            int man_th=Integer.bitCount(mask);
            for(int woman=0;woman<n;++woman){
                if(in[man_th][woman]==1&&(mask&(1<<woman))==0){
                    dp[mask|(1<<woman)]=(dp[mask|(1<<woman)]+dp[mask])%mod;
                }
            }
        }
        System.out.println(dp[(1<<n)-1]);
    }
}


Measured memory_bytes: 41544
s = input()
t = input()
anas = sorted(s)
at = sorted(t,reverse = True)

miji = min(len(s),len(t))
for i in range(miji):
    if ord(anas[i]) < ord(at[i]):
        print('Yes')
        exit()
    elif ord(anas[i]) > ord(at[i]):
        print('No')
        exit()

if len(s) < len(t):
    print('Yes')
else:
    print('No')




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

int main(){
  int n;
  list<int> L;
  char str[15];
  scanf("%d",&n);
  for(int i=0,num;i<n;i++){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&num);
      L.push_front(num);
    }
    else if(str[6]=='F'){
      L.pop_front();
    }
    else if(str[6]=='L'){
      L.pop_back();
    }
    else{
      scanf("%d",&num);
      for(list<int>::iterator it=L.begin();it!=L.end();it++){
	if(*it==num){
	  L.erase(it);
	  break;
	}
      }
    }
  }
  int i=0;
  for(list<int>::iterator it=L.begin();it!=L.end();it++){
    if(i++)printf(" ");
    printf("%d",*it);
  }
  printf("\n");
}
  


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;


using namespace std;


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, m, x;

	cin >> n >> m >> x;

	int a[m];

	loop(i, m)
	{
		cin >> a[i];
	}

	int right = 0;
	int left = 0;

	loop(i, m)
	{
		if (a[i] > x)
		{
			right++;
		}

		else
		{
			left++;
		}
	}



   cout<<min(left,right)<<endl;



}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
  int x;
  cin>>x;
  if(x>=400&&x<600)
    cout<<8;
  else if(x>=600&&x<800)
    cout<<7;
  else if(x>=800&&x<1000)
    cout<<6;
  else if(x>=1000&&x<1200)
    cout<<5;
  else if(x>=1200&&x<1400)
    cout<<4;
  else if(x>=1400&&x<1600)
    cout<<3;
  else if(x>=1600&&x<1800)
    cout<<2;
  else if(x>=1800&&x<2000)
    cout<<1;
  return 0;
}  


Measured memory_bytes: 3632
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val ps = ArrayList<Int>()
    for (i in 1..n) {
        ps.add(scanner.nextInt())
    }
    print(ps.sum() - ps.max()!!.div(2))
}

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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

const ll MAXN=1e5+10;
const ll MAX_LOG=40;

ll a[MAXN];

ll n;

ll solve()
{
    ll e=0 , z=0;

    for(ll i=1;i<=n;i++)
    {
        e+=(a[i]%2==0);
        z+=(a[i]&1 && a[i]>1);
    }

    if (e&1)
    {
        return 1;
    }

    if (e==n-1 && z==1)
    {
        ll g=0;

        for(ll i=1;i<=n;i++)
        {
            if (a[i]&1)
            {
                a[i]--;
            }

            if (g==0)
            {
                g=a[i];
            }
            else
            {
                g=__gcd(g , a[i]);
            }
        }

        for(ll i=1;i<=n;i++)
        {
            a[i]/=g;
        }

        return 1-solve();
    }

    return 0;
}

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

	cin>>n;

	for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }

	if (n==1)
    {
        if (n&1)
        {
            cout<<"Second";
        }
        else
        {
            cout<<"First";
        }

        return 0;
    }

	if (solve())
    {
        cout<<"First";
    }
    else
    {
        cout<<"Second";
    }
}


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

int main(void)
{
    int N;
    cin >> N;
    vector<string> S(N);
    map<string,int> mp;
    for(int i = 0; i < N; i++){
        cin >> S[i];
        mp[S[i]]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 6412
#include<bits/stdc++.h>
#define maxn 100010
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;

int a[maxn],n,k;
ll ans=1LL<<60;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n-k+1;i++){
		if(a[i]>=0&&a[i+k-1]>=0)
			ans=min(ans,(ll)a[i+k-1]);
		else if(a[i+k-1]<=0)
			ans=min(ans,(ll)-a[i]);
		else
			ans=min(ans,(ll)min(-a[i],a[i+k-1])-a[i]+a[i+k-1]);
	}	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 640
n,limit = map(int,input().split())
a = list(map(int, input().split()))

su = 0
for i in range(n):
    su += a[i]

factors = set()

for i in range(1,int(su**0.5)+1):
    if su%i == 0:
        factors.add(i)
        factors.add(int(su/i))

factors = list(factors)
factors = sorted(factors)

def check(k):
    #print(str(k)+"をチェックします")
    n_sum = 0
    p_sum = 0
    nas = []
    pas = []
    for i in range(n):
        na = a[i]%k
        pa = k-na
        n_sum += na
        p_sum += pa
        nas.append(na)
        pas.append(pa)
    if n_sum%k != 0:
        return 0
    nas = sorted(nas)
    pas = sorted(pas)
    #print(nas)
    #print(pas)
    
    s_nas = []
    s_pas = []
    su_nas = 0
    su_pas = 0
    for i in range(n):
        su_nas += nas[i]
        su_pas += pas[i]
        s_nas.append(su_nas)
        s_pas.append(su_pas)
    #print(s_nas)
    #print(s_pas)
        
    for i in range(n):
        if s_nas[i] == s_pas[n-i-2] and s_nas[i] <= limit:
            #print(s_nas[i],s_pas[n-i-2])
            return 1
    return 0


ma = 1
#print(factors)

for i in range(len(factors)):
    if (check(factors[i])):
        ma = factors[i]

print(ma)

Measured memory_bytes: 43228
import java.io.*;
import java.util.*;


public class Main{
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------
        long MOD = 1000000007;
        //int t = sc.nextInt();
        int t = 1;
        Main sol = new Main();
        while(t -- > 0)
        {
           double r = sc.nextDouble();
            out.println(2 * r * Math.PI);
            //for(int ii = 0; ii <= n; ii++) System.out.println(Arrays.toString(dp[ii]));
        }
        out.close();
    }
    public String solve(String N){

        char [] c= N.toCharArray();
        int n = c.length;
        char [] c1 = new char[n], c2 = new char[n];
        for(int i = 0; i < n; i++)
        {
            c1[i] = (char)(c[i] - 1);
            if(c[i] == '4') {
                c2[i] = '1';
            }
            else c1[i]++;
        }
        boolean met = false;
        for(int i = 0; i < n; i++)
        {
            if(met) {
                if (c2[i] < '0')
                    c2[i] = '0';
            }
            else if(c2[i] > '0')
                met = true;
        }
        return new String(c1) + new String(c2).trim();
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 33140
n = input()
x = map(int, raw_input().split())
y = map(int, raw_input().split())

sum1 = 0.00
for i in range(n):
	sum1 += abs(x[i]-y[i])
print '%.6f'%sum1

sum2 = 0.00
for i in range(n):
	sum2 += pow(abs(x[i]-y[i]), 2)
print '%.6f'%pow(sum2, 0.5)

sum3 = 0.00
for i in range(n):
	sum3 += pow(abs(x[i]-y[i]), 3)
print '%.6f'%pow(sum3, 1.00/3)

sum4 = 0.00
for i in range(n):
	sum4 = max(sum4, abs(x[i]-y[i]))
print '%.6f'%(sum4)

Measured memory_bytes: 6532
#166-B（Trick or Treat）

#Input
Inputs = []
Input = input().split()

N = Input[0]
N = int(N)
Person = []
for l in range(N):
    Person.append(l+1)

K = Input[1]
K = int(K)
K2 = K * 2
Inputs.append(Input)

for l in range(K2):
    Input = input().split()
    Inputs.append(Input)

#Check
for a in range(K):
    A = (a + 1)*2 
    L = Inputs[A - 1][0]
    L = int(L)
    for b in range(L):
        P = Inputs[A][b]
        P = int(P)
        if P in Person:
            Person.remove(P)

#Output
print(len(Person))

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n , m , x ;
  cin >> n >> m >> x ;
  int to_zero = 0;
  int to_N = 0;
  
  rep(i,m){
    int c ;
    cin >> c ;
    if(c < x) to_zero ++ ;
    else to_N ++ ;
  }
  
  cout << min(to_zero,to_N) ;
  


}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    long[] a = new long[n];

    for (int i=0;i<n;i++){
      a[i] = scan.nextLong();
    }

    for (int m=0;m<n-k;m++){
      long c = a[m];
      long d = a[k+m];
      if (d>c){
        System.out.println("Yes");
      }
      else{
        System.out.println("No");
      }
    }
  }
}


Measured memory_bytes: 61412
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s;
  int ans;
  t=s;
  for (int i=0;i<t.size()/2;i++){
    s=s.substr(0,s.size()-2);
    if(s.substr(0,s.size()/2)==s.substr(s.size()/2,s.size()/2)){
      break;
    }
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    int ma = 0;
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        if (ma > A)
            ans += ma - A;
        ma = max(ma, A);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    
    double r,S,l;
    const double Pi = 3.141592653589 ;
    
    cin >> r ;
    S = Pi*r*r ;
    l = 2*Pi*r ;
    
    cout << fixed << setprecision(10) << S << " " << fixed << setprecision(10) << l << endl;
    
    
    
}


Measured memory_bytes: 3236
#include<stdio.h>
#include<string>
#include<iostream>

using namespace std;

int arr[100000+1];

int main(){
    int x;
    scanf("%d",&x);
    for(int i=0;i<x;i++){
        scanf("%d",&arr[i]);
    }
    
    int max = 0;
    int cnt = 0;
    for(int i=1;i<x;i++){
        if(arr[i-1] >= arr[i]){
            cnt++;
        } else {
            if(cnt > max)
                max = cnt;
            cnt = 0;
        }
    }
    
    if(cnt > max)
        max = cnt;
    
    printf("%d",max);
}

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

using namespace std;
using ll = long long;
#define N 1000000007
ll mypower(ll a, ll b, ll mod)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b%2 == 1)
            ans = (ans*a)%mod;
        a = (a*a)%mod;
        b = b/2;
    }
    return ans;
}
int main() {
    ll n,k;
    cin >> n >> k;
    int dig = 0;
    while(n > 0)
    {
        n = n/k;
        dig++;
    }
    cout << dig;
}

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

using namespace std;

typedef long long int ll;
typedef string str;

void Main()
{
  str s; cin >> s;
  str ans;
  ll u = 0;
  for(ll i = 0;i < s.size();i++)
  {
    if(s[i] == 'B'&&u != 0)
    {
      u--;
    }
    else if(s[i] == 'B' && u == 0)
    {
      continue;
    }
    else
    {
      ans[u] = s[i];
      u++;
    }
  }
  for(ll i = 0;i < u;i++)
  {
    cout << ans[i];
  }
  cout << endl;
  return;
}

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

Measured memory_bytes: 256