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

using namespace std;

const int md = 1e5 + 10;

long long a[md];
long long n, m, v, p;

bool check(int x) {
    if (x < p)
        return true;
    if (a[x] + m < a[p - 1])
        return false;
    long long sum = 0;
    for(int i = 0; i < n; i++) {
        if (i < p - 1)
            sum += m;
        else if (i == x)
            sum += m;
        else if (i > x)
            sum += m;
        else {
            sum += a[x] + m - a[i];
        }
    }
    return sum >= m * v;
}

int bs(int l, int r) {
    while (r - l > 1) {
        int mid = (l + r) >> 1;
        if (check(mid))
            l = mid;
        else r = mid;
    }
    return l + 1;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> m >> v >> p;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    cout << bs(-1, n);
    return 0;
}

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

using namespace std;


int main(){
    string S;
    cin>>S;

    int count_b = 0;
    int count_w = 0;
    long long int distance = 0;
    int pointer = 0;
    while(S[pointer] != NULL){
        if(S[pointer] == 'B'){
            count_b = count_b + 1;
        }
        else{
            count_w = count_w + 1;
            distance = distance + (long long int)pointer;
        }
        pointer++;
    }
    long long int count_after = 0;
    for(int i=0; i<count_w; i++){
        count_after = count_after + (long long int)i;
    }

    cout<<distance-count_after<<endl;
    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 10e-8;

int main(){
	int len;
	while(~scanf("%d",&len)){
		if(len==0) break;
		int* a = new int[len];
		for(int i=0;i<len;i++){
			scanf("%d",a+i);
		}

		int n=32;
		int idx=0;
		while(n>0){
			n -= (n-1) % 5;
			printf("%d\n",n);
			n -= a[idx % len] >= n ? n : a[idx % len];
			printf("%d\n",n);
			idx++;
		}

		delete[] a;
	}
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;
int a[100009], b[100009];

int main(){
    int n; cin >> n;
    for (int i=0; i<n+1; i++)
        cin >> a[i];
    for (int i=0; i<n; i++)
        cin >> b[i];
    long long k, cnt=0;
    int i=0, j=n-1;
    while (i < j){
        k = min(b[i], a[i]);
        a[i] -=k;
        b[i] -=k;
        cnt += k;
        k = min(b[i], a[i+1]);
        b[i] -= k;
        a[i+1] -= k;
        cnt += k;

        k = min(b[j], a[j+1]);
        b[j] -= k;
        a[j+1] -= k;
        cnt += k;
        k = min(b[j], a[j]);
        a[j] -= k;
        b[j] -= k;
        cnt += k;
        i++, j--;
    }
    if (i == j){
        cnt += min(a[i] + a[i+1], b[i]);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	vector< vector<int> > a(3, vector<int>(3));

	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin >> a.at(i).at(j);
		}
	}
	cin >> n;
	vector<int> b(n);
	rep(i,n){
		cin >> b.at(i);
	}

	vector< vector<bool> > c(3, vector<bool>(3));
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			c.at(i).at(j) = false;
		}
	}


	for(int k=0;k<3;k++){
		for(int j=0;j<3;j++){
			rep(i,n){
				if(b.at(i)==a.at(k).at(j)){
					c.at(k).at(j) = true;
				}
			}
		}
	}

	bool flag = false;
	for(int i=0;i<3;i++){
		if(c.at(i).at(0) && c.at(i).at(1) && c.at(i).at(2)) {
			cout << "Yes" << endl;
			flag = true;
			return 0;
		}
	}
	for(int i=0;i<3;i++){
		if(c.at(0).at(i) && c.at(1).at(i) && c.at(2).at(i)) {
			cout << "Yes" << endl;
			flag = true;
			return 0;
		}
	}
	if((c.at(0).at(0) && c.at(1).at(1) && c.at(2).at(2)) || (c.at(0).at(2) && c.at(1).at(1) && c.at(2).at(0))) {
		cout << "Yes" << endl;
		flag = true;
		return 0;
	}

	if(!flag){
		cout << "No" << endl;
		return 0;
	}

}


Measured memory_bytes: 256
from math import sqrt
def prime(x):
  for i in range(2,int(sqrt(x))+1):
    if x%i==0:
      return False
  else:
    return True
n=int(input())
j=0
while True:
    
    if prime(n+j):
      print(n+j)
      break
    j+=1
  

Measured memory_bytes: 2940
import math
N,D = map(int,input().split())
X = [list(map(float, input().split())) for i in range(N)]
counter = 0
for i, x0 in enumerate(X): 
    for x1 in X[i+1:]:
        if math.sqrt(sum([(a-b)**2 for a, b in zip(x0,x1)])).is_integer():
            counter+=1
print(counter)


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

int main(void)
{
    double a, b, rad, S, L, h;
    int C;
    double PI = acos(-1);
    scanf("%lf %lf %d", &a, &b, &C);
    rad = C * PI / 180;
    S = a * (b * sin(rad)) / 2;
    double a2 = pow(a, 2);
    double b2 = pow(b, 2);
    L = a + b + sqrt(a2 + b2 - 2 * a * b * cos(rad));
    h = 2 * S / a;
    printf("%f\n%f\n%f\n", S, L, h);

    return 0;
}


Measured memory_bytes: 2140
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int dp[3002][3][3002][3];

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	dp[a][0][b][0] = 1;
	for (int i = a; i <= c; i++) {
		for (int j = b; j <= d; j++) {
			for (int l = 0; l < 3; l++) {
				for (int m = 0; m < 3; m++) {
					dp[i][l][j][m] %= MOD;
				}
			}
			dp[i + 1][1][j][0] += dp[i][0][j][0] * (j - 1) % MOD;
			dp[i + 1][1][j][1] += dp[i][0][j][0];
			dp[i + 1][1][j][2] += dp[i][0][j][1];
			dp[i + 1][1][j][0] += dp[i][1][j][0] * (j - 1) % MOD;
			dp[i + 1][1][j][1] += dp[i][1][j][0];
			dp[i + 1][1][j][2] += dp[i][1][j][1];
			if (j == b)dp[i + 1][1][j][2] += dp[i][1][j][1] * (j - 1) % MOD;
			dp[i + 1][1][j][2] += dp[i][1][j][2] * j % MOD;
			dp[i + 1][1][j][2] += dp[i][2][j][1];
			dp[i][0][j + 1][1] += dp[i][0][j][0] * (i - 1) % MOD;
			dp[i][1][j + 1][1] += dp[i][0][j][0];
			dp[i][2][j + 1][1] += dp[i][1][j][0];
			dp[i][1][j + 1][1] += dp[i][1][j][0] * (i - 1) % MOD;
			dp[i][0][j + 1][1] += dp[i][0][j][1] * (i - 1) % MOD;
			dp[i][1][j + 1][1] += dp[i][0][j][1];
			dp[i][2][j + 1][1] += dp[i][1][j][1];
			dp[i][1][j + 1][1] += dp[i][1][j][1] * (i - 1) % MOD;
			dp[i][2][j + 1][1] += dp[i][2][j][1] * i % MOD;
			dp[i][2][j + 1][1] += dp[i][1][j][2];
			dp[i][1][j + 1][1] += dp[i][1][j][2] * (i - 1) % MOD;
		}
	}
	long long int ans = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			ans += dp[c][i][d][j];
			ans %= MOD;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
int num = 0,xL = 0,xR = 0,L, R;
string l,r;

cin >> num;

for (int i = 0 ; i < num ; i++ ){
	cin >> l >> r;
	

	
	for (int j = 0  ; j < 100 ; j++ ){


		if (l == r){
			xL++;
			xR++;
			break;
		}
	
		L = l[j] - 'a';
		R = r[j] - 'a';
		

		if (R > L){
			xR += 3;
			break;
		}
	    if (R < L){
			xL += 3;
			break;
		}
		
	}
}
	cout << xL << " " << xR << endl;
	return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vll = vector<ll>;
#define x first
#define y second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define szz(x) (int) (x).size()
#define FOR(i,a,b) for (int i = (a), _for = (b); i < _for; i++)
#define REP(i,n) FOR(i,0,(n))
#define _ << " " <<
const ll MOD = 1000000007ll;
const ll INF = 0x3f3f3f3f3f3f3f3f;
inline ll SUB(ll a, ll b) { return a-b >= 0ll ? a-b : a-b+MOD; }
inline ll ADD(ll a, ll b) { return a+b >= MOD ? a+b-MOD : a+b; }
inline ll MUL(ll a, ll b) { return a*b % MOD; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vll a(n); REP(i,n) cin >> a[i];
  vll dp(n);
  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);
  FOR(i,2,n) {
    dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
  }
  cout << dp.back() << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public void main(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int min = Math.min(x, y);
        int del = Math.max(x, y) - min;

        int ans = Math.min(a + b, 2 * c) * min + Math.min((min == x) ? b : a, 2 * c) * del;

        println(ans);
    }

    public void print(Object o) {
        System.out.print(o);
    }

    public void println(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N, M;
vector<vector<int>> G;

vector<int> C;
void solve(){
	int s = 0;
	queue<int> q;
	q.push(s);
	C[s] = -1;
	bool b = false;
	while(!q.empty() and !b){
		int n = q.front(); q.pop();
		rep(i, G[n].size()){
			int to = G[n][i];
			if(!C[to]){
				C[to] = C[n] * -1;
				q.push(to);
			}
			else if(C[n] == C[to]){
				b = true;
				break;
			}
		}
	}
	if(b)
		cout << (ll)N * (N - 1) / 2 - M << endl;
	else{
		int W = 0, B = 0;
		rep(i, N){
			if(C[i] == 1)
				W++;
			else
				B++;
		}
		cout << (ll)W * B - M << endl;
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M;
	G.resize(N);
	C.resize(N);
	rep(i, M) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		G[A].pub(B);
		G[B].pub(A);
	}
		solve();
	return 0;
}


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

int main() {
	//code
	
	    int n,i,j,gap=0;
	    cin>>n;
	    long long A[n],sum=0;
	    for(i=0;i<n;i++)
        {
          cin>>A[i];
          sum+=A[i];
        }
	    long long dp[n][n];    
	    for(i=0;i<n;i++)
	        dp[i][i]=A[i];
	    for(i=0;i<n-1;i++)
	        dp[i][i+1]=max(A[i],A[i+1]);
	    for(i=0;i<n-2;i++)
	        dp[i][i+2]=max(A[i]+min(A[i+1],A[i+2]),A[i+2]+min(A[i],A[i+1]));
	        
	    for(gap=4;gap<=n;gap++)
	    {
	        for(i=0;i<=n-gap;i++)
	        {
	            j=i+gap-1;
	            dp[i][j] = max(A[i]+min(dp[i+1][j-1],dp[i+2][j]),
	                           A[j]+min(dp[i+1][j-1],dp[i][j-2])); 
	        }
	    }
	    
	    cout<<2*dp[0][n-1]-sum<<endl;
	
	return 0;
}

Measured memory_bytes: 70272
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n = ni()
A = []
for i in range(n):
    A.append(ni())
def isok(num,val):##適宜変更
    return num<val
def bisect(ls,val): ##valの関数isok(x,val)がTrueとなる一番右のindex を返す 全部Falseなら-1,Trueならlen(ls)-1
    ok = -1
    ng = len(ls)
    x = (ok+ng)//2
    while ng-ok>1:
        num = ls[x]
        if isok(num,val):
            ok = x
        else:
            ng = x
        x = (ok+ng)//2
    return ok ##一番右のTrueのindex  Trueの個数はok+1こ
INF=10**10
prev=INF
ls =[-INF]*n+[INF]*n
idx=0
for a in A:
    if a>prev:
        pass
    else:
        idx=bisect(ls,a)
    ls[idx]=a
    #print(ls,a)
print(2*n-ls.count(INF)-ls.count(-INF))


Measured memory_bytes: 83776
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
bool v[1000][10];
int cost[1000][11];
bitset<10>bit;
bitset<10>bit2;
int main() {
	int n;
	cin >> n;
	int sum[100] = {};
	int ans = 0 - INF; 
	TFOR(i, n)TFOR(j, 10) { cin >> v[i][j]; if(v[i][j])bit2[9-j] = 1; }
	TFOR(i, n)TFOR(j, 11)cin >> cost[i][j];
	TFOR(i, 2) {
		if(bit2[0])bit[0] = (i == 0 ? 0 : 1);
		TFOR(i2, 2) {
			if (bit2[1])bit[1] = (i2 == 0 ? 0 : 1);
			TFOR(i3, 2) {
				if (bit2[2])bit[2] = (i3 == 0 ? 0 : 1);
				TFOR(i4, 2) {
					if (bit2[3])bit[3] = (i4 == 0 ? 0 : 1);
					TFOR(i5, 2) {
						if (bit2[4])bit[4] = (i5 == 0 ? 0 : 1);
						TFOR(i6, 2) {
							if (bit2[5])bit[5] = (i6 == 0 ? 0 : 1);
							TFOR(i7, 2) {
								if (bit2[6])bit[6] = (i7 == 0 ? 0 : 1);
								TFOR(i8, 2) {
									if (bit2[7])bit[7] = (i8 == 0 ? 0 : 1);
									TFOR(i9, 2) {
										if (bit2[8])bit[8] = (i9 == 0 ? 0 : 1);
										TFOR(i10, 2) {
											if (bit2[9])bit[9] = (i10 == 0 ? 0 : 1);
											if (bit.count() > 0) {
												int a, b;
												TFOR(j, 10) {
													if (bit[9-j]) {
														TFOR(j2, n)if(v[j2][j])sum[j2]++;
													}
												}
												int nn = 0;
												a = sum[0]; b = sum[1];
												TFOR(j, n) {
													nn += cost[j][sum[j]];
													sum[j] = 0;
												}
												//cout << bit << "," <<a<<","<<b<<","<< nn << endl;
												if (ans < nn)ans = nn;
											}
										}}}}}}}}}}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
typedef long long ll;
const int MAXN = 200010;

int n, k, a[MAXN];

void input() {
	scanf( "%d%d", &n, &k );
	for( int i = 0; i < n; ++i )
		scanf( "%d", a+i ), a[i] -= k;
}

namespace Splay {
	struct Node {
		ll val;
		int sz;
		Node *ch[2], *pa, **rt;
		Node( ll v ) {
			val = v, sz = 1;
			ch[0] = ch[1] = pa = NULL;
			rt = NULL;
		}
		Node *maintain() {
			sz = 1;
			if( ch[0] ) sz += ch[0]->sz;
			if( ch[1] ) sz += ch[1]->sz;
			return this;
		}
		int rela() {
			return pa->ch[0] == this ? 0 : 1;
		}
		Node *rotate() {
			int x = rela();
			Node *old = pa;
			if( pa->pa ) pa->pa->ch[old->rela()] = this;
			pa = pa->pa;
			old->ch[x] = ch[x^1];
			if( ch[x^1] ) ch[x^1]->pa = old;
			ch[x^1] = old, old->pa = this;
			old->maintain(), maintain();
			if( !pa ) *rt = this;
			return this;
		}
		Node *splay( Node *tg = NULL ) {
			while( pa != tg ) {
				if( pa->pa == tg ) rotate();
				else {
					if( rela() == pa->rela() )
						pa->rotate(), rotate();
					else rotate(), rotate();
				}
			}
			return this;
		}
	};
	Node *rt = NULL;
	void insert( ll v ) {
		if( !rt ) {
			rt = new Node(v);
			rt->rt = &rt;
			return;
		}
		Node *o = rt;
		while(1) {
			int d = v <= o->val ? 0 : 1;
			if( !o->ch[d] ) {
				o->ch[d] = new Node(v);
				o->ch[d]->pa = o;
				o->ch[d]->rt = &rt;
				o->ch[d]->splay();
				return;
			} else {
				o = o->ch[d];
			}
		}
	}
	int query( ll v ) {
		int ans = 0;
		Node *o = rt;
		while( o ) {
			if( v <= o->val ) o = o->ch[0];
			else {
				++ans;
				ans += o->ch[0] ? o->ch[0]->sz : 0;
				o = o->ch[1];
			}
		}
		return rt->sz - ans;
	}
}

void solve() {
	ll zero = 0, ans = 0;
	for( int i = 0; i < n; ++i ) {
		zero -= a[i];
		Splay::insert( zero + a[i] );
		ans += Splay::query(zero);
		// printf( "%lld\n", ans );
	}
	printf( "%lld\n", ans );
}

int main() {
	input(), solve();
	return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            WillReturn.Add("1 5");
            WillReturn.Add("2 4");
            WillReturn.Add("3 6");
            //3
            //次の3種類の祭壇があります。
            //●上部に1個目、中部に1個目、下部に1個目のパーツを使った祭壇
            //●上部に1個目、中部に1個目、下部に2個目のパーツを使った祭壇
            //●上部に1個目、中部に2個目、下部に2個目のパーツを使った祭壇
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3");
            WillReturn.Add("1 1 1");
            WillReturn.Add("2 2 2");
            WillReturn.Add("3 3 3");
            //27
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("6");
            WillReturn.Add("3 14 159 2 6 53");
            WillReturn.Add("58 9 79 323 84 6");
            WillReturn.Add("2643 383 2 79 50 288");
            //87
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static int UB;

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[1]);
        int[] AArr = wkArr;
        UB = AArr.GetUpperBound(0);

        SplitAct(InputList[2]);
        int[] BArr = wkArr;

        SplitAct(InputList[3]);
        int[] CArr = wkArr;

        Array.Sort(AArr);
        Array.Sort(BArr);
        Array.Sort(CArr);

        //尺取法で、自分未満な配列Aの要素数[配列Bの添字]を求める
        int[] LowerCntArrA = new int[UB + 1];
        int J = 0;
        for (int I = 0; I <= UB; I++) {
            while (J <= UB && BArr[I] > AArr[J]) J++;
            LowerCntArrA[I] = J;
        }

        //尺取法で、自分以下な配列Cの要素数[配列Bの添字]を求める
        int[] LowerCntArrC = new int[UB + 1];
        J = 0;
        for (int I = 0; I <= UB; I++) {
            while (J <= UB && BArr[I] >= CArr[J]) J++;
            LowerCntArrC[I] = J;
        }

        long Answer = 0;
        for (int I = 0; I <= UB; I++) {
            Answer += (long)LowerCntArrA[I] * (CArr.Length - LowerCntArrC[I]);
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 43272
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int W = in.nextInt();
            int H = in.nextInt();
            int N = in.nextInt();
            int[] x = new int[N];
            int[] y = new int[N];
            int[] a = new int[N];
            for (int i = 0; i < N; i++) {
                x[i] = in.nextInt() - 1;
                y[i] = in.nextInt() - 1;
                a[i] = in.nextInt();
            }

            boolean[][] isBlack = new boolean[H][W];

            for (int i = 0; i < N; i++) {
                if (a[i] == 1) {
                    for (int r = 0; r < H; r++) {
                        for (int c = 0; c < W; c++) {
                            if (c <= x[i]) {
                                isBlack[r][c] = true;
                            }
                        }
                    }
                } else if (a[i] == 2) {
                    for (int r = 0; r < H; r++) {
                        for (int c = 0; c < W; c++) {
                            if (c > x[i]) {
                                isBlack[r][c] = true;
                            }
                        }
                    }
                } else if (a[i] == 3) {
                    for (int r = 0; r < H; r++) {
                        for (int c = 0; c < W; c++) {
                            if (r <= y[i]) {
                                isBlack[r][c] = true;
                            }
                        }
                    }
                } else if (a[i] == 4) {
                    for (int r = 0; r < H; r++) {
                        for (int c = 0; c < W; c++) {
                            if (r > y[i]) {
                                isBlack[r][c] = true;
                            }
                        }
                    }
                }
            }

            int count = 0;
            for (int r = 0; r < H; r++) {
                for (int c = 0; c < W; c++) {
                    if (!isBlack[r][c]) {
                        count++;
                    }
                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 29776
import java.util.Scanner;

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

		int n = sc.nextInt();
		String s = sc.next();
		String ss[] = s.split("");
		int count = 1;
		for(int i=0; i<n; i++) {
			if(i!=0) {
				if(!ss[i].equals(ss[i-1])) {
					count++;
				}
			}
		}
		System.out.print(count);

	}

}


Measured memory_bytes: 32244
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;

signed main() {
    int n;
    cin>>n;
    double asum = 0, bsum = 0;
    int a[222222], b[222222];
    for (int i = 0; i < n; i++) {
        cin>>a[i]>>b[i];
        asum += a[i];
        bsum += b[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    double x, y;
    if (n % 2) {
        x = a[n / 2];
        y = b[n / 2];
        cout<<(int)(y - x + 1)<<endl;
    } else {
        x = (a[n / 2 - 1] + a[n / 2]);
        y = (b[n / 2 - 1] + b[n / 2]);
        cout<<(int)(y - x + 1)<<endl;
        cerr<<x<<' '<<y<<endl;
    }
}


Measured memory_bytes: 6932
S = input()
H, L = map(int, [S[0:2], S[2:4]])

if ((H > 12) or (H == 0)) and (12 >= L >= 1):
    print('YYMM')
elif ((L > 12) or (L == 0)) and (12 >= H >= 1):
    print('MMYY')
elif (12 >= L >= 1) and (12 >= H >= 1):
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 3064
import Data.List

main = do
  [a,b,k] <- fmap (map read . words ) getLine
  mapM_ print (solve a b k)

solve :: Int -> Int -> Int -> [Int]
solve a b k =
  nub (sort (ls++us))
  where
    ls = take k [a..b]
    us = take k [b,b-1..a]

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  int odd = (n%2 == 0) ? n/2 : n/2+1;

  double ans = (double)odd/(double)n;
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def f(n, b):
    if n < b:
        return n
    else:
        return n % b + f(n // b, b)


def solve(n: int, s: int):
    if s > n:
        return -1

    if s == n:
        return n+1

    b = 2
    while b * b <= n:
        if f(n, b) == s:
            return b
        b += 1
    
    for p in range(b-1, 0, -1):
        if (n - s) % p > 0:
            continue

        c = (n - s) // p + 1
        if f(n, c) == s:
            return c
    
    return -1


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    s = int(next(tokens))  # type: int
    print(solve(n, s))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {
	LL N;
	cin >> N;
	//VI A;
	int flag_first = 0;
	LL A;
	REP(i, N) {
		//cin >> A[i];
		cin >> A;
		if (A % 2 == 1 || A == 1) {
			flag_first = 1;
		}
	}

	if (flag_first == 1) {
		cout << "first" << endl;
	} else {
		cout << "second" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
#include<unordered_map>
#define ll long long
const ll mx=1e5;
using namespace std;
ll mp[mx];
int main( ) {
 
     ll t,i,j,m ;
     ll k=0,n;
       
		   cin>>n;
		   if(n>=30)cout<<"Yes\n";
		   else cout<<"No\n";
	  
	return 0;
}



Measured memory_bytes: 3636
a, b, k = gets.split.map(&:to_i)
k.times do |i|
  if i % 2 == 0
    if a.odd?
      a -= 1
    end
    b += a/2
    a /= 2
  else
    if b.odd?
      b -= 1
    end
    a += b/2
    b /= 2
  end
end
puts "#{a} #{b}"

Measured memory_bytes: 1788
n, m, c = map(int, raw_input().strip().split())
b = map(int, raw_input().strip().split())

ans = 0
for _ in xrange(n):
    a = map(int, raw_input().strip().split())
    val = 0
    for i in xrange(m):
        val = val + a[i] * b[i]
    val += c
    if val > 0: ans += 1

print ans
    


Measured memory_bytes: 28396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string word;
bool Palindrome(int l,int r){
    for(int i=l,j=r;i<j;i++,j--){
        if(word[i] != word[j])  return false;
    }
    return true;
}
int main()
{
    cin >> word;
    int len = word.length();
    int mid = len/2;
    bool a = Palindrome(0,len -1);
    bool b = Palindrome(0,mid - 1);
    bool c = Palindrome(mid + 1, len - 1);
    if(a && b && c){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    def nc2(n):
        return n*(n-1)//2

    n = int(input())
    a = list(map(int, input().split()))
    s = [0]
    for i in range(n):
        s.append(s[-1]+a[i])
    from collections import Counter as cc
    c = cc(s)
    ans = 0
    for x in c:
        if c[x] > 1:
            ans += nc2(c[x])
    print(ans)



    
if __name__ == '__main__':
    main()

Measured memory_bytes: 44272
s = gets().chomp

y, m, d = s.split('/').map{|x| x.to_i}

is_heisei = true
if y > 2019
  is_heisei = false
elsif y == 2019 && m > 4
  is_heisei = false
end

puts is_heisei ? 'Heisei' : 'TBD'


Measured memory_bytes: 14256
package main

import (
	"fmt"
)

func main() {
	var n, m, t, p, x, sum int
	fmt.Scan(&n)
	ts := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		ts[i] = t
	}
	fmt.Scan(&m)
	ps := make(map[int][]int)
	for i := 0; i < m; i++ {
		ps[i] = make([]int, 2)
		fmt.Scan(&p, &x)
		ps[i][0] = p - 1
		ps[i][1] = x
	}
	for _, v := range ts {
		sum += v
	}
	for i := 0; i < len(ps); i++ {
		fmt.Println(sum - ts[ps[i][0]] + ps[i][1])
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};
int n,k;

int main() {
  cin >> n >> k;
 
  for(int i=0; i<n; i++){
   cin >> vec.at(i);
  }
  ll s = INF;
  int center = 0;
  int centerzero = 0;
  bool flag = true;
  for(int i=0; i<n; i++){
    if(flag && vec.at(0) >= 0){
        s = 0;
        flag = false;
    }
    else if(flag && vec.at(0) < 0){
      if(i<n-1 && vec.at(i) <0 && vec.at(i+1) > 0){
        center = i+1;
        flag = false;
      }
      else if(i<n-1 && vec.at(i) <0 && vec.at(i+1) == 0){
        centerzero = i+1;
        flag = false;
      }
      else if(vec.at(n-1) <= 0){
        s = n-1;
        flag = false;
      }
    }
  }
   if(s == 0)
     cout << vec.at(k-1) << endl;
   else if(s == n-1)
     cout << -vec.at(n-k) << endl;
   else{
     ll ans = INF;
     if(center){
       for(int i = center-k;i<=center;i++){
         ll a=0;
         ll b=0;
         if(i>=0 && i+k <= n){
           if(vec.at(i) < 0)
             a -= vec.at(i);
           else
             a = 0;
           if(vec.at(i+k-1) <0)
             b = 0;
           else
             b = vec.at(i+k-1);
           if(a<b)
           a *= 2;
           else
             b *= 2;
           if(ans > a+b)
           ans = a+b;
         }
       }
     }
     else if(centerzero){
       for(int i = centerzero-k+1;i<=centerzero;i++){
         ll a = 0;
         ll b = 0;
         if(i>=0 && i+k <= n){
           if(vec.at(i) < 0)
             a -= vec.at(i);
           else
             a = 0;
             b = vec.at(i+k-1);
         }
         if(a<b)
           a *= 2;
         else
           b *= 2;
         if(ans > a+b)
         ans = a+b;
     }
   }
     cout << ans << endl;
   }
}

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


using namespace std;


int main() {
	int tmp1, tmp2;
	stack<int> s;
	string a;
	
	while(cin >> a) {
		if (a == "+" || a == "-" || a == "*") {
			tmp2 = s.top();
			s.pop();
			tmp1 = s.top();
			s.pop();
			if (a == "+") { s.push(tmp1 + tmp2); }
			if (a == "-") { s.push(tmp1 - tmp2); }
			if (a == "*") { s.push(tmp1 * tmp2); }
		}
		else {
			s.push(atoi(a.c_str()));
		}
	}
	cout << s.top()<<endl;
	
	return 0;
}



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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1e18+1;

signed main() {
	int a[3];

	cin >> a[0] >> a[1] >> a[2];

	sort(a, a+3);

	int ans = 0;
	ans += (a[2] - a[0]) / 2;
	a[0] += (a[2] - a[0]) / 2 * 2;
	ans += (a[2] - a[1]) / 2;
	a[1] += (a[2] - a[1]) / 2 * 2;
	if ( a[0] < a[2] && a[1] < a[2] ) {
		ans += 1;
	}
	else if ( a[0] == a[2] && a[1] == a[2] ) {
		
	} else {
		ans += 2;
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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


    if(!N){
        cout<<0<<endl;
        return 0;
    } 

    vector<int64_t> pV{1},mV{0},sum_pV{1},sum_mV{0};
    int64_t i=1;
    while(pV.back()<=1e9 || mV.back()>=-1e9){
        pV.push_back(pow(4,i));
        sum_pV.push_back(pow(4,i)+sum_pV.back());
        mV.push_back(-2*pow(4,i-1));
        sum_mV.push_back(2*pow(4,i-1)+sum_mV.back());
        i++;
    }

    string ans;
    rep(i,0,33) ans+='0';
    while(N!=0){
        if(N>0){
            auto itr=lower_bound(ToEnd(sum_pV),N);
            int d=distance(sum_pV.begin(),itr);
            N-=pV.at(d);
            ans.at(ans.size()-2*d-1)='1';
        }else{
            auto itr=lower_bound(ToEnd(sum_mV),-N);
            int d=distance(sum_mV.begin(),itr);
            N-=mV.at(d);
            ans.at(ans.size()-2*d)='1';
        }
    }

    while(ans.front()=='0') ans.erase(0,1);

    cout<<ans<<endl;
}

Measured memory_bytes: 256
n,*A=map(int,open(0).read().split());k=10**9+7
c=(1<<n)%k-1
for l in A:
	X=Y=1
	for i in range(l):X=X*(n-i)%k;Y=Y*(i+1)%k
	c-=X*pow(Y,k-2,k)
print(c%k)

Measured memory_bytes: 263412
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main(){

	string s;
	long long k;
	int ans;

	cin >> s;
	cin >> k;

	ans = 1;
	for(long long i=0;i<k && i<s.size();i++){
		if(s[i] != '1'){
			ans = (s[i] - '0');
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long int
int i,j;
 main()
{
    int n,x; cin>>n;
    int a[n+1]={0};
    for(i=1;i<n;i++)
    {
        cin>>x;
        a[x-1]++;
    }
    for(i=0;i<n;i++) cout<<a[i]<<endl;
}


Measured memory_bytes: 5156
#include<bits/stdc++.h> 
using namespace std;
 
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	int l=a[0],r=a[n-2];
	int aim=a[n-1]/2;//+(a[n-1]%2==0?0:1);
	int now;
	int dis=0x3f3f3f3f;
	for(int i=0;i<n-1;i++){
		if(abs(a[i]-aim)<=dis){
			dis=abs(a[i]-aim);
			now=a[i];
		}
	}
	cout << a[n-1] <<" "<< now;
}


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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define EPS (1e-7)
#define INF ((ll)1e9+7)
#define PI (acos(-1))
#define c(a) cout<<a<<"\n";
using namespace std;

ll MOD = INF;
ll fact[2010], factinv[2010];

ll power(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1) res = res * a%MOD;
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

ll comb(ll n, ll r) {
	ll res;
	if (n < 0 || r < 0 || n < r) { res = 0; }
	else { res = (fact[n] * factinv[r]) % MOD*factinv[n - r] % MOD; }
	return res;
}
int main() {
	speed;
	int n, k;
	cin >> n >> k;//Binの分子

		// 階乗の計算
	fact[0] = 1;
	for (int i = 1; i <= n; i++) { fact[i] = fact[i - 1] * i%MOD; }

		// 逆元の計算
	factinv[n] = power(fact[n], MOD - 2);//フェルマーの小定理
	for (int i = n - 1; i >= 0; --i) { factinv[i] = factinv[i + 1] * (i + 1) % MOD; }
	for (int i = 1; i <= k; i++) {
		cout << comb(n - k + 1, i)* comb(k - 1, i - 1)%MOD << endl;
	}
	ed;
	return 0; 
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> T;
	if (T[5] != '0') {
		cout << "TBD";
	}
	else if (T[6] == '1' || T[6] == '2' || T[6] == '3' || T[6] == '4') {
		cout << "Heisei";
	}
	else {
		cout << "TBD";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  
  int a[n];
  for(int i = 0;i < n; ++i){
    cin >> a[i];
  }
  
  sort(a,a+n);
  
  int c = 0;
  for(int i = 0; i < n-1; ++i){
    c += a[i];
  }
  
  if(c > a[n-1]){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> res(N, 0);
  for (int i = 0; i < N-1; ++i) {
    int a; cin >> a; --a;
    res[a]++;
  }
  for (int i = 0; i < N; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 3992
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;

vector<int> g1[100100];
vector<int> g2[100100];
int f[100100];
int deg[100100];

int main(){
	int N,M;
	scanf("%d%d\n",&N,&M);
	while(M--){
		int x,y;
		scanf("%d%d",&x,&y),g1[x].push_back(y),g2[y].push_back(x),deg[y]++;
	}
	
	queue<int> q;
	for(int i=1;i<=N;i++)
		if(!deg[i]) q.push(i);
	int ans=0;
	while(!q.empty()){
		for(size_t i=0;i<g2[q.front()].size();i++)
			f[q.front()]=max(f[q.front()],f[g2[q.front()][i]]);
		f[q.front()]++;
		ans=max(ans,f[q.front()]);
		for(size_t i=0;i<g1[q.front()].size();i++)
			if(!--deg[g1[q.front()][i]]) q.push(g1[q.front()][i]);
		q.pop();
	}
	
	return printf("%d\n",ans-1)&0;
}

Measured memory_bytes: 11904
n, d = map(int, input().split())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

s = 0
for i in range(n):
    if (a[i][0]**2 + a[i][1]**2) ** 0.5 <= d:
        s += 1

print(s)

Measured memory_bytes: 103092
fun main(array: Array<String>) {
    val n = readLine()!!.toInt()
    var ans = 0
    val list = mutableListOf<Int>()
    list.add(0)
    for (num in readLine()!!.split(" ").map { it.toInt() }) {
        list.add(num)
    }
    for(j in 1..n) {
        if(j == list[list[j]]) {
            ans++
        }
    }
    print(ans / 2)
}

Measured memory_bytes: 52560
#include<bits/stdc++.h>
using namespace std;
int n;
long long k,pre=0;
pair<int,int> p[100010];
int main(){
	int n,i,a,b;
	cin>>n>>k; 
	for(int i=0;i<n;i++){
		cin>>a>>b;
		p[i].first=a;
		p[i].second=b;	
	}
	sort(p,p+n);
	int ans;
	for(int i=0;i<n;i++){
		if(pre<k&&k<=p[i].second+pre){
			ans=p[i].first;break;
		}
		pre+=p[i].second;
		
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

struct City {
  string S;
  int P;
  int idx;
};

bool cmp(const City &a, const City &b) {
  if (a.S == b.S) {
    return a.P > b.P;
  }
  return a.S < b.S;
}

int N;
vector<City> v;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  v.resize(N);
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    v[i] = City{s, p, i + 1};
  }
  sort(v.begin(), v.end(), cmp);

  for (auto &e : v) {
    cout << e.idx << endl;
  }

  return 0;
}

Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x_list = []
y_list = []
for v in x:
    x_list.append(v)
for v in y:
    y_list.append(v)
x_list.sort(reverse=True)
y_list.sort()
if x_list[0]>=y_list[0]:
    print('War')
else:
    XY = list(range(x_list[0]+1, y_list[0]+1))
    for v in XY:
        if (v > X) and (v <= Y):
            print('No War')
            break
        print('War')

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

using i64 = int64_t;

struct Edge{
    int from, to, cost;
};

using Graph = vector<vector<Edge>>;
using Weight = int;

constexpr Weight INF = 1e9;

tuple<int, int, Weight> tree_diameter(const Graph &tree){
    struct {
        pair<Weight, int> operator()(int v, const Graph &tree){
            pair<Weight, int> res(0, v);
            vector<Weight> dist(tree.size(), INF);
            dist[v] = 0;
            queue<pair<Weight, int>> que;
            que.push({0, v});
            while(!que.empty()){
                auto cur = que.front(); que.pop();
                res = max(res, cur);
                for(auto e: tree[cur.second]){
                    Weight new_cost = cur.first + e.cost;
                    if(new_cost >= dist[e.to])continue;
                    dist[e.to] = new_cost;
                    que.push({new_cost, e.to});
                }
            }
            return res;
        }
    } find_farthest_node;

    auto r = find_farthest_node(0, tree);
    auto t = find_farthest_node(r.second, tree);
    return make_tuple(r.second, t.second, t.first);
}

void bfs(int s, vector<Weight> &v, const Graph &tree){
    v[s] = 0;
    queue<pair<Weight, int>> que;
    que.push({0, s});
    while(!que.empty()){
        auto cur = que.front(); que.pop();
        for(auto e: tree[cur.second]){
            Weight new_cost = cur.first + e.cost;
            if(new_cost >= v[e.to])continue;
            v[e.to] = new_cost;
            que.push({new_cost, e.to});
        }
    }
}

int main(){
    int n;
    cin >> n;
    Graph tree(n, vector<Edge>());
    for(int i=0;i<n-1;++i){
        int u, v;
        cin >> u >> v;
        u--; v--;
        tree[u].push_back({u, v, 1});
        tree[v].push_back({v, u, 1});
    }
    int u, v, d;
    tie(u, v, d) = tree_diameter(tree);
    vector<Weight> ud(n, INF), vd(n, INF);
    bfs(u, ud, tree);
    bfs(v, vd, tree);
    for(int i=0;i<n;++i){
        cout << 2*(n-1) - max(ud[i], vd[i]) << endl;
    }

    return 0;
}



Measured memory_bytes: 10976
// ProblemURL : https://atcoder.jp/contests/abc120/tasks/abc120_c
// ---------------------------------------------
package main

import "fmt"

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var s string
	fmt.Scan(&s)

	sta0 := 0
	sta1 := 0
	ct := 0
	for i := range s {
		if s[i] == '0' {
			if sta1 > 0 {
				ct++
				sta1--
			} else {
				sta0++
			}
		} else {
			if sta0 > 0 {
				ct++
				sta0--
			} else {
				sta1++
			}
		}
	}

	fmt.Println(ct * 2)
}


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

int main() {
  string N;
  cin >> N;
  
  if(N.at(0) == N.at(1) && N.at(1) == N.at(2) || N.at(1) == N.at(2) && N.at(2) == N.at(3)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3588
from itertools import product, combinations_with_replacement
N=int(input())
s="abcdefghij"
 
def get_gen(a, N):
  for c in s[:s.index(max(a))+2 if a else 1]:
    t = a+c
    if len(t) == N:
      print(t)
    else:
      get_gen(t,N)

get_gen("", N)

Measured memory_bytes: 4428
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define endl '\n'

void solvetask(){
    int n; cin >> n;
    vector<int> a(n);
    int ans = 0;
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<n; i++){
        for (int j=i+1; j<n; j++){
            for (int k=j+1; k<n; k++){
                vector<int> b = {a[i], a[j], a[k]};
                if (b[0] == b[1] || b[0] == b[2] || b[1] == b[2]) continue;
                sort(b.begin(), b.end());
                if (b[2] < b[0] + b[1]) ans++;
            }
        }
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solvetask();
}

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

int main()
{
    int n, ans = 0;
    cin >> n;

    for(int i = 0; i < n; i++)
    {
        int l,r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
pair<int,int> C[100005]; //first A  second B 

int main()
{
	int N,M;
	cin >> N >> M;
	for (int i = 0; i < N; ++i)
	{
		cin >> C[i].first >> C[i].second;
	}

	sort(C,C+N);
	for (int i = 0; i < N; ++i)
	{
		
	}

	priority_queue<int> Q;
	int cnt = 0;
	int ans = 0;
	for (int i = 1; i <= M; ++i)
	{
		while(C[cnt].first == i)
		{
			Q.push(C[cnt].second);
			cnt++;
		}

		if (!Q.empty())
		{
			//cout << Q.top() << endl;
			ans += Q.top();
			Q.pop();
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;

int main() {
  string A, B, res = "no";

  cin >> A >> B;

  if (A.length() == B.length()) {
    for ( int i = 0; i < A.length(); i++) {
      if (A[i] > B[i]) {
        res = "GREATER";
        break;
      }
      else if (A[i] < B[i]) {
        res = "LESS";
        break;
      }
    }
    if (res == "no")
      res = "EQUAL";
    cout << res << endl;
  }

  else if (A.length() > B.length())
    cout << "GREATER" << endl;

  else
    cout << "LESS" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n-1;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
#define INF 1000000000000000000
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent,int mod)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
signed main()
{
	fast
	int n,m;
	cin>>n>>m;
	int mod=1000000007;
	string s[n];
	f(i,0,n)
	{
		cin>>s[i];
	}
	int dp[n][m];
	if(s[0][0]=='.') dp[0][0]=1;
	else dp[0][0]=0;
	f(i,0,n)
	{
		f(j,0,m)
		{
			if(i==0 && j==0) continue;
			if(s[i][j]=='#')
			{
				dp[i][j]=0;
				continue;
			}
			if(i==0)
			{ 
			    dp[i][j]=dp[i][j-1];
			}
			else if(j==0)
			{
			    dp[i][j]=dp[i-1][j];
			}
			else
			{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			}
		}
	}
	cout<<dp[n-1][m-1]%mod;
	return 0;
}

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

class Program {
    static void Main(string[] args) {
        int n = Cin.Ni();
        int total = 0;
        for (int i = 0; i < n; i++) {
            int a = Cin.Ni();
            int b = Cin.Ni();
            total += b - a + 1;
        }
        Console.WriteLine(total);
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

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

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

    public static int Ni() {
        return int.Parse(Next());
    }

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

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

}


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

using namespace std;

string s, b;

void init()
{
	cin >> s;
	int len = s.size();
	int S = 0, t = 0;
	if(len % 2 == 0) {
	for (int i = 0; i < len; ++i)
		{
			if(s[i] == 'S') {
				S++;
			}
			else {
				if(S != 0) S--; //s++;
				else t++;
			}
		}
		cout << S + t << '\n';	
	}
else {
	printf("0\n");
}
}
int main()
{
/*
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
*/
	init();

	return 0;
}

Measured memory_bytes: 640