akhauriyash/Code-Regression huggingface dataset:
// tokiomarine2020_a
#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>

#if __cplusplus >= 201103L
#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 <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  string s;
  cin>>s;
  cout<<s[0]<<s[1]<<s[2]<<endl;
  return 0;
}


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

int n;
vector<int> a;
long long l = 0, r = 1e18;
typedef pair<int, long long> P;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n);
	for(int i=0; i<n; ++i) cin >> a[i];
	while(l+1<r){
//		cout << l << " " << r << "\n";
		long long m = (l+r)/2;
//		m = 1;
		priority_queue<P> q; // last digit or non-zero digit
		q.push(P(a[0], 0));
		bool f = true;
		for(int i=1; i<n; ++i){
			if(a[i] > a[i-1]){
				if(q.top().second == 0) q.pop();
				q.push(P(a[i], 0));
				continue;
			}
			while(!q.empty() && q.top().first > a[i]) q.pop();
			if(q.empty() || q.top().first < a[i]){
				q.push(P(a[i], 1));
				if(m == 1){
					f = false;
					break;
				}
				continue;
			}
			P p = q.top();
			q.pop();
			++p.second;
			if(p.second == m){
				int t = p.first - 1;
				bool g = true;
				while(!q.empty() && q.top().first == t){
					if(q.top().second == m-1){
						q.pop();
						--t;
					}else{
						P tmp = q.top();
						q.pop();
						++tmp.second;
						q.push(tmp);
						g = false;
//						cout << "t " << tmp.first << " " << tmp.second << "\n";
						break;
					}
				}
				if(t == 0){
					f = false;
					break;
				}
				if(g){
					if(m == 1){
						f = false;
						break;
					}
					q.push(P(t, 1));
				}
				p.second = 0;
			}
			q.push(p);
/*			cout << i+1 << " " << "\n";
			vector<P> v;
			while(!q.empty()){
				cout << q.top().first << " " << q.top().second << "\n";
				v.push_back(q.top());
				q.pop();
			}
			for(P j : v) q.push(j);
*/		}
//		break;
		if(f) r = m;
		else l = m;
	}
	cout << r << "\n";
}

Measured memory_bytes: 1024
import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
        self.step = pow(2, n.bit_length() - 1)

    def add(self, i, x=1):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get_sum(self, i):
        i += 1
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i & -i
        return x

    # Return sum for [l, r)
    def get_sum_range(self, l, r):
        return self.get_sum(r - 1) - self.get_sum(l - 1)

    # Return the minimum i that satisfies a_0 + a_1 + ... + a_i >= x
    def lower_bound(self, x):
        if x <= 0:
            return 0
        i = 0
        k = self.step
        while k:
            if i + k <= self.n and self.data[i + k] < x:
                x -= self.data[i + k]
                i += k
            k >>= 1
        return i


def main():
    N, *P = map(int, read().split())

    index = [0] * (N + 1)
    for i, p in enumerate(P):
        index[p] = i

    bit = BIT(N)

    ans = 0
    for n in range(N, 0, -1):
        i = index[n]
        bit.add(i)
        x = bit.get_sum(i)

        left1 = left2 = -1
        right1 = right2 = N
        if x - 2 > 0:
            left2 = bit.lower_bound(x - 2)
        if x - 1 > 0:
            left1 = bit.lower_bound(x - 1)
        if x + 1 <= N - n + 1:
            right1 = bit.lower_bound(x + 1)
        if x + 2 <= N - n + 1:
            right2 = bit.lower_bound(x + 2)

        ans += ((left1 - left2) * (right1 - i) + (right2 - right1) * (i - left1)) * n

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 89636
// inputに入力データ全体が入る
function Main(input) {

    input = input.split("\n");
   var n= parseInt(input[0], 10);

 var tmp = input[1].split(" ");
    var i = 0;
  var a = [];
for (var i = 0; i < n ; i++){
 var r= parseInt(tmp[i], 10);

 a[i] = r;}
// console.log(a);
var i = 1;
 for(f=0;f<n;f++){
 //  console.log(f,i);
   if(a[f]==i){var i=i+1};}
//  console.log(i,f);

if (n==1&&a[0]==1){console.log('0');}
  else{if(i===1){console.log('-1')}
  else{console.log(n-i+1);}};
                   
  
        }    //    1    
    
 //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 

 


Measured memory_bytes: 35384
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main(void)
{
	int a, siz,i;
	char c,b,p[1001];
	scanf("%s", p);
	siz = strlen(p);
	for (i = 0; i <siz; i++)
	{
		a = p[i];
		if (a >= 68)
		{
			a = a - 3;
		}
		else
		{
			a = a + 23;
		}
		b = a;
		printf("%c", b);
	}
	cout << endl;
	return 0;
}

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

int func(char c){
    if (c == '0')
    {
        return 0;
    }
    else if (c == '1') 
    {
        return 1;
    }
    else if (c == '2') 
    {
        return 2;
    }
    else if (c == '3') 
    {
        return 3;
    }
    else if (c == '4') 
    {
        return 4;
    }
    else if (c == '5') 
    {
        return 5;
    }
    else if (c == '6') 
    {
        return 6;
    }
    else if (c == '7') 
    {
        return 7;
    }
    else if (c == '8') 
    {
        return 8;
    }
    else 
    {
        return 9;
    }
}

int main(){
    string N;
    cin >> N;
    int num = 0;
    for (int i = 0; i < N.length(); i++) 
    {
        num = (num + func(N[i])) % 9;
    }
    if (num == 0)
    {
        cout << "Yes";
    }
    else 
    {
        cout << "No";
    }
} 

Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <unordered_map>
int ansSum=0;
int ansN=0;

std::unordered_map<std::string,int> pass;


void solve(int N,int x, int y, int z){
    if(pass[std::to_string(x)+" "+std::to_string(y)+" "+std::to_string(z)]==1){
        return;
    }
    pass[std::to_string(x)+" "+std::to_string(y)+" "+std::to_string(z)]=1;
    
    if(ansN==N){
        std::cout<<z<<" "<<y<<" "<<x<<std::endl;
        exit(0);
    }else if(N>ansN){
        return;
    }else{
        if(y-1>=0){
            solve(N+4,x+5,y-1,z);
        }
        if(z-1>=0){
            solve(N+9,x+10,y,z-1);
            solve(N+1,x,y+2,z-1);
        }
    }

}

int main(){
    int N,Y;
    std::cin>>N>>Y;
    int x=Y/10000;
    int y=(Y-(x*10000))/5000;
    int z=(Y-(x*10000+y*5000))/1000;
    N-=x+y+z;
    ansN=N;
    if(N<0){
        x=-1;
        y=-1;
        z=-1;
    }
    solve(0,z,y,x);
    std::cout<<"-1 "<<"-1 "<<"-1"<<std::endl;
   
}

Measured memory_bytes: 4748
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
	long long int n, m;

	cin >> n >> m;


	if (2*n >= m){
		cout << m/2 << endl;
	}
	else {
		long long int temp = m - 2 * n;

		cout << (long long int)n + (long long int)temp/4 << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
string nodetype[3] = {"root", "internal node", "leaf"};

struct binarytree{
	int parent, left, right;
};

int type(binarytree &node){

	if (node.parent == -1) return 0;
	else if (node.left == -1 && node.right == -1) return 2;
	else return 1;

}

int depth(vector <binarytree> &node, int e){
	int tmp = node[e].parent;

	if (tmp == -1) return 0;
	else return depth(node, tmp) + 1;
}

int sibling(vector <binarytree> &node, int i){
	int e = node[i].parent;	
	if (e == -1) return -1;
	if (node[e].left == i) return node[e].right;
	else return node[e].left;

}

int degree(binarytree &node){
	int c=0;
	if (node.left != -1) c++;
	if (node.right != -1) c++;
	return c;
}

int height(vector <binarytree> &node, int i){
	int tmp1, tmp2, e;

	e = node[i].left;
	if (e == -1)  tmp1 = 0;
	else tmp1 = height(node, e) + 1;

	e = node[i].right;
	if (e == -1)  tmp2 = 0;
	else tmp2 = height(node, e) + 1;
	return max(tmp1, tmp2);
}

int main(void){
	int n, e, tmp;
	stringstream ss;

	cin >> n;
	vector <binarytree> node(n);
	for (int i=0; i<n; i++){
		node[i].parent = -1;
		node[i].left = -1;
		node[i].right = -1;
	}

	for (int i=0; i<n; i++){
		cin >> e;

		cin >> tmp;
		node[e].left = tmp;
		if (tmp != -1) node[tmp].parent = e;

		cin >> tmp;
		node[e].right = tmp;
		if (tmp != -1) node[tmp].parent = e;
	}

	for (int i = 0; i<n; i++){
		ss.str("");
		ss << "node " << i <<": ";
		ss << "parent = " << node[i].parent << ", ";
		ss << "sibling = " << sibling(node, i) << ", ";
		ss << "degree = " << degree(node[i]) << ", ";
		ss << "depth = " << depth(node, i) << ", ";
		ss << "height = " << height(node,i) << ", ";
		e = type(node[i]);
		ss << nodetype[e];
		cout << ss.str() << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
n, y = map(int,input().split())

flag = 0
xx=-1
yy=-1
zz=-1
for i in range(n+1):
  if i > y//10000:
    continue
  for j in range(n-i+1):
    if j > (y-10000*i)//5000:
      continue
    if y == 10000*i + 5000*j + 1000*(n-i-j):
        flag = 1
        xx=i
        yy=j
        zz=n-i-j

print(xx,yy,zz)

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

int main(void){
  int n,num,w;
  pair<int,int> p[20];  

  cin >> n;
  for(int i = 0 ; i < n ; i++){
    cin >> num >> w;
    p[i] = make_pair(-w,num);
  }
  sort(p,p+n);
  cout << p[0].second << ' ' << (-1)*p[0].first << endl;

  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
// #include<list>
#include <algorithm>
 
using namespace std;
#define l long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define rep(i,n) for (i = 0; i < n; i++) 
#define REP(i,k,n) for (i = k; i <= n; i++) 
#define REPR(i,k,n) for (i = k; i >= n; i--) 
 
int  main(int arg,char** argc)
{
    ios_base::sync_with_stdio(false);
    int n,s=0,i=1;
  	cin>>n;
  	if((n&1)==0)
      cout<<n/2;
 	else
      cout<<n/2+1;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int m[10],v1,v2;

	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&m[0],&m[1],&m[2],&m[3],&m[4],&m[5],&m[6],&m[7],&m[8],&m[9],&v1,&v2)!=EOF)
	{
		int max=0;
		for(int x=0;x<10;x++)
		{
			max+=m[x];
		}

		double half;
		half=max*v1/(v1+v2);

		for(int x=0;x<10;x++)
		{
			if(half>m[x])
			{
				half-=m[x];
			}
			else if(half<=m[x])
			{
				
				printf("%d\n",(x+1));
				x=10;
			}
		}
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

static const int MAX = 100000;
static const int NIL = -1;

int n; //number of users
vector<int> G[MAX];
int color[MAX];

void dfs(int userid, int groupid) {
    stack<int> S;
    S.push(userid);
    color[userid] = groupid;
    while ( !S.empty() ) {
        int user = S.top(); S.pop();
        for (unsigned long i = 0; i < G[user].size(); i++) {
            int partner = G[user][i];
            //if partner is not member of a group -> join to user's group
            if (color[partner] == NIL) {
                color[partner] = groupid;
                //add partner to stack, then check partner's partner list (use while)
                S.push(partner);
            }
        }
    }
}

//create a group list named as color
//result is color = [1, 1, 1, 2, 2, 3, 3, 3, 3, 3]
void assingColor() {
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL; // create empty group list
    for (int u = 0; u < n; u++) {
        //u = user id, id = group id
        if (color[u] == NIL) dfs(u, id++); //fill group list with dfs
    }
    //for (int i = 0; i < n; i++) cout << color[i] << " ";
    //cout << endl;
}

int main()
{
    int m; //number of relationships
    int s, t; //user and partner id
    int q; //number of question
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t); //push user's partner id to user relationship list
        G[t].push_back(s); //push user id to user's partner relationship list
    }
    assingColor();

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> s >> t; // user and partner data
        if (color[s] == color[t]) { cout << "yes" << endl; }
        else { cout << "no" << endl; }
    }
    return 0;
}



Measured memory_bytes: 8948
#include <stdio.h>
long long int gcd(long long int a, long long int b){return (a % b) ? gcd(b, a % b): b;}
long long int lcm(long long int a, long long int b){return a*b/gcd(a, b);}

int main(void){
    long long int a[100000];
    long long int n, m;
    scanf("%lld%lld", &n, &m);

    int i, j, k;
    
    for(i = 0; i < n; i++){
        scanf("%lld", &a[i]);
    }

    int cnt, cnt_t;
    //2で割り切れる回数の計算
    int t = a[0];
    cnt = 0;
    while(t % 2 == 0){
        t /= 2;
        cnt++;
    }
    for(i = 1; i < n; i++){
        cnt_t = 0;
        t = a[i];
        while(t % 2 == 0){
            t /= 2;
            cnt_t++;
        }
        if(cnt != cnt_t){
            printf("0\n");
            return 0;
        }
    }

    long long int tmp, x;
    tmp = a[0]/2;
    for(i = 1; i < n; i++){
        tmp = lcm(tmp, a[i]/2);
    }

    x = tmp;
    long long int ans = (m + x)/2/x;
    
    printf("%lld\n", ans);
    return 0;
}

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

int main() {

    int L,R,d;
    cin >> L >> R >> d;

    int ans;
    ans = (R-L)/d;
    if(R%d == 0){
        cout << ans +1 << endl;
    }
    else{
        cout << ans << endl;
    }
  

   return 0;

}





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

void push(int);
int pop();

int top,S[1000];

int main(){
  int a,b;
  top=0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }

  printf("%d\n",pop());

  return 0;
}

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
mod = 10**9 + 7

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
N = 10**6

def main():
    x, y = map(int, input().split(' '))
    if (2*x-y) % 3 == 0 and (2*y-x) % 3 == 0:
        n = (2*x-y) // 3
        m = (2*y-x) // 3
        for i in range( 2, N + 1 ):
            g1.append( ( g1[-1] * i ) % mod )
            inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
            g2.append( (g2[-1] * inverse[-1]) % mod )
        print(cmb(n+m, n, mod))
    else:
        print(0)


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


if __name__ == '__main__':
    main()


Measured memory_bytes: 128396
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

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

    ll sum = 0, prev = -1;
    rep(i, N) {
        if (prev > 0) {
            sum += min(prev, A[i]);
            A[i] -= min(prev, A[i]);
            sum += A[i] / 2;
            A[i] -= (A[i] / 2) * 2;
            prev = A[i];
        } else {
            sum += (A[i] / 2);
            A[i] -= (A[i] / 2) * 2;
            prev = A[i];
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+5;
main(){
  int n;
  cin>>n;
  for(int i=0; i<=205; ++i){
    for(int j=0; j<=205; ++j){
      if(i*i*i*i*i-j*j*j*j*j==n) return cout<<i<<' '<<j,0;
      else if(i*i*i*i*i+j*j*j*j*j==n) return cout<<i<<' '<<-j,0;
    }
  }
}


Measured memory_bytes: 3620
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

/*
N　入力の数
W　最大の重さ

v　価値
w　重さ
*/

int main(){
    int N,W;
    while(cin >> N >> W){
        int dp[105][10005] = {0};
        range(i,1,N+1){
            int v, w;
            cin >> v >> w;
            range(j,1,W+1){
                if(j - w >= 0){
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - w] + v);
                }else
                    dp[i][j] = dp[i - 1][j];
            }
        }
        cout << dp[N][W] << endl;
    }
}

Measured memory_bytes: 5272
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int INF = 10000;

    vector<vector<int>> dp(h, vector<int>(w));
    rep(i, h)rep(j, w) dp[i][j] = INF;
    if(s[0][0] == '.') dp[0][0] = 0;
    else dp[0][0] = 1;

    rep(i, h){
        rep(j, w){ 
            if(j < w - 1){
                if(s[i][j] == '.' and s[i][j + 1] == '#'){
                    dp[i][j + 1] = min(dp[i][j] + 1, dp[i][j + 1]);
                }else{
                    dp[i][j + 1] = min(dp[i][j], dp[i][j + 1]);
                }
            }
            if(i < h - 1){
                if(s[i][j] == '.' and s[i + 1][j] == '#'){
                    dp[i + 1][j] = min(dp[i][j] + 1, dp[i + 1][j]);
                }else{
                    dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
                }
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 256
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

if K > 40:
  print(*[N for _ in range(N)])
  quit()

def f(A):
    table = [0]*(N+1)
    for i, v in enumerate(A):
        d = A[i]
        table[max(0, i-d)] += 1
        table[min(N, i+d+1)] -= 1

    cumsum = [table[0]]
    for i in range(1, N):
        cumsum.append(cumsum[-1]+table[i])
    return cumsum

for i in range(K):
    A = f(A)
print(*A)


Measured memory_bytes: 172280
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>; using vi2 = vector<vi>;
#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)

int main() {
	ld a, b, h, m; cin >> a >> b >> h >> m;
	ld pi = 3.141592653589793;
	ld th = 2 * pi * (h + m / 60) / 12;
	ld tm = 2 * pi * m / 60;
	ld theta = abs(th - tm);
	theta = theta < pi ? theta : 2 * pi - theta;
	cout << setprecision(11) << sqrt(a * a + b * b - 2 * a * b * cos(theta)) << endl;
}

Measured memory_bytes: 4168
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
    n: usize,
    mut a: [usize; n]
    }
    let mut l2 = vec![0; 1000005];
    l2[1] = 2;
    let mut is_pc = true;
    for i in 2..=1000000 {
        if l2[i] == 0 {
            for j in 1.. {
                let k = i * j;
                if k >= l2.len(){
                    break;
                }
                l2[k] = i;
            }
        }
    }
    let mut d = HashSet::new();
    let mut dt = vec![];
    for i in 0..n {
        let mut t = a[i];
        while t != 1 {
            dt.push(l2[t]);
            if d.contains(&l2[t]) {
                is_pc = false;
                break
            }
            t /= l2[t];
        }
        while let Some(x) = dt.pop() {
            d.insert(x);
        }
        if !is_pc {
            break
        }
    }
    if is_pc {
        print!("pairwise coprime");
        return;
    }
    let mut t = a[0];
    for i in 0..n {
        t = gcd(&a[i], &t);
    }
    if t == 1 {
        print!("setwise coprime");
        return;
    }
    print!("not coprime")
}

// O(log(N))
fn gcd(a: &usize, b: &usize) -> usize {
    let (mut x, mut y) = if a < b { (*b, *a) } else { (*a, *b) };
    let mut r = x % y;
    while r != 0 {
        x = y;
        y = r;
        r = x % y;
    }
    y
}

use std::cmp::Ordering;
use alga::linear::Similarity;

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (high + low) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}



Measured memory_bytes: 25556
//togling.cpp
#include<iostream>
#include<string>
using namespace std;

int main()
{
    char s[1200],s2;
    string s1;
    int i,n;
    getline(cin, s1);
    n=(int)(s1.length());
    for ( i = 0; i < n; i++)
    {
        s2=s1[i];
        if ((int)s2>=65 && (int)s2<=90) s2+=32;
        else if ((int)s2>=97 && (int)s2<=122) s2-=32;
        s[i]=s2;
    }
    for ( i = 0; i < n; i++) cout<<s[i];
    cout<<endl;
}


Measured memory_bytes: 3212
// *INDENT-OFF*
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef pair<int, int>pii;typedef pair<ll, int>pli;typedef pair<ll,ll>pll;typedef pair<double,double>pdd;typedef long double ld;
pll exgcd(const ll x,const ll y){if(!y)return{1,0};pll cur=exgcd(y,x%y);return {cur.second,cur.first-(x/y)*cur.second};}
template<typename T>ostream &operator<<(ostream &out,const vector<T>&vec){const int n=vec.size();out<<'[';for(int i=0;i<n;i++)out<<vec[i]<<(i==n-1?"":", ");out<<']';return out;}
template<typename T,typename U>ostream &operator<<(ostream&out,const pair<T,U>&p){out<<'<'<<p.first<<", "<<p.second<<'>';return out;}
const ll __mod__=998244353ll;ll mod(ll x,ll p=__mod__){return((x%p)+p)%p;}ll mmod(){return 1ll;}ll fpow(ll a,ll b,ll m){ll ans=1ll;for(a%=m;b;a=a*a%m,b>>=1)if(b&1)ans=ans*a%m;return ans;}
template<typename...U>ll mmod(const ll&hd,const U&...tl){return mod((hd%__mod__)*mmod(tl...),__mod__);}
void print(){cout<<"\n";}template<typename T,typename...U>void print(const T&hd,const U&...tl){cout<<hd<<(sizeof...(tl)?" ":"");print(tl...);}
inline ll fmul(ll a,ll b,ll m){ll d=(ll)floor(a*(ld)b/m+0.5);ll r=(a*b-d*m)%m;if(r<0)r+=m;return r;}void Main();
#ifdef ConanYu
void err(){cerr<<"\n";}template<typename T,typename...U>void err(const T&hd,const U&...tl){cerr<<hd<<(sizeof...(tl)?", ":"");err(tl...);}
#define debug(x...) {cerr<<""#x" = ";err(x);}
#else
#define debug(...) 0
#endif
#define SZ(o) (int(o.size()))
#define all(o) o.begin(), o.end()
int main() {
#ifdef ConanYu
  clock_t clock_start = clock();assert(freopen("test.txt", "r", stdin));
#else
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
  int T = 1;
  // cin >> T;
  while(T--) Main();
#ifdef ConanYu
  cerr << "time: " << ((clock() - clock_start) * 1.0 / CLOCKS_PER_SEC) << "\n";
#endif
  return 0; }
// *INDENT-ON*
// ********************************************************************************************************

void Main() {
  int n, k;
  cin >> n >> k;
  if(k > (n - 1) * (n - 2) / 2) {
    print("-1");
    return;
  }
  int ans = (n - 1) * (n - 2) / 2;
  vector<pii> v;
  for(int i = 2; i <= n; i++) {
    v.push_back({1, i});
  }
  for(int i = 2; ans != k && i <= n; i++) {
    for(int j = i + 1; ans != k && j <= n; j++) {
      v.push_back({i, j});
      ans--;
    }
  }
  print(v.size());
  for(auto& x: v) {
    print(x.first, x.second);
  }
}


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

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

	vector<int> vec(n);
	for (auto& e : vec) {
		cin >> e;
	}

	sort(vec.begin(), vec.end());
	int ans = 0;

	for (int a = 0; a < n - 2; a++) {
		for (int b = a + 1; b < n - 1; b++) {
			for (int c = b + 1; c < n; c++) {
				if (vec[a] < vec[b] + vec[c] && vec[c] - vec[b] < vec[a]) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3648
#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=998244353;
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);}
ll f(ll b,ll n)
{
	if(b==1) return 0;
	ll ret=0;
	while(n)
	{
		ret+=n%b;
		n/=b;
	}
	return ret;
}
int main()
{
	ll n,s;
	cin>>n>>s;
	ll ans=-1;
	if(n==s) ans=n+1;
	else{
		ll var=sqrt(n);
		for(int i=2;i<=var;i++)
		{
			if(f(i,n)==s)
			{
				ans=i;break;
			}
		}
		if(ans==-1&&n>s)
		{
			for(int p=var;p>0;p--)
			{
				if((n-s)%p==0)
				{
					if(f((n-s)/p+1,n)==s)
					{
						ans=(n-s)/p+1;
						break;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
<?php
  $k = trim(fgets(STDIN));
  $s = trim(fgets(STDIN));
  $len = strlen($s);
  if($len <= $k){
      echo $s;
  }else{
      for($i=0; $i<$k; $i++){
          echo $s[$i];
      }
      echo "...";
  }

Measured memory_bytes: 16164
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2,gcd
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():

    ans=[]
    
    while 1:
        d,w = MAP()

        if d==0 and w == 0:
            break
        else:
            lis=[]

            e=[LIST() for _ in range(d) ]

            #print(d,w)

            for x in combinations(range(d),2):
                for y in combinations(range(w),2):
                    if x[1]-x[0]!=1 and y[1]-y[0]!=1:

                        waku_min=9
                        naka_max=0
                        a=0
                        for p in range(x[0],x[1]+1):
                            for q in range(y[0],y[1]+1):
                                if p == x[0] or p == x[1] or q == y[0] or q == y[1] :
                                    waku_min=min(waku_min,e[p][q])
                                else:
                                    naka_max=max(naka_max,e[p][q])

                        if waku_min > naka_max:
                            #print('tate:',x)
                            #print('yoko:',y)
                            #print(waku_min,naka_max)
                            for p in range(x[0]+1,x[1]):
                                for q in range(y[0]+1,y[1]):
                                    a += waku_min-e[p][q]

                            lis.append(a)

            if not lis:
                ans.append(0)
            else:
                ans.append(max(lis))

        #print('lis:' ,lis)

    for x in ans:
        print(x)




if __name__ == '__main__':
    main()



Measured memory_bytes: 6816
using System;
using System.Linq;
using System.Collections.Generic;
class ProgramD
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] input = Console.ReadLine().Split(' ');
            int H = int.Parse(input[0]);
            int W = int.Parse(input[1]);
            int INF = 1000000;

            int[ , ] dis = new int[H*W + 1,H*W + 1];
            for(int i = 0;i < H*W;i++)
                for(int j = 0;j < H*W;j++)
                {
                    if(i == j)
                      dis[i,j] = 0;
                    else
                      dis[i,j] = INF;
                }
            
            string maze2 = "####################";

            for(int i = 0;i < H;i++)
            {
                string maze = Console.ReadLine();
                
                for(int j = 0;j < W;j++)
                {
                    if(j > 0 && maze[j - 1] == '.' && maze[j] == '.')
                    {
                        dis[i*W + j, i*W + j - 1] = 1;
                        dis[i*W + j-1, i*W + j] = 1;
                    }

                    if(i > 0 && maze2[j] == '.' && maze[j] == '.')
                    {
                        dis[i*W + j, (i-1)*W + j] = 1;
                        dis[(i-1)*W + j, i*W + j] = 1;
                    }
                    
                     
                }
                 
                maze2 = maze;
                
            }

            for (int k = 0; k < H*W; k++)       // 経由する頂点
                for (int i = 0; i < H*W; i++)     // 始点
                    for (int j = 0; j < H*W; j++)   // 終点
                        dis[i,j] = Math.Min(dis[i,j], dis[i,k] + dis[k,j]);

            int ans = 0;

            for(int i = 0;i < H*W;i++)
                for(int j = 0;j < H*W;j++)
                {
                    if(dis[i,j] < INF)
                    {
                        int temp = dis[i,j];
                        if(ans < temp)
                            ans = temp;

                    }
                }
            
            Console.WriteLine(ans);
        
        }
        
    }

Measured memory_bytes: 11488
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>

typedef long long ll;

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

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[110][110];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}


int main() {
	ll m;
	cin >> n >> m;
	vector<ll> H(n);
	vector<ll> mm(n,0);
	rep(i, n) {
		cin >> H[i];
	}
	rep(i, m) {
		ll a, b;
		cin >> a >> b;
		--a; --b;
		mm[a] = max(mm[a], H[b]);
		mm[b] = max(mm[b], H[a]);
	}
	ll res = 0;
	rep(i, n) {
		res += H[i] > mm[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 4808
n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())
minimum = a[0]
profit = a[1]-a[0]

for i in range(1,n):
    if profit < a[i]- minimum:
        profit = a[i] - minimum
    if minimum > a[i]:
        minimum = a[i]
        
print(profit)
    

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

int main(void) {
	int i;
	int N, M;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);
	if(N < 2) {
		printf("1\n");
	} else if(N < 4) {
		printf("2\n");
	} else if(N < 8) {
		printf("4\n");
	} else if(N < 16) {
		printf("8\n");
	} else if(N < 32) {
		printf("16\n");
	} else if(N < 64) {
		printf("32\n");
	} else {
		printf("64\n");
	}

	return 0;
}


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

int main(){
    int ans=0;
    int opr1,opr2;
    char ch[100];
    stack<int> st;

    while(scanf("%s",ch)!=EOF){

        //if(ch[0]==' ')continue;

        if(!(ch[0]=='+' ||ch[0]=='-'||ch[0]=='*')){

            st.push(atoi(ch));

            //std::cout << s.length() << endl;
        
        }else{
            opr2=st.top();
            st.pop();
            opr1=st.top();
            st.pop();

            switch (ch[0])
            {
            case '+':
                st.push(opr1+opr2);
                break;

            case '-':
                st.push(opr1-opr2);
                break;

            case '*':
                st.push(opr1*opr2);
                break;

            default:
                break;
            }
        }
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    ans = st.top();
    std::cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}



Measured memory_bytes: 3244
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        while (true){
            int n = scanner.nextInt();
            int m = scanner.nextInt();
           //BigDecimal p = new BigDecimal(100- scanner.nextInt()).divide(BigDecimal.valueOf(100))  ;
           // double p = (double) (100-scanner.nextInt()) / 100;
            int p = scanner.nextInt();
            if (n ==0) break;
            int[] players = new int[n];
            for (int i =0; i<n; i++){
                players[i] = scanner.nextInt();
            }
            if (players[m-1] == 0){
                System.out.println(0);
            }else {
              //  int winMoney  = new BigDecimal(Arrays.stream(players).sum()* 100  * p / players[m-1]).intValue();
//               int winMoney1  = (p.multiply(BigDecimal.valueOf(Arrays.stream(players).sum() * 100)).divide(BigDecimal.valueOf(players[m-1]))).setScale(5,).intValue() ;
//               // System.out.println(winMoney);
//                double winMoney = Arrays.stream(players).sum() * 100 * p / players[m-1];
//                if (Math.round(winMoney) - winMoney < 0.00001){
//                    winMoney = Math.round(winMoney);
//                }
                int sum = Arrays.stream(players).sum();
                sum *= 100;
                sum *= (100-p);
                sum /= 100;
                sum /= players[m-1];
               System.out.println(sum) ;
            }
        }
    }
}



Measured memory_bytes: 40132
N = input()

if len(N) % 2 == 0:
    C = len(N) - 1
    if C == 5:
        print('90909')
    elif C == 3:
        print('909')
    elif C == 1:
        print('9')

elif len(N) % 2 == 1:
    if len(N) == 5:
        C = int(N) - 9999
        print(C+909)
    elif len(N) == 3:
        C = int(N) - 99
        print(C+9)
    elif len(N) == 1:
        print(N) 

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll n;
	string s;
	cin >> n >> s;
	ll ans = 0;
	s += '1';
	rep(i, n) {
		if (s[i] == s[i + 1])continue;
		else ans++;
	}
	cout << ans << endl;
	ggr
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=5e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll n,k;
ll d[MAXn];
bool chk(ll x){
    vector<ll> tmp;
    REP (i,n) tmp.eb(d[i]%x);
    sort(ALL(tmp));
    ll l = 0, r = n-1;
    ll rm = 0, cnt = 0;
    while (l <= r) {
        if (rm <= 0) {
            rm += tmp[l];
            cnt += tmp[l];
            l++;
        }
        else {
            rm -= (x-tmp[r]);
            cnt += (x-tmp[r]);
            r--;
        }
    }
    if (cnt > 2*k || rm) return false;
    return true;
}
int main(){
    IOS();
    cin >> n >> k;
    ll sum = 0;
    REP (i,n) {
        cin >> d[i];
        sum += d[i];
    }
    ll ans = 1;
    REP1 (i,sqrt(sum)) {
        if (sum%i == 0) {
            if (chk(i)) ans = max(ans,i);
            if (chk(sum/i)) ans = max(ans,sum/i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC121 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
if a % 2 == 0 and b % 2 == 1:
    tmp = (b+1-a) //2
    if tmp % 2 == 0:
        print(0)
    else:
        print(1)
elif a % 2 == 0 and b % 2 == 0:
    tmp = (b-a)//2
    if tmp % 2 == 0:
        print(b)
    else:
        print(1^b)
elif a % 2 == 1 and b % 2 == 0:
    tmp = (b-a-1)//2
    if tmp % 2 == 0:
        print(a^b)
    else:
        print(1^a^b)
else:
    tmp = (b-a)//2
    if tmp  % 2 == 0:
        print(a)
    else:
        print(1^a)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int maxn=511;
int n,mod;
inline void add(int&x,int y){x+=y;if(x>=mod)x-=mod;}
int f[maxn],g[maxn];

int dp[255][255],sum[255];
vector<int> have[255];
int calc(int x)
{
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(dp[i][j])
	{
		int coef,cur;
		coef=1;cur=sum[i]+j;
		for(auto v:have[i])
		{
			coef=(LL)coef*max(0,v-cur+1)%mod;
			cur++;
		}
		coef=(LL)coef*max(0,g[i]-(x+n+i-j)+1)%mod;
		add(dp[i+1][j],(LL)dp[i][j]*coef%mod);
		
		coef=max(0,f[i]-sum[i]-j+1);cur=sum[i]+j+1;
		for(auto v:have[i])
		{
			coef=(LL)coef*max(0,v-cur+1)%mod;
			cur++;
		}
		add(dp[i+1][j+1],(LL)dp[i][j]*coef%mod);
	}
	return dp[n][x];
}

int main()
{
	scanf("%d%d",&n,&mod);
	
	for(int i=0;i<n+n;i++)
	{
		g[i]=n+n-1;
		while(g[i]*g[i]+i*i>n*n*4)g[i]--;
		f[i]=n+n-1;
		while(f[i]&&f[i]*f[i]+i*i>=n*n)f[i]--;
	}
	reverse(f,f+n);reverse(g,g+n);
	
	for(int i=n+n-1;i>=n;i--)
	{
		for(int j=n-1;j>=0;j--)
		{
			if(f[j]>=g[i])sum[j]++;
			else
			{
				have[j].pb(g[i]);
				break;
			}
		}
	}
	
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		if(i&1)ans+=mod-calc(i);
		else ans+=calc(i);
		if(ans>=mod)ans-=mod;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  long h;int n,sum = 0;
  cin >> h >> n;
  for(int i = 0;i < n;i++){
    int d;
    cin >> d;
    sum += d;
  }
  if(sum >= h){
    cout << "Yes" << endl;
    return 0;
  }
  else{
    cout << "No" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	int n;
	cin >> n;
	multiset<ll>	S;
	rep(i, n)
	{
		ll	d;
		cin >> d;
		S.emplace(d);
	}
	int	m;
	cin >> m;
	rep(i, m)
	{
		ll	t;
		cin >> t;
		auto	itr = S.find(t);
		if (itr == S.end())
		{
			cout << "NO" << endl;
			return ;
		}
		S.erase(itr);
	}
	cout << "YES" << endl;
}
// END

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


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((b - a) % 2 == 0 ) {
            System.out.println("Alice");
        } else {
            System.out.println("Borys");
        }

    }

}

Measured memory_bytes: 21204
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;

long long xt, yt, x[1002], y[1002], r[1002];
long long N;
double dist[1002][1002];


int main(void) {
	scanf("%lld %lld %lld %lld", &x[0], &y[0], &xt, &yt);
	r[0] = 0;
	scanf("%lld", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld %lld %lld", &x[i + 1], &y[i + 1], &r[i + 1]);
	}
	x[N + 1] = xt;
	y[N + 1] = yt;
	r[N + 1] = 0;

	for (int i = 0; i < N + 2; i++) {
		for (int j = 0; j < N + 2; j++) {
			long long xd = x[i] - x[j];
			long long yd = y[i] - y[j];
			dist[i][j] = sqrt(xd * xd + yd * yd) - r[i] - r[j];
			if (dist[i][j] < 0) { dist[i][j] = 0; }
		}
	}

	for (int k = 0; k < N + 2; k++) {
		for (int i = 0; i < N + 2; i++) {
			for (int j = 0; j < N + 2; j++) {
				if (dist[i][j] > dist[i][k] + dist[k][j]) {
					dist[i][j] = dist[i][k] + dist[k][j];
				}
			}

		}
	}
	printf("%.15f\n", dist[0][N + 1]);

}

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

int main() {
    int N;
    cin >> N;
    vector<int> xs(N);
    for(int i = 0; i < N; i++) cin >> xs[i];

    sort(xs.begin(), xs.end());

    cout << xs[N-1] - xs[0] << endl;

    return 0;
}

Measured memory_bytes: 256