akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int N,M;
	cin>>N>>M;
	int freq[N+1];
	memset(freq,0,sizeof(freq));
	int i,j,k;
	bool check[N+1];
	memset(check,false,sizeof(check));
	string s;
	for(i=1;i<=M;i++)
	{
		cin>>j>>s;
		if(s.compare("AC")==0)
		{
			check[j]=true;
		}
		else
		{
			if(check[j]==false)
			freq[j]++;
		}
	}
	j=0;
	k=0;
	for(i=1;i<=N;i++)
	{
		if(check[i])
		{
			j++;
			k=k+freq[i];
		}
	}
	cout<<j<<" "<<k;
	return 0;
}

Measured memory_bytes: 4088
#include <stdio.h>
#include <ctype.h>
#define debug
int main(int argv, char *argc[]){
    char buf, print[2]={0};
    int x, num[26]={0};
    
    for(buf=getchar();!(EOF == buf); buf=getchar()){
        if(isalpha(buf)){
            num[tolower(buf)-'a']++;
        }
    }
    
    for(x=0; 26 > x; x++){
        print[0] = 'a'+x;
        printf("%s : %d\n", print, num[x]);
    }
    
    return 0;
}

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

int main() {
  ll n; cin >> n;
  vector<pair<ll, ll>> a(n);
  rep(i, n) {
    int x, l; cin >> x >> l;
    a[i].first = x + l;
    a[i].second = x - l;
  }
  sort(a.begin(), a.end());
  ll ans = 0, t = a[0].second;
  for (ll i = 0; i < n; i++) {
    if (t <= a[i].second) {
      ans++;
      t = a[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
// include
#include <array>
#include <algorithm>
#include <set>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <unordered_map>


// pow(10, 15) 10の15乗

//  多倍長整数
#include <boost/multiprecision/cpp_int.hpp>
using big_int = boost::multiprecision::cpp_int;


// ============================================
int main() {
    int L, R, d;
    std::cin >> L >> R >> d;
    int ans = 0;
    for (int i = L; i <= R; ++i) {
      if (i % d == 0) {
        ans++;
      }
    }
  
    std::cout << ans << std::endl;

    return 0;
}


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

int main()
{
    int N;
    int set = 2;
    cin >> N;

    if (N == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    for (int i = 1 ; i < 7 ; i++){
        if (set <= N && set * 2 > N)
        {
            cout << set << endl;
            return 0;
        }
        set = set * 2;
    }

        
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#define MAX 100005 
using namespace std;

struct node1
{
	int parent;
	vector<int> a;//相邻之节点 
};

node1 pnt[MAX];
int n;
int main()
{
	int i,j;
	int x,y;
	int f,t;
	int dis;
	int c;
	int fenneccontrol=0;
	int snukecontrol=0;
	queue<int> q;
	queue<int> q1;
	cin>>n;
	for (i=1;i<n;i++)
	{
		cin>>x>>y;
		pnt[x].a.push_back(y);
		pnt[y].a.push_back(x);
	}
	pnt[1].parent=-1;
	q.push(1);
	while (!q.empty())
	{
		f=q.front();
		q.pop();
		for (i=0;i<pnt[f].a.size();i++)
		{
			t=pnt[f].a[i];
			if (t==pnt[f].parent) continue;
			pnt[t].parent=f;
			q.push(t);
		}
	}
	
	f=n;
	dis=0;
	while(f!=1)
	{
		dis++;
		f=pnt[f].parent;
	}
	
	dis--;
	c=n;
	
	for (i=1;i<=dis/2;i++)
	{
		c=pnt[c].parent;
	}
	
	
	q1.push(c);
	while (!q1.empty())
	{
		f=q1.front();
		q1.pop();
		for (i=0;i<pnt[f].a.size();i++)
		{
			t=pnt[f].a[i];
			if (t==pnt[f].parent) continue;
			snukecontrol++;
			q1.push(t);
		}
	}
	
	snukecontrol++;
	fenneccontrol=n-snukecontrol;
	if (snukecontrol>=fenneccontrol)
	{
		cout<<"Snuke";
	}
	else
	{
		cout<<"Fennec";
	}
	return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int a, b;
    cin >> a >> b;

    cout << max(a + b, max(a - b, a * b)) << '\n';
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    int N,A,B;
    cin >> N >> A >> B;
    if(N*A < B) cout << N*A << endl;
    else cout << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n, m; cin >> n >> m;
    vector<string> a(n), b(m); cin >> a >> b;

    string ans = "No\n";
    FOR(y, 0, n - m + 1)FOR(x, 0, n - m + 1) {
        bool ok = true;
        FOR(i, 0, m)FOR(j, 0, m) {
            ok &= (a[y + i][x + j] == b[i][j]);
        }
        if (ok)ans = "Yes\n";
    }
    cout << ans;
}


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

int main() {
  #define int long long
  string s;
  cin >> s;
  int n = s.size() - 1;
  int res = 0;
  for (int bit = 0; bit < (1<<n); bit++) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int si = s.at(i) - '0';
      if ((1<<i) & bit) {
        res = res + 10 * sum + si;
        sum = 0;
      }
      else {
        sum = si + sum * 10;
      }
    }
    res += 10 * sum;
    res += (int)s.at(n) - '0';
  }
  cout << res << endl;
}





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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	double V;
	vector<double> H;
	while(cin>>V){
		H.push_back(V);
	}
	auto res = minmax_element(ALL(H));
	
	printf("%.5lf\n",*res.second-*res.first);
	return 0;
}


Measured memory_bytes: 3216
<?php
list ($S, $T) = fscanf(STDIN, '%s %s');
list ($A, $B) = fscanf(STDIN, '%d %d');
list ($U) = fscanf(STDIN, '%s');

echo (strcmp($S, $U) == 0) ? sprintf("%d %d", $A-1, $B) : sprintf("%d %d", $A, $B-1);
?>


Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int dy[]={-1,0,1,0},dx[]={0,-1,0,1};
int w,h;
char fld[20][20];
int lim;

void paint(int y,int x,char c,vector<int>&V){
    char tmp=fld[y][x];
    fld[y][x]=c;
    V.push_back(y*w+x);

    rep(d,4){
        int ny=y+dy[d],nx=x+dx[d];
        if(ny<0||ny>=h||nx<0||nx>=w)continue;
        if(fld[ny][nx]!=tmp)continue;
        paint(ny,nx,c,V);
    }
}
bool dfs(int cnt){
    char c=fld[0][0];
    bool ok=1;
    rep(i,h)rep(j,w)if(fld[i][j]!=c)ok=0;
    if(ok)return 1;
    if(cnt>=lim)return 0;

    rep(i,3)if(c!="RGB"[i]){
        vector<int>V;
        paint(0,0,"RGB"[i],V);
        if(dfs(cnt+1))return 1;
        rep(j,V.size())fld[V[j]/w][V[j]%w]=c;
    }
    return 0;
}

int main(){
    while(cin>>w>>h,w||h){
        rep(i,h)rep(j,w)cin>>fld[i][j];
        for(lim=0;;lim++){
            if(dfs(0))break;
        }
        cout<<lim<<endl;
    }
    return 0;
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

ll k;
ll n=50;
ll q;
ll r;
ll a[50];

int main(){
  scanf("%lld",&k);
  q=k/n;
  r=k%n;
  REP(i,n){
    a[i] = i+q;
  }
  REP(i,r){
    REP(j,n){
      if(i==j) continue;
      a[j]--;
    }
    a[i] += n;
  }
  printf("%lld\n",n);
  REP(i,n){
    printf("%lld ",a[i]);
  }
  printf("\n");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long n = 0;
  long q = 0;
  long asum[500001] = {};
  char s[500000] = {};
  long l[500000] = {};
  long r[500000] = {};
  long ans[500000] = {};
  long i = 0;
  long j = 0;
  
  scanf("%ld %ld",&n,&q);
  scanf("%s",s);
  for(i=0;i<q;i++){
    scanf("%ld %ld",&l[i],&r[i]);
  }
  //printf("%s",s);
  for(i=0;i<n;i++){
    if(i == 0){
      asum[0] = 0;
    }else{
      if(s[i-1] == 'A' && s[i] == 'C'){
        asum[i]++;
      }
    }
    
    asum[i+1] = asum[i];
    
    //printf("%ld ",asum[i]);
  }
  //printf("\n");
  for(i=0;i<q;i++){
    printf("%ld\n",asum[r[i]-1]-asum[l[i]-1]);
    /*ans[i] = asum[r[i]-1]-asum[l[i]-1];
    if(ansc[i] != ans[i]){
      printf("%ld/%ld\n",ansc[i],ans[i]);
    }*/
  }
  return 0;
}
    
        
  

Measured memory_bytes: 13056
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<string> si(N);
    vector<vector<ll>> alphanum(N,vector<ll>(26,0));
    for (int i = 0;i <N;i++){
        cin >> si[i];
        sort(si[i].begin(),si[i].end());
    }

    sort(si.begin(),si.end());
  
    ll ans = 0;
    ll cnt = 1;
    for (int i=0;i<N-1;i++){
      if (si[i] == si[i+1]) cnt++;
      else {
        ans += cnt*(cnt-1)/2;
        cnt = 1;
      }
    }
    ans += cnt*(cnt -1)/2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 31488
#include<stdio.h>

int main(){
  char g[101][10];
  int y[105],m[105],d[105];
  
  int i=0;
  for(;;){
    scanf("%s%d%d%d", g[i], &y[i], &m[i], &d[i]);
    if(g[i][0]=='#') break;
    i++;
  }

  int j;
  for(j=0;j<i;j++){
    
    if(((y[j]>=31)&&(m[j]>=5)||y[j]>=32)){
      printf("? %d %d %d\n",y[j] - 30, m[j], d[j]);
    } else {
      printf("HEISEI %d %d %d\n", y[j], m[j], d[j]);
    }
    
  }

  
  return 0;
}


Measured memory_bytes: 2696
#include<bits/stdc++.h>//万能库
using namespace std;
int n;
long long f[87];//开longlong，防爆
int main()
{
    cin>>n;
    f[0]=2;//初始化
    f[1]=1;
    for(int i=2;i<=n;i++)
        f[i]=f[i-1]+f[i-2];//套用公式
    cout<<f[n];//输出第n个
}


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

public class Main {
    public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String N = br.readLine();

	if (N.endsWith("2") || N.endsWith("4") || N.endsWith("5") || N.endsWith("7") || N.endsWith("9")) {
	    System.out.println("hon");
	} else if (N.endsWith("0") || N.endsWith("1") || N.endsWith("6") || N.endsWith("8")) {
	    System.out.println("pon");
	} else {
	    System.out.println("bon");
	}
    }
}


Measured memory_bytes: 32616
A,B,M = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
m = min(a) + min(b)
l = []
ans = 1000000
for i in range(M):
    x,y,c = map(int,input().split())
    l.append([x,y,c])
for i in range(M):
    s = a[l[i][0]-1] + b[l[i][1]-1] - l[i][2]
    if(s < ans):
        ans = s
print(min(ans, m))

Measured memory_bytes: 30764
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; 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;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	int p=0;
	while(s.find("ABC",p)!=-1){
		cnt++;
		p = s.find("ABC",p) + 1;
	}
	cout << cnt << '\n';
	return 0;
}



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

int main(){
    int N, M;
    cin >> N >> M;
    bool ac[100001] = {};
    int  wa[100001] = {};
    int wa_cnt = 0;
    int ac_cnt = 0;
    for(int i = 0; i < M; i++ ){
        int num;
        string result;
        cin >> num >> result;
        if(ac[num] == false && result == "WA"){
            wa[num]++;
        }
        else if (ac[num] == false && result == "AC"){
            ac[num] = true;
            wa_cnt += wa[num];
            ac_cnt++;
        }
    }
    cout << ac_cnt << " " << wa_cnt << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define mod 1000000007
using namespace std;

int h[12345],A[12345];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);


int n;
cin>>n;

string A;
cin>>A;

stack<char>s;

    string ans;
    deque<char>q;
for(int i=0;i<n;i++)
    {
        if(A[i]=='(')
            {s.push(A[i]);
            q.push_back(A[i]);
            }
        else
        {
            if(s.empty())
             {q.push_front('(');
             q.push_back(')');
             }
            else
                {s.pop();
                q.push_back(')');
                }
        }
    }

    while(!s.empty())
    {
       q.push_back(')');
       s.pop();

    }
    for(auto i : q)
    {
        ans+=i;
    }
cout<<ans<<"\n";
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,i=0;
	scanf("%d",&n);
	int m[n];
	while(n>i){
		scanf("%d",&m[i]);
		i++;
	}
	i=n-1;
	while(i>=0){
		printf("%d",m[i]);
		if(i>0)printf(" ");
		else if(i==0)printf("\n");
		i--;
	}
	return 0;
} 


Measured memory_bytes: 2052
/*
.......................
.......................
..... MY CODES ARE ....
... UGLIER THAN YOU ...
.......................
.......................
*/
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define maxn 200005
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;

void solve(){
    int a, b, res;
    cin >> a >> b;
    res = a/b;
    if(a%b) res++;
    cout <<res << endl;
}


int main() {

    int tc;
    tc = 1;
    while(tc--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
def ssplit(s):
    tp=0
    tmp=""
    ret=[]
    for c in s:
        if c.isdigit():
            tmp+=c
        else:
            if tmp!="":
                ret.append((0,int(tmp)))
                tmp=""
            ret.append((1,ord(c)))
    if tmp!="":
        ret.append((0,int(tmp)))
    return ret

n=int(input())
s=ssplit(input())
for i in range(n):
    z=ssplit(input())
    if z>=s:
        print('+')
    else:
        print('-')
    
    


Measured memory_bytes: 5612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            Integer a[] = new Integer[n];
            Integer b[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
                b[i] = a[i];
            }

            Arrays.sort(b, Comparator.reverseOrder());

            for (int i = 0; i < n; i++) {
                if (a[i] == b[0]) {
                    out.println(b[1]);
                } else {
                    out.println(b[0]);
                }
            }

        }

    }
}



Measured memory_bytes: 66252
#### import ####
import sys
sys.setrecursionlimit(10**7)
import math
from collections import defaultdict

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

from collections import deque

N = I()
tempA = [0]*N
for i in range(N):
  tempA[i] = I()
  
tempA.sort()
A = deque(maxlen=N)
for i in range(N):
  A.append(tempA[i])
A2 = tempA[:]


temp = A.popleft()
B = deque(maxlen=N)
B.append(temp)
for i in range(math.ceil((N-1)/2)):
  if i%2==0:
    temp = A.pop()
    B.appendleft(temp)
    if len(A)>0:
      temp = A.popleft()
      B.appendleft(temp)
  else:
    temp = A.pop()
    B.append(temp)
    if len(A)>0:
      temp = A.popleft()
      B.append(temp)

val1 = 0
val2 = val1
for i in range(N-1):
  val1 += abs(B[i]-B[i+1])

if N%2==1:
  val2 = val1-abs(A2[(N-1)//2]-A2[(N-1)//2+1])+abs(A2[(N-1)//2]-A2[(N-1)//2-1])
print(max(val1,val2))

Measured memory_bytes: 50648
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int n, k;
    
    cin >> n;
    
    k = int(n / 15) - 5;
    
    if(k < 0) {
        cout << 0 << endl;
    } else if(n >= 189) {
        cout << int(k / 2) + 1 << endl;
    } else {
        cout << int(k / 2) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 764
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Queue;
import java.util.Scanner;

class Edge {
    int from, to;

    Edge(int from, int to) {
        this.from = from;
        this.to = to;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        ArrayList<ArrayList<Integer>> graph = new ArrayList<>(N + 1);
        for (int i = 0; i <= N; i++) graph.add(new ArrayList<>());
        for (int i = 0; i < M; i++) {
            int A = scan.nextInt(), B = scan.nextInt();
            graph.get(A).add(B);
            graph.get(B).add(A);
        }

        Queue<Edge> explore = new ArrayDeque<>();
        explore.add(new Edge(0, 1));
        ArrayList<Integer> ans = new ArrayList<>(N + 1);
        for (int i = 0; i <= N; i++) ans.add(-1);

        while (!explore.isEmpty()) {
            Edge now = explore.poll();
            if (ans.get(now.to) != -1) continue;
            ans.set(now.to, now.from);

            for (Integer next : graph.get(now.to)) {
                if (ans.get(next) != -1) continue;
                explore.add(new Edge(now.to, next));
            }
        }

        System.out.println("Yes");
        for (int i = 2; i <= N; i++) {
            System.out.println(ans.get(i));
        }
    }
}


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

typedef long long ll;
ll p = 1e9+7;

int main(){
    int N;
    cin >> N;
    
    vector<int> c(1111,0);
    for(int i=2; i<=N; i++){
        int n=i, j=2;
        while(1){
            if(n%j==0){
                n /= j;
                c[j]++;
                j=2;
            }
            else j++;
            if(n==1) break;
        }
    }
    ll ans=1;
    for(int i=2; i<=N; i++){
        if(c[i]>0){
            ans *= c[i]+1;
            ans = ans % p;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[10000];
int main()
{
	int n;
	scanf("%d", &n);
	while(n != 0)
	{
		if(n % 2 == 0)
			a[++ a[0]] = 0, n /= -2;
		else if(n > 0)
			a[++ a[0]] = 1, n /= -2;
		else
			a[++ a[0]] = 1, n = (n / (-2)) + 1;
	}
	for(int i = a[0]; i >= 1; -- i)
		printf("%d", a[i]);
	if(a[0] == 0)
		printf("0");
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
if n == 2
    puts a[1].to_s + " " + a[0].to_s
    exit
end
max_num = a.pop
mi = []
a.each_with_index do |e, i|
    mi << [(e*2 - max_num).abs, i]
end
r = mi.min{|a, b| a[0] <=> b[0]}
puts [max_num, a[r[1]]].join(" ")

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s[1] == 'R') s[1] = 'B';
    else s[1] = 'R';
    cout << s << "\n";
    return 0;
}

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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;
//iostream::sync_with_stdio(false);

int main()
{
	ll n, m;
	cin >> n >> m;
	if(n == 1 || m == 1)
    {
        cout << 1 << endl;
    }
	else if (n % 2)
	{
		if (m % 2)
		{
			cout << (n + 1) / 2 * (m + 1) / 2 + (n / 2) * (m /2 );
		}
		else
		{
			cout << (n + 1) / 2 * (m/ 2) + (n / 2) * (m / 2);
		}
	}
	else
	{
		cout << (n / 2) * m;
	}
	return 0;
}




Measured memory_bytes: 256
N = int(input())
ans = 0
def f(a):
    r = 0
    for i in range(1,a+1):
        if a % i == 0:
            r += 1
    return r
for i in range(1, N+1):
    if i % 2 == 1 and f(i) == 8:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void){
  int X, A, B;
  cin >> X >> A >> B;

  //賞味期限の day_ 日後に食べる       
  int day_ = B-A; 
  int flag_2;

  //賞味期限の(-day_)日前に食べる
  if(day_ <= 0)
    cout << "delicious" << endl;
  //賞味期限を過ぎたとき
  else{
    //過ぎた日数がX日以内
    if(X >= day_)
      cout << "safe" << endl;
    //過ぎた日数がX日より大きい
    else
      cout << "dangerous" << endl;
      }
    
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
int n, a[3000];
long long dp[3000][3000][2];
bool vis[3000][3000][2];
long long calc(int l, int r, int t) {
	if (l > r) return 0;
	if (vis[l][r][t]) return dp[l][r][t];
	long long res;
	if (t == 0) {
		res = max(calc(l + 1, r, 1) + a[l], calc(l, r - 1, 1) + a[r]);
	} else {
		res = min(calc(l + 1, r, 0) - a[l], calc(l, r - 1, 0) - a[r]);
	}
	vis[l][r][t] = 1;
	return dp[l][r][t] = res;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	memset(vis, 0, sizeof(vis));
	long long ans = calc(0, n - 1, 0);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 158080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str= br.readLine();
		while(str!=null){
			
			System.out.println(str.toUpperCase());
			str= br.readLine();
		}
	}

}

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

using namespace std;

int main()
{
    string S, T;
    int A, B;
    string U;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if(S == U)
    {
        cout << A - 1 << " " << B << endl;
    }
    else
    {
        cout << A << " " << B -1  << endl;
    }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
	if(a<=b){
		cout << a << endl;
    }else{
		cout << a-1 << endl;
    }
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  A - Payment
//
//  Created by 李远铄 on 2020/8/7.
//  Copyright © 2020 李远铄. All rights reserved.
//

#include <iostream>

#define _DEBUG_
#ifdef _DEBUG_
#define debug(x) cout << #x << ": " << x << "  "
#define print_n printf("\n")
#define cout_n cout<<'\n'
#else
#define debug(x)
#define print_n
#define cout_n
#endif

using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    scanf("%d",&n);
    if(n%1000==0){
        printf("0\n");
    }else{
        printf("%d\n",1000-n%1000);
    }
    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  vi price(3);
  Srep(3) cin >> price[i];
  Vsort(price);
  cout << price[0] + price[1] << endl;
}

Measured memory_bytes: 3604
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        a: String,
        b: String,
    }

    if a.len() > b.len() {
        println!("GREATER");
    } else if a.len() < b.len() {
        println!("LESS");
    } else {
        let zero = '0' as i32;
        for (a, b) in a.chars().zip(b.chars()) {
            let a = a as i32 - zero;
            let b = b as i32 - zero;
            if a > b {
                println!("GREATER");
                return;
            } else if a < b {
                println!("LESS");
                return;
            }
        }
        println!("EQUAL");
    }
}


Measured memory_bytes: 2108
package main

import (
  "fmt"
  "reflect"
  "sort"
)

func main() {
  var n1, n2, n3, n4 int
  fmt.Scan(&n1, &n2, &n3, &n4)
  
  numbers  := []int{n1, n2, n3, n4}
  sort.Ints(numbers)
  expected := []int{1, 4, 7, 9}
  if reflect.DeepEqual(numbers, expected) {
    fmt.Print("YES")
  } else {
    fmt.Print("NO")
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <unordered_set>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <unordered_map>
#include <algorithm>

typedef long long ll;

using namespace std;

int main(void) {
    ll A, B, C, D;
    ll count = 0;
    cin >> A >> B >> C >> D;

    if (C > D) swap(C, D);

    // all - (C's + D's - C * D')
    ll all = B - A + 1;
    ll cc = 0, dd = 0, cd = 0;

    // C
    ll ci = (A / C) * C;
    ll cmi = (B / C) * C;
    if (ci < A) ci += C;
    if (cmi > B) cmi -= C;

    // D
    ll di = (A / D) * D;
    ll dmi = (B / D) * D;
    if (di < A) di += D;
    if (dmi > B) dmi -= D;

    // C and D
    ll CD = C * D / __gcd(C, D);
    // cout << CD << endl;
    ll cdi = (A / CD) * CD;
    ll cdmi = (B / CD) * CD;
    if (cdi < A) cdi += CD;
    if (cdmi > B) cdmi -= CD;
    cc = (cmi - ci) / C + 1;
    dd = (dmi - di) / D + 1;
    cd = (cdmi - cdi) / CD + 1;

    cout << (all - cc - dd + cd) << endl;

    // for (int i = A; i <= B; i++) {
    //     if (i % C != 0 && i % D != 0) {
    //         cout << i << endl;
    //         count++;
    //     }
    // }
    // cout << count << endl;
}

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

int main()
{
    int H, N;
    cin >> H >> N;
    int a[1010];
    int b[1010];
    int dp[10010];
    for(int i=0;i<N;i++)
        cin >> a[i] >> b[i];
    int temp;
    for(int i=1;i<=H;i++)
    {
        temp = 100000000;
        for(int j=0;j<N;j++)
        {
            if((i-a[j]) <= 0)
            {
                if(temp > b[j])
                    temp = b[j];
            }else{
                if(temp > (b[j] + dp[i-a[j]]))
                    temp = b[j] + dp[i-a[j]];
            }
        }
        dp[i] = temp;
    }
    cout << dp[H] << endl;
    return 0;
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n,m;
	cin>>n>>m;
	string s;
	cin>>s;
	vi ans;
	int i = s.length()-1;
	while(i>0) {
		if(s[i]=='1'){
			cout<<-1;
			return;
		}
		int prev = i;
		i-=m;
		if(i<0){i=0;}
		if(s[i]=='1') {
			for(int p=i+1;p<prev;p++){
				if(s[p]=='0'){
					i=p;
					break;
				}
			}
		}
		ans.PUB(prev-i);
	}
	for(int j=ans.size()-1;j>=0;j--)cout<<ans[j]<<" ";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 4076
#include<iostream>

int main(){
    int table[101][101];
    int i,j;
    int r,c;
    int sumr[100];
    int sumc[100];
    int sumall;
    
    std::cin>>r>>c;

    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            std::cin>>table[i][j];
        }
    }

    for(i=0;i<100;i++){
        sumr[i]=0;
        sumc[i]=0;
    }

    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            sumr[i]+=table[i][j];
        }
    }

    for(j=0;j<c;j++){
        for(i=0;i<r;i++){
            sumc[j]+=table[i][j];
        }
    }
    sumall=0;

    for(i=0;i<r;i++){
        sumall+=sumr[i];
    }
    
    for(i=0;i<r;i++){
        for(j=0;j<=c;j++){
            
            if(j==c){
                std::cout<<sumr[i]<<std::endl;
                }
            else{
                std::cout<<table[i][j]<<" ";
                }
        }
    }
    
    for(j=0;j<c;j++){
        std::cout<<sumc[j]<<" ";
    }
    std::cout<<sumall<<std::endl;
    return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    auto Q = readln.chomp.to!int;
    auto ks = readln.split.to!(int[]);

    foreach (k; ks) {
        long res;
        auto ms = new long[](N);
        long d, m, dm;
        foreach (i, c; S) {
            if (i >= k) {
                if (S[i-k] == 'D') {
                    --d;
                    dm -= ms[i-1] - ms[i-k];
                }
            }
            switch (c) {
                case 'D':
                    ++d;
                    break;
                case 'M':
                    ++m;
                    dm += d;
                    break;
                case 'C':
                    res += dm;
                    break;
                default:
            }
            ms[i] = m;
        }
        writeln(res);
    }
}

Measured memory_bytes: 30948
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
//#define i_7 998244353
//#define i_5 i_7-2
ll i_7=(ll)(1E9+7);
ll i_5=i_7-2;
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////

int main(){fastio
    ll n,a,b;cin>>n>>a>>b;
    vector<ll> v[n+1];
    rep(i,1,n-1){
        ll x,y;cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    vector<ll>chi[n+1];
    ll pa[n+1];memset(pa,-1,sizeof(pa));
    pa[b]=0;
    queue<ll>q;q.push(b);
    
    ll dep[n+1];
    dep[b]=0;
    while(!q.empty()){
        ll t=q.front();q.pop();
        for(auto x:v[t]){
            if(pa[x]==-1){
                pa[x]=t;
                chi[t].pb(x);
                q.push(x);
                dep[x]=dep[t]+1;
            }
        }
    }
    bool path[n+1];memset(path,false,sizeof(path));
    path[a]=true;
    ll pos=a;
    while(pos!=b){
        for(auto x:v[pos]){
            if(dep[x]<dep[pos]){
                pos=x;path[pos]=true;
                break;
            }
        }
    }
    rep(i,1,n)if(path[i]==false)dep[i]=0;
    ll sta;
    rep(i,1,n){
        if(dep[i]==(dep[a]+2)/2){
            sta=i;break;
        }
    }
    q.push(sta);
    while(!q.empty()){
        ll t=q.front();q.pop();
        for(auto x:chi[t]){
            dep[x]=dep[t]+1;
            q.push(x);
        }
    }
    ll ans=0;
    rep(i,1,n){
        if(chi[i].size()==0)continue;
        Max(ans,dep[i]);
    }
    cout<<ans<<endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 12800
from collections import defaultdict
n,m = map(int,input().split())
ans = []
flag = True
b = defaultdict(list)
for i in range(n):
    ans.append('a')
for i in range(m):
    s,c = map(int,input().split())
    c = str(c)
    b[s].append(c)

for key,value in b.items():
    if len(set(value)) == 1:
        ans[key-1] = value[0]
    else:
        flag = False
tmp = ''
if n > 1 and ans[0] == '0':
    print(-1)
    exit()
for idx,i in enumerate(ans):
    if idx == 0 and i == 'a':
        if n != 1:
            i = '1'
        else:
            i = '0'
    elif i == 'a':
        i = '0'
    tmp += i
print(tmp if len(tmp) == n and flag else -1)

Measured memory_bytes: 3316
import java.util.Scanner;


public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new A().doIt();
	}


	class A{
		void doIt(){
			while(true){
				int b[] = new int [1000];
				int min = Integer.MAX_VALUE, max = 0, sum = 0;
				int count = in.nextInt();
				if(count ==0)return;
				for(int i = 0; i < count; i++)b[i] = in.nextInt();
				for(int i=0;i<count;i++){
					sum += b[i];
					min = Math.min(min, b[i]);
					max = Math.max(max, b[i]);
				}
				sum -= min;
				sum -= max;
				double result = (1.0 * sum) / (count - 2);
				System.out.println((int)result);
			}
		}

	}
}

Measured memory_bytes: 21012
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    H1,M1,H2,M2,K = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = max((H2*60+M2)-(H1*60+M1)-K,0)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61776
l,r = map(int,input().split())
ans = 10**10
for i in range(l,r+1):
    for j in range(i+1,r+1):
        x = (i*j)%2019
        if x==0:
            ans = 0
            break
        else:
            ans=min(ans,x)
    else:
        continue
    break
print(ans)

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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mod 1000000007

int main () {
    char s[10];
    scanf("%s",s);
    int n = strlen(s);
    int f = 0;
    for(int i = 0; i < n-1; i++)
        if(s[i] == 'A' && s[i+1] == 'C') f = 1;
    printf("%s\n",f == 1 ? "Yes" : "No" );
    return 0;
}

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


int main(){
    
    int a,p;
    cin >> a >> p;
    
    cout << (a*3+p)/2 << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
A.sort()
B = []

ans = 1

if len(A) % 2 == 0:
    for i in range(len(A)//2):
        ans *= 2
        ans %= MOD
        B.append(2 * i + 1)
        B.append(2 * i + 1)

else:
    B.append(0)
    for i in range(len(A)//2):
        ans *= 2
        ans %= MOD
        B.append(2 * i + 2)
        B.append(2 * i + 2)

if A == B:
    print(int(ans))
else:
    print(0)


Measured memory_bytes: 14008
n=int(input())
a={}
for _ in range(n):
  s=input()
  if a.get(s):a[s]+=1
  else:a[s]=1
m=int(input())
b={}
for _ in range(m):
  s=input()
  if b.get(s):b[s]+=1
  else:b[s]=1
ans=0
for i in a:
  ans=max(a[i]-b.get(i,0),ans)
print(ans)

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

using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
    }

    cout << (n - 2) / (k - 1) + 1 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
重ならずに2回現れる文字列の最長かな
さっぱりわからん
しゃくとり？
でも開始文字からずれると
N^3ぐらいになりそう

TLE。
ちょっとの効率化

abcdab

*/
int main(){
  ll N,ans=0; cin>>N;
  string S; cin>>S;
  for(ll i=1; i<N; i++){//文字幅
    ll tmp=0;
    for(ll j=0; j+i<N; j++){
      tmp=(tmp+1)*(S[j]==S[i+j]);
      ans=max(ans,min(tmp,i));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
INV0 = pow(81729648000, MOD - 2, MOD)
INV1 = pow(163459296000, MOD - 2, MOD)
t = int(input())
buf = []
for _ in range(t):
    n = int(input())
    m = n // 2

    even = 0
    for i, co in enumerate([-11188800, -11670840, 2429994, 8028877, 4647426, 1368843, 235536, 23988, 1344, 32]):
        even = (even + co * pow(m, i, MOD)) % MOD
    for c in range(m - 2, m + 4):
        even = even * c % MOD
    even = even * INV0 % MOD

    if n % 2 == 0:
        m -= 1

    odd = 0
    for i, co in enumerate(
            [-61387200, -162718920, -80000346, 32588015, 46247060, 20273505, 4868682, 706860, 62040, 3040, 64]):
        odd = (odd + co * pow(m, i, MOD)) % MOD
    for c in range(m - 1, m + 4):
        odd = odd * c % MOD
    odd = odd * INV1 % MOD

    ans = (even + odd) % MOD
    buf.append(ans)

print('\n'.join(map(str, buf)))


Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numK = 0;
		int eqaC = 0;
		int oddC = 0;

		try {
			scanner = new Scanner(System.in);
			numK = scanner.nextInt();
			for (int i = 1; i <= numK; i++) {
				if (i % 2 == 0) {
					eqaC++;
				} else {
					oddC++;
				}
			}

			System.out.println(eqaC * oddC);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>

//using namespace std;


int main(void) {

	int n,i;
	std::cin >> n;
	std::vector<int> b(n - 1);
	for (i = 0; i < n - 1; i++) {
		std::cin >> b.at(i);
	}
	std::vector<int> a(n);
	a.at(0) = b.at(0);
  	a.at(n-1)=b.at(n-2);
	for (i = 0; i < n - 2; i++) {
		if (b.at(i) < b.at(i + 1)) {
			a.at(i + 1) = b.at(i);
		}else if (b.at(i) > b.at(i + 1)) {
			a.at(i + 1) = b.at(i+1);
		}else if(b.at(i) == b.at(i + 1)){
        		a.at(i + 1) = b.at(i);
        }
	}
	int s = 0;
	for (i = 0; i < n; i++) {
		s += a.at(i);
	}
	std::cout << s << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int a, b;

signed main()
{
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;

    return 0;
}
/*


*/


Measured memory_bytes: 256
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 3e5 + 7;
const int logn = 19;
int n;
int bin[logn], lg[maxn];
int pos[maxn];
struct seg
{
	int l, r, x, y;
};
inline bool operator < (const seg &u, const seg &v)
{
	if(u.x != v.x) return u.x > v.x;
	return u.y > v.y;
}
priority_queue <seg> q;
inline int Get()
{
	char c;
	while(!isdigit(c = getchar()));
	int x = c - '0';
	while(isdigit(c = getchar()))
		x = x * 10 + c - '0';
	return x;
}
struct minimum
{
	int x, y, ans[maxn][logn];
	inline void Init()
	{
		memset(ans, 127 / 2, sizeof(ans));
	}
	inline void Rmq()
	{
		for(int k = 1; k < logn; ++k)
			for(int i = 1; i <= n; ++i)
			{
				if(i + bin[k] - 1 > n) break;
				ans[i][k] = min(ans[i][k - 1], ans[i + bin[k - 1]][k - 1]);
			}
	}
	inline int Min(int l, int r)
	{
		int len = lg[r - l + 1];
		return min(ans[l][len], ans[r - bin[len] + 1][len]);
	}
};
minimum a, b;
inline void Push(int l, int r)
{
	if(r - l < 1) return;
	int x, y;
	if(l & 1)
	{
		x = a.Min(l, r);
		y = b.Min(pos[x] + 1, r);
	}
	else
	{
		x = b.Min(l, r);
		y = a.Min(pos[x] + 1, r);
	}
	q.push((seg) {l, r, x, y});
}
int main()
{
	n = Get();
	a.Init(), b.Init();
	for(int i = 1; i <= n; ++i)
	{
		int x = Get();
		if(i & 1) a.ans[i][0] = x;
		else b.ans[i][0] = x;
		pos[x] = i;
	}
	lg[1] = 0;
	for(int i = 2; i <= n; ++i) lg[i] = lg[i >> 1] + 1;
	bin[0] = 1;
	for(int i = 1; i < logn; ++i) bin[i] = bin[i - 1] << 1;
	a.Rmq(), b.Rmq();
	Push(1, n);
	seg w;
	while(!q.empty())
	{
		w = q.top(), q.pop();
		printf("%d %d ", w.x, w.y);
		Push(w.l, pos[w.x] - 1);
		Push(pos[w.x] + 1, pos[w.y] - 1);
		Push(pos[w.y] + 1, w.r);
	}
}

Measured memory_bytes: 48372