akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define int         int64_t

using namespace std;

typedef pair<int, int> pii;
const int N = 1 << 18 | 1;
const int inf = (int)1e15;

int n, x;
vector<int> cur, top;
set<pii> pq;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n; n = 1 << n;
    for(int i = 0; i < n; ++i) cin >> x, pq.insert(mp(x, i));
    cur.pb((*pq.rbegin()).fi);
    pq.erase(*pq.rbegin());
    while(pq.size()) {
        top.clear(); bool cando = 1;
        for(int i = 0; i < int(cur.size()); ++i) {
            auto ptr = pq.lower_bound(mp(cur[i], 0));
            if(ptr != pq.begin()) {
               ptr = prev(ptr);
               top.pb((*ptr).fi);
               pq.erase(*ptr);
            } else {cando = 0; break;}
        }
        if(!cando) break;
        for(int x: top) cur.pb(x);
    }
    if(pq.size()) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 18952
#include <iostream>
#include <string>

int main()
{
    while (true) {
        std::string in_str;
        std::cin >> in_str;

        if (in_str.at(0) == '0'){
            break;
        }

        int sum = 0;
        for (size_t i = 0; i < in_str.size(); i++){
            if (in_str.at(i) == '\0'){
                break;
            }

            int in_num = in_str.at(i) - '0';
            sum += in_num;
        }

        std::cout << sum << std::endl;
    }

    return 0;
}

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

int main() {
  int p[50];
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i)
    cin >> p[i];
  
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < n; ++j) {
      int tmp = p[i];
      p[i] = p[j];
      p[j] = tmp;
      int x = 0;
      for(int k = 0; k < n; ++k) {
        if(x > p[k])
          break;
        x = p[k];
        if( k == n-1 ) {
          cout << "YES\n";
          return 0;
        }
      }
      p[j] = p[i];
      p[i] = tmp;
    }
  }
  cout << "NO\n";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int ad(int a,int b){return(a+b)%mod;}
int de(int a,int b){return(a-b)%mod;}
struct peo{
	int x,v;
}p[200010];
struct seg{
	int l,r;
}s[200010];
bool operator<(peo a,peo b){return a.x<b.x;}
bool operator<(seg a,seg b){return(a.r==b.r)?a.l<b.l:a.r<b.r;}
int fast[200010],slow[200010],f[200010],sum[200010];
int main(){
	int n,i,l,r,mid,ans,t;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d%d",&p[i].x,&p[i].v);
	sort(p+1,p+n+1);
	fast[1]=p[1].v;
	for(i=2;i<=n;i++)fast[i]=max(fast[i-1],p[i].v);
	slow[n]=p[n].v;
	for(i=n-1;i>0;i--)slow[i]=min(slow[i+1],p[i].v);
	for(i=1;i<=n;i++){
		ans=i;
		l=1;
		r=i-1;
		while(l<=r){
			mid=(l+r)>>1;
			if(fast[mid]>p[i].v){
				ans=mid;
				r=mid-1;
			}else
				l=mid+1;
		}
		s[i].l=ans;
		ans=i;
		l=i+1;
		r=n;
		while(l<=r){
			mid=(l+r)>>1;
			if(slow[mid]<p[i].v){
				ans=mid;
				l=mid+1;
			}else
				r=mid-1;
		}
		s[i].r=ans;
	}
	sort(s+1,s+n+1);
	t=0;
	f[0]=sum[0]=1;
	for(i=1;i<=n;i++){
		while(s[t+1].r<i)t++;
		f[i]=de(sum[i-1],sum[s[t].l-1]);
		sum[i]=ad(sum[i-1],f[i]);
	}
	printf("%d",ad(de(sum[n],sum[s[n].l-1]),mod));
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N+1);
    for(int i = 1; i <= N; ++i) cin >> a[i];

    int cnt = 0;
    vector<bool> exist(N+1);
    for(int i = N; i > 0; --i){
        int sum = 0;
        for(int j = 2; j * i <= N; ++j){
            if(exist[j * i]) sum += 1;
        }
        if(sum % 2 != a[i]){
           exist[i] = true; 
           cnt += 1;
        }
    }

    cout << cnt << endl;
    for(int i = 1; i <= N; ++i){
        if(exist[i]) cout << i << " ";
    }
    return 0;
}


Measured memory_bytes: 1792
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=lmp()
print(sum(a)-len(a))

Measured memory_bytes: 5588
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

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();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

/* //約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}*/

int main() {
  int N,M,p,correct=0,wrong=0;
  string S;
  cin >> N >> M;
  map<int,int> m;

  REP(i,M) {
    cin >> p >> S;
    if (m[p] == 1) continue;
    else if(S=="AC") {wrong-=m[p];m[p]=1;correct++;}
    else {m[p]--;}
  }

  cout << correct << ' ' << wrong << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main(void)
{

	int date[101][101];
	int i, j, x, y, sum = 0;

	scanf("%d %d", &y, &x);

	for (i = 0; i < y; ++i)
	{
		for (j = 0; j < x; ++j)
		{

			scanf("%d", &date[i][j]);
		}
	}

	for (i = 0; i < y; ++i)
	{
		for (j = 0; j < x; ++j)
		{

			sum = sum + date[i][j];
		}

		date[i][x] = sum;
		sum = 0;
	}

	for (i = 0; i <= x; ++i)
	{
		for (j = 0; j < y; ++j)
		{

			sum = sum + date[j][i];
		}

		date[y][i] = sum;
		sum = 0;
	}

	for (i = 0; i <= y; ++i)
	{
		for (j = 0; j <= x; ++j)
		{

			if (j == 0)
			{
				printf("%d", date[i][j]);
			}

			else
			{
				printf(" %d", date[i][j]);
			}
		}

		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    double *v = new double[N];
    for (int i = 0; i < N; ++i) {
        cin >> v[i];
    }

    sort(v, v+N);
    double r = v[0] / pow(2, N - 1);
    for (int i = 1; i < N; ++i) {
        r += v[i] / pow(2, N - i);
    }
    cout << r << endl;
    delete[] v;
    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<vector<ll>> a(n, vector<ll>(3));
    for(int i = 0; i < n; i++)for(int j = 0; j < 3; j++)cin >> a[i][j];
    vector<vector<ll>> dp(n + 1, vector<ll>(3));


    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){

                if(j == k)continue;
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][k]);

            }
        }
    }

    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

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

const int XD = 1e5 + 2;
vector <int> v[ XD ];
int dp[ XD ];
bool vis[ XD ];

void dfs( int x )
{
    vis[ x ] = true;
    for( auto i : v[ x ] )
    {
        if( !vis[ i ] ) dfs( i );
        dp[ x ] = max( dp[ x ], dp[ i ] + 1 );
    }
}
int main()
{
    ios_base::sync_with_stdio( false );
    int n, m; cin >> n >> m;
    while( m-- )
    {
        int a, b; cin >> a >> b;
        v[ a ].push_back( b );
    }
    int w = 0;
    for( int i = 1; i <= n; i++ )
    {
        if( !vis[ i ] ) dfs( i );
        w = max( w, dp[ i ] );
    }
    cout << w;
    return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
ll INF = 10010001010;

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

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

int main(){
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for (int i = A; i <= B;i++){
        string C = to_string(i);
        string Co = C;
        reverse(all(Co));
        if(Co == C){
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, K := sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	// true: 先手 false: 後手
	dp := make([]bool, K+1)
	dp[0] = false
	for i := 1; i <= K; i++ {
		for j := 0; j < N; j++ {
			if i >= A[j] {
				// 後手勝ちの場合
				if !dp[i-A[j]] {
					dp[i] = true
					break
				}
			} else {
				break
			}
		}
	}

	if dp[K] {
		fmt.Fprintln(wtr, "First")
	} else {
		fmt.Fprintln(wtr, "Second")
	}
	wtr.Flush()
}


Measured memory_bytes: 768
s = input()
max_count = 0
now_count = 0
target = ["A", "C", "G", "T"]
for c in s:
        if(c in target):
                now_count += 1
        else:
                max_count = max(max_count, now_count)
                now_count = 0
print(max(max_count, now_count))

Measured memory_bytes: 3060
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	int n;
    cin >> n;
    if (n%2 == 0)
    {
      cout << n/2;
    }
    else
      cout << (n+1)/2;
  	return 0;
}	

Measured memory_bytes: 256
#!/usr/bin/env python3
n, p, *a = map(int, open(0).read().split())
dp = [0] * (n + 1)
dp[0] = 1 if p == 0 else 0
for i in range(1, n + 1):
    if a[i - 1] % 2:
        dp[i] = 2**(i - 1)
    else:
        dp[i] = 2 * dp[i - 1]
print(dp[n])


Measured memory_bytes: 9068
n = int(input())
s = input()
number = [n for n in range(10)]
ans = 0
for i in number:
    try:
        j = s.index(str(i))
        for k in number:
            try:
                l = s[j+1:].index(str(k))
                ans += len(set(s[l+j+2:]))
            except:
                continue
    except:
        continue
print(ans)

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

int main(){
    ll n,m;
    cin >> n >> m;
    //vector<int> a(m);
    ll a=0;
    rep(i, m){
        ll tmp;
        cin >> tmp;
        a += tmp;
    }
    if(n<a) cout << -1 << endl;
    else cout << n-a << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
int main()
{
    char a[201];
    gets(a);
    int i;
    printf("%c",a[0]);
    for(i=0;i<strlen(a);i++)
        if(a[i-1]==' '&&a[i]!=' ')
            printf("%c",a[i]);
}

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

int main() {
    int n, k, x, ans = 0;
    cin >> n >> k;
    for(int i = 0; i < n; ++i) {
        cin >> x;
        if(x < k-x) ans += 2*x;
        else ans += 2*(k-x);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100000
#define inf 0x3f3f3f3f
#define LL long long
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mm(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
const LL mod=1e9+7;
const LL INF=(LL)1e18;
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("ouput.txt","w",sdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int x,a,b;
	cin>>x>>a>>b;
	if(b<=a){
		cout<<"delicious"<<endl;
		return 0;
	}
	if(b-a<=x){
		cout<<"safe"<<endl;
		return 0;
	}
	else cout<<"dangerous"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int a,b,k,tmp,x,i,f[100];
   scanf("%d %d %d",&a,&b,&k);
   if (1>a) return 1;
   else if (b>100) return 1;
   else if (k<1) return 1;

   if(a<b){
        tmp=a;
        a=b;
        b=tmp;
   }
   for(i=1;i<=b;i++){
        if(a%i==0&&b%i==0){
           x++;
           f[x]=i;
        }
   }

   printf("%d\n",f[x-k+1]);
   return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	string s, p;
	cin >> s >> p;
	s += s;
	Yes(s.find(p) != string::npos);
	return 0;
}


Measured memory_bytes: 3204
import math
import copy
import fractions
import numpy as np

# ===FUNCTION===

def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

def GCD(x, y):
    return x if y == 0 else GCD(y, x % y)


def LCM(x, y):
    return x // GCD(x, y) * y

num = getInputListInt()

a = num[0]
b = num[1]
c = num[2]
d = num[3]

c_modzero = b//c - (a-1)//c
d_modzero = b//d - (a-1)//d

cd = LCM(c, d)

cd_modzero = b//cd - (a-1)//cd

ans = b - a + 1 - (c_modzero + d_modzero - cd_modzero)

print(int(ans))



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


 int InsertionSort(int* a, int n, int g)
{
	int tmp, j, count = 0;
	for (int i = g; i < n; i++)
	{
		tmp = a[i];
		for (j = i - g; j >= 0 && a[j] > tmp; j -= g)
		{
			a[j + g] = a[j];
			count++;
		}
		a[j + g] = tmp;
	}
	return count;
}

int ShellSort(int* a, int n)
{
	int m, g[100],count = 0;
	for (m = 1; m * m * m <= n; m++)
		continue;
	m--;
	cout << m << endl;
	for (int i = 0; i < m; i++)
	{
	    g[i] = (m - i) * (m - i);
		if (i)
			cout << " ";
		cout << g[i];
	}
	for (int i = 0; i < m; i++)
		count += InsertionSort(a, n, g[i]);

	return count;
}

int main()
{
	int n, a[1000000], count;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	count = ShellSort(a, n);
	cout << endl << count << endl;
	for (int i = 0; i < n; i++)
		cout << a[i] << endl;

	return 0;
}


Measured memory_bytes: 7004
// 他の人参考

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%2lld", name[i][j]); \
    }\
    printf("\n");\
  }\


#define MOD 1000000007
#define A 0
#define T 1
#define G 2
#define C 3 

using namespace std;

typedef long long ll;

int N;
ll dp[105][4][4][4]; //dp[i][j][k][l]: i文字目までの組み合わせのうち、i-3文字目がj、i-2文字目がk、i-1文字目がlであるものの数

int main(void) {
    scanf("%d", &N);
    
    rep(i, 0, 4) {
      rep(j, 0, 4) {
        rep(k, 0, 4) {
          if (i == A && j == G && k == C) continue; //AGCは無視
          if (i == A && j == C && k == G) continue; //ACGは無視
          if (i == G && j == A && k == C) continue; //GACは無視
          dp[3][i][j][k] = 1; //3までの文字列のうち条件を満たさないものをカウント
        }
      }
    }

    rep(i, 4, N+1) {
      rep(j, 0, 4) { //i-3番目の文字
        rep(k, 0, 4) { //i-2番目の文字
          rep(l, 0, 4) { //i-1番目の文字
            rep(m, 0, 4) { //今付加する文字
              /*
              jklにmの文字を付加したいとき、
              klmがAGC, ACG, GACを満たさない必要があり
              jklmがA?GC, AG?Cを満たさない必要がある
              逆にこれらを満たさない場合、klmが最後3文字となり、jklの組み合わせをklmの組み合わせに足せば良い
               */
              if (k == A && l == G && m == C) continue; //AGCは無視
              if (k == A && l == C && m == G) continue; //ACGは無視
              if (k == G && l == A && m == C) continue; //GACは無視
              if (j == A && l == G && m == C) continue; //A?GCは無視
              if (j == A && k == G && m == C) continue; //AG?Cは無視
              dp[i][k][l][m] += dp[i-1][j][k][l];
              dp[i][k][l][m] %= MOD;
            }
          }
        }
      }
    }
    ll ans = 0;
    rep(i, 0, 4) {
      rep (j, 0, 4) {
        rep(k, 0, 4) {
          ans += dp[N][i][j][k];
          ans %= MOD;
        }
      }
    }

  
  printf("%lld\n", ans);

	return 0;
}


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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 110, M = 10010;

int n, m, res;
int d[N][N];
PII q[M];
char g[N][N];

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

void bfs(int x, int y)
{
	memset(d, -1, sizeof d);
	
	int hh = 0, tt = -1;
	q[ ++ tt] = {x, y};
	d[x][y] = 0;
	
	while (hh <= tt)
	{
		auto t = q[hh ++ ];
		
		for (int i = 0; i < 4; i ++ )
		{
			int tx = t.F + dx[i];
			int ty = t.S + dy[i];
			
			if (tx < 0 || tx >= n || ty < 0 || ty >= m) continue;
			if (d[tx][ty] != -1 || g[tx][ty] != '.') continue;
			
			int td = d[t.F][t.S] + 1;
			res = max(res, td);
			d[tx][ty] = td;
			q[ ++ tt] = {tx, ty};
		}
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i ++ ) cin >> g[i];
	for (int i = 0; i < n; i ++ )
		for (int j = 0; j < m; j ++ )
			if (g[i][j] == '.')
				bfs(i, j);
				
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << max(0, c-(a-b)) << "\n";
    return 0;
}


Measured memory_bytes: 256
import itertools
import bisect


def main():
    N, K = map(int, input().split())
    D = list(map(int, input().split()))
    P = [str(x) for x in range(10) if x not in D]
    num = []
    for i in range(1, len(str(N))+2):
        for c in itertools.product(P, repeat=i):
            num.append(int("".join(c)))
    idx = bisect.bisect_left(num, N)
    print(num[idx])


if __name__ == "__main__":
    main()


Measured memory_bytes: 43612
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

double rad_to_deg(double x) {
    double res = x/(2*M_PI)*360;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a,b,x; cin >> a >> b >> x;
    double max_v = pow(a,2)*b;
    double ans,h;
    if(max_v>=2*x) {
        h = 2*x / (a*b);
        ans = rad_to_deg(atan2(b,h));
    }
    else {
        h = 2*(max_v-x) / (a*a);
        ans = rad_to_deg(atan2(h,a));
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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 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())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	vector<double> v(n);
	cin >> v;
	SORT(v);
	double ans = (v[0] + v[1])/2.0;
	for (int i = 2; i < n; i++) {
		ans = (ans + v[i])/2.0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; 
    cin >> s;
    int n=s.size();
    vector<ll> a(n+1);
    int tmp=1;
    ll c[2019]={1};
    for(int i=n-1;0<=i;i--){
        a[i]=a[i+1];
        a[i]+=(s[i]-'0')*tmp;
        a[i]%=2019;
        tmp*=10;
        tmp%=2019;
        c[a[i]]++;
    }
    ll ans=0;
    for(int i=0;i<2019;i++){
        ans+=c[i]*(c[i]-1)/2;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 5132
#include<iostream>
using namespace std;
int y,m,d;


int main(){
  while(cin>>y>>m>>d){
    if(y<1868|| (y==1868&&m<9) || (y==1868&&m==9&&d<8) ){
      cout<<"pre-meiji"<<endl;continue;
    }else if(y<1912||(y==1912&&m<7 )||(y==1912&&m==7&&d<30)){
      cout<<"meiji ";y-=1867;
    }else if(y<1926||(y==1926&&m<12)||(y==1926&&m==12&&d<25)){
      cout<<"taisho ";y-=1911;
    }else if(y<1989||(y==1989&&m<1 )||(y==1989&&m==1&&d<8)){
      cout<<"showa ";y-=1925;
    }else{
      cout<<"heisei ";y-=1988;
    }
    cout<<y<<' '<<m<<' '<<d<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
    long long n;
    cin >> n;
    while(n != 0){
        int digit = n % 10;
        if(digit == 7){
            cout << "Yes" << endl;
            return 0;
        }
        n = n / 10;
    }
    cout << "No" <<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

long long M  = 1e9+7;
 
signed main(){
    fast;
    int n,k; cin >> n >> k;
   	map <int,int> mp;
   	for(int i=0 ; i<k ; i++){
   		int x; cin >> x;
   		for(int j=0 ; j<x ; j++){
   			int y; cin >> y;
   			mp[y]++;
   		}
   	}
   	int ans = 0;
   	for(int i=1 ; i<=n ; i++){
   		if(mp[i] == 0)
   			ans++;
   	}
   	cout << ans << endl;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    System.out.println((str.charAt(0)==str.charAt(1) &&
                       str.charAt(1)==str.charAt(2)) ||
                       (str.charAt(1)==str.charAt(2) &&
                       str.charAt(2)==str.charAt(3))
                       ?"Yes":"No");
  }
}

Measured memory_bytes: 32844
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    ans = 0
    
    num_list.sort()

    left = num_list[int(n/2)-1] + 1
    right = num_list[int(n/2)]

    for i in range(left,right+1):
        ans += 1
            
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 52688
#include <stdint.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

#define OPC(n) (n == 0 ? "+" : (n == 1 ? "-" : (n == 2 ? "*" : "/")))

int apply(int a, int b, int op) {
  if (op == 0) return a + b;
  if (op == 1) return a - b;
  if (op == 2) return a * b;
  if (op == 3) return a / b;
  return 0;
}

int main(int argc, char *argv[]) {
  int a, b, c, d;
  int p, q, r, s;
  char v;
  std::cin >> v;
  a = v - '0';
  std::cin >> v;
  b = v - '0';
  std::cin >> v;
  c = v - '0';
  std::cin >> v;
  d = v - '0';

  for (p = 0; p < 4; p++) {
    if (b == 0 && p == 3) continue;
    for (q = 0; q < 4; q++) {
      if (c == 0 && q == 3) continue;
      for (r = 0; r < 4; r++) {
        if (d == 0 && r == 3) continue;
        if (apply(apply(apply(a, b, p), c, q), d, r) == 7) {
          break;
        }
      }
      if (r < 4) break;
    }
    if (q < 4) break;
  }

  printf("%d%s%d%s%d%s%d=7\n", a, OPC(p), b, OPC(q), c, OPC(r), d);

  return 0;
}


Measured memory_bytes: 256
void main() {
    long n = readln.chomp.to!int;
    long[] a = readln.split.to!(long[]);

    long l, r = a.sum;
    long diff = long.max;
    foreach (i; 0 .. n) {
        if (abs(r-l-2*a[i]) < diff) {
            l += a[i];
            r -= a[i];
            diff = abs(r-l);
        } else {
            break;
        }
    }

    abs(r-l).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 11648
#include <cstdio>
#include <cstring>
const int MAXN = 10;
bool vis[11];
char str[MAXN],c;
int main()
{
	int i, j, x, K, Len;
	scanf("%s%d", str, &K);
	for(i=0; i<K; ++i)
	{
		scanf("%d", &x);
		vis[x] = 1;
	}
	Len = strlen(str);
	for(i=0,j=Len-1; i<j; ++i,--j)
		c = str[i], str[i] = str[j], str[j] = c;
	int idx = -1;
	for(i=Len-1; i>=0; --i)
	{
		str[i] -= '0';
		if(vis[str[i]])
			break;
	}
	idx = i;
	bool flag = 0;
	if(idx >= 0)
	{
		for(i=idx; i<Len; ++i)
			if(flag || vis[str[i]])
			{
				flag = 0;
				for(++str[i]; vis[str[i]]; ++str[i]);
				if(str[i] > 9) flag = 1;
				else break;
				for(str[i]=0; vis[str[i]]; ++str[i]);
			}
		if(flag)
		{
			i = Len++;
			for(str[i]=1; vis[str[i]]; ++str[i]);
		}
	}
	for(i=Len-1; i>=idx; --i)
		if(i >= 0) putchar('0'+str[i]);
	int mi = 9;
	for(i=0; i<10; ++i)
		if(!vis[i])
		{
			mi = i;
			break;
		}
	for(i=idx-1; i>=0; --i)
		putchar('0'+mi);
	puts("");
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
//#include <boost/graph/adjacency_list.hpp>
using namespace std;

#define ll long long
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name) 

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, a);
	IN(ll, b);
	//IN_V(ll, als, n);

	cout << max({a + b, a - b, a * b}) << endl;
	
	return 0;
}

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

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

int main() {
    int n,T,mini=10000;
    cin>>n>>T;
    vector<int> c(n),t(n);
    rep(i,n) cin>>c[i]>>t[i];
    rep(i,n) {
        if (t[i]<=T) {
            mini=min(mini,c[i]);
        }
    }
    if (mini==10000) cout<<"TLE"<<endl;
    else cout<<mini<<endl;
}


Measured memory_bytes: 256
M, D = map(int, input().split())

ans = 0
for i in range(M):
    for j in range(D):
        month = i + 1
        day = j + 1
        if day//10 == 1 or day%10 == 1:
            continue
        if(month == (day//10)*(day%10)):
            ans += 1

print(ans)

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


void solve(long long S, long long W){
    if (W>=S) printf("unsafe\n");
    else printf("safe\n");

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);
    solve(S, W);
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#ifndef DBG
#define dbg(...)
#else
#define dbg(...) {cerr << "\033[1;96m"; ostream& cout = cerr; \
(void)(cout); __VA_ARGS__; cerr << "\033[0m";} 
#endif
#define ddmp(...) dbg(dmp(__VA_ARGS__))
#define prt(...) print(cout, __VA_ARGS__)
#define dprt(...) dbg(print(cerr, __VA_ARGS__))
#define dmp(...) print(cerr, #__VA_ARGS__, '=', __VA_ARGS__)
#define all(...) begin(__VA_ARGS__), end(__VA_ARGS__)
#define whr() __LINE__,  __PRETTY_FUNCTION__
using namespace std; using ll = long long;
template< typename... t > using V = vector< t... >;
template< typename t > void print(ostream& os, const t& a)
{os << a <<  '\n';} template< typename t, typename... v >
void print(ostream& os, const t& a, v&&... b){os << a << ' '; print(os, b...);}



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

    string s; cin >> s;
    int cnt = 0;

    for (char c : s)
        cnt += (c == '+'? 1 : -1);
    prt(cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    ll n, k, cnt = 0, ans = 0;

    cin >> n >> k;

    ll x = k*(k+1)/2;
    ll y = k*(k-1)/2;

    x%=mod;
    y%=mod;

    int arr[n];

    for (int i = 0; i < n; i++) {

        cin >> arr[i];
    }

    for (int i = 0; i < n; i++) {

        cnt = 0;

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

            if (arr[i] > arr[j]) cnt++;
        }

        ans += (cnt*x)%mod;

        cnt = 0;

        for (int j = 0; j < i; j++) {

            if (arr[i] > arr[j]) cnt++;
        }

        ans += (cnt*y)%mod;
        ans%=mod;
    }

    cout << ans;

    return 0;
}


//long long vs int
//pow function (+0.5)
//read carefully: overflow, constraints, etc...


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    ll k;
    cin >> n >> k;

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

    int cycle_num;
    vector <int> order(n, -1);

    int cur = 0, ord = 0;
    while (true) {
        if (order[cur] != -1) {
            cycle_num = ord - order[cur];
            break;
        }

        order[cur] = ord++;
        cur = a[cur];
        k--;

        if (k == 0) {
            cout << cur + 1 << endl;
            return 0;
        }
    }

    k %= cycle_num;

    while (k) {
        cur = a[cur];
        k--;
    }

    cout << cur + 1 << "\n";
    return 0;
}

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

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

  string left = s.substr(0, 2);
  string right = s.substr(2, 4);

  bool yymm = false;
  bool mmyy = false;

  if (right != "00" && stoi(right) <= 12) {
    yymm = true;
  }
  if (left != "00" && stoi(left) <= 12) {
    mmyy = true;
  }

  if (yymm && mmyy) {
    cout << "AMBIGUOUS" << endl;
  } else if (yymm) {
    cout << "YYMM" << endl;
  } else if (mmyy) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,t=0,h=0;
    string s;
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
		{
			t++;
		}
		else
		{
			t--;
		}
		if(t>h)
		{
			h=t;
		}
	}
	cout<<h<<endl;
    return 0;	
}

Measured memory_bytes: 256
first_set_count = int(input());
first_set = [int(n) for n in input().split()];
second_set_count = int(input());
second_set = [int(n) for n in input().split()];

def linear_search(first_set, second_set):
    count = 0;
    for n in second_set:
        for m in first_set:
            if n == m:
                count += 1;
                break;
    print(count);

linear_search(first_set, second_set);


Measured memory_bytes: 6560
MAX=8
L = [ [None] * MAX for x in range(MAX) ]

for i in range(MAX):
    l = list(input())
    L[i] = l

T = [ [None] * MAX for x in range(MAX) ]

for r in range(1,4):
    print(r*90)
    for i in range(MAX):
        for j in range(MAX):
            T[i][j] = L[MAX-1-j][i]

    L = T
    T = [ [None] * MAX for x in range(MAX) ]
    for l in L:
        print("".join(l))




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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    uint64_t X, Y;
    cin >> X >> Y;

    int ans;
    for(ans = 0;X<<ans <= Y;ans++) ;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
use proconio::{input,fastout};

struct Time {
  pub hour: usize,
  pub minute: usize
}

impl Time {
  // self - other
  pub fn sub(&self, other: &Time) -> Time {
	if self.minute > other.minute {
      Time {
        hour: self.hour - other.hour,
        minute: self.minute - other.minute
      }
    } else {
      Time {
        hour: self.hour - other.hour - 1,
        minute: self.minute + 60 - other.minute
      }
    }
  }
}

#[fastout]
fn main() {
  input!{h1: usize, m1: usize, h2: usize, m2: usize, k: usize};
  let t1 = Time {hour: h1, minute: m1};
  let t2 = Time {hour: h2, minute: m2};
  let end = t2.sub(&Time {hour: 0, minute: k});
  let ans = end.sub(&t1);
  println!("{}", ans.hour * 60 + ans.minute);
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-9;
const long long INF = OO;
const int MAXN = 206, MAXM = 102, Mod = 998244353, MAXLog = 20;


int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout
            << fixed;

    int n;
    cin >> n;
    long long ans = 1;
    for (int i = 0; i < 3; ++i) {
        ans *= n;
    }
    
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb emplace_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

#define mod 1000000007

ll add(ll a, ll b){return (a%mod + b%mod)%mod;}
ll sub(ll a , ll b){return (a%mod - b%mod + mod)%mod;}
ll mul(ll a, ll b){return (a%mod * b%mod)%mod;}
ull poww(ull a,ull b){ull res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll MOD){ll res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define dbg(x) cout<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define dbg4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;

//end of template

int main(int argc, char const *argv[])
{
	crap;
	int a, b;
	cin >> a >> b ;
	if (a >= 13){
		cout << b << endl;
	}
	else if (a >= 6){
		cout << b/2 <<endl;
	}
	else{
		cout << "0\n";
	}
	return 0;
}

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

const long long MAX_N = 500000 + 10;
long long A[MAX_N], tmp[MAX_N], n;
long long ans;

void merge(long long l, long long r) {
    if (l == r) return;
    long long mid = l + r >> 1;
    merge(l, mid);
    merge(mid + 1, r);
    long long i = l, j = mid + 1, k = l;
    while (i <= mid && j <= r) {
        if (A[i] <= A[j]) tmp[k++] = A[i++];
        else {
            ans += mid - i + 1;
            tmp[k++] = A[j++];
        }
    }
    while (i <= mid) tmp[k++] = A[i++];
    while (j <= r) tmp[k++] = A[j++];
    for (long long t = l; t <= r; t++) A[t] = tmp[t];
}

int main() {
	string s;
	cin >> s;
//	cout <<s.max_size() <<endl;
	long long n = s.size();
	for (long long i = 0; i < n; i++) {
		if (s[i] == 'B') A[i + 1] = 1;
		else A[i + 1] = 0;
	}
	merge(1, n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6276
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 2147483647;
const ll INF = 100000000000010000;
const ull B = 998244353;

//ll bit[200010];
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void update(ll i, ll x)
{
	i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

/*ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
	//毎回オーダーlog(n)かかる
}*/

/*void kaijo() {
	kai[0] = 1;
	for (ll i = 1; i <= 3004; i++) {
		kai[i] = kai[i - 1] * i % mod;
	}
}*/

ll N, hashed[5010], pow_B[5010];
string S;

bool judge(ll len) {
	map<ll, ll> mp;
	for (ll i = S.length() - 2 * len; i >= 0; i--) {
		ll b = (mod + hashed[i + 2 * len] - hashed[i + len] * pow_B[len] % mod) % mod;
		mp[b]++;
		ll a = (mod + hashed[i + len] - hashed[i] * pow_B[len] % mod) % mod;
		if (mp[a] > 0) return true;
	}
	return false;
}

void solve() {
	cin >> N >> S;
	rep(i, N) (hashed[i + 1] = hashed[i] * B + S[i]) %= mod;
	pow_B[0] = 1;
	rep(i, N) pow_B[i + 1] = pow_B[i] * B % mod;
	ll lb = 0, ub = N;
	while (lb + 1 < ub) {
		ll mid = (lb + ub) / 2;
		if (judge(mid)) lb = mid;
		else ub = mid;
	}
	cout << lb << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}


Measured memory_bytes: 640