akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[1009][1009];

int main(){
  int h,w;
  cin>>h>>w;
  vector<string>a(h);
  rep(i,h)cin>>a[i];
  dp[1][0]=1;
  rep(i,h){
    rep(j,w){
      if(a[i][j]=='#')continue;
      dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j];
    }
  }
  cout<<dp[h][w].x<<endl;
  return(0);
}

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

public class Main
{

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

	public static void main(String[] args) throws IOException
	{
		// TODO 自動生成されたメソッド・スタブ
		for(int i = 1;; i++)
		{
			String str[] = input(3);
			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[1]);
			int c = Integer.parseInt(str[2]);
			if(a == -1 && b == -1 && c == -1) break;
			if(a == -1 || b == -1 || a + b < 30) System.out.println("F");
			else if(a + b >= 80) System.out.println("A");
			else if(a + b >= 65) System.out.println("B");
			else if(a + b >= 50) System.out.println("C");
			else if(c >= 50) System.out.println("C");
			else System.out.println("D");
		}
	}

	public static String[] input(int Num) throws IOException
	{
		String str[] = new String[Num];
		String str2 = br.readLine();
		int j = 0;
		for(int i = 0; i < Num; i++)
		{
			if(i < Num - 1)
			{
				str[i] = str2.substring(j, str2.indexOf(" ", j));
				j = str2.indexOf(" ", j) + 1;
			}
			else
			{
				str[i] = str2.substring(j);
			}
		}
		return str;
	}

}



Measured memory_bytes: 24356
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a, b, w ; 
  int A , B ;
  cin >> a >> b ;
  A = a, B = b;
  w = ( a + b ) / 2 ;
  int R = w*10 ;
  int x = R % 10 % 4 ;
  cout << (A+B)/2 + x << endl;
 }

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int a,b,c,x,y;
long long ans;

int main()
{
  scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
  if(2*c>=a+b)
    {
      ans=1ll*a*x+1ll*b*y;
    }
  else
    {
      int minnum=std::min(x,y);
      x-=minnum;
      y-=minnum;
      ans=1ll*minnum*2*c;
      if(x>y)
	{
	  std::swap(x,y);
	  std::swap(a,b);
	}
      ans+=std::min(1ll*2*y*c,1ll*y*b);
    }
  printf("%lld\n",ans);
  return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;



char charBeda(char c, char d) {
	string s = "RGB";	
	for(int i=0;i<3;i++){
		if(s[i] != c && s[i] != d){
			return s[i];
		}
	}
	return '-';
}

int main(){
	int n,i,j;
	scanf("%d",&n);
	string s;
	cin>>s;
	int pref[26][4001];
	string te = "RGB";

	for(i=0;i<n;i++){
		pref[s[i] - 'A'][i]++;
		if(i){
			for(j=0;j<3;j++){
				pref[te[j] - 'A'][i] += pref[te[j] - 'A'][i-1];
			}
		}
	}
	ll ans = 0;

	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(s[i] != s[j]){
				char beda = charBeda(s[i], s[j]);
				//find beda di tempat lain
				int selisih = j - i;
				int forbidden = j + selisih;
				if(forbidden >= n){
					int banyak = pref[beda - 'A'][n-1] - pref[beda - 'A'][j];
					ans += banyak;
				}else{
					int banyak1 = pref[beda - 'A'][n-1] - pref[beda - 'A'][forbidden];
					int banyak2 = pref[beda - 'A'][forbidden-1] - pref[beda - 'A'][j];
					ans += banyak1;
					ans += banyak2;
				}
			}
			
		}
	}
	printf("%lld\n",ans);
	return 0;
};

Measured memory_bytes: 3856
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

void enqueue(P);
P dequeue(void);

P Q[LEN+1];
int head, tail, n;

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);
  }
  while(head!=tail){
    u=dequeue();
    
  if(u.t>q){
    u.t-=q;
    elaps+=q;
  enqueue(u);
  }
  else{
    elaps+=u.t;
    printf("%s %d\n",u.name,elaps);
  }
  }

  
  return 0;
}

void enqueue(P x){
  if(head == (tail + 1) % (n+1)) exit(2);
  Q[tail] = x;
  if(tail + 1 == (n+1)) tail = 0;
  else tail++;
}

P dequeue(){
  P x;
  if(head == tail) exit(3);
  x = Q[head];
  if(head + 1 == (n+1)) head = 0;
  else head++;
  return x;			
}



Measured memory_bytes: 6792
#include<bits/stdc++.h>
 
using namespace std;
 
main()
{
    int a,b,c;
   char x;
   cin>>a>>x>>b>>x>>c;
  
  if(a>2019)cout<<"TBD"<<endl;
  else if(b>4)cout<<"TBD"<<endl;
 else  cout<<"Heisei"<<endl;
  
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i + 1 < n; i++) {
		cout << a[n - 1 - i] << ' ';
	}
	cout << a[0] << endl;
	return 0;
}

Measured memory_bytes: 3052
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, moke;
    vector<int> list;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &moke);
        list.push_back(moke);
    }

    std::sort(list.begin(), list.end());
    
    printf("%d\n", list[n / 2] - list[n / 2 - 1]);

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    ll n,m,i,tmp;
    double sum=0;
    cin>>n>>m;
    vector<ll> a(n);
    for(i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(all(a),greater<int>());

    a[m-1]>=sum/(4.0*m) ? cout<<"Yes" : cout<<"No" ;
    

    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int X = min(A * 100 / 8, B * 10);
  for (X = min(A * 100 / 8, B * 10); X <= X + 100; X++) {
    if (X * 8 / 100 == A && X / 10 == B) {
      cout << X << endl;
      break;
    }
    else if (X > A * 100 / 8 && X > B * 10) {
      cout << "-1" << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
using namespace std;

int dp[100005];

int main()
{
    int i,j,n,k;
    cin>>n>>k;
    int ar[n];
    f(i,0,n)
    	cin>>ar[i];
    f(i,1,k+1)
    {
    	if(dp[i]==0)
    		f(j,0,n)
    		{
    			if(ar[j]<=i)
    			{
    				if(dp[i-ar[j]]==0)
    					dp[i]=1;
    			}
    		}
    }
   /* f(i,0,k+1)
    	cout<<dp[i]<<' ';*/
    if(dp[k]==1)
    	cout<<"First";
    else cout<<"Second";
}

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

void Main()
{
    int n;
    vector<int> a(3);
    cin >> n >> a[0] >> a[1] >> a[2];
    vector<string> s(n), ans;
    map<string, pair<int, int>> p;
    p["AB"] = make_pair(0, 1);
    p["AC"] = make_pair(0, 2);
    p["BC"] = make_pair(1, 2);
    vector<string> i2s = {"A", "B", "C"};
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++)
    {
        auto t = p[s[i]];
        if (a[t.first]==0 && a[t.second]==0) {
            cout << "No" << endl;
            return;
        }else if (a[t.first]==1 && a[t.second]==1 && i!=n-1) {
            auto tn = p[s[i+1]];
            if(t.first == tn.first || t.first == tn.second) {
                a[t.first]++; 
                a[t.second]--; 
                ans.push_back(i2s[t.first]);
            }else{
                a[t.first]--; 
                a[t.second]++; 
                ans.push_back(i2s[t.second]);
            }
        }else if (a[t.first] >= a[t.second]) {
            a[t.first]--; 
            a[t.second]++; 
            ans.push_back(i2s[t.second]);
        } else {
            a[t.first]++; 
            a[t.second]--;
            ans.push_back(i2s[t.first]);
        }
    }
    
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << endl;
    }
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

typedef long long ll;

void solve() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(a.begin(), a.end());
    int n = a[N - 1], k = n / 2;
    cout << n << " ";
    auto i = lower_bound(a.begin(), a.end(), k);
    if (*i * 2 - n < n - *(i - 1) * 2) cout << *i << endl;
    else cout << *(i - 1) << endl;
    return;
}

int main() {
    solve();
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int p,q,r;
  cin >> p >> q >> r;
  int a=p+q;
  int b=q+r;
  int c=r+p;
  if(a<=b && a<=c) cout << a << endl;
  if(b<a && b<=c) cout << b << endl;
  if(c<b && c<a) cout << c << endl;
  return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> p(N),q(N);
  int count = 0;
  rep(i,N)
  {
    cin >> p[i];
    q[i] = i + 1;
  }
  rep(i,N)
  {
    if(p[i]!=q[i])
    {
      count ++;
    }
  }
  if(count==0||count==2)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> S;
  int c = 0;
  char s, bit = '1';
  for (int i = 0; i < N; i++) {
    cin >> s;
    if (s == bit) {
      c++;
    } else {
      S.push_back(c);
      bit = bit == '0' ? '1' : '0';
      c = 1;
    }
  }
  S.push_back(c);

  int SLen = S.size();
  int ans = 0;
  for (int i = 0; i < SLen; i += 2) {
    int count = 0;
    int tempMax = min(SLen, i + K * 2 + 1);
    for (int j = i; j < tempMax; j++) {
      count += S[j];
    }
    ans = max(ans, count);
  }

  cout << ans << endl;

  return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    string s,t;
    i32 n,m, k;

    cin >> k >> s;
    --k;
    for (i32 i = 0; i < s.size(); ++i) {
        if(i <= k) t.push_back(s[i]);
        else {
            t = t + "...";
            break;
        }
    }

    cout << t << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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

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

int main() {
	int n;
	
	while (cin >> n, n) {
		for_(i,0,n) {
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			
			double ave = (double)(pm + pe + pj) / 3.;
			double aveme = (double)(pm + pe) / 2.;
			
			if (aveme > 89 || pm == 100 || pe == 100 || pj == 100) {
				cout << "A" << endl;
			} else {
				
				if (ave < 50) {
					cout << "C" << endl;
				} else if (ave < 70) {
					if (pm >= 80 || pe >= 80) cout << "B" << endl;
					else cout << "C" << endl;
				} else if (ave < 80) {
					cout << "B" << endl;
				} else {
					cout << "A" << endl;
				}
			}
		}
	}
}

Measured memory_bytes: 1156
from collections import deque

def make_lunlun():
    lst = []
    que = deque([1,2,3,4,5,6,7,8,9])
    for i in range(100000):
        str_num = str(que.popleft())
        str_one = str_num[-1]
        a = str(int(str_one) - 1)
        b = str(int(str_one) + 1)
        #minus = int(str_num + a)
        same = int(str_num + str_one)
        #plus = int(str_num + b)
        if 0 < int(str_one) < 9:
            minus = int(str_num + a)
            plus = int(str_num + b)
            que.extend([minus,same,plus])
            lst.extend([minus,same,plus])
        elif int(str_one) == 0:
            plus = int(str_num + b)
            que.extend([same,plus])
            lst.extend([same,plus])
        else:
            minus = int(str_num + a)
            que.extend([minus,same])
            lst.extend([minus,same])
    print(lst[K - 10])    

K = int(input())
if K <= 12:
    print(K)
else:
    make_lunlun()
    

Measured memory_bytes: 16376
#include <cmath>
#include <iostream>
#include <vector>

int main(int argc, char const* argv[]) {
    int  a, b;
    char op;
    std::cin >> a >> op >> b;

    if (op == '+') {
        std::cout << a + b << '\n';
    } else {
        std::cout << a - b << '\n';
    }
    return 0;
}


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

int main(){
 	int a,b;
  int cost;
  cin >> a >> b;
   cost = a*500;
  if(cost>=b){
    cout << "Yes" << endl;
    
  }
  else{
    cout << "No" << endl;
  }
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var dump = Console.ReadLine();
            var tmp = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).OrderBy(x => x);
            var A = tmp.ToArray();
            var B = tmp.Distinct().ToArray();
            var dec = new Dictionary<int, int>();
            var sum = 0;

            foreach (var a in B)
            {
                dec.Add(a,0);
            }

            foreach (var a in A)
            {
                dec[a]++;
            }

            foreach(var elem in dec)
            {
                var key = elem.Key;
                var value = elem.Value;
                if(key == value)
                {

                }
                else if(key > value)
                {
                    sum += value;
                }
                else
                {
                    sum += (value - key);
                }
            }
            Console.WriteLine(sum);

            
        }
    }
}


Measured memory_bytes: 34652
#include<iostream>
#include <string>
#include <string.h>
#include <algorithm>

int main()
{
  char s[100001];
  scanf("%s", s);
  
  const struct word_def
  {
    char str[10];
    int length;
  } words[4] =
  {
    {"dream", 5},
    {"dreamer", 7},
    {"erase", 5},
    {"eraser", 6},
  };

  int length = strlen(s);
  int index = 0;
  bool found = true;
  while(index < length && found)
  {
    found = false;
    for(auto w : words)
    {
      int cmp_index = length - index - w.length;
      if(cmp_index >= 0 && strncmp(&s[cmp_index], w.str, w.length) == 0)
      {
        found = true;
        index += w.length;
        break;
      }
    }
  }
  
  printf("%s", (found) ? "YES" : "NO");
  
  return 0;
}


Measured memory_bytes: 384
"""
~~ Author : Bhaskar
~~ Dated : 16~05~2020
"""

import sys
from math import *
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def calcAngle(h, m):

    if (h < 0 or m < 0 or h > 12 or m > 60):
        print('Wrong input')

    if (h == 12):
        h = 0
    if (m == 60):
        m = 0
    hour_angle = 0.5 * (h * 60 + m)
    minute_angle = 6 * m
    angle = abs(hour_angle - minute_angle)
    angle = min(360 - angle, angle)

    return angle


def main():
    a, b, h, m = map(int, sys.stdin.readline().split())
    angle = calcAngle(h, m)*(pi/180)
    ans = sqrt(a ** 2 + b ** 2 - (2 * a * b * cos(angle)))
    print(ans)


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;

int main() {
  string a, b, c, d;
  cin >> a >> b >> c >> d;
  a += b;
  a += c;
  a += d;
  sort(begin(a), end(a));
  if(a == "1479") puts("YES");
  else puts("NO");

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,i,j,k=0;
  cin>>n>>a>>b;
  for(i=0;i<n;i++){
    cin>>j;
    if(j<a||b<=j) k++; 
  }
  cout << k << endl;
  return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



ll mod = 1e9 + 7;

ll solve(ll n, ll k){
  if(n == 1) return 1;
  vector<vector<ll>> dp(k+1, vector<ll>(63244 + 10, 0)); // idx, right

  vector<ll> ma(63244 + 10, 0);
  ll r;
  ll idx = 0;
  for(ll l = 1; l <= n; l = r+1){
    r = n/(n/l);
    dp[0][idx] = r-l+1;
    dp[0][idx] %= mod;
    ma[idx] = r-l+1;
    idx++;
  }

  rep1(i, k){
    ll rem = 0;
    rep(j, idx){
      rem += dp[i-1][j];
      rem %= mod;
      dp[i][idx-1-j] = ma[idx-1-j] * rem;
    }
  }

  ll sum = 0;
  rep(i, idx) sum += dp[k-1][i], sum %= mod;
  

  return sum;
}

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

  
  ll sum = solve(n, k);
  
  cout << sum << endl;



  return 0;
}


Measured memory_bytes: 50832
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys
import math



def solve(b):
  ret = []
  while len(b) > 0:
    dct = [] # list of index
    for i in range(len(b)):
      if b[i] == i+1:
        dct.append(i)
    if len(dct) == 0:
      return [-1]
    else:
      ret.append(dct[-1]+1)
      b.pop(dct[-1])
  return ret[::-1]


N = int(input())
B = list(map(int, input().split()))

for i in solve(B):
  print(i)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    vector<string> grid(H+2);
    grid[0] = string(W+2,'#');
    grid[H+1] = string(W+2,'#');
    string s;
    REP(h,H){
        cin >> s;
        grid[h+1] = "#" + s + "#";
    }
    for(auto x:grid){
        cout << x << endl;
    }
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	public void run() {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextLong();
		}
		Arrays.sort(A);
		long ans = 0;
		for (long v : A)
			ans += v - 1;
		pw.println(ans);
		pw.close();
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 21460
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		// A<=B
		while (A > 0 && Long.highestOneBit(A) == Long.highestOneBit(B)) {
			long flip = Long.highestOneBit(A);
			A ^= flip;
			B ^= flip;
		}
		if (B == 0) {
			System.out.println(1);
			return;
		}
		int first = Long.numberOfTrailingZeros(Long.highestOneBit(B));
		int second = -1;
		if (B == (1L << first)) {
			second = -1;
		} else {
			second = Long.numberOfTrailingZeros(Long.highestOneBit(B ^ (1L << first)));
		}
		long l1 = A;
		long r1 = ((1L << first) + ((1L << (second + 1)) - 1));
		long l2 = A + (1L << first);
		long r2 = (1L << (first + 1)) - 1;
		long res = -1;
		if (l2 <= r1 && r1 <= r2) {
			res = r2 - l1 + 1;
		} else if (l1 <= r2 && r2 <= r1) {
			res = r1 - l1 + 1;
		} else if (r1 <= l2) {
			res = (r1 - l1 + 1) + (r2 - l2 + 1);
		}
		System.out.println(res);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 23892
#include<iostream>
#include<string>
#include<cstdlib>
#include<cctype>

int main()
{
	std::string s;
	int ans = 0;
	while( std::cin >> s )
	{
		int i = 0;
		while( i < s.size() )
		{
			int j = i;
			while( isdigit( s[j] ) )
				++j;

			if( i != j )
			{
				ans += atoi( s.substr( i, j - i ).c_str() );
				i = j;
			}

			++i;
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 1192
S = input()
l = []
m = []

for i in range(len(S) - 2):
    a = S[i] + S[i + 1] + S[i + 2]
    l.append(a)

for j in l:
    
    m.append(abs(int(j) - 753))
    
    
print(min(m))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds; 
using namespace std;
typedef long long ll;
int main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,count=1;cin>>n;
    //cout<<n<<" ";
    long  double start=101;
    if(n==start)return cout<<1,0;
    //if(n==1000000000000000000)return cout<<3760,0;
    while(start<n)
    {
        start=(long double)((ll)(start*1.01));
        
        //start/=100;
        count++;
        if((ll)start>=n)return cout<<count,0;
    }
    return 0;
}


Measured memory_bytes: 3648
// test.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string day;
	cin >> day;
	if (day == "SUN")
	{
		cout << 7 << endl;
	}
	else if (day == "MON")
	{
		cout << 6 << endl;
	}
	else if (day == "TUE")
	{
		cout << 5 << endl;
	}
	else if (day == "WED")
	{
		cout << 4 << endl;
	}
	else if (day == "THU")
	{
		cout << 3 << endl;
	}
	if (day == "FRI")
	{
		cout << 2 << endl;
	}
	else if (day == "SAT")
	{
		cout << 1 << endl;
	}
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //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 main(){
  /*int n;
  cin >> n; 
  vector<int> A(n);
  rep(i, n) cin >> A[i];*/ 
  /*int64_t x; cin >> x;
  vector<int64_t> A(20000000);
  set<int64_t> B;
  for(int64_t i=0; i<10000000; i++){
    int64_t w = i;  
    rep(j, 5) w *= i;
    A[2*i] = w;
    A[2*i+1] = -w;
    B.insert(w);
    B.insert(-w); 
  }
  int64_t g = 0LL;
  for(int64_t i=0; i<20000000; i++){
    g =  A[i]+x;
    if(B.count(g)){
      cout << g << " " << A[i] << endl;
      break;
    } 
  }*/
  ll n, a; cin >> n;
  map<ll, ll> A;
  map<ll, ll> B;
  for(ll i=0; i<n; i++){
    cin >> a;
    A[i+1] = a;
    if(B.count(a+i+1)) B[a+i+1]++;
    else B[a+i+1] = 1;   
  }
  ll ans = 0;
  for(auto p: A){
    ll k = p.first;
    ll v = p.second;
    //cout << k << " " << v << endl;
    if(k>v) ans += B[k-v];
  }
  cout << ans << endl;
}

Measured memory_bytes: 29808
#include<iostream>
using namespace std;
using ll = long long;

int main() {
	ll x, ans = 0;
	cin >> x;
	if (x > 11) {
		ans = (x / 11) * 2;
		x %= 11;
	}
	if (x > 0) {
		x -= 6;
		ans++;
	}
	if (x > 0) {
		x -= 5;
		ans++;
	}
	cout << ans << endl;
}

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

int main()
{
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    char c = sa[0];
    sa.erase(sa.begin());
    while(1)
    {
        if(c == 'a')
        {
            if(sa.size() == 0)
            {
                printf("A");
                break;
            }
            sa.erase(sa.begin());
            c = sa[0];
        }
        else if(c == 'b')
        {
            if(sb.size() == 0)
            {
                printf("B");
                break;
            }
            sb.erase(sb.begin());
            c = sb[0];
        }
        else
        {
            if(sc.size() == 0)
            {
                printf("C");
                break;
            }
            sc.erase(sc.begin());
            c = sc[0];
        }
    }
    return 0;
}


Measured memory_bytes: 256
i = gets.chomp.to_i
a = []
i.times do
 a << gets.chomp.split(' ')
end
b = []
a.each do |item|
  case item[0]
  when 'insert'
    b.unshift item[1]
  when 'delete'
    b.delete_at(b.index(item[1])) unless b.index(item[1]).nil?
  when 'deleteFirst'
    b.shift
  when 'deleteLast'
    b.delete_at(b.length-1)
  end
end
puts b.join(' ')

Measured memory_bytes: 324240
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, a, n) for(int i=(a);i < (n);i++)
#define all(e) (e).begin(), (e).end()

#ifdef LOCAL
#define show(x) cerr<< __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

using namespace std;

using ll=long long;
template<class T> using V=vector<T>;

template<class T, class U>
void chmin(T &t, const U u) {
    if (t > u) {
        t = u;
    }
}

template<class T, class U>
void chmax(T &t, const U u) {
    if (t < u) {
        t = u;
    }
}

const int INF = 1e+8+7;
#define print(X) cout << (X) << endl;
#define pb push_back
#define sz size()

int n,m,l;
string s,t;

string get(string str){
    string ans = "";
    ans += str[0];

    rep(i,0,str.sz-1){
        switch(str[i]){
            case 'a':
            case 'i':
            case 'u':
            case 'e':
            case 'o':
                ans += str[i+1];
                break;
            default:
                break;
        }
    }
    // cout << "get:" << ans << endl;
    return ans;
}

string split(string str, int n){
    string ans = "";
    int p = min<ll>(str.sz, n);

    rep(i,0,p)ans += str[i];
    if(p == str.sz)rep(i,0,n-p)ans += " ";
    return ans;
}

int main() {

    while(cin >> n, !(n == 0)){
        vector<string> ans;
        bool flag = true;

        rep(i,0,n)cin >> s, ans.pb(get(s));
        rep(i,0,ans.sz){
            rep(j,i+1,ans.sz){
                if(ans[i] == ans[j])flag = false;
            }
        }

        if(!flag)puts("-1");
        else{
            int mx = -1;
            int answer = -1;
            rep(i,0,ans.sz)mx = max<ll>(mx, ans[i].sz);

            rep(i,1,mx+1){
                set<string> now;
                // cout << "i = " << i << endl;
                flag = false;
                rep(j,0,ans.sz){
                    s = split(ans[j], i);
                    if(s == "-1")break;
                    now.insert(s);
                }
                if(now.sz == ans.sz){
                    answer = i;
                    break;
                }
            }
            print(answer);
        }
    }

    return 0;
}


Measured memory_bytes: 3072
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int res = Math.max(Math.abs(a-b)-w, 0);
        System.out.println(res);
    }
}

class io{
    public static void br(){
        System.out.println("");
    }

    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }

}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 21844
#include <iostream>

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

   int n = S.size();
   for(int i=1; i<n; ++i){
      if((n-i)%2!=0) continue;
      int m = (n-i)/2;
      bool flag = true;
      for(int j=0; j<m; ++j){
         if(S[j]!=S[j+m]){
	    flag = false;
	    break;
	 }
      }
      if(flag){
	 std::cout << n-i << std::endl;
	 return 0;
      }
   }
   return -1;
}


Measured memory_bytes: 384
from itertools import permutations
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')
n, m = LI()
edges = [[False] * n for _ in range(n)]  # edges[i][j] : 頂点 i から j へ向かう辺がある
for _ in range(m):
    a, b = LI()
    a -= 1
    b -= 1
    edges[a][b] = True
    edges[b][a] = True

# ハミルトン路 ： 頂点を一度だけ通る路のこと
# ハミルトン閉路 : 全頂点を一度だけ通る閉路のこと
# 関連 : オイラー路 ： 全辺を一度だけ通る路のこと

# 開始地点である頂点 1 をぞの板頂点の順列を全列挙
permu = list(permutations(range(1, n)))

ans = 0
for p in permu:
    now = 0  # 頂点 1 から順列にある頂点の順番を参考に各頂点に向かってみる
    is_ok = True  # 条件を満たすか
    for j in p:
        if edges[now][j]:
            now = j
        else:
            is_ok = False
            break
    if is_ok:
        ans += 1


print(ans)


Measured memory_bytes: 9632
s = input()

mae = int(s[:2])
usiro = int(s[2:4])

def is_mm(val):
    if (1<=val)and (12>=val):
        return True
    else:
        return False

is_mae = is_mm(mae)
is_usiro = is_mm(usiro)

if (is_mae is True) and (is_usiro is True):
    print('AMBIGUOUS')
elif(is_mae is False) and (is_usiro is True):
    print('YYMM')
elif(is_mae is True) and (is_usiro is False):
    print('MMYY')
elif(is_mae is False) and (is_usiro is False):
    print('NA')

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

signed main(){
    ll n,k;
    cin >> n >> k;

    ll ans = 0;
    rep(i,k+1,n+1){
        ans += (i-k)*(n/i);
        if(k == 0) ans += max(0LL,n-(n/i)*i-k);
        else ans += max(0LL,n-(n/i)*i-k+1);
    }

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

Measured memory_bytes: 256
a = gets.chomp.to_s

ans = []

len = a.length
for i in 0..len-1
  if a[i] == "0"
    ans.push("0")
  elsif a[i] == "1"
    ans.push("1")
  elsif ans.length > 0
    ans.pop()
  end
end

len = ans.length
for i in 0..len-1
  print ans[i]
end

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

typedef long long LL;

#define int LL

signed main() {
    int T; scanf("%d", &T);
    while (T--) {
        int A, B, C, D; scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
        int len = (max(A, B) + min(A, B)) / (min(A, B) + 1);
        int l = 0, r = 1e9, mid, pos = -1;
        while (l <= r) {
            mid = (l + r) >> 1;
            int t1 = A - mid / (len + 1) * len - mid % (len + 1);
            int t2 = B - mid / (len + 1);
            int h1 = t1 * len + (mid % (len + 1) || !mid ? len : len - 1);
            if (t1 >= 0 && t2 >= 0 && h1 >= t2) pos = mid, l = mid + 1;
            else r = mid - 1;
        } 
        assert(pos >= 0);
        for (int i = C; i <= min(D, pos); i++) 
            putchar(i % (len + 1) ? 'A' : 'B');
        for (int i = min(D, max(pos, C - 1)) + 1; i <= D; i++) 
            putchar((A + B - i + 1) % (len + 1) ? 'B' : 'A');
        puts("");
    }
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

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


int main() {
  int X,N,p;
  cin >> X >> N;
  set<int> P;
  rep(i,N) {
    cin >> p;
    P.insert(p);
  }
  rep(i,100) {
    if (P.find(X-i)==P.end()) {
      cout << X-i << endl;
      return 0;
    }
    if (P.find(X+i)==P.end()) {
      cout << X+i << endl;
      return 0;
    } 
  }
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
void _(ll&a , ll b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;cin >> s;
    if(s[2]==s[3] and s[4]==s[5])cout << "Yes\n";
    else cout << "No";
    }

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll X;
    cin >> X;
    for(ll i = 1; i <= 4000; i++) {
        for(ll j = 0; j <= 4000; j++) {
            if(i * i * i * i * i - j * j * j * j * j == X) {
                cout << i << " " << j << endl;
                return 0;
            } else if(i * i * i * i * i + j * j * j * j * j == X) {
                cout << i << " " << -j << endl;
                return 0;

            } else if(-i * i * i * i * i + j * j * j * j * j == X) {
                cout << -i << " " << -j << endl;
                return 0;

            } else if(-i * i * i * i * i - j * j * j * j * j == X) {
                cout << -i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int d[] = new int[N];
    int sum = 0;

    for (int i = 0; i < N; i++) {
      d[i] = sc.nextInt();
    }

    for (int i = 0; i < N - 1; i++) {
      for (int j = i + 1; j < N; j++) {
        sum = sum + d[i] * d[j];
      }
    }

    System.out.println(sum);

    sc.close();
  }
}


Measured memory_bytes: 21716
import java.util.*;
class Main{
     public static void main(String[] args) {
         Scanner sc=new Scanner(System.in);
        int count=0;
        int temp=0;
        int m=sc.nextInt();
        int l=sc.nextInt();
        count=l-2*m;
        count=count/2;
        temp=m-count;

         if(count*4+temp*2==l&&(m*4>=l&&(m-count>=0)&&(l-2*m>=0))){
        System.out.println("Yes");
        }
        else
         System.out.println("No");
     }
    
}


Measured memory_bytes: 35800
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };
    let mut s = 0;
    let mut c = 0;
    for &a_i in a.iter() {
        if a_i == 0 {
            s += c / 2;
            c = 0;
        } else {
            c += a_i;
        }
    }
    if c > 0 {
        s += c / 2;
    }
    let ans = s;
    println!("{}", ans);
}


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

using namespace std;

int num_flag(int x) {
    int count = 0;
    for(int i = 0; i < sizeof(int)*8; i++) {
        if(x & (1 << i)) count++;
    }
    return count;
}

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

    long long min_cost = 1000000000000;
    for(int i = 0; i < (1 << (n-1)); i++) {
        int bit_count = num_flag(i);
        if(bit_count != (k-1)) continue;
        long long cost = 0;
        int cur_height = heights[0];
        for(int b = 1; b < n; b++) {
            if(i & (1 << (b-1))) {
                if(cur_height >= heights[b]) {
                    cost += cur_height + 1 - heights[b];
                    cur_height++;
                }else {
                    cur_height = heights[b];
                }
            }else {
                cur_height = max(cur_height, heights[b]);
            }
        }
        min_cost = min(min_cost, cost);
    }

    cout << min_cost << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w,k;
	cin>>h>>w>>k;
	vector<vector<char>> g(h,vector<char>(w));
	rep(i,h)rep(j,w) cin>>g[i][j];
	vector<vector<int>> ans(h,vector<int>(w,-1));
	int now=1;
	rep(i,h)rep(j,w){
		if(g[i][j]!='#' || ans[i][j]!=-1) continue;
		ans[i][j]=now;
		int u1=0,u2=0;
		for(int x=j-1;x>=0;x--){//まず横から埋める
			if(g[i][x]=='#' || ans[i][x]!=-1) break;
			ans[i][x]=now; 
			u1++;
		}
		FOR(x,j+1,w){
			if(g[i][x]=='#' || ans[i][x]!=-1) break;
			ans[i][x]=now; 
			u2++;
		}
		for(int y=i-1;y>=0;y--){
			if(g[y][j]=='#' || ans[y][j]!=-1) break;
			bool flag=true;
			for(int x=j+u2;x>=j-u1;x--){
				if(g[y][x]=='#' || ans[y][x]!=-1){
					flag=false;
					break;
				}
			}
			if(flag){
				for(int x=j+u2;x>=j-u1;x--){
					ans[y][x]=now;
				}
			}else{
				break;
			}
		}
		for(int y=i+1;y<h;y++){
			if(g[y][j]=='#' || ans[y][j]!=-1) break;
			bool flag=true;
			for(int x=j+u2;x>=j-u1;x--){
				if(g[y][x]=='#' || ans[y][x]!=-1){
					flag=false;
					break;
				}
			}
			if(flag){
				for(int x=j+u2;x>=j-u1;x--){
					ans[y][x]=now;
				}
			}else{
				break;
			}
		}
		//cout<<u1<<' '<<u2<<endl;
		//cout<<ans<<endl;
 		now++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1280
N = int(input())
B = list(map(int,input().split()))
ins = 0
count = 0
for i in range(N-1):
  if i == 0:
    count += B[i]
  if i > 0 and B[i-1] > B[i]:
    count += B[i]
  elif i > 0 and B[i-1] <= B[i]:
    count += B[i-1]
count += B[i]
print(count)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

using ll = long long;
const ll INF = 1e18 + 1;


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

    ll n;
    cin >> n;

    int arr[100005];
    memset(arr, 0, sizeof arr);

    vector<ll> vec(n);

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

    ll q;
    cin >> q;

    for (int i = 0; i < q; ++i) {
        ll b, c;
        cin >> b >> c;
        sum -= arr[b]*b;

        sum += arr[b]*c;
        arr[c] += arr[b];
        arr[b] = 0;

        cout << sum << endl;
    }




}

Measured memory_bytes: 3832