akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
string s;
int a, b, c, d;
/**********************************************/

int main(){
    cin >> s;
    a = s[0] - '0';
    b = s[1] - '0';
    c = s[2] - '0';
    d = s[3] - '0';
    
    if(a+b+c+d == 7){
        cout << a << '+' << b << '+' << c << '+' << d << '=' << 7 << endl;   
    }else if(a+b-c+d == 7){
        cout << a << '+' << b << '-' << c << '+' << d << '=' << 7 << endl;   
    }else if(a+b-c-d == 7){
        cout << a << '+' << b << '-' << c << '-' << d << '=' << 7 << endl;   
    }else if(a+b+c-d == 7){
        cout << a << '+' << b << '+' << c << '-' << d << '=' << 7 << endl;   
    }else if(a-b+c+d == 7){
        cout << a << '-' << b << '+' << c << '+' << d << '=' << 7 << endl;   
    }else if(a-b-c+d == 7){
        cout << a << '-' << b << '-' << c << '+' << d << '=' << 7 << endl;   
    }else if(a-b-c-d == 7){
        cout << a << '-' << b << '-' << c << '-' << d << '=' << 7 << endl;   
    }else if(a-b+c-d == 7){
        cout << a << '-' << b << '+' << c << '-' << d << '=' << 7 << endl;   
    }
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toLong)
    val aList = readLine()!!.split(" ").map(String::toLong)
    val gcd = if (aList.size == 1) aList[0] else gcd(aList)
    println(if (k % gcd == 0L && aList.max() ?: 0L >= k) "POSSIBLE" else "IMPOSSIBLE")
}

fun gcd(a: Long, b: Long): Long {
    return if (b > 0) gcd(b, a % b) else a
}

fun gcd(param: List<Long>): Long {
    var g = gcd(param[0], param[1])
    for (i in 2 until param.size) g = gcd(g, param[i])
    return g
}

Measured memory_bytes: 48356
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  vector<string>N(A);
  for(int i=0;i<A;i++){
    cin >> N.at(i);
  }
  sort(N.begin(),N.end());
  string ans;
  for (int i = 0; i < A; i++){
    ans += N.at(i);
  }
  cout << ans << endl;
}

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

using namespace std;

#define fill(A, val) memset(A,val,sizeof(A))
#define rep(i, a, n) for (int (i)=a;(i)<n;++(i))
#define per(i, n, a) for (long long (i)=n-1;(i)>=a;--(i))
#define all(V) V.begin(),(V).end()
#define sz(V) (int)(V).size()
#define pb push_back
#define ff first
#define ss second
#define ret return
#define tr true
#define fl false

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef pair<ll, ll> pll;                                                                                                                                                        zÿ
typedef pair<ld, ld> pdd;
typedef map<int, int> mii;
typedef map<ll, ll> mll;                    
const double eps = 1e-8;                        
const double Pi = 3.14159265358979323846264338327950288419716939937510;
const long long INF = 1LL << 60;
const long long MAX3 = 1005;
const long long MAX4 = 10005;
const long long MAX5 = 100005;
const long long MAX6 = 1000005;
const long long MOD = 1e9 + 7;
const long long N = (int)1e7;
const int Grn = 10000;
/*
void buildtree(int v, int tl, int tr) {
    if (tl == tr) {
        tree[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        buildtree(v * 2, tl, tm);
        buildtree(v * 2 + 1, tm + 1, tr);
        tree[v] = tree[v * 2] + tree[v * 2 + 1];
   }
  }
void push(int v, int tl, int tr) {
    if (mod[v] != 0 && v * 2 + 1 < 400004) {    
        mod[v * 2] = mod[v * 2 + 1] = mod[v];
        mod[v] = 0;
        int tm = (tl + tr) / 2;
        tree[v * 2] = (tm - tl + 1) * mod[v * 2];
        tree[v * 2 + 1] = (tr - tm) * mod[v * 2 + 1];
    }
}
int getsum(int l, int r, int v, int tl, int tr) {
    if (l <= tl && tr <= r) {
        return tree[v];
    }
    if (tr < l || r < tl) {
        return 0;
    } 
    push(v, tl, tr);   
    int tm = (tl + tr) / 2;
    return getsum(l, r, v * 2,     tl,     tm)
         + getsum(l, r, v * 2 + 1, tm + 1, tr);
}
*/
int f(int n){
 int nn = 0;
  while(n>0){
  nn+=(n%10);
  n/=10;
 }
return nn;
}
ll a,b,n,sum;
int mn = (int)1e9;
int main(){
cin>>n;

for(int i = 1; i <= n; ++ i){
int j = n-i;  
if(f(i)+f(j)<mn&&j!=0){
  mn = f(i)+f(j);
}    

}
cout<<mn;

return 0;
}


Measured memory_bytes: 256
/**********************************************
ABC168 D ..(Double Dots)
***********************************************/
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using ll=long long;
using namespace std;
const long MOD=1e9+7;
using Graph = vector<vector<long>>;
template<class T>
T lcm(T a,T b){
    return a/__gcd(a,b)*b;
}



int main(){
    long n,m;cin >> n >> m;
    Graph g(n);
    for(int i=0;i<m;i++){
        long x,y;
        cin >> x >> y;
        g[x-1].push_back(y-1);
        g[y-1].push_back(x-1);
    }
    vector<long> dist(n,-1);
    queue<long> que;
    dist[0]=0;
    que.push(0);
    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(auto i:g[v]){
            if(dist[i] != -1)continue;
            dist[i]=v+1;
            que.push(i);
        }
    }
    cout << "Yes\n";
    for(int i=1;i<n;i++){
        cout << dist[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 12936
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 1e9;

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

    bool flag = false;
    rep(i, n + 1) {
        rep(j, m + 1) {
            if (j * (n - i) + i * (m - j) == k)
                flag = true;
        }
    }

    flag ? cout << "Yes" : cout << "No";
    cout << endl;

    return 0;
}

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


std::vector<bool> Eratosthenes( int N )
{
    std::vector<bool> is_prime(N + 1, true);
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    is_prime[0] = false;
    is_prime[1] = false;
    return is_prime;
}

void solve(long long X){
    vector<bool> v = Eratosthenes(1e7);
    for(int i = X;;i++){
        if(v[i]){
            cout<<i<<endl;
            return;
        }
    }
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

using namespace std;

using ll = long long;

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

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

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


  int n; cin >> n;
  vector<int> s(n);
  for(int i=0;i<n;++i) {
    cin >> s[i];
  }
  int q; cin >> q;
  vector<int> t(q);
  for(int i=0;i<q;++i) {
    cin >> t[i];
  }
  
  int cnt = 0;
  map<int, bool> mp;
  for(int i=0;i<q;++i) {
    bool ok = binary_search(s.begin(), s.end(), t[i]);
    if(ok) {
      cnt++;
    }
  }
  cout << cnt << endl;

}



Measured memory_bytes: 3272
import sys
#input = sys.stdin.buffer.readline

def main():
    N = int(input())
    S = str(input())
    left,right = 0,0
    for s in S:
        if s == "(":
            right += 1
        elif right <= 0:
            left += 1
        else:
            right -= 1
        
    print("("*left+S+")"*right)
  
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(void)
{
  int N;
  char s[4];
  int a = 0,b = 0,c = 0,d = 0;
  int i,j;

  scanf("%d",&N);
  for(i = 0;i < N;i++)
  {
    scanf("%s",s);
    if(strcmp(s,"AC")== 0)a++;
    if(strcmp(s,"WA")== 0)b++;
    if(strcmp(s,"TLE")== 0)c++;
    if(strcmp(s,"RE")== 0)d++;
    s[0] ='\0'; 
  }

  printf("AC x %d\n",a);
  printf("WA x %d\n",b);
  printf("TLE x %d\n",c);
  printf("RE x %d\n",d);
  
  return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#define int long long

using namespace std;

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2;
        return;
    }
    int ans = min(n - a, b - 1);
    int x = a - 1;
    ans = min(ans, x + 1 + (b - x - 1) / 2);
    int y = n - b;
    ans = min(ans, y + 1 + (n - (a + y + 1)) / 2);
    cout << ans << "\n";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()

K = ceil((-1+sqrt(1+8*N))/2)
tmp = K*(K+1)//2 - N

for i in range(K, 0, -1):
	if tmp < i:
		print(i)
	else:
		tmp -= i



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

template
<
    typename TYPE,
    std::size_t SIZE
>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;

#define REP(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
const int INF = 100001;

int n,a[INF],k;

int main()
{
    cin >> n >> k;
    REP(i,n){
        cin >> a[i];
    }
    cout << ceil((n-1)/(double)(k-1)) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r,g,b,n;
    cin>>r>>g>>b>>n;
    ll ans=0;
    rep(i,n/r+10)rep(j,n/g+10){
      ll k=n-i*r-j*g;
      if(k%b==0 && k/b>=0) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define MAXN 210
#define LL long long
using namespace std;



int main(){

    LL n,a,b,flag;
    cin >> n >> a >> b;
    if(b < a || (n == 1 && a != b)){
        flag = 0;
    }
    else if(n == 1 && a == b){
        flag = 1;
    }
    else {
        LL mi = a*(n-1)+b,ma = a+b*(n-1);
        flag = ma - mi + 1;
    }

    cout << flag <<endl;



return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  i64 H, A;
  std::cin >> H >> A;
  std::cout << tools::ceil(H, A) << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n+1],b=new int[n];
        for(int i=0;i<n+1;i++){
            a[i]=sc.nextInt();
        }
        for(int i=0;i<n;i++){
            b[i]=sc.nextInt();
        }
        long ans=0;
        int tmp;
        for(int i=0;i<n;i++){
            tmp=Math.min(a[i],b[i]);
            a[i]-=tmp;
            b[i]-=tmp;
            ans+=tmp;
            tmp=Math.min(a[i+1],b[i]);
            a[i+1]-=tmp;
            ans+=tmp;
        }
        System.out.println(ans);
        
    }
    
    
}

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

int main() {
  int n;
  long long length = 0;
  int a[310][310];
  bool ans = true;
  
  cin >> n;
  for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) cin >> a[i][j];
  
  for (int i = 0;i < n-1;++i) {
    for (int j = i+1;j < n;++j) {
      bool temp = true;
      for (int k = 0;k < n;++k) {
	if (a[i][j] > a[i][k]+a[k][j]) ans = false;
	if (a[i][j] == a[i][k]+a[k][j] && k != i && k != j) temp = false;
      }
      if (temp) length += a[i][j];
    }
  }
  
  cout << (ans ? length : -1) << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF 100000000000000
#define ll long long
using namespace std;
ll a,b,c,d,e,n;
ll arr[100001];
ll foo[100001];
ll trump(ll x){
    if(x==n)return 0;
    if(x>n)return INF/2;
    if(foo[x]!=INF)return foo[x];
    ll a=0,b=0;
    a=abs(arr[x]-arr[x+1])+trump(x+1);
    b=abs(arr[x]-arr[x+2])+trump(x+2);
    return foo[x]=min(a,b);
}
int main(){
    for(int i=0;i<=100001;i++)foo[i]=INF;
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>c;
        arr[i]=c;
    }
    cout<<trump(1)<<endl;
    return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		
		if(a * b == 15){
			System.out.println("*");
		}else if(a + b == 15){
			System.out.println("+");
		}else{
			System.out.println("x");
		}
		
	}
}


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

ll d(int n, vector<ll> a) {
  vector<ll> sum(n);
  sum[0] = a[0];
  for(int i=1;i<n;i++) {
    sum[i] = sum[i-1] + a[i]; 
  }

  ll result = numeric_limits<ll>::max();
  
  int c = 1;
  int d = 2;
  int e = 3;
  ll p, q, r, s;
  for(;d<=n-2;d++) {
    if(e <= d) {
      e = d + 1;
    }
    while(c<d-1) {
      if(abs(sum[c-1] - (sum[d-1] - sum[c-1])) < abs(sum[c] - (sum[d-1] - sum[c]))) {
	break;
      }
      c++;
    }
    while(e<n-1) {
      if(abs((sum[n-1] - sum[e-1]) - (sum[e-1] - sum[d-1])) < 
	  abs((sum[n-1] - sum[e]) - (sum[e] - sum[d-1]))) {
	break;
      }
      e++;
    }
    p = sum[c-1];
    q = sum[d-1] - sum[c-1];
    r = sum[e-1] - sum[d-1];
    s = sum[n-1] - sum[e-1];
    result = min(
	abs(max(p, max(q, max(r, s)))- min(p, min(q, min(r, s))))
	, result);
    //cout << " b -> 0-" << c-1 << " c -> " << c << "-" << d-1 << " d -> " << d << "-" << e-1 << " e-> " << e << "-" << n-1 <<endl;
    //cout << " p -> " << sum[c-1] << " q -> " << sum[d-1] - sum[c-1] << " r -> " << sum[e-1] - sum[d-1] << " e-> " << sum[n-1] - sum[e-1] << endl;
    //cout << " result " << result << endl;
  }

  return result;
  
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0; i< n;i++) {
    cin >> a[i];
  }
  cout << d(n, a);
}

Measured memory_bytes: 7992
#include "bits/stdc++.h"

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    var(int, N);
    i64 all = 0, odd = 0;
    reps(i, 1, N) {
        all++;
        odd += (i % 2 ? 1 : 0);
    }
    outn(fixed, setprecision(12));
    outl((double) odd / all);
    return 0;
}


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

int N, M;
vector<vector<int>> work(100010, vector<int>());  //work[i] : i日後にもらえる報酬一覧
priority_queue<int> pq;
int res = 0;   //報酬合計
int profit, d, p;

int main(){
  cin >> N >> M;

  for(int i = 0; i < N; i++){ cin >> d >> p; work[d].push_back(p); }

  for(int day = 1; day <= M; day++){  //残り日数
    for(int k = 0; k < work[day].size(); k++) pq.push(work[day][k]);

    if(pq.empty()) continue;  //受けれる仕事なし
    profit = pq.top();  //残り日数dayで受けれる仕事の中での最大報酬
    pq.pop();  //この仕事は受けた
    res += profit;
  }

  cout << res << endl;
  return 0;

}
    
  


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int n, k;
VI len;
int maxLength()
{
	sort(ALL(len), greater<int>());

	int ret = 0;
	for(int i = 0; i < k; ++i)
		ret += len[i];
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n >> k;

	len.resize(n);
	REP(i, 0, n) cin >> len[i];

	cout << maxLength() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;
 
ll pow(ll x,ll y){
  if(y==0){
    return 1;
  }else if(y==1){
    return x%MOD;
  }else if(y%2==0){
    return pow(x,y/2)*pow(x,y/2)%MOD;
  }else{
    return pow(x,y-1)*x%MOD;
  }
}

int main(){
  int N;cin >> N;
  vector<ll> X(N);
  vector<ll> Y(N);
  for(int i=0;i<N;i++){
    cin >> X[i] >> Y[i];
  }
  ll ans = -1;
  for(int bit=0;bit<2;bit++){
    ll q = 1;
    if(bit==1){
      q = -1;
    }
    ll Dmax = X[0] + Y[0] * q;
    ll Dmin = X[0] + Y[0] * q;
    for(int i=1;i<N;i++){
      Dmax = max(Dmax,X[i]+Y[i]*q);
      Dmin = min(Dmin,X[i]+Y[i]*q);
    }
    //cout << Dmin << " " <<Dmax << endl;
    if(ans==-1){
      ans = abs(Dmax-Dmin);
    }else{
      ll cur = abs(Dmax - Dmin);
      ans =  max(ans,cur);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define maxn 100050
#define inf 0x3f3f3f3f
#define LL long long
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mm(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const double eps = 1e-6;
const LL mod=1e9+7;
const LL INF=(LL)1e18;
using namespace std;
LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
LL qpow(LL x,LL y){LL re=1,base=x%mod;while(y){if(y&1)re=(re*base)%mod;base=(base*base)%mod;y>>=1;}return re;}
LL a[maxn];
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("ouput.txt","w",sdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	LL n,k;
	cin>>n>>k;
	LL Max=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		Max=max(Max,a[i]);
	}
	if(k>Max){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	if(n==1){
		if(a[1]==k) cout<<"POSSIBLE"<<endl;
		else cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(a[i]==k){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
	LL x=a[1];
	for(int i=2;i<=n;i++){
		x=gcd(x,a[i]);
	}
	if(x==1) cout<<"POSSIBLE"<<endl;
	else{
		if(k%x==0) cout<<"POSSIBLE"<<endl;
		else cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] a = new int[n];
			for(int i=0;i<n;i++){
				for(int j=0;j<5;j++){
					a[i] += sc.nextInt();
				}
			}
			Arrays.sort(a);
			System.out.println(a[n-1] + " " + a[0]);
			
		}
	}	
}

Measured memory_bytes: 33604
input_data=input()
new_input = input_data.split(" ")
# print(new_input)
A=int(new_input[0])
B=int(new_input[1])
C=int(new_input[2])
X=int(new_input[3])
Y=int(new_input[4])
min_num=min([X,Y])

#混合で作る場合
if min_num * (A+B) > min_num * 2 * C:
    price = min_num * 2* C
else:
    price = min_num*(A+B)

if min_num == X:
    if B > 2*C:
        price += 2 * C * abs(Y-X)
    else:
        price += B * abs(Y-X)
if min_num == Y:
    if A > 2*C:
        price += 2 * C * abs(Y-X)
    else:
        price += A * abs(Y-X)

print(price)

Measured memory_bytes: 3064
import math
n, k = map(int, input().split())
ans = 0.0
if n >= k:
  ans += (n-k+1)/n
  
for i in range(1, min(n+1, k)):
  now = i
  p = 1/n
  while(now <k):
    now *= 2
    p /= 2
  ans += p
  
print(ans)

Measured memory_bytes: 65596
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i=0; i<N; i++) cin >> p[i];
  int ans = 0;
  for (int i=0; i<N; i++) {
    if (p[i]==i+1) {
      ans++;
      i++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;
  ll count = 0;
  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    if (a == b)
      count++;
    else
      count = 0;
    if (count == 3) {
      Yes;
      return 0;
    }
  }
  No;

  return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {   
    public static void main(String[] args) {    	    	
	    long N, M;
	    Scanner sc = new Scanner(System.in);
	    N = sc.nextInt(); M = sc.nextInt();
	
		if (N>=2 && M>=2)
			System.out.println((N-2)*(M-2));
		else if (N==1 && M==1)
			System.out.println(1);
		else if (N==1)
			System.out.println(M-2);
		else  // M==1
			System.out.println(N-2);
			
		sc.close();								
    }
}

Measured memory_bytes: 23124
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
	    int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        if(nums[0] < (nums[2]-nums[1])) Console.WriteLine("dangerous");
        else if (nums[2] <= nums[1]) Console.WriteLine("delicious");
        else Console.WriteLine("safe");
	}
}

Measured memory_bytes: 11348
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
		//ArrayList<String> std_list = new ArrayList<String>();
			String std = scanner.nextLine();
			String[] std_list = std.split(" ");
			int a = Integer.parseInt(std_list[0]);
			String op = std_list[1];
			int b = Integer.parseInt(std_list[2]);

			if (op.equals("?")) {
				break;
			}
			else if (op.equals("+")) {
				System.out.println(a + b);
			}
			else if (op.equals("-")) {
				System.out.println(a - b);
			}
			else if (op.equals("*")) {
				System.out.println(a * b);
			}
			else {
				System.out.println(a / b);
			}
		}
	}
}


Measured memory_bytes: 26412
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define inp 20
#define check exit(0)
#define nl cout<<endl;
#define mod 1000000007 
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace __gnu_pbds;
using namespace std;
 
// Errichto ... ;)

void md(ll &a)
{
    a%=mod;
}
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
void sub_self(int& a, int b) {
    a -= b;
    if(a < 0) {
        a += mod;
    }
}

int main()
{
    jaldi

    int n,k;
    cin>>n>>k;
    vector<int> dp(k+1,0);
    dp[0]=1;

    for(int child=1;child<=n;child++)
    {
        int upto;
        cin>>upto;

        vector<int> tmp(k+2,0);
        for(int ubho=k;ubho>=0;ubho--)
        {
            int toadd=dp[ubho];
            int l=ubho+1;
            int r=ubho+min(upto,k-ubho);
            if(l<=r)
            {
                add_self(tmp[l],toadd);
                sub_self(tmp[r+1],toadd);
            }
        }
        int ps=0;
        for(int i=0;i<=k;i++)
        {
            add_self(ps,tmp[i]);
            add_self(dp[i],ps);
        }
    }
    cout<<dp[k];

    return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int m = a + b + c;
    if(a == b && b == c){
        cout << 0 << endl;
    } else {
        int ans = 0;
        if(m % 2 == 0){
            while(true){
                ans++;
                m += 2;
                if(m % 3 == 0 && m % 2 == 0
                && a <= m/3 && b <= m/3 && c <= m/3){
                    break;
                }
            }
        } else {
            while(true){
                ans++;
                m += 2;
                if(m % 3 == 0 && m % 2 == 1 
                && a <= m/3 && b <= m/3 && c <= m/3){
                    break;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto x = readln.chomp.split.to!(int[]);
  auto y = sort(x.dup);

  foreach (i; 0..x.length) {
    if (x[i] < y[n/2]) {
      writeln(y[n/2]);
    } else {
      writeln(y[n/2-1]);
    }
  }
}


Measured memory_bytes: 12940
import heapq

# def heapify(x):
#     for i in range((x)):
#         x[i] = -x[i]
#     heapq.heapify(x)

# def heappush(heap, item):
#     heapq.heappush(heap, -item)

# def heappop(heap):
#     return -heapq.heappop(heap)

# from heapq import heappop, heappush
# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None


def raw_input():
    return input()


rooms_count, passages_count = map(int, raw_input().split())
adj = []
for i in range(0, rooms_count):
    adj.append([])

for j in range(0, passages_count):
    a, b = map(int, raw_input().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)

seen = set()
distance = [100000000] * rooms_count
next = [100000000] * rooms_count
h = []
heapq.heappush(h, (0, 0, -1))
while len(h):
    (d, room, parent) = heapq.heappop(h)
    if (distance[room] <= d):
        continue
    distance[room] = d
    next[room] = parent
    seen.add(room)

    for neighbor in adj[room]:
        heapq.heappush(h, (d + 1, neighbor, room))

if len(seen) == rooms_count:
    print('Yes')
    for room in range(1, rooms_count):
        print(next[room] + 1)
else:
    print('No')


Measured memory_bytes: 56928
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	x %= b;
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;

int main(){
    ll X; cin >> X;
    ll k = X/500;
    X -= 500*k;
    ll l = X/5;
    cout << 1000*k + 5*l;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {   
    if (v == 0)
        return 1 % mod;
    if (v % 2 == 1)
        return (x * bpow(x, v - 1)) % mod;
    ll r = bpow(x, v / 2);
    return (r * r) % mod;   
}

ll solve(){ 
    ll n,m; cin>>n>>m;
    cout<<(n*(n-1))/2 + (m*(m-1))/2;
}

int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>

using namespace std;
string s1, s2, s3;

int main() {
  cin >> s1 >> s2 >> s3;
  cout << (char)toupper(s1.at(0)) << (char)toupper(s2.at(0)) << (char)toupper(s3.at(0)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int N,K; cin >> N >> K;
    vector <int> H(N);
    rep(i,N) cin >> H[i];
    
    vector <int> dp(110000,INF);
    dp[0]=0;
    for (int i=0; i<N; i++){
        for (int j=1; j<=K; j++){
            chmin(dp[i+j],dp[i]+abs(H[i]-H[i+j]));
        }
    }
   
    cout << dp[N-1] << endl;
}

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

int main()
{
    int n,v,s=0,m=INT_MIN;
    cin>>n;
    while(n--)
    {
        cin>>v;
        m=max(m,v);
        s+=v;
    }
    cout<<s-m/2<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 0,j = 0;
        while(true)
        {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0)
                break;
            for(i = 0 ; i < H ; i++)
            {
                for(j  = 0 ; j < W ; j++)
                    System.out.print("#");
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34556
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
ll k;
void mincost(ll i, ll mi[], ll h[])
{

	if (i == 0)
	{
		mi[i] = 0;
		return;
	}
	else if (i == 1)
	{
		mi[i] = abs(h[i] - h[i - 1]);
		return;
	}
	else
	{
		ll mini = LLONG_MAX;
		for (ll j = 1; j <= k; j++)
		{
			if (mi[i - j] == -1)
				mincost(i - j, mi, h);
		}
		for (ll j = 1; j <= k; j++)
		{
			mini = min(abs(h[i] - h[i - j]) + mi[i - j], mini);
		}
		mi[i] = mini;
	}
	return;
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin >> n >> k;

	ll h[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}
	ll mi[n];
	mem(mi, -1);
	mincost(n - 1, mi, h);
	cout << mi[n - 1];
	return 0;
}


Measured memory_bytes: 9804
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

h, w = na()

b = []
for i in range(h):
    b.append(na())

hh = []
hist = []
for i in range(h):
    for j in range(w):
        c = j if i % 2 == 0 else w-1-j
        if b[i][c] % 2 == 1:
            if len(hist) == 0:
                hist.append((i,c))
            else:
                hist.append((i,c))
                for k in range(len(hist)-1):
                    hh.append((hist[k][0]+1, hist[k][1]+1, hist[k+1][0]+1, hist[k+1][1]+1))
                hist = []
        else:
            if len(hist) > 0:
                hist.append((i,c))

print(len(hh))
for u in hh:
    print(" ".join(map(str, u)))


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

int main() {
	int n; cin >> n;
	vector<double> v(n);
	rep(i, n) cin >> v[i];
	rep(i, n - 1) {
		sort(v.begin(), v.end());
		v[i + 1] += v[i];
		v[i] = 0;
		v[i + 1] /= 2;
	}
	cout << v[n - 1] << endl;
}


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

#define int long long

int32_t main() {
    ios::sync_with_stdio(0);                                                                                                                               
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    map <int, int> vis;
    int st = 0;
    vector <int> t;
    bool f = false;
    int pos = -1;
    int it = 1;
    while (true) {
        t.push_back(st);
        if (vis[st]) {
            pos = vis[st];
            break;
        }
        vis[st] = it++;
        if (st == a[st]) f = true;
        st = a[st];
    }
    pos--;
    t.pop_back();
    if (k < t.size()) {
        cout << t[k] + 1 << '\n';
        return 0;
    }
    k -= pos;
    vector <int> kek;
    for (int i = 0; i < t.size(); i++) {
        if (i >= pos) kek.push_back(t[i]);
    }
    if (f) {
        cout << t.back() + 1 << '\n';
    }
    else {
        int sz = kek.size();
        k %= sz;
        cout << kek[k] + 1 << '\n';
    }
    return 0;   
}

Measured memory_bytes: 19036
#include<stdio.h>

int main(void)
{
	double n,a,Mx=-1000001,Mn=1000001,s=0;
	
	scanf("%lf",&n);
	
	for(int i=0;i<n;i++){
		
		scanf("%lf",&a);
		
		if(a>Mx){
			
			Mx=a;
			
		}
		
		if(a<Mn){
			
			Mn=a;
			
		}
		s=s+a;
		
	}
	
	printf("%0.f %0.f %0.f\n",Mn,Mx,s);
	
	return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

const string WA = "WA";
const string AC = "AC";

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, string>> submits(m);
    rep(i, m){
        int p;
        string s;
        cin >> p >> s;
        submits[i] = make_pair(p, s);
    }

    vector<pair<bool, int>> scores(1e5 + 5, pair<bool, int>(false, 0));
    for(auto x : submits){
        int num = x.first;
        string aw = x.second;
        if(!scores[num].first){
            if(aw == AC){
                scores[num].first = true;
            }
            else{
                scores[num].second++;
            }
        }
    }

    ll ans = 0;
    ll pen = 0;

    for(auto x : scores){
        if(x.first){
            ans++;
            pen += x.second;
        }
    }

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


Measured memory_bytes: 7296
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int arr[200005];

int main()
{
	cio;
	int n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++)
		cin >> arr[i];

	for (int i = 1; i + k <= n; i++)
	{
		if (arr[i] < arr[i + k])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}


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

using namespace std;
const int Maxn = 1e5 + 5;
set <int> vec[Maxn];
int cnt = 0;
int vis[Maxn], a[1010][1010], mp1[Maxn], mp2[Maxn];
int dfs(int x, int y){
    if (x == y) return 1;
    int ans = 0;
    vis[x] = 1;
    for (int i = 1; i <= cnt; i++)
        if (a[x][i] && !vis[i]){
            ans += dfs(i, y);
        }
    vis[x] = 0;
    return ans;
}
int main()
{
    //freopen("004.in", "r", stdin);
    int n, m;
    scanf("%d%d", &n, &m);
    //cout << n << " " << m << endl;
    for (int i = 1; i <= m; i++){
        int x, y;
        scanf("%d%d", &x, &y);
        //cout << x << " " << y << endl;
        vec[y].insert(x);
        vec[x].insert(y);
    }
    queue <int> q;
    for (int i = 1; i <= n; i++){
        if (vec[i].size() == 1) q.push(i);
    }
    //cout << q.size() << endl;
    while(!q.empty()){
        int x = q.front(), y = *vec[x].begin();
        //cout << x << endl;
        q.pop();
        vec[y].erase(x);
        vec[x].clear();
        if (vec[y].size() == 1){
            q.push(y);
        }
    }
    for (int i = 1; i <= n; i++){
        if (vec[i].size() == 2){
            set <int>::iterator it;
            it = vec[i].begin();
            int x = *it;
            it++;
            int y = *it;
            if (vec[x].find(y) == vec[x].end()){
                vec[x].insert(y);
                vec[y].insert(x);
                vec[x].erase(i);
                vec[y].erase(i);
                vec[i].clear();
            }
        }
    }
    for (int i = 1; i <= n; i++){
        if (!vec[i].empty()) mp1[i] = ++cnt, mp2[cnt] = i;
    }
    //cout << cnt << endl;
    for (int i = 1; i <= cnt; i++){
        int x = mp2[i];
        multiset <int>::iterator it;
        for (it = vec[x].begin(); it != vec[x].end(); it++){
            int y = *it;
            a[i][mp1[y]] = 1;
            //a[mp1[y]][i] = 1;
        }
    }
    int ans = 0;
    //cout << cnt << endl;
    for (int i = 1; i <= cnt; i++)
        for (int j = i + 1; j <= cnt; j++)
            if (a[i][j]){
            a[i][j] = a[j][i] = 0;
            ans += dfs(i, j);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 17756
N=int(input())

for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-N*n-N*h==0:
            continue
        if N*h*n%(4*h*n-N*n-N*h)==0:
            w=N*h*n//(4*h*n-N*n-N*h)
        else:
            continue
        if 4*h*n*w==N*(n*w+h*w+h*n) and w>0:
            print(h,n,w)
            exit()

Measured memory_bytes: 68308
from itertools import combinations
l, r = map(int,input().split())
if r-l >= 2019:
    print(0)
else:
    min_n = float('inf')
    for i, j in combinations([k for k in range(l, r+1)], 2):
        min_n = min(min_n, (i*j)%2019)
    print(min_n)
    

Measured memory_bytes: 3060