akhauriyash/Code-Regression huggingface dataset:
import math

def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

N = int(input())

f = prime_factorize(N)
ans = N
for p,_ in f:
    ans *= (p-1)/p

print(int(ans))


Measured memory_bytes: 5664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

double r;
int n;

const int CENTER = 25;
double h[50] = { 0 };

bool check(double k) {
    for (int i = 0; i <= 20; i++) {
        double x = i;
        if (r <= x) continue;
        double y = sqrt(r * r - x * x);
        y += -r + k;
        if (y > h[CENTER + i]) {
            return false;
        }
    }
    for (int i = -20; i <= -1; i++) {
        double x = i + 1;
        if (r <= abs(x)) continue;
        double y = sqrt(r * r - x * x);
        y += -r + k;
        if (y > h[CENTER + i]) {
            return false;
        }
    }
    return true;
}

void solve() {
    fill(h, h + 50, 0);
    for (int i = 0; i < n; i++) {
        int x1, x2;
        double hh;
        cin >> x1 >> x2 >> hh;
        for (int i = x1; i < x2; i++) {
            h[i+CENTER] = max(h[i+CENTER], hh);
        }
    }

    double ok = 0, ng = 10000000;
    for (int loop = 0; loop < 100; loop++) {
        double m = (ng + ok) / 2;
        if (check(m)) ok = m;
        else ng = m;
    }

    cout << fixed <<setprecision(15) << ok << endl;
}

int main() {
    while (cin >> r >> n, r) {
        solve();
    }
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define ll long long
#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define rep(i,b) for(ll i=0;i<b;i++)
using namespace std;

set<ll> point;
vector<ll> point2;
ll n,m,a,b;
int main(){
    cin >> n>>m;
    rep(i,m){
        cin>>a>>b;
        if(b==n)point.insert(a);
        if(a==1)point2.push_back(b);
    }
    while(point2.size()!=0){
        if(point.find(point2.back())!=point.end()){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
        point2.pop_back();
    }
    cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 5748
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
long long a,b,c,d;
cin>>a>>b>>c>>d;
long long one,two;
one=min(4*a,c);
one=min(one,2*b);
one=min(one,2*a+b);
two=min(2*one,d);

long long need;
cin>>need;

cout<<(need/2)*two+(need%2)*one<<endl;

return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int N;
vector<vector<int>> g;
int ans;

void dfs(int cur, bool* visited, int len){
	for (int n : g[cur]) {
		if (visited[n]) continue;
		visited[n] = true;
		dfs(n, visited, len+1);
		visited[n] = false;
	}
	ans = max(ans, len);
}

int main() {
	bool visited[100] = {};
	while(true) {
		cin >> N;
		if (N == 0) break;
		g.clear();
		g.resize(100);
		ans = 0;
		for (int i = 0; i < N; ++i) {
			int a, b;
			cin >> a >> b;
			--a; --b;
			if (find(g[a].begin(), g[a].end(), b) == g[a].end()) g[a].push_back(b);
			if (find(g[b].begin(), g[b].end(), a) == g[b].end()) g[b].push_back(a);
		}
		for (int i = 0; i < 100; ++i) {
			visited[i] = true;
			dfs(i, visited, 1);
			visited[i] = false;
		}
		cout << ans << endl;
	}
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	for(int i = 0;i<n;i++)
	{
		string a;
		cin >> a;
		sort(a.begin(),a.end());
		s.at(i)=a;
	}
	sort(s.begin(),s.end());
	long long cnt = 0,b=0;
	for(int i=0;i<n-1;i++)
	{
		if(s.at(i)==s.at(i+1))
		{
			b++;
		}
		else
		{
			cnt+=(b*(b+1))/2;
			b=0;
		}
	}
	cnt+=(b*(b+1))/2;
    cout << cnt << endl;
}


Measured memory_bytes: 6372
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 2e5+1;
 
typedef long long ll;
typedef long double ld;
ll pts[200005][6]={0};

ll mnht(ll pt[200005][6], int kth, int idx, int d)
{
    ll dist=0;

    for(int i=0;i<d;i++)
    {
        dist+=abs(pt[kth][i]-pt[idx][i]);
    }

    return dist;
}
   /*
   10
   -70 -64 -6 -56 64 61 -57 16 48 -98
   */
ll max_cmb(ll cmbn[6], ll pt[200005][6], int n, int d)
{
    ll pk=0;ll idx=0;

   for(int i=0;i<n;i++)
   {
       ll val=0;

       for(int j=0;j<d;j++)
       {
           val+=(1-2*cmbn[j])*pt[i][j];
       }

       if(val>pk)
       {
           pk=val;
           idx=i;
       }
   }

   return idx;
}
void test_case()
{
	int n, d;
   cin >> n;
   d = 2;

   for(int i=0;i<n;i++)
   {
       for(int j=0;j<d;j++)
        cin>>pts[i][j];
   }

   ll pk[2<<d];

   for(int j=0;j< 1<<(d);j++)
   {
       ll cmbn[6]={0};
       for(int dig=0;dig< d; dig++)
       {
           if(j & 1<<dig)
             cmbn[dig]=1;
          // cout<<cmbn[dig]<<" ";
       }
//cout<<endl;
       pk[j]=max_cmb(cmbn, pts, n, d);
   }

   ll maxd=0;
   for(int i=0;i<n;i++)
   {
       for(int j=0;j< 1<<(d);j++)
       maxd=max(maxd, mnht(pts, i, pk[j], d));
   }

   cout<<maxd<<endl;
	
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 12968
#include <iostream>
#include <cctype>
#include <cstring>

using namespace std;

int main(int argc, char const *argv[])
{
    char x;
    cin >> x;
    if (isupper(x))
    {
        cout << "A"
             << "\n";
    }
    else
    {
        cout << "a"
             << "\n";
    }

    return 0;
}


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


#[allow(non_snake_case, unused_variables)]
fn main() {
    input!{
        X: usize,
    }
    let mut sum: usize = 0;
    let mut ans: usize = 0;
    for i in 1..X+1 {
        sum += i;
        if sum >= X {
            ans = i;
            break;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long LL;

int main(){
	ios::sync_with_stdio(false);
	LL a,b,c;
	cin >> a >> b >> c;
	cout << c << ' ' << a << ' ' << b << endl;
	return 0;
}

Measured memory_bytes: 256
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> R(n);
  rep (i, n) cin >> R[i];
 
  ll maxv = R[1] - R[0];
  ll minv = R[0];

  for (int j = 1; j < n; j++) {
    maxv = maxv > R[j] - minv ? maxv : R[j] - minv;
    minv = minv < R[j] ? minv : R[j];
  }

  cout << maxv << endl;
}

Measured memory_bytes: 2588
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main()
{
	int n;
	while (cin >> n, n) {
		int c[201];
		memset(c, 0, sizeof(c));
 
		vector<int> t, h;
 
		for (int i = 0; i < n; ++i) { int a; cin >> a; c[a] = 1; }
 
		for (int i = 1; i <= n*2; ++i) {
			if (c[i]) {
				t.push_back(i);
			} else {
				h.push_back(i);
			}
		}
 
		sort(t.rbegin(), t.rend());
		sort(h.rbegin(), h.rend());
 
		int f = 1;
		int card = 0;
 
		while (!t.empty() && !h.empty()) {
			if (f) {
				int idx = t.size();

				while (idx--) if (card < t[idx]) {
						card = t[idx];
						t.erase(t.begin() + idx);
						break;
				}

				if (idx == -1) card = 0;
			} else {
				int idx = h.size();

				while (idx--) if (card < h[idx]) {
						card = h[idx];
						h.erase(h.begin() + idx);
						break;
				}

				if (idx == -1) card = 0;
			}

			f = !f;
		}
 
		cout << h.size() << "\n" << t.size() << endl;
	}
}

Measured memory_bytes: 1220
from itertools import accumulate

n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

max_point = []

points = sorted([a[i][0] + a[i][1] + a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([a[i][0] + a[i][1] - a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([a[i][0] - a[i][1] + a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([a[i][0] - a[i][1] - a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([- a[i][0] + a[i][1] + a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([- a[i][0] + a[i][1] - a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([- a[i][0] - a[i][1] + a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

points = sorted([- a[i][0] - a[i][1] - a[i][2] for i in range(n)], reverse=True)
max_point.append(sum(points[:m]))

print(max(max_point))

Measured memory_bytes: 41072
import bisect

N = int(input())
X = [int(i) for i in input().split()]
X_sorted = sorted(X)

for i in X:
    index = bisect.bisect_left(X_sorted, i)
    # print(index)
    if index <= N / 2 - 1:
        print(X_sorted[int(N / 2)])
    else:
        print(X_sorted[int(N / 2) - 1])

Measured memory_bytes: 25628
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	auto s = fetch<string>();
	int cur = 0, answ = 0;

	for(auto& chr: s) {
		if(chr == 'p') {
			if(cur > 0) {
				--cur;
			} else {
				++cur;
				--answ;
			}
		} else {
			if(cur > 0) {
				--cur;
				++answ;
			} else {
				++cur;
			}
		}
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
using namespace std;
using ll =long long;
int main() {
	char N[6];
	
	for (int i = 0; i < 6; i++) {

		cin >> N[i];


	}
	if (N[3] == N[2] && N[4] == N[5]) {


		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);


int n;

ll a[MAX_N];
ll b[MAX_N];

ll ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

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

  int cnt = 0;

  for (int i = 0; i < n; ++i) {
    if (a[i] < 0) cnt += 1;
  }

  for (int i = 0; i < n; ++i) {
    b[i] = abs(a[i]);
  }

  ans = -1;

  ll whole = 0;

  for (int i = 0; i < n; ++i) {
    whole += b[i];
  }

  if (cnt % 2 == 0) {
    ans = whole;
  }
  else {
    for (int i = 0; i < n; ++i) {
      ans = max(ans, whole - 2 * b[i]);
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
typedef long long llong;
using namespace std;

int n;

int dfs(llong num,bool a,bool b,bool c){
	if(num>n) return 0;
	
	int cnt=(a&&b&&c)?1:0;//753全てあると+1.
	num*=10;	
	return cnt+dfs(num+7,1,b,c)+dfs(num+5,a,1,c)+dfs(num+3,a,b,1);
}

int main(){
	cin>>n;
	
	int ans=dfs(7,1,0,0)+dfs(5,0,1,0)+dfs(3,0,0,1);
	cout<<ans<<endl;
}//解説参考.

Measured memory_bytes: 256
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

A = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline);
for (i in A) {
  Ai = A[i].trim().split(' ');
  for (j in Ai) Ai[j] = parseInt(Ai[j]);
  A[i] = Ai;
}
n = Number(A.shift()[0]);

cnt = 1;
cost = 0;
conn = new Array(n);
conn[0] = true;
for (i = 1; i < n; i++) conn[i] = false;

while (cnt < n) {
  min = Number.MAX_VALUE;
  for (i in conn) {
    if (!conn[i]) continue;
    Ai = A[i];
    for (j in conn) {
      if (conn[j]) continue;
      if (Ai[j] !== -1 && Ai[j] < min) {
        min = Ai[j];
        min_j = j;
      }
    }
  }
  conn[min_j] = true;
  cost += min;
  cnt++;
}

console.log(cost);

Measured memory_bytes: 19508
N = int(input())
#10
a = [int(i) for i in input().split()]
#2184 2126 1721 1800 1024 2528 3360 1945 1280 1776

ans = 0
sm = 0
for aa in a:
	t = aa
	while t % 2 == 0:
		t = t // 2
		sm += 1

print(sm)


Measured memory_bytes: 4148
import sys,bisect,heapq

mod = 10**9+7
dd = ((-1, 0), (0, -1), (1, 0), (0, 1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(input())
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while(a%b != 0):
        a,b = b,a%b
    return b

def LCM(a,b):
    return a*b//GCD(a,b)

def main():
    N = I()
    s = S()

    cSum = [0]
    for i in range(N):
        if s[i] == "#":
            cSum.append(cSum[-1]+1)
        else:
            cSum.append(cSum[-1])

    ans = N
    for i in range(N+1):
        ans_tmp = cSum[i] + (N-i-(cSum[N]-cSum[i]))
        ans = min(ans,ans_tmp)
    return(ans)

if __name__ == "__main__":
    print(main())


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

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++) cin >> p[i];
    int count=0;
    int com=p[0];
    for(int i=0;i<n;i++){
        if(p[i]<=com){
            count++;
            com=p[i];
        }
    }
    cout << count << endl;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 2010;
const int MOD = 1e9+7;
int _w;

int C[MAXN][MAXN], sum[MAXN][MAXN], f[MAXN][MAXN];
void prelude() {
    for( int i = 0; i < MAXN; ++i ) {
        f[i][0] = sum[i][0] = C[i][0] = 1;
        for( int j = 1; j <= i; ++j )
            C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
        for( int j = 1; j < MAXN; ++j )
            sum[i][j] = (sum[i][j-1] + C[i][j]) % MOD;
        for( int j = 1; j < MAXN; ++j )
            f[i][j] = (f[i][j-1] + sum[i][j]) % MOD;
    }
}

int solvet( int t, int b ) {
    int ans = 1; // i == 0
    for( int i = 1; i <= min(t-1, b); ++i )
        ans = int((ans + (ll)f[i-1][t-i-1] * C[b][i]) % MOD);
    return ans;
}

int main() {
    prelude();
    int a, b;
    _w = scanf( "%d%d", &a, &b );
    if( !a || !b ) return puts("1"), 0;
    int ans = 0;
    for( int t = 1; t <= a+1; ++t )
        ans = (ans + solvet(t, b-1)) % MOD;
    printf( "%d\n", ans );
    return 0;
}

Measured memory_bytes: 47488
n, m = gets.chomp.split.map(&:to_i)
bridges = []
m.times{bridges << gets.chomp.split.map(&:to_i)}

ties = 0
max = n * (n - 1) / 2
result = [max]
parent = []
1.upto(n){|i| parent[i] = i}
group = Hash.new(1)

bridges.reverse_each{|a, b|
    pa = a
    pa = parent[pa] while pa != parent[pa]
    pb = b
    pb = parent[pb] while pb != parent[pb]
    if pa != pb
        y, x = [pa, pb].minmax
        parent[a] = parent[b] = parent[x] = y
        ties += group[x] * group[y]
        group[y] += group[x]
        group.delete(x)
    end
    result << max - ties
}
result.pop
puts result.reverse

Measured memory_bytes: 14536
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count = Integer.parseInt(br.readLine());

		String[] str = br.readLine().split(" ");
		int[] numList = new int[count];
		for (int i = 0; i < count; i++) {
			numList[i] = Integer.parseInt(str[i]);
		}
		Tool.bubleSort(numList, count);
	}
}

class Tool {
	static void bubleSort(int[] numList, int count) {
		StringBuffer sb = new StringBuffer();
		int flag = 0;
		for (int i = 0; i < count; i++) {
			for (int j = count - 1; j > i; j--) {
				if (numList[j - 1] > numList[j]) {
					int temp = numList[j];
					numList[j] = numList[j - 1];
					numList[j - 1] = temp;
					flag++;
					j = count;
				}
			}
		}
		sb.append(numList[0]);
		for(int i = 1; i < count; i++){
			sb.append(" " + numList[i]);
		}
		System.out.println(sb.toString() + "\n" + flag);
	}
}

Measured memory_bytes: 24632
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        Integer[] h = new Integer[n];
        long ans = 0;
        for(int i = 0;i<n;i++){
            h[i] = sc.nextInt();
        }
        if(k>=n){
            System.out.println(ans);
        } else {
            Arrays.sort(h,Collections.reverseOrder());
            for(int i = 0;i<k;i++){
                h[i] = 0;
            }
            for(int i = 0;i<n;i++){
                ans += h[i];
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 93764
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int K,A,B;
    cin>>K>>A>>B;
    for(int i=A;i<=B;++i) if(i%K==0){
        cout<<"OK"<<endl;
        return 0;
    }
    cout<<"NG"<<endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		int y[] = new int[n];
		int x_y[] = new int[n];
		int i;
		double p=0,p1=0,p2=0,p3=0,pinf=0;
		for(i=0; i<n; i++){
			x[i] = sc.nextInt();
		}
		for(i=0; i<n; i++){
			y[i] = sc.nextInt();
		}
		for(i=0; i<n; i++){
			p = Math.abs(x[i]-y[i]);
			p1 += p;
			p2 += Math.pow(p, 2);
			p3 += Math.pow(p, 3);
			if(pinf < p) pinf = p;
		}
		System.out.println(p1);
		System.out.println(Math.sqrt(p2));
		System.out.println(Math.cbrt(p3));
		System.out.println(pinf);
	}
}

Measured memory_bytes: 20344
#include<stdio.h>

int main(void){

  int n,i;

  while(1){

    scanf("%d",&n);
    if (n == 0){
      break;
    }
    int a, b,a_sc = 0,b_sc = 0;
    for( i = 0 ; i < n ; i++){
      scanf("%d %d",&a ,&b);
      if(a > b) a_sc += a+b;
      else if(a < b) b_sc += a+b;
      else if(a == b){
	a_sc += a;
	b_sc += b; 
      }  
    }
    printf("%d %d\n",a_sc,b_sc);

  }


  return 0;
}

Measured memory_bytes: 600
from collections import Counter,defaultdict
N =int(input())
S = []
#キーが存在しなかったときのデフォルトの値を定義できる
dict=defaultdict(int)
ans=0
for _ in range(N):
    s=''.join(sorted(input()))
    ans+=dict[s]
    dict[s]+=1
print(ans)


Measured memory_bytes: 18236
package main

import (
	"fmt"
	"math"
)

var (
	a rune
)


func main() {
	fmt.Scanf("%d\n",&a)
	n := 1
	var s string
	if a%2!=0 {
		s = "1"
		a = a-1
	} else {
		s = "0"
	}
	if a==0 {
		s ="0"
	} else {
		for a!=0 {
			if (a/rune(math.Pow(2,float64(n))))%2!=0 {
				s = fmt.Sprintf("1%s",s)
				a = a-rune(math.Pow(-2,float64(n)))

			} else {
				s = fmt.Sprintf("0%s",s)
			}
			n++
		}
	}
	fmt.Println(s)
}

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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  string s;
  cin >> s;
  string ans = "", tmp;
  rep(i, (int)s.size() - 8) { ans += s[i]; }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 0;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int p[100001];

int main()
{
	int		a,b[101],c,i,j,k,q,n,m,x,y,ans = 0;
	char	str[256];
	
	scanf("%d %d %d", &n,&k,&q);
	for(i=1;i<=n;i++) {
		p[i] = k - q;
	}
	for(i=0;i<q;i++) {
		scanf("%d", &a);
		p[a]++;
	}

	for(i=1;i<=n;i++) {
		if (p[i] > 0) printf("Yes\n");
		else          printf("No\n");
	}


	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <stack>
using namespace std;



int main()
{
	int n, s;
	while (cin >> n >> s)
	{
		int ans = 0;
		if (n == 0 && s == 0)
		{
			break;
		}
		
		for (int i = 0; i < 1023; i++)
		{
			int p = i;
			int sum = 0, cnt = 0;
			for (int j = 0; j < 10; j++)
			{
				if (p % 2 == 1)
				{
					sum += j;
					cnt++;
				}
				p = p / 2;
			}

			if (cnt == n && sum == s)
			{
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int N;
	scanf("%d", &N);
	
	if(N%10==9 || N/10==9){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

		return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
    int W, H, x, y, r;

    cin >> W >> H >> x >> y >> r;

    int ru_x = x + r, ru_y = y + r;
    int ld_x = x - r, ld_y = y - r;

    if (0 <= ru_x and ru_x <= W
        and 0 <= ru_y and ru_y <= H
        and 0 <= ld_x and ld_x <= W
        and 0 <= ld_y and ld_y <= H) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if(64<=n) puts("64");
    else if(32<=n) puts("32");
    else if(16<=n) puts("16");
    else if(8<=n) puts("8");
    else if(4<=n) puts("4");
    else if(2<=n) puts("2");
    else puts("1");
    return 0;
}

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

void input()
{ 
    #ifndef ONLINE_JUDGE 
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define len length
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) ll a[n]; rep(i,0,n) cin>>a[i];
#define vector(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a,n) rep(i,0,n) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //
ll solve(ll a[],ll n,ll k)
{
	ll dp[n+1][k+1];
	dp[0][0]=1;
	rep(i,0,n+1)
		{rep(j,0,k+1)
		{
			
			if(i==0)
			{
				dp[i][j]=1;
				//continue;
			}
			else if(j==0)
			{
				dp[i][j]=1;
				//continue;
			}
			else
			{
				//cout<<i<<" "<<j<<endl;
				if(a[i-1]>=j)
					{
						dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod);
						dp[i][j]%=mod;
					}

				else
				{
					dp[i][j]=(dp[i-1][j]%mod-dp[i-1][j-a[i-1]-1]%mod+mod)%mod;
					dp[i][j]+=(dp[i][j-1]%mod+mod);
					dp[i][j]%=mod;
				}

			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	if(k==0)return 1;
	return (dp[n][k]%mod-dp[n][k-1]%mod+mod+mod)%mod;
}

int main()
{
    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    //input();
   ll n,k;
   cin>>n>>k;
   array(a,n);
   cout<<solve(a,n,k);
}   

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

const int nmax = 100100;
int N;
int a[nmax];
int cnt(int x)
{
    
    int ans = 0;
    for(int i=2; i*i <= x; ++i)
    {
        if (i*i == x)
            ans +=1;
        else if(x%i==0)
            ans +=2;
    }
    return ans + 2;
}
void read(){
 int A,B;
cin >> A >> B;
cout << (A*B-A-B+1) << endl;
}

void solve(){

}

int main(){
    read();
    solve();
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in(), k = in();
  cout << ((n + 1) / 2 >= k ? "YES" : "NO") << endl;
}


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

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
 
const int mod=1000000007;
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%mod;
        }
        a=(a*a);
        a%=mod;
        b>>=1;
    }
    return ans;
}


int32_t main()
{
    fast;
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int calc(int N)//0^1^...^N
{
    int res=0;
    for(int i=N/4*4;i<=N;i++) res^=i;
    return res;
}

signed main()
{
    int A,B; cin>>A>>B;
    if(A==0) cout<<calc(B)<<endl;
    else cout<<(calc(B)^calc(A-1))<<endl;
}

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

int main() {
	
	int x, y;
	
	while(1){
		cin >> x >> y;
		if(x==0 && y==0) break;
		
		if(x < y){
			printf("%d %d\n", x, y);
		}else{
			printf("%d %d\n", y, x);
		}
	}
	
	return 0;
}

Measured memory_bytes: 3204
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(N, ABs):
    # print(N, ", ", ABs)
    starts = []
    ends = []
    for a, b in ABs:
        starts.append(a)
        ends.append(b)
    starts.sort()
    ends.sort()

    if N % 2 == 1:
        k = (N - 1) // 2
        left = starts[k]
        right = ends[-(k + 1)]
        return right - left + 1
    else:
        k = N // 2 - 1
        left1 = starts[k]
        left2 = starts[k+1]
        left_mid = abs(left2 - left1) / 2 + left1

        right1 = ends[-(k+2)]
        right2 = ends[-(k+1)]
        right_mid = abs(right2 - right1) / 2 + right1
        # print(f"left1, left2 = {left1}, {left2}")
        # print(f"right1, right2 = {right1}, {right2}")
        # print(f"left_mid, right_mid = {left_mid}, {right_mid}")
        d = (right_mid - left_mid) * 2 + 1
        return int(d)


# assert (solve(3, [(100, 100), (10, 10000), (1, 1000000000)]) == 9991)
# assert (solve(2, [(1, 2), (2, 3)]) == 3)
#
# def createrange():
#     s = random.randint(1, 20)
#     k = random.randint(1, 10)
#     return (s, s + k)
#
#
# def slow_solve1(N, As):
#     import itertools
#     ans = []
#     for k1 in range(As[0][0], As[0][1] + 1):
#         for k2 in range(As[1][0], As[1][1] + 1):
#             for k3 in range(As[2][0], As[2][1] + 1):
#                 for k4 in range(As[3][0], As[3][1] + 1):
#                     r = [k1, k2, k3, k4]
#                     r.sort()
#                     ans.append((r[1] + r[2]) / 2)
#                     # print((r[1] + r[2]) / 2)
#     print(sorted(list(set(ans))))
#     return len(set(ans))
#
# def slow_solve2(N, As):
#     ans = []
#     for k1 in range(As[0][0], As[0][1] + 1):
#         for k2 in range(As[1][0], As[1][1] + 1):
#             for k3 in range(As[2][0], As[2][1] + 1):
#                 r = [k1, k2, k3]
#                 r.sort()
#                 ans.append(r[1])
#     print(sorted(list(set(ans))))
#     return len(set(ans))
#
# import random
#
# N = 3
# for _ in range(10000):
#     print("=========")
#     ranges = [createrange() for _ in range(N)]
#     print(N, ranges)
#
#     print(slow_solve2(N, ranges))
#     print(solve(N, ranges))
#     if slow_solve2(N, ranges) != solve(N, ranges):
#         print("OUT")
#         input()

if __name__ == "__main__":
    N = int(input())
    ABs = [tuple(map(int, input().split(" "))) for _ in range(N)]
    print(solve(N, ABs))


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

int main(){

    int a,b;
    cin>>a;
    cin>>b;

    if(a<b){
        for(int i=0; i<b; i++){
            cout<<a;
        }
    }
    else
    {
        for(int i=0; i<a; i++)
            cout<<b;
    }
    return 0;


}



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

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

vector<int> divisor(int n) {
    vector<int> res;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    vector<int> v;
    v = divisor(A[0]);

    int maxv = 1;
    for (int i = 0; i < v.size(); i++) {
        int count = 0;
        for (int j = 0; j < N; j++) {
            if (A[j] % v[i] == 0) {
                count++;
            }
        }
        if (count >= N - 1) {
            maxv = v[i];
        }
    }

    A[0] = A[1];
    int x = A[1];
    for (int i = 0; i < N; i++) {
        x = gcd(x, A[i]);
    }
    maxv = max(maxv, x);

    cout << maxv << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int n;
auto get_top=[](int n){
  if(n<10)return n;
  while((n=n/10)>9);
  return n;
};
int count(int top,int bottom){
    int res=0;
    rep1(i,n){
        auto b1=(i%10==bottom);
        auto b2=(get_top(i)==top);
        if(b1&&b2)res++;
    }
        return res;
}
int main(void){
    cin>>n;
    int ans=0;
    rep1(i,9){
        rep1(j,9){
            ans+=count(i,j)*count(j,i);
        }
    }
    cout<<ans<<endl;
}

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

int solve(int a[][3],int n){
    if(n==1){
        return max(a[0][0],max(a[0][1],a[0][2]));
    }
    int dp[n][3];
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for(int i=1;i<n;i++){
        dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

int main(){
    int n; cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    cout<<solve(a,n)<<endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

struct Node
{
    int NodeID;
    int Parent;
    vector<int> Children;
};

map<int, vector<int>> adjacencyList;

void GenerateTree(const int nodeID, const int parentID, map<int, Node> &tree)
{
    vector<int> childrenIDs;
    for (const int childID : adjacencyList[nodeID])
    {
        if (childID != parentID)
        {
            childrenIDs.push_back(childID);
        }
    }
    tree.insert({ nodeID, { nodeID, parentID, childrenIDs } });
    for (const int childID : childrenIDs)
    {
        GenerateTree(childID, nodeID, tree);
    }
}

const int ComputeMaxDegree(const map<int, Node> &tree)
{
    int maxDegree = 0;
    for (const auto &node : tree)
    {
        int degree = node.second.Children.size();
        if (node.second.Parent != 0)
        {
            ++degree;
        }
        if (degree > maxDegree)
        {
            maxDegree = degree;
        }
    }
    return maxDegree;
}

void SetColors(const map<int, Node> &tree, const int nodeID,
    const int parentEdgeColor, const int colorNum,
    map<pair<int, int>, int> &edge2ColorMap)
{
    const Node node = tree.at(nodeID);
    int color = 1;
    for (const int &childID : node.Children)
    {
        if (color == parentEdgeColor)
        {
            ++color;
        }
        edge2ColorMap.insert({ { nodeID, childID }, color });
        SetColors(tree, childID, color, colorNum, edge2ColorMap);
        ++color;
    }
}

int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> edges;
    for (int i = 0; i < N - 1; ++i)
    {
        int ai, bi;
        cin >> ai >> bi;
        edges.push_back({ ai, bi });
        adjacencyList[ai].push_back(bi);
        adjacencyList[bi].push_back(ai);
    }

    map<int, Node> tree;
    GenerateTree(1, 0, tree);

    const int colorNum = ComputeMaxDegree(tree);
    map<pair<int, int>, int> edge2ColorMap;
    SetColors(tree, 1, -1, colorNum, edge2ColorMap);

    cout << colorNum << endl;
    for (const auto &edge : edges)
    {
        cout << edge2ColorMap[edge] << endl;
    }
}


Measured memory_bytes: 29944
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
#define tc  int t;cin>>t;for(int i=0;i<t;i++)
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,a,b) for(int i=a;i<=b;i++)
bool check(vector<ll> temp,ll n,ll k,ll ans){
    ll cut=0;

    for(int i=0;i<n;i++){
        if(temp[i]>ans){
            cut=cut+(temp[i]/ans);
            if(temp[i]%ans==0)
            cut--;
        }

        if(cut>k)
        return false;
    }
    return true;
}
int main(){


      long long int n,k;
      cin>>n>>k;
      vector<ll> temp(n,0);
      forn(i,n){
          cin>>temp[i];
      }

      sort(temp.begin(),temp.end());
      ll start=1;
      ll end=temp[temp.size()-1];
      ll ans=1;
      while(start<=end){
          ll mid=(start+end)/2;
          if(check(temp,n,k,mid)){

              ans=mid;
              end=mid-1;
          }else{
              start=mid+1;
          }
      }
     cout<<ans<<endl;

}


Measured memory_bytes: 6364
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readInts()
    val b = readInts()

    val sa = IntArray(n)
    val sb = IntArray(n)
    sa[0] = a[0]
    sb[n - 1] = b[n - 1]
    for (i in 1 until n) {
        sa[i] = sa[i - 1] + a[i]
        sb[n - i - 1] = sb[n - i] + b[n - i - 1]
    }
    var ans = 0
    for (i in 0 until n) {
        ans = Math.max(ans, sa[i] + sb[i])
    }
    println(ans)
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    string s;
    cin >> s;
    char now = s[0];
    int cnt = 0;
    rep(i,s.size()){
        if(s[i] != now){
            now = s[i];
            cnt += 1;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#define N 100001

int main() {
  int n, i, j, x, tmp, A[N];

  scanf("%d", &n);
  for(j = 1; j <= n; j++) {
    scanf("%d", &A[j]);
  }

  x = A[n];
  i = 0;
  for (j = 1; j <= n; j++) {
    if(A[j] <= x) {
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }

  for (j = 1; j <= n; j++ ){
    if ( j > 1 ) printf(" ");
    if (i == j) printf("[");
    printf("%d", A[j]);
    if (i == j) printf("]");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 992
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String devider[] = {"maerd","remaerd","esare","resare"};
        String str = new StringBuffer(sc.nextLine()).reverse().toString();
        boolean flag1 = true;
        for(int i=0;i<str.length();){
            boolean flag2 = false;
            for(int j=0;j<4;j++){
                String d = devider[j];
                String d2 = str.substring(i,i);
                if((i+d.length())<=str.length()){
                    d2 = str.substring(i,i+d.length());
                }
                if(d2.equals(d)){
                    flag2 = true;
                    i += d.length();
                }
            }
            if(!flag2){
                flag1 = false;
                break;
            }
        }
        System.out.println(flag1 ? "YES":"NO");
    }
}

Measured memory_bytes: 29900
#include <bits/stdc++.h>
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    long long N;
    cin >> N;
    long long res = N + 1 - 2; // (a, b) = (1, N)
    for (long long a = 1; a * a <= N; ++a) {
        if (N % a == 0) res = min(res, a + N/a - 2);
    }
    cout << res << endl;
}

















Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)

int main()
{
  int N, K;
  cin >> N >> K;
  int a[N];
  rep(i, N) cin >> a[i];
  cout << ceil((float)(N - 1) / (float)(K - 1));
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main()
{
    int n,m,i,sum;
    cin>>n>>m;
    vector<int> x(m),l(m-1);
    if(m<=n){
        cout<<"0"<<endl;
        return 0;
    }
    for(i=0;i<m;i++)
        cin>>x[i];
    sort(x.begin(),x.end());
    for(i=0;i<m-1;i++)
        l[i]=x[i+1]-x[i];
    sort(l.begin(),l.end(),greater<int>());
    sum=x.back()-x.front();
    for(i=0;i<n-1;i++)
        sum-=l[i];
    cout<<sum<<endl;
    return 0;
}
   

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void printVec(vector<int>& vec) {
    for (auto& e : vec) {
        cout << e << " ";
    }
    cout << endl;
}

// 列挙型
enum day { SUN, MON, TUE, WED, THU, FRI, SAT };

int func(std::string S) {
    // cout << fixed << setprecision(8);

    if (S == "SUN") {
        cout << 7 << endl;
    } else if (S == "MON") {
        cout << 6 << endl;
    } else if (S == "TUE") {
        cout << 5 << endl;
    } else if (S == "WED") {
        cout << 4 << endl;
    } else if (S == "THU") {
        cout << 3 << endl;
    } else if (S == "FRI") {
        cout << 2 << endl;
    } else if (S == "SAT") {
        cout << 1 << endl;
    }

    return 0;
}

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

    func(S);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
const int N=200010;
const long long Mod=1000000007;
long long a[N];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    long long ans=0;
    long long sum=0;

    for(int i=0;i<n-1;i++) sum+=a[i];
    
    for(int lab=n-1;lab>0;lab--){
        ans=(ans+((sum%Mod)*a[lab])%Mod)%Mod;
        //cout<<ans<<" "<<a[lab]<<endl;
        sum-=a[lab-1];
        //cout<<sum<<endl;
    }
    
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5280