akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int x,ans=0;
  cin>>x;
  for(int i=1;i<=10000;i++){
    if(100*i<=x && x<=105*i){
      ans=1;
    }
  }
  cout<<ans;
}


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

typedef long long int int64;
int64 mod;
int64 qpow(int64 a,int b)
{
	int64 c = 1;
	for(int i = 30;i >= 0;--i) {
		c = c * c % mod;
		if(((b>>i)&1)==1) c = c * a % mod;
	}
	return c;
}
int64 f[3002][3002];
int64 pow2[3001];
int64 inv[3001],fac[3001],invfac[3001];
int64 choice(int a,int b)
{
	if(a < b || b < 0) return 0;
	return fac[a] * invfac[b] % mod * invfac[a-b] % mod;
}
int n;
int main()
{
	scanf("%d%lld",&n,&mod);
	f[0][0] = 1;
	for(int i = 1;i <= n;++i) {
		for(int j = 1;j <= n;++j) {
			f[i][j] = (f[i-1][j-1] + f[i-1][j] * j) % mod;
		}
	}
	pow2[0] = 2;
	for(int i = 1;i <= n;++i) pow2[i] = (pow2[i-1]*pow2[i-1])%mod;
	fac[0] = fac[1] = invfac[0] = invfac[1] = inv[1] = 1;
	for(int i = 2;i <= n;++i) {
		fac[i] = (fac[i-1]*i)%mod;
		inv[i] = (mod-mod/i)*inv[mod%i]%mod;
		invfac[i] = (invfac[i-1]*inv[i])%mod;
	}
	int64 ans = 0;
	for(int i = 0;i <= n;++i) { // # of 0,1 toppings
		int64 coe = choice(n,i) * pow2[n-i] % mod;
		int64 val = 0;
		int64 w1 = 1, w2 = qpow(2,n-i);
		for(int j = 0;j <= i;++j) { // # of ramen with topping 1..i
			val += (f[i][j+1]*(j+1) + f[i][j]) % mod * w1 % mod;
			w1 = w1 * w2 % mod;
		}
		if(i % 2 == 1) coe = -coe;
		ans += coe * (val % mod) % mod;
	}
	ans %= mod;
	if(ans < 0) ans += mod;
	printf("%lld\n", ans);
}


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

using i64 = long long;

const int N = 2e5 + 5;

int l[N];

int main() {
#ifdef HOME
	freopen("agc.in", "r", stdin);
	freopen("agc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, t;

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> t;
		l[t] = l[t - 1] + 1; }

	cout << n - *max_element(l + 1, l + n + 1) << endl;

	return 0; }


Measured memory_bytes: 1024
require 'prime'

class Integer
  def divisor_list
    return [] if self <= 0
    return [1] if self == 1

    prime_division.map.with_index { |(base, k), i|
      s = i.zero? ? 0 : 1
      (s..k).map { |n| base ** n }
    }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort
  end
end

n = gets.to_i

if n.prime?
  puts n - 1
  exit
end

sqrt = Math.sqrt(n)
y = n.divisor_list.bsearch { |x| x >= sqrt }
puts y + (n / y) - 2

Measured memory_bytes: 2428
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

def pne(n):
    print(n,end='')

rem = pow(10,9)+7

#n = ip()                                     #入力整数1つ
#x,y= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
b = ["A","C","T","G"]
s = [0]
c = 0
for i in range(len(a)):
    if a[i] in b:
        c+=1
    else:
        s.append(c)
        c=0
s.append(c)
print(max(s))


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

using namespace std;

typedef long long int ll;

int main()
{
    ll n;
    cin>>n;
    if(n%10!=1&&n%10!=3&&n%10!=7&&n%10!=9)
        cout<<"-1";
    else{
        ll k=7,cnt=1;
        while(k%n!=0){
            k=k%n;
            k=10*k+7;
            cnt++;
        }
        cout<<cnt;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define print(a) {\
    for (auto i : a) cout << i << ' ';\
    cout << '\n';\
}
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define pii pair<int,int> 
#define pdd pair<ld,ld> 
#define ld double
#define pll pair<lli,lli>
#define tiii tuple<int,int,int>
#define all(a) a.begin(), a.end()
#define X first
#define Y second
#define oset tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
auto SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);

const int mod = 1e8, x = 864197532, N = 100000, logN = 17;

int main () {
	lli a;
	string b;
	cin >> a >> b;
	int c = 0;
	c = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
	lli ans = a * c;
	cout << ans / 100 << endl;
}

Measured memory_bytes: 3632
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

def main():
    sx,sy,tx,ty = na()
    ret = ""
    for i in range(tx-sx):
        ret += "R"
    for i in range(ty-sy):
        ret += "U"
    for i in range(tx-sx):
        ret += "L"
    for i in range(ty-sy):
        ret += "D"
    ret += "L"
    for i in range(ty-sy+1):
        ret += "U"
    for i in range(tx-sx+1):
        ret += "R"
    ret += "D"
    ret += "R"
    for i in range(ty-sy+1): ret += "D"
    for i in range(tx-sx+1): ret += "L"
    ret += "U"
    print(ret)
    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  cout << (n * 500 >= k ? "Yes" : "No") << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int a, b, c, d,flag = 0, count = 0;
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        d = sc.nextInt();
        while(flag == 0){
            if(count % 2 == 0){
                c -= b;
                if(c <= 0){
                    System.out.println("Yes");
                    flag = 1;
                }else{
                    a -= d;
                    if(a <= 0){
                        System.out.println("No");
                        flag = 1;
                    }
                }
            }

        }

    }
}

Measured memory_bytes: 35812
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int[] a = new int[n];
		
		for(int i=0;i<n;i++)
		{
			a[i] = stdIn.nextInt();
		}
		
		for(int i=n-1;i>=0;i--)
		{
			System.out.print(a[i]);
			
			if(i!=0)
			{
				System.out.print(" ");
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 19712
/*
ID: jsnjhcb1
PROG: b
LANG: C++
*/
/*************************************************************************
	> File Name: b.cpp
	> Author: UCU
	> Mail: jsnjhcb@icloud.com
	> Created Time: 六 11/12 20:51:02 2016
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<string>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<iomanip>
#include<climits>
#include<fstream>
using namespace std;
int a[20010];
int b[20010];
int p[20010];
int sum[20010];
int main(){
    int n;
    scanf("%d",&n);
    p[0] = 0;
    for(int i=1;i<=n;++i){
        scanf("%d",p+i);
    }
    a[0] = 1;
    for(int i=1;i<=n;++i){
        a[i] = a[i - 1] + 20001; 
    }
    b[n + 1] = 1;
    for(int i=n;i>=1;--i){
        b[i] = b[i + 1] + 20001; 
    }
    for(int i=1;i<=n;++i){
        a[p[i]] += i;
    }
    for(int i=1;i<=n;++i){
        printf("%d",a[i] + 1);
        if(i != n)
            printf(" ");
    }
    printf("\n");
    for(int i=1;i<=n;++i){
        printf("%d",b[i] + 1);
        if(i != n)
            printf(" ");
    }
    printf("\n");
    return 0;
}


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

using namespace std;

int main()
{
	string s,s1,s2;
	cin>>s1>>s2;
	s=s2+"_"+s1;
	static int next[1100000];
	memset(next,0,sizeof(next));
	next[0]=-1;
	for(int i=1;i<s.size();i++)
	{
		int j;
		for(j=next[i-1];s[j+1]!=s[i]&&j>=0;j=next[j]);
		next[i]=(s[j+1]==s[i]?j+1:-1);
	}
	for(int i=s2.size()+1;i<s.size();i++)
		if(next[i]+1==s2.size())
			printf("%d\n",i-s2.size()*2);
	return 0;
}

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

int main(){
  int N, M, num=0, res;
  cin >> N >> M;
  vector<int> A(M);
  for(int i = 0; i < M; i++){
  	cin >> A[i];
    num += A[i];
  }
  
  res = N - num;
  if(res>=0){
  	cout << res << endl;
  }else{
  	cout << -1 << endl;
  }
  
 return 0;
}

Measured memory_bytes: 3664
a,b = map(int,input().split())
dp = [0]*(100010)
qp = [0]*(100010)
for i in range(b):
    ta,tb = map(str,input().split())
    ta = int(ta)
    if qp[ta] == 0 :
        if tb == 'WA':
            dp[ta]+=1
        else :
            qp[ta]=1
ANS = 0
for i, j in zip(dp,qp):
    ANS += i*j
print(sum(qp),ANS)

Measured memory_bytes: 4596
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define upd(a, b) b = add(a + b)
#define fi first
#define se second
using namespace std;
inline char nc() {
//	return getchar();
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
typedef pair<int, int> pii; 
const int mod = 1e9 + 7;
const int maxn = 300 + 5;
const int c[3][2] = {{1, 2}, {0, 2}, {0, 1}};
int n, m;
int f[2][maxn][maxn][3];
vector<pii> rec[maxn];
inline int add(int x) {
	return x >= mod ? x - mod : x;
}
void maintain(int cur, int n, int l, int x) {
	for(int i = 0; i <= n; ++i) {
		for(int j = 0; j <= n; ++j) {
			for(int t = 0; t < 3; ++t) {
				if(1 + (i >= l) + (j >= l) == x) continue;
				f[cur][i][j][t] = 0;
			}
		}
	}
}
int solve() {
	int cur = 0;
	f[cur][0][0][0] = f[cur][0][0][1] = f[cur][0][0][2] = 1;
	for(unsigned int i = 0; i < rec[1].size(); ++i) {
		if(rec[1][i].se != 1) return 0;
	}
	for(int i = 2; i <= n; ++i) {
		cur ^= 1;
		memset(f[cur], 0, sizeof(f[cur]));
		for(int j = 0; j <= i; ++j) {
			for(int k = 0; k <= i; ++k) {
				upd(f[cur ^ 1][j][k][0], f[cur][j][k][0]);
				upd(f[cur ^ 1][j][k][1], f[cur][j][k][1]);
				upd(f[cur ^ 1][j][k][2], f[cur][j][k][2]);
				upd(f[cur ^ 1][j][k][0], f[cur][i - 1][k][1]);
				upd(f[cur ^ 1][j][k][1], f[cur][i - 1][k][0]);
				upd(f[cur ^ 1][j][k][2], f[cur][k][i - 1][0]);
				upd(f[cur ^ 1][j][k][0], f[cur][i - 1][j][2]);
				upd(f[cur ^ 1][j][k][1], f[cur][j][i - 1][2]);
				upd(f[cur ^ 1][j][k][2], f[cur][j][i - 1][1]);
			} 
		}
		for(unsigned int j = 0; j < rec[i].size(); ++j) {
			maintain(cur, i, rec[i][j].fi, rec[i][j].se);
		}
	}
	int an = 0;
	for(int i = 0; i <= n; ++i) {
		for(int j = 0; j <= n; ++j) {
			for(int t = 0; t < 3; ++t) {
				upd(f[cur][i][j][t], an);
			}
		}
	}
	return an;
}
int main() {
	read(n), read(m);
	for(int i = 1; i <= m; ++i) {
		int l, r, x; read(l), read(r), read(x);
		rec[r].push_back(make_pair(l, x));
	}
	printf("%d\n", solve());
	return 0;
}

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

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

    for(int i=0; i<n; i++){
        string ord;
        cin >> ord;
        if(ord == "print"){
            int a,b;
            cin >> a >> b;
            cout << s.substr(a, b-a+1) << endl;
        }
        if(ord == "reverse"){
            int a,b;
            cin >> a >> b;
            reverse(s.begin()+a, s.begin()+b+1);
        }
        if(ord == "replace"){
            int a,b;
            string rep;
            cin >> a >> b >> rep;
            s.replace(a, b-a+1, rep);
        }
    }
    return 0;
}


Measured memory_bytes: 3200
N,W=map(int,input().split())
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,N+1):
  w,v=map(int,input().split())
  for j in range(1,w):
    dp[i][j]=dp[i-1][j]
  for j in range(w,W+1):
    if w<=j:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v)
print(dp[N][W])

Measured memory_bytes: 173192
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int X, N; std::cin >> X >> N;
    std::vector<bool> okay(102, true);
    {
        int p;
        for(int i(0); i < N; ++i){
            std::cin >> p;
            okay[p] = false;
        }
    }
    for(int i(0); i <= 101; ++i){
        if(X >= i){
            if(okay[X-i]){
                std::cout << X - i << std::endl;
                return 0;
            }
        }
        if(X+i <= 101){
            if(okay[X+i]){
                std::cout << X + i << std::endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int a[111111];
int main() {
	int n;
	cin >> n;
	for(int i(0); i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	bool flag;
	for(int i(0); i < n; i++) {
		if(n - i <= a[i]) {
			if(i > 0 && a[i - 1] == a[i]) {
				flag = 0;
				while(i > 0 && a[i - 1] == a[i]) {
					flag ^= 1;
					i--;
				}
			}else if(a[i - 1] == n - i) {
				flag = (a[i] - n + i) % 2 == 1 || (a + i - 1 - lower_bound(a, a + n, a[i - 1])) % 2 == 0;
			}else {
				flag = (a[i] - n + i) % 2;
			}
			break;
		}
	}
	cout << (flag ? "First" : "Second") << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(int i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

const int MAX=1e6;
vector<pll>g[MAX];
bool vis[MAX];
int ans[MAX];
void dfs(pll u){
    vis[u.ft]=true;
    for(auto &x:g[u.ft]){
        if(!vis[x.ft]){
            if(x.sd%2==0){
                ans[x.ft]=ans[u.ft];
            }else{
                ans[x.ft]=!ans[u.ft];
            }
          dfs(x);
        }
    }
}
int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif

int n;
cin>>n;
    int u,v,y;
forn(i,0,n-1){
    cin>>u>>v>>y;
    u--;v--;
    g[u].pb({v,y});
    g[v].pb({u,y});
}
dfs({0,0});
forn(i,0,n){
    cout<<ans[i]<<endl;
}
}


Measured memory_bytes: 34172
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int R,G;
  cin >> R >> G;
  cout << 2*G - R << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int t[] = new int[n];
            for (int i = 0; i < n; i++) {
                t[i] = Integer.parseInt(in.next());
            }
            int m = Integer.parseInt(in.next());
            int px[][] = new int[m][2];
            for (int i = 0; i < m; i++) {
                px[i][0] = Integer.parseInt(in.next());
                px[i][1] = Integer.parseInt(in.next());

            }
            int ans = 0;

            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    ans += t[j];
                }
                ans = ans - t[px[i][0] - 1] + px[i][1];
                // 出力
                out.println(ans);
                ans = 0;
            }

        }

    }
}



Measured memory_bytes: 21844
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = Array.new(n){|i|a[i]-b[i]}.sort
m = 0
ans = 0
for i in 0..n-1
    break if c[i] >= 0
    m -= c[i]
    ans += 1
end
(n-1).downto(0) do |i|
    break if m <= 0
    m -= c[i]
    ans += 1
end
if c.inject(:+) >= 0
    puts ans
else
    puts "-1"
end

Measured memory_bytes: 18120
#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>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    
int main(){
    string s;
    cin >> s;
    if(s[s.size()-1]=='s') s = s + "es";
    else s = s + "s";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	@SuppressWarnings("unchecked")
	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; ++i)
			A[i] = sc.nextInt();
		PriorityQueue<Long> pq1 = new PriorityQueue();
		PriorityQueue<Long> pq2 = new PriorityQueue();
		ArrayList<Integer> ans = new ArrayList();
		for (int i = 0; i < N; ++i) {
			pq1.add(A[i]);
			pq2.add(A[N - 1 - i]);
			while (!pq1.isEmpty() && pq1.peek().equals(pq2.peek())) {
				pq1.poll();
				pq2.poll();
			}
			if (pq1.isEmpty()) {
				ans.add(i + 1);
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < ans.size(); ++i) {
			pw.print(ans.get(i) + (i == ans.size() - 1 ? "\n" : " "));
		}
		pw.close();
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


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

int main() {
  string s;
  cin >> s;
  if (s.size() == 2) {
    cout << s << endl;
  }
  else {
    for (int i = 2; i >= 0; i--) {
      cout << s[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main () {
    string E, O;
    cin >> E >> O;
     for (int i=0; i < E. size () - 1 ; i++) {
     cout << E[i];
     cout << O[i];
  }
cout << E[E.size() - 1];
   if(E.size() == O. size () ) cout << O[O.size() - 1];
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int maxn = 200100;
const long long oo = 1e18;
int n;
long long a[maxn];
long long f[maxn][5];
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	for(int i = 1; i <= n; i ++)
		for(int j = 0; j < 5; j ++)
			f[i][j] = oo;
	for(int i = 1; i <= n; i ++)
	{
		long long mn = f[i - 1][0];
		f[i][0] = mn + a[i];
		mn = min(mn, f[i - 1][1]);
		f[i][1] = mn + (a[i] == 0 ? 2 : a[i] % 2);
		mn = min(mn, f[i - 1][2]);
		f[i][2] = mn + (a[i] % 2 != 1);
		mn = min(mn, f[i - 1][3]);
		f[i][3] = mn + (a[i] == 0 ? 2 : a[i] % 2);
		mn = min(mn, f[i - 1][4]);
		f[i][4] = mn + a[i];
	}
	cout << min(f[n][1], min(f[n][2], min(f[n][3], f[n][4]))) << endl;
	return 0;
}

Measured memory_bytes: 9600
a, b, c, d = map(int, input().split())
x = [a, b]
y = [c, d]
maxVal = max(x)*max(y)
if min(x)*min(y) > maxVal and min(x)*min(y) > min(x)*max(y) and min(x)*min(y) > max(x)*min(y):
    res = min(x)*min(y)
elif min(x)*max(y) > maxVal and min(x)*max(y) > min(x)*min(y) and min(x)*max(y) > max(x)*min(y):
    res = min(x)*max(y)
elif max(x)*min(y) > maxVal and max(x)*min(y) > min(x)*max(y) and max(x)*min(y) > min(x)*min(y):
    res = max(x)*min(y)
else:
    res = maxVal
print(res)


Measured memory_bytes: 9216
#include <iostream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <limits>

#define _USE_MATH_DEFINES

#include <math.h>

using namespace std;

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

    int R;
    cin >> R;
    cout << (R * 2 * M_PI) << endl;

    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int H,W,K;
    cin >> H >> W >> K;
    char C[H+1][W+1];
    int e=0;

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> C[i][j];
            
        }
    }
    int ans = 0;
    for(int divh=0;divh<1<<(H);divh++){ // i< 2^h-1
        for(int divw=0;divw<1<<(W);divw++){
            int e=0;
            rep(i,H) {
                rep(j,W){
                    if (divh>>i&1 && divw>>j&1){
                        if(C[i][j] == '#'){
                            e++;
                        }
                    }
                }
            }
            if(e==K){
                ans++;
            }
        }
    }


    cout << ans ;

    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            Main main = new Main();

            main.solveA(sc);
            // main.solveB(sc);
            // main.solveC(sc);
            // main.solveD(sc);
            // main.solveE(sc);

        }

    }

    private void solveD(Scanner sc) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out)) {
        } catch (IOException e) {

        }
    }

    private void solveE(Scanner sc) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out)) {

        } catch (IOException e) {

        }
    }

    private void solveC(Scanner sc) {
    }

    void solveB(Scanner sc) {
    }

    void solveA(Scanner sc) {
        runA(sc.nextLong());
    }

    private void runA(long num) {
        if (num == 1) {
            System.out.println("1");
            return;
        }
        long min = 1;
        long max = num;
        while (min + 1 < max) {
            long now = (min + max) / 2;
            long x = now * (now + 1) / 2;

            if (x > num) {
                max = now;
            } else if (x == num) {
                System.out.println(now);
                return;
            } else {
                min = now;
            }
        }
        System.out.println(min + 1);
    }

    private static int binarySearch(int[] list, int num) {
        int max = list.length;
        int min = 0;
        while (min + 1 < max) {
            int now = (max + min) / 2;
            if (list[now] > num) {
                max = now;
            } else {
                min = now;
            }
        }
        return min;
    }
}


Measured memory_bytes: 23508
Scanf.scanf "%d %d" (fun h w ->
    let a = Array.init h (fun _ -> Scanf.scanf " %s" (fun s -> s)) in 

    let rec loop x y f =
        let xf = x < w - 1 && a.(y).[x + 1] = '#' in
        let yf = y < h - 1 && a.(y + 1).[x] = '#' in
        let zf = x > 0     && a.(y).[x - 1] = '#' in
        let wf = y > 0     && a.(y - 1).[x] = '#' in
        if xf && yf then false else
            if f = 0 && wf then false else
            if f = 1 && zf then false else
            if xf then loop (x + 1) y 0 else
            if yf then loop x (y + 1) 1 else
            if x = w - 1 && y = h - 1 then true else
                false

    in
    print_endline @@ if loop 0 0 3 then "Possible" else "Impossible"
)

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define repi(i, a, b) for (long long i = (long long)(a); i < (long long)(b); i++)
#define drep(i, n) for (long long i = n - 1; i > 0; i--)
#define pb push_back
#define pb push_back
#define all(x) (x).begin(), (x).end()

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), col(w, false);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (a[i][j] == '#')
            {
                col[j] = true;
                row[i] = true;
            }
        }
    }

    for (int i = 0; i < h; i++)
    {
        if (row[i] == true)
        {
            for (int j = 0; j < w; j++)
            {
                if (col[j] == true)
                {
                    cout << a[i][j];
                }
            }
            cout << "\n";
        }
    }
    return 0;
    /* ABC 031 A
    int a, b,a_plus_ans,b_plus_ans;
    cin >> a >> b;

    b_plus_ans = (b+1)*a;
    a_plus_ans = (a+1)*b;

    if (a_plus_ans >= b_plus_ans)
    {
        cout << (a + 1) * b << endl;
    }
    else
    {
        cout << (b + 1) * a << endl;
    }

    return 0;*/
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest9
{
    class Program
    {
        public class Sub
        {
            static public int func(int num)
            {
                num += 1;// 0,1を無くすため
                int ret = 0;

                bool[] num_array = new bool[num];

                for (int i = 0; i < num;i++ )
                {
                    num_array[i] = true;
                }
                num_array[0] = false;
                num_array[1] = false;

                for (int act = 2; act < num; act++)
                {
                    if (num_array[act] == true)
                    {
                        int tmp = act * 2;
                        while (tmp < num)
                        {
                            num_array[tmp] = false;
                            tmp += act;
                        }
                    }
                }

                for (int i = 0; i < num; i++)
                {
                    if (num_array[i] == true)
                    {
                        ret++;
                    }
                }

                return ret;
            }
        }

        static void Main(string[] args)
        {
            while (true)
            {
                var line_origin = Console.ReadLine();

                if (string.IsNullOrEmpty(line_origin))
                {
                    break;
                }

                int num = int.Parse(line_origin);

                //素数の個数を探す　エラトステネスのふるい
                int ans = Sub.func(num);
                Console.WriteLine(ans.ToString());
            }
        }
    }
}

Measured memory_bytes: 6960
import java.util.*
import java.util.Comparator



fun main(args: Array<String>){
    var (N,M) = readLine()!!.split(" ").map{ it.toLong()}
    var A = readLine()!!.split(" ").map{it.toLong()}

    var map = mutableMapOf<Long,Long>()

    for(i in 0 until N){
        if(map.containsKey(A[i.toInt()])){
            map.set(A[i.toInt()],map[A[i.toInt()]]!!+1)
        } else {
            map.set(A[i.toInt()],1)
        }
    }

    for(i in 0 until M){
        val (B,C) = readLine()!!.split(" ").map{it.toLong()}
        if(map.containsKey(C)){
            map.set(C,map[C]!!+B)
        } else{
            map.set(C,B)
        }
    }

    val comparator = Comparator<Long> { a, b ->
        when {
            a > b -> -1
            else -> 1
        }

    }

    val sortedMap = map.toSortedMap(comparator)
    
    var ans : Long =0

    var size = A.size.toLong()

    for((k,v) in sortedMap){

        if(size >= v){
            ans += k * v
            size -=v
        } else {
            ans  += k * size
            size =0
        }


        if(size == 0L) break
    }
    println(ans)



}

Measured memory_bytes: 85364
#include<stdio.h>

int main(){
	int h,a,d,c;
	scanf("%d %d",&h,&a);
	d = h % a;
	c=h/a;
	if(d>=1){
		printf("%d",c+1);
	}
	if(d<1){
		printf("%d",c);
	}
	
}

Measured memory_bytes: 1692
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n, q = map(int, input().split())

tree = [[] for _ in range(n)]
for i in range(n-1) :
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree[a].append(b)
  tree[b].append(a)

ans = [0 for i in range(n)]
for i in range(q) :
  p,x = map(int, input().split())
  p -= 1
  ans[p] += x

check = [0 for _ in range(n)]
def dfs(st) :
  check[st] = 1
  for ne in tree[st] :
    if check[ne] == 1 :
      continue
    ans[ne] += ans[st]
    dfs(ne)

dfs(0)

print(*ans)

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

#define dbl double
const int siz = 3007;

int n;
dbl dp [siz][siz];
dbl tab [siz];

int main(){
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%lf",&tab[i]);
    }

    dp[0][0] = 1.0;
    for(int i = 1; i <= n; i++){
        for(int k = 0; k <= i; k++){
            dp[i][k] = dp[i - 1][k - 1] * tab[i] + dp[i - 1][k] * (1.0 - tab[i]);
        }
    }
    dbl sum = 0.0;
    for(int k = n / 2 + 1; k <= n; k++){
        sum += dp[n][k];
    }
    printf("%.10lf\n",sum);
    return 0;
}


Measured memory_bytes: 69120
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<set>
#include<vector>
using namespace std;

int solve(){
  int n, m; cin >> n >> m;
  int ans_ac = 0, ans_wa = 0;
  vector<int>  WA(n+1, 0);
  vector<bool> AC(n+1,false);

  for(int i=0; i<m; i++){
    int p;
    string s;
    cin >> p >> s;
    if(AC[p])  continue;
    if(s=="WA") {
      WA[p]++;
    }
    else if(s=="AC") {
      AC[p]=true;
      ans_ac++;
      ans_wa+=WA[p];
    }
  }
  cout << ans_ac << " " << ans_wa << endl;
  return 0;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?'){
            break;
        }
        if(op=='+'){
            printf("%d\n",a+b);
        }if(op=='-'){
            printf("%d\n",a-b);
        }if(op=='*'){
            printf("%d\n",a*b);
        }if(op=='/'){
            printf("%d\n",a/b);
        }
    }
    return 0;
}

Measured memory_bytes: 600
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
const int MX = 5e5;
const int BLOCK = 700;
struct Query {
  int l, r, idx;
  Query() {}
  bool operator<(const Query &p) {
    if (l / BLOCK != p.l / BLOCK) return l / BLOCK < p.l / BLOCK;
    return (l / BLOCK) & 1 ? r < p.r : r > p.r;
  }
} Q[MX + 2];
int A[MX + 2];
int ans = 0;
int res[MX + 2];
int freq[MX + 2];
void add(int x) {
  int val = A[x];
  if (freq[val] == 0) ans++;
  freq[val]++;
}
void remove(int x) {
  int val = A[x];
  if (freq[val] == 1) ans--;
  freq[val]--;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q;
  cin >> n >> q;
  fore(i, 0, n) cin >> A[i];
  fore(i, 0, q) {
    cin >> Q[i].l >> Q[i].r;
    Q[i].l--;
    Q[i].idx = i;
  }
  int l = 0, r = 0;
  sort(Q, Q + q);
  fore(i, 0, q) {
    Query p = Q[i];
    while (l > p.l) add(--l);
    while (r < p.r) add(r++);
    while (l < p.l) remove(l++);
    while (r > p.r) remove(--r);
    res[p.idx] = ans;
  }
  fore(i, 0, q) cout << res[i] << '\n';

  return 0;
}

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

int N, h[100000];
int DP[100000];

void dp() {
	DP[0] = 0;
	DP[1] = abs(h[1] - h[0]);
	for (int i = 2; i < N; i++) {
		DP[i] = min(DP[i - 2] + abs(h[i] - h[i - 2]), DP[i - 1] + abs(h[i] - h[i - 1]));
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	dp();
	cout << DP[N - 1];
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**6)
#input = sys.stdin.readline

def main():
    k = int(input())

    l = []
    def dfs(i, p, keta):
        l.append(i)
        if keta >= 10:
            return None
        if p != 0 and p != 9:
            for j in range(p-1, p+2):
                temp = j*(10**keta)+i
                l.append(temp)
                dfs(temp, j, keta+1)
        if p == 0:
            for j in range(p, p+2):
                temp = j*(10**keta)+i
                l.append(temp)
                dfs(temp, j, keta+1)
        if p == 9:
            for j in range(8, 10):
                temp = j*(10**keta)+i
                l.append(temp)
                dfs(temp, j, keta+1)

    for i in range(10):
        dfs(i, i, 1)
    #dfs(1, 1, 1)
    l = list(set(l))
    #print(l)
    l.sort()
    #print(l[0:k+1])
    #print(l[0:k])
    print(l[k])

if __name__ == '__main__':
    main()

Measured memory_bytes: 95396
#include <bits/stdc++.h>
#define int long long 
using namespace std;

const int N = 2e6 + 7;



int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	string str; cin >> str;
	vector <int> a, b;
	for(int i = 1; i <= n; i++) {
		if(str[i - 1] == 'W') {
			a.push_back(i);
		} else {
			b.push_back(i);
		}
	}
	int i = 0, j = b.size() - 1, ans = 0;
	while(i < a.size() && j >= 0 && a[i] < b[j]) {
		++ans;
		++i;
		--j;
	} 
	cout << ans << endl;
}

Measured memory_bytes: 5764
import sys
s = list(input())

sum0 = 0
sum1 = 0

len_s = len(s)

if len_s == 1:
    print(0)
    sys.exit()
else:
    for i in range(len_s):
        if (i % 2 == 0):
            if (s[i] == '0'):
                sum0 += 1
            else:
                sum1 += 1
        else:
            if (s[i] == '0'):
                sum1 += 1
            else:
                sum0 += 1


if (sum0 > sum1):
    print(sum1)
else:
    print(sum0)

Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <boost/math/common_factor.hpp>
using namespace std;

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

    int ans = A[0];
    for(int i = 1; i < N; i++) {
        ans = boost::math::gcd(ans, A[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int maxn=2e5+10;

int ma[maxn*4],n,a[maxn],c[maxn];

void change(int pos,int x,int id=1,int s=0,int e=maxn)
{
    if(s+1==e)
    {
        ma[id]=x;
        return ;
    }
    int mid=(s+e)/2;
    if(mid>pos)
        change(pos,x,id<<1,s,mid);
    else change(pos,x,id<<1|1,mid,e);
    ma[id]=max(ma[id<<1],ma[id<<1|1]);
}


int get(int l,int r,int id=1,int s=0,int e=maxn)
{
    if(e<=l || r<=s)
        return 0;
    if(l<=s && e<=r)
        return ma[id];
    int mid=(s+e)/2;
    return max(get(l,r,id<<1,s,mid),get(l,r,id<<1|1,mid,e));
}
int32_t main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
       // if(cin.peek()!='\n')
 //   ifstream cin("input.txt");
 //   ofstream cout("output.txt");
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>c[i];
    for(int i=0;i<n;i++)
    {
        change(a[i],get(0,a[i])+c[i]);
    }
    cout<<get(0,maxn);
}



Measured memory_bytes: 8448
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define inf 1e10
#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)
#define adj(N) vector<vector<int>> ADJ(N+1)
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

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

	multiset<ll> P;
	multiset<ll,greater<ll>> N;
	ll z=0;
	READV(N1);
	FORI(i,0,N1)
	{
		READV(x);
		if(x>0)
		{
			P.insert(x);
		}
		else if(x<0)
		{
			N.insert(x);
		}
		else
		{
			z++;
		}
	} 
	if(sz(P)==0 && z>0)
	{
		P.insert(0);
		z--;
	}
	if(sz(N)==0 && z>0)
	{
		N.insert(0);
		z--;
	}
	if (z>0)
	{
		while(z--)
		{
			P.insert(0);
		}
	}
	vector<pll> ans;
	if(sz(N)==0)
	{
		auto it=P.begin();
		ll x=*it;
		it++;
		ll y=*it;
		N.insert(x-y);
		ans.push_back({x,y});
		P.erase(P.begin());
		P.erase(P.begin());
	}
	if(sz(P)==0)
	{
		auto it=N.begin();
		ll x=*it;
		it++;
		ll y=*it;
		P.insert(x-y);
		ans.push_back({x,y});
		N.erase(N.begin());
		N.erase(N.begin());
	}
	while(sz(N)>1)
	{
		auto it=N.begin();
		auto it1=P.begin();
		ll x=*it1;
		ll y=*it;
		ans.push_back({x,y});
		P.erase(it1);
		N.erase(it);
		P.insert(x-y);
	}
	while(sz(P)>1)
	{
		auto it=N.begin();
		auto it1=P.begin();
		ll y=*it1;
		ll x=*it;
		ans.push_back({x,y});
		P.erase(it1);
		N.erase(it);
		N.insert(x-y);
	}
	ll x=*(P.begin());
	ll y=*(N.begin());
	ans.push_back({x,y});
	cout<<x-y<<endl;
	FORI(i,0,sz(ans))
	{
		cout<<ans[i].fi<<" "<<ans[i].se<<endl;
	}

	return 0;
}

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

using namespace std;

int main(){
  while(1){
    double d,e;
    double min,temp=0;
    double diff;

    cin>>d>>e;

    if(d==0 && e==0)
      break;

    for(int x=0;x<=d;x++){
      int y=d-x;
      diff=sqrt((double)x*x+y*y)-e;
      if(diff<0)
        diff=(-1)*diff;
      if(x==0)
        min=diff;
      if(diff<=min)
        min=diff;
    }

    cout<<min<<endl;
  }
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)

using namespace std;

long long gcd(long long a, long long b) {
  long long _max = a > b ? a : b;
  long long _min = a > b ? b : a;
  if (!(_max%_min)) return _min;
  else return gcd(_min, _max%_min);
}
 
long long lcm(long long a, long long b) {
  return a/gcd(a,b)*b;
}

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

void solve(long long N, long long K, std::vector<long long> A){
    LL tmp=A[0];
    for(auto a:A)tmp=gcd(tmp,a);
    for(auto a:A){
        if(a>=K && (a-K)%tmp==0){
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/*
 * [1][2][3][4][5][6][7][8] If we map greedily this way, we can have
 * |-||-||-||-||-||-||-||-| 2+3+4+5+..n-1 + n%2. If n is an even 
 * [1][3][4][5][6][7][8][2] number we can swap with smaller odd (eg 7
 *                          from 6%7, 8%2 => 6%8, 7%2.
 */

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    LL n;
    while (cin >> n) {
        const LL ans = (n-1)*n/2 - 1 + n%2 + (n%2 == 0);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static final int INF = 10000000;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {

			int n = sc.nextInt();
			int m = sc.nextInt();
			if (n+m==0) {
				break;
			}

			int[][] cost = new int[m][m];
			int[][] time = new int[m][m];
			for(int i=0;i<m;i++) {
				for(int j=0;j<m;j++) {
					if (i!=j) {
						cost[i][j] = INF;
						time[i][j] = INF;
					}
				}
			}
			for(int i=0;i<n;i++) {
				int a = sc.nextInt()-1;
				int b = sc.nextInt()-1;
				int c = sc.nextInt();
				int t = sc.nextInt();
				cost[a][b] = c;
				cost[b][a] = c;
				time[a][b] = t;
				time[b][a] = t;
			}
			for(int k=0;k<m;k++) {
				for(int i=0;i<m;i++) {
					for(int j=0;j<m;j++) {
						cost[i][j] = Math.min(cost[i][j],cost[i][k] + cost[k][j]);
						time[i][j] = Math.min(time[i][j], time[i][k] + time[k][j]);
					}
				}
			}
			int Q = sc.nextInt();
			for(int i=0;i<Q;i++) {
				int p = sc.nextInt()-1;
				int q = sc.nextInt()-1;
				int r = sc.nextInt();
				if (r==0) {
					System.out.println(cost[p][q]);
				}else{
					System.out.println(time[p][q]);
				}
			}
		}
	}

}

Measured memory_bytes: 65984
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let ans1 = xs[0] * xs[1];
   let ans2 = xs[2];
   if(ans1 > ans2){
     console.log(ans2);
   }else if(ans1 < ans2){
     console.log(ans1);
   }else{
     console.log(ans1)
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21064