akhauriyash/Code-Regression huggingface dataset:
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
long long x[400][400],y[400][400];
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n;
    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            cin>>x[i][j];
            y[i][j]=x[i][j];
        }
    }
    g=1;
    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            if(i==j)
                continue;
            for(p=0; p<n; p++)
            {
                if(i==p||j==p)
                    continue;
                if(x[i][p]+x[p][j]<x[i][j])
                {
                    g=0;
                }
                else if(x[i][p]+x[p][j]==x[i][j])
                {
                    y[i][j]=0;
                }
            }
        }
    }
    if(!g)
    {
        cout<<-1<<'\n';
        return 0;
    }
    f=0;
    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            f+=y[i][j];
        }
    }
    f/=2;
    cout<<f<<'\n';
    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define sll set<ll>
#define fo(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    //freopen("000.txt","r",stdin);
    ll n,i,j,k,t,a[26]={0},ma=100000;

    string s,s2,s3;

    cin>>s;

    //cout<<(char)(j+'a')<<endl;

    fo(j,26)
    {
        ll c=0,mi=0;
        fo(i,s.length())
        {
            if(s[i]-'a'==j)
                c=0;
            else
                c++;
            mi=max(mi,c);
        }
        ma=min(ma,mi);
    }

    cout<<ma;
    return 0;
}


Measured memory_bytes: 256
N, T = map(int, input().split())
ct = [[int(i) for i in input().split()] for _ in range(N)]

ret = float('inf')
for c, t in ct :
    if t <= T :
        ret = min(ret, c)

if ret == float('inf') :
    print('TLE')
else :
    print(ret)

Measured memory_bytes: 38256
#include<stdio.h>

int main(){
  int N,K;
  scanf("%d%d",&N,&K);
  double p[N];
  double sum_E=0,ans=0;
  for (int i = 0; i < N; i++)
  {
    scanf("%lf",&p[i]);
    p[i]=((p[i]*(p[i]+1))/2)/p[i];
  }

  
  for (int i = 0; i < K; i++)
  {
    sum_E+=p[i];
  }

  if (N==K)
  {
    printf("%.12f",sum_E);
  }else{
    for (int i = 0; i <= N-K; i++)
    {
      sum_E+=(p[K+i]-p[i]);
      if (ans<sum_E)
      {
        ans=sum_E;
      }
    }
    printf("%.12f",ans);
  }

  return 0;
}

Measured memory_bytes: 3260
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
X = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
dp1 = [set() for _ in range(W)]
dp1[0].add(X[0][0])
dp2 = [set() for _ in range(W)]
dplimit = [[0] * W for _ in range(H)]
dplimit[-1][-1] = 80
for i in range(H - 1, -1, -1):
  for j in range(W - 1, -1, -1):
    x = X[i][j]
    if i > 0: dplimit[i - 1][j] = max(dplimit[i - 1][j], dplimit[i][j] + x)
    if j > 0: dplimit[i][j - 1] = max(dplimit[i][j - 1], dplimit[i][j] + x)
for i in range(H):
  if i % 2 == 0:
    dp2 = [set() for _ in range(W)]
  else: dp1 = [set() for _ in range(W)]
  for j in range(W):
    if i % 2 == 0:
      for k in dp1[j]:
        if i + 1 < H:
          u = k + X[i + 1][j]
          v = abs(k - X[i + 1][j])
          if u <= dplimit[i][j]: dp2[j].add(u)
          if v <= dplimit[i][j]: dp2[j].add(v)
        if j + 1 < W:
          u = k + X[i][j + 1]
          v = abs(k - X[i][j + 1])
          if u <= dplimit[i][j]: dp1[j + 1].add(u)
          if v <= dplimit[i][j]: dp1[j + 1].add(v)
    else:
      for k in dp2[j]:
        if i + 1 < H:
          u = k + X[i + 1][j]
          v = abs(k - X[i + 1][j])
          if u <= dplimit[i][j]: dp1[j].add(u)
          if v <= dplimit[i][j]: dp1[j].add(v)
        if j + 1 < W:
          u = k + X[i][j + 1]
          v = abs(k - X[i][j + 1])
          if u <= dplimit[i][j]: dp2[j + 1].add(u)
          if v <= dplimit[i][j]: dp2[j + 1].add(v)
res = float("inf")
if H % 2:
  for k in dp1[-1]: res = min(k, res)
else:
  for k in dp2[-1]: res = min(k, res)
print(res)

Measured memory_bytes: 158724
void main() {
    dchar[] s = readln.chomp.to!(dchar[]);
    s.sort!"a < b";
    writeln(s == "abc" ? "Yes" : "No");
}

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

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){

	int n, d0=0, d2=0, d4=0, tmp;
	cin>> n;
  
  	rep(i, n){
      cin>> tmp;
      if(tmp%4==0) d4++;
      else if(tmp%2==0) d2++;
      else d0++;
    }
  
	if(d0<=d4 || (d0==d4+1 && d2==0)) cout<< "Yes" << endl;
	else cout<< "No" << endl;
 
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 +7;

int main() {
    

    ll n, m;
    
    cin >> n >> m;
    priority_queue<ll> q;
    
    for (int i = 0; i < n; ++i)
    {
        ll tmp;
        cin >> tmp;
        q.push(tmp);
    }
    
    for (int i = 0; i < m; ++i)
    {
        ll tmp = q.top();
        q.pop();
        tmp /= 2;
        q.push(tmp);
    }
    ll ret = 0;
    while (q.size() > 0)
    {
        ret += q.top();
        q.pop();
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 1400
import math
from collections import Counter

N = int(input())
A_B = []
mod = 1000000007
for _ in range(N):
    A, B = map(int, input().split())
    if (A == 0) and (B == 0):
        A_B.append((A, B))
    elif A == 0:
        A_B.append((0, -1))
    elif B == 0:
        A_B.append((1, 0))
    else:
        if A < 0:
            A = -A
            B = -B
        C = math.gcd(abs(A), abs(B))
        A_B.append((A // C, B // C))

A_B_C = Counter(A_B)


ans = 1
Done = set([])
Done.add((0, 0))
for key, value in A_B_C.items():
    if key in Done:
        continue
    keya, keyb = key
    a = 0
    if keya == 0 and keyb == 0:
        a = value + 1
        Done.add((0, 0))
    else:
        if keyb < 0:
            keya = -keya
            keyb = -keyb
        if (keyb, -keya) not in A_B_C:
            a = pow(2, value, mod)
        else:
            a = (pow(2, value, mod) - 1) + (pow(2, A_B_C[(keyb, -keya)], mod) - 1) + 1
            Done.add((keyb, -keya))
    ans *= a
    ans %= mod
    Done.add(key)
ans -= 1
ans += A_B_C[(0, 0)]

print(ans % mod)


Measured memory_bytes: 61140
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
mod = 10**9+7

# dp[i][j] : Sの左からi文字目までと Tの左からj文字目まででの 共通部分文字列の数
dp = [[0 for _ in range(M+1)] for _ in range(N+1)]
dp[0][0] = 1

for i in range(N+1):
    for j in range(M+1):
        if 0<=i-1 and 0<=j-1 and S[i-1]==T[j-1]:
            dp[i][j] += dp[i-1][j-1]
        if 0<=i-1:
            dp[i][j] += dp[i-1][j]
        if 0<=j-1:
            dp[i][j] += dp[i][j-1]
        # 重複カウント部分を減算する
        if 0<=i-1 and 0<=j-1:
            dp[i][j] -= dp[i-1][j-1]
        dp[i][j] %= mod

print(dp[N][M])


Measured memory_bytes: 76764
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    def isOK(x):
        count = sum((a-1)//x for a in A)
        if count <= K:
            return True
        else:
            return False

    def binary_search(init_l, init_r):
        """(l, r]"""
        left = init_l
        right = init_r

        while right-left > 1:
            mid = (right+left)//2
            if isOK(mid):
                right = mid
            else:
                left = mid

        return right
    
    sum_A = sum(A)
    max_ans = (sum_A + K)//(K+1)
    min_ans = (sum_A + K+N-1)//(K+N)
    ans = binary_search(min_ans-1, max_ans)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 31428
N, M = map(int, input().split())
AB = [0] * N
for i in range(N):
    AB[i] = list(map(int, input().split()))
AB.sort(key=lambda AB: AB[0])

cnt = 0
ans = 0
for i in range(N):
    cnt += AB[i][1]
    ans += AB[i][0] * AB[i][1]
    if cnt > M:
        ans -= (cnt - M) * AB[i][0]
        break
print(ans)

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

signed main(void)
{
	int x;
	cin >> x;
	if (x >= 30)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3632
from collections import deque

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

ALL = p + q + r
ALL.sort(reverse=True)
ALL = deque(ALL)

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p = deque(p)
q = deque(q)
r = deque(r)

ans = 0
p_cnt = 0
q_cnt = 0
r_cnt = 0
loopcnt = 0
while loopcnt < X+Y:
    apple = ALL.popleft()
    if p_cnt < X and apple == p[0]:
        ans += p.popleft()
        p_cnt += 1
        loopcnt += 1
    elif q_cnt < Y and apple == q[0]:
        ans += q.popleft()
        q_cnt += 1
        loopcnt += 1
    elif r_cnt < C and apple == r[0]:
        ans += r.popleft()
        r_cnt += 1
        loopcnt += 1
print(ans)

Measured memory_bytes: 29628
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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;}

int main() {
    ll A, B;
    cin >> A >> B;
    ll g = gcd(A,B);

    ll ans = 1;
    for(ll i=2;i*i<=g;++i){
        if(g%i==0){
            ++ans;
            while(g%i==0) g/=i;
        }
    }
    if(g>1) ++ans;
    cout << ans << '\n';
}


Measured memory_bytes: 3604
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto s = sread();
    auto t = sread();
    if (s == t)
    {
        writeln(s.length);
        return;
    }
    long ans = -1;

    foreach (i; 0 .. n)
    {
        if (func(s, t, i))
        {
            ans = max(ans, i);
        }
    }
    // writeln(ans);
    writeln((s.length + t.length) - ans);
}

bool func(string s, string t, long x)
{
    if (s[($ - x) .. $] == t[0 .. x])
    {
        return true;
    }
    return false;

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

int main(){
  string w;
  cin >> w;
  vector<int> cnt(26);
  for(int i=0; i<w.size(); i++){
    cnt.at(w.at(i)-97)++;
  }
  string ans="Yes";
  for(int i=0; i<26; i++){
    if(cnt.at(i)%2!=0) ans="No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int r,g,b,ans;
    scanf("%d" "%d" "%d", &r, &g, &b);
    ans = 100*r + 10*g + b;
  	if((ans % 4) == 0){
    	printf("YES");    
    }
	else{    
    	printf("NO");    
    }      
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n; cin >> n;
	int min_val = inf, ans = 0;
	forn(i,0,n){
		int x; cin >> x;
		if(x <= min_val){
			++ans;
			min_val = x;
		}
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3656
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n, ind,ma, a[200007];

int main () {
    fastIO;
    cin >> n;
    ma=-1;
    for(li i = 0; i < n; i ++) {
        cin >> a[i];
        if(ma<a[i]) ma=a[i], ind=i;
    }
    sort(a, a+n);
    for(li i = 0; i < n; i ++) {
        if(ind==i) cout << a[n-2] << "\n";
        else cout << ma << "\n";
    }
}


Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int N,a,ans=0,j=0;
string s,sa;
char ka[]={'(',')'};
stack<int> mae;
int main(){
  cin>>N;
  cin>>s;
  sa=s;
  int i=0;
  while(i<N){
    if(s[i]==ka[0]){
      mae.push(i);
    }else{
      if(!mae.empty())mae.pop();
      else {sa=ka[0]+sa.substr(0);}
    }
    i++;
  }
  while(!mae.empty()){
    mae.pop();sa=sa.substr(0)+ka[1];
  }
  cout<<sa<<endl;
  return 0;
}


Measured memory_bytes: 256
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  const int md=1e8;
  const int MAX=3e5+5;
  //
  //
  int main(){
  	ll n,W;
  	cin>>n>>W;
  	ll arr[W+2];
  	rep(i,0,W+2)
  		arr[i]=0;
  	ll wt,val;
  	rep(i,0,n){
  		cin>>wt>>val;
  		for(int j=W;j>=wt;j--){
  			arr[j]=max(arr[j-wt]+val,arr[j]);
  		}
  	}
  	ll ans=0;
  	rep(i,0,W+1)
  		ans=max(ans,(ll)arr[i]);
  	cout<<ans;
  	return 0;
  }

Measured memory_bytes: 1024
#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;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, k, s;
    cin >> n >> k >> s;

    if (s == 1000000000LL) {
        rep(i, k) { cout << s << " "; }
        rep(i, n - k) { cout << 1 << " "; }
    } else {
        rep(i, k) { cout << s << " "; }
        rep(i, n - k) { cout << s + 1 << " "; }
    }
    cout << endl;
    return 0;
}



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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); ++i)
    {
        if ((i + 1) % 2 == 0)
        {
            if (S[i] == 'R')
            {
                cout << "No" << endl;
                return 0;
            }
        }
        else
        {
            if (S[i] == 'L')
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n),b(n);
    cin >> a >> b;
    int ans = 0;
    ll now = 1;
    rep(_,30) {
        vi na = a,nb = b;
        rep(j,n) {
            na[j] %= now*2;
            nb[j] %= now*2;
        }
        sort(all(nb));
        ll cnt = 0;
        rep(j,n) {
            cnt += nb.end()-lower_bound(all(nb),now-na[j]);
            cnt -= nb.end()-lower_bound(all(nb),now*2-na[j]);
            cnt += nb.end()-lower_bound(all(nb),now*3-na[j]);
            cnt -= nb.end()-lower_bound(all(nb),now*4-na[j]);
        }
        if(cnt&1) ans += now;
        now <<= 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int N,M;
    cin >> N >> M;

    vector<pair<int,int> > p(N);

    int a,b;

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

        cin >> a >> b;

        p[i] = mp(a,b);

    }

    sort(p.begin(),p.end());

    priority_queue<int> que;

    int j = 0;
    ll ans = 0;

    for(int i=1;i<=M;i++){

        while(p[j].first <= i){

            que.push(p[j].second);

            j++;

        }

        if(!que.empty()){

            ans += que.top();

            que.pop();

        }

    }

    cout << ans << endl;

    return 0;
}

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

int main() {
   long long n ;
   cin>>n;
   long long x;
   string S[] ={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
   vector<string>v;
   while(n != 0){
        x = (n % 26) -1;
        if(x == -1){
            x = 25;
            n--;
        }
       v.push_back( S[x]);
       n /= 26;
   }
 for(reverse_iterator<vector<basic_string<char>>::iterator> it = v.rbegin(); it != v.rend(); it++){
     cout<<*it;
 }
 cout<<endl;

return 0;

}

Measured memory_bytes: 3624
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int x;
    cin>>x;
    if(x<1200)
    {cout<<"ABC";
    return 0;
    }
    if(x>=1200 && x<2800)
     {cout<<"ARC";
    return 0;
    }
    cout<<"AGC";
    return 0;

}


Measured memory_bytes: 256
const main = () => {
  const ab = getParams()
      , a = ab[0]
      , b = ab[1]
      , s = a + b
      , n = Number(s)
  console.log(solve(n));
};

const getParams = () =>
  getStdin().split(' ');

const getStdin = () =>
  require('fs').readFileSync('/dev/stdin', 'utf8');

const solve = n => {
  const sqrtn = Math.sqrt(n);
  return sqrtn === Math.floor(sqrtn) ? 'Yes' : 'No';
}

main();


Measured memory_bytes: 7372
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
  int N;
  int K;
  string S;
  cin >> N;
  cin >> K;
  cin >> S;
  int kouhuku = 0;
  for(int i=0; i<N-1; i++){
    if(S[i] == S[i+1]) kouhuku++;
  }
  kouhuku += 2*K;
  if(kouhuku>=N) kouhuku=N-1;

  cout << kouhuku << endl;
  return 0;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define SUM(a) accumulate(all(a),int(0))
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n, k; cin >> n >> k;
  vi a(n); rep(i,n) cin >> a[i]; sort(rall(a));
  int ans = 0;
  FOR(i, k, n) ans += a[i];
  cout << ans << endl;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            //  int B = int.Parse(input[1]);

            long Power = 1;
            for (int i = 1; i <= N; i++)
            {
                Power = (Power * i)%1000000007;
            }


            Console.WriteLine(Power);



        }
    }
}


Measured memory_bytes: 11092
n=int(input())
ans=0
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
for i in range(n):
    ans+=b[i]
for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans+=c[a[i]-1]
print(ans)

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

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

    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            int cnt = 0;
            for (int j = i; j < S.size(); j++) {
                if (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T') cnt++;
                else break;
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
class UnionFind():
    '''
    グループ分けを木構造で管理するデータ構造
    以下の二点を高速で行うことができるのがメリット．
    ・要素xと要素yが同じグループに属するかどうかを判定したい
        → 要素xの根と要素yの根が同じならば同じグループ，
          要素xの根と要素yの根が同じでないならば異なるグループ
          にあることが分かる．
    ・要素xと要素yが別のグループに属する場合，
        要素xの属するグループと要素yの属するグループを併合する．
    '''

    def __init__(self, n):
        self.n = n
        # parents[x] = y: xの親がy
        # aが親なら -size(初期値-1)
        self.parents = [-1] * n

    # グループの根を探索
    def find(self, x):
        if self.parents[x] < 0:  # xが木の根の場合
            return x
        # 親へ再帰
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    # グループの併合
    def unite(self, x, y):
        # x, yの根を探索
        x = self.find(x)
        y = self.find(y)
        if x == y:  # 同じ木に属する場合
            return
        # 計算速度のため、小さい方の根を大きい方の根につける
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]  # サイズを加算
        self.parents[y] = x  # 親の張り替え

    # 同じグループに属するか判定
    def same(self, x, y):
        # 根を比較し同じならtrue
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]  # 負で保存してあるため

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]



def resolve():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(int, input().split())
        uf.unite(a - 1, b - 1)

    ans = 0
    for i in range(n):
        s = uf.size(i)
        if ans < s:
            ans = s

    print(ans)

resolve()

Measured memory_bytes: 14736
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
const int MAX=1e5+5;

int par[MAX];
int rk[MAX];
ll v[MAX],sum[MAX];
int po[MAX];

//初期化
void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		rk[i]=0;
		sum[i]=v[i];
		po[i]=0;
	}
}
//根を求める
int find(int x){
	if(par[x]==x){
		return x;
	}
	else{
		return par[x]=find(par[x]);
	}
}
//xとyの属する集合を併合
int unite(int x,int y,ll c){
  	int d=0;
	x=find(x);
	y=find(y);
	if(x==y){
//      	cout<<sum[x]<<" ";
		if(c<=sum[x]){
			d=1;
		}
		else{
			po[x]++;
		}
		return d;
	}
//  	cout<<sum[x]+sum[y]<<" ";
	
	if(rk[x]<rk[y]){
		par[x]=y;
		sum[y]+=sum[x];
		po[y]+=po[x];
		if(c<=sum[y]){
			d=po[y]+1;
			po[y]=0;
		}
		else{
			po[y]++;
		}
	}
	else{
		par[y]=x;
		if(rk[x]==rk[y])rk[x]++;
		sum[x]+=sum[y];
		po[x]+=po[y];
		if(c<=sum[x]){
			d=po[x]+1;
			po[x]=0;
		}
		else{
			po[x]++;
		}
	}
  	return d;
}
//xとyが同じ集合に属するか判定
bool same(int x,int y){
	return find(x)==find(y);
}

int main(){
	int N,M;
	cin>>N>>M;
	rep(i,N)cin>>v[i];
	multimap<ll,P> edge;
	rep(i,M){
		int a,b;
      	ll y;
		cin>>a>>b>>y;
		a--;b--;
		P p=make_pair(a,b);
		edge.insert(make_pair(y,p));
	}
	
	init(N);
	multimap<ll,P>::iterator ite;
	ite=edge.begin();
  	int ans=0;
	while(ite!=edge.end()){
		ll cost=ite->first;
		P e=ite->second;
		int a=e.first,b=e.second;
//		cout<<a<<" "<<b<<" "<<cost<<" ";
		int ad=unite(a,b,cost);
//      	cout<<ad<<endl;
      	ans+=ad;
		ite++;
	}
	
	cout<<M-ans<<endl;;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}


int main() {
    ll n;
    cin>>n;
    vector<ll> v(n);
    vector<bool> bo(n-1,false);
    rep(i, n) cin>>v[i];
    //    rep(i, n-1){
    //        ll a = v[i];
    //        ll b = v[i+1];
    ////        if(a+b == (a^b)) bo[i]=true;
    //    }
    int l = 0; // sagen
    int r = 0; // ugen
    
    ll tmpsum = 0;
    ll tmp = 1;
    ll sum = 0;
    while(l<n && r<n){
        //        if(r == n){
        //            rep(i, tmp){
        //                auto y = i;
        //                sum+=y;
        //            }
        //            break;
        //        }
        if(l == n-1 && r == n-1){sum++;break;}
        if( l == r){
            tmpsum += v[l];
            r++;
            sum++;
        } else if( tmpsum + v[r] == ( tmpsum ^ v[r])){
            //            if(r!=n-1){
            tmp++;
            sum += tmp;
            tmpsum+=v[r];
            r++;
            //            }else{ // r == n-1
            //                tmp-=1;
            //                sum += tmp;
            //                //            sum+=tmp;
            //                tmpsum -=v[l];
            //                l++;
            //            }
        }else{
            tmp = max((ll)1,tmp-1);
            //            sum+=tmp;
            tmpsum -=v[l];
            l++;
        }
    }
    
    //    ll tmp = 1;
    //    ll sum = 1;
    //    rep(i, n-1){
    //        if (bo[i]) {
    //            tmp +=1;
    //        } else tmp = 1;
    //        sum+=tmp;
    //    }
    pr(sum);
    //    ll n;
    //    cin>>n;
    //    vector<ll> v(n);
    //    vector<bool> bo(n-1,false);
    //    rep(i, n) cin>>v[i];
    //    rep(i, n-1){
    //        ll a = v[i];
    //        ll b = v[i+1];
    //        if(a+b == (a^b)) bo[i]=true;
    //    }
    //    ll tmp = 1;
    //    ll sum = 1;
    //    rep(i, n-1){
    //        if (bo[i]) {
    //            tmp +=1;
    //        } else tmp = 1;
    //        sum+=tmp;
    //    }
    //    pr(sum);
}



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

int convert(char val) {
    switch (val)
    {
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}

int main()
{
  char n[256];
  if (scanf("%s", n) != 1) {
    printf("Failed to read integer.\n");
  }

  int cnt;
  int charSum = 0;
  for(cnt = 0; cnt < strlen(n); cnt++) {
    charSum += convert(n[cnt]);
  }
  if (atoi(n) % charSum == 0) {
      printf("Yes\n");
  } else {
      printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) {
        par = vector<int>(N,-1);
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x]<0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) { // xとyの木を併合
        x = root(x); //xの根をrx
        y = root(y); //yの根をry
        if (x == y) return false; //xとyの根が同じ(=同じ木にある)時はそのま
        if(par[x]>par[y]) swap(x,y);
        par[x]+=par[y];
        par[y] = x;
        return true; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x){
        return -par[root(x)];
    }
};

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

    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        uf.unite(a-1,b-1);
    }

    int ans=0;
    rep(i,n){
        ans=max(ans,uf.size(i));
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3988
#include<stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    int t,m[999],n,ali=0,bob=0;
    scanf("%d",&t);
    n=t;
  for(int i=1;i<=t;i++)
  {
      scanf("%d",&m[i]);
  }
    sort(m+1,m+t+1);
    for(int i=1;i<=t;i++)
    {
        if(i%2==0)
            bob+=m[n--];
        else
            ali+=m[n--];
    }
    printf("%d",ali-bob);
    return 0;
}


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

int main(){
  while(1){
    int n;
    cin >> n;
    if(n == 0) break;

    int sum = 0;

    for(int i = 0; i < n * (n - 1) / 2; i++){
      int x;
      cin >> x;
      sum += x;
    }

    cout << sum / (n - 1) << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;

ll w[300001] = {};
ll e[300001] = {};

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

	ll W = 0;
	ll E = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'W')W++;
		else E++;
	}

	ll LW = 0;
	ll RE = E;
	rep(i, 0, s.size()) {
		w[i] = LW;
		if (s[i] == 'W') {
			LW++;
		}
		else {
			RE--;
		}
		e[i] = RE;
	}
	ll minV = 1 << 21;
	rep(i, 0, s.size()) {
		minV = min(minV, w[i] + e[i]);
	}
	cout << minV << endl;

	return 0;
}

Measured memory_bytes: 5380
def generate_bin_list(num, target_list_len):
    flags = []
    if target_list_len == 0:
        return flags
    for i in range(target_list_len):
        flags.append(0)
    b = list(bin(num))
    l_b = len(b)
    for j in range(0, l_b-2):
        flags[target_list_len-1-j] = int(b[l_b-1-j])
    return flags


H, W, K = map(int, input().split())

if W == 1:
    print(1)
    exit()

A = {}
for i in range(H+1):
    A[i] = {}
    for j in range(W):
        A[i][j] = 0

n = pow(2, W-1)
patterns = []
for i in range(n):
    _p = generate_bin_list(i, W-1)
    current = _p[0]
    can_apply = True
    for i in range(1, len(_p)):
        if current == 1 and _p[i] == 1:
            can_apply = False
        current = _p[i]
    if can_apply:
        patterns.append(_p)

# start
A[0][0] = 1
mod = 1000000007

for h in range(1, H+1):
    for pattern in patterns:
        for x in range(W):
            if x == 0:
                if pattern[x] == 0:
                    A[h][x] += A[h-1][x]
                else:
                    A[h][x] += A[h-1][x+1]
            elif x == W-1:
                if pattern[x-1] == 0:
                    A[h][x] += A[h-1][x]
                else:
                    A[h][x] += A[h-1][x-1]
            else:
                if pattern[x-1] == 0 and pattern[x] == 0:
                    A[h][x] += A[h-1][x]
                if pattern[x-1] == 1:
                    A[h][x] += A[h-1][x-1]
                if pattern[x] == 1:
                    A[h][x] += A[h-1][x+1]
            A[h][x] %= mod

print(A[H][K-1])


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	set<string> k;
	string temp, prev;
	bool flag = true;
	cin>>n;
	cin>>temp;
	prev = temp;
	k.insert(temp);
	for(int i=1;i<n;i++){
		cin>>temp;
		if(k.find(temp)!=k.end()){
			flag = false;
		}else{
			int l = prev.size();
			if(prev[l-1]==temp[0]){
				k.insert(temp);
				prev = temp;
			}	
			else
				flag = false;
		}
	}
	if(flag)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 256
import collections
import itertools
import numpy as np
H,W,K = map(int, input().split())
C = [list(input()) for i in range(H)]
MAP = np.array(C)
EraseLine = np.count_nonzero(MAP == '#', axis=1)
EraseRow = np.count_nonzero(MAP == '#', axis=0)
sumSharp = sum(EraseLine)


cnt = 0
for i in itertools.product([0,1], repeat=(H+W)):
    EraseCnt = 0
    # 行の処理
    for j in range(H):
        if i[j] == 1:
            EraseCnt += EraseLine[j]

    # 列の処理
    for m in range(W):
        if i[H+m] == 1:
            EraseCnt += EraseRow[m]
            for n in range(H):
                if i[n] == 1:
                    EraseCnt -= C[n][m] == '#'

    if K == sumSharp - EraseCnt:
        cnt += 1

print(cnt) 

Measured memory_bytes: 27148
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        h: [i64; n],
    }
    let mut prev = 0;
    let mut ans = 0;

    for i in 0..n {
        if h[i] > prev {
            ans += h[i] - prev;
        }
        prev = h[i]
    }
    println!("{}", ans);
}


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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
    fastio
    int n,d;
    cin >> n >> d;
    int ans = 0;
    while(n--){
        int a,b;
        cin >> a >> b;
        if(a*a+b*b<=d*d) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    string w;
    cin >> w;
    int ans = 0;
    string s;
    while(cin >> s){
        if(s == "END_OF_TEXT") break;
        rep(i,w.size()){
            if(!('a' <= s[i] && s[i] <= 'z')) s[i] += 32;
        }
        if(s == w) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3176
N, M = map(int, input().split())
S_array = list(map(int, input().split()))
T_array = list(map(int, input().split()))

mod = 10**9 + 7

add_num_array = [0] * N
ans_array = [0] * (N + 1)
ans_old = [1] * (N + 1)

for t in T_array:
    ans_array = [1] * (N+1)
    for i, s in enumerate(S_array):
        if s == t:
            add_num_array[i] = (add_num_array[i] + ans_old[i]) % mod
        ans_array[i + 1] = (ans_array[i] + add_num_array[i]) % mod
    ans_old = ans_array

print(ans_array[-1])

Measured memory_bytes: 42332
#!/usr/bin/env python3
# 数列の操作で入力の配列を作ることができるか、と言う形式の問題(構築？)
# 考え方としては、一意に定まるとして考えることが定石
# 特徴的なケース1,nを考えたが、有効そうな案は浮かばず
# 前からi番目がj の時、これはi-j+1番以降に出されたことがわかる
# 前から順番に埋めて行ったら解けそう
# b[i-1]<=iなら絶対いけるのでは？
n = int(input())
b = list(map(int,input().split()))
for i in range(n):
    if b[i] > i+1: 
        print(-1)
        exit()
ans = []
add = [0]*n
for cnt in range(n):
    for i in range(n-1,-1,-1):
        if b[i] == i+1:
            ans.append(b[i]-add[i])#末尾
            b[i] = -1#２度と合わないように
            for j in range(i+1,n):
                b[j] += 1
                add[j] += 1
            break
for i in range(n-1,-1,-1):
    print(ans[i])

        

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

int main(){
  int s,s1,s2,s3;
  
  cin >> s;
  
  s1 = s/100;
  s2 = (s % 100)/ 10;
  s3 = s % 10;
  
  cout << s1 + s2 + s3 << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    int  arr[200010] = {};

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

    vector<int> v;
    for (int e: arr) v.push_back(e);
    sort(v.begin(), v.end());
    
    int l;
    if (v.size() - k > 0) l = v.size() - k;
    else                  l = 0;

    int ans = 0;
    for (int i = 0; i < l; i++) ans += v[i];
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
#include <stdio.h>

int n,x;

void swap(int *a,int *b){
  int comp;
  comp = *a;
  *a = *b;
  *b = comp;
}

		

void partition(int *a,int p,int r){
  int i,j,k;
  x = a[r];
  i = 0;

  for(j = p;j < r;j++){
    if(a[j] <= x){
      swap(&a[i],&a[j]);
       i++;
    }
  }
  swap(&a[i],&a[r]);
}

int main(){

  int i,j,sw = 0;
  int a[100001] = {};

  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&a[i]);

  partition(a,0,n - 1);

  for(i = 0;i < n;i++) {
    if(a[i] != x) printf("%d",a[i]);
    else {
      for(j = i + 1;j < n;j++){
	if(a[j] == x){
	  sw = 1;
	break;
	}
      }
      // printf("sw = %d\n",sw);
      if(sw == 1) printf("%d",a[i]);
      else printf("[%d]",a[i]);
      sw = 0;
    }
   
    if(i != n - 1) printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    string c;
    cin>>n>>c;
    int cnt=0,ans=0;
    for(int i=0;i<n;i++)
        if(c[i]=='R')
            cnt++;
    for(int i=0;i<cnt;i++)
        if(c[i]=='W')
            ans++;
    cout<<ans<<endl;
}


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

int main() {
  int N,K;
  string S;
  cin >> S;
  if (S[1] == S[2]) {
    if (S[0] == S[1] || S[2] == S[3]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double n = scan.nextDouble();
		double max = n;
		double min = n;
		while(scan.hasNext()){
			n = scan.nextDouble();
			if(n>max){
				max = n;
			}else if(n<min){
				min = n;
			}
		}
		System.out.println(max-min);
	}
}

Measured memory_bytes: 19016
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main() {
	//PLAY();
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	cin >> s;
	for (int i = 0; i < sz(s); i++) {
		int cnt2 = 0;
		if (i + 3 <= sz(s)) {
			int idx = i;
			int cnt = 3;
			cnt2 = 0;
			while (cnt--) {
				if (idx >= sz(s)) {
					if (cnt2 == 3) {
						cout << "Yes" << endl;
						return 0;
					}
					break;
				}
				cnt2 += s[idx] == s[i];
				idx++;
			}
			if (cnt2 == 3) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		if (cnt2 == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;	

	return 0;
}

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

int main(){
    int x, y;
    rep(i, 3000) {
        cin >> x >> y;
        if (x == 0 && y == 0) return 0;
        else if (x > y) swap(x, y);
        cout << x << " " << y << endl;;
    }
    return 0;
}


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

using namespace std;

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

    int abc[26];
    for(int i=0; i<26; i++) abc[i] = 0;

    for(int i=0;i<w.length();i++){
        if(w[i] == 'a') ++abc[0];
        else if(w[i] == 'b') ++abc[1];
        else if(w[i] == 'c') ++abc[2];
        else if(w[i] == 'd') ++abc[3];
        else if(w[i] == 'e') ++abc[4];
        else if(w[i] == 'f') ++abc[5];
        else if(w[i] == 'g') ++abc[6];
        else if(w[i] == 'h') ++abc[7];
        else if(w[i] == 'i') ++abc[8];
        else if(w[i] == 'j') ++abc[9];
        else if(w[i] == 'k') ++abc[10];
        else if(w[i] == 'l') ++abc[11];
        else if(w[i] == 'm') ++abc[12];
        else if(w[i] == 'n') ++abc[13];
        else if(w[i] == 'o') ++abc[14];
        else if(w[i] == 'p') ++abc[15];
        else if(w[i] == 'q') ++abc[16];
        else if(w[i] == 'r') ++abc[17];
        else if(w[i] == 's') ++abc[18];
        else if(w[i] == 't') ++abc[19];
        else if(w[i] == 'u') ++abc[20];
        else if(w[i] == 'v') ++abc[21];
        else if(w[i] == 'w') ++abc[22];
        else if(w[i] == 'x') ++abc[23];
        else if(w[i] == 'y') ++abc[24];
        else if(w[i] == 'z') ++abc[25];
    }

    string ans = "Yes";
    for(int i=0; i<26; i++){
        if(abc[i]%2 == 1){
            ans = "No";
            break;
        }
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
//shan61916
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;

int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n ;
  cin >> n;
  vector<pair<ll, ll>> a;
  for(ll i = 0; i < n; i++) {
    ll x, y;
    cin >> y >> x;
    a.push_back({x, y});
  }
  sort(a.begin(), a.end());
  ll curr = 0;
  bool foo = true;
  for(auto it: a) {
    if(curr + it.second <= it.first) {
      curr += it.second;
    }
    else {
      foo = false;
      break;
    }
  }
  if(foo) cout << "Yes" ;
  else {
    cout << "No";
  }
  return 0;
} //good night.

Measured memory_bytes: 6512