akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
    double w;
    while(cin >> w){
        if(w<=48.00){ cout << "light fly\n"; continue;}
        if(w<=51.00){ cout << "fly\n";continue;}
        if(w<=54.00){cout << "bantam\n";    continue;}
        if(w<=57.00){cout << "feather\n";continue;}
        if(w<=60.00){cout << "light\n";continue;}
        if(w<=64.00){cout << "light welter\n"; continue;}
        if(w<=69.00){cout << "welter\n";continue;}
        if(w<=75.00){cout << "light middle\n";continue;}
        if(w<=81.00){  cout << "middle\n"; continue; }
        if(w<=91.00){cout << "light heavy\n";  continue;}
        cout << "heavy\n";
    }
}

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

class DecimalNAN {};

struct Decimal{
 vector<UL> V = {0};
 void fix() {while(V.size()>1 && V.back()==0) V.pop_back();}
 void print() {
  rep(i,V.size()) cout<<V[V.size()-1-i];
 }
 Decimal(string s){
  reverse(s.begin(),s.end());
  V.clear();
  if(s.size()==0) throw DecimalNAN();
  rep(i,s.size()){
   if(s[i]<'0' || '9'<s[i]) throw DecimalNAN();
   V.push_back(s[i]-'0');
  }
  fix();
 }
 Decimal() :Decimal("0") {}
 operator bool() const{return V!=vector<UL>({0});}
 bool operator<(const Decimal& r) const {
  if(V.size()!=r.V.size()) return V.size()<r.V.size();
  for(UL i=V.size()-1; i!=~0u; i--)
   if(V[i]!=r.V[i]) return V[i]<r.V[i];
  return false;
 }
 bool operator>(const Decimal& r) const {return r<*this;}
 bool operator<=(const Decimal& r) const {return !(*this<r);}
 bool operator>=(const Decimal& r) const {return !(*this<r);}
 Decimal operator+(const Decimal& r) const{
  Decimal tmp=*this;
  tmp.V.resize(max(V.size(),r.V.size())+1);
  UL crr=0;
  rep(i,tmp.V.size()){
   if(i<V.size()) crr+=V[i];
   if(i<r.V.size()) crr+=r.V[i];
   tmp.V[i]=crr%10;
   crr/=10;
  }
  tmp.fix();
  return tmp;
 }
 Decimal operator-(const Decimal& r) const{
  Decimal tmp=*this;
  tmp.V.resize(max(V.size(),r.V.size())+2);
  UL crr=0;
  rep(i,tmp.V.size()){
   if(i<V.size()) crr+=V[i];
   if(i<r.V.size()) crr-=r.V[i];
   crr+=10;
   tmp.V[i]=crr%10;
   crr/=10; crr-=1;
  }
  if(tmp.V.back()!=0) throw DecimalNAN();
  tmp.fix();
  return tmp;
 }
 Decimal operator<<(const UL& r) const{
  Decimal tmp; tmp.V.clear();
  rep(i,r) tmp.V.push_back(0);
  for(UL v:V) tmp.V.push_back(v);
  tmp.fix();
  return tmp;
 }
 Decimal operator>>(const UL& r) const{
  Decimal tmp; tmp.V.clear();
  for(UL i=r; i<V.size(); i++) tmp.V.push_back(V[i]);
  if(tmp.V.empty()) tmp.V.push_back(0);
  tmp.fix();
  return tmp;
 }
 Decimal operator*(const Decimal& r) const{
  Decimal tmp;
  rep(i,r.V.size()){
   Decimal off=*this<<i;
   rep(j,r.V[i]) tmp=tmp+off;
  }
  return tmp;
 }
 Decimal operator/(const Decimal& r) const{
  if(V.size()<r.V.size()) return Decimal();
  UL shifts = V.size()-r.V.size();
  Decimal buf=*this;
  Decimal tmp; tmp.V.resize(shifts+1);
  for(UL i=shifts; i!=~0u; i--){
   Decimal off=r<<i;
   while(buf>=off){tmp.V[i]++; buf=buf-off;}
  }
  tmp.fix();
  return tmp;
 }
 Decimal operator%(const Decimal& r) const{
  if(V.size()<r.V.size()) return *this;
  UL shifts = V.size()-r.V.size();
  Decimal buf=*this;
  for(UL i=shifts; i!=~0u; i--){
   Decimal off=r<<i;
   while(buf>=off){buf=buf-off;}
  }
  buf.fix();
  return buf;
 }
};

int main() {
 string a,b; cin >> a >> b;
 Decimal A{a}, B{b};
 Decimal C=A%B;
 C.print(); cout << endl;
 return 0;
}



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

int main(){
  int N,a,b,c;
  bool ans=false;
  cin >>N;
  for(int i=0;i<N;i++){
    cin >>a>>b>>c;
    if((a>=(b+c))&&(a%2==(b+c)%2))
      ans=true;
    else{
      ans=false;
      cout <<"No"<<endl;
      return 0;
    }
  }
  cout <<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
N,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(N)]
INF=10**9
def chk(i,a,b,c):
    if i==N:
        if min(a,b,c)>0:
            return abs(A-a)+abs(B-b)+abs(C-c)-30
        else:
            return INF
    r0=chk(i+1,a,b,c)
    r1=chk(i+1,a+l[i],b,c)+10
    r2=chk(i+1,a,b+l[i],c)+10
    r3=chk(i+1,a,b,c+l[i])+10
    return min(r0,r1,r2,r3)
print(chk(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;

//=============Segment_Tree_with_Lazy_Propagation====
const int MAX_N = 1 << 17;//要変更
int n;
vector<ll> dat(2 * MAX_N - 1, 0);//要変更
vector<ll> lazy(2 * MAX_N - 1, 0);//要変更

void init(ll n_) {
  n = 1;
  while (n < n_) {
    n *= 2;
  }
}

void eval(ll k, ll l, ll r) {
  if (lazy.at(k) != 0) {
    dat.at(k) += lazy.at(k);//要変更
    if (r - l > 1) {
      lazy.at(k * 2 + 1) += lazy.at(k);//要変更
      lazy.at(k * 2 + 2) += lazy.at(k);//要変更
    }
    lazy.at(k) = 0;
  }
}

void update(ll a, ll b, ll plus, ll k = 0, ll l = 0, ll r = n) {
  if (r <= a || b <= l) {
    eval(k, l, r);//子供のlazyを更新する必要がある
    return;
  }
  if (a <= l && r <= b) {
    lazy.at(k) += plus;//要変更
    eval(k, l, r);//子供のlazyを更新する必要がある
  }
  else {
    eval(k, l, r);//updateで使う子供のlazeとdat.at(k)の更新
    update(a, b, plus, k * 2 + 1, l, (l + r) / 2);
    update(a, b, plus, k * 2 + 2, (l + r) / 2, r);
    dat.at(k) = dat.at(2 * k + 1) + dat.at(2 * k + 2);//要変更
  }
}

ll query(ll a, ll b, ll k = 0, ll l = 0, ll r = n) {
  if (r <= a || b <= l) {
    return 0;//要変更
  }
  eval(k, l, r);//dat.at(k)と子供のlazy更新のためreturn datとqueryに必要
  if (a <= l && r <= b) {
    return dat.at(k);
  }
  else {
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return vl + vr;//要変更
  }
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, Q;
  cin >> N >> Q;
  init(N);
  for (ll i = 0; i < Q; ++i) {
    ll q;
    cin >> q;
    if (q == 0) {
      ll s, t, x;
      cin >> s >> t >> x;
      update(s - 1, t, x);
    }
    else {
      ll index;
      cin >> index;
      cout << query(index - 1, index) << "\n";
    }
  }
}



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

int main(){
    int N; cin >> N;
    vector<int> a(N),b(N),c(N);
    rep(i,N){
        cin >> a[i] >> b[i] >> c[i];
    }

    int dp[N][3]; // N日目にiを選んだ時の最大幸福値
    dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
    for(int i=1; i<N; i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }

    int ans=0;
    ans = max({dp[N-1][0], dp[N-1][1], dp[N-1][2]});
    cout << ans << endl;
}


Measured memory_bytes: 5628
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

L, R, d = nn()

ans = 0
for i in range(L, R+1):
    if i % d == 0:
        ans += 1

print(ans)


Measured memory_bytes: 77172
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

ll N,Q;
ll table[SIZE];
vector<int> G[SIZE];


void dfs(int node_id,int pre){

	for(int i = 0; i < G[node_id].size(); i++){

		int child = G[node_id][i];
		if(child == pre)continue;

		table[child] += table[node_id];
		dfs(child,node_id);
	}
}


int main(){

	scanf("%lld %lld",&N,&Q);

	int from,to;

	for(int i = 0; i < N-1; i++){

		scanf("%d %d",&from,&to);
		from--;
		to--;

		G[from].push_back(to);
		G[to].push_back(from);
	}

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

		table[i] = 0;
	}

	ll p,x;

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

		scanf("%lld %lld",&p,&x);
		p--;

		table[p] += x;
	}

	dfs(0,-1);

	printf("%lld",table[0]);
	for(ll i = 1; i < N; i++){
		printf(" %lld",table[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 27392
#include<bits/stdc++.h>
using namespace std;
const int N=4e5+5,mod=998244353;
typedef long long ll;
int n;
ll f[N];
char s[N];
vector<int>v;
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++) s[i+n]='1';
    for(int i=1;i*i<=2*n;i++)
        if(2*n%i==0)
    {
        if(i&1)
            v.push_back(i);
        if(2*n/i!=i&&(2*n/i&1)) v.push_back(2*n/i);
    }
    for(int l=0;l<v.size();l++)
    {
        int k=2*n/v[l],t=k/2;
        string a="";
        for(int i=1;i<=t;i++) f[k]=((f[k]<<1)+s[i]-'0')%mod,a+=s[i];
        bool flag=true;
        for(int j=t;j+t<=2*n;j+=t)
        {
            for(int i=0;i<a.size();i++)
                if(a[i]=='1') a[i]='0';
            else a[i]='1';
            string b="";
            for(int h=1;h<=t;h++) b+=s[j+h];
            if(b<a){flag=false;break;}
            if(b>a) break;
        }
        f[k]+=flag;
    }
    ll ans=0;
    for(int i=2;i<=2*n;i++)
        if(f[i])
    {
        for(int j=2;j*j<=i;j++)
            if(i%j==0)
        {
            f[i]=(f[i]-f[j])%mod;
            if(i/j!=j) f[i]=(f[i]-f[i/j])%mod;
        }
        ans=(ans+f[i]*i)%mod;
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
struct p{
    string str;
    int num;
};
struct p pp,pp2;
int main(){
    int t,qq,time=0;
    queue<p>q;
    scanf("%d %d",&t,&qq);
    while(t--)
    {
        cin>>pp.str>>pp.num;
        q.push(pp);
    }
    while(q.size()!=0)
    {
        pp2 = q.front();
        if(pp2.num<=qq){
            time+=pp2.num;
            cout<<pp2.str<<" "<<time<<endl;
            q.pop();
        }
        else{
            pp2.num-=qq;
            q.push(pp2);
            q.pop();
            time+=qq;
        }
    }
    return 0;
}



Measured memory_bytes: 6280
n=int(input())
d=dict()
for i in input():
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
for _ in range(n-1):
  dd=dict()
  for i in input():
    if i not in dd:
      dd[i]=1
    else:
      dd[i]+=1
  for i in d.keys():
    if i in dd:
      d[i]=min(d[i],dd[i])
    else:
      d[i]=0
ans=[]
for i in d.keys():
  for _ in range(d[i]):
    ans.append(i)
ans.sort()
a=""
for i in ans:
  a+=i
print(a)


Measured memory_bytes: 3064
s=list(input())

right = [0]

left = [0]

count = 0
for i in range(len(s)):
    if s[i] == '<':
        count += 1
    else:
        count = 0
    right.append(count)
count = 0
for i in range(len(s)-1,-1,-1):
    if s[i] == '>':
        count += 1
    else:
        count = 0
    left.append(count)
left.reverse()

ans = 0

for i in range(len(s)+1):
    ans += max(right[i],left[i])
print(ans)

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n);

    for(int i=0;i<n+1;i++) cin >> a.at(i);
    for(int i=0;i<n;i++) cin >> b.at(i);

    long long sum = 0;
    for(int i=0;i<n;i++){
        if(a.at(i) > b.at(i)){
            sum += b.at(i);
            a.at(i) -= b.at(i);
            b.at(i) = 0;
        }else{
            sum += a.at(i);
            b.at(i) -= a.at(i);
            a.at(i) = 0;
            if(a.at(i+1) > b.at(i)){
                sum += b.at(i);
                a.at(i+1) -= b.at(i);
                b.at(i) = 0;
            }else{
                sum += a.at(i+1);
                b.at(i) -= a.at(i+1);
                a.at(i+1) = 0;
            }
        }

    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int M, N, K;
char S[550][550];
int dd[5] = { 0, 1, 0, -1, 0 };

bool isin(int y, int x) {
  return 0 <= y && y < M && 0 <= x && x < N;
}

int main(void) {
  cin >> M >> N;
  K = 0;
  REP(i, 0, M) REP(j, 0, N) cin >> S[i][j];

  int ans = 0;
  bool visited[256];
  REP(i, 0, 256) visited[i] = false;
  bool f = true;
  while(f) {
    f = false;
    REP(i, 0, M) REP(j, 0, N) {
      if(S[i][j] == '.' || visited[S[i][j]]) {
        int cnt[256];
        REP(k, 0, 256) cnt[k] = 0;
        REP(k, 0, 4) {
          int ny = i + dd[k], nx = j + dd[k + 1];
          while(isin(ny, nx)) {
            if(S[ny][nx] != '.' && !visited[S[ny][nx]]) {
              cnt[S[ny][nx]]++;
              if(cnt[S[ny][nx]] == 2) {
                visited[S[ny][nx]] = true;
                ans += 2;
                f = true;
              }
              break;
            }
            ny += dd[k];
            nx += dd[k + 1];
          }
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3388
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

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

struct point{
	int x,y;
};

int d[maxn][maxn];
char mp[maxn][maxn];
queue<point> q;

inline point make_point(int x,int y){
	point ret;
	ret.x = x;
	ret.y = y;
	return ret;
}

int main()
{
	int n, m;
	scanf("%d%d",&n,&m);
	for (int i = 1;i <= n;i++){
		scanf("%s",mp[i] + 1);
	}
	for (int i = 1;i <= n;i++){
		for (int j = 1;j <= m;j++){
			if (mp[i][j] == '#'){
				d[i][j] = 1;
				q.push(make_point(i, j));
			}
		}
	}
	while (!q.empty()){
		point u = q.front();
		q.pop();
		for (int k = 0;k < 4;k++){
			int nx = u.x + dx[k];
			int ny = u.y + dy[k];
			if (nx <= 0 || ny <= 0 || nx > n || ny > m) continue;
			if (d[nx][ny] == 0){
				d[nx][ny] = d[u.x][u.y] + 1;
				q.push(make_point(nx, ny));
			}
		}
	}

	int ans = 0;
	for (int i = 1;i <= n;i++){
		for (int j = 1;j <= m;j++){
			ans = max(ans, d[i][j]);
		}
	}
	printf("%d\n", ans - 1);
    return 0;
}



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

int main(void)
{
char num_str[1002];
int num;
long sum =0;
int i;
char tmp;

while(1)
{
fgets(num_str,sizeof(num_str),stdin);

if(num_str[0]=='0') break;

for(i=0;i<strlen(num_str)-1;i++)
{
tmp = num_str[i];
num = atoi(&tmp);
sum = sum + num;
}

printf("%ld\n",sum);

sum = 0;
memset(num_str,1002,0);
}
return 0;
}

Measured memory_bytes: 960
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*
5000^2
*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll N,K,ans=-1e10; cin>>N>>K;
  vector<ll> P(N+1,0), C(N+1,0);
  for(ll i=1; i<=N; i++) cin>>P[i];
  for(ll i=1; i<=N; i++) cin>>C[i];
  for(ll i=1; i<=N; i++){//start
//cout<<"ans:"<<ans<<" i:"<<i<<endl;
    ll k = K;
    ll tmp=0;
    vector<ll> seen(N+1,0);
    ll next = P[i];
    while(seen[next] < 3 && k>0){
      seen[next]++;
      tmp += C[next];
      ans = max(ans, tmp);
      next = P[next];
      k--;
//cout<<"tmp:"<<tmp<<" k:"<<k<<endl;  
    }
    if(k==0){
      ans=max(ans,tmp);
      continue;
    }
    ll count=0;
    ll score=0;
    for(ll j=1; j<=N; j++){
      if (seen[j] == 3){
        count++;
        score+=C[j];
      }
    }
    ll re=k/count;
    re-=1;
    if(re<0) re=0;
    k-=re*count;
    tmp+=score*re;
    ans=max(ans,tmp);
    while(k>0){
      tmp += C[next];
      ans=max(ans,tmp);
      next = P[next];
      k--;
    }
//cout<<"i:"<<i<<" tmp:"<<tmp<<endl;    
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define    ll long long
#define    pb          push_back
#define    m_p(a,b)    make_pair(a,b)
#define    inp(x)      scanf("%d",&x)
#define    lnp(x)      scanf("%lld",&x)
#define    ff          first
#define    ss          second
#define    srt(v)      sort(v.begin(),v.end())

#define    mxn         111111

ll n,m;
ll cost[mxn];
ll w[mxn];
ll dp[111][mxn];

ll solve(ll i,ll sum)
{
   if(i > n) return 0;
   if(dp[i][sum] != -1) return dp[i][sum];
   ll ret = 0;
   if(sum + w[i] <= m){
    ret = max(ret,cost[i] + solve(i+1,sum+w[i]));
   }

   ret = max(ret,solve(i+1,sum));
   dp[i][sum] = ret;

   return dp[i][sum];
}

int main()
{
    lnp(n);lnp(m);
    for(ll i = 1;i <= n;i++){
        lnp(w[i]);
        lnp(cost[i]);
    }
    memset(dp,-1,sizeof dp);
    ll ans = solve(1,0);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 96640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)
vector<int> v;
bool check(int maxm,int k) {
  for(int i:v) {
    if(i<=maxm)
      continue;
    int cut = i/maxm;
    if(i%maxm)
      cut++;
    cut--;
    k -= cut;
    if(k<0)
      return 0;    
  } 
  return 1;
}
int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n,k;
  cin>>n>>k;
  v.resize(n);
  for(int &i:v)
    cin>>i;
  int ans = -1;
  int l = 1,r = *max_element(v.begin(),v.end());
  while(l<=r) {
    int mid = (l+r)/2;
    if(check(mid,k)) {
      ans = mid;
      r = mid - 1;
    }else
    {
      l = mid + 1;
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 4732
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final String s = scanner.next();
        final int n = s.length();
        final boolean[] array = new boolean[n + 1];
        for (int i = 1; i <= n; i++) {
            array[i] = s.charAt(i - 1) == '1';
        }

        if (array[n] || !array[1] || !array[n - 1]) {
            System.out.println(-1);
            return;
        }

        for (int i = 1; i <= n / 2; i++) {
            if (array[i] != array[n - i]) {
                System.out.println(-1);
                return;
            }
        }

        if (IntStream.range(2, n - 1).mapToObj(i -> array[i]).noneMatch(Boolean::booleanValue)) {
            for (int i = 2; i <= n; i++) {
                System.out.println("1 " + i);
            }
            return;
        }

        int parent = 1;
        for (int i = 2; i <= n; i++) {
            System.out.println(parent + " " + i);
            if (array[i - 1]) {
                parent = i;
            }
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 51528
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    string a,b;
    cin>>a>>b;
    a = a+b;
    stringstream cont(a);
    //stringstream cont2(b);
    int n,m;
    cont>>n;
    //cont2>>m;
    double d=sqrt(n);
    m=d;
    if(m*m==n)
        cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main (){
	int n,m,c;
	cin>>n>>m>>c;
	int b[m],a[n][m];
	int i,j;
	for(i=0;i<m;i++){
		cin>>b[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	int sum[n];
	for(i=0;i<n;i++) sum[i]=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			sum[i] += b[j]*a[i][j];
		}
		sum[i] += c;
	}
	int count=0;
	for(i=0;i<n;i++){
		if(sum[i]>0) count++;
	}
	cout<<count;
	return 0;
} 

Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if (i+j)%2==0:
                print('#',end='')
            else:
                print('.',end='')
        print('')
    print('')


Measured memory_bytes: 7008
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Mon Dec 24 14:51:13 2018
//
package main

import "fmt"

const MOD = 1e9 + 7

func main() {
	var S string
	fmt.Scan(&S)

	dp := make([][]int, len(S)+1)
	for i := range dp {
		dp[i] = make([]int, 4)
	}

	dp[0][0] = 1
	for i, c := range S {
		if c == '?' {
			for j := range dp[i+1] {
				dp[i+1][j] += 3 * dp[i][j]
				dp[i+1][j] %= MOD
			}
		} else {
			for j := range dp[i+1] {
				dp[i+1][j] += dp[i][j]
				dp[i+1][j] %= MOD
			}
		}

		if c == 'A' || c == '?' {
			dp[i+1][1] += dp[i][0]
		}
		if c == 'B' || c == '?' {
			dp[i+1][2] += dp[i][1]
		}
		if c == 'C' || c == '?' {
			dp[i+1][3] += dp[i][2]
		}
		for j := range dp[i+1] {
			dp[i+1][j] %= MOD
		}
	}

	fmt.Println(dp[len(S)][3])
}


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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

int a[100500];
bool dp[100500];

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    int n, k;
    cin >> n >> k;
    forn(i, n) cin >> a[i];

    forn(i, k + 1)
        forn(j, n)
            if (i >= a[j])
                dp[i] |= !dp[i - a[j]];
    cout << (dp[k] ? "First" : "Second");
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> accum(N+1);
    rep(i,1,N+1){
        int num = i < 2 ? 0 : S.substr(i-2, 2) == "AC";
        accum[i] = accum[i-1] + num;
    }
    //rep(i,0,N)cout << accum[i] << " \n"[i==N-1];
    rep(i,0,Q){
        int l,r;
        cin >> l >> r;
        cout << accum[r] - accum[l] << endl;
    }
}

Measured memory_bytes: 1408
import Control.Monad
import qualified Data.ByteString.Char8 as BC
import Data.List
import Data.Maybe

solve :: Int -> [(Int,Int)] -> Bool
solve time [] = True
solve time (x:xs) = 
    if _time < a
    then
        False
    else 
        solve (_time - a) xs
    where 
        a = fst x
        b = snd x
        _time = min time b

main :: IO()
main = do

    n <- (fst.fromJust) <$> BC.readInt <$> BC.getLine

    arr <- map ((map (fst.fromJust.BC.readInt)).BC.words) <$> replicateM n BC.getLine

    let sortedArray = reverse $ sortOn snd $ map (\arr -> (head arr, (head.tail) arr) ) arr

    putStrLn $ if solve maxBound sortedArray then "Yes" else "No"


Measured memory_bytes: 126332
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	char ar[n+1];
	cin>>ar;

	ll ans=1;
	for(i=1;i<n;i++){
		if(ar[i]!=ar[i-1]){
			ans+=1;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<stack>
#include<iomanip>
#include<functional>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll> x(n);
    rep(i,n)
    {
        cin>>x[i];
    }
    ll cost=0;
    for(ll i=1;i<n;i++)
    {
        cost+=min((x[i]-x[i-1])*a,b);
    }
    cout<<cost;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace std;

#define int long long
#define deb(x) cerr << #x << " " << x << endl;
#define debb(x, y) cerr << #x << " = " << x << "," << #y << " = " << y << endl <<endl;
#define pb push_back
#define pp pop_back
#define mkp make_pair 
#define f first
#define s second
#define all(x) x.begin(),x.end()

#define MOD 1000000007
#define MAX 50000

typedef long double ld;
const int N = 1e5 + 10;
const long double Pie = acos(-1);

signed main() 
{		
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		
	int n, k;
	cin >> n >> k;
	
	int arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	
	sort (arr, arr + n);
	
	cout << accumulate (arr, arr + k, 0ll); 
		
	return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

const ll com_max = 510000;

ll fac[com_max], inv[com_max], finv[com_max];

void com_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for (ll i = 2; i < com_max; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll com(ll n, ll k) {
    if (n < k) {
        return 0;
    }
    if (n < 0 || k < 0) {
        return 0;
    }

    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
    ll n;
    cin >> n;
    ll a[n + 1];
    rep(i, n + 1) { cin >> a[i]; }
    vector<ll> v(n, -1);
    ll left, right;
    rep(i, n + 1) {
        ll num = a[i] - 1;
        if (v[num] == -1) {
            v[num] = i;
        } else {
            left = v[num];
            right = n - i;
        }
    }
    com_init();
    repd(i, 1, n + 2) {
        ll ans = com(n + 1, i) - com(left + right, i - 1) + mod;
        ans %= mod;
        cout << ans << endl;
    }
    return 0;
}



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

void solve() {
    int N;
    cin >> N;
    map<int, bool> is_visited;
    int ans = 0;
    while (true) {
        if (is_visited[N]) {
            cout << -1 << endl;
            return;
        }
        is_visited[N] = true;
        if (N < 10) break;
        int max_n = -1;
        int div = 10;
        for (int i = 0; i < 6; i++) {
            int d1 = N / div;
            int d2 = N % div;
            max_n = max(max_n, d1 * d2);
            div *= 10;
        }
        N = max_n;
        ans++;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <cstring>
#include <algorithm>


int main()
{
	std::string str,f,s2;
	int q;
	std::string p;
	int a,b;
	std::cin >> str;
	std::cin >> q;
	
	for(int i=0; i<q; i++){
		std::cin >> f ;
		switch(f[2]){
			case 'i':
				std::cin >> a >> b;
				std::cout << str.substr(a, b-a+1) << std::endl;
				break;				
			case 'v':
				std::cin >> a >> b;
				s2 = str.substr(a,b-a+1);
				std::reverse(s2.begin(),s2.end());
				str = str.substr(0, a) + s2 + str.substr(b+1, str.size()-b-1);
				break;
			case 'p':
				std::cin >> a >> b >> p;
				str.replace(a, b-a+1, p);
				break;
		}
	}

	
	return 0;
}

		


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define f(i,a,b) for(int i=(a); i<(b);++i)
int main()
{
    int a[10000],n,m,sum=0;
    cin>>n>>m;
    f(i,0,m){
         cin>>a[i];
         sum+=a[i];
    }
    if(sum>n) cout<<"-1"<<endl;
    else cout<<n-sum<<endl;
        return 0;
    }


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>

using namespace std;
using ll = long long;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<n*n<<endl;
	return 0;
}



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

int main() {
  int a[3];
  for ( int i=0; i<3; i++ ) cin >> a[i];
  for ( int i=0; i<3; i++ ) {
    for ( int j=0; j<3; j++ ) {
      for ( int k=0; k<3; k++ ) {
        if ( i!=j&&j!=k&&k!=i ) {
          if ( a[j]-a[i]==a[k]-a[j] ) {
            cout << "YES";
            return 0;
          }
        }
      }
    }
  }
  cout << "NO";
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int hours, minutes, freetime;

    hours = H1 < H2 || (H1 == H2 && M1 < M2) ? H2 - H1 : H2 + 24 - H1;
    minutes = M2 - M1;

    freetime = 60 * hours + minutes;

    int starttime = freetime > K ? freetime - K : 0;

    cout << starttime << endl;

    return 0;
}

Measured memory_bytes: 3644
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    D, X = [int(x)for x in stdin.readline().rstrip().split()]
    Ai = [int(stdin.readline().rstrip()) for _ in range(N)]
    spam = [[k for k in [Ai[i] * j + 1 for j in range(D)] if k <= D] for i in range(N)]
    ham = sum([len(x) for x in spam])
    print(ham + X)


if __name__ == '__main__':
    main()


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

using namespace std;

int n, k;
vector<int> pos, neg;

int main() {
	scanf("%d%d", &n, &k);
	while(n--) {
		int t;
		scanf("%d", &t);
		if(t >= 0) pos.push_back(t);
		else neg.push_back(t);
	}
	sort(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());
	reverse(neg.begin(), neg.end());
	int ret = 1 << 30;
	if(pos.size() >= k) ret = min(ret, pos[k-1]);
	if(neg.size() >= k) ret = min(ret, -neg[k-1]);
	for(int i = 1; i < k; i++) {
		int j = k-i;
		if(i-1 >= pos.size() || j-1 >= neg.size()) continue;
		ret = min(ret, pos[i-1] + pos[i-1] - neg[j-1]);
		ret = min(ret, pos[i-1] - neg[j-1] - neg[j-1]);
	}
	printf("%d\n", ret);
}

Measured memory_bytes: 1020
#include<stdio.h>
int main(void)
{
    int N,i;
    int flag=0;
    int count=0;
    int A[200]={};
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    while(1)
    {
        for(i=0;i<N;i++){
        if(A[i]%2==0){
            A[i]/=2;
        }else{
            flag = 1;
        }
        }if(flag == 1){
            break;
        }
        count++;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, a;
map<int, int>mp;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		mp[a]++;
	}
	if (n % 2) {
		for (int i = 0; i < n; i+=2) {
			if (!i&&mp[i] != 1) {
				cout << 0 << endl;
				endre;
			}
			else if (i&&mp[i] != 2) {
				cout << 0 << endl;
				endre;
			}
		}
	}
	else {
		for (int i = 1; i < n; i+=2) {
			if (mp[i] != 2) {
				cout << 0 << endl;
				endre;
			}
		}
	}
	cout << mod_pow(2, n / 2, INF) << endl;
	endre;
}


Measured memory_bytes: 4224
#include <stdio.h>
#include <ctype.h>

int getValue(char TopCh);

int main(void)
{
	int  Stack[200];  /* operand(100) + operator(99) */
	int  StackPoint;
	int  Value;
	char ch;
	
	StackPoint = 0;
	while(scanf("%c", &ch) != EOF)
	{
		if(ch == '-') /* minus */
		{
			scanf("%c", &ch);
			if(isspace(ch) != 0) /* operator */
			{
				Value = Stack[StackPoint-2] - Stack[StackPoint-1]; /* Caluculation */
				Stack[StackPoint-2] = Value;
				StackPoint--;
			}
			else /* minus sign */ 
			{
				Value = getValue(ch);
				Stack[StackPoint] = -1 * Value;
				StackPoint++;
			}
		}
		else if(ch == '+') /* plus */
		{
			Value = Stack[StackPoint-2] + Stack[StackPoint-1]; /* Caluculation */
			Stack[StackPoint-2] = Value;
			StackPoint--;
		}
		else if(ch == '*') /* multiply */
		{
			Value = Stack[StackPoint-2] * Stack[StackPoint-1]; /* Caluculation */
			Stack[StackPoint-2] = Value;
			StackPoint--;
		}
		else if(isdigit((unsigned char)ch) != 0)	/* judge operand */
		{
			Value = getValue(ch);
			Stack[StackPoint] = Value;
			StackPoint++;
		}
		else	/* Space or Bad Charactor*/
		{
		}
		
	}
	
	printf("%d\n", Stack[0]);
	
	return 0;
}

/* suuti hennkan */
int getValue(char TopCh)
{
	char ToAtoi[7];
	int  ValueDigits;
	char ch;
	
	ToAtoi[0] = TopCh;
	ValueDigits=1;
	scanf("%c", &ch);
	while(isdigit(ch) != 0)
	{
		ToAtoi[ValueDigits] = ch;
		ValueDigits++;
		scanf("%c", &ch);
	}
	ToAtoi[ValueDigits] = '\0';
	
	return atoi(ToAtoi);
}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

string s;

bool check(int i,int j){
    bool flag=true;
    for(int k=0;k+i<=j-k;k++)
    {
        if(s[k+i]!=s[j-k]){
            return false;
        }
    }
    return true;
}

int main()
{
    IOS
    cin>>s;
    int n=s.length();
    if(check(0,n-1)&&check(0,(n-3)/2)&&check((n+1)/2,n-1))
        cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

ll n, m;

int main()
{
    cin >> n >> m;
    vector<ll> div(0);
    for(ll i = 1; i * i <= m; i++)
    {
        if(m % i == 0){
            div.push_back(m / i);
            div.push_back(i);
        }
    }
    sort(div.begin(), div.end(), greater<int>());
    for(ll x : div)
    {
        if(n * x <= m)
        {
            cout << x << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
  XY[i] = [XY[i][0] - XY[i][1], XY[i][0] + XY[i][1]]
X = [XY[i][0] for i in range(N)]
Y = [XY[i][1] for i in range(N)]
X.sort()
Y.sort()
print(max(X[-1] - X[0], Y[-1] - Y[0]))

Measured memory_bytes: 49196
# -*- coding: utf-8 -*-
import bisect

n = int(input())
a = [int(input()) for _ in range(n)]

group_min = [a.pop()]
a.reverse()

for e in a:
    idx = bisect.bisect(group_min, e)
    if len(group_min) == idx:
        group_min.append(e)
    elif group_min[idx] > e:
        group_min[idx] = e
    else:
        # group_min[idx] == e:
        group_min.insert(idx, e)

print(len(group_min))


Measured memory_bytes: 7832
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int i;
    string s,t;
    cin >> s >> t;
    s+=s;
    for(i=0; i<s.length(); i++){
        if(equal(t.begin(), t.end(), s.begin()+i)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int main(){
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    int N; cin >> N; long long D; cin >> D;
    int ret = 0;
    for(int i = 0; i < N; i++){
        long long x, y; cin >> x >> y;
        if(x*x+y*y <= D*D) ret++;
    }
    cout << ret << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> vpll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define yes(a) printf(a ? "yes\n" : "no\n")
#define Yes(a) printf(a ? "Yes\n" : "No\n")
#define YES(a) printf(a ? "YES\n" : "NO\n") 
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

ll h, w;
string s[51];
ll dist[51][51];

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

  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  ll m = max(k, 1LL);
  for(ll i = k+1; i <= n; i++){
    ans += n/i * (i-k);
    if(n%i >= k) ans += (n%i)-k+1;
  }
  if(k == 0) ans -= n;
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int real(int a,int b)
{
	return (a>b)?a-b:b-a;
}
int main()
{
	int N,t,m,n;
	int flag = 0;
	int x1=0,y1=0;
	int sum;
	cin>>N;
	int t1=0;
	for(int i =0;i<N;i++)
	{
		cin>>t>>m>>n;
	   
		sum = real(m,x1)+real(n,y1);
		if(sum%2==0&&(t-t1)%2!=0)
		 flag=1;
		
	    if((t-t1)>=sum)
		{
			x1 = m;
			y1 = n;
			t1 = t;
			continue;
		}
	   else 
	   {
	   	 flag=1;
	   }
	  
		  
		 
	}
	if(flag)
	{
		cout<<"No"<<endl;
	}
	else if(!flag)
	 
	 {
	 	cout<<"Yes"<<endl;
	 }
	 return 0;
}

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

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

  for (int i = 0; i < B + 1;i++) {
    cout << "#";
  }
  cout << "#" << endl;//１行目の＃を入力
  
  for (int i = 0;i < A;i++) {
    vector<char> a(B);
    cout << "#";
    for (int j=0;j<B;j++) {
      cin >> a.at(j);
      cout << a.at(j);
    }
    cout << "#" << endl;
  }
  
  for (int i = 0; i < B + 2;i++) {
    cout << "#";
  }
  
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    //pattern1
    ll tmp1=0, sum1=0;
    for(int i=0; i<n/2; i++){
        sum1+=a[i*2];
        if(sum1<=0){
            tmp1=tmp1-sum1+1;
            sum1=1;
        }
        sum1+=a[i*2+1];
        if(sum1>=0){
            tmp1=tmp1+sum1+1;
            sum1=-1;
        }
    }
    if(n%2==1){
        sum1+=a[n-1];
        if(sum1<=0){
            tmp1=tmp1-sum1+1;
        }
    }
    //pattern2
    ll tmp2=0, sum2=0;
    for(int i=0; i<n/2; i++){
        sum2+=a[i*2];
        if(sum2>=0){
            tmp2=tmp2+sum2+1;
            sum2=-1;
        }
        sum2+=a[i*2+1];
        if(sum2<=0){
            tmp2=tmp2-sum2+1;
            sum2=1;
        }
    }
    if(n%2==1){
        sum2+=a[n-1];
        if(sum2>=0){
            tmp2=tmp2+sum2+1;
        }
    }
    cout << min(tmp1, tmp2) << endl;
    
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
	static Scanner s = new Scanner(System.in);			//文字の入力

	static String A = s.next();
	static String B = s.next();
	static int a =  Integer.parseInt(A);
	static int b =  Integer.parseInt(B);
static boolean flag = false;

	static int sum =0;

	public static void main(String[] args){
		solve();
	}

	static void solve() {
		int aketa = A.length();
		int bketa = B.length();
		int adata[] =new int[aketa];
		int bdata[] = new int [bketa];
		
		for(int i= 0;i<aketa;i++){
			adata[i] = 0;
		}
		for(int j = 0;j <bketa;j++){
			bdata[j] = 0;
		}		//初期化

		for(int j= 0; j < bketa;j++){
			int kagi=1;
			for(int i = 1;i < bketa-j;i++){
				kagi*=10;
			}
			bdata[j]=b/kagi;
			b -= bdata[j]*kagi;
		}

		for(int j= 0; j < aketa;j++){
			int kagi=1;
			for(int i = 1;i < aketa-j;i++){
				kagi*=10;
			}
			adata[j]=a/kagi;
			a -= adata[j]*kagi;

		}
		
		for(int i = 0;i<aketa;i++){
			int kagi = 1;
			for(int j = 0;j < aketa+bketa-1-i;j++){
			kagi *= 10;
			}
			sum += adata[i]*kagi;
		}
		for(int j= 0; j < bketa;j++){
			int kagi=1;
			for(int i = 1;i < bketa-j;i++){
				kagi*=10;
			}
			sum += bdata[j]*kagi;
			
		}
		
		for(int i =1;(i*i)<=sum;i++){

			if(sum==(i*i)){
				flag = true;
				System.out.println("Yes");
				break;
			}
			
		}
		if (flag != true){
			System.out.println("No");
			
		}

	}





}

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

int main()
{
   int n;
   unsigned long long int ans=0;
   cin>>n;
   int arr[n];
   for(int i=0;i<n;i++)
   cin>>arr[i];
   for(int i=1;i<n;i++)
   {
       if(arr[i]<arr[i-1])
       {
           ans=ans+arr[i-1] - arr[i];
           arr[i]=arr[i-1];
       }
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 4396