akhauriyash/Code-Regression huggingface dataset:
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
#define FF first
#define SS second

ll h, w; 
string g[1111]; 
bool valid(ll x, ll y) {
	if (x < 0 || x >= h || y < 0 || y >= w || g[x][y] == '#')
		return false;
	return true;
}

int main(){
	FASTIO;
	cin >> h >> w;
	pair<ll, ll> source; cin >> source.FF >> source.SS;
	pair<ll, ll> destination; cin >> destination.FF >> destination.SS;
	for ( int k = 0; k < h; k++ ) cin >> g[k];
	source.FF--, source.SS--, destination.FF--, destination.SS--;
	deque<pair<ll, ll>> dq;
	dq.push_back(source);
	ll dis[h][w];
	for ( int k = 0; k < h; k++ )
		for ( int j = 0; j < w; j++ )
			dis[k][j] = 1e9;
	dis[source.FF][source.SS] = 0;
	pair<ll, ll> dxy[] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
	while (!dq.empty()) {
		pair<ll, ll> me = dq.front();
		dq.pop_front();
		for (auto d: dxy) {
			pair<ll, ll> to = {me.FF + d.FF, me.SS + d.SS};
			if (!valid(to.FF, to.SS))
				continue;
			if (dis[to.FF][to.SS] > dis[me.FF][me.SS]) {
				dis[to.FF][to.SS] = dis[me.FF][me.SS];
				dq.push_front(to);
			}
		}
		for ( int k = -2; k <= 2; k++ ){
			for ( int j = -2; j <= 2; j++ ){
				pair<ll, ll> to = {me.FF + k, me.SS + j};
				if (!valid(to.FF, to.SS))
					continue;
				if (dis[to.FF][to.SS] > dis[me.FF][me.SS] + 1) {
					dis[to.FF][to.SS] = dis[me.FF][me.SS] + 1;
					dq.push_back(to);
				}
			}
		}
	}
	ll ans = dis[destination.FF][destination.SS];
	if (ans >= 1e9)
		ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12684
fun main (args : Array<String>) {
	val (n, t1) = readLine()!!.split(" ")
	val N : Int = n.toInt()
	val T : Int = t1.toInt()
	var cList : MutableList<Int> = mutableListOf()
	var tList : MutableList<Int> = mutableListOf()
	var calc : Int
	var result : Int = 0
	for (i in 0..N - 1) {
		val (c, t2) = readLine()!!.split(" ")
		cList.add(c.toInt())
		tList.add(t2.toInt())
	}
	for (i in 0..N - 1) {
		if (tList[i] <= T) {
			calc = cList[i]
			if (result == 0) {
				result = cList[i]
			}
			if (result > calc) {
				result = calc
			}
		}
	}
	return if (result != 0) {
		println("${result}")
	} else {
		println("TLE")
	}
}

Measured memory_bytes: 37960
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner entrada = new Scanner(System.in);
        int tipos = entrada.nextInt();
        int eleccion = entrada.nextInt();
        ArrayList<Integer> listaPrecios = new ArrayList<Integer>();
        for (int i = 0; i < tipos; i++) {
            int valor = entrada.nextInt();
            listaPrecios.add(valor);
        }
        int sumaMin = 0;
        for (int i = 0; i < eleccion; i++) {
            int min = Collections.min(listaPrecios);
            sumaMin += min;
            int index = listaPrecios.indexOf(min);
            listaPrecios.remove(index);
        }
        System.out.println(sumaMin);
    }
}

Measured memory_bytes: 38824
#include<bits/stdc++.h>
using namespace std;
const int mxn=105;
bool ok[mxn],bok[mxn];
int main(){
	int n,m;
	cin>>n>>m;
	char c[n][m];
	memset(ok,1,sizeof(ok));
	memset(bok,1,sizeof(bok));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>c[i][j];
			if(c[i][j]=='#'){
				ok[i]=0;
				bok[j]=0;
			}
		}
	}
	//cout<<endl;
	for(int i=0;i<n;i++){
		if(!ok[i]){
		for(int j=0;j<m;j++){
			if(!bok[j])cout<<c[i][j];
		}
		cout<<endl;
	}

	}

}
//solved  problems for today:1


Measured memory_bytes: 256
def get_ander_odds_digits(n):
    return [i for i in range(1, n + 1) if i % 2 == 1]

def get_number_of_odds(odd_list):
    return sum([9 * 10 ** (i - 1) for i in odd_list])

n = int(input())
number_of_digits = len(str(n))
answer = 0
if number_of_digits % 2 == 1:
    answer = n - 10 ** (number_of_digits - 1) + 1
number_of_digits -= 1

ander_odds_digits = get_ander_odds_digits(number_of_digits)
answer += get_number_of_odds(ander_odds_digits)
print(answer)

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

int main() {
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    for (long long i=0; i<N; i++) cin >> A.at(i);
    long long hyoten=1;
    for (long long j=0; j<K; j++) {
        hyoten+=A.at(j);
//        hyoten%=1000000007;
    }
    long long hyotmp=hyoten;
    for (long long i=K; i<N; i++) {
        hyoten -= A.at(i-K);
        hyoten += A.at(i);
//       hyoten %= 1000000007;
        if (hyoten>hyotmp) cout << "Yes\n";
        else cout << "No\n";
        hyotmp=hyoten;
    }
}

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

int main(){
    string s,t;
    cin >> s >> t;
    t = t.substr(0,s.size());
  //cout << t <<endl;
    if(s == t){
      cout << "Yes" << endl;
      return 0;
    }
else{
  cout << "No" << endl;
}
}



Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
LL N,i,sum;
LL A[1234567];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N;
    for(i=0;i<N;i++)
        cin>>A[i];
    sort(A,A+N);
    if(N&1)
    {
        for(i=0;i<N-i-4;i++)
            sum+=A[N-i-1]-A[i]<<1;
        sum+=max(A[i+2]*2-A[i+1]-A[i],A[i+2]+A[i+1]-A[i]*2);
    }
    else
    {
        for(i=0;i<N-i-2;i++)
            sum+=A[N-i-1]-A[i]<<1;
        sum+=A[N-i-1]-A[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
ll high_order_bit(ll n){
    ll tmp=1,i=-1;
    while(tmp<=n){
        tmp*=2;
        i++;
    }
    if(n==0) return 0;
    else return i;
}
vector<ll> binary_expansion(ll n){
    vector<ll> B(high_order_bit(n)+1);
    ll tmp=n;
    for(ll i=high_order_bit(n);i>=0;i--){
        B[i]=tmp/pw2[i];
        tmp%=pw2[i];
    }
    return B;
}
vector<ll> divisor(ll x){
    vector<ll> div;
    for(int i=1;i*i<=x;i++){
        if(i*i!=x && x%i==0){
            div.pb(i);
            div.pb(x/i);
        }
        else if(x%i==0) div.pb(i);
    }
    sort(all(div));
    return div;
}
vector<ll> vectorprime(ll x){
    vector<bool> is_prime(x+1);
    vector<ll> prime;
    rep(i,x+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=x;i++){
        if(is_prime[i]){
            prime.pb(i);
        }
        for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
    }
    return prime;
}
ll binary_search(vector<ll> v,ll key){ //key以上が初めて出てくる添字(0-index)
    int l=0,r=sz(v)-1;
    while(r-l>=1){
        int i=(l+r)/2;
        //cout<<l<<" "<<r<<" "<<i<<endl;
        if(v[i]<key) l=i+1;
        else r=i;
    }
    if(v[l]>=key) return l;
    else return INF;
}

int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll A; cin>>A;
    cout<<A+A*A+A*A*A;
    
}


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

int main(){
	int n;
	cin >> n;
	
	if(n<4){cout << "No" << endl;return 0;}
	
	for(int i=0;i<=25;i++){
		for(int j=0;j<=15;j++){
			if(4*i+7*j==n){cout << "Yes" << endl;return 0;}
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
n,m,q = map(int,input().split())
arr = [list(map(int,input().split())) for _ in range(q)]
ans = 0
for i1 in range(1, m+1):
    for i2 in range(i1, m+1):
        for i3 in range(i2, m+1):
            for i4 in range(i3, m+1):
                for i5 in range(i4, m+1):
                    for i6 in range(i5, m+1):
                        for i7 in range(i6, m+1):
                            for i8 in range(i7, m+1):
                                for i9 in range(i8, m+1):
                                    for i10 in range(i9, m+1):
                                        tmp = 0
                                        arrs = [0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10]
                                        for a, b, c, d in arr:
                                            if arrs[b] - arrs[a] == c:
                                                tmp += d
                                        ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 9064
package main

import (
	"fmt"
)

type Goods struct {
	value  int
	weight int
}

func main() {
	var N, W int

	fmt.Scanf("%d %d", &N, &W)

	objects := make([]Goods, N)

	// 品物入力
	for i := 0; i < N; i++ {
		var v, w int
		fmt.Scanf("%d %d", &v, &w)

		goods := Goods{value: v, weight: w}
		objects[i] = goods
	}

	value := Knapsack(W, objects)
	fmt.Println(value)
}

// Knapsack is Knapsack calculate
func Knapsack(bagWeight int, objects []Goods) int {
	preBag := make([]int, bagWeight+1)
	bag := make([]int, bagWeight+1)

	for _, obj := range objects {
		remain := 0
		for i := obj.weight; i <= bagWeight; i++ {
			remainValue := preBag[remain]

			if bag[i] < obj.value+remainValue {
				bag[i] = obj.value + remainValue
			}

			remain++
		}
		copy(preBag, bag)

	}

	return bag[bagWeight]
}



Measured memory_bytes: 1328
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


using ll=long long;

class mod_ll
{
public:
	ll m_v;
	static const ll m_m=1000000007; // prime value ex. 1000000009
	mod_ll(ll v=0) : m_v(v%m_m) {}
	mod_ll operator = (ll rhs)
	{
		m_v=rhs%m_m;
		return *this;
	}
	ll operator ()(){return m_v;}
	mod_ll operator = (mod_ll rhs)
	{
		m_v=rhs.m_v;
		return *this;
	}
	mod_ll operator += (mod_ll rhs)
	{
		m_v=(m_v+rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator + (mod_ll rhs)
	{
		auto ret=*this;
		return ret+=rhs;
	}
	mod_ll operator -= (mod_ll rhs)
	{
		m_v=(m_v-rhs.m_v+m_m)%m_m;
		return *this;
	}
	mod_ll operator - (mod_ll rhs)
	{
		auto ret=*this;
		return ret-=rhs;
	}
	mod_ll operator *= (mod_ll rhs)
	{
		m_v=(m_v*rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator * (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret*=rhs;
	}
	mod_ll operator ^ (ll rhs)
	{
		mod_ll t=*this;
		mod_ll ret(1LL);

		for(;rhs>0;rhs>>=1)
		{
			if(rhs&1) ret*=t;
			t*=t;
		}
		return ret;
	}
	mod_ll operator /= (mod_ll rhs)
	{
		return *this*=(rhs^(m_m-2));
	}
	mod_ll operator / (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret/=rhs;
	}
};


mod_ll mod_fact(int n)
{
	static vector<mod_ll> memo(1);

	if((int)memo.size()<=n)
	{
		if(memo.size()==1)
		{
			memo[0]=1;
		}
		for(int i=memo.size();i<=n;i++)
		{
			memo.push_back(memo.back()*i);
		}
	}
	return memo[n];
}


mod_ll mod_nCr(int n, int r)
{
	if(n<=0) return 1;
	mod_ll bunsi=mod_fact(n);
	mod_ll bunbo=mod_fact(n-r)*mod_fact(r);
	return bunsi/bunbo;
}


mod_ll mod_nCr2(int n, int r)
{
	mod_ll bunsi(1);
	mod_ll bunbo(1);
	if(r*2>n) r=n-r;

	for(int i=0;i<r;i++)
	{
		bunsi*=(n-i);
		bunbo*=(i+1);
	}

	return bunsi/bunbo;
}


mod_ll mod_nPr(int n, int r)
{
	mod_ll ret(1);

	for(int i=0;i<r;i++)
	{
		ret*=(n-i);
	}
	return ret;
}


struct solve
{
	solve(){}
	ll operator()(int k, string&s) {
		mod_ll ret;
		mod_ll v25(25), v26(26);
		int l=s.length();

		for(int i=0;i<=k;i++)
		{
			auto t=mod_nCr(l-1+i, i)*(v25^i)*(v26^(k-i));
			ret+=t;
//cout << "i=" << i << "  " << t() << "  " << ret() << "\n";
		}
		return ret();
	}
};

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

	for(;;)
	{
		int k;
		cin >> k;
		if(cin.fail()) break;
		string s;
		cin >> s;

		cout << solve()(k, s) << "\n";
	}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> e(n+1), w(n+1);
  for(int i=1; i<=n; i++) {
    char d;
    cin >> d;
    e[i]=e[i-1];
    w[i]=w[i-1];
    if(d=='E') e[i]++;
    else w[i]++;
  }
  int ans=n;
  rep(i,n+1) {
    ans=min(ans,w[i]+e[n]-e[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations_with_replacement
import numpy as np
def main():
    n, m, q = map(int, input().split())
    A = np.array(list(combinations_with_replacement(range(1, m + 1), n)))
    numA = len(A)
    score = np.zeros(numA, np.int32)
    ma = map(int, read().split())
    for a, b, c, d in zip(ma, ma, ma, ma):
        a -= 1
        b -= 1
        eachA_is_equalOrNot = A[:, b] - A[:, a] == c
        score += d * eachA_is_equalOrNot
        # print(score)
    print(score.max())

if __name__ == '__main__':
    main()

Measured memory_bytes: 46552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF 100000000

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    vector<ll> x(5);
    rep(i, 5) cin >> x[i];
    rep(i, 5) {
        if (x[i] == 0) { cout << i + 1 << endl; }
    }

}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#define min(a,b)    (((a) < (b)) ? (a) : (b))
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define abs(x)    ((x) < 0 ? -(x) : (x))
#define INF 0x3f3f3f3f
#define delta 0.85
#define eps 1e-3
#define PI 3.14159265358979323846
#define MAX_N 1005
using namespace std;
typedef pair<int, int> P;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
int W, H, N;
int X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];
bool fld[MAX_N * 4][MAX_N * 4];
//坐标压缩
int compress(int *x1, int *x2, int w){
	vector<int> xs(N * 4 + 2);
	xs.push_back(0);
	xs.push_back(w);
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= 1; j++){
			int tx1 = x1[i] - j, tx2 = x2[i] + j;
			if(tx1 >= 0 && tx1 <= w) xs.push_back(tx1);
			if(tx2 >= 0 && tx2 <= w) xs.push_back(tx2);
		}
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	for(int i = 0; i < N; i++){
		x1[i] = distance(xs.begin(), lower_bound(xs.begin(), xs.end(), x1[i]));
		x2[i] = distance(xs.begin(), lower_bound(xs.begin(), xs.end(), x2[i]));
	}
	return xs.size();
}

int main(){
	while(~scanf("%d%d", &W, &H) && W){
		scanf("%d", &N);
		for(int i = 0; i < N; i++) scanf("%d%d%d%d", X1 + i, Y1 + i, X2 + i, Y2 + i);
		W = compress(X1, X2, W);
		H = compress(Y1, Y2, H);
		memset(fld, 0, sizeof(fld));
		// 因为 x, y 是坐标值，而 fld 数组是离散的，填充时为了对应原图矩形，右上边界不填充
		--W, --H;
		for(int i = 0; i < N; i++){
			for(int x = X1[i]; x < X2[i]; x++){
				for(int y = Y1[i]; y < Y2[i]; y++){
					fld[x][y] = 1;
				}
			}
		}
		int res = 0;	
		for(int x = 0; x < W; x++){
			for(int y = 0; y < H; y++){
				if(fld[x][y]) continue;
				++res;
				fld[x][y] = 1;
				// Bfs
				queue<P> que;
				que.push(P(x, y));
				while(!que.empty()){
					P p = que.front(); que.pop();
					int x = p.first, y = p.second;
					for(int i = 0; i < 4; i++){
						int nx = x + dx[i], ny = y + dy[i];
						if(nx >= 0 && nx < W && ny >= 0 && ny < H && !fld[nx][ny]){
							fld[nx][ny] = 1;
							que.push(P(nx, ny));
						}
					}
				}
			}
		}
		printf("%d\n", res);
	}
	return 0;
}


Measured memory_bytes: 18964
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-8
#define inf INT_MAX
#define mod 1000000009
using namespace std;

int main() {
	speed;
	int a, b;
	cin >> a >> b;
	if (a < 6)
		b = 0;
	else if (a < 13)
		b /= 2;
	cout << b << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    bool Bingo[3][3];
  	int Card[3][3];
  	for ( int i = 0; i < 3; i++ ){
    	for ( int j = 0; j < 3; j++ ) Bingo[i][j] = false;
    }
  	cin >> Card[0][0] >> Card[0][1] >> Card[0][2];
    cin >> Card[1][0] >> Card[1][1] >> Card[1][2];
    cin >> Card[2][0] >> Card[2][1] >> Card[2][2];
  	int N, b;
  	cin >> N;
  	for ( int i = 0; i < N; i++ ){
      	cin >> b;
      	for ( int i = 0; i < 3; i++ ){
    		for ( int j = 0; j < 3; j++ ){
            	if ( b == Card[i][j] ) Bingo[i][j] = true;
           	}
    	}
    }
  	bool Flag = false;
  	if ( Bingo[0][0] && Bingo[0][1] && Bingo[0][2] ) Flag = true;
  	if ( Bingo[1][0] && Bingo[1][1] && Bingo[1][2] ) Flag = true;
  	if ( Bingo[2][0] && Bingo[2][1] && Bingo[2][2] ) Flag = true;
  	if ( Bingo[0][0] && Bingo[1][0] && Bingo[2][0] ) Flag = true;
  	if ( Bingo[0][1] && Bingo[1][1] && Bingo[2][1] ) Flag = true;
  	if ( Bingo[0][2] && Bingo[1][2] && Bingo[2][2] ) Flag = true;
 	if ( Bingo[0][0] && Bingo[1][1] && Bingo[2][2] ) Flag = true;
  	if ( Bingo[0][2] && Bingo[1][1] && Bingo[2][0] ) Flag = true;
  	if ( Flag ) cout << "Yes" << endl;
  	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <cstring>

using namespace std;

int main() {

	char num[1000];
	int sum;
	int int_num;

	while (cin >> num) {

		if ((int)num[0] - (int)'0' == 0) {
			break;
		}

		sum = 0;

		//cout << strlen(num) << endl;
		
		for (int i = 0; i < strlen(num); i++) {
			//cout << "num[i]=" << num[i] << endl;
			//cout << "(int)num[i]=" << (int)num[i] << endl;
			//cout << "int_num-(int)'0'=" << int_num-'0' << endl;
			sum += (int)num[i] - (int)'0';
		}

		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 2992
import java.util.Scanner;

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

        while(sc.hasNextLine()){
            sb.append(sc.nextLine().toLowerCase());
        }

        char a = 'a';
        int[] data = new int[26];
        String str = sb.toString();

        for(int i = 0; i < str.length(); i++){
            char now = str.charAt(i);
            for(int j = 0; j < 26; j++){
                if(now == (char)(a+j)){
                    data[j]++;
                    break;
                }
            }
        }

        for(int i = 0; i < 26; i++){
            System.out.println((char)(a+i) + " : " + data[i]);
        }
    }
}


Measured memory_bytes: 26188
#include <bits/stdc++.h>
#pragma optimize("-O2")
#define pb push_back
#define fi first
#define se second
#define SIZE 10000
#define PAD 250
#define MOD 1000000000LL
#define MAXV 200111
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<vector<long long> > mat;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

ll n, a[200111];

int main () {
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)	scanf("%lld",a+i);
	if(n % 2LL == 0) {
		for(int i=0;i<n/2;i++)	printf("%lld ",a[n - 2*i]);
		for(int i=1;i<=n/2;i++)	printf("%lld ",a[2*i-1]);
	}
	else {
		for(int i=0;i<=n/2;i++)	printf("%lld ",a[n - 2*i]);
		for(int i=1;i<=n/2;i++)	printf("%lld ",a[2*i]);
	}
printf("\n");
}

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

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

int main()
{
    int n;
    cin >> n;
    map<string, int> m;
    rep(i, n){
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3588
N = int(input())

x = []
y = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    x.append(in1)
    y.append(in2)

#f = [[0]*2 for i in range(N)]
X=[]
Y=[]
for i in range(N):
    #f[i][0] = x[i]-x[i]
    #f[i][1] = x[i]+y[i]
    X.append(x[i]-y[i])
    Y.append(x[i]+y[i])

dam1 = max(X) - min(X)
dam2 = max(Y) - min(Y)
print(max(dam1,dam2))

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

int main() {
  int n,m,ans = 0;
  cin >> n >> m;
  vector<vector<int>>data(n,vector<int>(m,0));
  //dataに入れる
  for(int i = 0;i < n;i++){
    int k;
    cin >> k;
    for(int j = 0;j < k;j++){
      cin >> data.at(i).at(j);
    }
  }
  //1~mがそれぞれ全てに含まれるかを判定
  for(int s = 1;s <= m;s++){
    int p = 0;//nの列に含まれていたら＋1
    for(int i = 0;i < n;i++){
      for(int j = 0;j < m;j++){
        if(data.at(i).at(j) == s){
          p++;
        }
      }
      if(p == n){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
x = int(input())
if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
else:
    print(1)


Measured memory_bytes: 9176
// you**can**do**anything :~  
#include <bits/stdc++.h>
#define ll long long
#define read(i) scanf("%lli" , &i)
const int maxn=5e5+10;
using namespace std;
vector<ll>abj[545445];
int main() {
ll n ,w;
read(n);  read(w);
if(n>w)
puts("safe");
else
puts("unsafe");




} 

Measured memory_bytes: 16468
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

S = input()

year = int(S[:4])
month = int(S[5:7])
day = int(S[8:])

if year >= 2019:
    if month > 4:
        print("TBD")
    else:
        print("Heisei")
else:
    print("Heisei")


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

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    for (int i = 0; i < a; i++) cin >> p[i];
    for (int i = 0; i < b; i++) cin >> q[i];
    for (int i = 0; i < c; i++) cin >> r[i];
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());
    reverse(p.begin(), p.end());
    reverse(q.begin(), q.end());
    reverse(r.begin(), r.end());
    ll sum = 0;
    for (int i = 0; i < x; i++) r.push_back(p[i]);
    for (int i = 0; i < y; i++) r.push_back(q[i]);
    sort(r.begin(), r.end());
    reverse(r.begin(), r.end());
    for (int i = 0; i < x + y; i++) sum += r[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 6384
def IsvalidStep(arr,row1,col1,row2,col2):
    if arr[row2][col2]=="#" and arr[row1][col1]==".":
        return 1
    return 0    

def solve(arr,matrix,n,m):
    maxx=0
    if n>0:
        if arr[0][0]=="#":
            matrix[0][0]=1
        for col in range(1,m):
            matrix[0][col]=matrix[0][col-1]
            if arr[0][col]=="#" and arr[0][col-1]==".":
                matrix[0][col]+=1

        for row in range(1,n):    
            matrix[row][0]=matrix[row-1][0]
            if arr[row][0]=="#" and arr[row-1][0]==".":
                matrix[row][0]+=1
          
        for row in range(1,n):
            for col in range(1,m):
                matrix[row][col]=min(matrix[row-1][col]+IsvalidStep(arr,row-1,col,row,col),matrix[row][col-1]+IsvalidStep(arr,row,col-1,row,col))
        return matrix[n-1][m-1]        



n,m=map(int,input().split())
arr=[int(0) for i in range(n)]
matrix=[int(0) for i in range(n)]
for i in range(n):
    arr[i]=list(input())
    matrix[i]=[int(0) for _ in range(m)]



print(solve(arr,matrix,n,m))       


"""
def solve(arr,n,m,row,col,count):
    if row>=n or col>=m:
        return 1e9
    elif row==n-1 and col==m-1:
        if arr[row][col]=="#":
            count+=1
        return count
    else:
        if arr[row][col]=="#":
            count+=1
        return min(solve(arr,n,m,row+1,col,count),solve(arr,n,m,row,col+1,count))        
"""


Measured memory_bytes: 3316
#include<stdio.h>
int main(){
    int a, b;
    while(scanf("%d %d", &a, &b) == 2){
        if(a<b)printf("a < b\n");
        else if(a>b)printf("a > b\n");
        else printf("a == b\n");
    }
return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>
#include<stdlib.h>

int main(){
	char** a/*[100][100]*/;
	int h,w,i,j;
	scanf("%d%d",&h,&w);
	a=(char **)malloc(sizeof(char *)*h);
	for(i=0;i<h;i++) a[i]=(char *)malloc(sizeof(char)*w);
	for(i=0;i<h;i++) scanf("%s",a[i]);

	printf("#");
	for(i=0;i<w;i++)printf("#");
	printf("#\n");
	for(i=0;i<h;i++){
		printf("#");
//		for(j=0;j<w;j++){
			printf("%s",a[i]);
//		}
		printf("#\n");
	}
	printf("#");
	for(i=0;i<w;i++)printf("#");
	printf("#\n");
	for(i=0;i<h;i++) free(a[i]);
	free(a);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
  	int N;
  	cin >> N;
  	int cnt = 0;
  	while (N) {
     	if (N % 10 == 2) {
          cnt++;
        }
        N /= 10;
    }
  	cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n = II()
s = IS()
ans = 0
cuts = [[s[:i],s[i:]] for i in range(1,len(s))]
for cut in cuts:
    count = 0 
    for char in set(cut[0]):
        if char in set(cut[1]):
            count += 1
            ans = max(ans, count)
print(ans)






Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef pair<long long int,long long int> pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
#define  MAX 100005
#define ll long long int
long long int MOD=998244353;
long long int mod=1e9+7;
long long int INF=1e18;

int main()
{
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(u==s)
        a--;
    else
        b--;
    cout<<a<<" "<<b;
    return 0;
}


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

#define fio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define tc(t) int t; cin >> t; while (t--)
#define for0(i, n)  for(int i = 0; i < n; i++)
#define pb push_back
#define int long long 

void solve()
{
  int x;
  for0(i, 5) {
    cin>>x;
    if(x == 0) {
      cout<<i+1;
      break;
    }
  }
}

signed main() {

  fio;
  //tc(tt) {
    solve();
    cout<<"\n";
  //}
  
  return 0;
}

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

typedef long long ll;


struct Node{
    ll key;
    Node *parent,*left,*right;
};


struct Tree{
    Node *nil,*root;

    void init(){
        root=nil;
    }

    void add(ll key){
        Node *newnode;
        Node *p;
        newnode = (Node*)malloc(sizeof(Node));

        newnode->key = key;
        newnode->parent = newnode->right = newnode->left = nil;

        Node *pa = find_parent(key);
        if(pa == nil){
            root = newnode;
        }else if(key < pa->key){
            pa->left = newnode;
        }else{
            pa->right = newnode;
        }
    }

    Node* find_parent(int key){
        Node *pa=nil;
        Node *loc=root;
        while(loc != nil){
            pa = loc;
            if(key < loc->key){
                loc = loc->left;
            }else{
                loc = loc->right;
            }
        }
        return pa;
    }

    void print_in(Node *r){
        if(r==nil)return;
        print_in(r->left);
        cout << " " << r->key;
        print_in(r->right);
    }

    void print_pre(Node *r){
        if(r==nil)return;
        cout << " " << r->key;
        print_pre(r->left);
        print_pre(r->right);
    }
    void print(){
        print_in(root);
        cout << endl;
        print_pre(root);
        cout << endl;
    }
};


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

    Tree tree;
    tree.init();
    int n;
    cin >> n;
    string s;
    int k;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s=="insert"){
            cin >> k;
            tree.add(k);
        }else{
            tree.print();
        }
    }
    return 0;
}



Measured memory_bytes: 26648
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000

int main(){	
	int a,b;
    cin>>a>>b;

    if(a<=b) cout<<a<<endl;
    else cout<<a-1<<endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
ct = [list(map(int,input().split())) for _ in range(N)]

#print(N, T, ct)
ct2 = []
#
for p in ct:
    if p[1] <= T:
        ct2.append(p)

#print(ct2)
if len(ct2) == 0:
    print("TLE")
else:
    print(sorted(ct2)[0][0])

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

vector<bool> solve(int n, vector<bool> const & s) {
    REP (t_0, 2) {
        REP (t_1, 2) {
            vector<bool> t(n);
            t[0] = t_0;
            t[1] = t_1;
            REP3 (i, 2, n) {
                t[i] = (t[i - 2] ^ t[i - 1] ^ s[i - 1]);
            }
            if (s[n - 1] == (t[n - 2] ^ t[n - 1] ^ t[0]) and
                    s[0] == (t[n - 1] ^ t[0] ^ t[1])) {
                return t;
            }
        }
    }
    return vector<bool>();
}

int main() {
    int n; cin >> n;
    vector<bool> s(n);
    REP (i, n) {
        char s_i; cin >> s_i;
        s[i] = (s_i == 'o');
    }
    vector<bool> result = solve(n, s);
    if (result.empty()) {
        cout << -1 << endl;
    } else {
        for (bool p : result) cout << (p ? 'S' : 'W');
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
/**********************************************************
* @Author: 			   Kirito
* @Last Modified by:   Kirito
* @Remark:
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn=111111;


int main()
{
    int n;
    cin>>n;
    if(n%10==3) cout<<"bon"<<endl;
    else if(n%10==0||n%10==1||n%10==6||n%10==8) cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
constexpr int MOD = 1e9+7;
int n, k;
ll dp[100005], ans;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MOD) if(n%2) (res *= b) %= MOD;
	return res;
}

int main(){
	scanf("%d%d", &n, &k);
	for(int i=k; i; i--){
		dp[i] = exp(k/i,n);
		for(int j=i*2; j<=k; j+=i) (dp[i] += MOD - dp[j]) %= MOD;
		(ans += dp[i] * i) %= MOD;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4540
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
bool is_prime(long long n) {  //素数判定
  for(int64_t i = 2; i * i <= n; i++) {
    if(n % i == 0) return false;
  }
  return true;
}
bool check_int(char c){
  if('0' <= c && c <= '9')return true;
  else return false;
}
int solve(){
  int a,b;
  cin >> a >> b;
  bool ans = true;
  string s;
  cin >> s;
  rep(i,a){
    if(!check_int(s[i]))ans = false;
  }
  if(s[a] != '-')ans = false;
  REP(i,a + 1,b + a){
    if(!check_int(s[i]))ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

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

#define REP(i,n) for(int i=0;i<n;i++)

void solve(){
    int m,mn,mx;
    cin>>m>>mn>>mx;
    if(m==0){
        exit(0);
    }
    vector<int>P(m);
    REP(i,m){
        cin>>P[i];
    }
    int mx_d=0;
    int ans=0;
    for(int i=mn;i<=mx;i++){
        int dif=P[i-1]-P[i];
        if(dif>=mx_d){
            mx_d=dif;
            ans=i;
        }
    }
    cout<<ans<<endl;
}
int main(){
    while(true)solve();
}


Measured memory_bytes: 3108
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions
int bit_count(ll x) {
    int cnt = 0;
    ll mask = 0x01;
    REP(i,64) {
        if (x & mask) cnt++;
        mask <<= 1;
    }
    return cnt;
}
void get_combination(vector<vs>& comb, vs a, int n){    
    const int AL = a.size();
    const int PTN = 1 << AL;
    for (int i = 0; i < PTN; i++) {
        if (bit_count(i) != n) continue;

        int mask = 0x01;
        vs p;
        for (int j = 0; j < AL; j++) {
            if ((i&mask) > 0) {
                p.push_back(a[j]);
            }

            mask <<= 1;
        }
        comb.push_back(p);
    }
}
#endif


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


    int N; cin >> N;
    vs S(N); REP(i, N) cin >> S[i];

    map<string, int> mp;
    REP(i,N) {
        string s = {S[i][0]};
        mp[s]++;
    }
    
    vs a;
    a.push_back("M");
    a.push_back("A");
    a.push_back("R");
    a.push_back("C");
    a.push_back("H");
    vector<vs> comb;
    get_combination(comb, a, 3);

    ll ans = 0;
    for(vs v : comb) {
        ll cnt = 1;
        for(string s : v) {
            cnt *= mp[s];
        }
        ans += cnt;
    }

    cout << ans << endl;


    return 0;
}


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

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

	int ans = 0;
	rep(i, 1, n) {
		string a, b;
		a = s.substr(0, i); b = s.substr(i);
		set<char> st; rep(j, 0, a.size()) st.insert(a[j]);
		int count = 0;
		rep(j, 0, b.size()) {
			if (st.count(b[j])) {
				count++;
				st.erase(b[j]);
			}
		}
		ans = max(ans, count);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

beforeNumber = 0
manzoku = 0
for i in a:
    if beforeNumber != 0 and beforeNumber + 1 == i:
        manzoku = manzoku + b[i-1] + c[beforeNumber-1]
    else:
        manzoku += b[i-1]
    beforeNumber = i
print(manzoku)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vi = vector<int>;
using vl = vector<i64>;
using vd = vector<double>;
using pi = pair<int, int>;
using pl = pair<i64, i64>;
using pd = pair<double, double>;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(T &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) cout << " ";
    cout << *it;
  }
  cout << endl;
}

int main() {
  int N, K;
  cin >> N >> K;
  vi v(N);
  REP(i, N) cin >> v[i];
  int ans = 0;
  int s = min(N, K);
  vi left(s + 1), right(s + 1);
  FOR(i, 1, s + 1) {
    left[i] = left[i - 1] + v[i - 1];
    right[i] = right[i - 1] + v[N - i];
  }
  REP(i, s + 1) {
    REP(j, s + 1 - i) {
      priority_queue<int> q;
      int score = left[i] + right[j];
      REP(ii, i) q.push(-v[ii]);
      REP(jj, j) q.push(-v[N - 1 - jj]);
      REP(k, K - i - j) {
        if (q.empty()) break;
        auto f = q.top();
        if (f <= 0) break;
        q.pop();
        score += f;
      }
      ans = max(ans, score);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
x = int(input())
if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
elif x < 2000:
    print(1)


Measured memory_bytes: 9108
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
int N;
long long int M;

while(1){
cin>>N>>M;if(N==0&&M==0)break;
int D[10002][2]={};
int P[10001]={};
for(int i=0;i<N;i++)
cin>>D[i][0]>>D[i][1];
int c=0;
for(int i=0;i<N;i++)
	for(int j=N-1;j>i;j--)
	{if(D[j][1]>D[j-1][1]){
		int t=D[j][1];D[j][1]=D[j-1][1];D[j-1][1]=t;
		int T=D[j][0];D[j][0]=D[j-1][0];D[j-1][0]=T;
}
	}

for(int i=0;i<N;i++)
	if(D[i][0]>0){if(M>=D[i][0]){M-=D[i][0];D[i][0]=0;}
	else{D[i][0]-=M;M=0;}
	}

for(int i=0;i<N;i++)
	c+=D[i][1]*D[i][0];

cout<<c<<endl;

}

return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <climits>
#include <algorithm>


using namespace std;


int main()
{
    string s;
    long long N;
    cin >> N;
    cin >> s;
    long long cost = count(s.begin() + 1, s.end(), 'E');
    long long ans = cost;

    for (long long i = 1; i < s.length(); i++) {
        cost += (s[i - 1] == 'W') ? 1 : 0;
        cost -= (s[i] == 'E') ? 1 : 0;
        ans = min(ans, cost);
    }
    cout << ans << endl;
}


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

bool check(int n)
{
	if(n==1) return false;
	for(int i=2;i*i<=n;i++){
		if( n%i==0 ) return false;
	}	
	return true;
}

int main() {
	while(true){
		int a,d,n;
		cin >> a >> d >> n;
		if(a==0&&d==0&&n==0)break;
		while(n>0){
			if( check(a) ){
				n--;
				if(n==0){
					cout << a << endl;
					break;
				}
			}
			a+=d;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <stdio.h>

using namespace std;
typedef long long ll;
const ll mod = 998244353;
const ll len = 2 * (int) 1e5 + 1;



int main() {
//    ios_base::sync_with_stdio(false); cin.tie(nullptr);
//    freopen("cowdate.in", "r", stdin);
//    freopen("cowdate.out", "w", stdout);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c;
    return 0;
}


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

const int N = 1e5 + 9, OO = 1e9 + 9;

int arr[N], mem[N], n;

int dp(int i) {
  if (i + 1 == n)
    return 0;
  if (i >= n)
    return OO;
  int& ret = mem[i];
  if (~ret)
    return ret;
  ret = OO;
  ret = min(ret, dp(i + 1) + abs(arr[i] - arr[i + 1]));
  ret = min(ret, dp(i + 2) + abs(arr[i] - arr[i + 2]));
  return ret;
}

int main() {
  //  freopen ("input.in","r",stdin);
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> arr[i];
  memset(mem, -1, sizeof mem);
  cout << dp(0) << endl;
  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n;cin>>n;
    cout<<3*n*n<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

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

  int A[N];
  A[0] = 0;
  rep(i, N - 1) {
    if (s[i + 1] == 'E') A[0]++;
  }
  int ans = A[0];

  rep(i, N - 1) {
    if (s[i] == 'W' && s[i + 1] == 'W') A[i + 1] = A[i] + 1;
    else if (s[i] == 'E' && s[i + 1] == 'E') A[i + 1] = A[i] - 1;
    else A[i + 1] = A[i];
    ans = min(ans, A[i + 1]);
  }

  cout << ans << endl;


}


Measured memory_bytes: 1796
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int r[]=new int[n];
		int a,b;
		int counter=0;

		for (int i=0;i<n;++i){
			r[i]=sc.nextInt();
		}

		for (int i=0;i<n;++i){
			for (int j=n-1;j>i;--j){
				if(r[j]<r[j-1]){
					a=r[j];
					b=r[j-1];
					r[j]=b;
					r[j-1]=a;
					++counter;
				}
			}
		}

		for (int i=0;i<n;++i){
			System.out.print(r[i]);
			if(i != n-1)System.out.print(" ");
		}
		System.out.println();
		System.out.println(counter);
	}

}


Measured memory_bytes: 26312
/*https://atcoder.jp/contests/abc141/tasks/abc141_c*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int n, pos, q;
	long long k;
	cin >> n >> k >> q;
	int a[n];
	for (int i = 0; i < n; i++)
		a[i] = k - q;
	while (q--)
	{
		cin >> pos;
		pos--;
		a[pos]++;
	}
	for (int i = 0; i < n; i++)
	{
		// cout << a[i] << "->";
		if (a[i] <= 0)
			cout << "No" << "\n";
		else
			cout << "Yes" << "\n";
	}
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
#define int ll
const int N = 500+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, k, a[N];

int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> k;
	int sum = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		sum += a[i];
	}
	vector<int> factors;
	for(int i=1; i*i <= sum; i++){
		if (sum%i == 0){
			factors.push_back(i);
			factors.push_back(sum/i);
		}
	}
	int ans = 1;
	vector<int> remainder;
	for(auto d:factors){
		remainder.clear();
		int cost_to_high = 0;
		for(int i=0; i<n; i++){
			// if (a[i] % d == 0) continue;
			remainder.push_back(a[i] % d);
			cost_to_high += d - (a[i] % d);
		}
		int cost_to_low = 0;
		sort(remainder.begin(), remainder.end());
		for(auto r:remainder){
			cost_to_low += r;
			cost_to_high -= (d-r);
			if (cost_to_low == cost_to_high && cost_to_high <= k) {
				ans = max(ans, d);
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256