akhauriyash/Code-Regression huggingface dataset:
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    deque<char> d;
    for(auto &x : s){
        d.push_back(x);
    }
    int pol = 0; //left head
    int q;
    cin >> q;
    while(q--){
        int t;
        cin >> t;
        if(t == 1){
            pol = pol ^ 1; // right head
        }else{
            int f;
            char c;
            cin >> f >> c;
            if(f == 1){
                if(pol == 0){
                    d.push_front(c);
                }else{
                    d.push_back(c);
                }
            }else{
                if(pol == 0){
                    d.push_back(c);
                }else{
                    d.push_front(c);
                }
            }
        }
    }
    if(pol == 0){
        while(SZ(d)){
            cout << d.front();
            d.pop_front();
        }
    }else{
        while(SZ(d)){
            cout << d.back();
            d.pop_back();
        }
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, s;
  cin >> n >> s;
  vl a(n);
  rep(i, n) cin >> a[i];
  mint dp[s + 1] = {};
  dp[0] = mint(2).pow(n);
  rep(i, n) for(int j = s - 1; j >= 0; j--) if(j + a[i] <= s) dp[j + a[i]] +=
      dp[j] / 2;
  cout << dp[s] << endl;
}

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

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

	vector<long long> v;

	for (int i = 0; i < N; i++) {
		long long a;
		cin >> a;
		v.push_back(a);
	}

	sort(v.begin(), v.end(), std::greater<long long>());
	
	unsigned long long ans = 0;
	int index = 0;
	for (int i = 0; i < N - 1; i++) {
		static bool b = true;
		ans += v[index];
		if (b)
			index++;
		b = !b;
	}

	cout << ans << endl;

	return 0;
}

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

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

Measured memory_bytes: 3600
#include <stdio.h>
int n,A[50];
int solve(int ,int );
int main(){
  int q,l,i;
  scanf("%d", &n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&l);
    if(solve(0,l))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
int solve(int i,int m){
  if(m==0) return 1;
  if(i>=n) return 0;
  int res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}

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

string shuffle(string s, int h){
	return s.substr(h) + s.substr(0, h);
}

int main(){
	while(true){
		string s;
		cin >> s;
		
		if(s == "-") return 0;
		
		int n;
		cin >> n;
		
		for(int i=0; i<n; i++){
			int h;
			cin >> h;
			s = shuffle(s, h);
		}
		
		cout << s << "\n";
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 3080
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>

std::vector<int> multiply(
    std::vector<int> const& a,
    std::vector<int> const& b) {

  size_t n = a.size();
  if (n <= 32) {
    std::vector<int> res(n+n-1);
    for (size_t i = 0; i < n; ++i)
      for (size_t j = 0; j < n; ++j)
        res[i+j] += a[i] * b[j];
    return res;
  }

  size_t nl = n/2;
  size_t nh = n-nl;
  std::vector<int> al(a.begin(), a.begin()+nl);
  std::vector<int> ah(a.begin()+nl, a.end());
  std::vector<int> bl(b.begin(), b.begin()+nl);
  std::vector<int> bh(b.begin()+nl, b.end());

  auto t = multiply(al, bl);
  auto u = multiply(ah, bh);

  for (size_t i = 0; i < nl; ++i) {
    ah[i] += al[i];
    bh[i] += bl[i];
  }

  std::vector<int> res(n+n-1);
  auto v = multiply(ah, bh);
  for (size_t i = 0; i < t.size(); ++i) {
    v[i] -= t[i];
    res[i] += t[i];
  }
  for (size_t i = 0; i < u.size(); ++i) {
    v[i] -= u[i];
    res[nl+nl+i] += u[i];
  }

  if (nl != nh) v.pop_back();

  for (size_t i = 0; i < v.size(); ++i)
    res[nl+i] += v[i];

  return res;
}

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  auto aa = multiply(a, a);
  int res = 0;
  for (auto& aai: aa) res += aai;
  for (auto ai: a) res -= ai * ai;
  res /= 2;
  printf("%d\n", res);
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	_, m := scanInt(), scanInt()
	type city struct{ i, p, y int }
	cs := make([]city, m)
	for i := range cs {
		cs[i].i = i
		cs[i].p, cs[i].y = scanInt(), scanInt()
	}
	sort.Slice(cs, func(i, j int) bool {
		if cs[i].p == cs[j].p {
			return cs[i].y < cs[j].y
		}
		return cs[i].p < cs[j].p
	})

	xs := make([]string, m)
	p, c := 0, 0
	for _, v := range cs {
		if p != v.p {
			p = v.p
			c = 0
		}
		c++
		xs[v.i] = fmt.Sprintf("%06d%06d", p, c)
	}

	wr := bufio.NewWriter(os.Stdout)
	for _, v := range xs {
		wr.WriteString(v + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 9196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		double btc = 380000.0;
		double x, sum = 0;
		String str;
		for (int i = 0; i < n; i++) {
			x = sc.nextDouble();
			str = sc.next();
			if (str.equals("JPY")) {
				sum += x;
			} else if (str.equals("BTC")) {
				sum += x * btc;
			}
		}
		System.out.println(sum);
	}
}


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

int main() {
    char a,b;
    cin >> a >> b;
    if(a=='H' && b=='H') cout << 'H' << endl;
    if(a=='H' && b=='D') cout << 'D' << endl;
    if(a=='D' && b=='H') cout << 'D' << endl;
    if(a=='D' && b=='D') cout << 'H' << endl;
}

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

#define int long long

int count(int a , int b , int x){
	int f = b/x , l = a/x ;
	return f - l + (a%x == 0) ;
}

int32_t main(){
	int a , b , c , d ;
	cin >> a >> b >> c >> d ;
	cout << b - a + 1 - count(a,b,c) - count(a,b,d) + count(a,b,c*d/__gcd(c,d)) ;
 	return 0;
}



Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;

///aとbの最大公約数を求める関数。計算量はO(log min(a, b))
Int Gcd(Int a, Int b) {
	if (a % b == 0)return b;
	else return Gcd(b, a % b);
}

void calc() {

	Int N; std::cin >> N;
	std::string S; std::cin >> S;
	std::unordered_map<char, Int> m; //個数
	rep(i, N)m[S[i]]++;
	Int ans = m['R'] * m['G'] * m['B'];

	for (Int i = 0; i < N; ++i)for (Int k = i + 1; k < N; ++k) {
		if (std::abs(k - i) <= 1 || (i + k) % 2 != 0)continue;
		Int j = (i + k) / 2;
		if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i])ans--;
	}

	std::cout << ans;

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(){
    int N,Sum=0,L,k;
    scanf("%d",&N);
    scanf("%d",&L);
    k=L+N;
    if(L>0){
        for(int i=0;i<N;i++){
        Sum=Sum+L+i;
    }
    Sum=Sum-L;
    } else if(L==0){
        for(int i=0;i<N;i++){
        Sum=Sum+L+i;
    }
    }else{
        if(k>0){
        for(int i=0;i<N;i++){
        Sum=Sum+L+i;
    }
        }else{
        for(int i=0;i<N;i++){
        Sum=Sum+L+i;
    } Sum=Sum-(L+N-1);
    }
    }
    printf("%d",Sum);
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){cin >> A[i]; B[i]=A[i];}
  sort(B.begin(),B.end());
  int M=B[N-1]; int m=B[N-2];
  for(int i=0;i<N;i++){
    if(A[i]!=M)cout << M << endl;
    else cout << m << endl;
  }
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <map>

using Graph = std::vector<std::vector<std::pair<int, int>>>;

struct LCA {
    const Graph& g;
    std::vector<std::vector<int>> par;
    std::vector<int> dep;

    LCA(const Graph& g) : g(g), dep(g.size(), -1) {
        int n = g.size();
        int k = 1;
        while ((1 << k) < n) k++;
        par.assign(k, std::vector<int>(n, -1));
        dep[0] = 0;
        dfs(0);

        for (int i = 0; i < k - 1; i++) {
            for (int j = 0; j < n; j++) {
                if (par[i][j] < 0)
                    par[i + 1][j] = -1;
                else
                    par[i + 1][j] = par[i][par[i][j]];
            }
        }
    }

    void dfs(int u) {
        for (auto p : g[u]) {
            int v = p.first;
            if (dep[v] < 0) {
                dep[v] = dep[u] + 1;
                par[0][v] = u;
                dfs(v);
            }
        }
    }

    int query(int u, int v) {
        if (dep[u] < dep[v]) std::swap(u, v);
        
        int k = par.size();
        for (int i = 0; i < k; i++) {
            if (dep[u] - dep[v] >> i & 1)
                u = par[i][u];
        }

        if (u == v) return u;

        for (int i = k - 1; i >= 0; i--) {
            if (par[i][u] != par[i][v]) {
                u = par[i][u];
                v = par[i][v];
            }
        }

        return par[0][u];
    }
};

Graph g;
std::vector<int> c, d;
std::vector<int> x, y; 
std::map<int, std::vector<int>> plus, minus;
std::vector<int> dist;
std::vector<int> num, sum;
std::vector<int> ans;

void dfs(int u) {
    for (int i : plus[u])
        ans[i] += num[x[i]] * y[i] - sum[x[i]];
    for (int i : minus[u])
        ans[i] -= (num[x[i]] * y[i] - sum[x[i]]) * 2;

    for (auto p : g[u]) {
        int v = p.first;
        int i = p.second;
        if (dist[v] < 0) {
            dist[v] = dist[u] + d[i];
            num[c[i]]++;
            sum[c[i]] += d[i];
            dfs(v);
            num[c[i]]--;
            sum[c[i]] -= d[i];
        }
    }
}

int main() {
    int N, Q;
    std::cin >> N >> Q;

    g.resize(N);
    c.resize(N);
    d.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        std::cin >> a >> b >> c[i] >> d[i];
        a--;
        b--;

        g[a].push_back(std::make_pair(b, i));
        g[b].push_back(std::make_pair(a, i));
    }

    LCA lca(g);

    x.resize(Q);
    y.resize(Q);
    std::vector<int> u(Q), v(Q), t(Q);
    for (int i = 0; i < Q; i++) {
        std::cin >> x[i] >> y[i] >> u[i] >> v[i];
        u[i]--;
        v[i]--;

        plus[u[i]].push_back(i);
        plus[v[i]].push_back(i);
        
        t[i] = lca.query(u[i], v[i]);
        minus[t[i]].push_back(i);
    }

    dist.assign(N, -1);
    num.resize(N);
    sum.resize(N);
    ans.resize(Q);
    dist[0] = 0;
    dfs(0);

    for (int i = 0; i < Q; i++) {
        ans[i] += dist[u[i]] + dist[v[i]] - dist[t[i]] * 2;
        std::cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 44280
x = int(input())

if 400 <= x <=599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)

Measured memory_bytes: 9184
#include<stdio.h>
#define N 100000
#define INFTY 1000000000
  
struct Card{
    
  char suit;
  int value;
    
};
  
struct Card L[N], R[N];
  
void merge(struct Card *, int, int, int);
void mergeSort(struct Card *, int , int);
int partition(struct Card *, int, int);
void quickSort(struct Card *, int, int);
  
  
  
int main(){
    
  int num;
  int i;
  int j;
  struct Card A[N], B[N];
  char S[10];
  int stable;
  
  stable = 1;
    
  scanf("%d", &num);
  
  for ( i = 0; i < num; i++ ) {
      
    scanf("%s %d", S, &j);
      
    A[i].suit = S[0];
    B[i].suit = S[0];
    A[i].value = j;
    B[i].value = j;
      
  }
  
  mergeSort(A, 0, num);
  quickSort(B, 0, num-1);
  
  for ( i = 0; i < num; i++ ){
    if ( A[i].suit != B[i].suit ) stable = 0;
  }
  
  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < num; i++ ) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }
  
  return 0;
}
  
void merge(struct Card A[], int left, int mid, int right){
    
  int i, j, k;
  int n1;
  int n2;
    
  n1 = mid - left;
  n2 = right - mid;
  
  for ( i = 0; i < n1; i++ ) {
    L[i] = A[left + i];
  }
  for ( i = 0; i < n2; i++ ) {
    R[i] = A[mid + i];
  }
  
    
  L[n1].value = INFTY;
  R[n2].value = INFTY;
  
  i = 0;
  j = 0;
    
  for ( k = left; k < right; k++ ){
      
    if ( L[i].value <= R[j].value ){
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}
   
void mergeSort(struct Card A[], int left, int right ){
    
  int mid;
    
  if ( left + 1 < right ){
      
    mid = (left + right)/2;
      
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
  
int partition(struct Card A[], int p, int r){
    
  int i, j;
  struct Card t, x;
  
  x = A[r];
  i = p - 1;
    
  for ( j = p; j < r; j++ ){
      
    if ( A[j].value <= x.value ){
        
      i++;
        
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
      
  }
    
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
    
  return i+1;
}
  
void quickSort(struct Card A[], int p, int r){
  
  int q;
    
  if ( p < r ){
      
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
      
  }
    
}


Measured memory_bytes: 4040
s = list(input())
q = int(input())
for i in range(q):
    cmd = [s for s in input().split()]
    cmd[1] = int(cmd[1])
    cmd[2] = int(cmd[2])
    if cmd[0] == "replace":
        c = list(cmd[3])
        h = 0
        for j in range(cmd[1], cmd[2]+1):
            s[j] = c[h]
            h+=1
    elif cmd[0] == "reverse":
        k = cmd[1]
        l = cmd[2]
        while k < l:
            t = s[k]
            s[k] = s[l]
            s[l] = t
            k+=1
            l-=1
    else:
        for m in range(cmd[1], cmd[2]+1):
            print("{}".format(s[m]), end = "")

        print()
        

Measured memory_bytes: 7860
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	double a, b;
	cin >> a >> b;
	cout << a/b << endl;

	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  
    long long x;
    cin >> x;
    
    int days = 0;
    long long curr = 100;
    while (curr < x) {
        days++;
        curr *= 1.01;
    }
    cout << days << endl;
    return 0;
}


Measured memory_bytes: 3624
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
    }

    let mut counter = 0;
    let mut max = 0;

    for c in s {
        if c == 'R' {
            counter += 1;
            if max < counter {
                max = counter;
            }
        } else {
            counter = 0
        }
    }
    println!("{}", max);
}

Measured memory_bytes: 2096
macro_rules! input { (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize
    }
    let mut v = vec![a, b, c, d];
    v.sort();
    let mut ans = 0;
    if !(b < c || d < a) {
        ans += v[2] - v[1]
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
using namespace std;
const long long N = 1e10 + 7;
const int maxn = 2e5 + 5;
const long long INF = 8e18;
typedef long long ll;
#define for0(i,n) for(int i = 0;i < n;i++)
#define for1(i,n) for(int i = 1;i <= n;i++)


int main()
{
    int x;
    cin >> x;
    if(x >= 400 && x <= 599 )
        cout << 8 << endl;
    else if(x >= 600 && x <= 799 )
        cout << 7 << endl;
    else if(x >= 800 && x <= 999 )
        cout << 6 << endl;
    else if(x >= 1000 && x <= 1199 )
        cout << 5 << endl;
    else if(x >= 1200 && x <= 1399 )
        cout << 4 << endl;
    else if(x >= 1400 && x <= 1599 )
        cout << 3 << endl;
    else if(x >= 1600 && x <= 1799 )
        cout << 2 << endl;
    else if(x >= 1800 && x <= 1999 )
        cout << 1 << endl;
    return 0;
}


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

void CHECK_NUM(int, int);
void INCLUDE3(int, int, int);
void END_CHECK_NUM(int, int);

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

	CHECK_NUM(n, 1);

	return 0;
}

void CHECK_NUM(int n, int i)
{
	int x = i;
	if (x % 3 == 0) {
		cout << " " << i;
		END_CHECK_NUM(n, i);
	}
	INCLUDE3(x, i,n);
}

void INCLUDE3(int x, int i,int n)
{
	if (x % 10 == 3) {
		cout << " " << i;
		END_CHECK_NUM(n, i);
	}
	x /= 10;
	if (x) {
		INCLUDE3(x, i, n);
	}

	END_CHECK_NUM(n, i);
}

void END_CHECK_NUM(int n, int i)
{
	if (++i <= n) {//入力よりiが小さいなら
		CHECK_NUM(n, i);
	}
	cout << endl;

	exit(0);//プログラムを正常終了	
}


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

#define pi 3.14159265358979323846
#define ll long long
#define N 100001


int main()
{
    int n,m,sum=0;
    int a[N];
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>n)cout<<"-1"<<endl;
    else cout<<n-sum<<endl;


}




Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] input = new int[N];
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextInt();
		}
		double sum = 0;
		for (int j = 0; j < K; j++) {
			sum += input[j] * 0.5 + 0.5;
		}
		double max = sum;
		for (int i = 1; i < N - K + 1; i++) {
			sum -= input[i - 1]* 0.5 + 0.5;
			sum += input[i + K - 1]* 0.5 + 0.5;
			if (sum > max) {
				max = sum;
			}
		}
		System.out.print(max);
	}
}

Measured memory_bytes: 65600
#include <stdio.h>

int main(void) {
    char s[10];
    scanf("%s", s);
    if(s[0] == 'S') {
        printf("Cloudy\n");
    } else if(s[0] == 'C') {
        printf("Rainy\n");
    } else {
        printf("Sunny\n");
    }
    return 0;
}


Measured memory_bytes: 128
<?php
$stdins = array();
while ( !feof(STDIN) ) {
    $stdin = trim(fgets(STDIN));
    if(empty($stdin)){
        break;
    }
    $stdins[] = $stdin;
}

$lengthSequence = $stdins[0];
$primeCount = 0;

for ($i=1; $i<=$lengthSequence; $i++) {
    if(CheckPrimeNumber($stdins[$i])==1){
        $primeCount++;
    }
}
echo $primeCount."\n";


function CheckPrimeNumber($number){
    if($number<=1){
        return 1;
    }
    if(2==$number || 3==$number){
        return 1;
    }
    if(0==$number%2){
        return 0;
    }
    $square_root = (int)sqrt($number);
    for($k=3; $k<=$square_root; $k+=2){
        if(0==$number%$k){
            return 0;
        }
    }
    return 1;
}



Measured memory_bytes: 10976
#include<cstdio>
#include<cstring>
#include<iostream>

#define ll long long
using namespace std;

int n,a,b,c,d;
int main()
{
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	
	b-=a;
	for (int x=0;x<=n-1;x++){
		ll L=x*1ll*c-(n-1-x)*1ll*d;
		ll R=x*1ll*d-(n-1-x)*1ll*c;
		if (L<=b&&b<=R) {puts("YES");return(0);}
		
	}
	puts("NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n];
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] * 4 * m >= sum)
            res++;
    }
    if (res < m)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
/*#include<bits/stdc++.h>
inline int read() {
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-')
			w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}
inline void write(int x) {
	if(x<0) {
		putchar('-');
		x=-x;
	}
	if(x>9)
		write(x/10);
	putchar(x%10+'0');
	return ;
}
main() {

}
*/
#include<bits/stdc++.h>
#define zhudeyu1478932871 main() {std::string s;std::cin>>s;std::cout<<s[0]<<s.size()-2<<s[s.size()-1]<<"\n";}
//	       o
//  	/\/\/
//  	 /
// 	   \/\
//  	 |
//
//
//	¤È
//	¤¤
//	¤¦
//
//
//
//            o
//		   \_|__|
//           \    /
//           _\__/
//           \ 
//           \
*/

zhudeyu1478932871

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long num = Long.parseLong(scanner.nextLine());
        long total = 0;
        for (long i = 1; i <= num; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                total += i;
            }
        }
        System.out.println(total);
    }
}

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

int counting(int N) {
  ll cnt = 0;
  for (int i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      cnt++;
      if (N / i != i)
        cnt++;
    }
  }
  return cnt;
}

int main(void) {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i, n) { ans += counting(n - i); }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
    long long int a[200000],mi=100000000000,n,sum1=0,sum2=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum1+=a[i];
    }
    for(int i=n-1;i>0;i--)
    {
        sum1-=a[i];
        sum2+=a[i];
        if(abs(sum1-sum2)<mi)
        {
            mi=abs(sum1-sum2);
        }
    }
    cout<<mi<<endl;

}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n, m, u, v, w;
  cin >> n >> m;
  vector<vector<pair<int,int>>> g(n);
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> w;
    u--; v--;
    g[u].emplace_back(v, w);
    g[v].emplace_back(u, w);
  }

  vector<long long> val(n);
  vector<long long> sign(n);
  vector<bool> visit(n);
  set<int> shift;
  val[0] = 1;
  sign[0] = 1;
  bool ok = true;

  function<void(int)> dfs = [&](int u) {
    visit[u] = true;
    int v, w, s;
    long long d;
    for (auto e : g[u]) {
      tie(v, w) = e;
      if (visit[v]) {
        s = sign[u] + sign[v];
        d = w - (val[u] + val[v]);
        if (s == 0) {
          ok &= (d == 0);
        } else if (s == 2) {
          ok &= (d % 2 == 0);
          shift.insert(d / 2);
        } else {
          ok &= (d % 2 == 0);
          shift.insert(-d / 2);
        }
      } else {
        val[v] = w - val[u];
        sign[v] = sign[u] * -1;
        dfs(v);
      }
    }
  };

  dfs(0);
  if (!ok || shift.size() > 1) {
    cout << 0 << '\n';
    return 0;
  }
  if (shift.size() == 1) {
    long long must = *shift.begin();
    for (int i = 0; i < n; i++) {
      if (sign[i] == 1) {
        val[i] += must;
      } else {
        val[i] -= must;
      }
      if (val[i] <= 0) {
        cout << 0 << '\n';
        return 0;
      }
    }
    cout << 1 << '\n';
    return 0;
  }

  long long low = 0, high = 5e16;
  for (int i = 0; i < n; i++) {
    if (sign[i] == 1) {
      low = max(low, -val[i] + 1);
    } else {
      high = min(high, val[i] - 1);
    }
  }
  cout << max(0LL, high - low + 1) << '\n';

  return 0;
}


Measured memory_bytes: 16244
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000LL;
const int MAX=100001;
const double EPS=1e-10;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}


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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200000 + 5;

int n, m, k;
ll a[N], b[N];

int ok(ll amt) {
	ll tot = 0;
	REP(i, 1, n+1) {
		if(a[i] > k) break;
		int lo = upper_bound(b+1, b+m+1, k - a[i]) - b;
		if(lo > m) --lo;
		if(b[lo] > k - a[i]) --lo;
		chkmax(tot, (ll)(lo + i));  
	}
	REP(i, 1, m+1) {
		if(b[i] > k) break;
		int lo = upper_bound(a+1, a+n+1, k - b[i]) - a;
		if(lo > n) --lo;
		if(a[lo] > k - b[i]) --lo;
		chkmax(tot, (ll)(lo + i));  	
	}
	return tot >= amt;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> k;
    REP(i, 1, n+1) {
    	cin >> a[i];
    	a[i] += a[i-1];
    }
    REP(i, 1, m+1) {
    	cin >> b[i];
    	b[i] += b[i-1];
    }
    ll lo = 0, hi = 2*(n+m);
    while(lo != hi) {
    	ll mid = (lo + hi + 1)/2;
    	if(ok(mid))
    		lo = mid;
    	else
    		hi = mid-1;
    }
    cout << lo << "\n";
    return 0;
}



Measured memory_bytes: 6728
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val (a, p) = (s.nextInt, s.nextInt)
    ((a * 3 + p) / 2).toString
  }

  val tests = List(
    """1 3""".stripMargin -> """3""",
    """0 1""".stripMargin -> """0""",
    """32 21""".stripMargin -> """58"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

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

int n;
string s;
vector<char> v;

bool dfs(int idx){
    if(idx == n-1){
        if(s[idx] == 'o' ){
            if((v[idx] == 'W' && v[idx-1] == 'W') || (v[idx] == 'S' && v[idx-1] == 'S')){
                if(v[0] == 'S') {
                    return dfs(idx+1);
                }
                else return false;
            }
            else {
                if(v[0] == 'S') return false;
                else {
                    return dfs(idx+1);
                }
            }
        }
        else {
            if((v[idx] == 'W' && v[idx-1] == 'W') || (v[idx] == 'S' && v[idx-1] == 'S')){
                if(v[0] == 'S') return false;
                else {
                    return dfs(idx+1);
                }
            }
            else {
                if(v[0] == 'S') {
                    return dfs(idx+1);
                }
                else return false;
            }
        }
    }
    else if(idx == n){
        if(s[0] == 'o'){
            if(v[0] == 'S' && v[idx-1] == v[1] || v[0] == 'W' && v[idx-1] != v[1]){
                return true;
            }
            else return false;
        }
        else{
            if(v[0] == 'S' && v[idx-1] == v[1] || v[0] == 'W' && v[idx-1] != v[1]){
                return false;
            }
            else return true;
        }
    }
    else{
        if(s[idx] == 'o'){
            if((v[idx] == 'W' && v[idx-1] == 'W') || (v[idx] == 'S' && v[idx-1] == 'S')){
                v.push_back('S');
            }
            else v.push_back('W');
            return dfs(idx+1);
        }
        else{
            if((v[idx] == 'W' && v[idx-1] == 'W') || (v[idx] == 'S' && v[idx-1] == 'S')){
                v.push_back('W');
            }
            else v.push_back('S');
            return dfs(idx+1);
        }
    }
}
 
int main(void){
    cin>>n;
    cin>>s;
    vector<char> kouho[4];
    kouho[0] = {'S', 'S'};
    kouho[1] = {'S', 'W'};
    kouho[2] = {'W', 'S'};
    kouho[3] = {'W', 'W'};
    rep(i, 4){
        v = kouho[i];
        if(dfs(1)){
            rep(i, v.size()) cout<<v[i];
            cout<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 5376
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define MAX_DWORD				(0xFFFFFFFF)
#define	MAX_SDWORD				((SDWORD)0x7FFFFFFF)
#define	MIN_SDWORD				((SDWORD)0x80000000)
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846

typedef long					SDWORD;
typedef long long				SQWORD;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef long long ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
#define N_MAX	(200 * 1000)
#define K_MAX	(10)
#define M_MAX	(10)
#define Q_MAX	(10)
#define H_MAX	(1000)
#define W_MAX	(1000)

class UnionFind 
{
private:
	vector<int> par, rank, sz;

public:
	// コンストラクタ
	UnionFind(int n) 
	{
		par.resize(n);
		rank.resize(n, 0);
		sz.resize(n, 1);
		for (int i = 0; i < n; i++) {
			// 始めは全部ROOT
			par[i] = i;
		}
	}

	int root(int x) 
	{
		return par[x] == x ? x : par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	int size(int x) {
		return sz[root(x)];
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) {
			par[x] = y;
			sz[y] += sz[x];
		} else {
			par[y] = x;
			sz[x] += sz[y];
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
};


int main()
{
	ll N, M;
	cin >> N >> M;
	vector<int> a(M), b(M);
	REP(i, M) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}

	UnionFind uTree(N);
	vector<ll> ans(M, 0);
	ans[M - 1] = N * (N - 1) / 2;
	for (int i = M - 1; i >= 1; i--) {
		if (uTree.same(a[i], b[i])) {
			ans[i - 1] = ans[i];
		} else {
			ll	temp1 = uTree.size(a[i]);
			ll	temp2 = uTree.size(b[i]);
			ans[i - 1] = ans[i] - temp1 * temp2;
		}
		uTree.unite(a[i], b[i]);
	}

	REP(i, M) {
		cout << ans[i] << endl;
	}
	return 0;
}


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

int main(){
    int N, odd_count = 0;
    cin >> N;
    int A[100000];
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i] % 2 != 0)
            odd_count++;
    }
    if(odd_count % 2 != 0)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{

    public static String process(TestCase testCase) {
        final int A = testCase.A;
        final int B = testCase.B;
        final int C = testCase.C;
        
        return String.valueOf(Math.min(C, B / A));
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        return new TestCase(A, B, C);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int A;
        final int B;
        final int C;

        public TestCase(int A, int B, int C) {
            this.A = A;
            this.B = B;
            this.C = C;
        }
    }
}


Measured memory_bytes: 22100
// Oh damn, cann't you see I'm fine?

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'

const int max_n = 2e3 + 5;
const int M = 1e9 + 7;

int dp[max_n];

int memo(int s) {
	if(s == 0) return 1;
	if(s < 3) return 0;
	if(dp[s] != -1) return dp[s];
	int res = 0;
	for(int i=3; i<=s; i++) {
		(res += memo(s - i)) %= M;
	}
	return dp[s] = res;
}

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

	int s;
	cin >> s;
	memset(dp, -1, sizeof dp);
	cout << memo(s) << endl;

	return 0;
}

Measured memory_bytes: 3632
import numpy as np

n = int(input())
A = list(map(int,input().split()))

cnt = np.sum(np.where(np.array(A) < 0, True, False))

#print(cnt)

A = list(map(lambda x:abs(x), A))


if cnt%2 == 0:
    print(sum(A))
else:
    print(sum(A)-2*min(A))

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

int main()
{
  i64 n, d, a;
  cin >> n >> d >> a;
  vector<pair<i64, i64>> mob(n);
  for (i64 i = 0; i < n; i++)
    cin >> mob[i].first >> mob[i].second;
  sort(mob.begin(), mob.end());
  vector<i64> cnt(n);
  i64 ans = 0, at = 0;
  for (i64 i = 0; i < n; i++)
  {
    at -= cnt[i];
    mob[i].second -= at * a;
    i64 tmp = (max(0LL, mob[i].second) + a - 1) / a;
    at += tmp;
    ans += tmp;
    i64 it = upper_bound(mob.begin(), mob.end(), make_pair(mob[i].first + 2 * d, (i64)1e9)) - mob.begin();
    if (it < n)
      cnt[it] += tmp;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(k >= s.length())cout << s << endl;
    else {
        s.resize(k);
        cout << s << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int n,m;
	cin>>n>>m;
	int x[n+1],y[m+1];
	cin>>x[0]>>y[0];
	rep(i,n)cin>>x[i+1];
	rep(i,m)cin>>y[i+1];
	sort(x,x+n+1);
	sort(y,y+m+1);

	if(x[n]<y[0])cout<<"No War"<<endl;
	else cout<<"War"<<endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
for i in range(N):
    if A[i] < B[i]:
        ans += A[i]
        m = min(A[i+1], B[i] - A[i])
        ans += m
        A[i+1] -= m
    else:
        ans += B[i]
print(ans)

Measured memory_bytes: 19116
#include<iostream>
 
using namespace std;
int main(){
  int N=0;
  int X=0;
  int L[100]={0};
  int ans=0;
  int s=0;
  cin>>N>>X;
  for(int i=0;i<N;i++){
    cin>>L[i];
    s+=L[i];
    if(s<=X){
      ans++;
    }
  }
  cout<<ans+1;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }
 
#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
 
// constexpr int MOD = 1e9+7;
 
int main(void){
    Cin(ll, a);
    Cin(double, b);
    Cout(a * (ll)round(100*b) / 100);
}

Measured memory_bytes: 3776
#include <stdio.h>

int main(void)
{
	int n;
	int i, j, k, l;
	int sq[24][24];
	
	while (scanf("%d", &n), n != 0){
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				sq[i][j] = 0;
			}
		}
		i = n / 2 + 1;
		j = n / 2;
		for (k = 1; k < n * n; k++){
			sq[i][j] = k;
			if (i + 1 >= n){
				i = 0;
			}
			else {
				i++;
			}
			if (j + 1 >= n){
				j = 0;
			}
			else {
				j++;
			}
			
			while (sq[i][j] > 0){
				if (j - 1 < 0){
					j = n - 1;
				}
				else {
						j--;
				}
				if (i + 1 >= n){
					i = 0;
				}
				else {
						i++;
				}
			}
		}
		sq[i][j] = k;
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				printf("%4d", sq[i][j]);
			}
			printf("\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 1044
n,ma,mb=map(int,input().split())
abc=[list(map(int,input().split())) for _ in range(n)]
import numpy as np
dp=np.full((401,401),4001,int)
dp[0,0]=0
for a,b,c in abc:
  dp[a:,b:]=np.minimum(dp[a:,b:],dp[:-a,:-b]+c)
ma_,mb_=ma,mb
ans=4001
while max(ma_,mb_)<401:
  ans=min(ans,dp[ma_,mb_])
  ma_+=ma
  mb_+=mb
print(ans if ans<4001 else -1)


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

int main() {
  uint64_t N;
  string S;
  cin >> N;
  cin >> S;
  
  uint64_t left_count = 0;
  uint64_t right_count = 0;
  
  for (uint64_t i = 1; i < N; i++) {
    if (S.at(i) == 'E') {
      right_count++;
    }
  }
  uint64_t min_count = right_count;
  
  for (uint64_t i = 1; i < N; i++) {
    uint64_t count = 0;
    if (S.at(i) == 'E') {
      right_count--;
    }
    if (S.at(i - 1) == 'W') {
      left_count++;
    }
    count = left_count + right_count;
    if (count < min_count) {
      min_count = count;
    }
  }
  cout << min_count << endl;
}

Measured memory_bytes: 900
N, M = list(map(int, input().split()))
L, R = [None] * M, [None] * M
for i in range(M):
    L[i], R[i] = list(map(int, input().split()))

l = max(L)
r = min(R)
ans = r - l + 1
if ans < 0:
    ans = 0
print(ans)

Measured memory_bytes: 10996
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            int start = n;
            long res = 0;
            for (int i = n - 1; i >= 0; --i) {
                int cur = i - a[i];
                if (cur < 0 || cur > start) {
                    out.println(-1);
                    return;
                }
                if (cur != start) {
                    res += a[i];
                    start = cur;
                }
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 47524
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,m,n,d,maxa;
	cin>>a>>b;
	m=a+b;
	n=a-b;
	d=a*b;
	maxa=max(m,n);
	maxa=max(maxa,d);
	cout<<maxa;
} 

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

int main(){
  int A, B, N1=0, N2=0, S=0;
  cin >> A >> B;
  for (int i = 0; i < B-A+1; i++){
    N1 = A + i;
    N2 = (N1 % 10) * 10000 + (N1 % 100 / 10) * 1000 + 
      (N1 % 1000 / 100) * 100 + (N1 % 10000 / 1000) * 10 + (N1 / 10000);
    if (N1 == N2){
      S++;
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 256