akhauriyash/Code-Regression huggingface dataset:
// tzl ak IOI! 

#include<bits/stdc++.h>

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}

template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }

template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }

template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

template <typename T>
void chkmax(T &x, const T &y){ if(y > x) x = y; return; }

template <typename T>
void chkmin(T &x, const T &y){ if(y < x) x = y; return; }

#ifdef ONLINE_JUDGE
#define debug(x,c) ;
#else
#define DEBUG
#define debug(x,c) cerr<<#x<<"="<<x<<c;
#endif

void TZL();

void RANK1();

#define tzl int
#define ak main
#define IOI ()
tzl ak IOI
{
#undef tzl
#undef ak
#undef IOI

	TZL();
	RANK1();

#define tzl return
#define caisi 0
#define myy ;
	tzl caisi myy
#undef tzl
#undef caisi
#undef myy
}

//---------------------------head----------------------------

const int N = 233;

LL n;
int cur = 0;
deque<int> ans;

void build(LL n)
{
	if(n == 1) return;
	if(n & 1)
	{
		build(n ^ 1);
		ans.push_front(++cur);
	}
	else
	{
		build(n >> 1);
		ans.pb(++cur);
	}
	return;
}

void TZL()
{
	scf(n);
	build(n + 1);
	return;
}

void RANK1()
{
	printf("%d\n", cur << 1);
	for(int x: ans) printf("%d ", x);
	forn(i, 1, cur) printf("%d ", i);
	return;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

class Pair<E,F>{
    E first;
    F second;
    public Pair(E first, F second){
        this.first=first;
        this.second=second;
    }
    public E getFirst(){return first;}
    public F getSecond(){return second;}
    public String toString(){
        return "<"+first.toString()+","+second.toString()+">";
    }
    public int hashCode(){
        return first.hashCode()*30011+second.hashCode()+2;
    }
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair another = (Pair) obj;
        return this.getFirst().equals(another.getFirst())&&this.getSecond().equals(another.getSecond());
    }
}

class Point extends Pair<Long,Long>{
    public Point(long x, long y){
        super(x,y);
    }
    public boolean contains(long xMin, long xMax, long yMin, long yMax){ //all inclusive
        return this.first >= xMin && this.first <=xMax && this.second>=yMin && this.second<=yMax;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        Point[] point = new Point[N];
        Set<Long> xEdges = new HashSet<>(), yEdges = new HashSet<>();
        for(int n=0; n<N; n++){
            long x = sc.nextLong(), y = sc.nextLong();
            point[n] = new Point(x,y);
            xEdges.add(x);
            yEdges.add(y);
        }

        long ans = Long.MAX_VALUE;
        for(long xMin:xEdges) for(long xMax:xEdges){
            if(xMax<xMin) continue;
            for(long yMin:yEdges) for(long yMax:yEdges){
                if(yMax<yMin) continue;
                int inner = 0;
                for(int n=0; n<N; n++) if(point[n].contains(xMin,xMax, yMin, yMax)) inner++;
                if(inner>=K) ans = Math.min(ans, (xMax-xMin)*(yMax-yMin));
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 28192
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int main(void){
	int h[10];
	for(int i=0; i<10; i++){
		cin >> h[i];
	}

	sort(h, h+10, greater<int>());

	cout << h[0] << endl << h[1] << endl << h[2] << endl;

	return 0;
}

Measured memory_bytes: 1176
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

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

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x) {
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

char s[123];

string str = "keyence";

int f(int l, int r){
  string s1 = "";
  for(int i = 0; s[i] ; i++){
    if(i < l || i > r) s1 += s[i];
  }
  return s1 == str;
}

int main(){
  scanf("%s", s);
  if(f(123, 123)){
    puts("YES");
    return 0;
  }
  for(int i = 0; s[i]; i++){
    for(int j = i; s[j] ; j++){
      if(f(i, j)){
        puts("YES");
        return 0;
      }
    }
  }
  puts("NO");
}


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

#define IN 0
#define OUT 1

typedef long long int LLI;
typedef pair<int, int> Data;
typedef pair<int, Data> Event;


int N;
LLI a[114514];
LLI b[114514];
vector<Event> es;
map<int, int> cnt;

int main() {
  scanf("%d", &N);

  LLI t = 0;
  for (int i=0; i<N; i++) {
    scanf("%lld%lld", &a[i], &b[i]);
    cnt[(t+a[i])%86400]++;
    t += a[i]+b[i];
  }

  for (auto itr : cnt) {
    es.emplace_back(Event(itr.first, Data(IN, itr.second)));
    es.emplace_back(Event(itr.first+10800, Data(OUT, itr.second)));
    es.emplace_back(Event(itr.first+86400, Data(IN, itr.second)));
    es.emplace_back(Event(itr.first+10800+86400, Data(OUT, itr.second)));
  }
  sort(es.begin(), es.end());

  int ans = 0;
  int num = 0;
  for (Event e : es) {
    Data d = e.second;
    int type = d.first;
    int a = d.second;
    if (type == IN) {
      num += a;
    } else {
      num -= a;
    }
    ans = max(ans, num);
  }
  printf("%d\n", ans);
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  int n, m; cin >> n >> m;
  vector <int> h(n + 1, 0);
  vector <bool> mark(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> h[i];
  for (int i = 1; i <= m; i++){
    int u, v; cin >> u >> v;
    if (h[u] == h[v]) mark[u] = mark[v] = true;
    else if (h[u] < h[v]) mark[u] = true;
    else mark[v] = true;
  }
  int res = 0;
  for (int i = 1; i <= n; i++) res += !mark[i];
  cout << res;
  return 0;
}

Measured memory_bytes: 3696
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Map<Integer, List<Integer>> yearCity = new TreeMap<>();

		for (int i = 1; i <= M; i++) {
			int P = sc.nextInt();
			int Y = sc.nextInt();
			yearCity.put(Y, new ArrayList<Integer>(Arrays.asList(i, P)));
		}

		int[] kenList = new int[N + 1];
		String[] outputList = new String[M + 1];
		for (List<Integer> city : yearCity.values()) {
			int cityID = city.get(0);
			int kenID = city.get(1);
			String output = String.format("%06d%06d", kenID, ++kenList[kenID]);
			outputList[cityID] = output;
		}

		for (int i = 1; i <= M; i++) {
			System.out.println(outputList[i]);
		}

	}
}

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

int main() {
    // 入力を受け取りながらバケットを作る
    int N;
    cin >> N;
    vector<int> num(110, 0); // 全体を 0 で初期化
    for (int i = 0; i < N; ++i) {
        int d;
        cin >> d;
        num[d]++;
    }

    // 数える
    int result = 0;
    for (int i = 0; i < 110; ++i) {
        // num[i] != 0 (0 以外の値は true) ならばインクリメント
        if (num[i]) ++result;
    }
    cout << result << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
#define pb 					push_back
#define FAST_IO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<"\n";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, set<T> input) {
	for(auto t: input)
		os << t <<"\n";
	return os;
}

int main() {
	long long k;
	cin >> k;
	long long n = 100;
	int i =1;
	for(i=1; i<=1e5; i++) {
		long long nxt = n*(101.0)/100;
		if(nxt>=k)
			break;
		n = nxt;
	}
	cout << i << "\n";
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);
static const int MAX = 100005;
int dp[MAX][26];

int main() {
  string s, t; cin >> s >> t;
  rep(i, MAX) {
    rep(j, 26) dp[i][j] = -1;
  }

  s = ' ' + s;

  for (int i = s.length()-2; i >= 0; i--) {
    int idx = s[i+1] - 'a';

    rep(j, 26) {
      if (j == idx) continue;
      dp[i][j] = dp[i+1][j];
    }

    dp[i][idx] = i + 1;
  }


  rep(i, t.length()) {
    if (dp[0][t[i]-'a'] == -1) {
      cout << -1 << endl;
      return 0;
    }
  }


  ll ans = 0LL;
  int now = 0;

  rep(i, t.length()) {
    int idx = t[i] - 'a';
    int next = dp[now][idx];

    if (next != -1) {
      ans += (ll)(next - now);
      now = next;
    } else {
      int y = dp[0][idx];
      ans += (ll)(s.length() - now + y - 1);
      now = y;
    }
  }

  cout << ans << endl;


  return 0;
}

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

int main() {
    ll n;
    cin >> n;

    ll ans = 0;
    for (ll i = 1; i * i < n; i++) {
        ll c = n / i - 1;
        if (n % i == 0 && n % c != 0) ans += c;
    }

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


Measured memory_bytes: 3580
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

string ango(string s) {
	REP(i, 25) {
		size_t t = s.find('b' + i);
		if (t != string::npos) {
			s[t]--;
		}
	}
	return s;
}
string in;
vector<string> ans;
void saiki(string s, int idx) {
	if (idx == s.size()) {
		string s2 = ango(s);
		if (in == s2) {
			ans.push_back(s);
		}
		return;
	}
	
	if (idx > 0) {
		if (ango(s).substr(0, idx) != in.substr(0, idx))
			return;
	}
	
	saiki(s, idx + 1);
	if (s[idx] != 'z')
		s[idx]++;
	saiki(s, idx + 1);
}

int main() {
	while (cin >> in, in != "#") {
		ans.clear();
		saiki(in, 0);
		SORT(ans);
		ans.erase(unique(ALL(ans)),ans.end());
		cout << ans.size() << endl;
		if (ans.size() <= 10) {
			REP(i, ans.size())
				cout << ans[i] << endl;
		}
		else {
			REP(i, 5)
				cout << ans[i] << endl;
			REP(i, 5)
				cout << ans[ans.size() - 5 + i] << endl;
		}
	}
}

Measured memory_bytes: 4164
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;
//------------------------------- Libraries --------------------------------//

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int N;
    cin >> N;
    //偶数回出現すれば消え、奇数回なら残る
    map<int, int> appear;
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        appear[A]++;
    }
    int ans = 0;
    for (auto &p : appear)
    {
        if (p.second % 2 == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>

using namespace std;

void out() {
     cout.flush();
     cerr << endl << "OUT" << endl;
     int bred;
     cin >> bred;
}
const int MOD = 1000000007;
const int INF = 1000000000;
int n;
string s;

int d[500500][27], d2[500500][27], nxt[500500][20];

void buildD() {
    for (int i = 0; i < 27; ++i)
        d[n-1][i] = d2[n-1][i] = INF;
    d[n-1][s[n-1]-'a'] = n;
    for (int i = s[n-1]-'a'; i < 26; ++i)
        d2[n-1][i] = n-1;
    
    for (int i = n-2; i >= 0; --i) {
        int c = s[i] - 'a';
        
        for (int j = 0; j < c; ++j)
            d[i][j] = INF;
        d[i][c] = i + 1;
        int ind = i + 1;
        for (int j = c + 1; j <= 26; ++j) {
            if (ind < n)
               ind = d2[ind][j - 1];
            if (ind >= n) {
               d[i][j] = INF;
               continue;
            }
            ind = d[ind][j - 1];
            d[i][j] = ind;
        }
        
        for (int j = c; j < 26; ++j)
            d2[i][j] = i;
        for (int j = c-1; j >= 0; --j)
            if (d[i][26] >= n)
               d2[i][j] = INF;
            else
                d2[i][j] = d2[d[i][26]][j];
    }
    
}

void buildNxt() {
    for (int i = 19; i >= 0; --i) {
        nxt[n+1][i] = n+1;
        nxt[n][i] = n;
    }
    for (int i = n-1; i >= 0; --i) {
        if (d[i][26] == INF)
           nxt[i][0] = n+1;
        else
           nxt[i][0] = d[i][26];
        for (int j = 1; j < 20; ++j)
            nxt[i][j] = nxt[nxt[i][j-1]][j-1];    
    }
}

void workWithQueries() {
     int q;
     cin >> q;
     while (q--) {
           int l, r;
           cin >> l >> r;
           --l; // [l..r)
           for (int i = 19; i >= 0; --i)
               if (nxt[l][i] <= r)
                  l = nxt[l][i];
           if (l == r)
              cout << "Yes\n";
           else
               cout << "No\n";
     }
}

void solve() {
     cin >> s;
     n = s.length();

     buildD();
     buildNxt();
     workWithQueries();
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    out();
    return 0;
}


Measured memory_bytes: 145948
def main():
    N = int(input())
    edges = [list(map(int, input().split())) for _ in range(N - 1)]
    ans = N * (N + 1) * (N + 2) // 6
    for e in edges:
        u, v = min(e), max(e)
        ans -= u * (N - v + 1)
    print(ans)


if __name__ == '__main__':
    main()

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

int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
    int i, n;
    int count = 0;
    int partCount;
    char a[101], b[101], c[101];
    scanf("%d", &n);
    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);
    for(i = 0; i < n; i++) {
        if(a[i] == b[i] && b[i] == c[i]) partCount = 0; // i文字目が3つとも同じ場合
        else if(a[i] == b[i] || b[i] == c[i] || a[i] == c[i]) partCount = 1;    // i文字目が1組だけ同じ場合→1つだけ文字を変更
        else partCount = 2; // i文字目がどれも違う場合→2つ文字を変更
        count += partCount;
    }
    printf("%d", count);
    
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 3333
#else
#define SIZE 3333
#endif

int N,T,A,B;

// 1つだけ、1分で食べることができる。
// i番目の料理まで食べた,特権を利用した,残り時間→最大の満足度
int DP[SIZE][2][SIZE];

void solve() {
    cin>>N>>T;
    REP(i,N) {
        cin>>A>>B;
        if (!i) {
            // 食べない
            DP[i][0][T] = 0;
            DP[i][1][T] = 0;
            if (A <= T) DP[0][0][T-A] = B; // 特権不使用
            if (1 <= T) DP[0][1][T-1] = B; // 特権利用
        } else {
            REP(j,T+1) {
                // 食べない
                DP[i][0][j] = DP[i-1][0][j];
                DP[i][1][j] = DP[i-1][1][j];
                if (j+A <= T) {
                    DP[i][0][j] = max(DP[i][0][j], DP[i-1][0][j+A] + B);
                    DP[i][1][j] = max(DP[i][1][j], DP[i-1][1][j+A] + B);
                }
                if (j+1 <= T) {
                    DP[i][1][j] = max(DP[i][1][j], DP[i-1][0][j+1] + B);
                }
            }
        }
    }
    int ans = 0;
    REP(j,T+1) {
        ans = max(ans, DP[N-1][0][j]);
        ans = max(ans, DP[N-1][1][j]);
    }
    cout << ans << endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef long long ll;

void solve() {
  string S;
  ll K;
  cin >> S >> K;
  ll N = S.size();
  if (S.find_first_not_of(S[0]) == string::npos) {
    cout << (N * K) / 2 << endl;
  } else {
    ll cnt = 1, a = 0;
    for (int i = 0; i < N - 1; i++) {
      if (S[i] == S[i + 1]) {
        cnt++;
      } else {
        a += cnt / 2;
        cnt = 1;
      }
    }
    a += cnt / 2;
    if (S[0] == S[N - 1]) {
      ll d = 0;
      cnt = 1;
      S = S + S;
      for (int i = 0; i < N * 2 - 1; i++) {
        if (S[i] == S[i + 1]) {
          cnt++;
        } else {
          d += cnt / 2;
          cnt = 1;
        }
      }
      d += cnt / 2;
      d = d - a;
      cout << a + (K - 1) * d << endl;
    } else {
      cout << a * K << endl;
    }
  }
}

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

  solve();

  return 0;
}


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

int main(){    
    string s;
    int k;
    cin>>s;
    cin>>k;
    vector<string> kouho;
    for(int i=0;i<s.size();i++){
        for(int j=0;j<k && i+j<s.size();j++){
            kouho.push_back(s.substr(i,j+1));
        }
    }
    sort(kouho.begin(),kouho.end());
    kouho.erase(unique(kouho.begin(),kouho.end()),kouho.end());
    cout<<kouho[k-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 1660
# 累積話の考え方を使う
H, W, D = map(int, input().split())
status = {}
for i in range(H):
    A = list(map(int, input().split()))
    for j in range(W):
        status[A[j]] = (i+1, j+1)
Q = int(input())
query = [list(map(int, input().split())) for _ in range(Q)]
# print(status)

# 目的地は必ずDだけ小さいマスからしか移動してこない
cumulative_sum = [0] * (H*W+1)
for i in range(H*W+1):
    if i <= D:
        cumulative_sum[i] = 0
        continue
    else:
        cumulative_sum[i] = cumulative_sum[i-D] + abs(status[i][0] - status[i-D][0]) + abs(status[i][1] - status[i-D][1])

for s, t in query:
    print(cumulative_sum[t] - cumulative_sum[s])


Measured memory_bytes: 84060
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    int n; cin >> n;
    set<string> count;
    rep(i, n){
        string s; cin >> s;
        count.insert(s);
    }
    cout << count.size() << endl;
}

Measured memory_bytes: 19228
#pragma GCC optimize("O3")

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
typedef
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int main () {
	SpeedForce;
	cin >> n >> m;
	cout << max({n * m, n - m, n + m}); 

	return Accepted;
}

// B...a

Measured memory_bytes: 18688
a,b,c,d = (int(i) for i in input().split())
count = 0

# 最大公約数。Euclidの互除法.
def gcd(m, n):
  if m < n:
    return gcd(n, m)
  if m%n == 0:
    return n
  else:
    return gcd(n, m%n)

# 最小公倍数
l = c*d//gcd(c,d)
def lowX(x,c,d,l):
  ans = x - x//c - x//d + x//l
  return ans
lowB = lowX(b,c,d,l)
lowA = lowX(a-1,c,d,l)
print(int(lowB-lowA))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <set>
#include <string>
#include <cstring>
#include <string>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define MAX 100
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INF 1e9
#define ll long long
#define vi vector<int>
#define all(a) a.begin(), a.end()
#define pb push_back
#define ull unsigned long long


using namespace  std;

void sol() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a>=k)cout << k << '\n';
    else if(a+b >= k)cout << a << '\n';
    else cout << a-(k-(a+b)) << '\n';




}
int main() {
    fast;
    sol();


}




Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String number = sc.nextLine();
              if (number.equals("0")) {
                break;
            }
            long sum [] = new long[number.length()];
            long total = 0;
            
            for (int i = 0; i < number.length(); i++) {
                String y = Character.toString(number.charAt(i));
                sum[i] = Integer.parseInt(y);
                total += sum[i];
            }
            System.out.println(total);
                    
        }
        
    }
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int N;
pairs(A);
double ans = 0;
int sss = 0;
bool flag[8];
void sum(double res,int index) {
	bool exeflag = false;
	fx(N) {
		if (!flag[x]) {
			exeflag = true;
			flag[x] = true;
			int a = A[index].first - A[x].first;
			int b = A[index].second - A[x].second;
			sum(res+sqrt(a*a+b*b),x);
			flag[x] = false;
		}
	}
	if (!exeflag) {
		ans += res;
		sss++;
	}
}


int main()
{

	cin >> N;

	fx(N) {
		pairsp(A);
	}

	fx(N) {
		flag[x] = true;
		sum(0,x);
		flag[x] = false;
	}
	//ce(sss)
		int n = 1;
	int i = 1;
	while (i<=N) {
		n *= i;
		i++;
	}
	cout << fixed << setprecision(10) << ans/n << endl;
    return 0;
}



Measured memory_bytes: 256
n=gets.chomp.to_i
l=gets.chomp.split(" ").map { |e| e.to_i }.sort

longest = l[n-1]
sum = 0

for i in 0..n-2 do
  sum += l[i]
end

if longest < sum
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        var A = cin.Scanint;
        if (A[0] == 1)
        {
            A[0] = 14;
        }
        if (A[1] == 1)
        {
            A[1] = 14;
        }
        if (A[0] == A[1])
        {
            WriteLine("Draw");
        }
        else if (A[0] > A[1])
        {
            WriteLine("Alice");
        }
        else
        {
            WriteLine("Bob");
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main(void){
   int a, b, c, d, e;
   cin >> a >> b >> c >> d >> e;
   if (a<0){
       cout << -(a)*c + d + b*e << endl;
   }
   else
   cout <<(b - a)*e << endl;

}    
 


Measured memory_bytes: 3032
a = int(input())
b = int(input())
c = int(input())
x = int(input())

res = 0
for i in range(a+1):
    aa = 500*i
    for j in range(b+1):
        bb = 100*j
        for k in range(c+1):
            cc = 50*k
            if aa+ bb+ cc ==x:
                res +=1

print(res)

Measured memory_bytes: 3064
class Queue:
    def __init__(self, limit):
        self.Q = [None]*limit
        self.head = 0
        self.tail = 0
        self.limit = limit

    def initialize(self):
        self.head = 0
        self.tail = 0

    def enqueue(self,x):
        self.Q[self.tail] = x
        self.tail = (self.tail+1) % self.limit

    def dequeue(self):
        if self.isEmpty():
            print('error')
        else:
            self.head = (self.head+1) % self.limit
            return self.Q[self.head-1]

    def isEmpty(self):
        return self.head == self.tail

if __name__ == '__main__':

    n,q = map(int, input().split(' '))

    Q = Queue(n+10)

    for i in range(n):
        name, time = input().split(' ')
        time = int(time)
        Q.enqueue([name,time])

    c = 0

    while Q.head != Q.tail:
        proc = Q.dequeue()
        if proc[1]-q > 0:
            Q.enqueue([proc[0],proc[1]-q])
            c += q
        else:
            c += proc[1]
            print(proc[0],c)

Measured memory_bytes: 16916
local N, K = io.read("n", "n")
local t = {}
local keys = {}
for i=1,N do
    local a, b = io.read("n", "n")
    if t[a] then
        t[a] = t[a] + b
    else
        t[a] = b
        table.insert(keys, a)
    end
end
table.sort(keys)
local c = 0
for _,k in ipairs(keys) do
    c = c + t[k]
    if c >= K then
        print(k)
        break
    end
end



Measured memory_bytes: 4396
fun main(args: Array<String>) {
    val INF = 1001001001
    val N = nextInt()
    val A = listOfInt()
    val B = listOfInt()
    val M = 1 shl N
    val dp = Array(M) { IntArray(51) { INF } }
    dp[0][0] = 0
    for (m in 0 until M) {
        for (i in 1 .. 50) dp[m][i] = Math.min(dp[m][i], dp[m][i-1])
        val x = Integer.bitCount(m)
        for (n in 0 until N) {
            if (((m shr n) and 1) == 1) continue
            val v = if ((x - n) % 2 == 0) A[n] else B[n]
            val j = m or (1 shl n)
            dp[j][v] = Math.min(dp[j][v], dp[m][v] + Integer.bitCount(m shr n))
        }
    }
    val x = dp[M - 1].min()!!
    println(if (x == INF) -1 else x)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n; std::cin >> n;
  string s; std::cin >> s;
  int len = s.size();
  vector<set<int>> pos(26); rep(i, len) pos[s[i]-'a'].insert(i);

  int q; std::cin >> q;
  rep(i, q) {
    int qq; std::cin >> qq;
    if (qq == 1) {
      int iq;
      char cq;
      std::cin >> iq >> cq; iq--;
      if (s[iq] == cq) continue;

      char t = s[iq];
      pos[t-'a'].erase(iq);
      pos[cq-'a'].insert(iq);
      s[iq] = cq;
    } else {
      int l, r; std::cin >> l >> r;
      --l, --r;

      int ans = 0;
      rep(j, 26) {
        auto it = pos[j].lower_bound(l);
        if (it != pos[j].end() && *it <= r)
          ans++;
      }
      std::cout << ans << "\n";
    }
  }

}


Measured memory_bytes: 24220
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s;
    cin >> s;
    ll ans=0;
    for (int bit = 0; bit < (1<<(s.size()-1));bit++){
        ll count=s[0]-'0';
        for (ll i=1;i<s.size();i++){
            if (bit & (1<<(i-1))){
                count=count*10+(s[i]-'0');
            }else{
                ans+=count;
                count=s[i]-'0';
            }
        }
        ans+=count;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
 

int main() {
	ll n,k;
	cin>>n>>k;
	ll ch[200010];
	ll ma=0;
	for(ll i=0;i<n;i++){
		cin>>ch[i];
		ma=max(ch[i],ma);
	}
    ll left = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll right = 1000000001; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        ll mid = left + (right - left) / 2;
        ll cnt=0;
        for(ll i=0;i<n;i++){
        	if(ch[i]%mid==0){
        		cnt+=ch[i]/mid-1;
        	}
        	else{
        	cnt+=(ch[i])/(mid);
        	}
        }
        if (cnt<=k) right = mid;
        else left = mid;
    }
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    cout << right;	
	// your code goes here
	return 0;
}

Measured memory_bytes: 5152
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static String solve() {

		String ans = "";

		while (true) {
			int a = in.nextInt();
			int b = in.nextInt();
			if (a + b == 0) return ans.substring(0,ans.length()-2);


			boolean f = false;
			for (int y=a; y<=b; y++) {
				if (isLeapYear(y)) {
					ans += y + "\n";
					f = true;
				}
			}

			if (!f) {
				ans += "NA\n";
			}

			ans += "\n";
		}
	}

	public static boolean isLeapYear(int y) {
        return y%400 == 0 || (y%4 == 0 && y%100 != 0);
    }

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		out.println(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

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

void sieve(int n, vector<int> &primes)
{
    vector<bool> v(n + 1, true);

    // check
    for (int i = 2, end = sqrt(n); i <= end; i++) {
        if (!v[i] || !(i & 1))
            continue;
        for (int j = i + i; j <= n; j += i)
            v[j] = false;
    }

    primes.push_back(2);
    for (int i = 3; i <= n; i += 2)
         if (v[i])
            primes.push_back(i);
}

int main()
{
    vector<int> primes;
    vector<int> inputs;
    int i;

    // read all inputs
    for (int x; cin >> x;)
        inputs.push_back(x);

    // init sieve
    sieve(*max_element(inputs.begin(), inputs.end()), primes);

    for (auto x : inputs) {
        for (i = 0; i < primes.size(); i++) // find
            if (primes[i] == x) {
                i++;
                break;
            } else if (primes[i] > x)
                break;
        cout << i << endl;
    }

    return 0;
}

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

int main(void) {
	string S;
	int a,b,c;
	cin >> S;
	a = stoi(S.substr(0, 4));
	b = stoi(S.substr(5, 2));
	c = stoi(S.substr(8, 2));
	if (a <= 2019) {
		if (b <= 4) {
			if (c <= 30) {
				cout << "Heisei";
			}
			else cout << "TBD";
		}
		else cout << "TBD";
	}
	else {
		cout << "TBD";
	}

	return 0;
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int N; cin >> N;
    set<string> S;
    for (int i = 0; i < N; ++i) {
        string si; cin >> si;
        S.insert(si);
    }
    cout << S.size() << endl;
}

Measured memory_bytes: 19208
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var A = cin.ReadIntArray(N);
            var count = 0;
            for (int i = 1; i < N - 1; i++)
            {
                if (((A[i - 1] < A[i])&&(A[i] < A[i + 1]))||((A[i-1]>A[i])&&(A[i]>A[i+1])))
                {
                    count++;
                }
            }
            Console.WriteLine(count);
            
            
            
        }



    }
    

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}

Measured memory_bytes: 13268
N,K = list(map(int,input().split()))

"""
10進数をn進数に変換するには
10進数で表された数値をnで割り
それのあまりを逆から並べると、答えになる
今回は、ただ何回割れるかを出せばいいだけ
"""

syou = N
iter = 1
while syou >= K:
    syou = syou//K
    iter = iter + 1
print(iter)


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

using namespace std;

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

	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int res = 3;
	if (a[0] == a[1]) res--;
	if (a[1] == a[2]) res--;
	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 256
from fractions import gcd
 
n = int(input())
a = list(map(int, input().split()))
 
rs, ls = [0], [0]
for i in range(n-1):
  rs.append(gcd(rs[i], a[i]))
  ls.append(gcd(ls[i], a[-i-1]))
 
print(max(gcd(r, l) for r, l in zip(rs, ls[::-1])))


Measured memory_bytes: 16056
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;


int w,h;
char L[53][53], R[53][53];
char memo[53][53][53][53];
struct state{
	int lx,ly,rx,ry;
};
int dl[4][2]={{0,1},{1,0},{-1,0},{0,-1}};
int dr[4][2]={{0,-1},{1,0},{-1,0},{0,1}};
bool dfs(state s){
	queue<state> S;
	S.push(s);
	while(!S.empty()){
		s = S.front();
		S.pop();
		if(L[s.ly][s.lx]=='%' && R[s.ry][s.rx]=='%') return true;
		if(L[s.ly][s.lx]=='%' || R[s.ry][s.rx]=='%') continue;
		for(int i=0;i<4;i++){
			state t = s;
			if(L[t.ly+dl[i][0]][t.lx+dl[i][1]] != '#'){
				t.ly += dl[i][0];
				t.lx += dl[i][1];
			}
			if(R[t.ry+dr[i][0]][t.rx+dr[i][1]] != '#'){
				t.ry += dr[i][0];
				t.rx += dr[i][1];
			}
			if(memo[t.ly][t.lx][t.ry][t.rx]) continue;;
			memo[t.ly][t.lx][t.ry][t.rx] = 1;
			S.push(t);
		}
	}
	return false;
}

main(){
	int i,j;
	while(cin >> w >> h, w){
		memset(memo, 0, sizeof(memo));
		for(i=0;i<53;i++)for(j=0;j<53;j++)L[i][j]=R[i][j]='#';
		int ans;
		state s;
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				cin >> L[i][j];
				if(L[i][j] == 'L'){
					s.lx=j;s.ly=i;
				}
			}
			for(j=1;j<=w;j++){
				cin >> R[i][j];
				if(R[i][j] == 'R'){
					s.rx=j;s.ry=i;
				}
			}
		}
		cout << (dfs(s)?"Yes":"No") << endl;
	}
	return 0;
}

Measured memory_bytes: 9852