akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l;
ll num,ans,sum,ok,ng;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005],u[500005];
bool dame,flag;

int main(){
	cin >> n >> m;
	for(i=0;i<m;i++){
		cin >> x[i];
	}
	sort(x,x+m);
	ans = x[m-1] - x[0];
	for(i=0;i<m-1;i++){
		y[num++] = x[i+1] - x[i];
	}
	sort(y,y+m-1);
	for(i=0;i<n-1;i++){
		ans -= y[num - 1 - i];
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 30720
#include <iostream>
#include <string>
int main() {
    std::string x;
    while (true) {
        std::cin >> x;
        if (x == "0") break;
        long result = 0;
        for (char c: x) {
            result += c - '0';
        }
        std::cout << result << std::endl;

    }
}


Measured memory_bytes: 3192
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        n: usize,
        v: [i32; n],
    }
    let mut ret = 100000;
    for i in 1..n {
	let sum1: i32 = v[..i].iter().sum::<i32>();
	let sum2: i32 = v[i..].iter().sum::<i32>();
	let tmp1 = sum1 - sum2;
	let tmp2 = num::abs(tmp1);
	if tmp2 < ret {
	    ret = tmp2;
	}
    }
    println!("{}", ret)
}


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

int main(){
    int k,a,b; cin>>k>>a>>b;
    for(int i=1;i<=b;i++){
        if(k*i>=a &&k*i<=b){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3692
N,M,C=map(int,input().split())
B=list(map(int,input().split()))

count=0

for i in range(N):
    A=list(map(int,input().split()))
    sum=0
    for m in range(M):
        sum+=A[m]*B[m]
    sum+=C
    if sum>0:
        count+=1

print(count)

Measured memory_bytes: 3060
<?php
  fscanf(STDIN,"%d %d",$n,$k);
  $h = explode(" ",trim(fgets(STDIN)));
  rsort($h);
  $atack = 0;
  for($i=$k; $i<$n; $i++){
    $atack += $h[$i];
  }
  echo $atack."\n";

Measured memory_bytes: 23200
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (a+b==c){
        printf("Yes\n");
    }
    else if (a+c==b){
        printf("Yes\n");
    }
    else if (b+c==a){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}

Measured memory_bytes: 3736
#include <cstdio>

using namespace std;

#define rep(i,x) for(int i=0;i<(x);++i)

int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};

char mp[20][22];
int H, W;

void dfs(int y, int x)
{
	if (y < 0 || y >= H || x < 0 || x >= W || mp[y][x] == '#' || mp[y][x] == ' ') return;

	mp[y][x] = ' ';

	rep(i, 4) dfs(y + dy[i], x + dx[i]);
}

int main()
{
	while (scanf("%d %d", &W, &H), H || W) {
		int sy, sx;

		rep(i, H) rep(j, W) {
			scanf("\n%c", &mp[i][j]);
			if (mp[i][j] == '@') sy = i, sx = j, mp[i][j] = '.';
		}

		dfs(sy, sx);

		int cnt = 0;

		rep(i, H) rep(j, W) if (mp[i][j] == ' ') cnt++;

		printf("%d\n", cnt);
	}
}

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

int main(){
    int i=0,n=0,k=0,j=0;
    cin >> n;
    int a[n]={},b[n]={};
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    if(n%2==0){
        k=(n/2);
        for(i=0;i<n;i++){
            if(i%2==0)j = i/2;
            else j = -(i+1)/2;
            b[k+j] = a[i];
        }
    }
    else{
        k=(n-1)/2;
        for(i=0;i<n;i++){
            if(i%2==1)j = (i+1)/2;
            else j = -i/2;
            b[k+j] = a[i];
        }
    }
    for(i=0;i<n-1;i++){
        cout << b[i] << " ";
    }
    cout << b[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine((p[0] - 1) * (p[1] - 1));
            
            Console.Out.Flush();
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}
    

Measured memory_bytes: 11348
#include<cstdio>
#include<vector>
using namespace std;
const int N=2e5+10;
int n,x,y,m,vis[N];
long long sum[N];
vector<int>f[N];
void dfs(int i,long long s)
{
	if(vis[i])return;
	long long t=s;
	s+=sum[i];
	sum[i]+=t;
	vis[i]=1;
	for(int j=0;j<f[i].size();j++)
		dfs(f[i][j],s);
	return;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		f[x].push_back(y);
		f[y].push_back(x);
	}
	while(m--)
	{
		scanf("%d%d",&x,&y);
		sum[x]+=y;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
		printf("%lld ",sum[i]);
	return 0;
}

Measured memory_bytes: 25088
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim().split(' ');
  var a = Number(inputs[0]);
  var b = Number(inputs[1]);
  var c = Number (inputs[2]);
  if (a<b && b<c ){
  	console.log('Yes');
  }else{
  	console.log('No');
  }
  // ????????????????????????
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15532
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
signed main()
{
  int k,a,b; cin >> k>>a>>b;
  for(int i = a; i<=b; ++i){
    if(i%k==0) {
      cout << "OK"; return 0;
    }
  }
  cout << "NG";
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    vi a(n);
    REP(i, n) {
        cin >> a[i];
        a[i]--;
    }

    vector<bool> visited(n, false);
    int p = 0;
    while (!visited[p]) {
        visited[p] = true;
        p = a[p];
    }

    REP(i, n) visited[i] = false;
    int q = 0;
    ll s = 0;
    while (q != p) {
        visited[q] = true;
        q = a[q];
        s++;
        if (s >= k) {
            cout << q + 1 << endl;
            return;
        }
    }

    vi root;
    REP(i, n) visited[i] = false;
    ll c = 0;
    while (!visited[p]) {
        visited[p] = true;
        root.emplace_back(p);
        p = a[p];
        c++;
    }

    //cout << c << endl;
    //printv(root);

    cout << root[(k - s) % c] + 1 << endl;
}


Measured memory_bytes: 5076
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {
    
    int N;
    cin >> N;
    int P;
    int min = 0;
    int out = 0;
    for(int i=0;i<N;i++){
        cin >> P;
        if(i==0 || P < min){
            min = P;
            out ++;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int N;
    int Hi[100];
    int sum = 1;
    int top;

    scanf("%d", &N);

    for (int i = 0; i < N; ++i) {
        scanf("%d ",&Hi[i]);
    }

    top = Hi[0];

    for (int i = 1; i < N; ++i) {
        if ( Hi[i] >= top ) {
            top = Hi[i];
            sum++;
        }
        else{}
    }

    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N;
	cin >> N;
	int B[100100] = {};
	rep1(i, N) {
		int A;
		cin >> A;
		B[A]++;
	}
	
	int OK = 1;
	if (N % 2) {
		if (B[0] != 1) OK = 0;
		rep1(i, N / 2) if (B[i * 2] != 2) OK = 0;
	}
	else {
		rep(i, N / 2) if (B[i * 2 + 1] != 2) OK = 0;
	}

	ll kotae = 1;
	ll mod = 1e9 + 7;
	rep(i, N / 2) {
		kotae = kotae * 2 % mod;
	}

	if (OK) co(kotae);
	else co(0);

	Would you please return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <cstring>
#include <ctime>
#include <vector>
#define inf 1e9
#define ll long long
#define maxn 20010
#define y1 fuck
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=k;i>=j;i--)
using namespace std;
inline void read(ll &tx){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  tx=x*f; }
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){write(x);puts("");}
ll n,p,a[101],f[101];
int main()
{
	read(n);read(p);
	For(i,1,n)	read(a[i]);
	f[0]=1;
	For(i,1,n)	
		if(a[i]&1)	
		{ll tmp=f[1];f[1]=f[1]+f[0];f[0]=f[0]+tmp;}
			else f[0]=f[0]+f[0],f[1]=f[1]+f[1];
	writeln(f[p]);
}

Measured memory_bytes: 256
# 重み付き UnionFind を初めて書いた


class WeightedUnionFind:
    # https://qiita.com/drken/items/cce6fc5c579051e64fab
    def __init__(self, n, SUM_UNITY=0):
        self.par = list(range(n))
        self.rank = [0] * n
        self.diff_weight = [SUM_UNITY] * n

    def root(self, x):
        p = self.par[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.diff_weight[x] += self.diff_weight[p]
            self.par[x] = r
            return r

    def weight(self, x):
        self.root(x)
        return self.diff_weight[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y, w):
        if self.same(x, y):
            return self.diff(x, y) == w
        w += self.weight(x);  w -= self.weight(y)
        x, y = self.root(x), self.root(y)
        # if x == y:
        #     return False
        if self.rank[x] < self.rank[y]:
            x, y = y, x
            w = -w
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x
        self.diff_weight[y] = w
        return True

    def diff(self, x, y):
        return self.weight(y) - self.weight(x)

    def get_roots_weights(self):
        roots = []
        weights = []
        for x in range(len(self.par)):
            roots.append(self.root(x))
            weights.append(self.weight(x))
        return roots, weights

import sys
from operator import itemgetter
from itertools import groupby
from collections import defaultdict

def main():
    R, C = map(int, input().split())
    N = int(input())
    RCA = list(zip(*[iter(map(int, sys.stdin.read().split()))]*3))
    uf_r = WeightedUnionFind(R+1)
    uf_c = WeightedUnionFind(C+1)

    RCA.sort(key=itemgetter(0))
    for _, g in groupby(RCA, key=itemgetter(0)):
        _, c0, a0 = next(g)
        for _, c, a in g:
            if not uf_c.unite(c0, c, a-a0):
                print("No")
                exit()

    RCA.sort(key=itemgetter(1))
    for _, g in groupby(RCA, key=itemgetter(1)):
        r0, _, a0 = next(g)
        for r, _, a in g:
            if not uf_r.unite(r0, r, a-a0):
                print("No")
                exit()

    r_roots, r_weights = uf_r.get_roots_weights()
    c_roots, c_weights = uf_c.get_roots_weights()
    r_roots_inv = defaultdict(list)
    for i, r in enumerate(r_roots):
        r_roots_inv[r].append(i)
    c_roots_inv = defaultdict(list)
    for i, r in enumerate(c_roots):
        c_roots_inv[r].append(i)
    Closed_r = set()
    Closed_c = set()
    for r, c, a in RCA:
        root_r, root_c = r_roots[r], c_roots[c]
        if root_r in Closed_r:
            assert root_c in Closed_c
            continue
        Closed_r.add(root_r)
        Closed_c.add(root_c)
        mi = float("inf")
        for v in r_roots_inv[root_r]:
            mi = min(mi, r_weights[v])
        a += mi - r_weights[r]
        for v in c_roots_inv[root_c]:
            a_ = a + c_weights[v] - c_weights[c]
            if a_ < 0:
                print("No")
                exit()
    print("Yes")

main()


Measured memory_bytes: 96996
INF = float("inf")
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
T, A = nl()
Hs = nl()

min_i = -1
min_diff = INF
for i in range(N):
    diff = abs(A - (T - Hs[i] * 0.006))
    if diff < min_diff:
        min_diff = diff
        min_i = i
print(min_i+1)


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

int main(){
    int n = 0,m = 0;
    cin >> n >> m;

    int tot = 0,tmp = 0;
    for(int i=0;i<m;i++){
        cin >> tmp;
        tot += tmp;
    }

    if(tot > n)
        cout << "-1";
    else
        cout << n - tot;
}

Measured memory_bytes: 3632
using System;

class MainClass
{
  public static void Main(string[] args)
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int N = inputs[0], K = inputs[1];

    long total = 0;
    for (var i = 1; i <= N; i++)
    {
      var p = N / i;
      var r = N % i;
      total += K == 0 ? p * (Math.Max(i - K, 0)) + r
        : p * Math.Max(i - K, 0) + Math.Max(0, r - (K - 1));
    }
    Console.WriteLine($"{total}");
  }
}


Measured memory_bytes: 13268
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int N;
int F[100][15];
int P[100][15];
int main()
{
	cin >> N;
	for (int i = 0; i < N; i++){
		for (int j = 0; j < 10; j++) cin >> F[i][j];
	}
	for (int i = 0; i < N; i++) for (int j = 0; j <11; j++)cin>>P[i][j];
	int ans = -INF;
	for (int b = 1; b <(1 <<10); b++){
		int num = 0;
		for (int i = 0; i < N; i++){
			int c = 0;
			for (int j = 0; j <10; j++) if ((b >> j & 1) && F[i][j]) c++;
			num += P[i][c];
		}
		ans = max(num, ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = set(table)
    return table

n = int(input())
ds = divisor(n)

step = n
for d in ds:
    r = n / d
    step = min(step, d+r-2)

print(int(step))


Measured memory_bytes: 3924
import collections
import heapq
def main():

    N = int(input())
    edges = collections.defaultdict(dict)
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        edges[a][b] = c
        edges[b][a] = c

    Q, K = map(int, input().split())
    dist = dict()
    cur = [[0, K]]
    while cur:
        d, a = heapq.heappop(cur)
        if a not in dist:
            dist[a] = d
            for b in edges[a]:
                if b not in dist:
                    heapq.heappush(cur, [d+edges[a][b], b])

    for _ in range(Q):
        x, y = map(int, input().split())
        print(dist[x] + dist[y])

if __name__ == '__main__':
    main()

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9 + 7;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    if(a == b && n == 1) {
        cout << 1 << endl;
        return 0;
    }
    if(n == 1 || b < a) {
        cout << 0 << endl;
        return 0;
    }

    cout << (b - a) * (n - 2) + 1 << endl;

    return 0;
}


Measured memory_bytes: 3608
/* author   : mpily :-()
title : Competing.cpp
time :Mon Mar 16 13:59:47 2020

*/
#define ll long long
#define pb push_back
#include<bits/stdc++.h>
using namespace std;
bool checkneg(const vector<ll>& neg,const vector<ll>&pos, ll target,ll k){
	ll tot = 0;
	int start = 0;
	int lst = neg.size()-1;
	while(start < pos.size() && lst >= 0){
		ll ck = pos[start]*neg[lst]*-1;
		if(ck > target){
			start+=1;
		}
		else if(ck <= target){
			tot+=(pos.size()-start);
			//cout<<"for "<<-1*neg[lst]<<" "<<pos[start]<<" at position "<<start<<" works \n";
			lst-=1;
		}
	}
	if(tot >=k)return true;
	else return false;
}
bool checkpos(const vector<ll>& neg,const vector<ll>&pos, ll target,ll k){
	if(k <= (ll)pos.size() * (ll)neg.size()){
		return true;
	}
	else{
		 ll tot = (ll)pos.size()*(ll)neg.size();
		//checking positive numbers only
		int strt = 0;
		int lst = pos.size()-1;
		while(strt < lst){
			ll ck = pos[strt]*pos[lst];
			if(ck > target){
				lst -=1;
			}
			else if(ck <= target){
				tot+=(lst-strt);
				strt+=1;
			}
		}
		if(tot >= k)return 1;
		//checking negative numbers only
		strt = 0;
		lst = neg.size()-1;
		while(strt < lst){
			ll ck = neg[strt]*neg[lst];
			if(ck > target){
				lst -=1;
			}
			else if(ck <= target){
				tot+=(lst-strt);
				strt+=1;
			}
		}
		if(tot >= k)return 1;
		return 0;
	}
}
int main(){
	int n; ll k;
	cin>>n>>k;
	vector<ll>posv;
	vector<ll>negve;
	for(int i = 0; i < n; i++){
		ll temp;
		cin>>temp;
		if(temp < 0){
			negve.pb(temp*-1);
		}
		else{
			posv.pb(temp);
		}
	}
	sort(posv.begin(),posv.end());
	sort (negve.begin(),negve.end());
	//cout<<(ll)posv.size()<<"is the orig product \n";
	ll mn = -1e18;
	ll mx = 1e18;
	ll md = mn+(mx-mn)/2;
	while(mn < mx){
		//cout<<mn<<" "<<md<<" "<<mx<<"\n";
		if(md < 0 && checkneg(negve,posv,md,k)){
			//cout<<md<<"works\n";
			mx = md;
			md = mn+ (mx-mn)/2;
		}
		else if(md >= 0 && checkpos(negve,posv,md,k)){
			//cout<<md<<"works\n";
			mx = md;
			md = mn+(mx-mn)/2;
		}
		else{
			//cout<<md<<"doesnt work\n";
			mn = md+1;
			md = mn+(mx-mn)/2;
		}
	}
	cout<<md<<"\n";
	return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    map<string, int> mp;
    for (int i=0;i<N;i++){
        string s; cin >> s;
        mp[s]++;
    }
    int max_cnt = 0;
    for (auto x : mp) max_cnt = max(max_cnt, x.second);
    for (auto x : mp) if (x.second == max_cnt) cout << x.first << endl;
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)
#define M 1000000007


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n>>x>>t;
    r=n/x+(n%x!=0);
    cout<<t*r<<endl;
}



Measured memory_bytes: 3556
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=1000 +117;
const int MM=200000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
vector<int> p[NN];
vector<int> rp[NN];
map<pair<int,int>,int> id;
bool ans[MM]={};
int fir[NN]={};
int las[NN]={};
void col(int vis[],int x,int c){
	if(vis[x])return ;
	vis[x]=c;
	for(int i=0;i<p[x].size();++i){
		col(vis,p[x][i],c);
	}
}
void getvis(int x){
	for(int i=1;i<=n;++i){
		fir[i]=las[i]=0;
	}
	fir[x]=las[x]=-1;
	for(int j=0;j<p[x].size();++j){
		col(fir,p[x][j],j+1);
	}
	for(int j=p[x].size()-1;j>=0;--j){
		col(las,p[x][j],j+1);
	}
}
int main(){
	//open();
	n=read();
	m=read();
	for(int i=1;i<=m;++i){
		int x=read(),y=read();
		p[x].push_back(y);
		rp[y].push_back(x);
		id[make_pair(x,y)]=i;
	}
	for(int i=1;i<=n;++i){
		getvis(i);
		for(int j=0;j<rp[i].size();++j){
			int cur=rp[i][j];
			bool fl=0;
			if(fir[cur])fl=1;
			ans[id[make_pair(cur,i)]]^=fl;
		}
		for(int j=0;j<p[i].size();++j){
			int cur=p[i][j];
			if(fir[cur]!=j+1||las[cur]!=j+1){
				ans[id[make_pair(i,cur)]]^=1;
			}
		}
	}
	for(int i=1;i<=m;++i){
		if(ans[i])printf("diff\n");
		else printf("same\n");
	}
	close();
	return 0;
}

Measured memory_bytes: 17280
#include<bits/stdc++.h>
using namespace std;
int n,t;
int v[101],w[101];
map<pair<int,int>, long long> dp;

int II()
{
int n;
scanf("%d",&n);
return n;
}
long long knap(int rim,int pos){
	if(dp[{rim,pos}]!=0)
	return dp[{rim,pos}];
	
	if(rim<0)
	return -10000000000000000ll;
	
	if(pos>=n)
	return 0;
	
	
	
	return dp[{rim,pos}]=max(knap(rim,pos+1),v[pos]+knap(rim-w[pos],pos+1));
	
	
}


int main(){
cin>>n>>t;
for(int i=0;i<n;i++)
cin>>w[i]>>v[i];

cout<<knap(t,0)<<endl;

return 0;
}


Measured memory_bytes: 6656
import sys

def main():
    A, B, C, K = map(int, input().split())

    ans = 0
    if A >= K:
        ans += K
        print(ans)
        return
    else:
        ans += A
        K -= A

    if B >= K:
        print(ans)
        return
    else:
        K -= B
    
    if C >= K:
        ans -= K
        print(ans)
        return
    else:
        ans -= C
        print(ans)

    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Measured memory_bytes: 61824
# coding: utf-8
# Your code here!
N = [0]*4

for _ in range(3):
    a,b = map(int,input().split())
    N[a-1] += 1
    N[b-1] += 1
# print(N)
N.sort()
# print(N)

if N[0] == 1 and N[1] == 1 and N[2] == 2 and N[3] == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
import sys
n = int(input())

R = [0] * n
for i in range(n):
    R[i] = int(input())

# Naive Algorithm
# mx = R[1] - R[0]
# for i in range(n):
#     for j in range(i+1, n):
#         if mx < A[j] - A[i]:
#             mx = A[j] - A[i]

# O(N) Algorithm
mx = R[1] - R[0]
mn = min(R[:2])

for r in R[2:]:
    if mx < r-mn:
        mx = r-mn
    elif mn > r:
        mn = r

print(mx)

Measured memory_bytes: 14900
#include<bits/stdc++.h>
using namespace std;
int a[36]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    int k;
    scanf("%d",&k);
    printf("%d",a[k-1]);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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


	int a = n * (n - 1) / 2;
	int b = m * (m - 1) / 2;

	println(a + b);
}


Measured memory_bytes: 384
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
#from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

import heapq
def dijkstra(start, end):
	#dist = defaultdict(lambda: float('inf'))
	dist = [[float('inf')]*W for _ in range(H)]
	dist[start[0]][start[1]] = 0
	heap = []
	heapq.heappush(heap, (0, start))
	while heap:
		d, n = heapq.heappop(heap)
		if n == end:
			return d
		if dist[n[0]][n[1]] != d:
			continue
		edges = get_edges(n)
		for nn, ed in edges:
			nd = d + ed
			ni, nj = nn
			if dist[ni][nj] > nd:
				dist[ni][nj] = nd
				heapq.heappush(heap, (nd, nn))
	return -1

def get_edges(n):
	i, j = n
	edges = []
	if M[i][j] == '#': return edges
	for di, dj in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
		ni, nj = i+di, j+dj
		if not (0 <= ni < H and 0 <= nj < W): continue
		if M[ni][nj] == '#': continue
		edges.append(((ni, nj), 0))
	for di in range(-2, +3):
		for dj in range(-2, +3):
			ni, nj = i+di, j+dj
			if di == 0 and dj == 0: continue
			if (di, dj) in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
				continue
			if not(0 <= ni < H and 0 <= nj < W): continue
			if M[ni][nj] == '#': continue
			edges.append(((ni, nj), 1))
	return edges

H, W = rl()
C = rl()
D = rl()
M = []
for i in range(H):
	s = rs()
	M.append(s)

start = tuple([C[0]-1, C[1]-1])
end = tuple([D[0]-1, D[1]-1])
d = dijkstra(start, end)
print(d)


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

int main( void ) {
    int a, b;
    cin >> a >> b;
    cout << 'a';
    if( a == b ) cout << " == ";
    else if( a > b ) cout << " > ";
    else cout << " < ";
    cout << 'b' << '\n';
    return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


VI eratos ( int n){
	vector<bool> prime(n+50);
	prime[2] = true; prime[0] = prime[1] = false;
	for(int i = 3; i <= n; i += 2) prime[i] = true, prime[i+1] = false;
	int limit = (int)sqrt((double)n) + 1;
	for(int i = 3; i <= limit; i += 2){
		if(!prime[i]) continue;
		for(int j = i * i, k = i * 2; j <= n; j += k) prime[j] = false;
	}
	VI pr;
	rep(i, n+1) if(prime[i]) pr.push_back(i);
	return pr;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	
	auto pr = eratos(n);
	map<int, int> mp;
	for(auto p: pr){
		int sm = 0;
		for(int w=n; w>0; w/=p){
			sm += w/p;
		}
		mp[p] = sm;
	}
	ll ans = 1;
	for(auto x :mp){
		ans = ans * (x.second +1) % MD;
	}
	cout << ans %MD <<"\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong(), blue = sc.nextLong(), red = sc.nextLong();
        
        long count = n / (blue + red);
        long rem = n % (blue + red);
        
        if(blue == 0){
            System.out.println(blue);
        } else if(n < (blue + red)) {
            if(n>blue){
                System.out.println(blue);
            } else {
                System.out.println(n);
            }
        } else {
            if(rem > blue){
                System.out.println((count * blue) + blue);
            } else {
                System.out.println((count * blue) + rem);    
            }
        }
    }
}


Measured memory_bytes: 23764
import math
import itertools
n,d = map(int,input().split())
x = []
a = []
for i in range(n):
    xi = list(map(int,input().split()))
    x.append(xi)
    a.append(i)

all_pattern = list(itertools.combinations(a,2))
ans = 0
for i in range((n*(n-1)) // 2):
    x1 = x[all_pattern[i][0]]
    x2 = x[all_pattern[i][1]]
    distance = 0
    for j in range(d):
        distance += ((x1[j] - x2[j]) ** 2)
    if math.sqrt(distance) == int(math.sqrt(distance)):
        ans += 1
print(ans)

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

int main(){
    int K,N; cin >> K >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    int longest=0;
    for(int i=0; i<N-1; i++){
        longest=max(longest,(A.at(i+1)-A.at(i)));
    }
    longest=max(longest,(A.at(0)+K-A.at(N-1)));
    cout << K-longest << endl;
}

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

int main() {
	vector<int> vec(10);
	for (int i = 0; i < 10; i++) {
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	for (int i = 0; i < 3; i++) {
		cout << vec[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n;
	while(cin>>n and n>0){
		int a[n]; rep(i,n) cin>>a[i];
		sort(a,a+n);

		int ans=1e9;
		rep(i,n-1){
			if(a[i+1]-a[i]<ans) ans=a[i+1]-a[i];
		}
		cout<<ans<<endl;
	}
	return 0;
}



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

using namespace std;

using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

set<string> solve(map<string, set<string>> &mp, vector<string> &parents, int i) {
  string par = parents[i];
  set<string> children = mp[par];
  vector<set<string>> v;
  vector<int> er;
  for(auto child: children) {
    auto result = find(parents.begin(), parents.end(), child);
    if(result != parents.end()) {
      int d = distance(parents.begin(), result);
      v.push_back(solve(mp, parents, d));
      er.push_back(d);
    }
  }
  int sz = v.size();
  for(int i=0;i<sz;++i) {
    vector<string> ins;
    set_union(children.begin(), children.end(), v[i].begin(), v[i].end(), inserter(ins, ins.end()));
    for(int j=0;j<(int)(ins.size());++j) {
      children.insert(ins[j]);
    }
  }

  sz = er.size();
  children.erase(par);
  for(int i=0;i<sz;++i) {
    children.erase(parents[er[i]]);
  }

  mp[parents[i]] = children;
  return children;
}

int main() {
    cin.tie(0);
    cout << fixed << setprecision(10);

    while(1) {
      int n; cin >> n;
      if(n == 0) break;
      map<string, set<string>> mp;
      vector<string> parents;
      for(int i=0;i<n;++i) {
        string s; cin >> s;
        int sz = s.size();
        string par = "", child = "";
        int prev =  0;
        for(int j=0;j<sz;++j) {
          if(s[j] == ':') {
            par = s.substr(prev, j);
            prev = j+1;
          } else if(s[j] == ',' || s[j] == '.') {
            child = s.substr(prev, j - prev);
            mp[par].insert(child);
            prev = j+1;
          }
        }
        parents.push_back(par);
      }

      cout << solve(mp, parents, 0).size() << endl;
    }
}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n, d;
  cin >> n >> d;
  int ans = 0;
  for(int i = 0; i < n; i++){
    double x, y;
    cin >> x >> y;
    double dist = sqrt(x * x + y * y);
    if(dist <= d){
      ans++;
    }
  }
  cout <<ans;
}


Measured memory_bytes: 3836
import java.util.Scanner;

//Sum of Integers
public class Main{

	public static int n;
	public static int s;
	public static int c;

	public static void dfs(int k, int rest, int x){
		if(k==n){
			c += rest==0?1:0;
			return;
		}
		if(rest<0)return;
		for(int i=Math.min(x, 9);i>=0;i--){
			dfs(k+1, rest-i, i-1);
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			s = sc.nextInt();
			if(n==0&&s==0)break;
			c = 0;
			dfs(0, s, s);
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 11000
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	int A, B, C, D; cin >> A >> B >> C >> D;
    int L = A+B; int R = C+D;
    if (L > R) cout << "Left" << endl;
    else if (L == R) cout << "Balanced" << endl;
    else cout << "Right" << endl;
}


Measured memory_bytes: 256
# https://github.com/mame/doublehelix
$code = ""
Object.instance_eval do
  def const_missing(s); $code << s.to_s; 0; end
  remove_const(:GC)  # Holy moly!
end
at_exit do
  dict = { "AT"=>"00", "CG"=>"01", "GC"=>"10", "TA"=>"11" }
  eval([$code.gsub(/../) {|s| dict[s] }].pack("b*"))
end


 AT
A--T
T---A
G----C
 G----C
  G----C
   T---A
    G--C
     AT
     GC
    T--A
   G---C
  T----A
 A----T
T----A
G---C
A--T
 AT
 CG
A--T
T---A
A----T
 C----G
  G----C
   G---C
    A--T
     CG
     GC
    T--A
   A---T
  T----A
 G----C
G----C
G---C
C--G
 GC
 AT
A--T
C---G
A----T
 T----A
  G----C
   C---G
    G--C
     GC
     GC
    C--G
   G---C
  A----T
 G----C
T----A
G---C
T--A
 AT
 TA
G--C
T---A
C----G
 G----C
  G----C
   A---T
    A--T
     TA
     AT
    G--C
   T---A
  G----C
 G----C
C----G
C---G
A--T
 AT
 AT
A--T
C---G
A----T
 A----T
  A----T
   C---G
    A--T
     TA
     GC
    T--A
   G---C
  A----T
 C----G
C----G
G---C
G--C
 GC
 CG
G--C
C---G
T----A
 C----G
  G----C
   A---T
    A--T
     CG
     AT
    T--A
   T---A
  T----A
 A----T
G----C
A---T
A--T
 GC
 TA
C--G
T---A
A----T
 A----T
  A----T
   C---G
    A--T
     TA
     TA
    T--A
   A---T
  A----T
 G----C
G----C
G---C
C--G
 CG
 AT
A--T
A---T
A----T
 C----G
  A----T
   A---T
    A--T
     CG
     AT
    T--A
   G---C
  T----A
 G----C
A----T
C---G
C--G
 GC
 GC
G--C
C---G
G----C
 C----G
  T----A
   C---G
    G--C
     AT
     AT
    C--G
   A---T
  T----A
 T----A
T----A
A---T
A--T
 GC
 GC
G--C
T---A
C----G
 T----A
  A----T
   A---T
    A--T
     CG
     AT
    T--A
   T---A
  T----A
 A----T
G----C
A---T
A--T
 GC
 CG
C--G
A---T
A----T
 A----T
  A----T
   C---G
    A--T
     AT
     AT
    C--G
   A---T
  T----A
 G----C
T----A
G---C
A--T
 CG
 CG
G--C
G---C
G----C
 C----G
  G----C
   C---G
    T--A
     CG
     GC
    A--T
   A---T
  C----G
 A----T
T----A
T---A
T--A
 AT
 TA
G--C
A---T
G----C
 T----A
  C----G
   T---A
    A--T
     AT
     AT
    C--G
   A---T
  T----A
 T----A
T----A
A---T
T--A
 AT
 AT
G--C
C---G
C----G
 A----T
  A----T
   A---T
    A--T
     CG
     AT
    A--T
   A---T
  C----G
 A----T
T----A
G---C
T--A
 GC
 AT
C--G
C---G
G----C
 G----C
  G----C
   C---G
    G--C
     CG
     TA
    C--G
   G---C
  A----T
 A----T
C----G
A---T
T--A
 TA
 TA
A--T
T---A
A----T
 A----T
  G----C
   T---A
    C--G
     TA
     AT
    A--T
   A---T
  C----G
 A----T
T----A
T---A
T--A
 AT
 TA
G--C
A---T
G----C
 C----G
  C----G
   A---T
    A--T
     GC
     GC
    C--G
   G---C
  C----G
 T----A
C----G
G---C
A--T
 GC
 CG
G--C
C---G
C----G
 A----T
  A----T
   C---G
    C--G
     AT
     AT


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

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for(int i=0; i<h; i++) cin >> a[i];
    
        // 各行と各列に'#'があるかどうか調べる
	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(a[i][j] == '#'){
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for(int i=0; i<h; i++){
		if(row[i]){  // その行に'#'があれば
			for(int j=0; j<w; j++){
				if(col[j]){  // その列に'#'があれば
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
N = int(input())
W = [int(x) for x in input().split()]
res = 1000
for i in range(1,N-1):
  r = W[0:i+1]
  l = W[i+1:N]
  R = sum(r)
  L = sum(l)
  a = abs(R-L)
  if a < res:
    res = a
print(res)

Measured memory_bytes: 3064
# include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,area1=0,area2=0;
scanf("%d%d%d%d",&a,&b,&c,&d);
area1=a*b;
area2=c*d;
cout<<max(area1,area2)	;
return 0;	
}

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;

  if(a + k > b){
    for(int i = a; i <= b; i++){
      cout << i << endl;
    }
  }else{
    for(int i = a; i < a + k; i++){
      cout << i << endl;
    }
  }

  if(a+k-1 >= b-k+1){
    for(int i = a+k; i <= b; i++){
      cout << i << endl;
    }
  }else{
    for(int i = b-k+1; i <= b; i++){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	scanf("%lld",&n);
	if(n==1)
		printf("0\n");
	else
	{
		printf("%lld",n*(n-1)/2);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int a[12] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};

  ll x, y;
  cin >> x >> y;
  
  x--; y--;
  if (a[x] == a[y])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

int main() {
  int H, W, N, sr, sc; cin >> H >> W >> N >> sr >> sc;
  vector<int> Srow(N,0);
  vector<int> Scol(N,0);
  vector<int> Trow(N,0);
  vector<int> Tcol(N,0);
  getchar();
  for (int i=0; i<N; i++) {
    char c = getchar();
    if (c=='R') Srow[i]=1;
    else if (c=='L') Srow[i]=-1;
    else if (c=='D') Scol[i]=1;
    else if (c=='U') Scol[i]=-1;
  }
  getchar();
  for (int i=0; i<N; i++) {
    char c = getchar();
    if (c=='R') Trow[i]=1;
    else if (c=='L') Trow[i]=-1;
    else if (c=='D') Tcol[i]=1;
    else if (c=='U') Tcol[i]=-1;
  }
  int scR=sc, scL=sc, srU=sr, srD=sr;
  for (int i=0; i<N; i++) {
    if(Srow[i]==1) scR++;
    else if(Srow[i]==-1) scL--;
    if(Scol[i]==1) srD++;
    else if(Scol[i]==-1) srU--;
    if(scR>W||scL<=0||srD>H||srU<=0) {cout << "NO" <<"\n"; return 0;}
    if(Trow[i]==1) scL=min(scL+1,W);
    else if(Trow[i]==-1) scR= max(scR-1,1);
    if(Tcol[i]==1) srU = min(srU+1,H);
    else if(Tcol[i]==-1) srD = max(srD-1,1);
  }
  cout << "YES" <<"\n"; return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

std::string S;

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

    std::cin >> S;

    int L = S.size();
    
    bool can = S == "keyence";

    for(int i=0;i<L;++i){
        for(int j=i+1;j<=L;++j){
            if((j < L && S.substr(0, i) + S.substr(j) == "keyence") ||
               (j == L && S.substr(0, i) == "keyence")){
                can = true;
                break;
            }
        }

        if(can){break;}
    }

    if(can){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int red = 0; 
		int blue=0;
		for(int i = 0; i<n; i++){
			if(s.charAt(i)=='R'){
				red++;
			}else if(s.charAt(i)=='B'){
				blue++;
			}
		}
		if(red>blue){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        int temp=s[i]-'A';
        s[i]=(temp+(n)%26)%26+'A';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
def koch_curve a, b, n
  return if n == 0

  new_coords = [a, nil, nil, nil, b]

  a_x = a[0]
  a_y = a[1]
  b_x = b[0]
  b_y = b[1]
  new_coords[1] = [a_x + (b_x - a_x) / 3.0, a_y + (b_y - a_y) / 3.0]
  new_coords[2] = if a_y == b_y
                    [(a_x + b_x) / 2.0, a_y + (b_x - a_x) / 6.0 * Math.sqrt(3)]
                  elsif a_x < b_x && a_y > b_y
                    [b_x, a_y + (b_y - a_y) / 3.0]
                  elsif a_x < b_x && a_y < b_y
                    [a_x, a_y + (b_y - a_y) / 3.0 * 2.0]
                  elsif a_x > b_x && a_y > b_y
                    [a_x, a_y + (b_y - a_y) / 3.0 * 2.0]
                  else
                    [b_x, a_y + (b_y - a_y) / 3.0]
                  end
  new_coords[3] = [a_x + (b_x - a_x) / 3.0 * 2.0, a_y + (b_y - a_y) / 3.0 * 2.0]

  koch_curve new_coords[0], new_coords[1], n - 1
  puts "#{sprintf('%.8f', new_coords[1][0])} #{sprintf('%.8f', new_coords[1][1])}"
  koch_curve new_coords[1], new_coords[2], n - 1
  puts "#{sprintf('%.8f', new_coords[2][0])} #{sprintf('%.8f', new_coords[2][1])}"
  koch_curve new_coords[2], new_coords[3], n - 1
  puts "#{sprintf('%.8f', new_coords[3][0])} #{sprintf('%.8f', new_coords[3][1])}"
  koch_curve new_coords[3], new_coords[4], n - 1
end

n = gets.chomp.to_i
coords = [[0.0, 0.0], [100.0, 0.0]]
puts "#{sprintf('%.8f', coords[0][0])} #{sprintf('%.8f', coords[0][1])}"
koch_curve(coords[0], coords[1], n)
puts "#{sprintf('%.8f', coords[1][0])} #{sprintf('%.8f', coords[1][1])}"


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  string sd, t;
  cin >> sd >> t;

  if (sz(sd) < sz(t)) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  vector<string> ss;  
  rep(i,sz(sd)-sz(t)+1) {
    string s = sd;
    bool ok = true;
    for (int j = i; j < i+sz(t); ++j) {
      if (sd[j]!=t[j-i] && sd[j]!='?') ok = false;
    }
    if (ok) {
      for (int j = i; j < i+sz(t); ++j) {
        s[j] = t[j-i];
      }
      rep(i,sz(s)) {
        if (s[i] == '?') s[i] = 'a';
      }
      ss.pb(s);
    }
  }
  if (!ss.empty()) cout << *min_element(rng(ss)) << endl;
  else cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import exit
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
for n in range(10**N):
  if len(str(n)) == N and all(str(n)[s - 1] == str(c) for s, c in sc):
    print(n)
    exit()
print(-1)

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

ll Count[205];

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % inf, N / 2) % inf;
  return A * Pow(A * A % inf, N / 2) % inf;
}

int main(){
  ll K; cin >> K;
  ll ans = 0;
  for (ll i = K; i >= 1; i--){
    ll num = Pow(K / i, 3) - Count[i];
    ans += i * num;
    for (ll j = 1; j * j <= i; j++){
      if (i % j == 0){
        if (j * j == i){
          Count[j] += num;
        }else{
          Count[j] += num;
          Count[i / j] += num;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
    #define ll long long
    #define double long double
    #define rep(i,n) for(int i=0;i<(n);i++)
    #define REP(i,n) for(int i=1;i<=(n);i++)
    #define mod (ll)(1e9+7)
    #define inf (ll)(3e18+7)
    #define P pair<int,int>
    #define PiP pair<int,pair<int,int>>
    #define all(x) x.begin(),x.end()
     
    using namespace std;
     
    int main() {
        int n, ans = 1000;
        cin >> n;
        vector<int> a(n);
        rep(i, n){
            int cnt=0;
            cin >> a.at(i);
            while(a.at(i)%2 == 0){
                cnt++;
                a.at(i)/=2;
            }
            ans = min(ans, cnt);
        }
        cout << ans;
    }

Measured memory_bytes: 256