akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
	long long int a[100];
	int n;
	a[1]=1;
	for(int i=2;i<=20;i++){
		a[i]=a[i-1]*i;
	}
	cin>>n;
	cout<<a[n]<<endl;
	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int compr(const void *a, const void *b)
{ //昇順
    return *(int *)b - *(int *)a;
}

int main(void)
{
    int n, m, l;
    int a[120] = {0};
    scanf("%d %d", &n, &m);
    int i, max = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &l);
        a[i] = l;
        max += l;
    }
    float lim = (float)max / (4 * m);
    qsort(a, n, sizeof(int), compr);
    /*for (i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
    printf("\n%d %d %f %d\n", max, 4 * m, lim, a[m - 1]);*/
    if (a[m - 1] >= lim)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

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

int main()
{
    int n, h;
    cin >> n >> h;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end());
    int maxa = a[n - 1];
    sort(b.begin(), b.end());
    int current = n - 1, ans = 0;
    while (h > 0)
    {
        if (current < 0)
        {
            ans += h / maxa + (h % maxa != 0);
            h = 0;
            break;
        }
        if (b[current] >= maxa)
        {
            h -= b[current];
            current -= 1;
        }
        else
        {
            h -= maxa;
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n;
    cin>>n;
    vector<int> b(n);
    rep(i,n) cin>>b[i];
    bool flag=false;
    vector<int> ans;
    for(int i=0;i<n;i++){
        int ind=-1;
        for(int j=0;j<n-i;j++){
            if(b[j]==j+1){
                ind=j;
            }
        }
        if(ind<0){
            cout<<-1<<endl;return 0;
        }
        b.erase(b.begin()+ind);
        ans.push_back(ind+1);
    }
    for(int i=n-1;i>=0;i--)  cout<<ans[i]<<endl;
    return 0;
}


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

signed main(){
	lint N, A; cin >> N >> A;
	vector<lint> x(N);
	for(int i = 0; i < N; i++) cin >> x[i], x[i] -= A;
	lint X = *max_element(x.begin(), x.end());
	X = max(X, A);
	vector<vector<lint> > dp(N + 1, vector<lint> (2 * N * X + 1, 0));
	dp[0][N * X] = 1;
	for(int j = 1; j <= N; j++){
		for(int  t = 0; t <= 2 * N * X; t++){
		dp[j][t] = dp[j - 1][t];
		  if((t - x[j - 1]) < 0 || (t - x[j - 1]) > 2 * N * X) continue;
		  else dp[j][t] += dp[j - 1][t - x[j - 1]];
		}
	}
	cout << dp[N][N * X] - 1 << endl;
}

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

int main() {


    int n;
    string s;

    cin >> n;
    cin >> s;

    int count = 1;
    
    for(int i = 1; i < n; ++i) {

        if(s[i] == s[i - 1])
            continue;

        count++;
    }


    cout << count << endl;

    return 0;

}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

#define M 210

#define pb push_back
#define mp make_pair

using namespace std;

int main(void)
{
	int d,n;
	int a,b,c;
	int i1,i2,i3;
	int maxx;

	cin>>d>>n;

	vector<int> t(d);
	vector<pair<int,int> > cl[M]; 

	for(i1=0;i1<d;i1++){
		cin>>t[i1];
	}
	for(i1=0;i1<n;i1++){
		cin>>a>>b>>c;
		
		for(i2=0;i2<d;i2++){
			if(a<=t[i2] && t[i2]<=b) cl[i2].pb(mp(c,0));
		}
	}

	maxx=0;
	for(i1=1;i1<d;i1++){

		for(i2=0;i2<cl[i1].size();i2++){
			for(i3=0;i3<cl[i1-1].size();i3++){
				cl[i1][i2].second=max(cl[i1][i2].second,abs(cl[i1][i2].first-cl[i1-1][i3].first)+cl[i1-1][i3].second);
				//cout<<cl[i1][i3].first<<" "<<" "<<cl[i1][i2].first<<" "<<cl[i1][i2].second<<endl;
			}
			maxx=max(maxx,cl[i1][i2].second);
		}
		//cout<<endl;
	}

	cout<<maxx<<endl;

	return 0;
}

Measured memory_bytes: 1352
import sys
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
MOD = 10 ** 9 + 7


class SegmentTree():
    f = max
    unit = 0
   
    def __init__(self,array):
        self.N = len(array)
        self.tree = [self.unit] * (2*self.N)
        #self._build(array)
    
    def _build(self,array):
        for i,x in enumerate(array,self.N):
            self.tree[i] = x
        for i in range(self.N - 1,0,-1):
            self.tree[i] = self.f(self.tree[i << 1],self.tree[i << 1|1])
    
    def update(self,k,x):
        k += self.N
        self.tree[k] = x
        while k > 1:
            k >>= 1
            self.tree[k] = self.f(self.tree[k << 1],self.tree[k << 1|1])
    
    def query(self,l,r):
        l += self.N
        r += self.N
        vl = self.unit
        vr = self.unit
        while l < r:
            if l&1: 
                vl = self.f(vl,self.tree[l])
                l += 1
            if r&1:
                r -= 1
                vr = self.f(self.tree[r],vr)
            l >>= 1
            r >>= 1
        return self.f(vl,vr)
    
    def __str__(self):
        return '\n'.join(' '.join(str(v) for v in self.tree[1<<i:1<<(i + 1)]) for i in range((2*self.N).bit_length()))

def main():
    N = int(input())
    H = list(map(int,input().split()))
    A = list(map(int,input().split()))

    st = SegmentTree([0] * N)
    ans = 0
    for i in range(N):
        a = st.query(0,H[i] - 1)
        ans = max(ans,a + A[i])
        st.update(H[i] - 1,a + A[i])
    print(ans)
if __name__ == '__main__':
    main()
    


Measured memory_bytes: 118396
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, K = il()
    ret = set()
    for n in range(A, min(A+K, B)):
        ret.add(n)
    for n in range(max(B-K+1, A), B+1):
        ret.add(n)
    print(*sorted(ret), sep="\n")


if __name__ == '__main__':
    main()


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

int main() {
    int n, h, w, x[100], ans = 0;
    cin >> n >> h >> w;
    for(int i=0;i<n;i++) cin >> x[i];
    for(int i=0;i<n;i+=2){
        ans += min(x[i], w-x[i+1]);
        ans += min(w-x[i], x[i+1]);
    }
    cout << ans * h << endl;
    return 0;
}



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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string s; cin >> s;
    int n = s.length();

    deque<char> dq;
    for (int i = 0; i < n; i++) dq.push_back(s[i]);

    int q; cin >> q;
    int cnt = 0;
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            cnt++;
        } else {
            int f; char c; cin >> f >> c;
            if ((f == 1) ^ (cnt & 1)) dq.push_front(c);
            else dq.push_back(c);
        }
    }
    if (cnt & 1) {
        while (!dq.empty()) {
            cout << dq.back(); dq.pop_back();
        }
    } else {
        while (!dq.empty()) {
            cout << dq.front(); dq.pop_front();
        }
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 976
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N;
	long long H[100000];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	for (int i = N - 1; i >= 1; i--) {
		if (H[i] < H[i - 1]) {
			H[i - 1]--;
		}
	}
	for (int i = 0; i < N - 1; i++) {
		if (H[i] > H[i + 1]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

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

a = [0] * N
b = [0] * N
c = [0] * N

for i in range(N):
    a[i],b[i],c[i] = map(int,input().split())
    
#[i] = i日目まで, i日目Aの時の最大値


memo =[[0 for i in range(N+1)] for j in range(3)]


for i in range(0,N):
    if i == 0:
      memo[0][i],memo[1][i],memo[2][i] = a[0],b[0],c[0]
    else:
        memo[0][i] = max(memo[1][i-1],memo[2][i-1])+a[i]
        memo[1][i] = max(memo[0][i-1],memo[2][i-1])+b[i]
        memo[2][i] = max(memo[0][i-1],memo[1][i-1])+c[i]


print(max(memo[0][N-1],memo[1][N-1],memo[2][N-1]))


Measured memory_bytes: 26800
_ = input()
a = [int(x) for x in input().split()]

p = set()
q = 0
for i in a:
    if i < 3200:
        p.add(i//400)
    else:
        q += 1
else:
    lenp = len(p)
    print(max(lenp, 1), lenp + q)

Measured memory_bytes: 9104
<?php
fscanf(STDIN, "%d %d", $a, $b);

if($a == 1) $a = 14;
if($b == 1) $b = 14;

if($a > $b) {
  echo "Alice";
} elseif ($a == $b) {
  echo "Draw";
} else {
  echo "Bob";
}

Measured memory_bytes: 4728
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

const int N = 55;
int a[N];

int main() {
	int n;
	scanf("%d", &n);
	REP(i, n)scanf("%d", &a[i]);
	int max_val = 0;
	int max_idx = 0;
	REP(i, n) {
		if (abs(a[i]) > max_val) {
			max_val = abs(a[i]);
			max_idx = i;
		}
	}
	vector<PII> ret;
	REP(i, n) if(i!=max_idx)ret.PB(MP(max_idx + 1, i + 1));
	if (a[max_idx] < 0)REP(i, n - 1)ret.PB(MP(n - i, n - i - 1));
	else 	REP(i, n - 1)ret.PB(MP(i+1, i+2));
	printf("%d\n", ret.size());
	REP(i, ret.size()) {
		printf("%d %d\n", ret[i].first, ret[i].second);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;

const int M=10;
int x[M],y[M];
double g[M][M];

double dis(int i,int j)
{
	return sqrt((x[i]-x[j])*(x[i]-x[j])
		+(y[i]-y[j])*(y[i]-y[j]));
}

int a[M];

int main()
{
	int n; scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d%d",&x[i],&y[i]);
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			g[i][j]=g[j][i]=dis(i,j);
	double ans=0;
	int cnt=0;
	for(int i=0;i<n;i++)
		a[i]=i;
	do
	{
		cnt++;
		for(int i=1;i<n;i++)
			ans+=g[a[i-1]][a[i]];
	}while(next_permutation(a,a+n));
	ans/=cnt;
	printf("%.8f\n",ans);
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int> > ab(n, vector<int>());
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        ab[a].push_back(b);
    }

    each(i, ab[0]) {
        each(j, ab[*i]) {
            if (*j == n - 1) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int N;

	cin >> N;

	vector<int> A[] = { vector<int>(N),vector<int>(N) };
	vector<int> dp[] = { vector<int>(N),vector<int>(N) };

	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < N; j++)
		{
			cin >> A[i][j];
		}
	}

	dp[0][0] = A[0][0];
	dp[1][0] = A[0][0] + A[1][0];

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

	for (int i = 1; i < N; i++)
	{
		dp[1][i] = A[1][i];

		if (dp[0][i] > dp[1][i - 1])
		{
			dp[1][i] += dp[0][i];
		}
		else
		{
			dp[1][i] += dp[1][i - 1];
		}
	}

	cout << dp[1][N - 1] << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
int n;
int a[N];
int ans[N];
int main()
{
	cin >> n ;
	int cnt = 0;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		a[i]=-a[i];
		if(cnt==0)
		{
			ans[cnt++] = a[i];
			continue;
		}
		int k = upper_bound(ans,ans+cnt,a[i])-ans;
		if(k==cnt)
		{
			ans[cnt++] = a[i];
		}
		else 
		{
				ans[k] = a[i];
		}
	}
	cout << cnt <<endl; 
	return 0;
}

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


int main() {
  long long N;
  cin >> N;
  long long ans = 0;
  vector<long long> a(N);
  for (int i=0; i<N; i++) {
    cin >> a[i];
  }
  long long term = 0;
  bool loop_end = false;
  
  
  for (int jsndfjn = 0; jsndfjn <= 100000000000; jsndfjn++) {
    loop_end = true;
    term = 0;
    for (int i=0; i<N; i++) {
      if (a[i] >= N) {
        term += (a[i] / N);
        a[i] -= (N+1) * (a[i]/N);
        loop_end = false;
      }
    }
    cerr << term << endl;
    if (loop_end) {
      break;
    }
    ans += term;
    for (int i=0; i<N; i++) {
      a[i] += term;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
class Process:
    def __init__(self, name_time):
        self.name = name_time[0]
        self.time = int(name_time[1])


process_amount, quontam = (int(i) for i in input().split(' '))

processes = [Process(input().split(' ')) for i in range(process_amount)]

i = 0
total_time = 0
while len(processes) != 0:
    process = processes[0]
    if process.time <= quontam:
        total_time += process.time
        print('{} {}'.format(process.name, total_time))
    else:
        total_time += quontam
        process.time -= quontam
        processes.append(process)

    processes.pop(0)



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

using namespace std;

int main() {
  string s = "CODEFESTIVAL2016";
  string t;
  cin >> t;
  int ans = 0;
  for (int i = 0; i < 16; i++) if (s[i] != t[i]) ++ans;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s="";
  string S;
  cin >> S;
  for (int i=0;i<S.size();i++){
    if(S.at(i)=='0'||S.at(i)=='1'){
      s+=S.at(i);
    }
    else if(S.at(i)=='B'&&s.size()!=0){
      s.pop_back();
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#python3
from heapq import heappop
from heapq import heappush
from heapq import heapify
def main():
    n, m = map(int, input().split())
    a = [-int(i) for i in input().split()]
    heapify(a)
    for i in range(m):
        v = -heappop(a)//2
        heappush(a, -v)
    ans = sum([-i for i in a])
    print(ans)
main()


Measured memory_bytes: 14180
#include<iostream>
using namespace std;
int main(){
  int A,B,C,D,L;
  int J,M;
  int enjoy;
  cin >> L >> A >> B >> C >> D ;
  if(A%C==0){
    J=A/C;
  }else{
    J=A/C+1;
  }
  if(B%D==0){
    M=B/D;
  }else{
    M=B/D+1;
  }
  if(J<M){
    enjoy=L-M;
  }else{
    enjoy=L-J;
  }
  
  cout << enjoy << endl;
  
}


Measured memory_bytes: 3068
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    long long h, a;
    cin >> h >> a;
    if(h % a == 0){
        cout << h / a << endl;
    }
    else{
        cout << (h / a) + 1 << endl;
    }
    solve();
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long nc2(long long n){
    return n*(n-1)/2;
}
int main(){
    int n; cin >> n;
    map<int, int> m;
    vector<int> v;
    for (int i = 0; i < n; i++){
        int a; cin >> a;
        v.push_back(a);
        m[a]++;
    }
    long long y = 0;
    for (map<int, int>::iterator itr = m.begin(); itr != m.end(); itr++){
        y += nc2((*itr).second);
    }
    for (int i = 0; i < n; i++){
        cout <<  y - (m[v[i]] - 1) << endl;; 
    }
}

Measured memory_bytes: 8308
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<typename T>
struct BinaryIndexedTree{
    vector<T> data;
    int sz;

    BinaryIndexedTree(int n){
        sz = n + 2;
        data.assign(sz, 0);
    }

    void add(int i, T x){
        ++i;
        while(i < sz){
            data[i] += x;
            i += i & -i;
        }
    }

    // [0, i] の区間和
    T sum(int i){
        T res = 0;
        ++i;
        while(i > 0){
            res += data[i];
            i -= i & -i;
        }
        return res;
    }

    // [l, r) の区間和
    T sum(int l, int r){
        return sum(r - 1) - sum(l - 1);
    }

    // val 以上を満たす 0-indexed の位置を返す
    int lower_bound(T val){
        // if(val <= 0)    return -1;
        int res = 0;
        int n = 1;
        while(n < sz)   n <<= 1;
        for(int k = n >> 1; k > 0; k >>= 1){
            if(res + k < sz && data[res + k] < val){
                val -= data[res + k];
                res += k;
            }
        }
        return res;     // 1-indexed であれば、res + 1 を返す
    }
};

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

    int n, q;
    cin >> n >> q;
    vector<int> prev(n + 1, -1);
    vector<vector<int>> section(n);
    for(int i = 0; i < n; ++i){
        int c;
        cin >> c;
        if(prev[c] != -1)   section[prev[c]].emplace_back(i);
        prev[c] = i;
    }
    vector<vector<int>> qs(n);
    vector<vector<int>> idx(n);
    for(int i = 0; i < q; ++i){
        int l, r;
        cin >> l >> r;
        --l, --r;
        qs[l].emplace_back(r);
        idx[l].emplace_back(i);
    }
    BinaryIndexedTree<int> bit(n);
    vector<int> ans(q);
    for(int L = n - 1; L >= 0; --L){
        for(int R : section[L])    bit.add(R, 1);
        for(int i = 0; i < (int)qs[L].size(); ++i){
            int R = qs[L][i];
            ans[idx[L][i]] = R - L + 1 - bit.sum(R);
        }
    }
    for(int x : ans)    cout << x << '\n';
}

Measured memory_bytes: 77620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

int main(){
	char text[100001];
	int count1,count2;
	scanf("%s",text);
	int max=strlen(text);

	count1=0;
	count2=0;
	for(int i=0; i<max; i++){
		if(i%2==0 && text[i]!='0') count1++;
		if(i%2==1 && text[i]=='0') count1++;
	}	
	for(int i=0; i<max; i++){
		if(i%2==0 && text[i]!='1') count2++;
		if(i%2==1 && text[i]=='1') count2++;
	}	
	int ans=min(count1,count2);
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 384
<?php
  fscanf(STDIN, "%d %d", $a, $b);
  function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);   
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
  }
  function lcm($m, $n){
    return $m * $n / gcd($m, $n);
  }
  $lcm = lcm($a, $b);
  echo $lcm;
?>

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

long long N, cnt;
string S;
 
int main() {
  
  cin >> N >> S;
  
  for (int i = 0; i < N-2; i++){
  if (S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C') cnt++;
  }
  cout << cnt << endl;
  

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll a,b,c;

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


Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}
template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
//Auther: Arin Roday
#define vec vector
#define i64 long long
#define endl '\n'
#define sz(x) (x).size()
#define times(n) for(i64 i = 0; i < (n); ++i)
#define bits(x) __builtin_popcount(x)
 
void solve(){
    i64 n, k;
    cin >> n >> k;
    i64 h[n];
    for(i64 i = 0; i < n; ++i){
        cin >> h[i];
    }
    sort(h, h + n, greater<i64>());
    i64 sum = 0;
    for(i64 i = min(n, k); i < n; ++i){
        sum += h[i];
    }
    cout << sum << endl;
}
 
int32_t main(){
    solve();
}

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

int main () {
	int N, K, Q;
	int scores[100001] = {0};
	cin >> N >> K >> Q;
	for (int i=0; i<Q; i++) {
		int tmp;
		cin >> tmp;
		scores[tmp-1] ++;
	}
	for (int i=0; i<N; i++) {
		if (Q-scores[i] < K)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] L = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Array.Sort(L);
            Array.Reverse(L);
            int sum = 0;
            for(int i = 1; i < n; i++)
            {
                sum += L[i];
            }
            Console.WriteLine(sum > L[0] ? "Yes" : "No");
        }
    }
}


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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> like_count(M);
	for (int n = 0; n < N; ++n)
	{
		int K;
		cin >> K;
		for (int k = 0; k < K; ++k)
		{
			int A;
			cin >> A;
			++like_count[A - 1];
		}
	}
	cout << count_if(like_count.begin(), like_count.end(), [N](int c) { return c == N; });
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
    int a, b, c;
 
    cin >> a >> b >> c;
 
    if (int sum = a+b+c >= 22) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long X, K, D;
  cin >> X >> K >> D;


  long long px = (X >= 0) ? (X % D) : (X % D + D);
  long long nx = px - D;
  long long pn = abs(X - px) / D;
  long long nn = abs(X - nx) / D;

  if (K <= pn && K <= nn) {
    if (X > 0) {
      cout << abs(X - D * K) << endl;
    } else {
      cout << abs(X + D * K) << endl;
    }
    return 0;
  }

  long long x = 0;
  long long k = 0;
  if (K < pn && K >= nn) {
    x = nx;
    k = nn;
  } else if (K < nn && K >= pn) {
    x = px;
    k = pn;
  } else {
    if (px <= abs(nx)) {
      x = px;
      k = K - pn;
    } else {
      x = nx;
      k = K - nn;
    }
  }

  if (k % 2 == 0) {
    cout << abs(x) << endl;
  } else {
    long long rx = (x == px) ? nx : px;
    cout << abs(rx) << endl;
  }

  return 0;
}


Measured memory_bytes: 3216
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#include <bitset>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    string S;
    cin >> S;
    
    bitset<26> bits;
    for (char c : S) {
        bits[c - 'a'] = 1;
    }

    Rep (i, 26) {
        if (!bits[i]) {
            S += i + 'a';
            cout << S << "\n";
            return 0;
        }
    }
    
    // 後ろから出た文字を記録していき、使える文字があれば置き換える
    bits.reset();
    Rep (i, 26) {
        ll now = S[25-i] - 'a';
        for (ll j = now; j < 26; j++) {
            if (bits[j]) {
                S = S.substr(0, 26 - i);
                S[25 - i] = j + 'a';
                cout << S << "\n";
                return 0;
            }
        }
        bits[now] = 1;
    }

    cout << -1 << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int N, p[10];
  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    scanf("%d", &p[i]);
  }

  int m = 0;
  int sum = 0;

  for(int i = 0; i < N; i++){
    sum += p[i];
    if(m < p[i]){
      m = p[i];
    }
  }

  printf("%d\n", sum - m / 2);

  return 0;
}


Measured memory_bytes: 128
n = int(input())
ame1 = list(map(int,input().split()))
ame2 = list(map(int,input().split()))

ame3 = []
for i in range(n+1):
  ame3.append(sum(ame1[:i+1])+sum(ame2[i:]))

print(max(ame3))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
int x,t; cin>>x>>t;
cout<<((x-t<0)?0:(x-t));
return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a;
	for(int i=3;i<=a;i++){
		b=0;
		if(i%3==0 || i%10==3){
			cout<<" "<<i;
			b=1;
		}
		if(i>=30 && b==0){
			for(int j=i;j>=9;){
			j=j/10;
			if(j%10==3){
				cout<<" "<<i;
				break;
				}
			}
		}
	}
	cout<<endl;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;

const int maxn = 105;

int main()
{
    char A[maxn];
    char B[maxn];
    char C[maxn];
    while(scanf("%s%s%s",A,B,C) != EOF)
    {
        queue<char>a;
        queue<char>b;
        queue<char>c;
        for(int i = 0;A[i] != '\0';i++)
        {
            a.push(A[i]);
        }
        for(int i = 0;B[i] != '\0';i++)
        {
            b.push(B[i]);
        }
        for(int i = 0;C[i] != '\0';i++)
        {
            c.push(C[i]);
        }
        char x = a.front();
        while(1)
        {
            if(x == 'a')
            {
                if(a.empty())
                {
                    printf("A\n");
                    break;
                }
                x = a.front();
                a.pop();
            }
            else if(x == 'b')
            {
                if(b.empty())
                {
                    printf("B\n");
                    break;
                }
                x = b.front();
                b.pop();
            }
            else
            {
                if(c.empty())
                {
                    printf("C\n");
                    break;
                }
                x = c.front();
                c.pop();
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
from collections import deque

S = input()
Q = int(input())
reverse_cnt = 0
s = deque([i for i in S])

for i in range(Q):
    query = input().split()
    if query[0] == "1":
        reverse_cnt += 1
    else:
        if query[1] == "1":
            if reverse_cnt % 2 == 0:
                s.appendleft(query[2])
            else:
                s.append(query[2])
        else:
            if reverse_cnt % 2 == 0:
                s.append(query[2])
            else:
                s.appendleft(query[2])

if reverse_cnt % 2 == 0:
    while s:
        print(s.popleft(), end="")
else:
     while s:
        print(s.pop(), end="")

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

int times[100001];

int main() {
	int N;
	cin >> N;
	for(int i=1;i<=N;i++){
		int m = times[i-1]+1;
		for(int k=6;k<=i;){m = min(m, 1+times[i-k]); k*=6;}
		for(int k=9;k<=i;){m = min(m, 1+times[i-k]); k*=9;}
		times[i] = m;
	}
	cout << times[N] << "\n";
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#H, W = map(int, input().split())
#N = int(input())
S = list(str(input()))

S.sort()

for i in range(1, len(S)) :
  if S[i-1] == S[i] :
    print ("no")
    exit()
print ("yes")

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N;
    cin >> N;
    map<ll, ll> A;
    ll a;
    ll total_a=0;
    for(size_t i=0;i<N; i++)
    {
        cin >> a;
        A[a]++;
        total_a += a;
    }
    //for(auto i : A) cerr << i.first << ":" << i.second << endl;
    //cerr << total_a << endl;
    ll Q;
    cin >> Q;
    ll B, C;
    ll ans[Q];
    for(size_t i=0;i<Q; i++)
    {
        cin >> B >> C;
        ll num = A[B];
        A.erase(B);
        total_a = total_a - B*num + C*num;
        ans[i] = total_a;
        A[C] += num;
        //cerr << num << ":" << num << endl;
    }

    for(size_t i=0;i<Q; i++)
    {
        cout << ans[i] << endl;
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>

int main() {

    ll N, M;
    cin >> N >> M;

    multiset<pair<ll, ll>> A;

    ll tmp;
    for (ll i = 0; i < N; i++) {
        cin >> tmp;
        A.insert(make_pair(tmp, i));
    }

    pair<ll, ll> tmp_p;
    for (int i = 0; i < M; i++) {
        tmp_p = *A.rbegin();
        A.erase(tmp_p);
        A.insert(make_pair(tmp_p.first/2, tmp_p.second));
    }

    ll sum = 0;
    for (auto itr = A.begin(); itr != A.end(); ++itr) {
        sum += (*itr).first;
    }

    cout << sum << endl;

    return 0;
}


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

public class Test
{
    public static void Main()
    {
        int R = int.Parse(Console.ReadLine());
        long[] n = new long[R];

        for (int x = 1; x <= R; ++x) 
        {
            if (x % 3 == 0 || x % 5 == 0)
            {
                //mynumber is a Perfect Number
            }
            else 
            {
                int index = x - 1;
                n[index] = x;
            }
        }

         long result = n.Sum();
        System.Console.WriteLine(result);

    }

}



Measured memory_bytes: 35692
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=bases[3];
		h2*=bases[1];
		h2+=a-'a';
		h2%=bases[4];
	}
	return h1*(MOD+13893829)+h2;
}

const int N=300010;
int n,m,a,x,r;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829)+13893829);
	cin>>n>>m;
	++r;
	for (int i=0;i<n;++i)
	{
		cin>>a;
		x+=a;
		if (x<=m) ++r;
	}
	cout<<r;
}




Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>
#include <deque>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num*10 + ( s[i]^48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}

int MOD=1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    SIN(s);

    ll m = StoLL( s.substr( 5, 2 ) );
    ll d = StoLL( s.substr( 8, 2 ) );
    if( 4 < m ){
      puta( "TBD" );
      return 0;
    }else{
      puta( "Heisei" );
      return 0;
    }

}


Measured memory_bytes: 256
#include <stdio.h>
#define IMPOSSIBLE -1

int main(void) {
	int n, m, sn[100], sm[100]; /* 与えられる値 */
	int i, j;

	/* データセット毎の処理 */
	while (scanf("%d%d", &n, &m) == 2 && n > 0 && m > 0) {
		int tn = 0, tm = 0; /* 現在の合計点数 */
		int an = IMPOSSIBLE, am = IMPOSSIBLE; /* 交換すべきカード */

		/* 各カードの点数を入力する */
		for (i = 0; i < n; i++) {
			scanf("%d", sn + i);
			tn += sn[i];
		}
		for (i = 0; i < m; i++) {
			scanf("%d", sm + i);
			tm += sm[i];
		}

		/* 交換すべきカードを総当たりで探す */
		for (i = 0; i < n; i++) {
			for (j = 0; j < m; j++) {
				/* 交換によって合計点数が等しくなるか */
				if ((sn[i] - sm[j]) * 2 == tn - tm) {
					/* 交換するカードの点数の和が最小か */
					if (an == IMPOSSIBLE || am == IMPOSSIBLE || sn[i] + sm[j] < an + am) {
						an = sn[i];
						am = sm[j];
					}
				}
			}
		}

		/* 結果を出力する */
		if (an == IMPOSSIBLE || am == IMPOSSIBLE) printf("%d\n", IMPOSSIBLE);
		else printf("%d %d\n", an, am);
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
/***** MAIN *****/
signed main() {
  int n;
  scanf("%d", &n);
  int tmp, count = 0;
  REP(i,n) {
    scanf("%d", &tmp);
    if(i+1 != tmp) count++;
  }
  if(count <= 2) cout << "YES";
  else cout << "NO";
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
S = input()
for i in range(len(S)):
    if i % 2 == 1:
        if not S[i] in ['L', 'U', 'D']:
            print('No')
            exit()
    else:
        if not S[i] in ['R', 'U', 'D']:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 2940
N = int(input())
S = [input() for i in range(N)]
S.sort()
k = [0]* (N - 1)
for i in range(N - 1):
    if S[i] == S[i + 1]:
        k[i] = 1
if k == [0]* (N-1):
    for i in range (N):
        print(S[i])
else:
    t = [0]*(N-1)
    for i in range(N-1):
        if k[i] == 0:
            t[i] = 0
        else:
            t[i] = t[i - 1] + 1
    M = max(t)
    for i in range (N-1):
        if t[i] == M:
            print(S[i])

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<bool> res(N, false);
    int di, Ai;
    for(int i=0;i<K;i++){
        cin >> di;
        for(int j=0;j<di;j++){
            cin >> Ai;
            res[Ai-1] = true;
        }
    }
    int c = 0;
    for(auto v : res){
        if(!v) c++;
    }
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 3600
//                          **********  YATIN KWATRA  ********** 

//AC bakshi Rabha

#include <bits/stdc++.h>
#define ll                      long long 
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node

using namespace std;

void INPUT() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

}
#define m 998244353

ll power(ll n, ll p)
{
    if(p == 0) return 1LL;

    ll res = 1LL;

    while(p)
    {
        if(p&1){

            res *= n;
            res%=m;
        }

        p >>= 1;
        n *= n;
        n%=m;
    }

    return res;
}

ll cnt;

ll f(vvll &dp, vll &v, ll n, ll i, ll s)
{
    if(s == 0) return power(2,n-i);

    if(i == n) return 0LL;

    if(dp[i][s] != -1 ) return dp[i][s];


    // Case-> Take it or leave it

    ll op1 = 0, op2 = 0;

    if(s>=v[i]) op1 = f(dp,v,n,i+1,s-v[i]);
                op2 = 2*f(dp,v,n,i+1,s);

    op1 %= m;
    op2 %= m;

    dp[i][s] = op1+op2;

    dp[i][s] %= m;

    return dp[i][s];
}

void solve()
{ 
        ll n,s,x;
        cin >> n >> s;

        vll v(n);
        cnt = 0; 

        fo(i,0,n-1)
        {
            cin >> v[i];
        } 

        sort(all(v));

    //    fo(i,0,n-1) cout << v[i] << " ";
      //  cout << endl;

        vvll dp(n+1,vll(s+1,-1));

    //    cout << power(2,6) << " " << power(3,5) << endl;
        cout << f(dp,v,n,0LL,s) << endl;

    
       
}
int main() {
    
    FIO
    INPUT();
    
    int t;
    t = 1;
 //   cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


Measured memory_bytes: 73920
<?php
while(true){
    fscanf(STDIN,"%d %d",$h,$w);
    if( $h===0 and $w===0 ) break;
    for ( $i = 0 ; $i < $h ; $i ++){
        for ( $j = 0 ; $j < $w ; $j++ ){
            if( $i === 0 or $i ===$h-1 ){
                echo "#";
            }else{
                if( $j === 0 or $j === $w-1 ){
                    echo "#";
                }else{
                    echo ".";
                }
            }
        }
        echo PHP_EOL;
    }
    echo PHP_EOL;
}

Measured memory_bytes: 15016