akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> li = new ArrayList<Integer>();
        for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        }
        int zero = 0;
        ArrayList<Integer> ans = new ArrayList<Integer>();
        while(li.size() != 0){
            int right = -1;
            for(int i = 0; i < li.size(); i++){
                if(li.get(i) == i+1){
                    right = i;
                }
            }
            if(right == -1){
                System.out.println(-1);
                return;
            }else{
                ans.add(li.get(right));
                li.remove(right);
            }
        }
        for(int i = n-1; i >= 0; i--){
            System.out.println(ans.get(i));
        }
    }
}

Measured memory_bytes: 22996
s=input()
t=input()

a="abcdefghijklmnopqrstuvwxyz"
rs=dict()
rt=dict()
for i in range(26):
    rs[a[i]]=-1
    rt[a[i]]=-1

yn="Yes"
for i in range(len(s)):
    if rs[s[i]]==-1:
        rs[s[i]]=t[i]
    else:
        if rs[s[i]]!=t[i]:
            yn="No"
            break
    if rt[t[i]]==-1:
        rt[t[i]]=s[i]
    else:
        if rt[t[i]]!=s[i]:
            yn="No"
            break       
print(yn)


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;

int a[maxn];

int main()
{
	int n, m, k, t;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> k;
		while(k--) {
			cin >> t;
			a[t]++;
		}
	}
	int ans = 0;
	for(int i = 0; i < maxn; i++) {
		if(a[i] == n) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;
	long[] x, y;
	void calc() {
		sc = new Scanner(System.in);
		int N = sc.nextInt();
		x = new long[N];
		y = new long[N];
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		double sum = 0d;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (i == j) continue;
				long dx = x[i]-x[j];
				long dy = y[i]-y[j];
				sum += Math.sqrt(dx*dx+dy*dy);
			}
		}
		System.out.println(sum/N);
	}

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

Measured memory_bytes: 24532
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;

const string n = "0123456789";

int main() {

	string c;

	bool a = false, b = false;

	cin >> c;

	
	int g;
	g = n.find(c[0]) * 10 + n.find(c[1]);
	if (g <= 12 && g != 0) a = true;
	g = n.find(c[2]) * 10 + n.find(c[3]);
	if (g <= 12 && g != 0) b = true;

	if (a && b) cout << "AMBIGUOUS" << endl;
	else if (a) cout << "MMYY" << endl;
	else if (b) cout << "YYMM" << endl;
	else  cout << "NA" << endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<int>		vll;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 3e5+5, OO = 0x3f3f3f3f;
int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class AAdditionAndSubtractionEasy {
public:
	void solve(std::istream& in, std::ostream& out) {
        int a, b; char c;
        in >> a >> c >> b;
        if (c == '-') out << a - b << el;
        else out << a + b << el;
	}
};


int main() {
	AAdditionAndSubtractionEasy solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n, k;
    cin >> n >> k;
    vll p(n), c(n);
    rep(i, n) cin >> p[i];
    rep(i, n) p[i]--;
    rep(i, n) cin >> c[i];
    vint vis(n);
    int loopId = 1;
    vvll g;
    rep(i, n)
    {
        if (vis[i])
            continue;
        vll now = vll();
        int j = p[i];
        now.emplace_back(c[i]);
        while (j != i)
        {
            vis[j] = loopId;
            now.emplace_back(c[j]);
            j = p[j];
        }
        g.emplace_back(now);
        loopId++;
    }

    ll ans = INT64_MIN;
    for (vll now : g)
    {
        int m = now.size();
        ll loopScore = 0;
        rep(i, m)
        {
            loopScore += now[i];
        }
        ll maxScore = INT64_MIN;
        rep(i, m)
        {
            int j = i;
            ll sc = 0;
            rep(l, min(m, k))
            {
                j = (i + l) % m;
                sc += now[j];
                ll loops = ((k - l - 1) / m);
                ll nowScore = loopScore * loops + sc;
                // printf("%d %d %d %d %d %d\n", loopScore * loops, k - l - 1, m, loopScore, sc, nowScore);
                nowScore = max(nowScore, sc);
                maxScore = max(nowScore, maxScore);
            }
        }

        ans = max(ans, maxScore);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3824
function Main(input) {
  input = input.split("\n");
  tmp1 = input[0].split(" ");
  tmp2 = input[1].split(" ");
  tmp3 = input[2].split(" ");
  c = new Array(3);
  c1= new Array(3).fill(0);
  c2= new Array(3).fill(0);
  c3= new Array(3).fill(0); 
  for(i=0;i<3;i++){
    c1[i]=parseInt(tmp1[i]);
    c2[i]=parseInt(tmp2[i]);
    c3[i]=parseInt(tmp3[i]);
  }
  c[0]=c1;
  c[1]=c2;
  c[2]=c3;
  var ans="No";
  if(c[2][2]-c[1][2]==c[2][1]-c[1][1]&&c[2][1]-c[1][1]==c[2][0]-c[1][0]&&
  c[1][2]-c[0][2]==c[1][1]-c[0][1]&&c[1][1]-c[0][1]==c[1][0]-c[0][0]&&
  c[0][2]-c[0][1]==c[1][2]-c[1][1]&&c[1][2]-c[1][1]==c[2][2]-c[2][1]&&
  c[0][1]-c[0][0]==c[1][1]-c[1][0]&&c[1][1]-c[1][0]==c[2][1]-c[2][0]){
    var ans="Yes";
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.util.*;
import java.io.*;

public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);

	   int s=sc.nextInt();

	   int dp[]=new int[3003];
	    dp[0]=0;
	    dp[1]=0;;
	    dp[2]=0;
	    dp[3]=1;
	    for(int i=4;i<=s;i++) {
	      dp[i]=dp[i-1]+dp[i-3];
	      dp[i]%=mod;
	    }
System.out.println((dp[s]+mod)%mod);
	}
static long nos(int dp[][],int a[],int n,int s) {
  if(n==0) {
    return 0;
  }
  if(s==0) {
    return 1;
  }
  if(a[n-1]>=3&&a[n-1]<=s) {

   return nos(dp,a,n,s-a[n-1])+nos(dp,a,n-1,s);
  }else {
    return nos(dp,a,n-1,s);
  }
}

	static boolean vis[]=new boolean[10001];
	      static long gcd(long a, long b) 
	      { 
	          if (a == 0) 
	              return b; 
	          return gcd(b % a, a); 
	      } 

static long nCr(int n,int r) {
  int dp[][]=new int[2001][2001];
  for(int i=0;i<2001;i++) {
    dp[0][i]=0;
  }
  for(int i=0;i<2001;i++) {
    dp[i][0]=1;
  }
  for(int i=1;i<2001;i++) {
    for(int j=1;j<2001;j++) {
      if(i==j) {
        dp[i][j]=1;
      }else {
        dp[i][j]=dp[i-1][j-1]+dp[i][j-1];
      }
    }
  }
  return dp[n][r];
}
//	     
//	      
}

Measured memory_bytes: 36060
def a():
  a = list(map(int,input().split()))
  max1 = max(a[0], a[1])
  min1 = min(a[0], a[1])
  max2 = max(a[2], a[3])
  min2 = min(a[2], a[3])
  result = [max1 * max2, max1 * min2, min1 * max2, min1 * min2]
  return max(result)

print(a())

Measured memory_bytes: 9132
package main

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

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func loadints(n int) []int {
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		xs[i] = loadint()
	}
	return xs
}

func maxints(xs []int) (result int) {
	result = xs[0]
	for _, x := range xs[1:] {
		if result < x {
			result = x
		}
	}
	return
}

func minints(xs []int) (result int) {
	result = xs[0]
	for _, x := range xs[1:] {
		if result > x {
			result = x
		}
	}
	return
}

func main() {
	n := loadint()
	m := loadint()
	x := loadint()
	y := loadint()
	xs := loadints(n)
	ys := loadints(m)
	xs = append(xs, x)
	ys = append(ys, y)
	if maxints(xs) >= minints(ys) {
		fmt.Print("War")
	} else {
		fmt.Print("No War")
	}
}


Measured memory_bytes: 640
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    a = [0] * 1000005
    A_max = A[-1]

    for i in A:
        for j in range(1, A_max//i + 1):
            a[i * j] += 1

    ans = 0
    for i in A:
        if a[i] == 1:
            ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 32132
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string s; cin >> s;
    int n = s.size();
    rep(i,n){
        if(s[i] == 'R' && i % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
        if(s[i] == 'L' && i % 2 == 0){ 
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in a:
    if i < 0:
        cnt += 1
a = [abs(x) for x in a]
if cnt % 2 == 0:
    print(sum(a))
else:
    print(sum(a)-min(a)*2)

Measured memory_bytes: 14412
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF 1e+18
#define MAX_V 100100
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Graph Start
struct edge {
    int from, to;
    long long cost;
};
/// Graph End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(n, m);
    vector<int> x(m), sub(m - 1);
    rep(i, m) cin >> x[i];
    sort(All(x));
    rep(i, m - 1){ sub[i] = x[i + 1] - x[i]; }
    int sum = 0;
    sort(All(sub),greater<int>());
    rep(i,m-1){
        if(i<n-1) continue;
        sum += sub[i];
    }
    cout << sum << nn;

    return 0;
}

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

class Dice
{
public:
    int f[6];
    Dice(){}
    void roll_z(){ roll(1, 2, 4, 3); }
    void roll_y(){ roll(0, 2, 5, 3); }
    void roll_x(){ roll(0, 1, 5, 4); }
    void roll(int i, int j, int k, int l){
        int t = f[i];
        f[i] = f[j];
        f[j] = f[k];
        f[k] = f[l];
        f[l] = t;
    }
    void move(char ch){
        if (ch == 'E') for (int i = 0; i < 3; i++) roll_y();
        if (ch == 'W') roll_y();
        if (ch == 'N') roll_x();
        if (ch == 'S') for (int i = 0; i < 3; i++) roll_x();
    }
    int equals(Dice other){
        int result = 0;
        for (int i = 0; i < 6; i++)
        {
            if (f[i] != other.f[i]){
                result++;
            } 
        }
        return result;
    }
};

int main()
{
    Dice dice1, dice2;
    for (int i = 0; i < 6; i++)
        cin >> dice1.f[i];
    for (int i = 0; i < 6; i++)
        cin >> dice2.f[i];
    int dis = dice1.equals(dice2);
    for (int i = 0; i < 4; i++)
    {
        if (dice1.equals(dice2) < dis)
        {
            break;
        }
        dice2.roll_x();
    }
    dis = dice1.equals(dice2);
    for (int i = 0; i < 4; i++)
    {
        if (dice1.equals(dice2) < dis)
        {
            break;
        }
        dice2.roll_y();
    }
    dis = dice1.equals(dice2);
    for (int i = 0; i < 4; i++)
    {
        if (dice1.equals(dice2) < dis)
        {
            break;
        }
        dice2.roll_z();
    }
    if (dice1.equals(dice2) == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    int N, M;
    cin >> N >> M;
    int A[10000];
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }

    int sum = 0;

    for (int i = 0; i < M; i++) {
        sum += A[i];
    }

    if (sum > N) cout << -1;
    else cout << N - sum;

    return 0;
}


Measured memory_bytes: 3676
#include <stdio.h>

int n, A[20];

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

int main(void)
{
	int q, M, 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", &M);
		if (solve(0, M))	printf("yes\n");
		else printf("no\n");
	}
}


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int cnt = 0;

		while(n > 0) {
			int x = n % 10;
			if (x == 1) {
				cnt++;
			}
			n /= 10;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21844
/*
Segment Tree
セグ木
セグメントツリー
*/
#include<bits/stdc++.h>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define INF 1000000000

struct SegmentTree {
private:
  int n;
  vector<long> node;
public:
  SegmentTree(vector<long long> v){
    int sz = v.size();
    n = 1;
    while(n<sz) n *= 2;
    node.resize(2*n-1,INF);
    for(int i=0; i<sz; i++) node[i+n-1] = v[i];
    for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
  }

  void update(int x, long long val){
    x += (n-1);
    node[x] = val;
    while(x>0){
      x = (x-1)/2;
      node[x] = min(node[2*x+1],node[2*x+2]);
    }
  }

  long long getmin(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    if(r<=a||b<=l) return INF;
    if(a<=l&&r<=b) return node[k];
    long long vl = getmin(a,b,2*k+1,l,(l+r)/2);
    long long vr = getmin(a,b,2*k+2,(l+r)/2,r);
    return min(vl,vr);
  }
};


signed main(){

  int n;
  cin >> n;
  vector<int> s(n),ind(n);
  rep(i,n)cin >> s[i];
  rep(i,n)ind[s[i]-1]=i;
  SegmentTree st(vector<long long>(n,0));
  rep(i,n){
    int index = ind[i];
    st.update(index,min(st.getmin(0,index)-i-1,(long long)(-i-1)));
  }
  cout << n*(n+1)/2+st.getmin(0,n) << endl;

  return 0;
}



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

int main(){
    int W=0, H=0, x=0, y=0, r=0;
    cin >> W >> H >> x >> y >> r;
    cout << ((x+r<=W)&&(y+r<=H)&&(x-r>=0)&&(y-r>=0)?"Yes":"No") << endl;
}


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

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=500001;
P a[maxn],b[maxn];
vector<ll> divisor(ll x){
  vector<ll> res;
  for(ll i=1LL;i*i<=x;i++){
    if(x%i==0){
      res.push_back(i);
      if(i!=x/i)res.push_back(x/i);
    }
  }
  return res;
}

int main(){
  ll n;
  cin>>n;
  ll s1=1LL,s2=1LL;
  for(int i=0;i<n;i++){
    ll tmp1,tmp2;
    cin>>tmp1>>tmp2;
    ll nn=max((tmp1+s1-1)/tmp1,(tmp2+s2-1)/tmp2);
    s1=nn*tmp1;
    s2=nn*tmp2;
  }
  cout<<s1+s2<<endl;
}


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

int main () {
  int A, B, X;
  cin >> A >> B >> X;
  
  if (A + B + 1 > X && X > A - 1)  {
    
    cout << "YES" << endl;
  }
  
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
x, y = map(int, input().split())
if (x + y)%3 != 0:
    print(0)
else:
    k = (x + y)//3
    if k <= x <= 2*k:
        MOD = 10**9 + 7
        fac = [0]*(k + 1)
        finv = [0]*(k + 1)
        inv = [0]*(k + 1)
        fac[0] = 1; fac[1] = 1; finv[0] =1; finv[1] = 1; inv[1] = 1
        for i in range(2, k + 1):
            fac[i] = fac[i - 1] * i % MOD
            inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
            finv[i] = finv[i - 1] * inv[i] % MOD
        
        i = x - k
        print(fac[k] * (finv[i] * finv[k - i] % MOD) % MOD)
    else:
        print(0)

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main() {
    ll a;cin>>a;
    string s;cin>>s;
    if(a>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())

    hon = [2,4,5,7,9]
    pon = [0,1,6,8]
    bon = [3]

    if N%10 in hon:
        res = 'hon'
    elif N%10 in pon:
        res = 'pon'
    else:
        res = 'bon'

    print(res)



main()


Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    int i = a * x + b * y;
    int ii = c * 2 * Math.max(x, y);
    int iii = 0;
    if (x > y) {
      iii = c * 2 * Math.min(x, y) + a * (x - y);
    } else {
      iii = c * 2 * Math.min(x, y) + b * (y - x);
    }
    System.out.println(Math.min(Math.min(i, ii), iii));
  }
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vec a(N);
    rep(i, N){
        int p; cin >> p;
        a[p-1] = i;
    }
    int cnt = 1;
    int res = 1;
    rep(i, N-1){
        if(a[i] < a[i+1]){
            cnt++;
        }else{
            cnt = 1;
        }
        res = max(res, cnt);
    }
    cout << N-res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <unordered_map>
#include <iterator>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int N;
unordered_map<string,int> S;

int main(){
    ll ans=0;

    cin>>N;
    rep(i,N){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        S[s]++;
        ans+=S[s]-1;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 10660
import fractions


if __name__ == "__main__":
    K = int(input())

    d = {}

    result = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            gcd_ab = fractions.gcd(i, j)
            if gcd_ab not in d:
                d[gcd_ab] = 0
            d[gcd_ab] += 1

    for gcd_ab, count in d.items():
        for k in range(1, K+1):
            result = result + fractions.gcd(gcd_ab, k) * count

    print(result)


Measured memory_bytes: 10668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	string s,d1,d2,e1,e2;
	cin>>s;
	d1="dream";d2="dreamer";e1="erase";e2="eraser";
	bool flag=true;
	for(int i=0;i<s.size();i++){
		if(s.compare(i,e2.size(),e2)==0){
			i+=5;
			continue;
		}
		if(s.compare(i,e1.size(),e1)==0){
			i+=4;
			continue;
		}
		if(s.compare(i,d1.size(),d1)==0){
			i+=5;
			if(s.compare(i,2,"er")==0&&s.compare(i,3,"era")!=0){
				i+=2;
			}
			i--;
			continue;
		}
		flag=false;
		break;
	}
	cout << (flag ?"YES":"NO");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

vector<int> convert(string);
void dfs(vector<int>,long long*,int*,int,int);

int main()
{
    string s;cin>>s;
    vector<int> S; S = convert(s);
    int n = S.size();
    int *A; A=new int[n-1];

    long long ans[1]={0};
    dfs(S,ans,A,n,0);

    cout << *ans << endl;


    return 0;
}



vector<int> convert(string s)
{
    int n = s.size();
    vector<int> S;
    for(int i=0;i<n;i++){
        if(s[i]=='0'){
            S.push_back(0);
        }else if(s[i]=='1'){
            S.push_back(1);
        }else if(s[i]=='2'){
            S.push_back(2);
        }else if(s[i]=='3'){
            S.push_back(3);
        }else if(s[i]=='4'){
            S.push_back(4);
        }else if(s[i]=='5'){
            S.push_back(5);
        }else if(s[i]=='6'){
            S.push_back(6);
        }else if(s[i]=='7'){
            S.push_back(7);
        }else if(s[i]=='8'){
            S.push_back(8);
        }else if(s[i]=='9'){
            S.push_back(9);
        }
    }
    return S;
}

void dfs(vector<int> S, long long *ans, int *A, int n, int i)
{
    if(i==n-1){
        int prev=0;
        for(int j=0;j<n-1;j++){
            if(A[j]==1){
                for(int k=prev;k<=j;k++){
                    *ans += S[k]*pow(10,j-k);
                }
                prev=j+1;
            }
        }
        for(int k=prev;k<=n-1;k++){
            *ans += S[k]*pow(10,n-1-k);
        }
        return;
    }
    A[i]=0;
    dfs(S,ans,A,n,i+1);

    A[i]=1;
    dfs(S,ans,A,n,i+1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
		//#ifndef ONLINE_JUDGE
		//	freopen("input", "r", stdin);
			//freopen("output","w",stdout);
	//#endif

	int n;	cin>>n;
	vector<int> v(n+1), dp(n+1,0);

	for(int i=1;i<=n;++i)	cin>>v[i]; 
  
	dp[2] = abs(v[1] - v[2]);

	for(int i=3;i<=n;++i)
		dp[i] = min(dp[i-1] + abs(v[i] - v[i-1]), dp[i-2] + abs(v[i] - v[i-2]));

	// for(auto i:dp)
	// 	cout<<i<<" ";
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 3968
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int N = cin.NextInt();
            int ans = 1;
            int x = 2;
            while (x <= N)
            {
                if (ans < x) ans = x;
                x *= 2;
            }

            Console.WriteLine(ans);
        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}



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

const int size = 101;
int G1[size][size]; // time
int G2[size][size]; // money

int main() {
  int n, m;
  while ( cin >> n >> m && n && m ) {
    for ( int i = 0; i < size; i++ ) {
      for ( int j = 0; j < size; j++ ) {
	G1[i][j] = -1;
	G2[i][j] = -1;
      }
    }
    for ( int i = 0; i < n; i++ ) {
      int a, b;
      cin >> a >> b;
      int t, c;
      cin >> c >> t;
      G1[a][b] = G1[b][a] = t;
      G2[a][b] = G2[b][a] = c;
    }
    for ( int k = 1; k <= m; k++ ) {
      for ( int i = 1; i <= m; i++ ) {
	for ( int j = 1; j <= m; j++ ) {
	  if ( G1[i][k] == -1 || G1[k][j] == -1 ) continue;
	  if ( G1[i][j] == -1 ) G1[i][j] = G1[i][k] + G1[k][j];
	  G1[i][j] = min( G1[i][j], G1[i][k] + G1[k][j] );
	}
      }
    }
    for ( int k = 1; k <= m; k++ ) {
      for ( int i = 1; i <= m; i++ ) {
	for ( int j = 1; j <= m; j++ ) {
	  if ( G2[i][k] == -1 || G2[k][j] == -1 ) continue;
	  if ( G2[i][j] == -1 ) G2[i][j] = G2[i][k] + G2[k][j];
	  G2[i][j] = min( G2[i][j], G2[i][k] + G2[k][j] );
	}
      }
    }
    {
      int k;
      cin >> k;
      for ( int i = 0; i < k; i++ ) {
	int p, q, r;
	cin >> p >> q >> r;
	cout << ( r ? G1[p][q] : G2[p][q] ) << endl; 
      }
    }
  }
  return 0;
}

Measured memory_bytes: 948
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int a[n];
    vector<int>v;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        v.push_back(a[i]);
    }
    map<int,int>mp;
    for(i=0;i<n;i++)
    {
        mp[v[i]]++;
    }
    int sum=0;
    for(auto u:mp)
    {
        if(u.first!=u.second&&u.first>u.second)
        {
            sum+=u.second;
        }
    }
    int sum2=0;
    for(auto u:mp)
    {
        if(u.first<u.second)
        {
            sum2+=(u.second-u.first);
        }
    }
    cout<<sum+sum2<<endl;
}


Measured memory_bytes: 8388
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>

using namespace std;

int suitToIndex(char c) {
  switch (c) {
    default:
    case 'S':
      return 0;
    case 'H':
      return 1;
    case 'C':
      return 2;
    case 'D':
      return 3;
  }
}

char suits[4] = {'S', 'H', 'C', 'D'};

int main() {
  bool found[4][13] = {};
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    char suit;
    int rank;
    cin >> suit >> rank;
    found[suitToIndex(suit)][rank - 1] = true;
  }
  for (int suitIndex = 0; suitIndex < 4; ++suitIndex) {
    for (int rank = 1; rank <= 13; ++rank) {
      if (!found[suitIndex][rank - 1]) {
        cout << suits[suitIndex] << " " << rank << endl;;
      }
    }
  }
}

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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  if ( s.back() == 's' ) std::cout << s << "es" << std::endl;
  else std::cout << s << "s" << std::endl;
  return 0;
}



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

const int N = 1e5 + 10;

int a[N];

int main(){
	int n, x, y, p, len1, len2;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
	sort(a + 1, a + n + 1, [&](int x, int y){return x > y;});
	x = y = 0;
	while (a[x + 2] > y + 1) x++, y++;
	len1 = 0; p = x;
	while (y < a[p + 2]) p++;
	len1 = p - x; len2 = a[x + 1] - y - 1;
	if (len1 % 2 == 0 && len2 % 2 == 0) printf("Second\n");
	else printf("First\n");
	return 0;
}

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

int main() {
  int N, MAX = 1e6;
  cin >> N;
  vector<int> V;
  V.push_back(1);
  for (int i = 6; i <= MAX; i *= 6) {
    V.push_back(i);
  }
  for (int i = 9; i <= MAX; i *= 9) {
    V.push_back(i);
  }
  sort(V.begin(), V.end());
  vector<int> DP(MAX + 1, 2e9);
  DP.at(0) = 0;
  for (int i = 0; i < V.size(); i++) {
    for (int j = 0; j < MAX + 1; j++) {
      if (DP.at(i) != 2e9) {
        if (j + V.at(i) < MAX + 1) {
          DP.at(j + V.at(i)) = min(DP.at(j + V.at(i)), DP.at(j) + 1);
        }
      }
    }
  }
  cout << DP.at(N) << "\n";
}

Measured memory_bytes: 7188
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int e = sc.nextInt();
			if(e == 0) break;
			int m = 1<<30;
			for(int z=0;;z++) {
				int xy = e-z*z*z;
				if(xy<0) break;
				for(int y=0;y*y<=xy;y++) {
					int x = xy-y*y;
					m = Math.min(m, x+y+z);
				}
			}
			System.out.println(m);
		}
	}
}


Measured memory_bytes: 34468
package main

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

// T - Hx * 0.006
// T A
// Hi ...

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	num, _ := strconv.Atoi(nextLine())
	ta := strings.Split(nextLine(), " ")
	t, _ := strconv.ParseFloat(ta[0], 64)
	a, _ := strconv.ParseFloat(ta[1], 64)
	h := strings.Split(nextLine(), " ")
	var n = 0
	var diff = 0.0
	for i := 0; i < num; i++ {
		h, _ := strconv.ParseFloat(h[i], 64)
		if i == 0 {
			n = 1
			tmp := t - h*0.006
			if a > tmp {
				diff = math.Abs(a - tmp)
			} else {
				diff = math.Abs(tmp - a)
			}
		} else {
			tmp := t - h*0.006
			var tmpd = 0.0
			if a > tmp {
				tmpd = math.Abs(a - tmp)
			} else {
				tmpd = math.Abs(tmp - a)
			}
			if diff > tmpd {
				n = i + 1
				diff = tmpd
			}
		}
	}
	fmt.Println(n)
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
 
#define MAX 1010
#define max(a,b) ((a<b)?b:a)
 
char s[MAX], t[MAX];
int dp[MAX][MAX],path[MAX][MAX];
 
int LCS() {
  int n = strlen(s);
  int m = strlen(t);
  memset(dp,0,sizeof dp);
  int i,j,maxi=0;
  for(i=0;i<n;i++) {
    for(j=0;j<m;j++) {
      if( i ) dp[i][j] = max(dp[i][j],dp[i-1][j]);
      if( j ) dp[i][j] = max(dp[i][j],dp[i][j-1]);
      if( s[i] == t[j] ) {
    dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
    maxi = max(maxi,dp[i+1][j+1]);
      }
    }
  }
  return maxi;
}
 
int main() {
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++) {
  scanf(" %s",&s[0]);
  scanf(" %s",&t[0]);
  printf("%d\n",LCS());
  }
  return 0;
}


Measured memory_bytes: 6732
#include <iostream>
#include <string>
#include <map>
#include <stack>
#include <algorithm>
using namespace std;
#define MAX 100000

static const int N=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n, M[N][N];
int color[N],d[N],f[N],tt;
int nt[N];

int next(int u){
  for(int v=nt[u]; v<n; v++){
    nt[u]=v+1;
    if(M[u][v]) return v;
  }
  return -1;
}

void dfs_visit(int r){
  for(int i=0;i<n;i++) nt[i]=0;
  stack<int> S;
  S.push(r);
  color[r]=GRAY;
  d[r]=++tt;
  while( !S.empty() ){
    int u=S.top();
    int v=next(u);
    if( v!=-1 ){
      if(color[v]==WHITE){
        color[v]=GRAY;
        d[v]=++tt;
        S.push(v);
      }
    }else{
        S.pop();
        color[u]=BLACK;
        f[u]=++tt;
    }
  }
}

void dfs(){
  for(int i=0;i<n;i++){
    color[i]=WHITE;
    nt[i]=0;
  }
  tt=0;

  for(int u=0;u<n;u++){
    if(color[u]==WHITE) dfs_visit(u);
  }
  for(int i=0;i<n;i++){
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
}

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

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j]=0;
    }
  }

  for(int i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j=0;j<k;j++){
      cin >> v;
      v--;
      M[u][v]=1;
    }
  }
  dfs();
  return 0;
}


Measured memory_bytes: 3108
s = list(input())

temp = s[0]
c = 1
l = []
for i in range(1, len(s)):
  if temp == s[i]:
    c += 1
  else:
    l.append((temp, c))
    temp = s[i]
    c = 1
l.append((temp, c))

n = [0]*len(s)
m = 0
for t in l:
  if t[0] == 'R':
    m += t[1]
    if t[1]%2 ==0:
      a = t[1] // 2
      n[m-1] += a
      n[m] += a
    else:
      a, b = divmod(t[1], 2)
      n[m-1] += a+b
      n[m] += t[1]-a-b
  else:
    if t[1]%2 ==0:
      a = t[1] // 2
      n[m] += a
      n[m-1] += a
    else:
      a, b = divmod(t[1], 2)
      n[m] += a+b
      n[m-1] += t[1]-a-b
    m += t[1]
d = list(map(lambda x: str(x), n))
print(' '.join(d))

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

    int H, W;
    cin >> H >> W;
    char s[H+10][W+10] = {'.'};
    REP1(i, H+1)REP1(j, W+1) cin >> s[i][j];

    REP1(i, H+1){
        REP1(j, W+1){
            if((s[i-1][j] == '.') && (s[i+1][j] == '.') && (s[i][j-1] == '.') && (s[i][j+1] == '.') & (s[i][j] == '#')){
                // cout << i << " " << j << endl;
                // cout << s[i-1][j] << s[i+1][j] << s[i][j-1] << s[i][j+1]  << endl;
                // s[i][j] = ' ';
                cout << "No" << endl;
                return 0;
            }
        }
    }
    // REP1(i, H+1){
    //     REP1(j, W+1){
    //         cout << s[i][j];
    //     }cout << endl;
    // }
    cout << "Yes" << endl;
    return 0;

    

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3620
N, M, X, Y = (int(i) for i in input().split()) 
x= [int(i) for i in input().split()] 
y= [int(i) for i in input().split()] 
x.sort()
y.sort()
z = X + 1
max_x = x[-1]
min_y = y[0]
while z<Y:
    if(max_x < z and min_y >=z):
        print('No War')
        #print(z)
        break
    else:
        z = z + 1
if (z>=Y):
    print('War')
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    const ll mod=2019;
    ll l,r;
    cin>>l>>r;
    if(r-l>mod){
        cout<<0<<endl;
        return 0;
    }
    ll ans=mod;
    rep(l,i,r+1){
        rep(i+1,j,r+1){
            ans=min(ans,(i*j)%mod);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int sum(int problem[],int n)
{
    int sum=0;
    for(int i=0;i<n;i++)
        sum+=problem[i];
    return sum;
}

int main()
{
    int n,m;
    cin>>n;
    int problem[n];
    int temp;
    for(int i=0;i<n;i++)
       cin>>problem[i];

    cin>>m;
    int index,time;
    int _sum[m];
    for(int i=0;i<m;i++)
    {
        cin>>index>>time;
        temp=problem[index-1];
        problem[index-1]=time;
        _sum[i]=sum(problem,n);
        problem[index-1]=temp;
    }
    for(int i=0;i<m;i++)
        cout<<_sum[i]<<"\n";


}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int L, R;
    scan(L, R);
    auto D = R - L + 1;

    if (D >= 2019) {
        writeln(0);
        return;
    }

    long ans = 2019;

    foreach (i ; L .. R + 1) {
        foreach (j ; i + 1 .. R + 1) {
            ans = min(ans, (1L * i * j) % 2019);
        }
    }

    writeln(ans);
}

















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main(){
  
  string s,t;
  cin>>s>>t;
  int c = INT_MAX;
  for(int i=0;i<(s.length()-t.length()+1);i++)
  {
     int k = i;
    int c1=0;
    for(int j=0;j<t.length();j++)
    {
      if(s[k]!=t[j])
        c1++;
      k++;
    }
    c = min(c,c1);
  }
  cout<<c<<endl;
  
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1000000000;
const ll inf=LONG_LONG_MAX;
const ll ms=(1e5)+5;

int ar[ms];
int vis[ms]={0};

int main()
{
    idfc;
    int n;
    cin>>n;
    int i;
    for(i=1;i<=n;i++)cin>>ar[i];

    int c=0;
    i=1;

    while(true)
    {
        if(vis[i]){cout<<-1;return 0;}
        vis[i]=1;
        if(i==2){cout<<c;return 0;}
        i=ar[i];
        c++;
    }

    return 0;
}

Measured memory_bytes: 1024
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;
	auto X = RD;

	writeln(A <= X && A + B >= X ? "YES" : "NO");
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
N = list(input())
if N[-1] == "2" or N[-1] == "4" or N[-1] == "5" or N[-1] == "7" or N[-1] == "9":
    print("hon")
elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8":
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

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

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int solve(string s){
  int res=0;
  int n=s.size();
  rep(i,(n+1)/2){
    if(s[i]=='1'){
      res=n-1-i;
    }
  }
  int res2=inf;
  reverse(ALL(s));
  rep(i,(n+1)/2){
    if(s[i]=='1'){
      res2=n-1-i;
    }
  }
  //reverse(ALL(s));
  int cur=0;
  s+='0';
  int res3=0;
  if(s[0]=='1')cur++;
  rep1(i,n){
    if(s[i]=='1'){
      cur++;
    }
    else{
      res3=max(cur,res3);
      cur=0;
    }
  }
  //res3=0;
  if(res==4&&false){
    cout<<s<<endl;
    cout<<res3<<"\n";
  }
  return max(res3,min(res,res2));
}
string R(string s){
  string res=s;
  int n=s.size();
  rep(i,n){
    if(res[i]=='0')res[i]='1';
    else res[i]='0';
  }
  return res;
}
signed main(){
  string s;cin>>s;
  int k=0;
  int res=max(solve(s),solve(R(s)));
  if(s=="1"){
    res=1;
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 640