akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
  var n,_ int = NextInts()
  var a []int = NextIntArray()
  var min []int = make([]int,n)
  var max []int = make([]int,n)
  min[0] = a[0]
  max[n-1] = a[n-1]
  for i:=1;i<n;i++ {
    min[i] = min[i-1]
    if min[i] > a[i] { min[i] = a[i] }
    max[n-1-i] = max[n-i]
    if max[n-1-i] < a[n-1-i] { max[n-1-i] = a[n-1-i] }
  }
  var m int
  for i:=0;i<n;i++ {
    if m < max[i]-min[i] { m = max[i]-min[i] }
  }
  s := make(map[int]struct{})
  for i:=0;i<n;i++ {
    if max[i]-min[i] == m {
      s[max[i]] = struct{}{}
    }
  }
  fmt.Println(len(s))
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInts() (int,int) {
  var x,y int
  var s []string = strings.Split(NextLine()," ")
  x,_ = strconv.Atoi(s[0])
  y,_ = strconv.Atoi(s[1])
  return x,y
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

Measured memory_bytes: 7168
s = input()

if int(s[0:4]) < 2019:
    print('Heisei')
elif int(s[0:4]) > 2019:
    print('TBD')
else:
    if int(s[5:7]) <= 4:
        print('Heisei')
    elif int(s[5:7]) > 4:
        print('TBD')


Measured memory_bytes: 3060
def f(a,c):
    if (c-a)%2==0:
        return (c-a)//2
    return (c-a)//2+2
a,b,c=sorted(map(int,input().split()))
print(min(f(a,c)+f(b,c),f(a,c-1)+f(b,c-1)+1))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
using namespace boost::multiprecision;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define isu isupper
#define isl islower
#define lb(a,k) lower_bound(all(a),k)
#define ub(a,k) upper_bound(all(a),k)
#define bs(a,k) binary_search(all(a),k)
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

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

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    ll N;
    cin >> N;
    vl a(N);
    rep (i, N) cin >> a[i];

    ll m = 1000;
    ll cnt = 0;
    rep (i, N) {
        if (i != 0) m += (a[i]-a[i-1])*cnt;

        if (a[i] < a[i+1]) cnt = m/a[i];
        else cnt = 0;
    }

    cout << m << endl;
}


Measured memory_bytes: 3628
import heapq

n = int(input())
v = [int(v) for v in input().split()]

hq = []
for value in v:
    heapq.heappush(hq,value)

while len(hq) != 1:
    v1 = heapq.heappop(hq)
    v2 = heapq.heappop(hq)
    heapq.heappush(hq,(v1+v2)/2)
print(hq[0])


Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int N;
    int[] H;
    private void solve() {
        N = nextInt();
        H = new int[N];
        for(int i = 0;i < N;i++) {
            H[i] = nextInt();
        }

        int max = 0, ans = 0;
        for(int i = 0;i < N;i++) {
            if (max <= H[i]) {
                max = H[i];
                ans++;
            }
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

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

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

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

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

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define N 100000
using namespace std;

int child[N][20];
int parent[N];
int depth[N];
int k[N];
int root;

char str[3][20] = {"root","internal node","leaf"};

void pr(int id){
  int type;
  if(parent[id] == -1) type = 0;
  else if(k[id] > 0) type = 1;
  else if(k[id] == 0) type = 2;

  
  printf("node %d: parent = %d, depth = %d, %s, [", id, parent[id], depth[id], str[type]);
  for(int i=0;i<k[id];i++){
    if(i)printf(", ");
    printf("%d",child[id][i]);
  }
  printf("]\n");
}

void dfs(int id,int dep){
  depth[id] = dep;
  for(int i=0;i<k[id];i++)dfs(child[id][i],dep+1);
}

int main(){
  int n;
  cin>>n;
  memset(parent,-1,sizeof(parent));
  for(int i=0,id;i<n;i++){
    cin>>id;
    cin>>k[id];
    for(int j=0;j<k[id];j++){
      cin>>child[id][j];
      parent[ child[id][j] ] = id;
    }
  }
  
  for(int i=0;i<n;i++) if(parent[i] == -1) root = i;
  dfs(root,0);
  for(int i=0;i<n;i++)pr(i);

  return 0;
}

Measured memory_bytes: 5144
#include <iostream>

using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
    return b>0?gcd(b,a%b):a;
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}
int main()
{
    ll a,b;
    while ((cin>>a>>b)>0)
    {
        ll GCD=gcd(a,b);
        cout<<GCD<<" "<<a/GCD*b<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=200005;
int a[maxn],b[maxn];
int main(){
  int n;scanf("%d",&n);
  int l=1,r=n;
  for(int i=1;i<=n;++i)scanf("%d",a+i);
  int flag=0;
  for(int i=n;i>=1;--i){
    if(flag){
      b[r--]=a[i];      
    }else{

      b[l++]=a[i];
    }
    flag^=1;
  }
  for(int i=1;i<=n;++i)printf("%d ",b[i]);
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define INF (1 << 30)
#define MAX (1 << 20)

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

    int n;

    cin >> n;

    string s[n];
    int t[n], ans = 0;
    string x;

    for(int i = 0; i < n; i++){
        cin >> s[i] >> t[i];
    }

    cin >> x;

    bool flag = false;
    for(int i = 0; i < n; i++){
        if(flag)
            ans += t[i];
        if(s[i] == x){
            flag = true;
        }
    }

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

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll X, Y, A, B, C;
ll p[100010], q[100010], r[100010];
priority_queue<ll> pq;
ll ans;
int main(){
	cin >> X >> Y >> A >> B >> C;
	REP(i,0,A) cin >> p[i];
	REP(i,0,B) cin >> q[i];
	REP(i,0,C) cin >> r[i];
	sort(p, p+A);
	sort(q, q+B);
	sort(r, r+C);
	REP(i,0,min(A, X)){
		pq.push(p[A-i-1]);
	}
	REP(i,0,min(B, Y)){
		pq.push(q[B-i-1]);
	}
	REP(i,0,min(C, X+Y)){
		pq.push(r[C-i-1]);
	}
	REP(i,0,X+Y){
		ans += pq.top();
		pq.pop();
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 8560
# list型でappend, popを用いると、Stackとして使うことができる。
# push -> append, pop -> pop
S = input().split()
s = []
for i in S:
    if i not in ['+', '-', '*']:
        s.append(int(i))
    else:
        s1 = s.pop()
        s2 = s.pop()
        if i == '+':
            s.append(s1 + s2)
        elif i == '-':
            s.append(s2 - s1)
        elif i == '*':
            s.append(s1 * s2)
print(s[0])



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef double flt;
const flt inf = 1e9;

int p[20], h[20];
int d, n, b;

flt get(flt s, flt l, int n) {
  flt ret = inf;
  for (int i = 0; i < n; ++ i) {
    if (p[i] >= s && p[i] <= s + l) {
      flt x = p[i] - s;
      ret = min(ret, sqrt((l * x - x * x) / 2.0 / h[i]));
    }
  }
  return ret;
}

int main() {
  while (scanf("%d%d%d", &d, &n, &b) == 3) {
    for (int i = 0; i < n; ++ i) scanf("%d%d", p + i, h + i);
    flt ret(inf);
    for (int i = 1; i <= b + 1; ++ i) {
      flt l = flt(d) / i, vx(inf);
      for (int j = 0; j < i; ++ j) {
        flt s = l * j;
        vx = min(vx, get(s, l, n));
      }
      if (vx == 0) continue;
      flt a = l / 2;
      if (vx >= sqrt(a)) ret = min(ret, sqrt(2.0 * a));
      else ret = min(ret, sqrt(vx * vx + a * a / vx / vx));
    }
    printf("%.10f\n", ret);
  }
  return 0;
}

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

typedef long long ll;

ll n, sum, r, b[100000], a[100000];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a + n);
    b[0] = a[0];
    for (int i = 1; i < n; ++i)
        b[i] = a[i] + b[i - 1];
    //for (int i = 0; i < n; ++i)
    //    cout << a[i] << " ";
    //cout << endl;
    //for (int i = 0; i < n; ++i)
    //    cout << b[i] << " ";
    //cout << endl;
    int mx = 0;
    for (int i = 0; i < n - 1; ++i)
        if (a[i + 1] > 2 * b[i])
            mx = i + 1; //, cout << "1";
    //else
    //    cout << "0";
    //cout << endl;
    cout << n - mx << endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = [0] + list(map(int,input().split()))
X = [0 for i in range(N+1)]

for i in range(1,N+1)[::-1]:
    tmp = 0
    for j in range(1,N//i+1):
        tmp = (tmp + X[i*j]) % 2
    X[i] = tmp ^ A[i]
print(sum(X))
[print(i) for i, a in enumerate(X) if a]

Measured memory_bytes: 7984
datasets = []

while n = gets.chomp.to_i
	if n == 0
		break
	end
	dataset = {}
	points = []
	n.times do |i|
		point = gets.chomp.split(" ")
		points << point
	end
	dataset[:points] = points
	
	m = gets.chomp.to_i
	moves = []
	m.times do |i|
		move = gets.chomp.split(" ")
		moves << move
	end
	dataset[:moves] = moves
	
	datasets << dataset
end


datasets.each do |dataset|
	gem_count = dataset[:points].size
	r_point = [10, 10]

	dataset[:moves].each do |move|
		move[1].to_i.times do |i|
			case move[0]
			when "N"
				r_point[1] += 1 
			when "E"
				r_point[0] += 1
			when "W"
				r_point[0] -= 1
			when "S"
				r_point[1] -= 1
			end

			dataset[:points].each_with_index do |point, i|
				if r_point[0] == point[0].to_i && r_point[1] == point[1].to_i
					gem_count -= 1
					dataset[:points][i] = [-1, -1]
				end
			end

		end

	end


	if gem_count == 0
		puts "Yes"
	else
		puts "No"
	end
end

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

int n, A[20];

bool exhaustiveSearch(int v, int i){
  if ( v == 0) return 1;
  if (i >= n || v < 0 ) return 0;
  bool res = exhaustiveSearch(v, i + 1) || exhaustiveSearch(v - A[i], i + 1);
  return res;
}

int main(){
  int q, v;
  cin >> n;
  for ( int i = 0; i < n; i++) cin >> A[i];
  cin >> q;
  for ( int i = 0; i < q; i++){
    cin >> v;
    if (exhaustiveSearch(v, 0)) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

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


void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  cin >> a;

  // x = ai(2p+1)/2
  // x = ai'(2p+1)
  rep(i, n) {
    if (a[i] % 2) {
      cout << 0 << endl;
      return;
    }
    a[i] /= 2;
  }

  // youtube editorial
  // x = ai'(2p+1)
  // x, ai' で素因数 2 の数が同じでないと
  int two = 0;
  rep(i, n) {
    int tmp = 0;
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      tmp++;
    }
    // cout << tmp << endl;
    if (i == 0) two = tmp;
    else {
      if (tmp != two) {
        cout << 0 << endl;
        return;
      }
    }
  }
  while (two--) m /= 2;

  // cout << a << endl;
  // すべて奇数
  ll l = 1;
  rep(i, n) {
    l = lcm(l, 1LL * a[i]);
    // cout << l << endl;
    if (l > m) {
      cout << 0 << endl;
      return;
    }
  }
  cout << (m / l + 1) / 2 << endl;
}


Measured memory_bytes: 640
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            return False
    return True


while 1:
    a,d,n = map(int,input().split())
    if a == 0: break
    if is_prime(a):
        n -= 1
    while n > 0:
        a += d
        if is_prime(a):
            n -= 1
    print(a)


Measured memory_bytes: 5660
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define pb(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007


using namespace std;



int main() {
	int n,cnt=0;
	cin >> n;
	vector<int> v;
	REP(i, n) {
		int a;
		cin >> a;
		v.pb(a);
	}
	REP(i, n) {
		int mini = i;
		FOR(j, i, n) {
			if (v[j] < v[mini]) {
				mini = j;
			}
		}
		if (i != mini) {
			swap(v[i], v[mini]);
			cnt++;
		}
	}
	REP(i, n) {
		cout << v[i];
		if (i != n - 1) cout << " ";
	}
	cout << endl;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3140
/*
 *       Author:  8mao
 * Created Time:  2014/3/16 13:46:42
 *    File Name:  1346.cpp
 */
# include<map>
# include<set>
# include<cmath>
# include<queue>
# include<stack>
# include<vector>
# include<string>
# include<cstdio>
# include<cstring>
# include<iostream>
# include<algorithm>
# include<functional>
using namespace std;

typedef pair<int,int> PII;
# define INF 1<<30
# define LL long long
# define MOD 1000000007
# define VI vector<int>
# define VLL vector<LL>
# define VS vector<string>
# define PII pair<int,int>

# define F first
# define S second
# define mp make_pair
# define pb push_back
# define lb lower_bound
# define up upper_bound
# define lowbit(x)(x&-x)
# define lson l,m,rt<<1
# define rson m+1,r,rt<<1|1
# define clr(x) (x).clear()
# define sz(x) ((int)(x).size())
# define all(x) (x).begin(),(x).end()
# define mem(x,y) memset(x,y,sizeof(x))
# define forall(it,c) for(typeof((c).begin())it=(c).begin();it!=(c).end();it++)

# define N 305
LL b[N][N], a[N];

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

LL calc(LL a, LL b, LL c)
{
    //printf ("%I64d %I64d %I64d\n", a, b, c);
    LL g = gcd(a, c);
    a /= g, c /= g;
    g = gcd(b, c);
    b /= g, c /= g;
    return (LL)sqrt(a * b * 1.0);
}

int main()
{
    //freopen("in.txt","r",stdin);
    int i, j, n;
    while (scanf ("%d", &n) != EOF && n) 
    {
        mem (a, 0);    
        for (i = 0; i < n; i++)
            for (j = i + 1; j <= n; j++)
                scanf ("%lld", &b[i][j]);
        a[0] = calc(b[0][1], b[0][2], b[1][2]);
        for (i = 1; i <= n; i++)
            a[i] = b[0][i] / a[0];
        printf ("%lld\n", a[0]);
        sort (a + 1, a + n + 1);
        for (i = 1; i <= n; i++)
            printf ("%lld%c", a[i], i == n ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 1800
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	long long a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	if(a*b >= c*d)
	printf("%lld",a*b);
	else
	printf("%lld",c*d);
	return 0;
}

Measured memory_bytes: 128
var
	n,i,j,c,a,b:Longint;
	x,y,d:array[1..100000]of Longint;
begin
	read(n);
	for i:=1 to n do begin
		read(x[i],y[i]);
		if (abs(x[i])+abs(y[i]))mod 2<>(abs(x[1])+abs(y[1]))mod 2 then begin
			writeln(-1);
			exit;
		end;
	end;
	a:=1073741824;
	while a>0 do begin
		inc(c);
		d[c]:=a;
		a:=a div 2;
	end;
	if (abs(x[1])+abs(y[1]))mod 2=0 then begin
		inc(c);
		d[c]:=1;
	end;
	writeln(c);
	for i:=1 to c do write(d[i],' ');
	writeln;
	for i:=1 to n do begin
		a:=x[i];
		b:=y[i];
		for j:=1 to c do begin
			if abs(a)>abs(b) then begin
				if a>0 then begin
					dec(a,d[j]);
					write('R');
				end else begin
					inc(a,d[j]);
					write('L');
				end;
			end else begin
				if b>0 then begin
					dec(b,d[j]);
					write('U');
				end else begin
					inc(b,d[j]);
					write('D');
				end;
			end;
		end;
		writeln;
	end;
end.


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    rep(i, N) cin >> x[i];
    rep(i, M) cin >> y[i];
    
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    for (int i = x[N - 1] + 1; i <= y[0]; ++i) {
        if (X < i && i <= Y) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
    int a,b,s;
    char c;

    scanf("%d %c %d",&a,&c,&b);
    if(c=='+'){
        s=a+b;
    printf("%d\n",s);
    }
    else if(c=='-'){
        s=a-b;
         printf("%d\n",s);
    }










    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int imprtnum = scan.nextInt();

        int A,B,C,D;
        D=imprtnum%10;
        imprtnum/=10;
        C=imprtnum%10;
        imprtnum/=10;
        B=imprtnum%10;
        imprtnum/=10;
        A=imprtnum%10;

        boolean p1 = A+B+C+D==7;
        boolean p2 = A+B+C-D==7;
        boolean p3 = A+B-C+D==7;
        boolean p4 = A+B-C-D==7;
        boolean p5 = A-B+C+D==7;
        boolean p6 = A-B+C-D==7;
        boolean p7 = A-B-C+D==7;
        boolean p8 = A-B-C-D==7;

        if(p1){
            System.out.println(A+"+"+B+"+"+C+"+"+D+"=7");
        }else if(p2){
            System.out.println(A+"+"+B+"+"+C+"-"+D+"=7");
        }else if(p3){
            System.out.println(A+"+"+B+"-"+C+"+"+D+"=7");
        }else if(p4){
            System.out.println(A+"+"+B+"-"+C+"-"+D+"=7");
        }else if(p5){
            System.out.println(A+"-"+B+"+"+C+"+"+D+"=7");
        }else if(p6){
            System.out.println(A+"-"+B+"+"+C+"-"+D+"=7");
        }else if(p7){
            System.out.println(A+"-"+B+"-"+C+"+"+D+"=7");
        }else if(p8){
            System.out.println(A+"-"+B+"-"+C+"-"+D+"=7");
        }
    }
}

Measured memory_bytes: 23124
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    rr = []

    def f(i,n):
        t = [c for c in str(i)]
        if len(t) < n:
            t = t + ['0'] * (n-len(t))
        t.sort()
        a = int(''.join(t))
        b = int(''.join(t[::-1]))
        return b - a

    while True:
        n,l = LI()
        if n == 0 and l == 0:
            break
        d = {}
        d[n] = 0
        i = 1
        while True:
            n = f(n,l)
            if n in d:
                rr.append('{} {} {}'.format(d[n], n, i-d[n]))
                break
            d[n] = i
            i += 1


    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9032
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	int a, b, c; cin >> a >> b >> c;
	vector<int> len(n);
	for( auto &i : len ) cin >> i;
	int bound = 0;
	for( int i = 0; i < n; ++i ){
		bound += 3*pow(4, i);
	}
	int ans = INF;
	for( int i = 0; i <= bound; ++i ){
		vector<int> welch;
		int itemp = i;
		for( int j = 0; j < n; ++j ){
			welch.push_back( itemp % 4 );
			itemp -= itemp % 4;
			itemp /= 4;
		}
		int sum[4] = {0, 0, 0, 0};
		int gs[4] = {0, 0, 0, 0};
		for( int j = 0; j < n; ++j ){
			++gs[welch[j]];
			sum[welch[j]] += len[j];
		}
		if( gs[1] == 0 || gs[2] == 0 || gs[3] == 0 ) continue;
		int res = abs( a-sum[1] ) + abs( b-sum[2] ) + abs( c-sum[3] ) + 10*(gs[1]-1) + 10*(gs[2]-1) + 10*(gs[3]-1);
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  string s;
  cin >> s;
  vi32 cnt = {0, 0};
  rep(i, s.size()) {
    if (s[i] == '0') cnt[0]++;
    else cnt[1]++;
  }
  cout << s.size() - abs(cnt[0] - cnt[1]) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned int uint;
typedef unsigned long long ulint;
constexpr lint mod1 = 1e9+7;

template<typename T>
struct ST{
  using F = function<T(T, T)>;
  int size_ = 1, n_; vector<T> node; T initial; F query_, update_;
  ST(int n, T initial, F query, F update){
    while(size_ < n) size_ *= 2;
    node.resize(2*size_-1, initial);
    n_ = n;
    query_ = query;
    update_ = update;
  }
  void printnodes(){
    rep(i, node.size()) cout << node[i] << endl;
    return;
  }
  void build(vector<T> v){
    rep(i, v.size()) node[i+size_-1] = v[i];
    rrep(i, size_ - 1) node[i] = query_(node[2*i+1], node[2*i+2]);
    return;
  }
  void update(int j, T x){
    j += size_-1;
    node[j] = update_(node[j], x);
    while(j > 0){
      j = (j-1)/2;
      node[j] = query_(node[2*j+1], node[2*j+2]);
    }
    return;
  }
  T query(int l, int r){
    l += size_-1;
    r += size_-1;
    T ql = node[l], qr = node[r];
    while(l < r-1){
      if(l % 2 == 1) ql = query_(node[l], node[l+1]);
      if(r % 2 == 0) qr = query_(node[r-1], node[r]);
      l = (l-1)/2;
      r = (r-1)/2;
    }
    return query_(ql, qr);
  }
  int lb(T x){
    int tmp = 0;
    while(tmp < size_-1){
      if(x <= node[tmp*2+1]) tmp = tmp*2+1;
      else tmp = tmp*2+2;
    }
    if(node[tmp] < x) ++tmp;
    return min(tmp+1-size_, n_);
  }
  int ub(T x){
    int tmp = 0;
    while(tmp < size_-1){
      if(x < node[tmp*2+1]) tmp = tmp*2+1;
      else tmp = tmp*2+2;
    }
    return min(tmp+1-size_, n_);
  }
};

int main() {
  lint n, s = 0;
  cin >> n;
  vector<lint> a(n), b(n), c(n);
  rep(i, n) cin >> a[i]; rep(i, n) cin >> b[i]; rep(i, n) cin >> c[i];
  sort(a.begin(), a.end()); sort(b.begin(), b.end()); sort(c.begin(), c.end());
  auto f = [](lint p, lint q){return max(p, q);};
  auto g = [](lint p, lint q){return q;};
  ST<lint> sta(n, 0, f, g), stc(n, 0, f, g);
  sta.build(a); stc.build(c);
  rep(i, n) s += sta.lb(b[i]) * (n - stc.ub(b[i]));
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 7536
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, K = in.nextInt
  val As = Array.fill(N)(in.nextDouble)

  def cuts(orig: Double, max: Int): Double = (orig / max).ceil - 1

  def binSearch(min: Int, max: Int, cur: Int): Int = {
    if (min + 1 == max) max
    else {
      val totalCuts = As.map(cuts(_, cur)).sum
      if (totalCuts > K) binSearch(cur, max, (cur + max) / 2)
      else binSearch(min, cur, (min + cur) / 2)
    }
  }

  println(binSearch(0, 1_000_000_000, 500_000_000))
}

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

using namespace std;

#define MAX 1500

vector<int> G[MAX];
set<int> st;
bool visited[MAX];

void solve(int v){
  if(st.count(v)) return;
  if(visited[v]) return;
  visited[v] = true;
  if(G[v].size() == 0){
    st.insert(v);
  }
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    solve(G[v][i]);
  }
}

int main(){
  int N;
  while(cin >> N, N){
    for(int i = 0 ; i < MAX ; i++){
      G[i].clear();
      visited[i] = false;
    }
    int idx = 0;
    string s;
    map<string,int> mp;
    for(int i = 0 ; i < N ; i++){
      cin >> s;
      int p = s.find(":");
      string s1,s2;
      s1 = s.substr(0,p);
      s2 = s.substr(p+1); s2.resize(s2.size()-1);
      if(mp.find(s1) == mp.end()){
        mp[s1] = idx++;
      }
      stringstream ss(s2);
      while(getline(ss,s2,',')){
        if(mp.find(s2) == mp.end()){
          mp[s2] = idx++;
        }
        G[mp[s1]].push_back(mp[s2]);
      }
    }
    st.clear();
    solve(0);
    cout << st.size() << endl;
  }
  return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N;
ll x[51], y[51];
map<pair<ll, ll>, ll> mp;
ll ans;
int main() {
	cin >> N;
	REP(i,0,N){
		cin >> x[i] >> y[i];
	}
	ans = N;
	REP(i,0,N){
		REP(j,0,N){
			if(i==j) continue;
			mp[make_pair((x[i]-x[j]), (y[i]-y[j]))]++;
			ans = min(N - mp[make_pair((x[i]-x[j]), (y[i]-y[j]))], ans);
		}
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 384
import math
li=[]
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
a2 = math.ceil(a/10)*10
b2 = math.ceil(b/10)*10
c2 = math.ceil(c/10)*10
d2 = math.ceil(d/10)*10
e2 = math.ceil(e/10)*10
s = a2+b2+c2+d2+e2
a = str(a)
b = str(b)
c = str(c)
d = str(d)
e = str(e)
li.append(int(a[-1]))
li.append(int(b[-1]))
li.append(int(c[-1]))
li.append(int(d[-1]))
li.append(int(e[-1]))
li.sort()
i=0
ans=0
while ans==0 and i!=5:
  ans=li[i]
  i+=1
if ans != 0:
  ans = 10 - ans
print(s-ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int N,M;
int dp[100010]; //dp[i] = iからのLongest Path
vector<int> graph[100010];
vector<bool> root(100010);

int solve(int a) {
    if(dp[a] != Inf) {
        return dp[a];
    }
    int cnt = 0;
    bool update = false;
    for(int i = 0;i < graph[a].size();i++) {
        update = true;
        cnt = max(cnt,solve(graph[a].at(i)));
    }
    if(update == false) {
        return dp[a] = 0;
    }
    else {
        return dp[a] = cnt + 1;
    }
}

int main() {
    cin >> N >> M;
    for(int i = 0;i < M;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        B--;
        graph[A].push_back(B);
        root.at(B) = true;
    }
    for(int i = 0;i < 100010;i++) {
        dp[i] = Inf;
    }
    for(int i = 0;i < N;i++) {
        if(root.at(i) == false) {
            solve(i);
        }
    }
    int ret = 0;
    for(int i = 0;i < N;i++) {
        ret = max(ret,dp[i]);
    }
    cout << ret << endl;
}

Measured memory_bytes: 13936
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BStringPalindrome {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      int n = s.size();
      rep(i, n) {
        if (s[i] != s[n-1-i]) {
          cout << "No" << endl;
          return;
        }
      }
      for(int i=0; i<(n-1)/2; i++) {
        if (s[i] != s[(n-1)/2-1-i]) {
          cout << "No" << endl;
          return;
        }
      }
      reverse(all(s));
      for(int i=0; i<(n-1)/2; i++) {
        if (s[i] != s[(n-1)/2-1-i]) {
          cout << "No" << endl;
          return;
        }
      }

      cout << "Yes" << endl;


    }
};

signed main() {
  BStringPalindrome solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(v1, v2));
    graph[v2].push_back(Edge(v2, v1));
  }
  return graph;
}

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

  int n;
  cin >> n;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  auto graph = ReadUndirectedGraph(n, n - 1, true);

  int r = -1;
  for (int v = 0; v < n; v++) {
    if (graph[v].size() >= 2) {
      r = v;
      break;
    }
  }

  if (r == -1) {
    // n == 2
    if (n != 2) exit(1);
    cout << ((xs[0] == xs[1]) ? "YES" : "NO") << endl;
    return 0;
  }

  vector<int64> dp(n);
  function<bool(int, int)> dfs_fn = [&](int v, int p) -> bool {
    if (graph[v].size() == 1) {
      dp[v] = xs[v];
      return true;
    }

    int64 xc = 0;
    int64 xv = xs[v];
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      if (!dfs_fn(e.to, v)) return false;
      xc += dp[e.to];
    }

    int64 a = xc - xv;
    int64 b = -xc + xv * 2;

    if (a < 0 || b < 0) return false;
    
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      if (dp[e.to] > a + b) return false;
    }
    
    dp[v] = b;

    if (p < 0) return b == 0;

    return true;
  };
  bool ans = dfs_fn(r, -1);
  cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 19400
#include <bits/stdc++.h>
#define int long long int
const int INF = 1000000007;
using namespace std;
void solve() {
   int n, a, b;
   cin >> n >> a >> b;
   cout << min(n*a, b) << '\n';
   return ;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define SQ(x) ((x) * (x))
 
 
int main(void)
{
 double x,y,r;
 double x1,x2,x3,y1,y2,y3;
 double ecm[3][2]; //enlarged coefficient matrix:ツ拡ツ妥・ツ係ツ青板行ツ療ア
 double a,b,c,A;
 int i;
 int n;
 
 scanf("%d",&n);
 for(i = 0; i < n; i++)
 {
  scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
  ecm[0][0] = x1 - x2;
  ecm[0][1] = y1 - y2;
  ecm[0][2] = (x2*x2 + y2*y2) - (x1*x1 + y1*y1);
  ecm[1][0] = x1 - x3;
  ecm[1][1] = y1 - y3;
  ecm[1][2] = (x3*x3 + y3*y3) - (x1*x1 + y1*y1);
  A = (ecm[0][0]*ecm[1][1])-(ecm[0][1]*ecm[1][0]); 
  a = ((ecm[0][2]*ecm[1][1])-(ecm[0][1]*ecm[1][2]))/A+0;
  b = ((ecm[0][0]*ecm[1][2])-(ecm[0][2]*ecm[1][0]))/A+0;
  x = (a/-2.0);
  y = (b/-2.0);
  c = -1 * (SQ(x1) + SQ(y1) + a * x1 + b * y1);
  //r = sqrt(pow(x1*x1-x0*x0,2)+pow(y1*y1-y0*y0,2));
  printf("%.3f %.3f %.3f\n",x,y,sqrt(SQ(a) + SQ(b) - 4 * c) / 2.0); 
 }
 return 0;
}
 

Measured memory_bytes: 0
using System;
class Program
{
  public static void Main(){
        // Your code here!
        string[] s = System.Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        if((a+b)%2==0){
            System.Console.WriteLine((a+b)/2);
        }else{
            System.Console.WriteLine("IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 11092
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int D;
int G;
int P[10];
int C[10];
int main(){
  int i;
  int j;
  int k;
  int x;
  int y;
  int res = 1073709056;
  rd(D);
  rd(G);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(D);Lj4PdHRW++){
      rd(P[Lj4PdHRW]);
      rd(C[Lj4PdHRW]);
    }
  }
  G /= 100;
  {
    int KL2GvlyY;
    for(KL2GvlyY=(0);KL2GvlyY<((D-1) + 1);KL2GvlyY++){
      C[KL2GvlyY] /= 100;
    }
  }
  for(k=(0);k<(1<<D);k++){
    x = y = 0;
    j = -1;
    for(i=(0);i<(D);i++){
      if(k&1<<i){
        x += P[i];
        y += (i+1) * P[i] + C[i];
      }
      else{
        j = i;
      }
    }
    if(y >= G){
      chmin(res, x);
      continue;
    }
    if(j == -1){
      continue;
    }
    if(y + (j+1) * P[j] < G){
      continue;
    }
    chmin(res, x +divup_L((G-y),(j+1)));
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190925-1

// --- original code ---
// int D, G, P[10], C[10];
// {
//   int i, j, k, x, y, res = int_inf;
// 
//   rd(D,G,(P,C)(D));
//   G /= 100;
//   C[0..D-1] /= 100;
// 
//   rep(k,1<<D){
//     x = y = 0;
//     j = -1;
//     rep(i,D){
//       if(k&1<<i) x += P[i], y += (i+1) * P[i] + C[i];
//       else       j = i;
//     }
//     if(y >= G) res <?= x, continue;
//     if(j == -1) continue;
//     if(y + (j+1) * P[j] < G) continue;
//     res <?= x + (G-y) /+ (j+1);
//   }
// 
//   wt(res);
// }


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);

  for (int i = 0; i < n; ++i){
    cin >> a[i];
  }

  for (int i = 0; i < n - k; ++i){
    if (((a[i] * 1.0) / a[k + i]) < 1){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4048
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  static double F_[6001];
  auto F = F_ + 3000;
  F[0] = 1.;
  for (auto i = 1; i <= N; ++i) {
    double p;
    cin >> p;
    auto f = F[-i - 1];
    for (auto j = -i; j <= i; ++j)
      f = exchange(F[j], f * p + F[j + 1] * (1 - p));
  }
  auto res = accumulate(F + 1, F + N + 1, 0.);
  cout << fixed << setprecision(12) << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    ll N;
    cin >> N;

    string s;
    while (N) {
        N--;
        s.push_back('a' + (N % 26));
        N /= 26;
    }

    reverse(s.begin(), s.end());
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3652
use proconio::input;
use proconio::marker::Isize1;

fn size(parents: &mut Vec<isize>, i: isize) -> isize {
  let ii = find(parents, i) as usize;
  -1 * parents[ii]
}

fn find(parents: &mut Vec<isize>, i: isize) -> isize {
  let ii = i as usize;
  if parents[ii] < 0 {
    i
  } else {
    parents[ii] = find(parents, parents[ii]);
    parents[ii]
  }
}

fn connect(
  parents: &mut Vec<isize>,
  a: isize,
  b: isize
) -> bool {
  let mut pa = find(parents, a);
  let mut pb = find(parents, b);
  
  if pa == pb { return false }
  
  if size(parents, pa) < size(parents, pb) {
    let temp = pa;
    pa = pb;
    pb = temp;
  }
  
  let paa = pa as usize;
  let pbb = pb as usize;
  parents[paa] += parents[pbb];
  parents[pbb] = pa;
  
  true
}

fn main() {
  input! {
    n: usize,
    m: usize,
    vals: [(Isize1, Isize1);m]
  }
  let mut parents: Vec<isize> = vec![-1;n];
  let mut result: Vec<isize> = vec![0;m];
  let mut index = m - 1;
  result[index] = (n * (n - 1) / 2) as isize;
  while 0 < index {
    let (from, to) = vals[index];
    result[index-1] = result[index];
    if find(&mut parents, from) != find(&mut parents, to) {
      let val = size(&mut parents, from) * size(&mut parents, to);
      result[index-1] -= val;
      connect(&mut parents, from, to);
    }
    index -= 1;
  }
  
  for v in result {
    println!("{}", v);
  }
}

Measured memory_bytes: 6236
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n; cin >> n;
   int K; cin >> K;
   vector<int> a(n);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }

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

   vector<int> b;
   for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
         b.push_back(sum[j+1] - sum[i]);
      }
   }

   int ans = 0;
   for (int i = 40; i >= 0; i--) {
      // DUMP(i);
      sort(b.rbegin(), b.rend());
      // DUMP(b);
      if (b[K-1] >> i & 1) {
         ans |= 1LL<<i;
         // DUMP(ans);
         vector<int> bn;
         for (int j = 0; j < b.size() && b[j] >> i & 1; j++) {
            bn.push_back(b[j]);
         }
         swap(bn, b);
      } else {
         for (int j = 0; b[j] >> i & 1; j++) {
            b[j] &= ~(1LL<<i);
         }
      }
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 6388
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        Map<String,Integer> map = new TreeMap<>();
        int max = 0;
        for(int i = 0; i<n;i++){
            String s = sc.next();
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            } else {
                map.put(s,1);
            }
            max = Math.max(max,map.get(s));
        }
        for(String key : map.keySet()){
            if(map.get(key)==max){
                System.out.println(key);
            }
        }
    }
}

Measured memory_bytes: 78996
#include<bits/stdc++.h>
using namespace std;
int a[207];
int main(){
    int n,l;
    cin>>n>>l;
    int x=0;
    int mn=1e9;
    for(int i=1;i<=n;++i){
        x=0;
        a[i]=l+i-1;
        if(a[i]<0){
            x=-a[i];
        }
        else{
            x=a[i];
        }
        mn=min(mn,x);
    }
    int flag=0;
    for(int i=1;i<=n;++i){
        if(a[i]==mn||a[i]==-mn){
            flag=i;
        }
        if(flag)
            break;
    }
    int sum=0;
    for(int i=1;i<=n;++i){
        if(i!=flag){
            sum+=a[i];
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,a[1100000],s[1100000][2],g[110000],tm[4];
long long ans;
inline bool cmp(int x,int y){
	if (a[x]==a[y]) return x<y;
	return a[x]>a[y];
}
inline void uni(int x,int y){
	/*if (a[s[y][0]]>a[s[x][0]]){//<
		s[x][1]=s[x][0];
		s[x][0]=s[y][0];
	}else if (a[s[y][0]]>a[s[x][1]]){//<
		s[x][1]=s[y][0];
	}
	if(a[s[y][1]]>a[s[x][1]]) s[x][1]=s[y][1];//<*/
	tm[0]=s[x][0];tm[1]=s[x][1];tm[2]=s[y][0];tm[3]=s[y][1];
	sort(tm,tm+4,cmp);
	s[x][0]=tm[0];
	fo(i,1,3) if (tm[i]!=tm[0]){
		s[x][1]=tm[i];
		break;
	}
}
int main(){
	scanf("%d",&n);
	fo(i,0,(1<<n)-1) scanf("%d",&a[i]);
	a[1<<n]=-0x7fffffff;
	s[0][0]=0;s[0][1]=1<<n;//null
	fo(x,1,(1<<n)-1){
		//s[x][0]=s[x][1]=1<<n;//null
		s[x][0]=x;s[x][1]=1<<n;
		fo(i,0,n-1) if (x&(1<<i)) uni(x,x^(1<<i));
	}
	fo(x,1,(1<<n)-1) g[x]=a[s[x][0]]+a[s[x][1]];
	fo(x,1,(1<<n)-1){
		if (g[x]>g[x+1]) g[x+1]=g[x];
		printf("%d\n",g[x]);
	}
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#pragma optimize("TKACHENKO-GORYACHENKO")
#define psl pair <string, ll>
#define pls pair <ll, string>
#define x first
#define y second
#pragma GCC optimize("O3")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 4e5;
const ll inf = 1e15;

ll n, m, k, t;

int main()
{
	pyshnapyshnakaa;
	ll q, w, e, a, b, c;
	cin >> n;
	vector <pll> X;
	set <ll> S;
	S.insert(inf);
	S.insert(-inf);
	map <ll, ll> M;
	for (q = 0; q < n; q++) {
		cin >> a >> b;
		X.pb(mp(a - b, a + b));
		// cout << a << " " << b << endl;
		// cout << X[q].first << " " << X[q].second << endl;
		S.insert(a - b);
		S.insert(a + b);
	}
	vector <ll> I;
	for (auto p: S) {
		M[p] = I.size();
		I.pb(p);
	}
	vector <vector <ll> > L(I.size());
	for (q = 0; q < n; q++) {
		X[q] = mp(M[X[q].first], M[X[q].second]);
		// cout << X[q].first << " " << X[q].second << endl;
		L[X[q].first].pb(q);
	}
	// cout << endl;
	vector <ll> D(I.size());
	D[0] = 0;
	for (q = 1; q < I.size(); q++) {
		// cout << q << " " << D[q] << endl;
		D[q] = max(D[q], D[q - 1]);
		for (auto i : L[q]) {
			ll r = X[i].second;
			D[r] = max(D[r], D[q] + 1);
			// cout << r << " R" << endl; 
		}
	}
	cout << D[I.size() - 1];
	return 0;
}


Measured memory_bytes: 34672