akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int N=1000005;
int n,i,j,k,l,tot,pt[N],tk[N],head[N],adj[N],nxt[N],flow[N],cap[N],cur[N],d[N],q[N],bg,ed;
bool v[N];
vector<int> bl[N];
void addedge(int u,int v,int w)
{
	adj[++l]=v;
	nxt[l]=head[u];
	head[u]=l;
	cap[l]=w;
	adj[++l]=u;
	nxt[l]=head[v];
	head[v]=l;
	cap[l]=0;
}
bool bfs()
{
	int i;
	for(i=1;i<=tot;++i)
		d[i]=1<<30;
	d[tot-1]=0;
	q[bg=ed=1]=tot-1;
	while(bg<=ed)
	{
		for(i=head[q[bg]];i;i=nxt[i])
			if(flow[i]<cap[i]&&d[adj[i]]==(1<<30))
			{
				d[adj[i]]=d[q[bg]]+1;
				q[++ed]=adj[i];
			}
		++bg;
	}
	return d[tot]!=(1<<30);
}
int dfs(int x,int a)
{
	if(x==tot||a<=0)
		return a;
	int g,h=0;
	for(;cur[x];cur[x]=nxt[cur[x]])
		if(d[adj[cur[x]]]==d[x]+1&&(g=dfs(adj[cur[x]],min(a,cap[cur[x]]-flow[cur[x]])))>0)
		{
			flow[cur[x]]+=g;
			flow[cur[x]&1?cur[x]+1:cur[x]-1]-=g;
			a-=g;
			h+=g;
			if(a<=0)
				break;
		}
	return h;
}
int main()
{
	scanf("%d",&n);
	tot=2*n;
	for(i=1;i<n;++i)
	{
		scanf("%d",&k);
		while(k--)
		{
			scanf("%d",&j);
			bl[j].push_back(i);
			if(j<n)
				addedge(i,n-1+j,1);
		}
		addedge(tot-1,i,1);
		addedge(n-1+i,tot,1);
	}
	k=0;
	while(bfs())
	{
		for(i=1;i<=tot;++i)
			cur[i]=head[i];
		k+=dfs(tot-1,1<<30);
	}
	if(k<n-1)
	{
		printf("-1");
		return 0;
	}
	for(i=1;i<n;++i)
		for(j=head[i];j;j=nxt[j])
			if(adj[j]!=tot-1&&flow[j]==cap[j])
			{
				pt[i]=adj[j]-(n-1);
				break;
			}
	q[bg=ed=1]=n;
	for(i=1;i<=n;++i)
		v[i]=false;
	v[n]=true;
	while(bg<=ed)
	{
		for(i=bl[q[bg]].size()-1;i>=0;--i)
			if(!v[pt[bl[q[bg]][i]]])
			{
				q[++ed]=pt[bl[q[bg]][i]];
				v[q[ed]]=true;
				tk[bl[q[bg]][i]]=q[bg];
			}
		++bg;
	}
	for(i=1;i<n;++i)
		if(!tk[i])
		{
			printf("-1");
			return 0;
		}
	for(i=1;i<n;++i)
		printf("%d %d\n",pt[i],tk[i]);
	return 0;
}


Measured memory_bytes: 64256
n = int(input())
l = list(map(int,input().split()))
score = list(map(int,input().split()))
add = list(map(int,input().split()))
sum = sum(score)

for i in range(n-1):
  if l[i+1] - 1 == l[i]:
    sum += add[l[i]-1]
print(sum)

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

int main() {
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s;
	cin >> t;
	ll l = n / __gcd(n, m) * m;
	ll nl = l / m;
	ll ml = l / n;
	for (int i = 0; i < n / nl; i++) {
		if (s.at(i * nl) != t.at(i * ml)) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << l << endl;
}

Measured memory_bytes: 512
n,x=int(input()),10**6+100
a,b,c=list(map(int,input().split())),[0]*(2*x),0
for i in a:
    b[i]+=1
for i in range(x):
    c+=1 if b[i]==1 else 0
    if b[i]==0:
        continue
    for j in range(1,x):
        if i*j>=x:
            break
        b[i*j]=0
print(c)

Measured memory_bytes: 34968
import java.util.*;

public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] edge = new ArrayList[N + 1];
		for (int i = 0; i < M; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			if (edge[u] == null) {
				edge[u] = new ArrayList<>();
			}
			edge[u].add(v);
		}
		int S = sc.nextInt();
		int T = sc.nextInt();
		long[][] visited = new long[N + 1][3];
		Queue<Integer> q = new ArrayDeque<>();

		long ans = -1;
		q.add(S * 3 + 0);
		visited[S][0] = 1;
		while (q.size() > 0) {
			int value = q.poll();
			int node = value / 3;
			int step = value % 3;
			long numStep = visited[node][step];
			if (node == T && step == 0) {
				ans = (numStep - 1) / 3;
				break;
			}
			if (edge[node] != null) {
				int nextStep = (step + 1) % 3;
				for (int next : edge[node]) {
					if (visited[next][nextStep] == 0) {
						visited[next][nextStep] = numStep + 1;
						q.add(next * 3 + nextStep);
					}
				}
			}
		}

		System.out.println(ans);
	}
}


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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    string s;

    cin >> s;


    cout << s.substr(0,3) << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 3624
/*    AUTHOR: julianferres, sáb 29 ago 2020 00:49:45 -03 */
#include <bits/stdc++.h>
using namespace std;

// DEBUGGER
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//END DEBUGGER

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define esta(x,c) ((c).find(x) != (c).end())
const int INF = 1<<30; // const ll INF = 1LL<<60;
const int MOD = 1e9+7; // 998244353
const int MAXN  = 2e5+5;


int main(){  
    FIN;

    int n; cin >> n;
    vi a(n); forn(i, n) cin >> a[i];
    ll ans = 0;
    ll mx = a[0];
    forr(i, 1, n)
    {
        mx = max(mx, a[i]);
        ans += mx-a[i];
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
int N,M;
main(){
  cin>>N>>M;
  vector<vector<int>>xs(N,vector<int>());
  for(int i=0;i<M;++i){
    int a,b;
    cin>>a>>b;
    --a;
    --b;
    xs[b].push_back(a);
  }
  int last=-1;
  int n_count=0;
  for(int right=0;right<N;++right){
    for(int left:xs[right]){
      // printf("left, right = %d, %d\n",left,right);
      if(left<=last)continue;
      last=right-1;
      ++n_count;
    }
  }
  cout<<n_count<<endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;

int main(){

    string S,T;
    int i,j;
    int diff,ans;


    cin >> S >> T;
    ans = T.size();


    for(i = 0;i <= S.size() - T.size(); i++){


        diff = 0;
        for(j = 0; j < T.size();j++){

            if(T[j] != S[i+j]){
                diff++;
            }

        }

        ans = min(ans,diff);

    }

    cout << ans << endl;


 }

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

#define STRING(str) #str
#define ll long long

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

const ll INF = 1e13;

int main() {
	int N, K;
	cin >> N >> K;
	vector<vector<int>> A(N, vector<int>(N, 0));
	for (int i=0;i<N;i++) {
		for (int j=0;j<N;j++) {
			cin >> A[i][j];
		}
	}

	mcf_graph<ll, ll> graph(2*N+2);
	// s -> row(0, ..., N-1) / colmn(N, ... 2*N-1) -> t
	int s = 2*N;
	int t = 2*N+1;
	graph.add_edge(s, t, N*K, INF);
	for (int i=0;i<N;i++) {
		graph.add_edge(s, i, K, 0LL);
		graph.add_edge(i+N, t, K, 0LL);
	}
	for (int i=0;i<N;i++) {
		for (int j=0;j<N;j++) {
			graph.add_edge(i, j+N, 1, INF-A[i][j]);
		}
	}


	string S = "";
	for (int i=0;i<N;i++) S += '.';
	vector<string> ans(N, S);

	pair<ll, ll> p = graph.flow(s, t, N*K);
	for (auto edge : graph.edges()) {
		if ((edge.from != s) && (edge.to != t) && edge.flow == 1) {
			ans[edge.from][edge.to-N] = 'X';
		}
	}

	cout << INF*(N*K)-p.second << endl;
	for (int i=0;i<N;i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 3980
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

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

typedef long long int64;
const int64 MOD = 1000000007;

class CTypicalStairs {
 public:
  void solve(std::istream &in, std::ostream &out) {
    int n, m, x;
    in >> n >> m;
    vector<bool> fb(n + 1, false);
    forn(i, m) {
      in >> x;
      fb[x] = true;
    }

    vector<int64> dp(n + 1, 0);
    dp[0] = 1L;
    for (int i = 1; i <= n; ++i) {
      if (!fb[i]) {
        dp[i] = dp[i - 1];
        if (i >= 2)dp[i] += dp[i - 2];
        dp[i] %= MOD;
      }
    }
    out << dp[n] << endl;
  }
};

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

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n < 1200) cout << "ABC";
    else if (n < 2800) cout << "ARC";
    else cout << "AGC";
}


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

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

    int h, w;
    cin >> h >> w;

    char D[51][51];
    REP(i, h){
        REP(j, w){
            cin >> D[i][j];
        }
    }

    int A[51][51] = {};

    int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1};
    int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
    REP(i, h){
        REP(j, w){
            int cnt = 0;
            REP(k, 8){
                bool f1, f2;
                f1 = (i + dx[k] < 0) or (j + dy[k] < 0);
                f2 = (i + dx[k] >= h) or (j + dy[k] >= w);
                if(f1 or f2) continue;
                if(D[i + dx[k]][j + dy[k]] == '#') cnt++;
            }
            A[i][j] = cnt;
        }
    }

    REP(i, h){
        REP(j, w){
            if(D[i][j] == '#') cout << '#';
            else cout << A[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// C - Vacation
#include <bits/stdc++.h>
using namespace std;
#define MAX(a,b) ((a)>(b)?(a):(b))
// void abcprn(int a, int b, int c){printf("%4d,%4d,%4d\n",a,b,c);}

int main(){
	int N; cin>>N;
	// cout<<"dp:A    B    C\n";//
	int A=0, B=0, C=0;
	while(N--){
		int a,b,c; cin>>a>>b>>c;
		a += MAX(B,C); b += MAX(C,A); c += MAX(A,B);
		A=a; B=b; C=c;
		// abcprn(A,B,C);//
	}
	cout<< MAX(A,MAX(B,C)) <<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public long N, X;
        public long MOD = 1000000007;
        public long[] A, B;
        public void Run()
        {
            {
                var line = Input.ReadLongArray();
                N = line[0];
                X = line[1];
            }

            A = new long[N + 1];
            B = new long[N + 1];

            for (int i = 0; i <= N; i++)
            {
                if (i == 0)
                {
                    A[i] = 1;
                    B[i] = 1;
                }
                else
                {
                    A[i] = A[i - 1] * 2 + 3;
                    B[i] = B[i - 1] * 2 + 1;
                }
            }

            long ret = Count(N, X);
            Console.WriteLine(ret);
        }

        public long Count(long n, long x)
        {
            if (x >= A[n]) return B[n];

            long r = 0;

            x--;
            if (x <= 0) return r;

            r += Count(n - 1, x);
            x -= A[n - 1];
            if (x <= 0) return r;

            r++;
            x--;
            if (x <= 0) return r;

            r += Count(n - 1, x);
            x -= A[n - 1];
            if (x <= 0) return r;

            return r;
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13268
def main():
    N = int(input())
    playlist = []
    for _ in range(N):
        tmp = input().split(' ')
        tmp[1] = int(tmp[1])
        playlist.append(tmp)

    X = input()

    titles = [x[0] for x in playlist]
    time = [x[1] for x in playlist]

    i = titles.index(X)
    if i + 1 >= N:
        print(0)
    else:
        print(sum(time[i + 1:]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
N = int(input())
A = input().split()
A = [int(a) for a in A]
p = 1 if (len([n for n in A if n == 0]) == 0) else 0
for i in range(len(A)):
  p *= A[i]
  if p > 1000000000000000000:
    p = -1
    break
print(p)

Measured memory_bytes: 21756
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  a.push_back(0);
  ll mon = 1000;
  ll cab = 0;
  REP(i, n) {
    cab += mon / a[i];
    mon %= a[i];
    if (a[i] < a[i + 1]) {
      continue;
    } else {
      mon += cab * a[i];
      cab = 0;
    }
  }
  cout << mon << endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  long long sum = 0;
  int cnt = 0, ans = n;
  for(int i = 0; i < n-1; i++){
    sum += a.at(i), cnt++;
    if(sum * 2 >= a.at(i+1)) continue;
    ans -= cnt;
    cnt = 0;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include "math.h"
#include <complex>
#include <iomanip>
#define ifor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;
typedef long double ld;
typedef long long int  lli;
typedef complex <double> P;
const double eps = 1e-11;
int vex[4]={1,0,-1,0};
int vey[4]={0,1,0,-1};
int n,k;
vector<vector<int> >  e(2005);
vector<int> A,B;
int d [2005][2005];
void dfs(int cur,int from,int root,int curDist){
	d[root][cur] = curDist;
	for(int i = 0;i<e[cur].size();i++){
		int t = e[cur][i];
		if(t !=from)dfs(t,cur,root,curDist+1);
	}
}

int main(){
	cin >>  n >> k ;
	for(int i = 0;i<n-1;i++){
		int a,b;
		cin >>  a >> b;
		a--;
		b--;
		e[a].push_back(b);
		e[b].push_back(a);
		A.push_back(a);
		B.push_back(b);
	}
	for(int i = 0;i<n;i++){
		dfs(i,-1,i,0);
	}
	int ans  = 0;
	for(int i = 0;i<n;i++){
		int cnt = 0;
		for(int j = 0;j<n;j++){
			if(2*d[i][j] <=k)cnt++;
		}
		ans = max(ans,cnt);
	}
	for(int i =0;i<n-1;i++){
		int a = A[i];
		int b = B[i];
		int cnt = 0;
		for(int j =0;j<n;j++){
			if(2*min(d[j][a],d[j][b])+1<=k){
				cnt++;
			}
		}
		ans = max(ans,cnt);
	}
	cout << n- ans <<endl;
}


Measured memory_bytes: 16128
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	getLine
	(l:ls) <- reverse . sort <$> readInts
	putStrLn $ which "Yes" "No" $ l < sum ls

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define double long double
#define x first
#define y second
#define long long long
#define int long 



           //       |----|       /\      |    |   -----   |
           //       |   /       /  \     |    |     |     |
           //       |--/       /----\    |----|     |     |
           //       |   \     /      \   |    |     |     |
           //       |    \   /        \  |    |   -----   -------

string s1,s2;
int cache[3005][3005];
int dp(int pos1,int pos2)
{
	if(pos1==s1.length()||pos2==s2.length())
		return 0;
	if(cache[pos1][pos2]!=-1)
		return cache[pos1][pos2];
	if(s1[pos1]==s2[pos2])
		return cache[pos1][pos2]=dp(1+pos1,1+pos2)+1;
	else
		return cache[pos1][pos2]=max(dp(1+pos1,1+pos2),max(dp(pos1,1+pos2),dp(1+pos1,pos2)));
}

void path(int pos1,int pos2)
{
	if(pos1==s1.length()||pos2==s2.length())
		exit(0);
	if(s1[pos1]==s2[pos2])
	{
		cout<<s1[pos1];
		path(1+pos1,1+pos2);
	}
	else
	{

		int a=max(dp(1+pos1,1+pos2),max(dp(pos1,1+pos2),dp(1+pos1,pos2)));
		if(a==dp(1+pos1,1+pos2))
			path(1+pos1,1+pos2);
		else if(a==dp(pos1,1+pos2))
			path(pos1,1+pos2);
		else
			path(1+pos1,pos2);
	}
}
int32_t main()
{
    IOS
    cin>>s1>>s2;
    memset(cache,-1,sizeof(cache));
    dp(0,0);
    path(0,0);
}

Measured memory_bytes: 71040
#include<iostream>
#include<cstring>
#include<cstdio>
#define S 0
#define T 201
#define INF 2000000000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
long long ans=0;
int n,a[T+5],head[T+5],c[T+5],d[T+5],q[T+5],top,cnt=1;
struct edge{int to,next,w;}e[T*T+5];
inline void ins(int f,int t,int w)
{
	e[++cnt]=(edge){t,head[f],w};head[f]=cnt;
	e[++cnt]=(edge){f,head[t],0};head[t]=cnt;	
}
bool bfs()
{
    memset(d,0,sizeof(d));int i,j;
    for(d[q[top=i=1]=S]=1;i<=top;++i)
        for(j=c[q[i]]=head[q[i]];j;j=e[j].next)
            if(e[j].w&&!d[e[j].to]) d[q[++top]=e[j].to]=d[q[i]]+1;
    return d[T];    
}
int dfs(int x,int f)
{
    if(x==T) return f;int used=0;    
    for(int&i=c[x];i;i=e[i].next)
        if(e[i].w&&d[e[i].to]==d[x]+1)
        {
            int w=dfs(e[i].to,min(f-used,e[i].w));
            e[i].w-=w;e[i^1].w+=w;used+=w;
            if(used==f) return f;    
        }
    return d[x]=-1,used;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
		if(a[i]>=0)	ans+=a[i],ins(i,T,a[i]);
		else ins(S,i,-a[i]);
	}
	for(int i=1;i<=n;++i)
		for(int j=i<<1;j<=n;j+=i)
			ins(i,j,INF);
	while(bfs()) ans-=dfs(S,INF);
	cout<<ans;
	return 0;
}

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

int iC[ 20 ];

int main( int argc, char *argv[] )
{
int i;
int N;
int a;
int iColor;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	for( i = 0; i < N; i++ )
	{
		cin >> a;
		if( a < 400 )
			iC[ 0 ]++;
		else if( a < 400 )
			iC[ 1 ]++;
		else if( a < 800 )
			iC[ 2 ]++;
		else if( a < 1200 )
			iC[ 3 ]++;
		else if( a < 1600 )
			iC[ 4 ]++;
		else if( a < 2000 )
			iC[ 5 ]++;
		else if( a < 2400 )
			iC[ 6 ]++;
		else if( a < 2800 )
			iC[ 7 ]++;
		else if( a < 3200 )
			iC[ 8 ]++;
		else
			iC[ 9 ]++;
	}


	iColor = 0;
	for( i = 0; i <= 8; i++ )
	{
		if( iC[ i ] > 0 ) iColor++;
	}

	if( iColor <= 0 )
		cout << 1 << " ";
	else
		cout << iColor << " ";

	cout << iColor + iC[ 9 ] << endl;

	return 0;
}




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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x,ll y,ll m) 
{
    ll res = 1; 
    x = x % m;                
    if (x == 0)
        return 0; 
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

ll gcd(ll a,ll b) 
{
    if(b==0) return a;
    return gcd(b,a%b);
}

void solve()
{
    int a,b,k;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++) {
        if(i%k==0) {
            cout<<"OK";
            return;
        }
    }
    cout<<"NG";
}

int main()
{
    fastio;
    int t;
    t=1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout<<newl;
    }

    return 0;
}

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

using namespace std;



void solver() {
    int x; cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << '\n';
}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

    int t;
    //cin >> t;
    t = 1;

    while(t--)
        solver();

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);\
	ll n;
	ll ans = 0;
	cin >> n;
	for(ll i = 1; i <= n; i++)
	{
		if(i%3 && i%5)
		{
			ans += i;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3648
N = int(input())
max1 = 0
blue_dic = {}
red_dic = {}
for i in range(N):
    b = input()
    if b in blue_dic:
        blue_dic[b] += 1
    else:
        blue_dic[b] = 1
M = int(input())
for i in range(M):
    r = input()
    if r in red_dic:
        red_dic[r] += 1
    else:
        red_dic[r] = 1
for kb, vb in blue_dic.items():
    tmp = 0
    tmp += vb
    if kb in red_dic:
        tmp -= red_dic[kb]
    if tmp > max1:
        max1 = tmp
print(max1)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    cin >> n;
    vector<long long> boss(n, 0);
    for(int i=0;i<n-1;++i)
    {
        long tmp;
        cin >> tmp;
        ++boss[tmp-1];
    }
    for(int i=0;i<n;++i)
    {
        cout << boss[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 4784
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int cnt[N];
  fill(cnt,cnt+N,1);
  bool red[N];
  fill(red,red+N,false);
  red[0] = true;

  for(int i=0;i<M;i++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;

    if(red[x]) red[y] = true;
    cnt[x]--;
    cnt[y]++;
    if(cnt[x] == 0) red[x] = false;
  }

  int ans = 0;
  for(int i=0;i<N;i++){
    if(red[i]) ans++;
  }

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


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
bool isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
void solve()
{	
	char c;
	cin>>c;
	cout<<char(c+1);
}	
int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int[] ary = new int[num];
		int sum = 0;
		for(int i=0; i<num; i++) {
			ary[i] = scan.nextInt();
			sum += ary[i];
		}
		scan.close();
		if(sum%10 != 0) {
			System.out.println(sum);
			return;
		}
		Arrays.sort(ary);
		for(int i=0; i<num; i++) {
			int sum2 = sum-ary[i];
			if(sum2%10 != 0) {
				System.out.println(sum2);
				return;
			}
		}
		System.out.println(0);
	}

}

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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
#define swap(x, y)    \
  {                   \
    auto ___temp = x; \
    x = y;            \
    y = ___temp;      \
  }

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}

int main() {
  int n, h[20];
  cin >> n;
  repi(n) cin >> h[i];
  int re = 1;
  repr(i, 1, n) {
    repj(i) if (h[j] > h[i]) goto cont;
    re++;
  cont:
    0;
  }
  cout << re << endl;
}


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

int main() {
	int n,k;
	cin>>n>>k;
	vector<int> P(n);
	rep(i,n)cin>>P[i];
	rep(i,n)P[i]++;
	
	vector<ll> S(n+1,0);
	for(int i=0;i<n;i++)S[i+1]=S[i]+P[i];
	
	ll res=0;
	for(int i=0;i<=n-k;i++){
		int left=i,right=i+k;
		res=max(S[right]-S[left],res);
		
	}
	cout << fixed << setprecision(10) << (double)(res)/2 << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

long long mod = 1000000007;
long long N;
long long S[1 << 20];
long long V[1 << 20];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> S[i]; long long r = S[i];
		vector<pair<long long, long long>> vec;
		for (int j = 2; j * j <= r; j++) {
			if (r % j != 0) continue;
			long long cnt = 0; while (r % j == 0) { cnt++; r /= j; }
			vec.push_back(make_pair(j, cnt));
		}
		if (r >= 2) vec.push_back(make_pair(r, 1));
		for (int j = 0; j < vec.size(); j++) V[vec[j].first] = max(V[vec[j].first], vec[j].second);
	}

	long long rem = 1;
	for (int i = 1; i <= 1000000; i++) {
		for (int j = 0; j < V[i]; j++) { rem *= (1LL * i); rem %= mod; }
	}

	long long ans = 0;
	for (int i = 1; i <= N; i++) {
		ans += Div(rem, S[i], mod);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  rep(i,26){
    cin >> c.at(i);
  }
  vector<vector<int>> s(D,vector<int>(26));
  rep(i,D){
    rep(j,26){
      cin >> s.at(i).at(j);
    }
  }
  vector<int> t(D);
//  rep(i,D){
//   cin >> t.at(i);
//   t.at(i) --;
//  }
  vector<int> score(D);//正式スコア
  int v = 0;//仮の計算
  vector<int> last(26,-1);
  vector<int> last_kari(26,-1);
  rep(i,D){//i日め
    int good_j = -1;
    rep(j,26){//26個分調べる
      last_kari = last;
      if(i != 0){//i==0のときvは0(初期)
      v = score.at(i-1);//前の正式スコアをvにおく
      }
      int up = s.at(i).at(j);
      int down = 0;
      last_kari.at(j) = i;
      rep(k,26){
        down += c.at(k) * (i - last_kari.at(k));
      }
      v = v + up - down;
      if(j == 0 || score.at(i) < v){
        good_j = j;//良いjをキープ
        score.at(i) = v;//最大スコアをさっき計算したvにする(jのscore)
      }
    }
    cout << good_j + 1 << endl;
    last.at(good_j) = i;
//    cout << v << endl;
  }
  return 0;
}



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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

int calc(int x, int n) {
    vector<int> digits;
    while (x > 0 || digits.size() < n) {
        digits.emplace_back(x % 10);
        x /= 10;
    }

    sort(all(digits));
    reverse(all(digits));
    int a = 0;
    for (auto d : digits) {
        a *= 10;
        a += d;
    }
    reverse(all(digits));
    int b = 0;
    for (auto d : digits) {
        b *= 10;
        b += d;
    }

    return a - b;
}

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

    int x, n;
    while (cin >> x >> n, n) {
        set<int> st;
        vector<int> v;
        int i;
        for (i = 0; st.count(x) == 0; i++) {
            st.insert(x);
            v.emplace_back(x);
            x = calc(x, n);
        }
        int j;
        for (j = 0; v[j] != x; j++)
            ;
        cout << j << " " << x << " " << i - j << endl;
    }
}

Measured memory_bytes: 3096
n, k = map(int, input().split())
for x in range(n+1):
    for y in range(n+1):
        if x + y <= n:
            z = n - x - y
            result = 10000*x + 5000*y + 1000*z
            if result == k:
                print("{} {} {}".format(x, y, z))
                exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
<?php
list($n, $m) = ints();
for ($i = 0; $i < $m; ++$i) {
    list($a[], $b) = ints();
    $c = ints();
    $d = 0;
    for ($j = 0; $j < $b; ++$j) {
        --$c[$j];
        $d |= 1 << $c[$j];
    }
    $t[] = $d;
}
$dp = array_fill(0, $m + 1, array_fill(0, 1 << $n, INF));
$dp[0][0] = 0;
for ($i = 0; $i < $m; ++$i) {
    for ($j = 0; $j < (1 << $n); ++$j) {
        $dp[$i + 1][$j] = min($dp[$i + 1][$j], $dp[$i][$j]);
        $dp[$i + 1][$j | $t[$i]] = min($dp[$i + 1][$j | $t[$i]], $dp[$i][$j] + $a[$i]);
    }
}
echo $dp[$m][(1 << $n) - 1] !== INF ? $dp[$m][(1 << $n) - 1] : -1;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 148340
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}

int calc2(vector<P> A){
  const int N = (1e6) + 100;
  vector<int> cnt(N, 0);
  int n = A.size();
  for(int i=0;i<n;i++){
    int a, b; tie(a, b) = A[i];
    cnt[a]++;
    cnt[b]--;
  }

  for(int i=1;i<N;i++) cnt[i] += cnt[i-1];
  int ans = 0;
  for(int i=0;i<N;i++) Max(ans, cnt[i]);
  return ans;
}

int calc1(vector<P> A){
  int n = A.size();
  vector<int> L, R;
  for(int i=0;i<n;i++){
    int l, r; tie(l, r) = A[i];
    L.push_back(l);
    R.push_back(r);
  }
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());

  int ans = 0;
  for(int i=0;i<n;i++){
    int l, r; tie(l, r) = A[i];
    int numL = n - (lower_bound(L.begin(), L.end(), r) - L.begin());
    int numR = upper_bound(R.begin(), R.end(), l) - R.begin();
    int num = n - (numL + numR);
    Max(ans, num);
  }
  return ans;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin>>n;
  vector<P> A(n);
  cin>>A;
  int s1 = calc1(A);
  int s2 = calc2(A);
  cout<<s1<<" "<<s2<<endl;
  return 0;
}



Measured memory_bytes: 13000
n = int(input())
S = input()
ans = n
temp = 0

for i in range(1, n):
    if S[i] =='E':
        temp += 1
ans = min(ans, temp)

for i in range(1, n):
    if S[i - 1] == 'W':
        temp += 1
    if S[i] == 'E':
        temp -= 1
    ans = min(ans, temp)        

print(ans)

Measured memory_bytes: 3700
#include<stdio.h>

int A[9];
int b[10];
int m[9] = {0};

int main(){
	int n;
	int i, j;
	int flag = 0;

	for(i=0; i<9; i++){
		scanf("%d", A+i);
	}
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", b+i);
		for(j=0; j<9; j++){
			if(A[j] == b[i]){
				m[j] = 1;
			}
		}
	}

	if(m[0]+m[1]+m[2] == 3){
		flag = 1;
	}else if(m[3]+m[4]+m[5] == 3){
		flag = 1;
	}else if(m[6]+m[7]+m[8] == 3){
		flag = 1;
	}else if(m[0]+m[3]+m[6] == 3){
		flag = 1;
	}else if(m[1]+m[4]+m[7] == 3){
		flag = 1;
	}else if(m[2]+m[5]+m[8] == 3){
		flag = 1;
	}else if(m[0]+m[4]+m[8] == 3){
		flag = 1;
	}else if(m[2]+m[4]+m[6] == 3){
		flag = 1;
	}

	if(flag == 1){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}


Measured memory_bytes: 128
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var D = one[2];
  var output = (D == 0) ? (1 / N) : (2 * (N - D)) / N / N;
  myout(output * (M - 1));
}


Measured memory_bytes: 30044
# -*- coding: utf-8 -*-
import math
X = int(input())

q, mod = divmod(X, 100)

q2, mod2 = divmod(mod, 5)

q3, mod3 = divmod(X, 105)

if mod3 == 0:
  print(1)
elif q2+1 <= q:
  print(1)
else:
  print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   string s;
   cin>>s;
   if(s[0]!='9' && s[1]!='9')cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
}

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

int main(){
  for(double a1,b1,c1,d1,e1,f1,b2,c2,e2,f2,a3,c3,d3,f3,x,y;cin>>a1>>b1>>c1>>d1>>e1>>f1;){

    b2=b1*d1;
    c2=c1*d1;

    e2=a1*e1;
    f2=a1*f1;

    y=(c2-f2)/(b2-e2);
    if(y==-0.000){
      y=0.000;
    }

    a3=a1*e1;
    c3=c1*e1;

    d3=b1*d1;
    f3=b1*f1;

    x=(c3-f3)/(a3-d3);
    if(x==-0.000){
      x=0.000;
    }

    cout<<fixed<<setprecision(3)<<x;
    cout<<" ";
    cout<<fixed<<setprecision(3)<<y<<endl;
  }
  return 0;
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
 
int main() {
 int x1,x2,x3,x4,x5;
 cin >> x1 >> x2 >> x3 >> x4 >>x5;

if(x1==0){
   cout << 1 << endl; return 0;
}
if(x2==0){
   cout << 2 << endl; return 0;
}
if(x3==0){
   cout << 3 << endl; return 0;
}
if(x4==0){
   cout << 4 << endl; return 0;
}
if(x5==0){
   cout << 5 << endl; return 0;
}

 
return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define N 200005

ll i=0,j=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

int main()
{
    IOS;
    ll n,w;
    cin>>n>>w;
    ll dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    ll wt[n+1];
    ll val[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(wt[i]<=j)
            {
                dp[i][j]=max(val[i]+dp[i-1][j-wt[i]],dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w]<<endl;
}



Measured memory_bytes: 79232
import java.util.Scanner;

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

    long H = scanner.nextLong();
    H = H / 2 * 2;
    long count = 1;
    while (H > 1) {
      H /= 2;
      count = count * 2 + 1;
    }
    System.out.println(count);
  }
}


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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}

typedef struct UnionFind_ {
  vector<int> par;
  vector<int> rank_;
  UnionFind_(int n): rank_(n, 0) {
    for(int i = 0; i < n; i++)par.push_back(i);
  }
  int find(int x) {
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
  }
  bool same(int x, int y) {
    if(find(x) == find(y))return true;
    else return false;
  }
  bool unite(int x, int y){
    int xp = find(x);
    int yp = find(y);
    if(xp == yp)return false;
    if(rank_[xp] > rank_[yp])par[yp] = xp;
    else if(rank_[xp] < rank_[yp])par[xp] = yp;
    else {
      par[yp] = xp;
      rank_[xp]++;
    }
    return true;
  }
} UnionFind;

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  UnionFind uf(n);
  rep(i, q){
    int c, x, y;
    cin >> c >> x >> y;
    if(c == 0)uf.unite(x, y);
    else {
      if(uf.same(x, y))cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
	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++)

int vminn(vector<int> v, int n) {
  sort(v.begin(), v.end());
  return v[n-1];
}

int main() {
  int Q, H, S, D, N; cin >> Q >> H >> S >> D >> N;
  
  long long ans = 0;
  
  int a = vminn({8*Q, 4*H, 2*S, D}, 1);
  while(N >= 2) {
    ans += a;
    N -= 2;
  }

  a = vminn({4*Q, 2*H, S}, 1);
  while(N >= 1) {
    ans += a;
    N -= 1;
  }

  a = vminn({2*Q, H}, 1);
  while(N >= 0.5) {
    ans += a;
    N -= 0.5;
  }

  while(N > 0) {
    ans += Q;
    N -= 0.25;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

const int mod=1e9+7;

int add(int &a,int b)
{
    a=(a+b)%mod;
}

int mul(int &a,int b)
{
    a=(a*b)%mod;
}

signed main()
{
    int N,M; cin>>N>>M;
    vector<int> a(N),b(M);
    for(int i=0;i<N;i++){
	cin>>a[i];
    }
    sort(a.rbegin(),a.rend());
    a.push_back(-1);
    for(int i=0;i<M;i++){
	cin>>b[i];
    }
    sort(b.rbegin(),b.rend());
    b.push_back(-1);

    int i=0,j=0,num=N*M;
    int ans=1;
    while(num>0){
	if(a[i]==num and b[j]==num){
	    i++;
	    j++;
	}else if(a[i]==num){
	    i++;
	    mul(ans,j);
	}else if(b[j]==num){
	    j++;
	    mul(ans,i);
	}else{
	    mul(ans,i*j-(N*M-num));
	}
	num--;
    }
    cout<<ans<<endl;
}


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

int main() {
  int64_t n, k;
  cin >> n >> k;
  vector<int64_t> h(n);
  for (int64_t i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  int64_t sum = 0;
  for (int64_t i = k; i < n; i++) {
    sum += h.at(i);
  }
  cout << sum << endl;


}
  
      

Measured memory_bytes: 1792