akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;

int main() {
    sll n;
    cin >> n;
    vector<sll> hs(n);
    vector<sll> dp(n);

    REP(i, n) {
        cin >> hs[i];
    }

    REP(i, n) {
        if (i == 0) {
            dp[i] = 0;
        } else if (i == 1) {
            dp[i] = abs(hs[1] - hs[0]);
        } else {
            dp[i] = min(
                abs(hs[i] - hs[i - 1]) + dp[i - 1],
                abs(hs[i] - hs[i - 2]) + dp[i - 2]
            );
        }
    }

    cout << dp[n - 1] << endl;
    return 0;
}

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

int main(){
  int n,k;
  std::cin >> n>>k;
  std::vector<bool> v(n,false);

  int d;
  rep(i,k){
    std::cin >> d;
    rep(j,d){
      int temp;
      std::cin >> temp;
      temp--;
      v[temp]=true;
    }
  }

  int ans=0;
  rep(i,n)if(v[i]==false)ans++;
  std::cout <<ans << '\n';

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main(){
  int n;
  cin >>n;
  int a[n];
  double sum =0;
  for(int i=0; i<n; i++){
    cin >>a[i];
    sum += (double)1/a[i];
  }
  cout <<1/sum;
}


Measured memory_bytes: 888
# フェルマーの小定理
N, K = map(int, input().split())

m = 1000000007


def make_factorial_table(n):
    result = [0] * (n + 1)
    result[0] = 1
    for i in range(1, n + 1):
        result[i] = result[i - 1] * i % m
    return result


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


n = max(K, N - K + 1)
fac = make_factorial_table(n)

result = []
for i in range(1, K + 1):
    result.append(mcomb(K - 1, i - 1) * mcomb(N - K + 1, i) % m)
print('\n'.join(str(i) for i in result))
#print(*result, sep='\n')


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < N; i++)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main() {
  int H, W;
  cin >> H >> W;
  string a[H];
  REP(i, H) cin >> a[i];

  // C++17
  // string('#', W + 2) << endl;
  REP(i, W + 2) cout << '#';
  cout << endl;

  REP(i, H) {
    string line = "#" + a[i] + "#";
    cout << line << endl;
  }

  REP(i, W + 2) cout << '#';
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807/2;
const int MOD = 1000000007;
const int N_MAX = pow(10,5);

int main() {
  int N; cin >> N;
  int a[N+1][3]; for(int i=1; i<=N; i++) rep(j, 3) cin >> a[i][j];

  ll dp[N_MAX+1][3] = {};
  for (int i=1; i<=N; i++) {
    rep(j, 3) rep(k, 3) {
      if (j!=k) dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i][j]);
    }
  }
  // rep(i, N+1) rep(j, 3) cout << dp[i][j] << " "; cout << endl;
  ll result = 0; rep(i, 3) result = max(result, dp[N][i]);
  cout << result << endl;
  return 0;
}

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

signed main(){
  int k;
  cin>>k;
  int N=pow(4,10);
  int ans=0;
  int a,b,c;
  for(int i=0;i<N;i++){
    int j=0;
    a=b=c=0;
    int l=1;
    int x=i;
    for(int zz=0;zz<10;zz++){
      if(x%4==1){a++;j+=l*3;}
      if(x%4==2){b++;j+=l*5;}
      if(x%4==3){c++;j+=l*7;}
      x/=4;
      l*=10;
    }
    int p=0;
    int v=j;
    while(v){p++;v/=10;}
    if(a+b+c==p&&a&&b&&c&&j<=k)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll a,b,x; cin >> a >> b >> x;
    if(a>x) puts("NO");
    else if(x-a>b) puts("NO");
    else puts("YES");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int X;
	public  static void main(String[]args) {
		Scanner sc= new Scanner(System.in);
		X=sc.nextInt();
		if(X>=30) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		}
	}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int n = ri();
	int c[2 * n];
	int a[2 * n];
	int pos_w[n];
	int pos_b[n];
	for (int i = 0; i < n * 2; i++) {
		std::string s;
		std::cin >> s;
		c[i] = s[0] == 'B';
		a[i] = ri() - 1;
		if (c[i]) pos_b[a[i]] = i;
		else pos_w[a[i]] = i;
	}
	int b_before_b[n];
	for (int i = 0; i < n; i++) {
		b_before_b[i] = 0;
		for (int j = 0; j < i; j++) if (pos_b[j] < pos_b[i]) b_before_b[i]++;
	}
	int w_before_w[n];
	for (int i = 0; i < n; i++) {
		w_before_w[i] = 0;
		for (int j = 0; j < i; j++) if (pos_w[j] < pos_w[i]) w_before_w[i]++;
	}
	int b_before_w[n][n + 1]; // [i][j] : b >= j after i-th w
	for (int i = 0; i < n; i++) {
		int pos = pos_w[i];
		int cnt = 0;
		b_before_w[i][0] = 0;
		for (int j = 0; j < n; j++) {
			if (pos_b[j] < pos) cnt++;
			b_before_w[i][j + 1] = cnt;
		}
	}
	int w_before_b[n][n + 1]; // [i][j] : w >= j after i-th b
	for (int i = 0; i < n; i++) {
		int pos = pos_b[i];
		int cnt = 0;
		w_before_b[i][0] = 0;
		for (int j = 0; j < n; j++) {
			if (pos_w[j] < pos) cnt++;
			w_before_b[i][j + 1] = cnt;
		}
	}
	/*
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) std::cerr << b_after_w[i][j] << " ";
		std::cerr << std::endl;
	}*/
	int dp[n + 1][n + 1];
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++) dp[i][j] = 10000000;
	dp[0][0] = 0; // w, b
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			// std::cerr << "i:" << i << " j:" << j << std::endl;
			if (i < n) { // use w
				int cost = pos_w[i] - b_before_w[i][j] - w_before_w[i];
				// std::cerr << "  cost:" << cost << std::endl;
				assert(cost >= 0 && cost < 2 * n);
				dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j] + cost);
			}
			if (j < n) { // use b
				int cost = pos_b[j] - w_before_b[j][i] - b_before_b[j];
				// std::cerr << "  cost:" << cost << std::endl;
				assert(cost >= 0 && cost < 2 * n);
				dp[i][j + 1] = std::min(dp[i][j + 1], dp[i][j] + cost);
			}
		}
	}
	/*
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			std::cerr << "dp[" << i << "][" << j << "] : " << dp[i][j] << std::endl;
		}
	}*/
	std::cout << dp[n][n] << std::endl;
	return 0;
}


Measured memory_bytes: 47232
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process(int test_number)throws IOException
    {
        char s[] = nln().toCharArray(), t[] = nln().toCharArray();
        int n = s.length, m = t.length;
        int res = 123456, cnt = 0;

        for(int i = 0; i + m - 1 < n; i++){
            cnt = 0;
            for(int j = 0, k = i; j < m && k < n; j++, k++){
                if(s[k] != t[j])
                    cnt++;
            }

            res = Math.min(res, cnt);
        }        

        pn(res);
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


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

int pos;
int a,b,c,d;
string s;

int Hash(void){
	int ret;
	if(s[pos]=='['){
		++pos;
		int L,R;
		if(s[pos]=='+'){
			++pos;
			L=Hash();	R=Hash();
			ret=L|R;
		}else if(s[pos]=='*'){
			++pos;
			L=Hash();	R=Hash();
			ret=L&R;
		}else if(s[pos]=='^'){
			++pos;
			L=Hash();	R=Hash();
			ret=L^R;
		}

		++pos;
		return ret;
	}

	if(s[pos]=='a')ret=a;
	if(s[pos]=='b')ret=b;
	if(s[pos]=='c')ret=c;
	if(s[pos]=='d')ret=d;

	++pos;
	return ret;
}

int main(){
	while(1){
		cin>>s;		if(s==".")break;
		string p;	cin>>p;
		a=p[0]-'0';
		b=p[1]-'0';
		c=p[2]-'0';
		d=p[3]-'0';

		pos=0;
		int H=Hash();

		int ans=0;
		for(int i=0; i<10000; i++){
			a=i/1000;
			b=(i%1000)/100;
			c=(i%100)/10;
			d=i%10;

			pos=0;
			if(H==Hash())ans++;
		}

		printf("%d %d\n",H,ans);
	}

	return 0;
}



Measured memory_bytes: 3268
using System;

namespace ABC333A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var A = int.Parse(input[0]);
            var B = int.Parse(input[1]);

            var flag = false;

            for (int C = 1; C < 4; C++)
            {
                if ((A*B*C)%2 != 0)
                {
                    flag = true;
                }
            }

            if (flag)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
N, H = map(int, input().split())
ab = [[int(i) for i in input().split()] for _ in range(N)]

a = 0
for i in range(N):
    a = max(a, ab[i][0])

b = []
for i in range(N):
    if ab[i][1] > a:
        b.append(ab[i][1])
b.sort(reverse=True)

w = True
c = 0
h = H
for i in range(len(b)):
    h -= b[i]
    c += 1
    if h <= 0:
        print(c)
        w = False
        break

if w:
    print(c + (h-1)//a + 1)


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

int main() {
  ll n,k;cin>>n>>k;
  ll a=n%k;
  ll ans=min(a,k-a);
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;

void solve(int t)
{
    ll i,j,n,m,ans=1,ct=0;
    cin >> n >> m;
    ll A[n+5];
    for(i=0; i<n; i++)
    {
        cin >> A[i];
        A[i] /= 2;
        ans = (ans*A[i])/__gcd(ans,A[i]);
        if(ans>m)
            ct=1;
    }
    for(i=n-1; i>=0; i--)
    {
        if((ans/A[i])%2==0 || ct)
        {
            cout <<0<<endl;
            return ;
        }
    }
    ct = m/ans;
    cout <<(ct+1)/2<<endl;
    return ;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
   // cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}



Measured memory_bytes: 4336
#include<iostream>
#include<vector>
#include<string>

int main(){
    long long r, D, xBase;
    std::cin >> r >> D >> xBase;
    for(int i = 0; i < 10; i++){
        long long x = r * xBase - D;
        std::cout << x << std::endl;
        xBase = x;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
ll GCD(ll a, ll b){
    if(b==0) return a;
    else return GCD(b,a%b);
}
 
int main(){
    ll n,m; cin >> n >> m;
    string s,t; cin >> s >> t;
    ll g = GCD(n,m);
    ll ans = n * m / g;
    vector<pair<ll, char>> v;
    rep(i,n){
        v.emplace_back(i*ans/n,s[i]); 
    }
    rep(i,m){
        ll left = 0, right = v.size();
        ll mid;
        ll p = -1;
        while(left < right){
            mid = (left+right)/2;
            if(i*ans/m==v[mid].first){
                p = mid;
                break;
            }
            if(i*ans/m > v[mid].first){
                left = mid+1;
            }
            if(i*ans/m < v[mid].first){
                right = mid;
            }
        }
        if(p != -1 && v[p].second != t[i]){
            ans = -1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2744
#include<iostream>
using namespace std;
int M[100][100] = {};
int color[100] = {};
int d[100] = {}, f[100] = {};
int cot=0;
int n;

void dps(int u) {
	if (color[u] == 0) {
		cot++;
		d[u] = cot;
		color[u]++;
	}

	for (int t = 0;t < n;t++) {
		if (M[u][t] == 1) {
			if(color[t]==0){
			    dps(t);
			}
			
			
		}
	}
	if (color[u] == 1) {
        cot++;
	    f[u] = cot;
		color[u]++;
	}
	
	return;

}
int main(){
	int k,m,j;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> m>>k;
		for (int l = 0;l < k;l++) {
			cin >> j;
			M[m - 1][j - 1] = 1;
		}
	}
	for (int i = 0;i < n;i++) {
		if (color[i] == 0) {
			dps(i);
		}
	}


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

	return 0;
}


Measured memory_bytes: 3128
import sys
import os

def file_input():
    f = open('ARC069/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    N,M=map(int, input().split())

    if N*2>=M:
        print(str(M//2))
    else:
        M-=N*2
        print(str(N+M//4))

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    if (A > W / 2 || B > H / 2) {
        puts("No");
        return 0;
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            const char c = '0' + ((i < B) ^ (j < A));
            putchar(c);
        }
        putchar('\n');
    }
}


Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
    int a,b,add,sub,mul;
    scanf("%d%d",&a,&b);
    add=a+b;
    sub=a-b;
    mul=a*b;
    if(add>sub&&add>mul)
        printf("%d",add);
    else if(sub>mul)
        printf("%d",sub);
    else
        printf("%d",mul);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384
 
using namespace std;
using ll =long long;
using P = pair<int,int>;
 
#define INF 1000000000000000000
//1000000000000000000
//2147485794483647
int main(int argc, const char * argv[]) {
    ll n;
    cin >> n;
    
    unsigned long long ans=1;
    rep(i, n){
        unsigned long long m;
        cin >> m;
        if(m==0) ans = 0;
        else if(ans>INF/m) ans=INF+1;
        else ans = ans * m;
    }
    
    if(ans>INF) cout << -1;
    else cout << ans;
    
    return 0;
}



Measured memory_bytes: 3604
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
A = getList()

cnt = 0
for i in range(N):
    if i % 2 == 0 and A[i] % 2 == 1:
        cnt += 1
print(cnt)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int H, W; cin >> H >> W;
	char c[105][105];

	bool a[105], b[105];
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));

	for (int i = 0;i < H;i++){
		bool flag = true;
		for (int j = 0;j < W;j++){
			cin >> c[i][j];
			if(c[i][j] != '.') flag = false;
		}
		if(flag) a[i] = true;
	}

	for (int j = 0;j < W;j++){
		bool flag = true;
		for (int i = 0;i < H;i++){
			if(c[i][j] != '.') flag = false;
		}
		if(flag) b[j] = true;
	}

	for (int i = 0;i < H;i++){
		for (int j = 0;j < W;j++){
			if(a[i] || b[j]) continue;
			cout << c[i][j];
		}
		if(!a[i])cout << endl;
	}

	return 0;

}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll k, x;
    cin >> k >> x;

    Yn(500 * k >= x)
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void main(String[] args) {
		int a=scan.nextInt();
		String str=scan.next();
		int x[]=new int[a];
		int y[]=new int[a];
		int cnt=0;
		int cnte=0;
		for(int i=0;i<a;i++) {
			char ch=str.charAt(i);
			if(ch=='W')cnt++;
			else cnte++;
			x[i]=cnt;
			y[i]=cnte;
		}
		int min=1145141919;
		for(int i=0;i<a;i++) {//リーダー(i)
			int east=i==0?0:x[i-1];//右を向かなきゃいけない人
			int west=y[a-1]-y[i];//Eの人
			int sum=east+west;
			min=min(min,sum);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 31288
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
const int maxn = 100010;
const int INF = INT_MAX/2;

int n;
vector <pi> v;
int pre[maxn],suf[maxn];

int dist(int x, int y) {
	return max(y - x + 1,0ll);
}

int32_t main() {
	FAST
	cin >> n;
	v.push_back(pi(0,0));
	for (int i =1;i<=n;i++) {
		int a,b; cin >> a >> b;
		v.push_back(pi(a,b));
	}
	sort(all(v));
	
	//CASE 1: All .f of group 1 < All .f of group 2
	//prefix[i] from 1 to i
	int maxl=0, minr=INF;
	
	for (int i = 1;i<=n;i++) {
		maxl = max(maxl,v[i].f); 
		minr = min(minr,v[i].s);
		
		pre[i] = dist(maxl,minr);
	}
	int whack = pre[n];
	
	//Suffix[i] from n to i+1
	maxl = 0; minr = INF;
	for (int i =n-1;i>=1;i--) {
		maxl = max(maxl,v[i+1].f);
		minr = min(minr,v[i+1].s);
		
		suf[i] = dist(maxl,minr);
	}
	int ans = 0;
	for (int i =1;i<n;i++) {
		ans = max(ans, pre[i] + suf[i]);
	}
	
	//CASE 2: Just take largest guy for group 1 and throw the rest into group 2.
	
	for (int i =1;i<=n;i++) {
		ans = max(ans, whack + dist(v[i].f,v[i].s));
	}
	cout << ans;
}








Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a, b, c;
 cin >> a;
 b = a / 3600;
 a -= b * 3600;
 c = a / 60;
 a -= c * 60;
 cout << b << ":" << c << ":" << a << endl;
}



Measured memory_bytes: 3120
import java.util.*;

public class Main {
    private class Sina {
        long num;
        long value;

        public Sina(long n, long v) {
            num = n;
            value = v;
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        long k = sc.nextLong();
        Sina sina[] = new Sina[n];
        for (int i = 0; i < n; i++) {
            sina[i] = new Sina(sc.nextLong(), sc.nextLong());
        }
        Arrays.sort(sina, (o1, o2) -> Long.compare(o1.num, o2.num));

        long ans = 0;
        for (int i = 0; i <= 30; i++) {
            if (i > 0 && (k >> (i - 1)) % 2 == 0) {
                continue;
            }

            long kr = (i == 0) ? k : ((k >> i) << i) + ((1 << (i - 1)) - 1);
            long sum = 0;
            for (int j = 0; j < n; j++) {
                if ((kr & sina[j].num) != sina[j].num) {
                    continue;
                }

                sum += sina[j].value;
            }
            ans = Math.max(ans, sum);
        }

        System.out.println(ans);
    }

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


Measured memory_bytes: 95216
import numpy as np

h, w = map(int, input().split())
grid = np.array([[j for j in input()] for i in range(h)])
grid = np.array([x for x in grid if "#" in x])
grid = np.array([x for x in grid.T if "#" in x])

[print("".join(x)) for x in grid.T]

  
    

Measured memory_bytes: 12452
fn lower_bound<T: std::cmp::Ord>(arr: &Vec<T>, b: T) -> usize {
    let (mut lt, mut ge) = (0, arr.len());
    // lt=-1にすると型強制しなきゃなのでここで確かめる
    if arr[lt] >= b {
        return 0;
    }
    while lt + 1 < ge {
        let m = (lt + ge) / 2;
        if arr[m] < b {
            lt = m;
        } else if arr[m] > b {
            ge = m;
        } else {
            return m;
        }
    }
    ge
}

fn main() {
    let n = read();
    let mut v: Vec<usize> = vec![];
    for _ in 0..n {
        v.push(read());
    }
    let mut dp = vec![std::usize::MAX; n];
    let mut ans = 0;
    for i in 0..n {
        let b = lower_bound(&dp, v[i]);
        dp[b] = v[i];
        ans = max(ans, b + 1);
    }
    println!("{}", ans);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 7072
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;


int main(){

    int n;
    cin >> n;

    vector<int> a;
    int absmax_index = 0;

    vector<pair<int,int>> ansv;

    rep(i,n){
        int tmp;
        cin >> tmp;
        a.pback(tmp);
        if(abs(a[absmax_index]) < abs(tmp)){
            absmax_index = i;
        }
    }

    rep(i,n){
        if(i != absmax_index){
            a[i] += a[absmax_index];

            ansv.pback(mpair(absmax_index + 1, i + 1));
        }
    }

    a[absmax_index] += a[absmax_index];
    ansv.pback(mpair(absmax_index + 1, absmax_index + 1));

    if(a[absmax_index] >= 0){

        for(int i = 1; i < n; i++){
            if(a[i - 1] > a[i]){
                a[i] += a[i - 1];
                ansv.pback(mpair(i ,i + 1));
            }
        }

    }else{

        for(int i = n - 1; i - 1 >= 0; i--){
            if(a[i - 1] > a[i]){
                a[i - 1] += a[i];
                ansv.pback(mpair(i + 1,i));
            }
        }
    }

    assert(ansv.size() <= n * 2);

    rep(i,n){
        cerr << a[i] << " ";
    }
    cerr << endl;

    cout << ansv.size() << endl;

    rep(i, ansv.size()){
        cout << ansv[i].first << " " << ansv[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
D = gets.split.map &:to_i
M = gets.to_i
T = gets.split.map &:to_i
h = Hash.new 0
D.each{|d|
  h[d] += 1
}
puts T.all?{|t|
  0 <= h[t] -= 1
} ? :YES : :NO


Measured memory_bytes: 42020
#include<stdio.h>

#define N 20
#define Q 200

int A[N],m[Q];
int n,q,i;
int flag;

void solve(int i,int x){
   
  if(x == 0) flag = 1;
  else if(i != n){
    solve(i+1, x-A[i]);
    solve(i+1,x);
  }
}

int main(){
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) scanf("%d",&m[i]);
  for(i=0; i<q; i++){
    flag = 0;
    solve(0, m[i]);
    if(flag==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define PF push_front
#define PB push_back
#define FST first
#define SEC second
#define sz(obj) ((int)(obj).size())
#define ALL(v) (v).begin(), (v).end()

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in() {int x; std::cin >> x; return x;}
 
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

int gcd(int a, int b){ int c; while (a != 0){ c = a; a = b % a; b = c; } return b; }

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

  int n = in(), k = in(), x = in(), y = in();
  
  print(n <= k ? n * x : k * x + (n - k) * y);

  return (0);
}


Measured memory_bytes: 764
ans = 0
used = False
mins = [int(input()) for _ in range(5)]
maa = list(map(lambda x:(x%10, x), filter(lambda x:x%10, mins)))
m = (0,0) if len(maa) == 0 else sorted(maa)[0]
for menu in mins:
  if used==False and menu==m[1]:
    used=True
    continue
  ans += (menu//10)*10 + 10*(menu%10>0)
print(ans + m[1])

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int e,y;

int main(){
	cin>>e>>y;
	if(!e){
		if(y<1912) cout<<'M'<<y-1867<<endl;
		else if(y<1926) cout<<'T'<<y-1911<<endl;
		else if(y<1989) cout<<'S'<<y-1925<<endl;
		else cout<<'H'<<y-1988<<endl;
	}
	else{
		if(e==1) y+=1867;
		if(e==2) y+=1911;
		if(e==3) y+=1925;
		if(e==4) y+=1988;
		cout<<y<<endl;
	}
}

Measured memory_bytes: 3120
import math

def calc_dist(pta, ptb):
    return abs(pta[0] - ptb[0]) + abs(pta[1] - ptb[1])

n, m = map(int, input().split())
stdts = [tuple(map(int, input().split())) for _ in range(n)]
cpts = [tuple(map(int, input().split())) for _ in range(m)]

for stdt in stdts:
    dist_min = math.inf
    for i in range(m):
        dist = calc_dist(stdt, cpts[i])
        if dist < dist_min:
            dist_min = dist
            ans = i + 1
    print(ans)


Measured memory_bytes: 9092
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
  string s, t;
  cin >> s;
  
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') t += "0";
    else if (s[i] == '1') t += "1";
    else if (t.size() != 0) t.pop_back();
  }
  cout << t;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int p[n], count=0;
  for(int i=0;i<n;i++) cin>>p[i];
  for(int i=0;i<n-2;i++){
    if(p[i]<p[i+1]&&p[i+1]<p[i+2] ||
      p[i]>p[i+1]&&p[i+1]>p[i+2] ) count++;
  }
  cout<<count<<endl;
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<b) {
		cout<<"a < b"<<endl;
	} else if (a>b) {
		cout<<"a > b"<<endl;
	} else if (a==b) {
		cout<<"a == b"<<endl;
	}
	return 0;			
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main(){string s;cin>>s;int n=s.size();vector<char> v;for(int i=0;i<n;i++){switch(s[i]){case '0':v.push_back('0');break;case '1':v.push_back('1');break;case 'B':if(v.empty()){break;}v.pop_back();}}for(auto&& i:v){cout<<i;}puts("");}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int main(){
	int n,a,b;
	cin>>n;
	if(n==1){
		cout<<"Hello World"<<endl;
	}else{
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

long long n;
std::vector<char> ans;

int main()
{
	scanf("%lld", &n);
		
	
	ans.clear();
	while (n > 0) {
		n--;		
		int r = n % 26;
		n = n / 26;
		char ch = r + 'a';
		ans.push_back(ch);
				
	}
	
	for (int i = ans.size() - 1 ; i >= 0 ; i--)
		printf("%c", ans[i]);
//	printf("%c", ans[0]);
	printf("\n");
		
	return 0;
}


Measured memory_bytes: 3176
N = int(input())
X = list(map(int, input().split()))
X_sort = sorted(X)

for i in range(N):
    if X[i] <= X_sort[N // 2 - 1]:
        print(X_sort[N // 2])
    elif X_sort[N // 2] <= X[i]:
        print(X_sort[N // 2 - 1])


Measured memory_bytes: 26016
#include <iostream>
#include <algorithm>
#include <string>
typedef long long ll;
using namespace std;
int x[105],y[105];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,X,Y,c=0;cin>>n>>m>>X>>Y;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<m;i++){
        cin>>y[i];
    }
    sort(x,x+n);sort(y,y+m);
    if(x[n-1]<y[0]&&X<x[n-1]&&x[n-1]<=Y&&X<y[0]&&y[0]<=Y)cout<<"No War"<<endl;
    else cout<<"War"<<endl;
    
    return 0;
}


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

struct POINT
{
	int r, c;
	POINT(int r = 0, int c = 0) :r(r), c(c) {}
};

POINT dir[4] = { POINT(-1, 0), POINT(0, 1), POINT(1, 0), POINT(0, -1) };

int main()
{
	int H, W; cin >> H >> W;

	vector<vector<int>>grid(H, vector<int>(W, 1e9));
	vector<vector<int>>status(H, vector<int>(W, 0));
	queue<pair<POINT, int>>black;

	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++)
	{
		char c; cin >> c;

		if (c == '#')
		{
			black.push(make_pair(POINT(i, j), 0));
		}
	}

	int ans = 0;

	while (black.size())
	{
		pair<POINT, int> pi = black.front();
		black.pop();
		POINT p = pi.first;
		int dist = pi.second;

		if (status[p.r][p.c] == 1 || grid[p.r][p.c] <= pi.second)continue;
		grid[p.r][p.c] = pi.second;
		status[p.r][p.c] = 1;

		ans = max(ans, pi.second);

		for (int k = 0; k < 4; k++)
		{
			POINT np;
			np.r = p.r + dir[k].r;
			np.c = p.c + dir[k].c;

			if (np.r < 0 || np.r >= H || np.c < 0 || np.c >= W)continue;

			if (status[np.r][np.c] == 1)continue;
			if (grid[np.r][np.c] > pi.second + 1)
			{
				black.push(make_pair(np, pi.second + 1));
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 32436
import sys

stdin = sys.stdin


def na(): return map(int, stdin.readline().split())


def ns(): return stdin.readline().strip()

def bf(es, n, start, ved):
    I = 999999999999999999
    d = [I] * n
    d[start] = 0

    for i in range(n-1):
        updated = False
        for e in es:
            if not ved[e[0]]: continue
            if not ved[e[1]]: continue
            if d[e[0]] + e[2] < d[e[1]]:
                d[e[1]] = d[e[0]] + e[2]
                updated = True
        if not updated: break
    for e in es:
        if not ved[e[0]]: continue
        if not ved[e[1]]: continue
        if d[e[0]] + e[2] < d[e[1]]:
            return None
    return d

def go(start, g, ind):
    n = len(g)
    ved = [False] * n
    q = [start]
    j = 0
    ved[start] = True
    while(j < len(q)):
        cur = q[j]
        for e in g[cur]:
            if not ved[e[ind]]:
                ved[e[ind]] = True
                q.append(e[ind])
        j += 1
    return ved

n,m = na()
es = []

for i in range(m):
    a,b,c = na()
    es.append([a-1,b-1,-c])

g = [[] for _ in range(n)]
for e in es:
    g[e[0]].append(e)

ig = [[] for _ in range(n)]
for e in es:
    ig[e[1]].append(e)


ved = go(0, g, 1)
ived = go(n-1, ig, 0)

for i in range(n):
    ved[i] &= ived[i]

res = bf(es, n, 0, ved)
if res:
    print(-res[n-1])
else:
    print("inf")

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

int main() {
	// your code goes here
	int n, cnt=0, light;
	cin >> n;
	
	int a[n+1];
	
	map<int, int> v;
	
	for(int i=1; i<=n; i++) cin >> a[i];
	
	light = a[1];
	
	while(v[2] != 1){
		if(v[light] == 0){
			v[light] = 1;
			cnt++;
		}else{
			cout << -1 << endl;
			return 0;
		}
		light = a[light];
	}
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 5376
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

r, g, b = MAP()
print("YES" if (10*g+b)%4 == 0 else "NO")

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

public class MainApp
{
    static public void Main(string[] args)
    {
        string read = Console.ReadLine();
        string[] split = read.Split(' ');
        int N = int.Parse(split[0]);
        int K = int.Parse(split[1]);
        split = Console.ReadLine().Split(' ');
        List<int> l = new List<int>();
        for (int i = 0; i < N; i++)
        {
            l.Add(int.Parse(split[i]));
        }
        l.Sort();
        l.Reverse();
        int output = 0;
        for (int i = 0; i < K;i++)
        {
            output += l[i];

        }
        Console.WriteLine(output);

    }

}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define _1 first
#define _2 second
using namespace std;
const int N=2050;
char s[N][N<<3];
int n,k,len[N];
bitset<N<<3> f[N];
pair<int,int> v[2][N<<3];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i){
		scanf("%s",s[i]+1);
		len[i]=strlen(s[i]+1);
	}
	f[n+1][0]=1;
	for(int i=n;i>=1;--i)
		f[i]=f[i+1]|(f[i+1]<<len[i]);
	int cnt=0;
	for(int i=1;i<=n;++i)
		if(f[i+1][k-len[i]]) 
			v[1][++cnt]=make_pair(i,1);
	for(int t=1;t<=k;++t){
		int i=t&1;
		char ch='z'; 
		int ncnt=0;
		for(int j=1;j<=cnt;++j)
			ch=min(ch,s[v[i][j]._1][v[i][j]._2]);
		putchar(ch);
		int nw=n+1;
		for(int j=1;j<=cnt;++j)
		{
			if(s[v[i][j]._1][v[i][j]._2] != ch) 
				continue;
			if(v[i][j]._2<len[v[i][j]._1]) 
				v[i^1][++ncnt]=make_pair(v[i][j]._1 , v[i][j]._2+1);
			else nw=min(nw, v[i][j]._1);
		}
		for(int j=nw+1;j<=n;++j)
			if(k-t-len[j]>=0&&f[j+1][k-t-len[j]]) v[i^1][++ncnt]=make_pair(j,1);
		cnt=ncnt;
	}
	return 0;
}


Measured memory_bytes: 37120
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX 200000

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair< ll , P > PP;
priority_queue< P, vector<P> , greater<P> > AX,AY;
priority_queue< P > BX,BY;
ll n,d,x,y,b;
vector< PP > t;


P funcA(priority_queue< P , vector< P> , greater<P> > &Q,ll b){
  P res;
  while(1){
    res=Q.top();
    if(b-res.second>d)Q.pop();
    else break;
  }
  return res;
}


P funcB(priority_queue< P > &Q,ll b){
  P res;
  while(1){
    res=Q.top();
    if(b-res.second>d)Q.pop();
    else break;
  }
  return res;
}

int main(){
  scanf("%lld %lld",&n,&d);
  t.resize(n);
  for(ll i=0;i<n;i++){
    scanf("%lld %lld %lld",&x,&y,&b);
    t[i]=PP(b,P(x,y));
  }
  sort(t.begin(),t.end());
  ll ans=0;
  P ax,ay,bx,by;
  for(int i=0;i<n;i++){
    b=t[i].first;
    x=t[i].second.first;
    y=t[i].second.second;
    AX.push(P(x,b));    
    AY.push(P(y,b));
    BX.push(P(x,b));
    BY.push(P(y,b));
    ax=funcA(AX,b);
    ay=funcA(AY,b);
    bx=funcB(BX,b);
    by=funcB(BY,b);
    ans=max(ans,(bx.first-ax.first)*(by.first-ay.first));
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 22740
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[200000],b[200000];
int n,m;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&b[i]);
	}
	if(n<m)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	int tmp=1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[tmp])tmp++;
	}
	if(tmp>m)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
} 

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int N;
  string str;
  cin>>N;
  cin>>str;
  int COUNT = 0;
  for (int i = 1; i < N; i++)
  {
    if(str[i] == 'E')COUNT++;
  }

  int ANS = COUNT;
  for (int i = 0; i < N-1; i++)
  {
    if(str[i+1] == 'E')COUNT--;
    if(str[i] =='W')COUNT++;
    chmin(ANS,COUNT);
  }
  cout<<ANS<<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}

Measured memory_bytes: 720
def main():
    s = input()
    s = s[::-1]
    

    i = 0
    f = True
    while i < len(s):
        if s[i:i+5] == "maerd":
            i += 5
        elif s[i:i+5] == "esare":
            i += 5
        elif s[i:i+6] == "resare":
            i += 6
        elif s[i:i+7] == "remaerd":
            i += 7
        else:
            f = False
            break

    if f:
        print("YES")
    else:
        print("NO")


    

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <stdio.h>

int main()
{
    int n,y;
    scanf("%d %d", &n, &y);
    y/=1000;
    int a,b,c,res=0;
    int ra,rb,rc;
    for(int i=0;i<=n;i++){
        a=n-i;
        for(int j=0;j<=n-a;j++){
            b=n-a-j;
            c=j;
            if(y==(10*a + 5*b + c)){
                res=1;
                ra=a;rb=b;rc=c;
            }
        }
        if(res==1)
            break;
    }
    if(res==0){
        ra=-1;
        rb=-1;
        rc=-1;
    }
    printf("%d %d %d\n", ra, rb, rc);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  double ans;
  int n,t,a;
  cin >> n;
  cin >> t >> a;
  ll h[n];
  rep(i,n) {
    cin >> h[i];
  }

  ans = t - h[0] * 0.006;
  ll res = 1;
  for (int i = 1; i < n; ++i) {
    double tmp = t - h[i] * 0.006;
    if (abs(ans - a) < abs(tmp - a)) {
      ;
    } else {
      ans = tmp;
      res = i + 1;
    }
  }

  cout << res << endl;
}


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

int main() {
  char c;
  cin >> c;
  if ( c == 'a' || c == 'e' || c=='i' || c=='o' || c=='u'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
  // ここにプログラムを追記
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  for (int i = 1; i < n; i++) {
    if (a.at(i) == a.at(i - 1)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main() {
	int n, result = 0, memo = 0,min=100;
	char str[105];
	int num[20000]={};
	scanf("%d", &n);
	

	for (int i = 0; i < n; i++) {
		scanf("%d", &num[i]);
		memo = 0;
		while (num[i] % 2 == 0) {
			memo++;
			num[i] /= 2;
		}
		if (memo < min) { min = memo; }
	}
	printf("%d", min);
}

Measured memory_bytes: 256