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

using namespace std;

struct edge {
    int to;
    int cost;
    edge(int a, int b) : to(a), cost(b) {}
};

vector<vector<edge>> e;
int N;

pair<int, int> dfs(int p, int par = -1)
{
    if (e[p].size() == 1 && par >= 0) return make_pair(0, p);
    pair<int, int> res = make_pair(0, p);
    for (auto x : e[p]) {
        if (x.to == par) continue;
        auto t = dfs(x.to, p);
        t.first += x.cost;
        res = max(res, t);
    }
    return res;
}

int main()
{
    cin >> N;
    e.resize(N);
    for (int i = 0; i < N-1; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        e[s].emplace_back(t, w);
        e[t].emplace_back(s, w);
    }
    auto res = dfs(0);
    res = dfs(res.second);
    cout << res.first << endl;
}


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

// 与2数の絶対値の差を返す
int absolute_diff (int a, int b) {
  if (a - b >= 0) return a-b;
  else return b-a;
}

// 与パターンのコストの和を返す
int p_sum (int a, int b, int c) {
  return absolute_diff(a, b) + absolute_diff(b, c);
}

int main () {
  int A, B, C;
  cin >> A >> B >> C;
  int m;
  m = min(p_sum(A, B, C), p_sum(A, C, B));
  m = min(m, p_sum(B, A, C));
  m = min(m, p_sum(B, C, A));
  m = min(m, p_sum(C, A, B));
  m = min(m, p_sum(C, B, A));
  cout << m << endl;
}
  

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

struct UnionFindTree{
    vector<int> v;
    vector<int> rank;
     
    UnionFindTree(int n): v(n, -1), rank(n, 0){}
    int Find(int x){
        if(v[x] < 0) return x;
        return v[x] = Find(v[x]);
    }
    void Union(int a, int b){
        a = Find(a);
        b = Find(b);
        if(a == b) return;
        if(rank[a] < rank[b]) swap(a, b);
        if(rank[a] == rank[b]) rank[a]++;
        v[b] = a;
    }
};

struct edge{
    int a,b,d;
    bool operator<(const edge &x) const{
        return d < x.d;
    }
};
    
int mst(vector<edge> &e, vector<int> &use, int skip = -1){
    int m = e.size();
    UnionFindTree uft(m);
    int res = 0;
    for(int i=0; i<m; i++){
        if(i == skip) continue;
        if(uft.Find(e[i].a) != uft.Find(e[i].b)){
            uft.Union(e[i].a, e[i].b);
            if(skip == -1) use.push_back(i);
            res += e[i].d;
        }
    }
    return res;
}
 
int main(){
    int n,m;
    cin >> n >> m;
    vector<edge> e(m);
    for(int i=0; i<m; i++){
        cin >> e[i].a >> e[i].b >> e[i].d;
        e[i].a--; e[i].b--;
    }
    sort(e.begin(), e.end());

    vector<int> use;
    int mincost = mst(e, use);
    int num=0, cost=0;
    for(size_t i=0; i<use.size(); i++){
        if(mincost != mst(e, use, use[i])){
            num++;
            cost += e[use[i]].d;
        }
    }
    cout << num << " " << cost << endl;
    return 0;
}



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

bool check( ll x)
{
        ll last = x%10;
        last--;
        x/=10;
        while(x>0)
        {
                ll r = x%10;
                if(last != r) return false;
                last--;
                x/=10;
        }
        return true;
}

int main()
{
        ll n,ans,i,j,x;
        ll arr[1011];
        scanf("%lld",&n);
        for(i=0; i<n; i++)
        {
           scanf("%lld",&arr[i]);
        }
        sort(arr,arr+n,greater<int>());
        bool flag = false;
        ans = -1;
        for(i=0; i<n-1; i++)
        {
                for(j=0; j<n; j++)
                {
                        if(j!=i)
                        {
                                x = arr[i]*arr[j];
                                if( check(x) ) { flag = true; ans = x; }
                        }
                        if(flag) break;
                }
                if(flag) break;
        }
        printf("%lld\n",ans);
        return 0;
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int A, B, T;
  cin >> A >> B >> T;
  cout << (T / A) * B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int N, A[200010];
int W[200010];

long long mergecount(const int l, const int r)
{
    if (l + 1 >= r) return 0;
    if (l + 2 == r)
    {
        if (A[l] <= A[r - 1]) return 0;
        swap(A[l], A[r - 1]);
        return 1;
    }
    int m = (l + r) / 2;
    long long cl = mergecount(l, m);
    long long cr = mergecount(m, r);
    long long c = 0;
    int i = l, j = m;
    int k = l;
    while (i < m && j < r)
    {
        if (A[i] <= A[j]) W[k++] = A[i++];
        else
        {
            W[k++] = A[j++];
            c += (m - i);
        }
    }
    while (i < m) W[k++] = A[i++];
    while (j < r) W[k++] = A[j++];
    copy(W + l, W + r, A + l);
    return cl + cr + c;
}

int main(void)
{
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    cout << mergecount(0, N) << endl;
    return 0;
}


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

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

  int v[20];
  for(int i=0;i<n;i++) cin>>v[i];

  int ans=0;
  int tmp;
  for(int i=0;i<n;i++){
    cin>>tmp;
    ans+=max(v[i]-tmp,0);
  }

  cout<<ans<<endl;

  return 0;
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------

int main(void) {
  string s;
  cin >> s;

  s.pop_back();
  s.pop_back();
  while(1){
    string a=s.substr(0,s.size()/2);
    string b=s.substr(s.size()/2,s.size()/2);
    if(a==b){
      prt(s.size());
      return 0;
    } else {
      s.pop_back();
      s.pop_back();
    }
  }

}


Measured memory_bytes: 256
import sys
n, y = list(map(int, input().split(' ')))
y = y/1000
result = [-1,-1,-1]
for p in range(n+1):
    for q in range(n-p+1):
        if p*10+q*5+(n-p-q) == y:
            print(p, q, n-p-q)
            sys.exit()

print(' '.join(list(map(str, result))))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y){
    int c[N+1][N+1];
    int m = X.size();
    int n = Y.size();
    int maxl =0;
    X = ' '+X;
    Y=' '+Y;
    for(int i = 0; i <= m; i++) c[i][0]= 0;
    for(int j = 1; j <= n; j++) c[0][j]=0;
    
    for (int i=1; i <= m; i++){
        for(int j=1; j<=n; j++){
            if (X[i]== Y[j]){
                c[i][j] =c[i-1][j-1]+1;
            } else {
                c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }
    return maxl;
}
int main(){
    string s1, s2;
    int n;
    cin >> n;
    for(int i =0; i < n; i++ ){
        cin >> s1 >> s2;
        cout << lcs(s1,s2) << endl;
    }
    return 0;
}


Measured memory_bytes: 6988
#include <stdio.h>
#include <string.h>
int stack_index;
int stack[102];
int pop();
void push(int x);
int main(){
  char line[102];
  stack_index=0;
  int a, b;
  while(scanf("%s", line)!=EOF){
	if(strcmp(line, "+")==0){
	  b=pop();
	  a=pop();
	  a=a+b;
	  push(a);
	}else if(strcmp(line, "-")==0){
	  b=pop();
	  a=pop();
	  a=a-b;
	  push(a);
	}else if(strcmp(line, "*")==0){
	  b=pop();
	  a=pop();
	  a=a*b;
	  push(a);
	}else{
	  a=atoi(line);
	  push(a);
	}
  }
  a=pop();
  printf("%d\n", a);
  return 0;
}
int pop(){
  int a;
  a=stack[stack_index];
  --stack_index;
  return a;
}
void push(int x){
  ++stack_index;
  stack[stack_index]=x;
}



Measured memory_bytes: 2100
#!/usr/bin/env python3
import sys
from collections import deque
def main():
    S=input()
    Q=int(input())
    query=[list(input().split()) for _ in range(Q)]
    
    d=deque(S)
    c=0

    for q in query:
        if q[0]=="1":
            c+=1
        elif q[0]=="2":
            if (c%2==0 and q[1]=="1") or (c%2==1 and q[1]=="2"):
                d.appendleft(q[2])
            else:
                d.append(q[2])
    if(c%2!=0):
        d.reverse()
    print("".join(d))

if __name__ == '__main__':
    main()

Measured memory_bytes: 35316
import sys
import collections
input = sys.stdin.readline
N = int(input())
tree = [[] for _ in range(N+1)]
tree_cost = [1000000001 for _ in range(N+1)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    tree[a].append([b, c])
    tree[b].append([a, c])
Q, K = map(int, input().split())

queue = collections.deque()
queue.append([K, 0])
tree_cost[K] = 0
while len(queue) > 0:
    now = queue.popleft()
    for next in tree[now[0]]:
        if tree_cost[next[0]] == 1000000001:
            queue.append(next)
            tree_cost[next[0]] = tree_cost[now[0]] + next[1]

for _ in range(Q):
    x, y = map(int, input().split())
    print(tree_cost[x]+tree_cost[y])


Measured memory_bytes: 50032
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define inf 1000000000007;
typedef long long ll;
int main(){
	fast;
	ll rem,n,a,b,ans; cin>>n>>a>>b;
	ans=n/(a+b)*a;
	rem=n%(a+b);
	ans+=min(rem,a);
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
while True:
    try:
        a=list(map(int,input().split()))
        x=0
        y=0
        z=0
        u=0
        w=0
        
        g=1000-a[0]
        if g==1000:
            pass
        else:
            if g>=500:
                x=1
                g=g-500
            y=g//100
            g=g-100*y
            if g>=50:
                z=1
                g=g-50
            u=g//10
            g=g-10*u
            if g>=5:
                w=1
                g=g-5
            print(x+y+z+u+w+g)
    except:
        break;


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

long double l;
int main(){
    cin >> l;
    // cout << l/3 << endl;
    long double ans = l/3 * l/3 * l/3;
    cout << fixed;
    cout << setprecision(12)<< ans << endl;
    // printf("%.12f",ans);

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>



int main(){
	char ss[1100];
	int i,j,flag,mojisu;
	
	memset(ss,0,sizeof(ss));
	
	fgets(ss,sizeof(ss),stdin);
	
	for(i=0;;i++){
		if(ss[i]=='\0')break;
		if(ss[i]==' ' || ss[i]==',' || ss[i]=='.')ss[i]='\0';
	}
	
	flag=0;
	for(i=0;i<1100;i++){
		if(ss[i]!='\0'){
			mojisu=0;
			for(j=i;;j++){
				if(ss[j]!='\0'){
					++mojisu;
				}else{
					break;
				}
			}
			if(2<mojisu && mojisu<7){
				if(flag!=0)printf(" ");
				flag=1;
				for(j=i;mojisu>0;j++){
					printf("%c",ss[j]);
					--mojisu;
				}
			}
			i=j;
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
int main() {
    //入力
    int ans=0,n,q;
    cin >> n;
    long S[100000];
    for (int i = 0; i < n; i++) cin >> S[i];
    cin >> q;
    long T[50000];
    for (int j = 0; j < q; j++) cin >> T[j];
    //処理
    for (int k = 0; k < q; k++) {
        int left, right,mid;
        left = 0; right = n;
        while (left <= right) {
            mid = (left + right) / 2;
            //cout << left << " " << right << endl;
            if (T[k] == S[mid]) {
                ans++;
                break;
            }
            else if (T[k] < S[mid]) {
                //cout << "L" << endl;
                right = mid - 1;
            }
            else {
                //cout << "R" << endl;
                left = mid + 1;
            }
        }
    }
    //出力
    cout << ans << endl;
}


Measured memory_bytes: 4164
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N,K;
    cin >> N >> K;
    VLL h(N);
    rep(i,N){
        cin >> h[i];
    }
    VLL dp(N);
    rep(i,N){
        dp[i]=INF;
    }
    dp[0]=0;
    if(K>=N){
        cout << abs(h[N-1]-h[0]) << endl;
        return 0;
    }
    rep(i,N){
        if(i+K<N){
            rept(j,1,K+1){
                dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
            }
        }
        else{
            rept(j,1,N-i){
                dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));                
            }
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) = println(run {
    val (w,h,n) = readLine()!!.split(" ").map { it.toInt() }
    val a = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }

    var l = 0
    var r = w
    var u = h
    var d = 0
    a.forEach {
        val (x,y,z) = it
        when (z) {
            1 -> l = Math.max(l, x)
            2 -> r = Math.min(r, x)
            3 -> d = Math.max(d, y)
            4 -> u = Math.min(u, y)
        }
    }
    Math.max(0, r-l) * Math.max(0, u-d)

})


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

import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		System.out.println(solve());
	}
	
	String solve() {
		Scanner sc = new Scanner(System.in);
		s = sc.next() + "="; long ans = sc.nextLong();
		long a = add();
//		debug(a);
		p = 0;
		long b = num();
		char c = next();
		while (c != '=') {
			long d = num();
			if (c == '*') b *= d;
			else b += d;
			c = next();
		}
		if (a == ans && b == ans) return "U";
		if (a == ans) return "M";
		if (b == ans) return "L";
		return "I";
	}
	
	String s; int p;
	char next() {
		return s.charAt(p++);
	}
	
	long add() {
		long a = mlt();
		char c = next();
		while (c == '+') {
			long b = mlt();
			a += b;
			c = next();
		}
		p--;
		return a;
	}
	
	long mlt() {
		long a = num();
		char c = next();
		while(c == '*') {
			long b = num();
			a *= b;
			c = next();
		}
		p--;
		return a;
	}
	
	long num(){
		return next() - '0';
	}
	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

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

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

  int ans= 0;
  for(size_t i=0; i<S.size(); i++){
    if(S.at(i) != T.at(i)){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3912
#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
#include<deque>
#include<stack>
#include<queue>
using namespace std;
#define pb push_back
#define ff(i,a,b) for(int i=a;i<b;++i)
#define ffl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
const int md = 1000000007;
#define pi 3.141592653589793238462643383279


int main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
    
 	int tt{},T{};
 	//cin>>tt;T=tt;
    tt=1;
 	while(tt--){
        //cout<<"------------- #"<<T-tt<<endl;
        int n{},m{},ans{},k{},a{},b{},c{},f{};
        
        cin>>n;
        if(n==0){
            cout<<"1\n";
        }else{
            cout<<"0\n";
        }
    }
    
    
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<math.h>
#include<map>
#include<set>
#include<vector>
using namespace std;
#define ll long long 

 
int main() {

	int n, x;
	cin>>n;
	map<ll, ll> _map;
	map<ll, ll> _nap;
	set<ll> _set;

	for(int i = 1; i <= n ;i++) {
		cin>>x;
		_map[i + x] += 1;
		_nap[i - x] += 1;
		_set.insert(i + x);
	}
	ll ans = 0;
	set<ll> :: iterator it = _set.begin();
	for(;it!=_set.end();++it) {
		ans += _map[*it] * _nap[*it];
	}

	cout<<ans<<endl;

}

Measured memory_bytes: 46488
X,K,D = map(int,input().split())
X = abs(X)
X_div_D = X//D

ans_min = X % D

if K <= X_div_D:
  print(X - K * D)
else:
  if (K % 2) ^ (X_div_D % 2) == 0:
    print(ans_min)
  else:
    print(abs(ans_min - D))

Measured memory_bytes: 9180
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
 
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s=new Scanner(System.in);
		int t=s.nextInt();
		System.out.println(t*t);}}

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

using namespace std;

int main(void){
    int N,L;
    int sum = 0;
    int min = 300;
    cin >> N;
    cin >> L;

    for(int i=L; i<N+L; i++){
        sum += i;
        if(abs(min) > abs(i)){
            min = i;
        }
    }
    cout << sum-min <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll n;cin >> n;
	VLL p(n);
	ll ans = 0;
	for (int i = 0;i < n;i++)cin >> p[i];
	for (int i = 0;i < n - 2;i++) {
		if (p[i + 1] > p[i]&& p[i + 2] > p[i + 1]) {
			ans++;
		}
		else if (p[i + 1] < p[i] && p[i + 2] < p[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
A = [0, 0, 0, 0, 0]
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
k = int(input())

flg = 0

for i in range(0, 4, 1):
    if flg == 1:
        break

    for j in range(i+1, 5, 1):
        if k < (A[j] - A[i]):
            flg = 1
            print(":(")
            break

if flg == 0:
    print("Yay!")


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
	int a=0,b=0,c=0,count=0,i=0,min=0;


	scanf("%d %d %d",&a,&b,&c);

	

	for(i=a; i<=b; i++){
	
		if(c%i==0){
			count++;
		}
	}
	
	printf("%d\n",count);
}


Measured memory_bytes: 2104
use itertools::Itertools;
use proconio::input;

fn main() {
    input!(n: usize, station: [(u32, u32, u32); n - 1]);
    let rup = |a, b| (a + b - 1) / b * b;
    let ans = (0..n)
        .map(|i| {
            station[i..]
                .iter()
                .fold(0, |t, &(c, s, f)| c + s.max(rup(t, f)))
                .to_string()
        })
        .collect_vec()
        .join("\n");
    println!("{}", ans);
}


Measured memory_bytes: 2200
// 素数を和を求めるプログラム
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

int main(void)
{
    bool flag = true;
    int n, num, last_num, total_num, sum;
    vector<int> prime;

    // 初期値の設定
    num = last_num = 2;
    prime.push_back(num);

    while(1)
    {
        cin >> n;

        if( n == 0 )
        {
            // 入力終了
            break;
        }

        num = last_num;
        total_num = prime.size();

        // 素数を探索する処理
        // ( ただし, 同じ素数を2回探索しないようする )
        while( total_num <= n )
        {
            num++;
            flag = true;

            for(unsigned int i = 0; i < prime.size(); i++)
            {
                if( num % prime[i] == 0 )
                {
                    // 素数で割り切れる数は, 素数ではない
                    flag = false;
                    break;
                }
            }

            if( flag == true )
            {
                // 素数が見つかった
                prime.push_back(num);
                // 見つかった最後の素数を記憶する
                last_num = num;
                total_num++;
            }
        }

        sum = 0;

        for(int i = 0; i < n; i++)
        {
            // 素数の和を求める
            sum += prime[i];
        }

        printf("%d\n", sum);

    }

    return 0;
}



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

int main(){
    int wh,wm,sh,sm,k;
    cin >> wh >> wm >> sh >> sm >>k;
    wm += wh*60;
    sm += sh*60;
    cout << sm - wm - k << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    string s;
    cin >>s;
    n = s.length();
    for (int i = 0; i < n/2;i++){
        ans += s[i] != s[n - i - 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int , input().split()))

if n >= m:
    print(0)
    exit()

x.sort()
#print(x)
l = [x[i] - x[i-1] for i in range(1, m)]
l.sort(reverse=True)
#print(l)
print(sum(l[n-1:]))

Measured memory_bytes: 56744
#include<iostream>
#include<cstring>
using namespace std;
char s1[100001],s2[100001];
int main()
{
	cin>>s1>>s2;
	int len1=strlen(s1),len2=strlen(s2);
	if(len1!=len2)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	for(int i=0;i<len1;i++)
		if(s1[i]!=s2[len2-i-1])
		{
			cout<<"NO"<<endl;
			return 0;
		}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
ans = 'Good'
tmp = ''
for c in s:
    if tmp == c:
        ans = 'Bad'
    tmp = c
print(ans)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 2e5 + 100;
ll X[MAXN];
ll preX[MAXN];
ll sufX[MAXN];

int main() {
  ll L;
  int N;
  scanf("%lld%d", &L, &N);
  for (int i = 0; i < N; i++)
    scanf("%lld", &X[i]);
  preX[0] = X[0];
  for (int i = 1; i < N; i++)
    preX[i] = preX[i - 1] + X[i];
  sufX[0] = L - X[0];
  for (int i = 1; i < N; i++)
    sufX[i] = sufX[i - 1] + (L - X[i]);

  ll ans = 0;
  for (int lst = 0; lst < N; lst++) {
    do {
      ll sum = X[lst];
      int l = lst;
      int r = N - lst - 1;
      l = min(l, r);
      r = min(r, l + 1);
      if (l < 0)
        break;
      sum += 2 * ((lst - 1 >= 0 ? preX[lst - 1] : 0) - (lst - l - 1 >= 0 ? preX[lst - l - 1] : 0));
      debug("sum %lld\n", sum);
      sum += 2 * (sufX[lst + r] - sufX[lst]);
      debug("sum %lld\n", sum);
      debug("lst %d  %lld (%d %d)\n", lst, sum, l, r);
      ans = max(ans, sum);
    } while (0);
    do {
      ll sum = L - X[lst];
      int l = lst;
      int r = N - lst - 1;
      l = min(l, r + 1);
      r = min(r, l);
      if (r < 0)
        break;
      sum += 2 * (preX[lst - 1] - (lst - l - 1 >= 0 ? preX[lst - l - 1] : 0));
      sum += 2 * (sufX[lst + r] - sufX[lst]);
      debug("lst %d  %lld (%d %d)\n", lst, sum, l, r);
      ans = max(ans, sum);
    } while (0);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int N,i,j,k,Y;
  cin>>N>>Y;
    for(i=0;i<=N;i++){
    for(j=0;i+j<=N;j++){
            k=N-i-j;
        if(i*10000+j*5000+k*1000==Y){
            cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
        }
    }

     
 }
    
    cout<<"-1 -1 -1\n"<<endl;
    

    }

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

using namespace std;

int main(){
	int n; cin >> n;
	int a[n], sum=0;
	int mi=105;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
		if(a[i]%10!=0){
			mi=min(mi,a[i]);
		}
	}
	if(sum%10==0){
		if(mi!=105){
			cout << sum-mi << endl;
		}
		else{
			cout << 0 << endl;
		}
	}
	else{
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b, c, d, disa_b, disb_c, disa_c;
  
  scanf("%d %d %d %d", &a, &b, &c, &d);
  
  (a > b) ? (disa_b = a - b) : (disa_b = b - a);
  (a > c) ? (disa_c = a - c) : (disa_c = c - a);
  (c > b) ? (disb_c = c - b) : (disb_c = b - c);
  if((disa_b <= d && disb_c <= d) || disa_c <= d){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 500;
ll n, k;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  ll ans = 0;
  for(ll i=k; i<=n+1; i++) ans += (n+1-i)*i%MOD+1;
  cout << ans%MOD << endl;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int a , b , c ;
    cin >> a >> b >> c ;

    while ( b < a && c > 0 ) { b++ ; c-- ; }
    cout << c ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define txt freopen("ip.txt", "r", stdin); freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define div2(a) (!(a&1))
#define deb(x) cout<<(#x)<<" "<<(x)<<"\n";
#define newl cout<<"\n" 
#define all(s) s.begin(),s.end()
#define pi 3.14159265358979323846
#define mod 1000000007
#define fp(x) fixed<<setprecision(x)<<
template<class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template<class T>
int sumAllInts(T n){
    int a = 1;
    int su = 0;
    while(n){
        su += n%10;
        n/=10;
    }
    return su;
}
template<class T>
void split(char c,T s){
    int n = s.size();
    int i = 0;
    while ((cout<<s[i],i+=1) && (i<n) && (cout<<c<<' '));
}
void solve(){
    
   ll a,b,c,d; cin>>a>>b>>c>>d;
   ll p = a*c;
   ll q = b*d;
   ll r = a*d;
   ll s = b*c;
   cout<<max(p,max(q,max(r,s)));
    
}
int main(){
    quickie;
    //txt;
    int t= 1;
    while(t--){
        solve(); 
        newl; 
    } 
    return 0;
}

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

#define FOR(i,a,b) for(long long i = (a); i < (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define REP(i,a) for(int i = 0; i < (a); i++)
#define REPD(i,a) for(int i = (a)-1; i >= 0; i--)
#define sz(a) (int)a.size()
#define ALL(a) a.begin(),a.end()

#define ii pair<int,int>
#define fi first
#define se second
#define ll long long
#define N 1e5

using namespace std;

int main()
{
    ll r;
    cin>>r;
    cout<<r*r;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vvi = vector<vector<int>> ;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, n) for(ll i = 0; i < n; i++)



int main(){
  ll n; cin >> n;
  vll a(n);
  ll res = 0;
  rep(i, n){cin >> a[i]; res = (res ^ a[i]);}

  rep(i, n){
    ll ans = (res ^ a[i]);
    if(i != n-1){
    cout << ans << " ";}
    else{cout << ans << endl;}
  }

}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](long a, long b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll n,k,d,num,cnt;
  set<ll> s;
  cin >> n>>k;
  rep(i,k){
    cin >>d;
    rep(j,d){
      cin >> num;
      s.insert(num);
    }
  }
  cout << n-s.size() << endl;
  return 0;
}


Measured memory_bytes: 3520
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 100005
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

int main() {

	int n, i;

	cin>>n;

	if(n <30) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 3628
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    int n = Integer.parseInt(data[0]);
    int m = Integer.parseInt(data[1]);
    
    int time = 1900*m + 100*(n-m);
    int result = (time*(int)Math.pow(2, m));
    System.out.println(result);
  }
}


Measured memory_bytes: 21076
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include<cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include<bitset>

#define REP(i, b, n) for(int i=b;i<(int)n;i++)
#define rep(i, n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it, o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define dbg(x) cout << __LINE__ << ' ' << #x << " = " << (x) << endl


typedef long long ll;

using namespace std;

//ハマったらチェックリスト見ろ!!

int main() {
    string s;
    cin >> s;
    int len = s.length();
    cout << s.substr(0, len - string("FESTIVAL").length()) << endl;

    return 0;
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M, X, Y = il()
    x = il() + [X]
    y = il() + [Y]

    for z in range(-100, 101):
        if max(x) < z <= min(y):
            print('No War')
            exit()
    else:
        print('War')


if __name__ == '__main__':
    main()


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

using namespace std;
typedef pair<int, int> P;
const int MAXN = 200005;
const int INF = 1e9 + 5;
vector<int> G[MAXN];
int n, m;

vector<P> bfs() {
  vector<P> dist(n, make_pair(INF, -1));
  queue<int> que;
  que.push(0);
  dist[0] = P(0, -1);
  while (!que.empty()) {
    int cur = que.front(); que.pop();
    for (int next: G[cur]) {
      if (dist[next].first == INF) {
	que.push(next);
	dist[next] = P(dist[cur].first + 1, cur);
      }
    }
  }
  return dist;
}

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

  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<P> dist = bfs();
  cout << "Yes" << '\n';
  for (int i = 1; i < n; ++i) {
    cout << dist[i].second + 1<< '\n';
  }
  return 0;
}



Measured memory_bytes: 12872
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (auto _x: _a) cerr << _x << ' '; cerr << endl;
#define debugm(a) 		cerr << #a << ":\n"; \
						for (auto v: a) { for(auto x: v) cout << x << ' '; cerr << "\n"; }
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 998244353;

int32_t main()
{
	FAST_IO;
	
	int n;
	cin >> n;
	int a[n];
	for (int& x: a) cin >> x;
	
	int t = 1;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == t) {
			t++;
		} else {
			ans++;
		}
	}
	if (ans == n) cout << -1 << endl;
	else cout << ans << endl;
}


// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, M, P[100];

int main(void){
	//IO("test.in", "test.out");
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &P[i]);
	scanf("%d", &M);
	for(int i = 0; i < M; i++){
		int p, x, t = 0;
		scanf("%d%d", &p, &x);
		for(int j = 0; j < N; j++)
			if(j == p - 1) t += x;
			else t += P[j];
		printf("%d\n", t);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    
    
    
    int main() {
     
     char ch,h;// int h;
     while(true){
        scanf("%c",&ch);
        
        if(ch=='\n')  break;
     	if(isalpha(ch)){//アルファベットの場合
     		if(islower(ch))  h=toupper(ch);
     		else              h=tolower(ch);
     		
     		std::cout << h;
     	} else{
     		cout << ch;
     	}
     }	
     	cout <<'\n';
    
     return 0;
    }


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


int N;
int K;

vector<int> cou(200010,0);

int main()
{
	cin >> N >> K;
	int a;
	int k = 0;
	for(int i = 0;i < N;i++)
	{
		cin >> a;
		if(cou[a] == 0)
			k++;

		cou[a]++;
	}

	sort(cou.begin(),cou.end());

	int result = 0;
	int c = 0;
	for(int i = 0;i < cou.size();i++)
	{
		if(c >= k - K) break;
		if(cou[i] == 0)
		{
			continue;
		}
		result += cou[i];
		c++;
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    ll n;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++)cin>>s[i];
    map<string,int> mp;
    for(int i=0;i<n;i++){
        mp[s[i]]++;
    }
    int cnt = 0;
    for(auto i:mp)cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 25496
#define _USE_MATH_DEFINES
#include<iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int n;
	char *ch;
	cin >> n;
	ch = new char[n];

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

	string str = "";
	int countr = 0;
	int countl = 0;
	int addl = 0;
	int addr = 0;
	int buffl = 0;
	for (int i = 0; i < n; i++){

		if (ch[i] == '('){
			countl++;
			buffl++;
		}
		else if (ch[i] == ')'){
			buffl--;
			if (buffl < 0){
				addl++;
				buffl = 0;
			}
		}
	}


	addr = countl - (n - countl) + addl;

	for (int i = 0; i < addl; i++){
		str = str + '(';
	}

	for (int i = 0; i < n; i++){
		str = str + ch[i];
	}

	for (int i = 0; i < addr; i++){
		str = str + ')';
	}

	cout << str;

	return 0;
}

Measured memory_bytes: 256
// abc171_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N;
    cin >> N;

    ll n = 0;
    REPN(i, 1, 100){

        if (N <= n + pow(26, i)){
            ll x = N - n - 1;
            string ans;
            REP(k, i){
                char s = (char)(x % 26) + 'a';
                ans += s;
                x /= 26;
            }
            reverse(ALL(ans));
            print(ans);
            return 0;
        }

        n += pow(26, i);
    }


    return 0;
}


Measured memory_bytes: 4056
import java.util.Scanner;

public class Main {
	//half and half


	public static void main(String[] args){
		int A,P;
		Scanner sc = new Scanner(System.in);
		A=sc.nextInt();
		P=sc.nextInt();
		int n=A*3+P;
		System.out.println(n/2);


	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int i,j;
  int ans=0;
  for(j=0;j<n;j++){
    int x=0;
    for(i=0;i<=j;i++){
      if(s.at(i)=='I'){
        x++;
      }
      if(s.at(i)=='D'){
        x--;
      }
    }
     ans=max(ans,x);
  }
  cout << ans;
}


Measured memory_bytes: 256