akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define MCLR(a) memset((a), -1 ,sizeof(a))
#define SZ(a) (sizeof(a))
#define FILL(a,v) fill((int*)a,(int*)(a+(SZ(a)/SZ(*(a)))),v)
bool cheak(int x, int y, int xMax, int yMax){return x >= 0 && y >= 0 && xMax > x && yMax > y;}
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 10007;
const int INF = 2147483647;

int main()
{
	string s;

	while (getline(cin, s) && !(s[0] == '.' && s.size()==1)){
		int i;
		stack<char> sc;
		for(i = 0;i < s.size();i++){
			if (s[i] == '(' || s[i] == '[')sc.push(s[i]);

			if (s[i] == ')')if (sc.size() && sc.top() == '('){
				sc.pop();
			}
			else break;
			if (s[i] == ']')if (sc.size() && sc.top() == '['){
				sc.pop();
			}
			else break;
		}
		if (i == s.size() && !sc.size())cout << "yes" << endl;
		else							cout << "no"	<< endl;
	}

}

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

#define M 200005
#define MOD 1000000007
#define PI 3.14159265358979323846
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> PII;
typedef pair<lli,lli> PLL;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int x,n;
	cin>>x>>n;

	map<int,int> mp;
	for(int i=0;i<n;i++)
	{
		int temp;
		cin>>temp;
		mp[temp]++;
	}

	vector<PII> res;
	for(int i=0;i<=1000;i++)
	{
		if(mp[i]==0)
		{
			res.ep(mk(abs(i-x),i));
		}
	}

	sort(all(res));

	int ans = res[0].second;
	cout<<ans<<"\n";

}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <utility>
#include <functional>
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++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 ll = long long;
using P = std::pair<int, int>;
using namespace std;
 
constexpr int INF = 1000000000; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18
constexpr int MAX_N = 201;
 
// d[i][j]はi->jの最小コスト
int d[MAX_N][MAX_N];
int dp[256][8];
int N, M, R;
vector<int> r;
 
void solve(){
	for(int s = (1 << R) - 2; s >= 0; --s){
		REP(v, R){
			REP(u, R){
				if(!((s >> u) & 1)){
					dp[s][v] = min(dp[s][v], dp[s | 1 << u][u] + d[r[v]][r[u]]);
					//cout << "dp[" << s << "][" << v << "]: " << dp[s][v] << "\nu: " << u << "\n";
				}
			}
		}
	}
}
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M >> R;
	r = vector<int>(R);
	for(int i = 0; i < N + 1; ++i){
		fill(d[i] + 1, d[i] + N + 1, INF);
		d[i][i] = 0;
	}
	REP(i, R) cin >> r[i];
	REP(i, M){
		int a, b, c;
		cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;
	}
 
	// WF法
	FOR(k, 1, N + 1){
		FOR(i, 1,  N + 1){
			FOR(j, 1, N + 1){
				 d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	// ビットDP
	for(int S = 0; S < 1 << R; ++S) {
		fill(dp[S], dp[S] + R, INF);
	}
	REP(i, R) dp[(1 << R) - 1][i] = 0;
	solve();
	int m = INF;
	REP(i, R){
		m = min(m, dp[1 << i][i]);
	}
 
	cout << m << "\n";
 
	return 0;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<ll,ll> p;

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

unordered_map<ll,ll> dp;

ll f(ll n) {
    if(n==0) return 0;
    if(n==1) return 1;
    if (dp.find(n)!=dp.end()) return dp[n];
    return dp[n] = ( f(n/2) + f((n+1)/2) + f((n-1)/2) ) % INF;
}

int main(){
    ios::sync_with_stdio(false);
    
    
//    愚直解法 1 ~ 128
//    set<p> s;
//    ll pre = 1;
//    //for(int N = 1; N <= 128; N*=2) {
//    REP(N,1000) {
//        s.clear();
//        REP(a,N+1) REP(b,N+1) {
//            ll u = a xor b;
//            ll v = a + b;
//            if (u<=N && v <=N)
//                s.insert(p(u,v));
//        }
//        cout << "N: " << N << " ";
//        cout << "size: " << s.size() << endl;
//        //cout << "diff: " << s.size() - pre << endl;
//        pre = s.size();
//    }
//    for(auto x: s){
//        cout << x.first << " " << x.second << endl;
//    }
    
    ll N;
    cin >> N;
    cout << f(N+1) << endl;
    
    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

int N, A[100005];
ll cum[100005];

int main() {
	
	cin >> N;
	REP(i, N) {
		cin >> A[i];
	}

	sort(A, A + N);

	cum[0] = A[0];
	for (int i = 1;i < N;i++) {
		cum[i] = cum[i - 1] + A[i];
	}

	/*
	REP(i, N) cout << cum[i] << " ";
	cout << endl;
	*/

	int cnt = 0;
	for (int i = N - 2;i >= 0;i--) {//N-1は必ず生き残れる．
		if (cum[i] * 2 >= A[i + 1]) cnt++;
		else break;
	}

	cout << cnt + 1 << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int ans = 0;
    int counter = 0;

    for (int i = 1; i <= N; i+=2) {
        for (int j = 1; j <= i; j++) {
            if(i%j == 0) {
                counter++;
            }
            if (counter == 8) {
                counter = 0;
                ans++;
            }
        }
        counter = 0;
    }

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

Measured memory_bytes: 888
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

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

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int m, n;
	int start, goal;
	int[][] a;

	void run(){
		for(;;){
			m=sc.nextInt();
			if(m==0){
				break;
			}
			start=sc.nextInt()-1;
			goal=sc.nextInt()-1;
			n=sc.nextInt();
			a=new int[n][m-1];
			for(int j=0; j<n; j++){
				String s=sc.next();
				for(int i=0; i<m-1; i++){
					a[j][i]=s.charAt(i)-'0';
				}
			}
			solve();
		}
	}

	void solve(){
		if(check()){
			println("0");
			return;
		}

		for(int j=0; j<n; j++){
			for(int i=0; i<m-1; i++){
				if(a[j][i]==1){
					continue;
				}
				if(i<m-2&&a[j][i+1]==1){
					continue;
				}
				if(i>0&&a[j][i-1]==1){
					continue;
				}
				a[j][i]=1;
				if(check()){
					println((j+1)+" "+(i+1));
					return;
				}
				a[j][i]=0;
			}
		}
		println("1");
	}

	boolean check(){
		int p=start;
		for(int j=0; j<n; j++){
			if(p<m-1&&a[j][p]==1){
				p++;
			}else if(p>0&&a[j][p-1]==1){
				p--;
			}
		}
		return p==goal;
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;

int a,b,c;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>a>>b>>c;
	if(b-a==c-b)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e16;
typedef long long ll;

int main(){

  int N, M, S, T; cin >> N >> M >> S >> T;
  S--; T--;

  vector < vector < pair<ll, int> > > YEN(N), SNUKE(N);
  // (最短距離・次の頂点)のペアを保存
  for (int i = 0; i < M; i++){
    int u, v, a, b; cin >> u >> v >> a >> b;
    u--; v--;

    YEN[u].push_back(make_pair(a, v)); YEN[v].push_back(make_pair(a, u));
    SNUKE[u].push_back(make_pair(b, v)); SNUKE[v].push_back(make_pair(b, u));
  }
  
  vector <ll> min_YEN(N);
  fill(min_YEN.begin(), min_YEN.end(), 1e16);
  min_YEN[S] = 0;

  priority_queue < pair<ll, int>, vector < pair<ll, int> >, greater<pair<ll, int> > > que1;
  que1.push(make_pair(0, S));

  vector <bool> used(N);

  while (!que1.empty()){
    pair<ll, int> P = que1.top(); que1.pop();

    if (used[P.second] == false){
      used[P.second] = true;

      for (int i = 0; i < YEN[P.second].size(); i++){
        ll D = YEN[P.second][i].first;
        int next = YEN[P.second][i].second;

        if (used[next] == false){
          if (min_YEN[next] > min_YEN[P.second] + D){
            min_YEN[next] = min_YEN[P.second] + D;
            que1.push(make_pair(min_YEN[next], next));
          }
        }
      }
    }
  }

  vector <ll> min_SNUKE(N);
  fill(min_SNUKE.begin(), min_SNUKE.end(), 1e16);
  min_SNUKE[T] = 0;

  fill(used.begin(), used.end(), false);
  que1.push(make_pair(0, T));

  while (!que1.empty()){
    pair<ll, int> P = que1.top(); que1.pop();

    if (used[P.second] == false){
      used[P.second] = true;

      for (int i = 0; i < SNUKE[P.second].size(); i++){
        ll D = SNUKE[P.second][i].first;
        int next = SNUKE[P.second][i].second;

        if (used[next] == false){
          if (min_SNUKE[next] > min_SNUKE[P.second] + D){
            min_SNUKE[next] = min_SNUKE[P.second] + D;
            que1.push(make_pair(min_SNUKE[next], next));
          }
        }
      }
    }
  }

  vector <ll> cost(N);
  for (int i = N - 1; i >= 0; i--){
    if (i == N - 1) cost[i] = min_YEN[i] + min_SNUKE[i];
    else cost[i] = min(cost[i + 1], min_YEN[i] + min_SNUKE[i]);
  }
  
  for (int i = 0; i < N; i++){
    ll ans = 1e15 - cost[i];
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 19576
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for modular inverse
ll inv(ll a,ll m){
	return mpow(a,m-2,m);
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

void solve(){
	//code
	ll n,x,t;
	cin>>n>>x>>t;
	ll p=(n+x-1)/x;
	cout<<p*t;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 1400;
const int INF = 1 << 21;
const int NOTV = 0;
const int VIST = 1;
const int n = 10;
int a[10][10];
int dijkstra(int x, int y) {
	//int a[n][n];
	const int NMAX = 10;
	int p[NMAX];
	int d[NMAX];
	int vst[NMAX];
	int minc;
	for (int i = 0; i < n; i++) {
		vst[i] = NOTV;
		d[i] = INF;
	}
	d[x] = 0;
	p[x] = -1;
	while (1) {
		minc = INF;
		int u;
		for (int i = 0; i < n; i++) {
			if (minc > d[i] && vst[i] == NOTV) {
				u = i;
				minc = d[i];
			}
		}
		if (minc == INF) break;
		vst[u] = VIST;
		for (int v = 0; v < n; v++) {
			if (vst[v] == NOTV && a[u][v] != INF) {
				if (d[u] + a[u][v] < d[v]) {
					d[v] = d[u] + a[u][v];
					vst[v] = NOTV;
				}
			}

		}
	}
	int ans = d[y];
	return ans;
}


int main() {
	//int a[10][10];
	int h, w;
	int A;
	cin >> h >> w;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> a[i][j];
		}
	}
	int cost=0;
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			cin >> A;
			if (A == -1 || A==1) {
				continue;
			}
			else {
				cost += dijkstra(A, 1);
			}
		}
	}
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char eki[2] = {0};
    int count = 0;
    for(int i=0; i<3; i++){
        scanf("%s", &eki[i]);
        if(i>=1){
            if(eki[i] != eki[i-1]){
                count++;
            }
        }
    }
    if(count>=1){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
from collections import Counter
N = int(input())
listA = input().split()

if N % 2 == 1:
    count = Counter(listA)
    i = 0
    flag = True
    while i < N:
        if i == 0 and count[str(i)] == 1:
            i = i + 2
            continue
        elif count[str(i)] == 2:
            i = i + 2
            continue
        else:
            flag = False
            break
    if flag:
        print((2 ** ((N-1)//2)) % (10**9 + 7))
    else:
        print("0")
else:
    count = Counter(listA)
    i = 1
    flag = True
    while i < N:
        if count[str(i)] == 2:
            i = i + 2
            continue
        else:
            flag = False
            break
    if flag:
        print(2 ** (N//2) % (10**9 + 7))
    else:
        print("0")

Measured memory_bytes: 15216
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int ans = 1e5;
    vector<int> v(5);
    rep(i, 5) cin >> v[i];
    sort(v.begin(), v.end());
    do{
        int sum = 0;
        rep(i, 5){
            sum += v[i];
            while(sum % 10 != 0 && i != 4){
                sum++;
            }
        }
        ans = min(ans, sum);
    }while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T>
using mp = pair<T,T>;
template<class T>
using vec = vector<T>;
using ll = long long;
int main(){
    int N,K;
    cin >> N >> K;
    //lli ans = 0;
    /*for(int i = 1,_N=N*2;K*i <= _N;i++){
        kc.push_back(K*i);
    }
    /*for(int &x:kc){
        cout << "*" << x << "\n";
    }*/
    ll ans=0L;
    int res = N/K;
    ans+=(ll)res*res*res;
    //cout << ans << "***\n";
    if(K%2==0){
        if(K/N > 2){
            ans = 0;
        }
        else{
            int tmp = ((N+(K/2))/K);
            //cout << tmp << "**\n";
            ans+=(ll)tmp*tmp*tmp;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

#define int long long
#define LL long long
#define ULL unsigned long long

const int LL_INF = ~(ULL)0 >> 1;

signed main() {
    int n, m, joi[100002] = {0};
    cin >> n >> m;

    for (int i = 0; i < n - 1; ++i) {
        int temp;
        cin >> temp;
        joi[i + 1] = joi[i] + temp;
    }

    int sum = 0, pos = 0;
    for (int i = 0; i < m; ++i) {
        int mv;
        cin >> mv;
        sum += abs(joi[pos] - joi[pos + mv]);
        sum %= 100000;
        pos += mv;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1944
N, K = map(int, input().split())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ans = (max(x) - min(x)) * (max(y) - min(y))

for i in range(N):
    for j in range(N):
        for k in range(N):
            for l in range(N):
                cnt = 0

                lx = x[i]
                rx = x[j]
                uy = y[k]
                dy = y[l]

                if lx >= rx or dy >= uy:
                    continue

                for m in range(N):
                    if lx <= x[m] <= rx and dy <= y[m] <= uy:
                        cnt += 1

                if cnt >= K:
                    ans = min(ans, (rx - lx) * (uy - dy))

print(ans)

Measured memory_bytes: 50140
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;cin>>N;
    vector<int>V1(N);
    vector<int>V2(N);
    for(int i=0;i<N;i++)cin>>V1[i];
    for(int i=0;i<N;i++)cin>>V2[i];
    int sum=0;
    for(int i=0;i<N;i++){
        if(V1[i]>V2[i])sum+=V1[i]-V2[i];
    }
    cout<<sum<<endl;
}

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

using namespace std;

struct Node {
	vector<Node> ch;
	int v;

	Node() { v = -1; }
};

Node MakeTree(string& s, int& pos) {
	Node ret;
	if (s[pos] == '[') {
		while (s[pos] == '[') {
			++pos;
			ret.ch.push_back( MakeTree(s, pos) );
		}
		++pos;
	}
	else {
		int v = 0;
		while ('0' <= s[pos] && s[pos] <= '9') {
			v *= 10;
			v += s[pos] - '0';
			++pos;
		}
		++pos;
		ret.v = v/2+1;
	}
	return ret;
}

int cal(Node& node) {
	if (node.v > -1) return node.v;

	vector<int> v;
	for (int i = 0; i < node.ch.size(); ++i) {
		v.push_back( cal(node.ch[i]) );
	}
	sort( v.begin(), v.end() );

	int ret = 0;
	for (int i = 0; i < node.ch.size()/2+1; ++i) {
		ret += v[i];
	}
	return ret;
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		string s; cin >> s;
		Node root;
		{
			int pos = 0;
			root = MakeTree(s, pos);
			cout << cal(root) << endl;
		}
	}
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
	ll n,W;
	cin>>n>>W;
	ll w[n];
	ll v[n],x[n];
	rep(i,0,n) cin>>w[i]>>v[i];
	rep(i,0,n)x[i]=w[i];

	vector <pair<ll,ll>> p(n);
	vector <ll> p1,p2,p3,p4;
	rep(i,0,n)p[i]=make_pair(v[i],w[i]);
	sort(p.rbegin(),p.rend());
	sort(x,x+n);
    ll b=x[0];
    p1.push_back(0);
    p2.push_back(0);
    p3.push_back(0);
    p4.push_back(0);
	rep(i,0,n){
		if(p[i].second==b) p1.push_back(p[i].first);
		if(p[i].second==b+1) p2.push_back(p[i].first);
		if(p[i].second==b+2) p3.push_back(p[i].first);
		if(p[i].second==b+3) p4.push_back(p[i].first);
	}

	ll m=0;
	ll value1=0,value2=0,value3=0,value4=0;
	rep(i,0,p1.size()){
		value1+=p1[i];
		rep(j,0,p2.size()){
			value2+=p2[j];
			rep(k,0,p3.size()){
				value3+=p3[k];
				rep(l,0,p4.size()){
					value4+=p4[l];
					if((b*i+(b+1)*j+(b+2)*k+(b+3)*l)<=W){
						m = max(value1+value2+value3+value4,m);
					}
				}
               value4=0;
			}
            value3=0;
		}
        value2=0;
	}
	cout<<m<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
struct Dice{/*Procon Lib from @primenumber*/
  int t, r, f;
  int top() { return t; }
  int bottom() { return 7 - t; }
  int right() { return r; }
  int left() { return 7 - r; }
  int front() { return f; }
  int back() { return 7 - f; }
  void toFront() { swap(f, t); t = 7 - t; }
  void toBack() { toFront(); toFront(); toFront(); }
  void toRight() { swap(t, r); t = 7 - t; }
  void toLeft() { toRight(); toRight(); toRight(); }
  void toClock() { swap(f, r); r = 7 - r; }
  void toConter() { toClock(); toClock(); toClock(); }
};

int main(){
	Dice dai1;
	int men[7];
	FOR(i,1,7) cin >> men[i];
	dai1.t = 1; dai1.r = 3; dai1.f = 2;
	string s;
	cin >> s;
	REP(i,s.size()){
		if(s[i]=='W') dai1.toLeft();
		if(s[i]=='E') dai1.toRight();
		if(s[i]=='N') dai1.toBack();
		if(s[i]=='S') dai1.toFront();
	}
	cout << men[dai1.t] << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, ans;
string s;
unordered_map<string, int> mp;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        ++mp[s];
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
        cin >> s;
        --mp[s];
    }
    for (auto &[s, cnt] : mp) {
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
 int n; cin >> n;
 int a[n],b[n];
 rep(i,n) cin >> a[i];
 memcpy(b,a,sizeof(a));
 sort(b,b+n);
 int max = b[n-1]; int max2 = b[n-2];
 rep(i,n) (a[i]==max)?cout<<max2<<endl:cout<<max<<endl;
}

Measured memory_bytes: 3200
#include<stdio.h>
#include<algorithm>
#include<map>
#include<string>
#include<sstream>
#include<limits.h>
using namespace std;
int main(void)
{
	const int N = 8;
	int c[N] = {1,2,1,2,1,4,1,4,};
	int p[N];
	int i,j,a,V;
	map<int,int> m;
	for(;;)
	{
		for(i = 0; i < N; ++i)
		{
			if(scanf("%d", &p[i]) != 1)
				return 0;
		}
		for(i = 0; i < N; i++)
		{
			V = a = 0;
			for(j = 0; j < N; j++)
			{
				V = V*10+c[(i+j)%N];
				a += max(0, p[j]-c[(i+j)%N]);
			}
			m[V] = a;
		}
		int least = INT_MAX, index;

		for(map<int,int>::iterator ite = m.begin();
			ite != m.end();
			++ite)
		{
			if(least > ite->second)
			{
				least = ite->second;
				index = ite->first;
			}
		}
		stringstream ss;
		ss << index;
		string str = ss.str();
		for(i = 0; i < str.size(); i++)
		{
			printf("%s%d", (i?" ":""), str[i]-'0');
		}
		putchar('\n');
	}
	return 1;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}

vector<ll>v[200000];
map<ll,ll>is;
void dfs(ll node){
    is[node]=1;
    fo(i,v[node].size()){
        if(is[v[node][i]]==0){
            dfs(v[node][i]);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        cin>>n;
        cin>>m;
        fo(i,m){
            ll a,b;
            cin>>a>>b;
            v[a].pb(b);
            v[b].pb(a);
        }
        ll ans=0;
        for(int i=1;i<=n;i++){
            if(is[i]==1)continue;
            else{
                ans++;
                dfs(i);
            }
        }
        cout<<ans-1;





        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	ll tmp = 1;
	REP(i, n) {
		if (tmp * 2 >= tmp + k)tmp += k;
		else tmp *= 2;
	}
	cout << tmp << endl;
}


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

using namespace std;

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

static const double eps = 1e-8;

int mypow(int x,int n){
	int res = 1;
	while(n>0){		
		if(n & 1) res = res*x;
		x = x * x;
		n>>=1;
	}
	return res;
}


int conv(vector<int>& sets,int n){
	int res = 0;
	for(int i=0;i<sets.size();i++){
		for(int j=0;j<n;j++){
			if(sets[i] & (1<<j)){
				res += i * mypow(3,j);
			}
		}
	}
	return res;
}

int bfs(int m,int n,vector<int>& root,bool* visited){

	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,root));
	visited[conv(root,n)] = 0;
	vector<int> tmp;
	vector<int> sets;
	while(!que.empty()){
		int cost = que.top().first;
		
		sets = que.top().second;

		if(sets[1]==0 && sets[2]==0) return cost;
		if(sets[0]==0 && sets[1]==0) return cost;

		if(cost >= m) break;
		que.pop();
		for(int i=0;i+1<sets.size();i++){
			if((sets[i] && sets[i+1] && sets[i] < sets[i+1]) 
				|| (!sets[i] && sets[i+1])){
				tmp = sets;

				int pos=0;
				for(int j=n;j>=0;j--){
					if(tmp[i+1] & (1<<j)){
						pos = j;
						break;
					}
				}
				tmp[i+1] &= ~(1<<pos);
				tmp[i] |= (1<<pos);

				
				int next;
				if(!visited[(next = conv(tmp,n))]){
					visited[next] = cost+1;
					que.push(P(cost+1,tmp));
				}
			}

			else if((sets[i] && sets[i+1] && sets[i] > sets[i+1]) 
				|| (sets[i] && !sets[i+1])){
				tmp = sets;

				int pos=0;
				for(int j=n;j>=0;j--){
					if(tmp[i] & (1<<j)){
						pos = j;
						break;
					}
				}
				tmp[i] &= ~(1<<pos);
				tmp[i+1] |= (1<<pos);

				int next;
				if(!visited[(next = conv(tmp,n))]){
					visited[next] = cost+1;
					que.push(P(cost+1,tmp));
				}
			}
		}
	}
	return -1;
}

int main(){

	int n,m;
	while(~scanf("%d %d",&n,&m)){
		if(n==m && m==0) break;
		vector<int> sets(3);
		bool* visited = new bool[mypow(3,n)]();
		for(int i=0;i<3;i++){
			int amount;
			scanf("%d",&amount);
			for(int j=0;j<amount;j++){
				int size;
				scanf("%d",&size);
				sets[i] |= (1<<(size-1)); 
			}
		}

		printf("%d\n",bfs(m,n,sets,visited));
		delete[] visited;
	}
	//printf("%d %d %d\n",mypow(3,0),mypow(3,1),mypow(3,2));
}

Measured memory_bytes: 14000
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int x;
    cin >> x;
    int y = x/100, z = x%100;
    z = (z+5-1)/5;
    // z /= 5;
    cout << (y < z ? 0 : 1) << endl;
}

Measured memory_bytes: 256
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        x: u64,
        y: u64,
    }
    println!("{}", gcd(x,y));
}
/* vim:set foldmethod=marker: */



Measured memory_bytes: 5036
#include<stdio.h>
long long t,tt;
long long a[100001],s[100001];
int b[100001],flg[100001];
int main(void)
{
	int n,q,i,j,c[1000],x;
	scanf("%d %lld %d",&n,&t,&q);
	for(i=1;i<=n;i++){
		scanf("%lld %d",&a[i],&b[i]);
		flg[i]=0;
	}	
	for(i=1;i<=q;i++)	scanf("%d",&c[i]);
	for(i=1;i<n;i++){
		if(b[i]==1&&b[i+1]==2&&a[i+1]-a[i]<t*2){
			flg[i]=1; flg[i+1]=1;
			s[i]=s[i+1]=(a[i]+a[i+1])/2;
		}
	}
	x=0;
	for(i=n;i>=1;i--){
		if(flg[i]==1){
			tt=s[i];	x=1;
		}
		else{
			if(b[i]==1&&x==1&&a[i]+t>tt){
				s[i]=tt;	flg[i]=2;
			}
		}
	}
	x=0;
	for(i=1;i<=n;i++){
		if(flg[i]==1){
			tt=s[i];	x=1;
		}
		else{
			if(b[i]==2&&x==1&&a[i]-t<tt){
				s[i]=tt;	flg[i]=2;
			}
		}
	}
	for(i=1;i<=n;i++){
		if(flg[i]==0){
			if(b[i]==1) s[i]=a[i]+t;
			else s[i]=a[i]-t;
		}
	}	
	for(i=1;i<=q;i++) printf("%lld\n",s[c[i]]);
}

Measured memory_bytes: 5096
n = int(input())
a = list(map(int,input().split()))
a.sort()
ma = a[-1]
mn = float("inf")
mni = -1
for i in range(n-1):
  if abs(2*a[i]-ma) < mn:
    mn = abs(2*a[i]-ma)
    mni = i
print(ma,a[mni])

Measured memory_bytes: 85336
#include<stdio.h>
int main(){
  int n,m;
  int d;
  int a,b,i,j;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    int id[4000]={0};
    unsigned long long int p[4000]={0};
    for(i=0;i<n;i++){
      scanf("%d %d %d",&d,&a,&b);
      for(j=0;id[j]!=0;j++){
	if(id[j]==d)break;
      }
      id[j]=d;
      p[j]+=a*b;
    }
    m=0;
    for(j=0;id[j]!=0;j++){
      if(p[j]>=1000000){
	printf("%d\n",id[j]);
	m=1;
      }
    }
    if(m==0)printf("NA\n");
  }
  return 0;
}

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

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = 998244353;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static int maxn = 200005;

    static void solve() {
        int n = ni();
        int m = ni();
        long a[] = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nlo();
        PriorityQueue<Long> pq = new PriorityQueue<>();
        long ans = 0;
        for (int l = 0; l <= Math.min(n, m); l++) {
            for (int r = 0; r <= Math.min(m - l, n - l); r++) {
                pq.clear();
                pq.add(0l);
                long sum = 0;
                for (int i = 0; i < l; i++) {
                    pq.add(a[i]);
                    sum += a[i];
                }
                for (int j = 0; j < r; j++) {
                    pq.add(a[n - j - 1]);
                    sum += a[n - j - 1];
                }
                int d = m - (l + r);
                for(int i=0;i<d;i++){
                    if (pq.peek() == 0)
                        break;
                    sum -= pq.poll();
                }
                ans = Math.max(ans, sum);
            }
        }
        out.println(ans);
    }
}

Measured memory_bytes: 24532
#pragma warning(disable:4996)
//#define _CRT_NONSTDC_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <math.h>
#include <bitset>
#include <fstream>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <ctime>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>


using namespace std;
typedef long long ll;
typedef long double ld;
                        
#define all(x)   (x).begin(), (x).end()           /*sorting STL */
#define fastio	 ios_base::sync_with_stdio(0);  cin.tie(nullptr);  cout.tie(nullptr)

#define TRIPmin(a, b, c) 	min(a, min(b, c))
#define TRIPmax(a, b, c)    max(a, max(b, c))
#define fillchar(a,x) 		memset(a, x, sizeof (a))

//#define mod		(1000000000+7)

/***********************************************************************/

int main() {
    int n;
    cin >> n;
    if(n < 30) cout << "No";
    else cout << "Yes";
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
vector<vector<ll>> graph;
vector<ll> as;
map<P, ll> number;
ll rmemo[101][100001];
ll memo[101][100001];
int main() {
    ll n;
    cin >> n;
    bool found = true;
    ll ans = 0;
    while (found) {
        bool now = false;
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                now = true;
            }
        }
        if (now == false) {
            found = false;
            ans = n;
        }
        n++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;

//https://atcoder.jp/contests/dp/tasks/dp_d
public class Main {

	public static void main(String[] args) throws Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		XeniaAndBitOperations solver = new XeniaAndBitOperations();
		// int test = in.nextInt();
		// while (test-- > 0)
		solver.solve(1, in, out);
		out.close();
	}

	static class XeniaAndBitOperations {

		String s, t;

		public void solve(int testNumber, InputReader in, PrintWriter out) throws Exception {

			s = in.next();
			t = in.next();
			int dp[][] = new int[s.length()+1][t.length()+1];
			int p[][] = new int[s.length()+1][t.length()+1];
//			int len = lcs(s.length()-1, t.length()-1);
//			System.out.println(len);
//			
//			1->up,2->left,3->diagonal
			for(int i=0;i<=s.length();i++)
				dp[i][0] = 0;
			for(int i=0;i<=t.length();i++)
				dp[0][i] = 0;
			
			for(int i=1; i<=s.length(); i++){
				for(int j=1; j<=t.length(); j++){
					int c1 = dp[i-1][j];
					int c2 = dp[i][j-1];
					int c3 = 0;
					if(s.charAt(i-1)==t.charAt(j-1))
						c3 = 1+ dp[i-1][j-1];
					
					if(c1>=c2 && c1>=c3){
						dp[i][j] = c1;
						p[i][j] = 1;
					}
					else if(c2>=c1 && c2>=c3){
						dp[i][j] = c2;
						p[i][j] = 2;
					}
					else if(c3>=c1 && c3>=c2){
						dp[i][j] = c3;
						p[i][j] = 3;
					}
				}
			}
			
			StringBuilder st = new StringBuilder("");
			int i=s.length();
			int j=t.length();
			while(i>0 && j>0){
				if(p[i][j]==3){
					st.append(s.charAt(i-1));
					i--;
					j--;
				}
				if(p[i][j]==2)
					j--;
				if(p[i][j]==1)
					i--;
			}
			
			System.out.println(st.reverse());
			
		}
		
		
		private int lcs(int i, int j) {

			if (i >= 0 && j >= 0) {
				int len1 = lcs(i, j - 1);
				int len2 = lcs(i - 1, j);
				int len3 = 0;
				if(s.charAt(i)==t.charAt(j))
					len3 = 1+lcs(i-1, j-1);
				
				return Math.max(len1, Math.max(len2, len3));
			}

			return 0;

		}
		
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}

Measured memory_bytes: 132036
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; string S;
    cin >> N >> S;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        vector<bool> X(26), Y(26);
        for(int j = 0; j <= i; j++) X.at(S.at(j)-'a') = true;
        for(int j = i+1; j < N; j++) Y.at(S.at(j)-'a') = true;
        
        int tmp = 0;
        for(int j = 0; j < 26; j++) {
            if(X.at(j)&&Y.at(j)) tmp++;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
void solve(){
	int n;cin>>n;
    int a,b,c;
    vector<int>dp(3,0);
    for(int i=0;i<n;i++){
        vector<int>new_dp(3,0);
        cin>>a>>b>>c;
        new_dp[0]=max(dp[1],dp[2])+a;
        new_dp[1]=max(dp[0],dp[2])+b;
        new_dp[2]=max(dp[0],dp[1])+c;
        dp=new_dp;
    }
    cout<<max({dp[0],dp[1],dp[2]});
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;
vector<int> a;
bool visited[100000];
ll d[100000];

void dfs(int cur){
  if (visited[cur])
    return ;

  visited[cur] = true;
  d[a[cur]] = min(d[a[cur]], d[cur] + 1);
  dfs(a[cur]);

  return;
}

int main(void){
  int n;
  cin >> n;
  a = vector<int>(n);

  for (int i = 0; i < 100000; i++){
    d[i] = INF;
  }

  d[0] = 0;

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

  dfs(0);

  if (visited[1])
    cout << d[1] << endl;
  else
    cout << -1 << endl;


  return 0;
}


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

using namespace std;

typedef long long ll;

int N;

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

    cin >> N;

    ll ans = 0;
    int p = 0;

    int a;
    for (int i = 0; i < N; ++i) {
        cin >> a;

        if (p == 0) {
            ans += (a - 1);
            p = 1;
        } else if (a <= p) {
        } else if (a == p+1) {
            p++;
        } else if (a >= p+1) {
            ans += ((a - 1) / (p + 1));
        }

        //cout << "i: " << i << ", a:" << a << ", p: " << p << ", ans: " << ans << endl;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 764
k=int(input())
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])

Measured memory_bytes: 3060
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");



i64 a,b,n;
cin>>a>>b>>n;
i64 x;
if(b<=n)x=b-1;
if(b>n)x=n;
i64 ans=a*x/b;
ans-=a*(x/b);
cout<<ans;
    return 0;
  }


Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;

int main()
{
	int A, B,C;
	cin >> A >> B >> C;

	int nokori = A - B;
	int sss= C - nokori;

	if (sss <= 0)
	{
		cout << 0;
	}
	else
	{
		cout << sss;
	}
	
}


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {

  double n;
  cin >> n;
  double ans = 0;
  ans = pow(n / 3, 3);
  printf("%0.10lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int  gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
signed main(){
  int a,b,c,d,e,f=0;
  int q=0,w=0,r=0;
  cin>>a>>b>>c>>d;
  e=gcd(c,d);
  e=(c)*(d)/e;
  if(a%c!=0&&a%d!=0) f=1;
  if(a%c!=0&&b%d!=0) f=1;
  //if(a%e!=0&&b%e!=0) f++;
  //cout<<e<<" "<<q<<" "<<w<<" "<<r<<"\n";
  //cout<<b-a<<" "<<b/c-a/c<<" "<<b/d-a/d<<" "<<b/e-a/e<<"\n";
  cout<<(b-a)-((b)/c-(a)/c)-((b)/d-(a)/d)+((b)/e-(a)/e)+f<<"\n";
}
  

Measured memory_bytes: 256
#include <iostream>
#include<math.h>

using namespace std;
int smallest = 1000000;
int x, threez, N;
int main()
{
while (cin >> N && N != 0) {
    smallest = 1000000;
            for(int z = 0; pow(z, 3) <= N; z++) {
                threez = pow(z, 3);
                for(int y = 0; pow(y, 2) <= N - threez; y++) {
                    x = N - threez - pow(y, 2);
                    if (x + y + z < smallest) {
                        smallest = x + y + z;
                    }
                }
            }
            cout << smallest << endl;
}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
const int N=100050;
int n,k,cnt,ans,p=1;
string s;
vector<int> vec;

int main() 
{
cin>>n>>k>>s;
cnt=(s[0]=='0');
  for (int i=0; i<n; i++)
  {
	if(i && s[i]=='1' && s[i-1]=='0')
	  cnt--;
	while(p<n) 
	{
	  if(s[p-1]==s[p])
		p++;
	  else if(s[p]=='1')
		p++;
	  else if(cnt<k)
		cnt++,p++;
	  else
		break;
	}
	ans=max(ans,p-i);
  }
cout<<ans<<endl;
}

Measured memory_bytes: 512