akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

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

  ll a, b, c, d; cin >> a >> b >> c >> d;
  ll mx = max({d * b, a * c, a * d, b * c});
  if (a <= 0 && 0 <= b) {
    ckmax(mx, 0ll);
  }
  if (c <= 0 && 0 <= d) {
    ckmax(mx, 0ll);
  }
  cout << mx << endl;
  
  return 0;
}


Measured memory_bytes: 3648
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
countA= Counter(A)
if n%2==1:
  for k,v in countA.items():
    if k==0:
      if v!=1:
        print(0)
        exit()
    else:
      if v!=2:
        print(0)
        exit()
  print(2**((n-1)//2)%mod)
else:
  for k,v in countA.items():
    if v!=2:
      print(0)
      exit()
  print(2**(n//2)%mod)


Measured memory_bytes: 14820
#include <bits/stdc++.h>
using namespace std;
int n;
const long long D=1e9+7;
long long gcd(long long x,long long y){
    if(y==0)return x;
    return gcd(y,x%y);
}
long long pow2(long long x,long long y){
    if(y%2==0)return 1;
    long long ret=pow2(x,y/2);
    return ret*ret%D*(y%2==0 ? 1: x)%D;
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    deque<char> dq;
    string s;
    cin>>s;
    for(auto k: s)dq.push_back(k);

    int flag=0;
    cin>>n;
    for(int i=0 ; i<n ; i++){
        int k;
        cin>>k;
        if(k==1){
            flag=1-flag;
        }
        else{
            int x;
            char c;
            cin>>x>>c;
            x--;
            if((x+flag)%2==0){
                dq.push_front(c);
            }
            else
                dq.push_back(c);
        }
    }
    if(flag==1){
        while(!dq.empty()){
            cout<<dq.back();
            dq.pop_back();
        }
        return 0;
    }
    while(!dq.empty()){
            cout<<dq.front();
            dq.pop_front();
        }
    return 0;
}


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

using ll = long long;
using ld = long double;

const ll MOD = 998244353;
const int N = 2e5;

inline void add(ll& x, ll y) { x = (x + y) % MOD; }

ll pre[N + 5], ar[N + 5];

void solve() {
  int n, k;
  cin >> n >> k;

  vector<pair<int, int>> bat;
  for(int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    bat.emplace_back(x, y);
  }
  pre[1] = ar[1] = 1;
  for(int i = 2; i <= n; i++) {
    for(int j = 0; j < k; j++) {
      add(ar[i], pre[max(0, i - bat[j].first)] - pre[max(0, i - bat[j].second - 1)]);
    }
    pre[i] = (pre[i - 1] + ar[i]) % MOD;
  }
  ar[n] %= MOD;
  if(ar[n] < 0) ar[n] += MOD;
  cout << ar[n] << '\n';
}

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

  int TC = 1;
  for(int i = 1; i <= TC; i++) {
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 6764
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll M;
	ll d[200001];
	ll c[200001];
	ll csum=0;
	ll dsum=0;
	scan(M);
	rep(i,M){
		scan(d[i]>>c[i]);
		dsum+=d[i]*c[i];
		csum+=c[i];
	}
	ll ans=csum-1;
	if(dsum>9) ans+=(dsum-9)/9+(dsum%9!=0);
	prin(ans);
	return 0;
}


Measured memory_bytes: 3328
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<list>
#include<map>
using namespace std ;
int n,q ;
vector<int> son[200005] ;
int dotval[200005] ;
int fa[200005] ;
void add(int a, int b){
	son[a].push_back(b); son[b].push_back(a);
}
void wk(int k,int v){
	dotval[k]+=v; 
}
void getval(int n,int f){
	for(auto& t:son[n]){
		if(t!=f){
			dotval[t]+=dotval[n] ;
			getval(t, n) ;
		}
	}
}
int main(){
	cin>>n>>q ;
	for(int i=1;i<n;++i){
		int a,b; cin>>a>>b; add(a,b) ;
	}
	while(q--){
		int x,y ; cin>>x>>y; wk(x,y) ;
	}
	getval(1, 0) ;
	for(int i=1;i<=n;++i) {
		cout<<dotval[i]<<" " ;
	}
	cout<<endl ;
}

Measured memory_bytes: 23424
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

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

class State
{
public:
        int x,y,c;
        State(int x, int y, int c)
        :x(x),y(y),c(c)
        {}
};

bool f[1000][1000];
bool v[1000][1000];

int main()
{
        int T,N;
        while(cin >> T >> N, (T||N))
        {
                memset(f,0,sizeof(f));
                memset(v,0,sizeof(v));

                for(int i=0; i<N; i++)
                {
                        int x,y;
                        cin >> x >> y;
                        f[x+500][y+500]=1;
                }

                int ret=0;

                int sx,sy;
                cin >> sx >> sy;
                queue<State> q;
                q.push(State(sx+500,sy+500,0));

                while(!q.empty())
                {
                        State s=q.front(); q.pop();
                        if(v[s.x][s.y]) continue;
                        if(s.c > T) continue;
                        v[s.x][s.y]=1;
                        ret++;

                        for(int i=0; i<6; i++)
                        {
                                int tx=s.x+dx[i], ty=s.y+dy[i];
                                if(v[tx][ty]) continue;
                                if(f[tx][ty]) continue;

                                q.push(State(tx,ty,s.c+1));
                        }
                }

                cout << ret << endl;
        }
}

Measured memory_bytes: 2880
lines = [list(map(int, input().split())) for _ in range(int(input()))]

for cx in range(101):
    for cy in range(101):
        pt = 0
        while lines[pt][2] == 0:
            pt += 1
        x0, y0, h0 = lines[pt]
        h = h0 + abs(cx - x0) + abs(cy - y0)
        flag = True
        for x0, y0, h0 in lines:
            tmp = h0 + abs(cx - x0) + abs(cy - y0)
            if h0 > 0 and tmp != h:
                flag = False
                break
            if h0 == 0:
                if h - abs(cx - x0) - abs(cy - y0) > 0:
                    flag = False
                    break
        if flag:
            print(cx, cy, h)
            exit()

Measured memory_bytes: 3064
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;


void fill_square(int left, int bottom, int width, int height, vector<vector<int>> &accum) {
    accum[left][bottom] += 1;
    accum[left + width][bottom] -= 1;
    accum[left][bottom + height] -= 1;
    accum[left + width][bottom + height] += 1;
}


int process_accum(vector<vector<int>> &accum) {
    for (int i = 0; i < accum.size(); i++) {
        int now = 0;
        for (int j = 0; j < accum[i].size(); j++) {
            now += accum[i][j];
            accum[i][j] = now;
        }
    }
    int maxx = 0;
    for (int i = 0; i < accum[0].size(); i++) {
        int now = 0;
        for (int j = 0; j < accum.size(); j++) {
            now += accum[j][i];
            accum[j][i] = now;
            maxx = max(maxx, now);
        }
    }
    return maxx;

}

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

    vector<int> x(n), y(n);

    for (int i = 0; i < n; i++) {
        char c;
        cin >> x[i] >> y[i] >> c;
        // 全部黒の条件だけで考えます
        if (c == 'W')
            x[i] += k;

        x[i] %= (2 * k);
        y[i] %= (2 * k);
    }
    vector<vector<int>> accum(2 * k+1, vector<int>(2 * k+1, 0));

    for (int i = 0; i < n; i++) {
        if (x[i] < k && y[i] < k) {
            fill_square(x[i], y[i], k, k, accum);
            fill_square(x[i] + k, y[i] + k, k - x[i], k - y[i], accum);
            fill_square(x[i] + k, 0, k - x[i], y[i], accum);
            fill_square(0, y[i] + k, x[i], k - y[i], accum);
            fill_square(0, 0, x[i], y[i], accum);
        }
        else if (x[i] < k) {
            fill_square(x[i], y[i], k, 2 * k - y[i], accum);
            fill_square(x[i] + k, y[i] - k, k - x[i], k, accum);
            fill_square(x[i], 0, k, y[i] - k, accum);
            fill_square(0, y[i] - k, x[i], k, accum);
        }
        else if (y[i] < k) {
            fill_square(x[i], y[i], 2 * k - x[i], k, accum);
            fill_square(x[i] - k, 0, k, y[i], accum);
            fill_square(0, y[i], x[i] - k, k, accum);
            fill_square(x[i] - k, y[i] + k, k, k - y[i], accum);
        }
        else {
            fill_square(x[i], y[i], 2 * k - x[i], 2 * k - y[i], accum);
            fill_square(x[i], 0, 2 * k - x[i], y[i] - k, accum);
            fill_square(0, 0, x[i] - k, y[i] - k, accum);
            fill_square(0, y[i], x[i] - k, 2 * k - y[i], accum);
            fill_square(x[i] - k, y[i] - k, k, k, accum);
        }
    }

    int ret = process_accum(accum);
    cout << ret << endl;


    return 0;
}

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

int main(){

  int N,count = 0,frag = 1;
  cin >> N;
  vector<int> A(N);

  for(int i = 0; i < N ; i ++){
    cin >> A.at(i);
  }

  while(frag){
    for(int i = 0 ;i < N ;i++){
      if(A.at(i) % 2 == 0){//もし２で割り切れるなら
        A.at(i) = A.at(i) / 2;
        // cout << "wari" << endl;
      }else{//割り切れないならカウントせず離脱
        // cout << "anya" << endl;
        frag = 0;
        break;
      }
    }
    count++;//なんにせよ始まった時点で追加されてしまうので
  }
  //
  // for(int i = 0;i < N;i++){
  //   cout << A.at(i) % 2 << endl;
  // }

  cout << --count << endl;//最後に一回引いておく（ゴミコードか？）
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007

ll ebob(ll a, ll b){
	if(a == 0) return b;
	return ebob(b%a, a);
}
int main(){
	ll n,a,b; cin>>n>>a>>b;
	if((a+b) % 2){
		if(a-1 < n-b){
			cout<<a-1 + (b-a+1)/2;
		}else{
			cout<<n-b + (b-a+1)/2;
		}
	}else{
		cout<<(b-a)/2;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    long r = sc.nextInt();
    long w = sc.nextInt();
    long rok1 = (r + 1) / 2;
    long rok2 = r / 2;
    long ok = ((w + 1) / 2) * rok1 + (w / 2) * rok2;
    if (r == 1 || w == 1) {
		ok = 1;
    }
    System.out.printf("%d", ok);
  }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);
int get_digent(int);


int main(){
  often();
  int n,d;
  cin >> n >> d;
  REP(i,1,n+1){
    if((2*d+1)*i >= n){
      cout << i << endl;
      return 0;
    }
  }
}








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
}  //ユークリッドの互除法

void often(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int get_digent(int x){
  string s;
  s = to_string(x);
  int digent = s.size();
  return digent;
} 

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

int linearSearch(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key){
        i++;
    }
    return i != n;
}
int main(){
    int A[10001];
    int m,n,key = 0;
    int sum = 0;

    scanf("%d",&m);
    for(int i = 0; i < m; i++) scanf("%d", &A[i]);
    scanf("%d",&n);
    
    for(int i = 0; i < n; i++){
        scanf("%d", &key);
        if(linearSearch(A, m, key)) sum++;
    }
   
    printf("%d\n",sum);
    
    return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a-b==b-c)
	{
		cout<<"YES\n";
		
	}
	else
	{
		cout<<"NO\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include<algorithm>
#include<cstring>
#include<queue>
#include <string>
using namespace std;
struct node
{ int Id;
  int ord;
  bool operator <(const node&c)
   { return ord<c.ord;
   }
}a[100010];
 int n; 
int main(int argc, char** argv) {
	cin>>n;
	
	 for(int i=0;i<n;i++)
	{ cin>>a[i].ord;
	  a[i].Id=i+1;
		
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{ cout<<a[i].Id<<" ";
		
	}
	return 0;
}

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

int main(){
    int N;
    int box[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> N;
    cout << box[N-1] << endl;
}

Measured memory_bytes: 256
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val N = rd.readInt()
    val AB = rd.readListLongCols(N)

    val ans = AB.reversed().fold(0L) { sum, ls ->
        val A = ls[0]; val B = ls[1]
        val C = B * ((A + sum + B - 1)/B)
        val press = C - (A + sum)
        sum + press
    }

    println(ans)
}


//val rd = debug.Reader("agc", "009", "a", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.ne(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll k;
int a[200005];
ll nx[65][200005];
void solve() {
    cin >> n >> k;

    map<int, vector<int>> idx;
    rep(i, n) {
        cin >> a[i];
        idx[a[i]].push_back(i);
    }

    for (auto& v : idx) {
        v.second.push_back(v.second[0] + n);

        rep(i, v.second.size() - 1) {
            nx[0][v.second[i]] = v.second[i + 1] - v.second[i] + 1;
        }
    }

    rep(i, 62) rep(j, n) {
        nx[i + 1][j] = min(inf, nx[i][j] + nx[i][(j + nx[i][j]) % n]);
    }

    ll now = 0;
    repd(i, 62) {
        if (now + nx[i][now % n] <= k * n)
            now += nx[i][now % n];
    }

    if (now == k * n) return;

    set<int> s;
    vector<int> ans;
    loop(i, now % n, n) {
        if (s.count(a[i]) == 0) {
            ans.push_back(a[i]);
            s.insert(a[i]);
        }
        else {
            while (true) {
                auto x = ans.back();
                ans.pop_back();
                s.erase(x);
                if (x == a[i]) break;
            }
        }
    }

    rep(i, ans.size()) cout << ans[i] << " ";
    cout << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 134644
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();  
        int c = sc.nextInt();
        int d = sc.nextInt();
        int l = (a+b);
        int r = (c+d);
        if(l>r) {
        System.out.println("Left");
        }
        else if(r>l)
        {
        System.out.println("Right");
        }
        else if(l==r)
        {
        System.out.println("Balanced");
        }
    }
}

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

int main() {
    int n; cin >> n;
    double res = 0;
    for (int i = 0; i < n; ++i) {
        double t; cin >> t;
        res += 1 / t;
    }

    cout << 1 / res << endl;
}

Measured memory_bytes: 256
a,b=[str(i) for i in input().split()]
list=["2","3","4","5","6","7","8","9","10","11","12","13","1"]
A=list.index(a)
B=list.index(b)
if A>B:
  print('Alice')
elif A==B:
  print('Draw')
else:
  print('Bob')

Measured memory_bytes: 3060
using System;

namespace _0543
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int goukei = int.Parse(Console.ReadLine());
                if(goukei==0)
                {
                    break;
                }
                for (int i = 0; i < 9; i++)
                {
                    goukei -= int.Parse(Console.ReadLine());
                }
                Console.WriteLine(goukei);
            }
        }
    }
}

Measured memory_bytes: 8984
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define fi first
#define se second
#define pii pair<int,int>
#define inf LLONG_MAX
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int MAX=(int)2e5 + 1;

bool cmp(pii a, pii b){
    if(a.fi < b.fi) return true;
    else if(a.fi==b.fi){
        return a.se < b.se;
    }
    return false;
}

signed main() {
    int n;
    cin>>n;
    int arr[n];
    vector< pii > v;
    for(int i=0;i<n;i++) {
        cin>>arr[i];
        v.push_back({arr[i], i});
    }

    int cnt=0;
    sort(v.begin(), v.end(), cmp);

    int req=1, prev_pos=-1;
    for(int i=0;i<n;i++){
        if(v[i].fi==req && v[i].se>prev_pos){
            cnt++;
            req++;
            prev_pos=v[i].se;
        }
    }

    if(cnt==0) cout<<-1<<"\n";
    else cout<<n-cnt<<"\n";

}

Measured memory_bytes: 7408
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(h,adj):
	n = len(h)
	ans = [0]*n
	for i in range(n):
		if(ans[i] == 0):
			currH = h[i]
			f = 1
			z = 1
			for nn in adj[i]:
				f = 0
				if(h[nn] >= currH):
					z = 0
					break
				elif(h[nn] < currH):
					ans[nn] = -1
			if(z == 1 and f == 0 and ans[i] == 0):
				ans[i] = 1
	for i in range(n):
		if(len(adj[i]) == 0):
			ans[i] = 1
	return ans.count(1)

N,M = list(map(int, stdin.readline().rstrip().split()))
h = list(map(int, stdin.readline().rstrip().split()))
adj = [[] for i in range(N)]
for mm in range(M):
	a,b = list(map(int, stdin.readline().rstrip().split()))
	a -= 1
	b -= 1
	adj[a].append(b)
	adj[b].append(a)
ans = solve(h,adj)
print(ans)



Measured memory_bytes: 101712
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  
  if(a==b && b==c) printf("No");
  else if(a!=b && a!=c && b!=c) printf("No");
  else printf("Yes");
  
  return 0;
 }

Measured memory_bytes: 128
def university(xxx, pattern):
    tate = 0
    yoko = 1
    for current_tate in range(8-xxx[tate]+1):
        for current_yoko in range(8-xxx[yoko]+1):
            if absolutely_fantastic(current_tate, current_yoko):
                return True

def absolutely_fantastic(current_tate, current_yoko):
    tate = 0
    yoko = 1
    run = []
    for add_tate in range(xxx[tate]):
        for add_yoko in range(xxx[yoko]):
            run.append(mapppp[current_tate+add_tate][current_yoko+add_yoko])
    if run == pattern:
        print xxx[2]
        return True

A = {(2,2,'A'):[1,1,1,1]}
B = {(4,1,'B'):[1,1,1,1]}
C = {(1,4,'C'):[1,1,1,1]}
D = {(3,2,'D'):[0,1,1,1,1,0]}
E = {(2,3,'E'):[1,1,0,0,1,1]}
F = {(3,2,'F'):[1,0,1,1,0,1]}
G = {(2,3,'G'):[0,1,1,1,1,0]}
lis = [A,B,C,D,E,F,G]
mapppp = []
count = 0
while True:
    try:
        input_line = raw_input()
        if input_line:
            yoko = [int(char) for char in input_line]
            mapppp.append(yoko)
            count += 1
        if count == 8:
            for XXX in lis:
                flag = False
                for xxx, pattern in XXX.items():
                    if university(xxx, pattern):
                        flag = True
                        break
                if flag == True:
                    break
            count = 0
            mapppp = []
    except EOFError:
        break

Measured memory_bytes: 4348
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>

using namespace std;

int main () {
  int n;
  while(cin >> n, n != 0 ) {
    int data[1000];
    int sum = 0;
    for(int i = 0; i < n ; i++){
      int r;
      cin >> r;
      data[i] = r;
      sum += r;
      
    }
    double avg = (double)sum / (double)n;
    double ss = 0;
    for(int i = 0; i < n ; i++){
      ss += pow((double)data[i] - avg, 2);
    }
    printf("%.6f\n", sqrt(ss/(double)n));


  }


}

Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    string s, t;
    cin >> s >> t;
    int ans = s.size();
    rep(i, s.size()) {
        if (s.at(i) == t.at(i)) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll n,m;
  while(cin>>n>>m,n||m){
    string s,p,g;
    cin>>s>>p>>g;
    vector<P> G[n];
    map<string,int> st;
    vector<string> vs;
    for(ll i=0;i<m;i++){
      string a,b;
      ll d,t;
      cin>>a>>b>>d>>t;
      if(st.find(a)==st.end()){
    st[a]=vs.size();
    vs.push_back(a);
      }
      if(st.find(b)==st.end()){
    st[b]=vs.size();
    vs.push_back(b);
      }
      G[st[a]].push_back(P(st[b],d/40+t));
      G[st[b]].push_back(P(st[a],d/40+t));
    }
    ll ans=0;
    ll dp[n];
    priority_queue<P,vector<P>,greater<P> > q;
    memset(dp,-1,sizeof(dp));
    q.push(P(0,st[s]));
    while(!q.empty()){
      P pp=q.top();q.pop();
      ll v=pp.second,d=pp.first;
      if(~dp[v]&&dp[v]<=d) continue;
      dp[v]=d;
      if(v==st[p]) break;
      for(ll i=0;i<(ll)G[v].size();i++){
    q.push(P(d+G[v][i].second,G[v][i].first));
      }
    }
    while(!q.empty()) q.pop();
    ans+=dp[st[p]];
    memset(dp,-1,sizeof(dp));
    q.push(P(0,st[p]));
    while(!q.empty()){
      P pp=q.top();q.pop();
      ll v=pp.second,d=pp.first;
      if(~dp[v]&&dp[v]<=d) continue;
      dp[v]=d;
      if(v==st[g]) break;
      for(ll i=0;i<(ll)G[v].size();i++){
    q.push(P(d+G[v][i].second,G[v][i].first));
      }
    }
    ans+=dp[st[g]];
    cout<<ans<<endl;
  } 
  return 0;
}

Measured memory_bytes: 3432
N, H = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort(reverse=True)
B.sort(reverse=True)

c = 0
for b in B:
    if b < A[0] or H <= 0:
        break
    H -= b
    c += 1

if H > 0:
    c += H // A[0]
    if H % A[0] != 0:
        c += 1

print(c)

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

int main()
{
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int k;
  cin >> k;
  int ma = a[0];
  for (int i = 0; i < 3; ++i) {
    if (ma < a[i])
      ma = a[i];
  }
  int sum = a[0] + a[1] +a [2] - ma;
  int kma = ma;
  for (int i = 0; i < k; ++i)
    kma *= 2;
  sum += kma;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;
int main()
{
    long long a,b;
    while(scanf("%lld %lld",&a,&b)!=EOF)
    {
        cout << floor(log10(a+b))+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<" ";

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    double a[n];
    double num=1e9,sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sum/=n;
    for(int i=0;i<n;i++){
        num=min(num,abs(a[i]-sum));
    }
    for(int i=0;i<n;i++){
        if(abs(sum-a[i])==num){
            cout<<i<<endl;
            return 0;
        }
    }

    return 0;
}


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

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


int main(){

    string s;
    cin >> s;
    if(s=="AAA"||s=="BBB"){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Maxn=45;
char vis[Maxn][Maxn];
ll f[Maxn][Maxn][Maxn];
int main(){
    int n;cin>>n;n*=2;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cin>>vis[i][j];
    for(int i=n;i>=1;i--)
        for(int j=i+1;j<=n;j++)
            for(int k=j;k<=n;k++)
                if(k==i+1)f[i][j][k]=j==k;
                else
                    for(int x=i+1;x<j;x++)
                        for(int y=j+1;y<=k;y++)
                            if(vis[x][y]=='1')
                                for(int a=x;a<j;a++)
                                    for(int b=j;b<y;b++)
                                        f[i][j][k]+=f[i][x][a]*f[a][j][b]*f[b][y][k];
    ll ans=0;
    for(int i=2;i<=n;i++)
        if(vis[1][i]=='1')
            ans+=f[1][i][n];
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
bool is_prime(long long number){
    for(long long i=2;i<=sqrt(number);i++)
    {
	if(number%i==0)
	    return false;
    }
    return true;
}
int main()
{
    long long int num;
    cin>>num;
    if(is_prime(num))
    {cout<<num;exit(0);}
	    long long int temp=num+1;
    while(!(is_prime(temp))){temp++;}
    cout<<temp;
    return 0;
}


Measured memory_bytes: 764
using System;
using System.Collections.Generic;

class TEST
{

    public static void Main()
    {
        string[] values = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
        float distance = float.Parse(values[0]);
        float time = float.Parse(values[1]);
        float speed = float.Parse(values[2]);


        if (distance / speed > time)
        {
            Console.WriteLine("No");
        }else
            Console.WriteLine("Yes");


   //     Console.ReadKey();
    }


}

Measured memory_bytes: 27356
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int N,K;
int sum=0;
cin>>N>>K;
int i;
int l[N];
  for(i=0;i<N;i++){
  cin>>l[i];
  }
  sort(l,l+N,greater<int>());
  for(i=0;i<K;i++){
    sum+=l[i];
  }
  cout<<sum;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
//bellman_ford
typedef struct E{
  int to,cost;
}edge;
const int MAX_V=1010;
const int Inf=1e9;
vector<vector<edge> >E(MAX_V);
int d[MAX_V];
bool bellman_ford(int s,int n) { // nは頂点数、sは開始頂点
  fill_n(d,MAX_V,Inf);
  d[s]=0;
  for (int i=0;i<n;i++) {
    for (int v=0;v<n;v++) {
      for (int k=0;k<E[v].size();k++) {
        edge e=E[v][k];
        if (d[v]!=Inf&&d[e.to]>d[v]+e.cost) {
          d[e.to]=d[v]+e.cost;
          if(i==n-1)return true; // n回目にも更新があるなら負の閉路が存在
        }
      }
    }
  }
  return false;
}
int main(){
  int a,b,r;cin>>a>>b>>r;
  for(int i=0;i<b;i++){
    int s;edge e;
    cin>>s>>e.to>>e.cost;
    E[s].pb(e);
  }
  if(bellman_ford(r,a)){
    cout<<"NEGATIVE CYCLE"<<endl;
  }else{
    for(int i=0;i<a;i++){
      if(d[i]==Inf)
	cout<<"INF"<<endl;
      else
	cout<<d[i]<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll L, R;
    cin >> L >> R;

    if (R - L >= 2018) {
        cout << 0 << endl;
        return;
    }

    ll ans = 2019;
    for (ll i = L; i <= R; i++) {
        for (ll j = i+1; j <= R; j++) {
            ans = min(ans, (i % 2019) * (j % 2019) % 2019);
        }
        // minval = min(minval, i % 2019);
    }

    // cout << (minval * (minval + 1)) % 2019 << endl;
    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import math

a,b,C = map(int, input().split())
S = (1/2)*a*b*math.sin(math.radians(C))
L = (a**2+b**2-2*a*b*math.cos(math.radians(C)))**(1/2)+a+b
h = 2*S/a
print(S)
print(L)
print(h)


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

using namespace std;

int p[10002];
int main() {
   int n, k;
   cin>>n>>k;
   for (int i=0; i<n; i++){
       cin>>p[i];
   }
   sort(p, p+n);
   int sum=0;
   
        for (int j=0; j<k; j++){
            sum+=p[j];
           
        }
   cout<<sum;
   
   return 0;
}

Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	N := sc.nextInt()
	Dn := sc.nextInts()
	var ans int
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if i == j {
				continue
			}
			ans += Dn[i] * Dn[j]
		}
	}
	fmt.Println(ans / 2)
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s;
	bool fl=true;
	int a,b;
	cin>>a>>b;
	while(a--){
		cin>>s;
		if(s=='-') fl=false;
	}
	cin>>s;
	if(s!='-') fl=false;
	while(b--){
		cin>>s;
		if(s=='-') fl=false;
	}
	cout<<(fl?"Yes\n":"No\n");
    return 0;
}

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

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long a = in.nextLong(), b = in.nextLong();
            out.println((a * b) % 2 == 0 ? "Even" : "Odd");
        }

    }
}



Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
int32_t main()
{
	fast;
	int n;
	cin>>n;
	vector<int> v(n);
	int l=-1;
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
		if(l==-1)
			l=v[i];
		else
			l=((l*v[i])/__gcd(l, v[i]));
	}
	int s=0;
	for(int i=0;i<n;i++)
		s+=l/v[i];
	cout<<fixed<<setprecision(10)<<(double)l/s<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char o[55],e[55];
	scanf("%s%s",o,e);
	int i;
	for(i=0;i<strlen(e);i++)
	  printf("%c%c",o[i],e[i]);
	if(strlen(o)-strlen(e)>0)
	  printf("%c",o[strlen(o)-1]);
	printf("\n");
	return 0;
}

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

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

  	int A, B, X; cin >> A >> B >> X;
    if (X >= A and X <= A+B) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
int n;
int c[501];
int s[501];
int f[501];
int main(){
  cin>>n;
  int now=0;
  int ans[501];
  for(int i=0;i<n-1;i++){
    cin>>c[i]>>s[i]>>f[i];
  }
  for(int i=0;i<n-1;i++){
    now=0;
    for(int j=i;j<n-1;j++){
      if(now<=s[j]){
        now=c[j]+s[j];
      }
      else{
        if(now%f[j]!=0) now+=(f[j]-(now%f[j]));
        now+=c[j];
      }
    }
    cout<<now<<endl;
  }
  cout<<0<<endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env pypy3

#import numpy as np
#import scipy, scipy.special

# Python 3 modules: https://docs.python.org/3/library/

import math, itertools, operator
from math import *
from math import factorial as fact
from operator import itemgetter, attrgetter
from itertools import permutations, combinations
from functools import reduce
# Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
# Before Python 3.5
from fractions import gcd

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return list(map(conv, inp().split(sep = sep)))

################################################################################

N, K = input_ints()
V = input_ints()

cnt = -inf
for LR in range(min(N,K)+1):
    disp = K - LR
    for L in range(LR+1):
        R = LR - L
        left = V[:L]
        right = V[-R:] if R > 0 else []
        s = sum(left) + sum(right)
        both = sorted(list(filter(lambda x: x < 0, left + right)))
        s -= sum(both[:disp])
        cnt = max(cnt, s)
print(cnt)


Measured memory_bytes: 5508
import sys

def merge(numlist, left, mid, right):
    L = numlist[left:mid] + [sys.maxsize]
    R = numlist[mid:right] + [sys.maxsize]
    i = j = 0
    k = left
    inv = 0
    while k < right:
        if L[i] < R[j]:
            numlist[k] = L[i]
            i += 1
        else:
            inv += (mid - left - i)
            numlist[k] = R[j]
            j += 1
        k += 1
    return inv


def cal_inv(numlist, left, right):
    if right > left + 1:
        mid = (left + right) // 2
        linv = cal_inv(numlist, left, mid)
        rinv = cal_inv(numlist, mid, right)
        return linv + rinv + merge(numlist, left, mid, right)
    else:
        return 0
    

if __name__ == '__main__':
    n  = int(input())
    numlist = [int(num) for num in input().split(' ')]
    print(cal_inv(numlist, 0, n))


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

int main () {
  
  int N;
  cin >> N;
  
  vector<long long> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  long long X = 0, Y = 0;
  
  for (int i = 0; i < N; i += 2) {
    X += A[i];
  }
  
  for (int i = 1; i < N; i += 2) {
    Y += A[i];
  }
  
  for (int i = 0; i < N; i++) {
    cout << X - Y << " ";
    X -= A[i];
    Y += A[i];
    swap(X, Y);
  }
    
  
}

Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            String[] values = line.split(" ");
            int y = Integer.parseInt(values[0]);
            int m = Integer.parseInt(values[1]);
            int d = Integer.parseInt(values[2]);
            int x = y * 10000 + m * 100 + d;
            String result = "pre-meiji";
            for (int i = 0; i < limits.length; i++) {
                if (x >= limits[i]) {
                    int year = y - limits[i] / 10000 + 1;
                    result = names[i] + " " + year + " " + m + " " + d;
                    break;
                }
            }
            out.println(result);
        }
    }

    private static int[] limits = { 19890108, 19261225, 19120730, 18680908 };

    private static String[] names = { "heisei", "showa", "taisho", "meiji" };
}

Measured memory_bytes: 8824
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b; scanf("%d%d", &a, &b);
	
	printf("%d\n", std::max({a + b, a - b, a * b}));
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;
  
  return 0;
}


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

int main(){
    long long A,B,N;
    cin>>A>>B>>N;
    long long limit=N/B;
    long long over=N%B;
    long long temp_first,temp_second;
    if(limit==0){
        temp_first=over*A;
        temp_first/=B;
        temp_second=over/B;
        temp_second*=A;
        cout<<temp_first-temp_second<<endl;
        return 0;
    }
    long long x;
    x=limit*B-1;
    temp_first=x*A;
    temp_first/=B;
    temp_second=x/B;
    temp_second*=A;
    long long first_op=temp_first-temp_second;
    x=limit*B+over;
    temp_first=x*A;
    temp_first/=B;
    temp_second=x/B;
    temp_second*=A;
    long long second_op=temp_first-temp_second;
    cout<<max(first_op,second_op)<<endl;
    return 0;
}

Measured memory_bytes: 3620