akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int n1, n2, n3, n4;
  bool flag1 = false;
  bool flag9 = false;
  bool flag7 = false;
  bool flag4 = false;

  vector<int> N;
  cin >> n1;
  cin >> n2;
  cin >> n3;
  cin >> n4;
  N.push_back(n1);
  N.push_back(n2);
  N.push_back(n3);
  N.push_back(n4);

  for (int n : N) {
    if (n == 1) {
      flag1 = true;
    }
    if (n == 9) {
      flag9 = true;
    }
    if (n == 7) {
      flag7 = true;
    }
    if (n == 4) {
      flag4 = true;
    }
  }

  if (flag1 && flag9 && flag7 && flag4) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
C - Lower
https://atcoder.jp/contests/abc139/tasks/abc139_c

"""
import sys


def solve(N, numbers):
    dp = {-1: 0}
    for i, a, b in zip(range(N), numbers, numbers[1:]):
        dp[i] = (dp[i-1] + 1) if b <= a else 0
    return max(dp.values())


def main(args):
    N = int(input())
    numbers = [int(h) for h in input().split()]
    ans = solve(N, numbers)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main(){
    int64_t n; cin >> n;
    int64_t ans = 0;
    for (int64_t i = 1; i <= n; i++) ans += i * (n / i) * (n / i + 1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
long long int gcd(long long int i,long long int j){
	long long int M=max(i,j);
	long long int m=min(i,j);
	if(M%m!=0){
		return gcd(m,M%m);
	}else return m;
}
int main() {
	int n;
	cin>>n;
	long long int c[n];
	for(int i=0;i<n;i++)cin>>c[i];
	long long int l=c[0];
	for(int i=1;i<n;i++){
		long long int num=gcd(l,c[i]);
		l=num*(l/num)*(c[i]/num);
	}
	cout<<l;

	return 0;
}


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


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

    int n;
    string v = "aiueo";
    while(cin>>n){
        if(n==0) break;
        string s[n];
        for(int i=0;i<n;i++){
            cin>>s[i];
        }
        string t[n]={};
        for(int i=0;i<n;i++){
            int m=s[i].size();
            t[i]+=s[i][0];
            for(int j=1;j<m;j++){
                bool vow=false;
                for(int k=0;k<5;k++){
                    if(s[i][j-1]==v[k]) vow=true;
                }
                if(vow) t[i]+=s[i][j];
            }
        }
        int cnt=0;
        bool same=false;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(t[i] == t[j]) same=true;
                int ret=1;
                int siz = min(t[i].size(), t[j].size());
                for(int k=0;k<siz;k++){
                    if(t[i][k]==t[j][k]) ret++;
                    else break;
                }
                cnt = max(ret,cnt);
            }
        }
        if(same){
            cout<<-1<<endl;
        }
        else cout<<cnt<<endl;

    }
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  if(x==25)
    cout<<"Christmas"<<endl;
  else if(x==24)
    cout<<"Christmas Eve"<<endl;
  else if(x==23)
    cout<<"Christmas Eve Eve"<<endl;
  else if(x==22)
    cout<<"Christmas Eve Eve Eve"<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/agc028/editorial.pdf
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

N, M = MAP()
S = input()
T = input()

lcm = lcm_base(N, M)
n = N // gcd(N, M)
m = M // gcd(N, M)
for i in range(gcd(N, M)):
    if S[i*n] != T[i*m]:
        print(-1)
        exit()
print(lcm)


Measured memory_bytes: 5312
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;cin>>n;
    int a[n];
    int d;
    for(int i=0;i<n;i++){
        cin>>d;
        a[d-1]=i+1;
    }
    for(int i=0;i<n;i++){
        cout<<a[i]<<endl;
    }

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n;
    cin >> n;
    string s  , t;
    cin >> s >> t ;
    string ans = "";
    for (int i = 0 ; i < n ; i ++) {
    	cout << s[i] << t[i];
	} 
    return (0) ;
}

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

int main() {
    int a, b, c;cin >> a >> b >> c;
    int x;cin >> x;
    int cnt = 0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i + 100*j + 50*k == x) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(arr: Array<String>) {
    var str = readLine()!!
    var prev = ""
    var ans = 0
    while (str.length > 0) {
        var tmp = ""
        if(str.substring((0 until 1)) == prev) {
            if(str.length == 1) {
                break
            } else {
                tmp = str.substring(0 until 2)
                str = str.drop(2)
                ans++
            }
        } else {
            tmp = str.substring(0 until  1)
            str = str.drop(1)
            ans++
        }
        prev = tmp
    }
    println(ans)
}



Measured memory_bytes: 58096
#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <stack>
using namespace std;

double operate( double a, double b, string opc ) {
  return (
    opc == "+" ? a + b :
    opc == "-" ? a - b :
    opc == "*" ? a * b : a / b
  );
}

int main() {
  string line;
  while( getline( cin, line ) ) {
    istringstream iss( line );
    stack<double>  st;
    string item;
    while( iss >> item ) {
      if(
          ( '0' <= item[ 0 ] && item[ 0 ] <= '9' ) ||
          ( item[ 0 ] == '-' && item.size() >= 2 )
      ) {
        st.push( atof( item.c_str() ) );
      } else {
        double b = st.top();
        st.pop();
        double a = st.top();
        st.pop();
        st.push( operate( a, b, item ) );
      }
    }
    printf( "%.6f\n", st.top() );
    st.pop();
  }
  return EXIT_SUCCESS;
}

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

#define ll long long

int main() {
	ll k;
	cin >> k;
	int i, j;
	vector<ll> a(k);

	a[0] = 7 % k;
	for (i = 1; i < k; i++) {
		a[i] = (a[i - 1] * 10 + 7) % k;
	}
	for (i = 0; i < k; i++) {
		if (a[i] == 0) {
			cout << i + 1;
			return 0;
		}
	}
	cout << "-1";
	return 0;
}

Measured memory_bytes: 10992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int i(a);i<b;i++)
#define rep(i,n) for(int i(0);i<n;i++)
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define pres(x) cout<<fixed; cout<<setprecision(x);
#define open freopen("input.txt","r",stdin) ; freopen("output.txt","w",stdout);
#define watch(x) cout<<(#x)<<" is "<<x<<"\n";
#define mod 1000000007

int32_t main(){
	
	fast;
	//open;

	int n,ans=INT_MAX;
	cin>>n;
	int array[n],p[n];
	rep(i,n)cin>>array[i];
	p[0] = array[0];
	f(i,1,n)p[i] = p[i-1]+array[i];
	rep(i,n){
		ans = min(ans, abs(p[n-1] - 2*p[i]));
	}
	cout<<ans;



	return 0;
}

Measured memory_bytes: 256
n=int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
diff={}

for i in range(n):
    for j in range(n):
        if i==j:
            continue
        if ((xy[i][0]-xy[j][0]),(xy[i][1]-xy[j][1])) in diff:
            diff[((xy[i][0]-xy[j][0]), (xy[i][1]-xy[j][1]))]+=1
        else:
            diff[((xy[i][0] - xy[j][0]), (xy[i][1] - xy[j][1]))] = 1

print(n-max(diff.values()) if n!=1 else 1)


Measured memory_bytes: 3444
#!python3.8
# -*- coding: utf-8 -*-
# abc179/abc179_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    if S[-1] != 's':
        print(S + 's')
    else:
        print(S + 'es')
    return

main()


Measured memory_bytes: 9132
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define ar array
#define N 200005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++){
        cin>>a[i];
	}
	int lift[n+1][61];
	for(int i=1;i<=n;i++){
        lift[i][0] = a[i];
	}
	for(int i=1;i<61;i++){
        for(int j=1;j<=n;j++){
            lift[j][i] = lift[lift[j][i-1]][i-1];
        }
	}
	int ans = 1;
	int pos = 0;
	while(k){
        if(k&1){
            ans = lift[ans][pos];
        }
        k >>= 1;
        pos++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 52056
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (auto& v : A)cin >> v;
  for (auto& v : B)cin >> v;
  for (auto& v : C)cin >> v;
  sort(begin(A), end(A));
  sort(begin(B), end(B));
  sort(begin(C), end(C));
  int64_t ans = 0;
  for (auto& b : B) {
    int64_t a = distance(begin(A), lower_bound(begin(A), end(A), b));
    int64_t c = distance(upper_bound(begin(C), end(C), b),end(C));
    ans += a * c;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;
int N;
long a[10001];
void solve(){
  long ans = 0;
  for(int i = 0; i < N; i++){
    while(a[i] % 2 == 0){
      a[i] /= 2 ;
      ans++;
    }
  }
  cout << ans << endl;
  return ;
}
int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  solve();
  return 0;
}


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

using namespace std;

int main(){
  vector<int> n(3);
  for(int i=0;i<3;i++){
    cin >> n.at(i);
  }
  sort(n.begin(),n.end());
  reverse(n.begin(),n.end());

  cout << n.at(0)*10+n.at(1)+n.at(2) << endl;
  
  return 0;
}


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


int main(int argc, const char * argv[]) {

    int a, b, c;
    cin >> a >> b >> c;
    if(a == b){
        cout << c << endl;
    }else if(a == c){
        cout << b << endl;
    }else{
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define ll long long

const int MAXN = (int)3e5 + 5;

int h[MAXN], dp[MAXN];

int main(){
    int n;cin >> n;
    for (int i = 1;i <= n;i ++) {
        cin >> h[i];
        dp[i] = int(2e9);
    }
    dp[1] = 0;
    for (int i = 2;i <= n;i ++) {
        for (int j = 1;j <= 2;j ++) {
            int prev_pos = i - j;
            if (prev_pos <= 0) continue;
            dp[i] = min(dp[i], abs(h[i] - h[prev_pos]) + dp[prev_pos]);
        }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  ll N;
  cin >> N;
  double sum = 0;
  REP(i, N) {
    double A;
    cin >> A;
    sum += 1.0 / A;
  }
  double ans = 1.0 / sum;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long a1;
    cin>>a1;
    char a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<a1*(long long)(a-'0')+a1*(long long)((c-'0')*10+(d-'0'))/100LL;
}


Measured memory_bytes: 3636
#include <iostream>

int main() {
	int num[3];
	for (int i = 0;i < 3;i++) {
		std::cin >> num[i];
		if (i != 0) {
			for (int j = i;j > 0;j--) {
				if (num[j] > num[j - 1])
				{
					int tmp;
					tmp = num[j];
					num[j] = num[j - 1];
					num[j - 1] = tmp;
				}
			}
		}
	}
	std::cout << (num[0] * 10) + num[1] + num[2] << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Copyright © 2018 Chris. All rights reserved.
 *
 * @author Chris
 * 2018/6/23 11:55
 * @see meituan.n2018.Bturn
 */
public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        char ch[] = sc.next().toCharArray();
        int cnt = 0;
        for (char c : ch) {
            cnt += c == '+' ? 1 : -1;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vll vector<ll>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ld x;
    cin >> x;
    
    ld y = x/3, vol = 0;
    vol = y*y*y;
    cout << fixed << setprecision(12) << vol << endl;
    return 0;
}

Measured memory_bytes: 3816
#include <stdio.h>
int main(void){
   int i,t[101];
  int max,n;
 
  max = 0;
  for(i=0;i<=100;i++)t[i] = 0;
 
  while(scanf("%d",&n)!=EOF){
    t[n]++;
    if(max<t[n])max = t[n];
  }
 
  for(i=0;i<=100;i++)
    if(t[i]==max)printf("%d\n",i);
 
  return 0;
}


Measured memory_bytes: 2024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		int h=sc.nextInt();
		
		System.out.println((a+b)*h/2);
		
		sc.close();
		
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
int main(void)
{
  int n, a[2][100] = {}, map[2][100] = {};
  std::cin >> n;
  for(int i = 0; i != 2; i++){
    for(int j = 0; j != n; j++){
      std::cin >> a[i][j];
      map[i][j] = std::max((i != 0 ? map[0][j] : 0), (j != 0 ? map[i][j - 1] : 0)) + a[i][j];
    }
  }
  std::cout << map[1][n - 1] << std::endl;
  return 0;
}

Measured memory_bytes: 256
/*May The Force Be With Me*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")
#define ll long long
#define MOD 1000000007
#define endl "\n"
#define vll vector<long long>
#define mll map<long long,long long>
#define pll pair<long long, long long>
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define pb push_back
#define f first
#define s second
#define inf INT_MAX
#define size_1d 10000000
#define size_2d 1000
#define rep(i,v,n) for(ll i = v; i < n; i++)
//Snippets: delta, sieve, fastexp, dfs, bfs, dijkstra, floodfill

using namespace std;

ll n, k;

void Input() {
	cin >> n >> k;
}

void Solve() {
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	ll l = 0;
	for (ll i = k; i < n; i++) {
		if (a[i] > a[l])cout << "Yes";
		else cout << "No";
		l++;
		cout << endl;
	}
}

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

	ll T = 1;
	//cin >> T;
	//ll t = 1;
	while (T--) {
		Input();
		//cout << "Case " << t << ": ";
		Solve();
		//t++;
	}
	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll hi[303030], lo[303030];

int main() {
   int N;
   cin >> N;
   vec<ll> A(N*3);
   rep (i, 3*N) cin >> A[i];

   {
      pq<int> Q;
      ll sum = 0;
      rep (i, 3*N) {
         Q.push(-A[i]);
         sum += A[i];
         if (Q.size() > N) {
            sum += Q.top();
            Q.pop();
         }
         hi[i] = sum;
      }
   }
   {
      pq<int> Q;
      ll sum = 0;
      for (int i = 3*N-1; i >= 0; i--) {
         Q.push(A[i]);
         sum += A[i];
         if (Q.size() > N) {
            sum -= Q.top();
            Q.pop();
         }
         lo[i] = sum;
      }
   }
   ll ret = -(1LL << 60LL);
   for (int i = N-1; i <= 2*N-1; i++) {
      ret = max(ret, hi[i] - lo[i+1]);
   }
   cout << ret << endl;

   return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

ll factorial(ll x){
    if(x==1) return 1;
    return x*factorial(x-1)%mod;
}

int main(){
    ll N, M;
    cin >> N >> M;
    if(N<M) swap(N, M);
    if(N==M){
        cout << 2 * factorial(N) * factorial(M) % mod << endl;
    }else if(N-1==M){
        cout << factorial(N) * factorial(M) % mod << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
from math import sqrt

def main():
    q = int(input())
    ans = [None]*q
    for i in range(q):
        a, b = map(int, input().split())
        score = a*b
        tmp = 0
        if b < a:
            a, b = b, a
        if a == b:
            tmp = (a-1) + (b-1)
        elif a+1 == b:
            tmp = (a-1) + (a-1)
        else:
            p = int(sqrt(score))
            if p**2 == score:
                p -= 1
            tmp = 2*p - 1
            if p * (p+1) >= score:
                tmp -= 1
        ans[i] = tmp
    for v in ans:
        print(v)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9104
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    if(s.charAt(s.length()-1)=='s')
    {
      s=s+"es";
    }
    else
    {
      s=s+"s";
    }
    System.out.println(s);
  }
}


Measured memory_bytes: 38344
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int all,n,A,B;
int lowbit(int x){return x&(-x);}
int num(int x){
	int ret=0;
	while(x){
		ret++;x^=lowbit(x);
	}
	return ret;
}
void dfs(int x,int y,int s){
	if(num(all^s)==1){printf("%d %d ",y,x^y);return;}
	for(int i=0;i<n;i++)
		if((~s&(1<<i)) && (x>>i)&1)
			for(int j=0;j<n;j++)
				if((~s&(1<<j)) && i!=j){
					dfs(1<<j,y,s|(1<<i));
					dfs(x^(1<<i)^(1<<j),y^(1<<i)^(1<<j),s|(1<<i));
					return;
				}
}
int main(){
	n=gi();A=gi();B=gi();all=1<<n;all--;
	if(num(A^B)&1)puts("YES"),dfs(A^B,A,0);
	else puts("NO");
	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> x(N);

  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  long long ans = 10000000000;

  // 左端からKのレンジ分、繰り返す l がレンジの左端、r が右端
  for (int l = 0; l < N - K + 1; l++) {
    int r = l + K - 1;

    long long left = x[l];
    long long right = x[r];

    // 左に行った場合の時間と右に行った時間の小さい方を採用する
    long long goToLeftTime = abs(left) + abs(right - left);
    long long goToRightTime = abs(right) + abs(left - right);

    ans = min(ans, min(goToLeftTime, goToRightTime));
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;

// function to print number of
// digits
void findNumberOfDigits(long n, int base)
{

	int dig = (int)(floor( log(n) /
						log(base)) + 1);

	// printing output
	cout << dig;
}

// Driver method
int main()
{
	// taking inputs
	long long n,m; cin >> n >> m;

	// calling the method
	findNumberOfDigits(n, m);
	return 0;
}



Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)

    return divisors

N = int(input())

combo = make_divisors(N)
sum = [sum(combo[i:i+2]) for i in range(0,len(combo),2)]
minimum = min(sum) - 2

print(minimum)

Measured memory_bytes: 3296
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var K = input[1];
        var h = new long[N];
        for (int i = 0; i < N; i++)
        {
            h[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(h);
        var result = h[N - 1];
        for (int i = 0; i < N - K + 1; i++)
        {
            if (result > h[i + K - 1] - h[i])
            {
                result = h[i + K - 1] - h[i];
            }
        }
        Console.WriteLine(result);
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N, K; cin >> N >> K;
  double p[N]; rep(i,N) cin >> p[i];
  double now = 0, result = 0;
  rep(i,K) now += (p[i]+1)/2;
  result = now;
  repr(i,K,N) {
    now += (p[i]-p[i-K])/2;
    // cout << now << endl;
    result = max(result, now);
  }
  cout << setprecision(10) << result << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(10);
    double r;
    cin >> r;
    cout << r * 2 * 3.14 << endl;
    return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9) + 7)

int main()
{
  ll n;
  cin >> n;
  vector<string> s(n);
  for(ll i = 0;i < n;i++)
  {
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  ll ans = 1;
  for(ll i = 0;i < n-1;i++)
  {
    if(s[i] != s[i+1])
    {
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main() {

    string s;
    string y, m, d;

    cin >> s;

    m = s.substr(5, 2);
    d = s.substr(8, 2);
    
    string ans = "TBD";
    if( stoi(m) <= 4 && stoi(d) <= 30) {
        ans = "Heisei";
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
s = gets.split.map(&:to_i).sort
ret = 0
for i in 0..n-1
  if s[i] <= k
    k -= s[i]
    ret += 1
  end
end

puts ret == n && k > 0 ? ret - 1 : ret


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string st;
    cin>>st;
    REP(i,st.size()){
        cout<<st[i];
        i++;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 512
#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 <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int N,A,B;
    cin >> N >> A >> B;
    int ans = 0;
    rep(i,1,N+1){
        string s = to_string(i);
        int tmp = 0;
        rep(j,0,s.size()){
            tmp += s[j] - '0';
        }
        if(tmp >= A && tmp <= B){
            ans += i;
        }

    }
    cout << ans << endl;
    return 0;
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, K, Q;
    cin >> N >> K >> Q;

    vector<ll> points(N, K);
    vector<ll> score(N, 0);

    ll a;
    REPinit(i, 0, Q) {
        cin >> a;
        score.at(a - 1) += 1;
    }

    REPinit(i, 0, N) {
        if ((K + score.at(i) - Q) <= 0) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4740
#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 x;
    cin >> x;
    int d = x / 100;
    int l = d * 100 + d * 5;
    if (x <= l) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c;long long K;
int main(){
	scanf("%d%d%d%lld",&a,&b,&c,&K);
	if(K&1)printf("%d\n",b-a);else printf("%d\n",a-b);return 0;
}

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

/*                        [Template]                        */
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define Int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) x.find( y ) != x.end()
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
int mod = (int)1e9 + 7 ;
/************************************************************/


signed main(){
	float N, X, T ;
	cin >> N >> X >> T ;
	cout << int(ceil(N/X) * T) ;
	return 0 ;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
int main(){
int x;
cin >> x;
string str;
cin >> str;
string st,ss;
if(x%2 == 0){

    for(int i = 0 ; i < x/2 ; i++)
        st = st + str[i];
    for(int i = x/2 ; i < x ; i++)
        ss = ss + str[i];
}
if(x%2 == 1)
    cout << "No" << endl;
else if( st == ss)
    cout << "Yes" << endl;
else
    cout << "No" << endl;

return 0;
}


Measured memory_bytes: 256
#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)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vint a(N + 1);
    vector<multiset<int>> love(N + 1);
    rep2(i, 1, N + 1)
    {
        cin >> a[i];
        a[i];
        love[i].insert(a[i]);
    }
    int cnt = 0;
    rep2(i, 1, N + 1)
    {
        if (love[i].find(a[i]) != love[i].end() and love[a[i]].find(i) != love[a[i]].end())
            cnt++;
    }
    cout << cnt / 2;
    return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){

	int a, b;
	cin >> a >> b;
	cout << (a + b)%24  << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll mo=1000000007;
int N,K;
ll dp[101010];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

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

	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	ll sum=0;
	for(i=K;i>=1;i--) {
		dp[i]=modpow(K/i,N);
		for(j=i*2;j<=K;j+=i) dp[i]-=dp[j];
		//dp[i]=(dp[i]%mo+mo)%mo;
		sum+=i*dp[i]%mo;
	}
	cout<<sum%mo<<endl;

    return 0;
}


Measured memory_bytes: 4436
program main
  implicit none
  integer i,ans,a,b
  read(*, *)a,b
  !read(*, *) (L(i), i = 1,N)
  i = 1
  ans = 0
  do
    if (i >= b) then
      exit
    else
      i = i + a-1
      ans = ans + 1
    end if
  end do

  write(*, *) ans
end program main


Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}


int main(){
    int n=in();
    vector<pair<double,double>> p(n);
    rep(i,n){
        int a=in(),b=in();
        p[i]=mp(a,b);
    }
    vector<double> a;
    double sum=0;
    rep(i,n)rep2(j,i+1,n-1){
        int x=p[i].first,y=p[i].second,xx=p[j].first,yy=p[j].second;
        sum+=sqrt( (x-xx)*(x-xx) + (y-yy) * (y-yy) );
    }
    sum*=2;
    sum/=n;
    printf("%.15f",sum);
}

Measured memory_bytes: 256
import heapq

n=int(input())
*a,=map(int,input().split())
inf=float("inf")

pos=n
q,r=[],[]
u,d=[-inf]*(3*n),[inf]*(3*n)

for i in range(n):
    heapq.heappush(q,a[i])
    u[i]=u[i-1] if i else 0
    u[i]+=a[i]

for i in range(n,2*n):
    heapq.heappush(q,a[i])
    b=heapq.heappop(q)
    u[i]=u[i-1]+a[i]-b

for i in range(2*n,3*n)[::-1]:
    heapq.heappush(r,-a[i])
    d[i]=d[i+1] if i!=3*n-1 else 0
    d[i]+=a[i]

for i in range(n,2*n)[::-1]:
    heapq.heappush(r,-a[i])
    b=heapq.heappop(r)
    d[i]=d[i+1]+a[i]+b

ans=-inf
for i in range(n-1,2*n):
    ans=max(ans,u[i]-d[i+1])

print(ans)

Measured memory_bytes: 39512
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

const int limit = 200010;

int last[limit];

const int upper = 60;
int nxt[upper + 1][limit];
ll step[upper + 1][limit];

const ll val_limit = 1LL << 60;

inline ll add_with_limit(ll a, ll b){
	if(max(a, b) >= val_limit) return val_limit;
	return min(val_limit, a + b);
}

int main(void){
	ll n, k;
	cin >> n >> k;
	vector<int> a(n);
	
	rep(i, n) cin >> a[i];
	rep(i, limit) last[i] = -1;

	rep(i, 2 * n){
		int &pos = last[a[i % n]];
		
		if(pos != -1){
			nxt[0][pos] = (i + 1) % n;
			step[0][pos] = i + 1 - pos;
		}

		if (i < n)
			pos = i;
		else
			pos = -1;
	}

	rep(t, upper){
		rep(i, n){
			nxt[t + 1][i] = nxt[t][nxt[t][i]];
			step[t + 1][i] = add_with_limit(step[t][nxt[t][i]], step[t][i]);
		}
	}

	const ll thr = n * k;
	ll cur = 0;

	rrep(t, upper){
		const ll pos = cur % n;
		if (cur + step[t][pos] > thr) continue;
		cur += step[t][pos];
	}

	set<int> used;
	vector<int> ans;
	
	for(ll i = cur; i < thr; ++i){
		const int val = a[i % n];
		if(used.find(val) != end(used)){
			while(ans.back() != val) {
				const int tmp = ans.back();
				used.erase(tmp);
				ans.pop_back();
			}
			used.erase(val);
			ans.pop_back();
		} else {
			used.insert(val);
			ans.push_back(val);
		}
	}

	const int m = ans.size();
	rep(i, m) cout << (i? " " : "") << ans[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 156148
#include <iostream>


using namespace std;

int main(){
    string geng[100];
    int nen[100],getu[100],day[100];
    int i = 0;
    cin >> geng[i];
    while(geng[i] != "#"){
        cin >> nen[i] >> getu[i] >> day[i];
        if(nen[i] >= 32){
            cout << '?' << ' ' << nen[i] - 30 << ' ' << getu[i] << ' ' << day[i] << endl;
        }else{
            if(nen[i] == 31 && getu[i] >= 5){
                cout << '?' << ' ' << nen[i] - 30 << ' ' << getu[i] << ' ' << day[i] << endl;
            }else{
                cout << "HEISEI" << ' ' << nen[i] << ' ' << getu[i] << ' ' << day[i] << endl;
            }
        }
        i++;
        cin >> geng[i];
    }
    return 0;
}


Measured memory_bytes: 3140
function f(n::Int,i::Int,ans::Int)
    a=string(i)
    return parse(Int,a[n])==ans
end
function main()
    n,m=parse.(split(readline()))
    a=[parse.(split(readline())) for i=1:m]
    for i=10^(n-1)-(n==1):10^n-1
        flag=true
        for j in a
            flag = flag==true ? f(j[1],i,j[2]) : flag
        end
        if Bool(flag)
            print(i)
            return 0
        end
    end
    print(-1)
end
main()

Measured memory_bytes: 180400
{-# LANGUAGE BangPatterns #-}
import Control.Applicative((<$>))
import Control.Monad
import qualified Data.Map as M
-- import qualified Data.Char as C
import qualified Data.List as L
-- import qualified Data.IntSet as I
-- import Debug.Trace
--------------------------------------------
readInt    = read :: String -> Int
readFloat  = read :: String -> Float
getInt     = readInt <$> getLine
getIntList = map readInt . words <$> getLine
int2bin 0 =  []
int2bin n =  n `mod` 2 : int2bin (n `div` 2)
----------------------------------------------

solve _ [] = 0
solve [a] xxs@(x:xs) =
  if length (takeWhile (x ==) xxs) >= 2
  then a*x
  else solve [a] xs
solve [ ] xxs@(x:xs) =
  let !howmany = length (takeWhile (x ==) xxs) in
  if howmany >= 4 then x*x
  else if howmany >= 2 then solve [x] (dropWhile (x==) xxs)
  else solve [ ] xs

main :: IO ()
main = do
  n  <- getInt
  as <- getIntList
  print $ solve [] $ L.sortOn (\a -> -a) as


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

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

    int forward[n] = {};
    int backward[n] = {};
    int total[n];

    for(int i = 1; i < n; i++){
        if(s[i-1]=='W') forward[i] = forward[i-1]+1;
        else            forward[i] = forward[i-1];
    }

    for(int i = n-2; i >= 0; i--){
        if(s[i+1]=='E') backward[i] = backward[i+1]+1;
        else            backward[i] = backward[i+1];
    }

    for(int i = 0; i < n; i++){
        total[i] = forward[i]+backward[i];
    }

    sort(total, total+n);

    cout << total[0] << endl;
    return 0;
}

Measured memory_bytes: 4228
import sys
from bisect import bisect
from itertools import accumulate

def main():
    input = sys.stdin.readline
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))

    Bn = [0] * N
    for i in range(N):
        b = B[i]
        m = bisect(C, b)
        Bn[i] = (N - m)

    Bn = list(accumulate(Bn[::-1]))[::-1]
    Bn += [0]

    ans = 0
    for i in range(N):
        a = A[i]
        m = bisect(B, a)
        ans += Bn[m]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25488
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int w, h, x, y;
	cin >> w >> h >> x >> y;

	printf("%.9f %d\n", (double)w * h / 2, (x * 2 == w && y * 2 == h));



	return 0;
}

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

using namespace std;

#define lli long long int
#define pb  push_back
#define mp  make_pair

vector <lli> vv;

int main(){
    lli s, w;
    cin >> s >> w;
    if(s>w) cout << "safe";
    else cout << "unsafe";
}


Measured memory_bytes: 3560
#include <stdio.h>
int main ()
{
  int a, b;
  scanf("%d%d",&a, &b);
  if (a < b)
printf("a < b\n");
  if(a > b)
 printf("a > b\n");
  if(a == b)
 printf("a == b\n");
  return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
int MAX(int a, int b){return a>b?a:b;}

int main(void){
    int a,b,c;
    scanf("%d%d%d", &a,&b,&c);

    int max = MAX(a, MAX(b, c));
    
    int x = max;
    while(1){
        if((3*x-(a+b+c))%2 == 0){
            break;
        }
        x++;
    }

    printf("%d\n", (x*3-(a+b+c))/2);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef vector<int> VI;

int main(void) {
    int n;
    int k;
    cin >> n >> k;
    VI bar(n);
    for (int i = 0; i < n; i++) {
        cin >> bar[i];
    }
    sort(bar.begin(), bar.end());
    /*
    for (int i = 0; i < n; i++) {
        cout << bar[i] << endl;
    }
    */
    int total = 0;
    for (int i = 0; i < k; i++) {
        total += bar[n - i - 1];
    }
    cout << total << endl;
    return 0;
}



Measured memory_bytes: 256