akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>

using namespace std;

#define HMAX 10
#define WMAX 5

int main(){

	int H,W;
	int ban[HMAX][WMAX];

	while(1){

		int sum1=0;
		cin>>H;
		if(H==0) break;
		W=5;

		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>ban[i][j];
				sum1+=ban[i][j];
			}
		}

		while(1){
			bool ff=false;
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					for(int l=W;l>=3;l--){
						bool f=true;
						int base=ban[i][j];
						if(ban[i][j]==-1) f=false;
						for(int k=0;k<l;k++){
							if(j+k>=W) f=false;
							else if(ban[i][j+k]!=base) f=false;
						}
						if(f){
							for(int k=0;k<l;k++){
								ban[i][j+k]=-1;
							}
							ff=true;
						}
					}
				}
			}
			while(1){
				bool f=false;
				for(int i=1;i<H;i++){
					for(int j=0;j<W;j++){
						if(ban[i][j]==-1&&ban[i-1][j]!=-1){
							swap(ban[i][j],ban[i-1][j]);
							f=true;
							ff=true;
						}
					}
				}
				if(!f) break;
			}
			if(!ff) break;
		}

		int sum2=0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(ban[i][j]!=-1) sum2+=ban[i][j];
			}
		}

		cout<<sum1-sum2<<endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<queue>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;
queue <int> q;
int main(){
    int n;
    cin >> n;
    int ans[n+1];
    vector <vector <pair<int ,int> > > tree(n+1);
    for(int i=0;i<n-1;i++){
        int u,v,w;
        cin >> u >> v >> w;
        tree[u].push_back(make_pair(v,w));
        tree[v].push_back(make_pair(u,w));
    }
    for(int i=0;i<=n;i++){
        ans[i] = -1;
    }
    q.push(1);
    ans[1] = 0;
    while(!q.empty()){
        int num = q.front();q.pop();
        //cout << "num=" << num << endl;
        for(int i=0;i<tree[num].size();i++){
            //cout << "i=" << i << "tree[" << num <<"][" << i << "]" << tree[num][i].first<<" " <<tree[num][i].second<< endl;
            if(ans[ tree[num][i].first ] != -1){
                continue;
            }
            if(tree[num][i].second%2 == 0){
                ans[tree[num][i].first] = ans[num];
                //cout << "even" << endl;
            }
            else{
                ans[tree[num][i].first] = 1-ans[num];
                //cout << "odd" << endl;
            }
            q.push(tree[num][i].first);
        }
    }
    for(int i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
  long long N, T;
  cin >> N >> T;
  vector<long long> t(N);
  for (int i = 0; i < N; i++) cin >> t.at(i);
  long long X = 0;
  for (int i = 1; i < N; i++) {
    if (t.at(i) - t.at(i-1) > T) X += T;
    else X += t.at(i) - t.at(i-1);
  }
  X += T;
  cout << X << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int main() {
	int A, B, X;
	scanf("%d %d %d", &A, &B, &X);
	if (X >= A && X <= A + B) printf("YES\n");
	else printf("NO\n");
	return 0;
}

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


int main() {
    int N,K;
	string S;
    cin >> N >> S >> K ;
	char temp=S[K-1];
	
    
for(int i=0;i<S.length();i++){
if(S[i]==temp)
    cout << S[i];
else
    cout << "*";


}
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

void bintree(int* A, int n) {
    for(int i=0; i<n; i++) {
        int key = i+1;
        printf("node %d: key = %d, ", key, A[i]);
        if(i != 0) {
            printf("parent key = %d, ", A[key/2 - 1]);
        }
        if(key * 2 <= n) {
            printf("left key = %d, ", A[key*2 - 1]);
        }
        if(key*2 + 1 <= n) {
            printf("right key = %d, ", A[key * 2]);
        }
        cout << "\n";
    }
}

int main() {
    int n;
    cin >> n;
    int *A = new int[n];
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    bintree(A, n);
    delete[] A;
}


Measured memory_bytes: 3244
def main():
    N = int(input())
    cnt = {}
    ans = 0
    for _ in range(N):
        s = input()
        ss = "".join(sorted(list(s)))
        if ss not in cnt:
            cnt[ss] = 0
        ans += cnt[ss]
        cnt[ss] += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62936
H, W = map(int, input().split())
grid = [list('#' * (W+1))]
for _ in range(1, H+1):
    temp = list(input())
    temp = ['#'] + temp
    grid.append(temp)
dp = [[0] * (W+1) for _ in range(H+1)]
dp[0][1] = 1
mod = 10**9 + 7

for i in range(1, H+1):
    for j in range(1, W+1):

        if grid[i][j] == '.':
            dp[i][j] = dp[i][j-1] + dp[i-1][j]
            dp[i][j] %= mod
            
print(dp[H][W])     

Measured memory_bytes: 56564
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
 */
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int d=sc.nextInt();
        int g=sc.nextInt();
        int[] p=new int[d+1];
        int[] c=new int[d+1];
        for (int i = 0; i < d; i++) {
            p[i+1]=sc.nextInt();
            c[i+1]=sc.nextInt();
        }
        int ans=1000000000;
        for (int i = 0; i < (1 << d); i++) {
            int temp=0;
            long score=0;
            for (int j = 0; j < d; j++) {
                if((1&(i>>j))==1) {
                    score += (j + 1) * 100 * p[j + 1] + c[j + 1];
                    temp += p[j + 1];
                }
            }
            if(score>=g){
                ans=min(ans,temp);
            }else {
                for (int j = d-1; j > -1; j--) {
                    if((1&(i>>j))==1)continue;
                    else {
                        for (int k = 1; k < p[j + 1]; k++) {
                            score += (j + 1) * 100;
                            temp += 1;
                            if(score>=g) {
                                ans = min(ans, temp);
                                break;
                            }
                        }
                        break;
                    }
                }
            }
        }
        out.println(ans);
    }
}

Measured memory_bytes: 25044
#!/usr/bin/perl
#abc082_a.pl
#Sun Jan 14 20:47:06 2018
#

use warnings;
use strict;

my $k = <STDIN>;
chomp $k;

my $temp = <STDIN>;
chomp $temp;

my @a = split(" ", $temp);

$k--;

my $min = 2;
my $max = 2;

my $survive = 2;
my $flag = 0;

while ($k>=0){
	my $calc = int($min/$a[$k]);
	my $tempmin = $calc * $a[$k];
	if ($min%$a[$k] > 0){
		$tempmin = $tempmin+$a[$k];
	}
	my $calc2 = int($max/$a[$k]);
	my $tempmax = $calc2 * $a[$k];
	if ($tempmin > $max || $tempmax > $max){
		$flag = 1;
		last;
	}
	$min = $tempmin;
	$max = $tempmax + $a[$k] - 1;
	$k--;
}

if ($flag == 0){
	print $min," ",$max,"\n";
}else{
	print "-1\n";
}

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

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

	long long n; cin >> n;
	long long ans = 0;
	ans += (int)(n/500)*1000;
	n %= 500;
	ans += (int)(n/5)*5;
	cout << ans << endl;
}


Measured memory_bytes: 256
import math 
import numpy
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
for num, val in enumerate(a):
    x -= val
    if x >= 0:
        ans += 1
    else:
        break
else:
    if x > 0:
        ans -= 1
    else:
        pass
print(ans)

Measured memory_bytes: 27156
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int h,w,count=0;
	cin>>h>>w;
	char c[8][8];
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin>>c[i][j];
			if(c[i][j]=='#')
				count++;
		}
	}

	if(count==h+w-1)
		cout<<"Possible"<<endl;
	else
		cout<<"Impossible"<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>

int main()
{
    int H = 0;
    int W = 0;
  
    std::cin >> H >> W;
    std::vector<std::vector<char>> mine(H, std::vector<char>(W));

    for(int loop = 0; loop < H; ++loop) {
        for(int loop2 = 0; loop2 < W; ++loop2) {
            std::cin >> mine.at(loop).at(loop2);
        }
    }

    std::vector<std::vector<int>> valmines(H, std::vector<int>(W, 0));
    std::vector<std::vector<char>> valmine(H, std::vector<char>(W));
   int minecount = 0;
    for(int loop = 0; loop < H; ++loop) {
        for(int loop2 = 0; loop2 < W; ++loop2) {
            if(mine.at(loop).at(loop2) == '#') {
                valmine.at(loop).at(loop2) = '#';
                ++minecount;
                if(0 <= loop - 1 && 0 <= loop2 - 1) {
                    valmines.at(loop - 1).at(loop2 - 1) += 1;
                }
                if(0 <= loop - 1) {
                    valmines.at(loop - 1).at(loop2) += 1;
                }
                if(0 <= loop - 1 && W > loop2 + 1) {
                    valmines.at(loop - 1).at(loop2 + 1) += 1;
                }
                if(0 <= loop2 - 1) {
                    valmines.at(loop).at(loop2 - 1) += 1;
                }
                if(W > loop2 + 1) {
                    valmines.at(loop).at(loop2 + 1) += 1;
                }
                if(H > loop + 1 && 0 <= loop2 - 1) {
                    valmines.at(loop + 1).at(loop2 - 1) += 1;
                }
                if(H > loop + 1 && W > loop2 + 1) {
                    valmines.at(loop + 1).at(loop2 + 1) += 1;
                }
                if(H > loop + 1) {
                    valmines.at(loop + 1).at(loop2) += 1;
                }
            }
        }
    }

    for(int loop = 0; loop < H; ++loop) {
        for(int loop2 = 0; loop2 < W; ++loop2) {
            if(mine.at(loop).at(loop2) != '#') {
                char moji[3];
                sprintf(moji, "%d", valmines.at(loop).at(loop2));
                valmine.at(loop).at(loop2) = *moji;
            } else {
                valmine.at(loop).at(loop2) = mine.at(loop).at(loop2);
            }
            std::printf("%c", valmine.at(loop).at(loop2));
        }
        std::printf("\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,k;
    string s;
    cin>>s;
    ll n1 = ((s[0]-'0')*10)+(s[1]-'0');
    ll n2 = ((s[2]-'0')*10)+(s[3]-'0');
    if(n1<=12 && n1 >0 && n2<=12 && n2 >0)
        cout<<"AMBIGUOUS"<<endl;
    else if((n1<=12 && n1 >0))
        cout<<"MMYY"<<endl;
    else if((n2<=12 && n2 >0))
        cout<<"YYMM"<<endl;
    else
        cout<<"NA"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
#define N 500007
#define pb push_back;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 998244353

int main()
{
    FAST;
    ll n,k;
    cin>>n>>k;
    vector<ll> v;
    ll x,i,sm=0;
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(i=0;i<k;i++)
    {
        sm+=v[i];
    }
    cout<<sm;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

template<typename T> // order_of_key(), *find_by_order()
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll) ((ld) a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }

    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }

    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}
int const maxn = 3e5 + 5;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    int m = n + 1;
    vector<ll> a(m, -1);
    vector<ll> cntl(m), cntr(m);
    cntl[0] = 0;
    for (ll i = 1; i < m; i++) {
        if (s[i - 1] == '<') cntl[i] = cntl[i - 1] + 1;
        else cntl[i] = 0;
    }
    for (ll i = m - 2; i >= 0; i--) {
        if (s[i] == '>') cntr[i] = cntr[i + 1] + 1;
        else cntr[i] = 0;
    }

    for (ll i = 0; i < m; i++) {
        a[i] = max(cntl[i], cntr[i]);
    }

    ll ans = 0;
    for (ll x: a)ans += x;
    cout << ans << endl;
    return 0;
}
/*
6
3 4 1
5 1 6
5 4 2
2 4 3
2 5 6
6 1 3

3
1 2 3
2 3 1
1 2 3
*/

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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;



const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
 
     

LL bestHere(vector<int> &low, vector<int> &high) {
    int ihigh = 0;
    LL rr = len(low);
    // ii (len(low))
        // printf("Low %d\n", low[i]);
    // ii (len(high))
        // printf("High %d\n", high[i]);
    ii (len(low)) {
        while (ihigh < len(high) && high[ihigh] < low[i])
            ++ihigh;
        //printf("Low %d ihigh %d\n", i, ihigh);
        rr = min(rr, LL(len(high) - ihigh + i));
    }

    return rr;
}



int main() {
    ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';
    cout.precision(16);
    

    int N, T;
    cin >> N >> T;

    vector<int> as(N);
    ii (N)
        cin >> as[i];

    int min_so_far = as[0];
    int highest_rise = 0;
    ii (N) {
        min_so_far = min(min_so_far, as[i]);
        highest_rise = max(highest_rise, as[i] - min_so_far);
    }

    map<int, int> v2index;
    vector<vector<int> > v2indices;
    ii (N) {
        if (!v2index.count(as[i])) {
            v2index[as[i]] = len(v2indices);
            v2indices.append(vector<int>(0));
        }

        v2indices[v2index[as[i]]].append(i);
    }

    LL rr = 0;
    fe (it, v2index) {
        int counterpart = it->uu + highest_rise;
        //printf("this %d counterpart %d howmany %d\n", it->uu, counterpart,
        //        v2index.count(counterpart));
        if (!v2index.count(counterpart))
            continue;

        LL here = bestHere(v2indices[it->vv], v2indices[v2index[counterpart]]);
        //printf("From %d %d get %d\n", it->uu, counterpart, int(here));
        rr += here;
    }

    cout << rr << '\n';
    

    return 0;
}


Measured memory_bytes: 10800
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String inputA = scanner.nextLine();
        String inputB = scanner.nextLine();
        char[] arrayA = inputA.toCharArray();
        char[] arrayB = inputB.toCharArray();
        Arrays.sort(arrayA);
        Arrays.sort(arrayB);

        String desStr = new String(arrayA);
        char[] tmpRevArray = arrayB;
        StringBuilder revStr = new StringBuilder();
        for(int i=tmpRevArray.length-1; i>=0; i--) {
            revStr.append(Character.toString(tmpRevArray[i]));
        }

        if(desStr.compareTo(revStr.toString()) >= 0) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 21844
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		char[] s = (S + S.charAt(0)).toCharArray();
		int[] a = new int[N+2];
		for(int i = 0; i <= 1; i++) {
			for(int j = 0; j <= 1; j++) {
				a[0] = i;
				a[1] = j;
				for(int k = 2; k <= N+1; k++) {
					if(a[k-1] == 0)
						a[k] = s[k-1] == 'o' ? a[k-2] : (a[k-2]+1)%2;
					else
						a[k] = s[k-1] != 'o' ? a[k-2] : (a[k-2]+1)%2;
				}
				if(a[0] == a[N] && a[1] == a[N+1]) {
					for(int k = 0; k < N; k++)
						System.out.print(a[k] == 0 ? "S" : "W");
					return;
				}
			}
		}
		System.out.println(-1);	
	}

}

Measured memory_bytes: 50044
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Max(x, y) (((x) > (y)) ? (x) : (y))
#define Min(x, y) (((x) < (y)) ? (x) : (y))
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e3 + 10;
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
int str[15], tot, sum, cache[15], pows[15];
inline int get(int s, int e)
{
    int tmp = 0;
    for (ri i = s; i <= e; ++i) {
        tmp += str[i] * pows[e - i];
    }
    return tmp;
}
int Calc(int limit)
{
    int sum = 0;
    cache[0] = 0, cache[limit + 1] = tot;
    for (ri i = 1; i <= limit + 1; ++i) {
        int tmp = get(cache[i - 1] + 1, cache[i]);
        sum += tmp;
    }
    return sum;
}

void dfs(int now, int start, int limit)
{
    if (now == limit) {
        sum += Calc(limit);
        return;
    }
    for (ri i = start + 1; i < tot; ++i) {
        cache[now + 1] = i;
        dfs(now + 1, i, limit);
    }
}
signed main()
{
    int N = read(), rec = N;
    pows[0] = 1;
    for (ri i = 1; i < 15; ++i) {
        pows[i] = pows[i - 1] * 10;
    }
    while (N) {
        str[++tot] = N % 10, N /= 10;
    }
    std::reverse(str + 1, str + 1 + tot);
    N = rec;
    sum = N;
    for (ri i = 1; i < tot; ++i) {
        dfs(0, 0, i);
    }
    writeln(sum);
    return 0;
}

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

void print( const vector<int>& a ) {
	int n = a.size();

	for( int i = 0; i < n; ++i ) {
		cout << a.at( i );

		if( i < n-1 ) { cout << ' '; }
	}

	cout << endl;
}

void insertionSort( vector<int>& A, int N ) {
	print( A );

	for( int i = 1; i < N; ++i ) {
		int v = A.at( i );
		int j = i - 1;

		while( j >= 0 && A.at( j ) > v ) {
			A.at( j+1 ) = A.at( j );
			j -= 1;
		}

		A.at( j+1 ) = v;

		print( A );
	}
}

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

	vector<int> A( N );
	for( auto& v: A ) { cin >> v; }

	insertionSort( A, N );
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin>>S;
  int N=S.size();
  int max=0;
  int end=true;
  if(S.at(N-1)=='A' || S.at(N-1)=='T' || S.at(N-1)=='G' || S.at(N-1)=='C'){
    max=1;
  }
  for(int i=0; i<N-1; i++){
    if(S.at(i)=='A' || S.at(i)=='T' || S.at(i)=='G' || S.at(i)=='C'){
      int count=1;
    for(int j=i+1; j<N; j++){
      if((S.at(j)=='A' || S.at(j)=='T' || S.at(j)=='G' || S.at(j)=='C')){
        count++;
      }
      else{
        break;
      }
    }//j
      if(count>max){
        max=count;
      }
    }//iがATGCなら
  } //i
  cout<<max<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,sum,x;
bitset<4500000> bi;
int main()
{
	cin>>n;
	bi[0]=1;
	for (int i=1;i<=n;i++)
	{
	  cin>>x;
	  sum+=x;
	  bi=bi|(bi<<x);
	}
	sum=(sum+1)/2;
	while (!bi[sum])  sum++;
	cout<<sum;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
  int n;
  cin >> n;
  vector<int> bit(n);
  rep(i,n){
    int f = 0;
    rep(j,10){
      int a;
      cin >> a;
      f += a*(pow(2,j));
    }
    bit.at(i) = f;
  }
  vector<vector<int>> score(n,vector<int>(11));
  rep(i,n){
    rep(j,11){
      cin >> score.at(i).at(j);
    }
  }
  ll ans = -INF;
  for(int i=1;i<pow(2,10);++i){
    ll can = 0;
    rep(j,n){
      int count = 0;
      rep(k,10){
        if(i>>k & bit.at(j)>>k & 1 ==1){
          count ++;
        }
      }
      can += score.at(j).at(count);
    }
    ans = max(ans,can);
  }
  cout << ans <<endl;
}
    
          
        
      
    
    
    
    

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

int main(){
  while(true){
    int n; cin >> n;
    if(n ==0) break;
    vector<int> a(n); cinf(n,a);
    sort(a.begin(),a.end());
    int sum=0;
    for(int i=1;i<n-1;i++)
      sum +=a[i];
    cout << sum/(n-2) << endl;
  }
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	string s; cin>>s;
	rep(i,0,s.size())cout<<'x';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, A, B;
ll t;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>q;

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A >> B;
		q.push(mkp(B, A));
	}
	while (!q.empty()) {
		t += q.top().second;
		if (t > q.top().first) {
			puts("No");
			return 0;
		}
		q.pop();
	}
	puts("Yes");
}

Measured memory_bytes: 2420
#!/usr/bin/env python3
import sys


def solve(D: int, N: int):
    if N == 100:
        print(100**D*(N + 1))
    else:
        print((100**D)*N)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(D, N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	ll n,x;cin>>n>>x;
	ll L[n];
	for(ll i=0;i<n;i++) cin>>L[i];
	ll D[n+1];
	D[0]=0;
	for(ll i=1;i<=n;i++){
		D[i]=D[i-1]+L[i-1];
	}
	sort(D,D+n);
	ll c=0;
	for(ll i=0;i<=n;i++){
		if(D[i]<=x) c++;
		else break;
	}
	cout<<c<<"\n";
	return 0;
}

Measured memory_bytes: 256
n=int(input())
num=list(map(int,input().split()))
num.sort()

i,cnt,ans=1,1,0
m=num[0]
while i<n:
    if num[i]==m:
        cnt+=1
    else:
        if cnt<m:
            ans+=cnt
        elif cnt>m:
            ans+=cnt-m
        m=num[i]
        cnt=1
    i+=1
if cnt<m:
  ans+=cnt
elif cnt>m:
  ans+=cnt-m
print(ans)

Measured memory_bytes: 14692
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

maxCount = 0

if N == 2:
    print(len(set(S[0])&set(S[-1])))
else:
    for i in range(N):
        commonCount = len(set(S[0:i+1])&set(S[i+1:]))
        if maxCount < commonCount:
            maxCount = commonCount
    print(maxCount)



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

using namespace std;

int main()
{
  int found = 0;
  string n;
  cin >> n;
  for(int i=0;i<3;i++){
    if(n[i] == '7'){
      found = 1;
      break;
    }
  }

  if(found) cout << "Yes";
  else cout << "No";

  return 0;
}


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

int main() 
{	
	string a,b;
	int a_b;
	cin >>a >>b;
	a_b = stoi(a+b);
	for (int i=0;i<320;i++)
	{
		if(i*i==a_b){
			cout <<"Yes"<<endl;
			return 0;
		}
		if(i*i>a_b){
			break;
		}
	}
	cout <<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <limits.h>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    
    vector<vector<ll>> count;
    
    for(int i =0; i<n; i++){
        vector<ll> add(3);
        count.push_back(add);
    }
    
    int a,b,c;
    cin>>a>>b>>c;
    count[0][0] = a;
    count[0][1] = b;
    count[0][2] = c;
    
    for(int i =1; i<n; i++){
        cin>>a>>b>>c;
        count[i][0] = a+ max(count[i-1][1],count[i-1][2]);
        count[i][1] = b+ max(count[i-1][0],count[i-1][2]);
        count[i][2] = c+ max(count[i-1][0],count[i-1][1]);
    }
    
    ll ans = count[n-1][0];
    if(ans<count[n-1][1]){
       ans = count[n-1][1];
    }
    if(ans<count[n-1][2]){
       ans = count[n-1][2];
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 


int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    cout<<std::fixed<<std::setprecision(15);

    string S;
    cin >> S;

    int n = count(all(S), '0');

    cout << min(n, (int)S.size() - n) * 2 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int siz,huge=0;
  string s;
  cin>>s;
  siz=s.size();
  for(int i=0;i<siz/2;i++){
    if(s[i] != s[siz-1-i])
      huge++;
  }
  cout<<huge<<endl;
  return(0);
}

Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    println(n * n * n)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33580
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
///////////////////////////////////////////////


int main() {
    int k, t; cin >> k >> t;
    vector<int> a(t);
    rep(i,t) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    if (t == 1) {
        cout << a[0]-1 << endl;
    } else {
        if (a[0]-1<(k-a[0])) cout << 0 << endl;
        else cout << a[0]-1-(k-a[0]) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	int m, d;
	cin >> m >> d;
	int ans = 0;
	FOR(i, 22, d + 1)
	{
		if (i % 10 <= 1)
			continue;
		if ((i / 10) * (i % 10) <= m)
			ans++;
	}
	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 256
use strict;
use warnings;
package SuffixArray;
sub sa_is(\@$);
sub sa_is(\@$){
	my@s=@{$_[0]};
	my$upper=$_[1];
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	my@sa;
	my@ls;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	$ls[$_]?$sum_l[$s[$_]+1]++:$sum_s[$s[$_]]++for 0..$n-1;
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my@sa=(-1)x$n;
		my@buf=@sum_s;
		for(@_){
			next if$_==$n;
			$sa[$buf[$s[$_]]++]=$_;
		}
		@buf=@sum_l;
		$sa[$buf[$s[$n-1]]++]=$n-1;
		for(@sa){
			$sa[$buf[$s[$_-1]]++]=$_-1if$_>=1&&!$ls[$_-1];
		}
		@buf=@sum_l;
		for(my$i=$n-1;$i>=0;$i--){
			my$v=$sa[$i];
			$sa[--$buf[$s[$v-1]+1]]=$v-1if$v>=1&&$ls[$v-1];
		}
		return@sa;
	};
	my@lms=grep!$ls[$_-1]&&$ls[$_],1..$n-1;
	my@lms_map=(-1)x($n+1);
	@lms_map[@lms]=0..$#lms;
	@sa=$induce->(@lms);
	if(@lms){
		my@sorted_lms=grep$lms_map[$_]!=-1,@sa;
		my@rec_s;
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$#lms){
			my$l=$sorted_lms[$_-1];
			my$r=$sorted_lms[$_];
			my$end_l=$lms_map[$l]+1<@lms?$lms[$lms_map[$l]+1]:$n;
			my$end_r=$lms_map[$r]+1<@lms?$lms[$lms_map[$r]+1]:$n;
			my$same=1;
			if($end_l-$l!=$end_r-$r){
				$same=0;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$same=0if$l==$n||$s[$l]!=$s[$r];
			}
			$rec_upper++if!$same;
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper;
		}
		my@rec_sa=sa_is(@rec_s,$rec_upper);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$#lms;
		@sa=$induce->(@sorted_lms);
	}
	return@sa;
}
sub suffix_array(\$){
	my@s=map ord,split"",${$_[0]};
	return sa_is(@s,255);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp;
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array(\$\@){
	my@s=map ord,split"",${$_[0]};
	return lcp(@s,@{$_[1]});
}
package main;
my$s=<>;
chomp$s;
my@sa=SuffixArray::suffix_array($s);
my@lcp=LcpArray::lcp_array($s,@sa);
my$ans=@sa*(@sa+1)/2;
$ans-=$_ for@lcp;
print$ans,$/;


Measured memory_bytes: 251964
#include <bits/stdc++.h>
using namespace std;
#include <unordered_map>
#define inputarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prllarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define pb push_back
#define ll long long
#define mod 1000000007
#define foi ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define in(n) scanf("%lld",&n);
#define in2(x,y) scanf("%lld %lld",&(x),&(y));
#define in3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));
#define out(n) printf("%lld\n",n);
#define out2(x,y) printf("%lld %lld\n",x,y);
#define test(t)  ll t; in(t);while(t--)
#define set(arr,n,s) for(ll i=0;i<n;i++){arr[i]=s;}


/*error-----
convert every int to long long eg-1LL
create array with proper analysis of problem constrain
check mod also
*/
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1){res=(res*x)%p;} y=y>>1;x=(x*x)%p;}return res;}
ll modInverse(ll a,ll p){return power(a,p-2,p);}//used with feemat little

ll gcd(ll x,ll y){if(x==0 || y==0){return max(y,x);}return gcd(y%x,x);}
ll gcdExtended(ll a,ll b,ll &x,ll &y){if(a==0){x=0;y=1;return b;}ll x1,y1;ll gcd = gcdExtended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return gcd;}//o(log(b))

//ll ncr(ll n,ll r,ll p){if(r==0){return 1;}return ((((fact[n]* inv[r]) % p) * inv[n-r]) % p);}
ll dp[3005][3005];
int main()
{
	string s,t;
	cin>>s>>t;
	for(ll i=1;i<=s.size();i++)
	{
		for(ll j=1;j<=t.size();j++)
		{
			if(s[i-1]==t[j-1])
			{
				dp[i][j]=1+dp[i-1][j-1];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	ll i=s.size();
	ll j=t.size();
	string ans="";
	while(i!=0 && j!=0)
	{
		if(s[i-1]==t[j-1])
		{
			ans+=s[i-1];
			i--;
			j--;
		}
		else
		{
			if(dp[i][j]==dp[i-1][j])
			{
				i--;
			}
			else

			{
				j--;
			}
		}

	}
	for(ll i=ans.size()-1;i>=0;i--)
	{
		cout<<ans[i];
	}
}

	



	

Measured memory_bytes: 70656
Scanf.scanf "%d %d %d %d %d %d" (fun a b c d e f ->
    let rec loop_y water sugar y ((s, w) as acc) =
        let sugar2 = sugar + y * d in
        let total = water + sugar2 in
        if total > f || 100 * sugar2 > e * water then acc else
            let acc = if s * total < sugar2 * (s + w) then sugar2, water else acc in
            loop_y water sugar (y + 1) acc
    in

    let rec loop_x water x acc =
        let sugar = x * c in
        let total = water + sugar in
        if total > f || 100 * sugar > e * water then acc else loop_x water (x + 1) (loop_y water sugar 0 acc)
    in

    let rec loop_m water m acc =
        let water2 = water + 100 * m * b in
        if water2 = 0 || water2 > f then acc else loop_m water (m + 1) (loop_x water2 0 acc)
    in

    let rec loop_n n acc =
        let water = 100 * n * a in
        if water > f then acc else loop_n (n + 1) (loop_m water 0 acc)
    in
    let s, w = loop_n 0 (0, 100 * a) in
    Printf.printf "%d %d\n" (s + w) s
)


Measured memory_bytes: 3832
from math import factorial
n, m = map(int, input().split())
mod = 10**9 + 7
if abs(n - m) <= 1:
    ans = factorial(n) % mod
    ans = ans * factorial(m) % mod
    if abs(n - m) == 1:
        print(ans)
    else:
        print(ans * 2 % mod)
else:
    print(0)

Measured memory_bytes: 4096
from collections import Counter

H, W = list(map(int, input().split()))
A = [[None for _ in range(W)] for _ in range(H)]
for h in range(H):
    A[h] = list(map(int, input().split()))

access = []
for h in range(H):
    if h % 2 == 0:
        for w in range(W):
            access.append((h, w))
    else:
        for w in range(W - 1, -1, -1):
            access.append((h, w))

choices = []
for i in range(len(access) - 1):
    hi, wi = access[i]
    hi1, wi1 = access[i + 1]
    # print(hi, wi, hi1, wi1)
    if A[hi][wi] % 2 == 1:
        A[hi][wi] -= 1
        A[hi1][wi1] += 1
        choices.append((hi, wi, hi1, wi1))

print(len(choices))
# print(access)
for x, y, z, w in choices:
    print(x + 1, y + 1, z + 1, w + 1)

Measured memory_bytes: 86568
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = list(Counter(A).values())
D = [0] * (N+1)
for k, d in Counter(C).items():
    D[k] = d

ckd, cd = [0] * (N+1), [0] * (N+1)

for i in range(1,N+1):
    cd[i] = cd[i-1] + D[i]
    ckd[i] = ckd[i-1] + i*D[i]

INF = float('inf')
def f(x):
    if x:
        return (x*(cd[-1] - cd[x]) + ckd[x]) // x
    return INF

cur = N
v = f(cur)
for k in range(1,N+1):
    while k > v:
        cur -= 1
        v = f(cur)
    print(cur)


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

using namespace std;

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

  int n;
  cin >> n;
  uint64_t ans = 0;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << "\n";
}


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

#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13

using namespace std;

int array[128];

int translateStr(char buf[]){
    int sum = -1,mult = 1;
    for(int i = 0; buf[i] != '\0'; i++){
        sum += array[buf[i]]*mult;
        mult *= 4;
    }
    return sum;
}

int main(){

    array['A']=1,array['C']=2,array['G']=3,array['T']=4;

    int n;
    scanf("%d",&n);
    char order[ORDER_LENGTH],str[STR_LENGTH];

    char* check_table = new char[TABLE_SIZE];

    for(int i = 0; i < n; i++){
        scanf("%s %s",order,str);
        if(order[0] == 'i'){
            check_table[translateStr(str)] = 'Y';
        }else{
            if(check_table[translateStr(str)] == 'Y'){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
}



Measured memory_bytes: 4512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200100;
int n , a[N] , nxt[N];
ll ans;

int main(){

scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",a+i);

for(int i=n;i;i--){
    if( i == n || a[i] )
    nxt[i]=i;
    else
    nxt[i]=nxt[i+1];
}



for(int i=1;i<=n;i++){
    int sum=0,x=0;
    int j=i;
    while( j <=n ){
            ans += nxt[j]-j;
            j=nxt[j];

        sum+=a[j];
         x ^=a[j];
         if( sum == x )ans++;
         else break;
         j++;
    }
}

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


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

struct request {
	int start;
	int end;
};

int main() {
	map<int, int> endStart{};

	int N, M;
	cin >> N >> M;
	int tmpStart, tmpEnd;
	vector<request> requests;
	for (int i = 0; i < M; i++) {
		cin >> tmpStart >> tmpEnd;
		requests.push_back({ tmpStart, tmpEnd });
	}
	sort(requests.begin(), requests.end(), [](const request& x, const request& y) {return x.end < y.end; });
	int minEnd = requests.at(0).end;
	int div = 1;
	for (auto x : requests) {
		if (minEnd <= x.start) {
			minEnd = x.end;
			++div;
		}
	}

	cout << div << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <cmath>

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

int main(){
    int N;
    cin >> N;
    int bricks[N];

    rep(i,N){
        cin >> bricks[i];
    }
    int current = 1;
    int breaks = 0;
    rep(i,N){
        if( bricks[i] == current) {
            current++;
        }else{
            breaks++;
        }
    }

    if( current == 1){
        cout << -1 << endl;
    }else{
        cout << breaks << endl;
    }
}

Measured memory_bytes: 1024
//In The Name Of The God

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x
#define p2(x) (1LL<<x)
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MAXS = 325;
const int SUPERS = 1000;
const int MD = 1e9+7;
//......Structures.......

//......Variables........
ll x,v,u,n;
//......Funcs............
ll sum(ll a,ll b)
{
    return (a+b)%MD;
}
ll mu(ll a,ll b)
{
    return (a*b)%MD;
}
ll mn(ll a,ll b)
{
    return(a-b+MD)%MD;
}
//......Code.............
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    rep(i,1,n)
    {
        cin>>x;
        if(x%4==0)u++;
        else if(x%2==0)v++;
    }
    if(2*u+1>=n)cout<<"Yes";
    else if(2*u+v>=n)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<28);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int a[18][2],dp[1<<18][18],b[18];

int main(void){
	int n,i,j,mask,k,t,ans=-INF,cnt;
	fill(dp[0],dp[1<<18],-INF);
	cin >> n; b[n] = (1<<n);
	for(i=0; i<n; ++i){
		cin >> a[i][0];
		b[i] = (1<<i);
	}
	for(i=0; i<n; ++i){
		cin >> a[i][1];
		dp[b[i]][i] = 0;
	}
	for(mask=1; mask<b[n]; ++mask){
		k = __builtin_popcount(mask);
		for(i=0; i<n; ++i){
			if(!(mask&b[i])){
				continue;
			}
			t = a[i][abs(i-k+1)%2]; cnt = 0;
			for(j=0; j<n; ++j){
				if(mask&b[j]){
					++cnt;
					continue;
				}
				if(t>a[j][abs(j-k)%2]){
					continue;
				}
				dp[mask+b[j]][j] = max(dp[mask+b[j]][j],dp[mask][i]+cnt);
			}
		}
	}
	for(i=0; i<n; ++i){
		ans = max(ans,dp[b[n]-1][i]);
	}
	cout << ((ans<0)?(-1):(n*(n-1)/2-ans)) << endl;
	return 0;
}


Measured memory_bytes: 18688
# -*- coding: utf-8 -*-

# 入力を各変数に格納
limit = int(input())

b = 2
p = 2

# 1000までのべき乗をリストに格納
num_list = [1]
while b ** p <= 1000:

	while b ** p <= 1000:
		num_list.append(b ** p)
		p += 1

	b += 1
	p = 2

# 重複削除
num_list = list(set(num_list))
# 昇順ソート
num_list.sort()

# limit以下のものを結果リストに格納
result_list = []
for num in num_list:
	if num <= limit:
		result_list.append(num)
	else:
		break

# 最後の要素を出力
print(result_list[len(result_list)-1])

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

int main() {
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;
    int sumThru = 0;
    int brank = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'a') {
            if (sumThru < a + b) {
                sumThru++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else if (s[i] == 'b') {
            if (sumThru < a + b && brank <= b) {
                sumThru++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
            brank++;
        } else {  // s[i] == 'c'
            cout << "No" << endl;
        }
    }
}

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

using namespace std;

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

    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        sum += v[i];
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    if (1LL * v[m-1] * 4 * m >= sum) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define endl '\n'
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
 using namespace std;
ll n,t,m,c1,c2,c,x,y,sum,mn=999999999,avg,pos,dif,j,dis,mx,xi,yi,q;
vector<ll>v;
set<int>s;
map<ll , ll >mp;
bool PE(int x)
{
for (int i=2;i*i<=x;i++)
if (x%i==0)
return false;
return true;
}
bool PR(string s)
{
int n=s.length();
for(int i=0;i<n/2;i++)
if(s[i]!=s[n-i-1])
return false;
return true;
}

int main(void) 
{ SpeeD;
long double p =6.28318530717958623200/2.0;
cin>>n;
cout<<2*p*n;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> B(N - 1);
  for (int i = 0; i < N - 1; i++){
    cin >> B[i];
  }
  vector<int> A(N);
  A[0] = B[0];
  for (int i = 1; i < N - 1; i++){
    A[i] = min(B[i - 1], B[i]);
  }
  A[N - 1] = B[N - 2];
  long long ans = 0;
  for (int i = 0; i < N; i++){
    ans += A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256