akhauriyash/Code-Regression huggingface dataset:
/**
  *  Worg
  */
#include <cstdio>
#include <algorithm>

using namespace std;

//FILE *fin = freopen("main.in", "r", stdin); FILE *fout = freopen("main.out", "w", stdout);

const int kMaxN = 1e5 + 5;
const int kMaxBits = 40;

int N, K, M;
int a[kMaxN], b[kMaxN];

long long solution;
long long orSum, totalSum;

long long deleteCost[kMaxBits];
bool exists[kMaxBits];
bool erased[kMaxN];

void GetBitCosts() {
    for(int bit = 0; bit <= 30; bit++) {
        deleteCost[bit] = 0; exists[bit] = false;
    }

    for(int i = 1; i <= M; i++) {
        for(int bit = 0, pow = 1; pow <= a[i]; bit++, pow <<= 1) {
            if(a[i] & pow) {
                if(erased[i]) continue;
                deleteCost[bit] += b[i];
                exists[bit] = true;
            }
        }
    }
}

void GetAnswer() {
    GetBitCosts();
    for(int bit = 30, pow = 1 << 30; bit >= 0; bit--, pow >>= 1) {
        if(!(K & pow)) {
            bool bad = false;
            int orSum = 0;
            for(int i = 1; i <= M; i++) {
                if(!erased[i] && (a[i] & pow)) {
                    bad = true;
                }
                orSum |= a[i];
            }

            if(!bad || orSum <= K) continue;

            bool ok = false;
            long long minCost = 10000000000000000LL;

            for(int i = 30; i > bit; i--) {
                if(exists[i]) {
                    ok = true; minCost = min(minCost, deleteCost[i]);
                }
            }

            if(ok) {
                solution = max(solution, totalSum - minCost);
            }

            for(int i = 1; i <= M; i++) {
                if((a[i] & pow) && !erased[i]) {
                    totalSum -= b[i]; erased[i] = true;
                }
            }
        }
        GetBitCosts();
    }

    solution = max(solution, totalSum);
    printf("%lld\n", solution);
}

int main() {
    scanf("%d%d", &N, &K);

    for(int i = 1; i <= N; i++) {
        int x, y; scanf("%d%d", &x, &y);

        if(x <= K) {
            M ++;
            a[M] = x; b[M] = y;
            orSum |= x; totalSum += y;
        }
    }

    GetAnswer();

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {

	int N;
	cin >> N;
	vector<int> d(N);
	rep(i, N) cin >> d.at(i);

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

	if (N % 2 == 0) {
		int mid = N / 2;
		if (d.at(mid - 1) == d.at(mid)) {
			cout << 0 << endl;
		}
		else {
			cout << d.at(mid) - d.at(mid - 1) << endl;
		}
	}
	else {
		cout << 0 << endl;
	}

	

	
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
      
      while(n>=1000){
      	n -=1000;
      }
      int oturi = 0;
      if(n>0){
       oturi = 1000-n;
      }
      
		// 出力
		System.out.println(oturi);
	}
}

Measured memory_bytes: 35716
#include<bits/stdc++.h>
using namespace std;
long long a[200005];
int main(){
	int k,n;
	long long sum=0;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k;i++) sum+=a[i];
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// exam-and-wizard.rs --- Exam and Wizard
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        xs: [i64; n],
        ys: [i64; n],
    };

    let diffs = xs
        .into_iter()
        .zip(ys.into_iter())
        .map(|(x, y)| x - y)
        .collect::<Vec<_>>();

    let mut affords = diffs.iter().filter(|&&d| 0 < d).collect::<Vec<_>>();
    affords.sort();
    let mut afford_sums = vec![0; n + 1];
    for (i, afford) in affords.into_iter().rev().enumerate() {
        afford_sums[i + 1] = afford_sums[i] + afford;
    }
    let short_sum = diffs.iter().filter(|&&d| d < 0).sum::<i64>();

    let ans = afford_sums
        .iter()
        .enumerate()
        .find(|&(_, &afford_sum)| -short_sum <= afford_sum)
        .map(|(i, _)| i as i64)
        .map(|cnt| cnt + diffs.iter().filter(|&&d| d < 0).count() as i64)
        .unwrap_or(-1);
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
bool isPrime[100010];
void set_prime()
{
	for (int i = 1; i <= 100000; i++) {
		isPrime[i] = true;
	}
	isPrime[0] = false; isPrime[1] = false;
	for (int i = 2; i * i <= 100000; i++) {
		int j = 2;
		while (i * j <= 100000) {
			isPrime[i * j] = false;
			j++;
		}
	}
}

int main()
{
	int N;
	int count[1010] = { 0 };
	long long an = 1;
	scanf("%d", &N);
	set_prime();
	for (int i = 2; i <= N; i++) {
		int tmp = i;
		int j = 2;
		while (tmp > 1) {
			if (isPrime[j]) {
				//printf("%d ", tmp);

				while(tmp % j == 0) {
					count[j]++;
					tmp /= j;
				}
			}
			j++;
		}
		//puts("");
	}
	for (int i = 1; i <= N; i++) {
		//printf("%d\n", count[i]);
		an *= count[i] + 1;
		an = an % mod;
	}
	printf("%lld", an);
	return 0;
}

Measured memory_bytes: 256
house = Array.new(4){Array.new(3){Array.new(10,0)}}

count = gets.to_i

for i in 1..count do
	info = gets
	b,f,r,v = info.split(" ").map(&:to_i)
	house[b-1][f-1][r-1] += v
end

for i in 0..3 do
	for j in 0..2 do
		for k in 0..9 do
			print " " , house[i][j][k] 
		end
		print "\n"
	end 
		if i < 3 then
	    	puts "####################"
	    end
end

Measured memory_bytes: 8768
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

int prm[5000];

void prm_count(){
    int i,j,k, m=0;
    for(i=3;i<=55555;i+=2){
        k=0;
        for(j=3;j<=sqrt(i);j+=2){
            if(i%j==0){
                k=1;
                break;
            }
        }
        if(k==0 && i%5 == 1) {
            prm[m] = i;
            m++;
            //printf("%d\n", m);
        }
    }
}

int main(){
    int n;
    scanf("%d", &n);
    prm_count();
    /*5で割って1余るような数を5個選べばそれらの合計は必ず5で割り切れる。
    さらに、N個から必ず"5個選ぶ"ので、Nがいくつであっても必ず満たす*/
    for(int i=0;i<n;i++){
        printf("%d", prm[i]);
        if(i != n-1){
            printf(" ");
        }else {
            printf("\n");
        }
    }

    return 0;
}

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

int main() {
  vector<int> data(3);
  int a=0, b=0;
  for(int i=0; i<3; i++) {
    cin >> data[i];
    if (data[i] == 5) a++;
    else if (data[i] == 7) b++;
  }
  if (a==2 && b==1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	string s;
	cin >> s;
	Yes(s[0] == s[1] && s[1] != s[2] && s[2] == s[3] ||
		s[0] == s[2] && s[2] != s[1] && s[1] == s[3] || 
		s[0] == s[3] && s[3] != s[2] && s[2] == s[1]);
	return 0;
}

Measured memory_bytes: 256
#coding: utf-8
string = str(input())
X = 0
li = []
for a in range(len(string)):
    if string[a] == " ":
        li.append(string[X:a])
        X = a+1
li.append(string[X:])
for aa in range(len(li)):
    li[aa] = int(li[aa])
h1 = li[0]
m1 = li[1]
h2 = li[2]
m2 = li[3]
k = li[4]
Time = (h2 * 60 + m2) - (h1 * 60 + m1) - k
print(int(Time))

Measured memory_bytes: 9076
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    string s;
    cin>>s;

    ll dp[13];
    mem(dp,0);

    ll n=s.size();

    if(s[0]=='?')
    {
        f(i,10) dp[i]=1;
    }
    else
    {
        ll v=s[0] - '0';
        dp[v]=1;
    }

    for(ll i=1;i<n;i++)
    {
        ll tp[13];
        mem(tp,0);

        if(s[i]!='?')
        {
            ll v=s[i]-'0';

            f(j,13)
            {
                ll nr= (j*10)+v;
                nr%=13;
                tp[nr]+=(dp[j])%mod;
                tp[nr]%=mod;
            }
        }
        else
        {
            f(k,10)
            {
               ll v=k;

                f(j,13)
                {
                    ll nr= (j*10)+v;
                    nr%=13;
                    tp[nr]+=(dp[j])%mod;
                    tp[nr]%=mod;
                }
            }
        }

        f(i,13) dp[i]=tp[i]%mod;
    }

    cout<<dp[5]%mod<<"\n";

    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

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

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 512
#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 n;
	cin >> n;

	unordered_set<int> set;
	int a;
	rep(i, n) {
		cin >> a;
		set.insert(a);
	}

	cout << ((set.size() == n) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 8520
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,k,i;
    long long x[100000],ans=1000000001;
    cin >> n >> k;
    for(i=0;i<n;i++) cin >> x[i];
    sort(x,x+n);
    for(i=0;i<n-k+1;i++) ans = min(ans,x[i+k-1]-x[i]);
    cout << ans;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int m = sc.nextInt();
    int r[] = new int[m*2];
    int cnt[] = new int[n];
    
    
    //入力値を配列に格納
    for(int i = 0; i < m*2; ++i){
      r[i] = sc.nextInt();
    }

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

      for(int j = 0; j < m*2 ; ++j){
        if(i==r[j]){
          cnt[i-1] += 1;
        }
      
      }
      
      System.out.println(cnt[i-1]);       
    }
  }
}

Measured memory_bytes: 35972
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace  std;

#define TRACE(x) cout << #x << " = " << x << endl;

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

const int MAXN = 310;

int n;
int niz[MAXN];

double dp[MAXN][MAXN][MAXN];

/*double rek(int a, int b, int c) {
	if(a == 0 && b == 0 && c == 0) return 0;
	double &ret = dp[a][b][c];
	if(ret > -0.5) return ret;
	ret = 0;
	if(a != 0) ret += ((double)a / (a + b + c)) * (rek(a - 1, b, c) + (double) (n - b - c) / a);
	if(b != 0) ret += ((double)b / (a + b + c)) * (rek(a + 1, b - 1, c) + (double) (n - a - c) / b);
	if(c != 0) ret += ((double)c / (a + b + c)) * (rek(a, b + 1, c - 1) + (double) (n - a - b) / c);
	cout << a << " " << b << " " << c << ": " << ret << endl;
	return ret;
}*/

double rek(int a, int b, int c) {
	if(a == 0 && b == 0 && c == 0) return 0;
	double &ret = dp[a][b][c];
	if(ret > -0.5) return ret;
	ret = 0;
	if(a != 0) ret += (double) a / n * (rek(a - 1, b, c) + 1);
	if(b != 0) ret += (double) b / n * (rek(a + 1, b - 1, c) + 1);
	if(c != 0) ret += (double) c / n * (rek(a, b + 1, c - 1) + 1);
	ret += (double)(n - a - b - c)/n;
	ret *= n;
	ret /= (double)(a + b + c);
	//cout << a << " " << b << " " << c << ": " << ret << endl;
	return ret;
}

int main() {
	scanf("%d", &n);
	int a = 0, b = 0, c = 0;
	REP(i, n) {
		int x;
		scanf("%d", &x);
		if(x == 1) a++;
		else if(x == 2) b++;
		else c++;
	}
	REP(i, MAXN) REP(j, MAXN) REP(k, MAXN) dp[i][j][k] = -1;
	printf("%.12lf\n", rek(a, b, c));
	return 0;
}

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

int main(){
  string S,x,y;
  cin>>S;
  int N=S.size();
  for(int i=0;i<(N-1)/2;i++){
    x+=S.at(i);
    y+=S.at(i+(N+3)/2-1);
  }
  string z;
  for(int i=x.size()-1;i>=0;i--){
    z+=x.at(i);
  }
  if(x==y&&z==x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
an = 0
 
while 1:
    for i in range(n):
        if a[i]%2==0:
            a[i] = a[i]/2
        else:
            print(an)
            exit()
    else:
        an+=1
 
print(an)

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	ll n,k;
	cin>>n>>k;
	ll n1=n/k;
	ll ans=min(n-(n1*k),((n1+1)*k)-n);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  bool flg = false;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(i * j == n) flg = true;
    }
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


class UnionFind(object):
    __slots__ = ["nodes"]

    def __init__(self, n: int):
        self.nodes = [-1]*n # 親: -(属するノード数), それ以外: (親ノードindex)

    def find(self, x: int) -> int:
        if self.nodes[x] < 0:
            return x
        else:
            self.nodes[x] = self.find(self.nodes[x]) # compression
            return self.nodes[x]

    def has_same_root(self, x, y) -> bool:
        return self.find(x) == self.find(y)
    
    def size(self, x) -> int:
        return -self.nodes[self.find(x)]

    def unite(self, x: int, y: int) -> None:
        if self.has_same_root(x, y):
            return

        root_x, root_y = self.find(x), self.find(y)
        if self.nodes[root_x] < self.nodes[root_y]:
            bigroot, smallroot = (root_x, root_y)
        else: 
            bigroot, smallroot = (root_y, root_x)
        self.nodes[bigroot] += self.nodes[smallroot]
        self.nodes[smallroot] = bigroot


def solve(N: int, M: int, X: "List[int]", Y: "List[int]", Z: "List[int]"):
    UFT = UnionFind(N)
    for i in range(M):
        UFT.unite(X[i], Y[i])
    cluster = set(UFT.find(i) for i in range(N))
    print(len(cluster))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = [int()] * (M)  # type: "List[int]" 
    Y = [int()] * (M)  # type: "List[int]" 
    Z = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        X[i] = int(next(tokens)) - 1
        Y[i] = int(next(tokens)) - 1
        Z[i] = int(next(tokens)) % 2
    solve(N, M, X, Y, Z)

if __name__ == '__main__':
    main()


Measured memory_bytes: 86620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main
{
    static long dp[][][];
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        String str[]=br.readLine().split(" ");
        dp=new long[str.length+1][str.length+1][2];
        for(int i=0;i<dp.length;i++)
            for(int j=0;j<dp[0].length;j++)
                for(int k=0;k<dp[0][0].length;k++)
                    dp[i][j][k]=-Long.MIN_VALUE;
        int arr[]=new int[str.length];
        for(int i=0;i<str.length;i++)
            arr[i]=Integer.parseInt(str[i]);
        System.out.println(calculate(arr,0,arr.length-1,0));
    }

    private static long calculate(int[] arr, int i, int j, int turn) {
        if(i>j)
            return 0;
        if(dp[i][j][turn]!=Long.MIN_VALUE)
            return dp[i][j][turn];
        if(turn==0)
        {
            return dp[i][j][turn]= Math.max(arr[i]+calculate(arr,i+1,j,1),arr[j]+calculate(arr,i,j-1,1));
        }
        else
            return dp[i][j][turn]= Math.min(-arr[i]+calculate(arr,i+1,j,0),-arr[j]+calculate(arr,i,j-1,0));
    }
}

Measured memory_bytes: 352328
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    ll n;
    cin>>n;
    ll a = 0,b = 0;
    rep(i,1,sqrt(n)){
        if(n % i == 0){
            a = i;
            b = n / a;
        }
    }
    cout<<(a-1)+(b-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x, res = 0;
    cin >> x;
    for (int i = x; i < 1000; i++) {
        if ((i % 111) == 0) {
            res = i;
            break;
        }
    }
    cout << res << endl;
    
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    char a, b;
    cin >> a >> b;
    if (a == b) cout << "H" << endl;
    else cout << "D" << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main () {
    int n, flag=0;
    cin >> n;
    int a[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
        if (a[i]%2==0) {
            if (a[i]%3!=0 && a[i]%5!=0) {
                flag=1;
            }
        }
    }

    if (flag==1) {
        cout << "DENIED";
    }
    else {
        cout << "APPROVED";
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp;


macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }
 
 

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let patterns: Vec<Vec<char>> = ["dream", "dreamer", "erase", "eraser"]
        .iter()
        .map(|s| s.chars().rev().collect())
        .collect();
    let s: Vec<char> = read::<String>().chars().rev().collect();
    let mut s = &s[..];
    let mut succeeded = true;
    while s.len() > 0 {
        let matched = patterns.iter().find(|&p| s.starts_with(p));
        if let Some(p) = matched {
            s = &s[p.len()..];
        } else {
            succeeded = false;
            break;
        }
    }
    println!("{}", if succeeded { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll dic[100005];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >>n;
    ll a[n];
    rp(i,n){
      cin >> a[i];
      if(a[i] < 100005) dic[a[i]]++;
    }
    ll sum=0;
    rp(i,100005){
      if(dic[i] >= i) sum+=i;
    }
    cout << n - sum << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

const int INF = 1000000007;

int main () {

    int H, W;
    scanf("%d %d", &H, &W);

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

    int A[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            scanf("%d", &A[i][j]);
        }
    }

    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] != -1) {
                ans += c[A[i][j]][1];
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>


#define DEBUG if(false)

using namespace std;

using ll = long long;
const int MOD = 1000000007;

int main(){
  string S, T;
  cin >> S >> T;
  bool boolean = true;;
  for(int i = 0; i < S.length(); i++){
    if(S[i] != T[i]){
      boolean = false;
    }
  }
  if(boolean){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int s,w;
	cin>>s>>w;
	
	cout<<((w>=s)?"unsafe":"safe")<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
    int n, a[100000+5];
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%d", &a[i]);
    int four=0, odd=0;
    for(int i=0; i<n; i++){
        if(a[i]%4==0)four++;
        else if(a[i]%2==1)odd++;
    }
    if(odd<=four || (odd==four+1 && odd+four==n))printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 1992
L=int(input());S=bin(L);N=len(S)-2;print(N,2*N+S.count("1")-3)
for i in range(1,N):
 for j in[0,1]:print(i,i+1,j*2**~-i)
 if int(S[-i]):L^=2**~-i;print(i,N,L)

Measured memory_bytes: 3060
S=input()+'R'
n=len(S)-1
a=[0]*n
r=0
while r<n:
    l=S.find('L',r)
    a[l]+=(l-r)//2
    a[l-1]+=(l-r+1)//2
    r=S.find('R',l)
    a[l]+=(r-l+1)//2
    a[l-1]+=(r-l)//2
print(*a)


Measured memory_bytes: 78896
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }

////////////////////////////////////////////////////////////////

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = pow(10, 9) + 7;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};


////////////////////////////////////////////////////////////////

int main(void) {

	int N, M;
	cin >> N >> M;

	int ans = 0;
	if(N>=2) ans += N * (N-1) / 2;
	if(M>=2) ans += M* (M-1) /2;

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 256
L, R = [int(i) for i in input().split()]
num_list = []
if R-L > 2019:
  print(0)
else:
  for i in range(R-L):
    for j in range(R-L-i):
      x = (L + i)%2019
      y = (L + i + j + 1)%2019
      num = (x*y)%2019
      num_list.append(num)
  print(min(num_list))

Measured memory_bytes: 75416
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 214748364700000
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N, C;
int ctl[40][100010];
int tl[100010];


void makeTL(){
	rep(i, 0, C)
		rep(j, 1, 100010)
			ctl[i][j] += ctl[i][j-1];
	rep(i, 0, C)
		rep(j, 0, 100010)
			if(ctl[i][j]) tl[j]++;
}


signed main(){
	cin >> N >> C;
	rep(i, 0, N){
		int s, t, c;
		cin >> s >> t >> c;
		s--, c--;
		ctl[c][s]++;
		ctl[c][t]--;
	}
	
	makeTL();

	cout << *max_element(RNG(tl, 0, 100010)) << endl;

	return 0;
}

Measured memory_bytes: 12544
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 5100000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7
vector<ll> fac(MAX), finv(MAX), inv(MAX);

int main(){
    ll n,m; cin >> n >> m;
    vector<vpl> G(n);
    rep(i,m){
        ll a,b,c; cin >> a >> b >> c; a--; b--;
        G[a].emplace_back(b,c);
        G[b].emplace_back(a,-c);
    }
    set<ll> se;
    rep(i,n) se.insert(i);
    vl x(n,inf);
    while(!se.empty()){
        ll s = *se.begin(); se.erase(s);
        if(x[s] != inf) continue;
        if(G[s].empty()) continue;
        stack<ll> q;
        q.push(s);
        x[s] = 0;
        while(!q.empty()){
            ll u = q.top(); q.pop();
            for(auto v : G[u]){
                if(x[v.first]==inf){
                    x[v.first] = x[u] + v.second;
                    q.push(v.first);
                }
                else{
                    if(x[v.first] != x[u] + v.second){
                        puts("No");
                        return 0;
                    }
                }
            }
        }
    }
    puts("Yes");
}


Measured memory_bytes: 137600
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

fn main() {
    input!{
        N: usize,
        W: [i32; N],
    }
    let mut ret = 100;
    for t in 0..N {
        let mut l = 0;
        for n in 0..t {
            l += W[n];
        }
        let mut r = 0;
        for n in t..N {
            r += W[n];
        }
        if ret > (r - l).abs() {
            ret = (r - l).abs()
        }
    }

    println!("{}", ret);
}



Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 1005
#define M 30005
#define ll long long 
#define INF 0x3f3f3f3f
#define MOD 10000000
inline ll rd()
{
	ll f=1ll,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-f;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
ll n;
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	//ios::sync_with_stdio(false);
	n=rd();
	ll a=(int)sqrt(n);
	for(ll i=a;i>=1;i--)
		if(n%i==0)
		{
			ll b=n/i;
			//printf("%d %d\n",i,b);
			printf("%lld\n",i+b-2);
			return 0;
		}
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Threading;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var x = cin.ReadIntArray(N + 1);
            Array.Sort(x);
            var ans = x[1] - x[0];
            for (int i = 1; i < N; i++)
            {
                ans = gcd(ans, x[i + 1] - x[i]);
            }
            Console.WriteLine(ans);
        }

        static int gcd(int a, int b)
        {
            return a == 0 ? b : gcd(b % a, a);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = i+1; j < N; j++)
        {
            for(int k = j+1; k < N; k++)
            {
                if(A[i] == A[j] || A[i] == A[k] || A[j] == A[k]) continue;
                int len = A[i] + A[j] + A[k];
                int ma = max(A[i], max(A[j], A[k]));
                if(ma < len-ma) ans++;
            }
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define step(i,s,n,c) for(int i=(s);i<(n);i+=(c))
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define each(i,vec) for(auto i:vec)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  int n,x;
  cin>>n>>x;
  cinv(n,l);

  VL D(n+1);
  D[0]=0;
  reps(i,n){
    D[i]=D[i-1]+l[i-1];
  }
  int sum=0;
  rep(i,n+1)if(D[i]<=x)sum++;
  out(sum);
  
  
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[3000];
int main(){
  int res;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS;
    if(N==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = A[0];
      for(KL2GvlyY=(1);KL2GvlyY<(N);KL2GvlyY++){
        Q5VJL1cS += A[KL2GvlyY];
      }
    }
    res =Q5VJL1cS- N;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int N, A[3000];
// {
//   int res;
//   rd(N,A(N));
//   res = sum(A(N)) - N;
//   wt(res);
// }


Measured memory_bytes: 256
n = int(input())
r_min = int(input())
r_t   = int(input())
g_max = r_t - r_min
r_min = min(r_t,r_min)
for _ in range(n-2):
    r_t = int(input())
    g_max = max(g_max, r_t-r_min)
    r_min = min(r_t,r_min)
print(g_max)


Measured memory_bytes: 5612
// Kab khoon khaulega re tera?

#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int N = 3e5 + 5;
ll a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x, y;
    cin >> x >> y;
    cout << x * y;
return 0;
}



Measured memory_bytes: 3644