akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<ldouble, ldouble> pdd;

int N, A[100010];

void solve() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) scanf("%d", A+i);
	ll mn = 2, mx = 2;
	for(int i=N;i;i--) {
		ll ai = A[i];
		ll v1 = (mn + ai - 1) / ai * ai;
		ll v2 = mx / ai * ai;
		if(v1 > v2) {
			puts("-1"); return;
		}
		mn = v1; mx = v2 + ai - 1;
	}
	printf("%lld %lld\n", mn, mx);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int z=sc.nextInt();
		int w=sc.nextInt();
		int[] a=new int[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
		}
		int[][] dp=new int[n+1][2];
		//0は先行、１は後攻
		for(int i=n-1; i>=0; i--){
			int max=0;
			int min=0;
			if(i==0){
				max=Math.abs(w-a[n-1]);
				min=Math.abs(z-a[n-1]);
			}else{
				max=Math.abs(a[i-1]-a[n-1]);
				min=Math.abs(a[i-1]-a[n-1]);
			}
			for(int j=i+1; j<n; j++){
				max=Math.max(dp[j][1],max);
				min=Math.min(dp[j][0],min);
			}
			dp[i][0]=max;
			dp[i][1]=min;
		}
		System.out.println(dp[0][0]);
	}
}


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

using namespace std;

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

  vector<int> box(n, 0);
  vector<int> res;
  for (int i = n; i > 0; --i) {
    int s = 0;
    for (int j = i; j <= n; j += i) {
      s += box[j-1];
    }
    if (s % 2 != a[i-1]) {
      box[i-1] = 1;
      res.push_back(i);
    }
  }

  cout << res.size() << endl;
  for (auto i: res) {
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3192
file = $stdin
line = file.readlines
file.close
a,b = line[0].split(" ")

if a.to_i == b.to_i 
puts "Draw"
elsif a.to_i == 1 && b.to_i != 1
puts "Alice"
elsif a.to_i != 1 && b.to_i == 1
puts "Bob"
elsif a.to_i != 1 && b.to_i != 1 && a.to_i > b.to_i
puts "Alice"
else
puts "Bob"
end

Measured memory_bytes: 1788
from math import ceil

def binary(N,LIST,num):  # 二分探索 # N:探索要素数
    l, r = -1, N
    while r - l > 1:
        if LIST[(l + r) // 2] > num:  # 条件式を代入
            r = (l + r) // 2
        else:
            l = (l + r) // 2
    return r + 1


n, d, a = map(int, input().split())
xh = sorted(list(map(int, input().split())) for _ in range(n))
x = [i for i, j in xh]
h = [j for i, j in xh]

bomb, bsum, ans = [0] * (n + 1), [0] * (n + 1), 0
for i, xi in enumerate(x):
    j = binary(n, x, xi + 2 * d) - 1
    bsum[i] += bsum[i - 1] + bomb[i]
    bnum = max(ceil(h[i] / a - bsum[i]), 0)
    bomb[i] += bnum
    bomb[j] -= bnum
    bsum[i] += bnum
    ans += bnum
print(ans)


Measured memory_bytes: 63620
res = []
gets.chomp.to_i.times do 
    a = gets.chomp.split(" ").map { |i| i.to_i }
    if a[0] == 0
        res.push(a[1])
    elsif a[0] == 2
        res.pop
    elsif a[0] == 1
        puts res[a[1]]
    end
end


Measured memory_bytes: 8540
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  string a;
  cin >> a;
  ll b=a.size();
  if(a[b-1]=='s'){
    a.push_back('e');
    a.push_back('s');
  }
  else{
    a.push_back('s');
  }
  cout << a <<endl;
}
  

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

int arr[3][3];

int main(void)
{
        for(int i = 0; i< 3; i++)
                for(int j =0; j<3;j++)
                        cin >> arr[j][i];

        int n;
        cin >>n;
        int bingo[n];
        for(int i =0; i<n;i++)
        {
                cin >> bingo[i];
        }
        for(int i= 0;i< 3; i++){
                for(int j=0;j<3;j++){
                        for(int a = 0; a< n;a++)
                        {
                                if(arr[j][i] == bingo[a])
                                {
                                        arr[j][i] =0;
                                        break;
                                }
                        }
                }
        }
        bool ans = false;  
        if(arr[0][0] == 0 && arr[0][1] ==0&&arr[0][2]==0)
                ans = true;
        else if(arr[1][0] ==0 && arr[1][1] == 0 && arr[1][2]==0)
                ans = true;
        else if(arr[2][0] ==0 && arr[2][1] == 0 && arr[2][2]==0)
                ans = true;
        else if(arr[0][0] ==0 && arr[1][0] == 0 && arr[2][0]==0)
                ans = true;
        else if(arr[0][1] ==0 && arr[1][1] == 0 && arr[2][1]==0)
                ans = true;
        else if(arr[0][2] ==0 && arr[1][2] == 0 && arr[2][2]==0)
                ans = true;
        else if(arr[0][0] ==0 && arr[1][1] == 0 && arr[2][2]==0)
                ans = true;
        else if(arr[0][2] ==0 && arr[1][1] == 0 && arr[2][0]==0)
                ans = true;


        if(ans == true)
        {
                cout << "Yes" << endl;
        }
        else if(ans == false){
                cout << "No" << endl; 
        }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

// 配るDP
ll dp1(const vector<ll> &values, const vector<ll> &weights,
       vector<vector<ll>> &dp, ll N, ll W) {
  for (ll i = 0; i < N; i++) {
    for (ll w = 0; w < W + 1; w++) {
      if (w + weights[i] <= W) {
        dp[i + 1][w + weights[i]] =
            max(dp[i][w] + values[i], dp[i][w + weights[i]]);
      }

      dp[i + 1][w] = max(dp[i][w], dp[i + 1][w]);
    }
  }

  ll ans = 0;
  for (auto d : dp[N]) {
    ans = max(ans, d);
  }

  return ans;
}

ll dp2(const vector<ll> &values, const vector<ll> &weights,
       vector<vector<ll>> &dp, ll N, ll W) {
  for (ll i = 0; i < N; i++) {
    for (ll w = 0; w < W + 1; w++) {
      if (w - weights[i] >= 0) {
        dp[i + 1][w] = max(dp[i][w - weights[i]] + values[i], dp[i][w]);
      } else {
        dp[i + 1][w] = dp[i][w];
      }
    }
  }

  ll ans = 0;
  for (auto d : dp[N]) {
    ans = max(ans, d);
  }

  return ans;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  ll N, W;
  cin >> N >> W;

  vector<ll> values(N);
  vector<ll> weights(N);

  for (ll i = 0; i < N; i++) {
    cin >> weights[i] >> values[i];
  }

  vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));

  // for (ll i = 0; i < N + 1; i++) {
  //   for (ll w = 0; w < W + 1; w++) {
  //     cout << dp[i][w] << " ";
  //   }
  //   cout << endl;
  // }

  cout << dp2(values, weights, dp, N, W) << endl;

  return 0;
}


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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			while (n-- != 0)
			{
				int o = 0, r = 0, p = 0;
				while (o != 3)
				{
					var s = Console.ReadLine();
					if (s == "OUT") o++;
					else if (s == "HIT")
					{
						if (r < 3)
							r++;
						else
							p++;
					}
					else if (s == "HOMERUN")
					{
						p += r + 1;
						r = 0;
					}
				}
				Console.WriteLine(p);
			}
		}
	}
}

Measured memory_bytes: 5612
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
using namespace std;

struct Edge
{
	int to;
	int i;
};

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

	vector<vector<Edge>> ab(n + 1);
	for (int i = 1; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		ab[a].push_back(Edge{ b, i });
		ab[b].push_back(Edge{ a, i });
	}

#if 0
	vector<int> ret(n, 0);
	stack<int> si;
	si.push(1);
	cout << 1 << endl;
	while (!si.empty())
	{
		int c = 1;
		const int& t = si.top();
		int next = -1;
		for (auto& e : ab[t]) {
			if (ret[e.i] == 0) {
				ret[e.i] = c;
				next = e.to;
				break;
			}
		}

		if (next != -1) {
			cout << next << endl;
			si.push(next);
		}
		else {
			si.pop();
		}
	}
#else
	vector<int> ret(n, 0);
	queue<int> qi;
	qi.push(1);
	while (!qi.empty())
	{
		const int& t = qi.front();
		int c = 1;
		int outc = 0;
		for (auto& e : ab[t]) {
			if (ret[e.i] != 0) {
				outc = ret[e.i];
			}
		}
		for (auto& e : ab[t]) {
			if (c == outc) {
				c++;
			}
			if (ret[e.i] == 0) {
				ret[e.i] = c++;
				qi.push(e.to);
			}
		}

		if (ret[0] < c - 1) {
			ret[0] = c - 1;
		}

		qi.pop();
	}
#endif

	for (auto& i : ret) {
		cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 6912
import java.util.*;

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

        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();

            if(x == 0 && y == 0){
                break;
            }else{
                if(x < 3 || y < 3){
                for(int i=0;i<x;i++){
                    for(int j=0;j<y;j++){
                        System.out.print("#");
                    }
                    System.out.println();
                }
                System.out.println();
                }else{
                    for(int l=0;l<y;l++) System.out.print("#");
                    System.out.println();                    
                    for(int i=1;i<x-1;i++){
                        System.out.print("#");
                        for(int j=1;j<y-1;j++){
                            System.out.print(".");
                        }
                        System.out.println("#");
                    }
                    for(int l=0;l<y;l++) System.out.print("#");
                    System.out.println();
                    System.out.println();
                }
            }
        }
        sc.close();
    }
}


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

namespace ABC_C
{
    class C073
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            Dictionary<int, int> dic = new Dictionary<int, int>();
            for(int i = 0; i < N; i++)
            {
                int A = int.Parse(Console.ReadLine());
                if (!dic.ContainsKey(A)) dic.Add(A, 0);
                dic[A]++;
            }
            int count = dic.Values.Count(x => x % 2 == 1);
            Console.WriteLine(count);
        }

    }
}


Measured memory_bytes: 21212
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=1e9+7;
LL f[110][110][2],n,h[110];
bool vis[110][110];
LL Pow(LL a,LL b)
{
	LL ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;b>>=1;
	}
	return ans;
}
void solve(LL l,LL r,LL s)
{
	//printf("solve:%lld %lld %lld\n",l,r,s);
	bool flag=true;
	for(LL i=l;i<r;i++) if(h[i]!=h[i+1]) flag=false;
	if(flag)
	{
		LL c=Pow(2,r-l+1);
		f[l][r][1]=(c-2+mod)%mod;
		f[l][r][0]=Pow(2,h[l]-s+1);
		//printf("f:%lld %lld\n",f[l][r][0],f[l][r][1]);
		return;
	}
	LL t=1e9+10,cnt=0;
	for(LL i=l;i<=r;i++)
	{
		if(h[i]<t) t=h[i],cnt=0;
		if(t==h[i]) cnt++;
	}
	LL p=l,g0=2,g1=1;
	//printf("t:%lld\n",t);
	while(p<=r)
	{
		while(p<=r&&h[p]==t) p++;
		LL q=p;
		while(q<=r&&h[q]!=t) q++;
		if(p<=r)
		{
			solve(p,q-1,t+1);
			(g0*=f[p][q-1][0])%=mod;
			(g1*=(f[p][q-1][0]*2+f[p][q-1][1])%mod)%=mod;
		}
		//printf("g0 g1:%lld %lld\n",g0,g1);
		p=q;
	}
	//printf("g1:%lld\n",g1);
	(g1*=Pow(2,cnt))%=mod;g1-=g0;(g1+=mod)%=mod;
	(g0*=Pow(2,t-s))%=mod;
	//printf("now:%lld %lld %lld %lld %lld\n",l,r,s,g0,g1);
	f[l][r][0]=g0;f[l][r][1]=g1;
}
int main()
{
	scanf("%lld",&n);
	for(LL i=1;i<=n;i++) scanf("%lld",&h[i]);
	memset(vis,false,sizeof(vis));
	LL tot=1;
	for(LL i=1;i<=n;i++) if(h[i]>h[i-1]&&h[i]>h[i+1])
	{
		LL t=max(h[i-1],h[i+1]);
		(tot*=Pow(2,h[i]-t))%=mod;h[i]=t;
	}
	solve(1,n,1);
	printf("%lld",tot*(f[1][n][0]+f[1][n][1])%mod);
}

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

   map<int, int> student;

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

   for (int i = 1; i < N; i++) {
     cout << student[i] << " ";
   }
   cout << student[N] << endl;
 }


Measured memory_bytes: 5504
#include<stdio.h>
int main (void){
 int a,b,c,x;
 scanf("%d %d %d",&a,&b,&c);
 
 if(a>c){
  x = c;
  c = a;
  a = x;
 }
 if(b>c){
  x = c;
  c = b;
  b = x;
 }
 if(a>b){
  x = b;
  b = a;
  a = x;
 }
 printf("%d %d %d\n",a,b,c);
 return 0;
}

Measured memory_bytes: 596
import sys
N = int(input())
arr = list(map(int, input().split()))

for i in range(len(arr)):
    if arr[i] % 2 == 0 and (arr[i] % 3 != 0 and arr[i] % 5 != 0):
        print("DENIED")
        exit()

print("APPROVED")

Measured memory_bytes: 3060
s = str(input())
for i in range(len(s)) :
    if s[i] == 'A' :
        leftCnt = i
        break
for i in range(len(s)) :
    if s[-1-i] == 'Z' :
        rightCnt = len(s) - i
        break
print(rightCnt - leftCnt)

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;

    if(c >= a && c <= b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N, M;
  while (cin >> N >> M, N+M) {
    vector<int> h(N), w(M);
    int totalH = 0, totalW = 0;
    for (int i = 0; i < N; i++) {
      cin >> h[i];
      totalH += h[i]; 
    }
    for (int i = 0; i < M; i++) {
      cin >> w[i];
      totalW += w[i];
    }

    vector<int> height(totalH+1, 0), width(totalW+1, 0);
    for (int i = 0; i < N; i++) {
      int k = h[i];
      height[k]++;
      for (int j = i+1; j < N; j++) {
        k += h[j];
        height[k]++;
      }
    }
    for (int i = 0; i < M; i++) {
      int k = w[i];
      width[k]++;
      for (int j = i+1; j < M; j++) {
        k += w[j];
        width[k]++;
      }
    }
  
    int ans = 0;
    for (int i = 1; i <= min(totalH, totalW); i++) {
      ans += height[i]*width[i];
    }
    cout << ans << endl;
  }
}




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


long long mod = 1e9+7;
long long N, A[100000];
long long invs[100001], invs_sum[100001];

long long pow(long long a, long long x){
    if(x == 0){
        return 1;
    }else if(x == 1){
        return a % mod;
    }
    a %= mod;
    return pow(a*a%mod, x/2) * ((x%2)?a:1)%mod;
}

long long inv(long long x){
    return pow(x, mod-2) % mod;
}

long long fac(long long n){
    if(n == 0){
        return 1;
    }
    return n % mod * fac(n-1) % mod;
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 1; i <= 100000; i++){
        invs[i] = inv(i);
        invs_sum[i] = invs_sum[i-1] + invs[i];
    }

    long long ans = 0;
    for(int j = 0; j < N; j++){
        long long p = invs_sum[N-j] + invs_sum[j+1] + (mod - 1);
        long long tmp = (A[j] % mod) * (p % mod) % mod;
        ans += tmp;
        ans %= mod;
    }
    ans *= fac(N);
    ans %= mod;
    cout << ans << endl;
    
    
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const double pi=3.1415926535;

int main(){
  ll n,m,a;
  cin>>n>>m;
  rep(i,0,m){
    cin>>a;
    n-=a;
  }
  if(n<0) co(-1);
  else co(n);
  
  return 0;
}

Measured memory_bytes: 3620
#include "stdio.h"

int main()
{
	//左から、横の長さ（共通）、Aの左端の位置、Bの左端の位置、あと入れ替え用と出力する距離
	int W = 0, A = 0, B = 0, save=0, length=0;

	//標準入力後、簡単にするためにAがBより左になるように入れ替える。
	scanf("%d %d %d", &W, &A, &B);
	if (A > B) {
		save = A;
		A = B;
		B = save;
	}

	//AはBより左にあるので、Aの右端とBの左端の位置関係を考える。
	//その距離が必要な移動距離である。ただし右端のほうが前に出ていたら移動しなくていいので距離0になる。
	//例によると点と点で接しているのも距離0になる。
	if ((A + W) >= B)
		length = 0;
	if ((A + W) < B)
		length = B - (A + W);

	/*
	//入れ替えできてるか表示テスト →OK
	printf("%d %d %d", W, A, B);
	*/

	//解答となる距離を出力
	printf("%d",length);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N+1);
    for(int i=0; i<=N; i++) {
        cin >> A.at(i);
    }
    vector<int> B(N);
    for(int i=0; i<N; i++) {
        cin >> B.at(i);
    }
    long long int ans = 0;
    for(int i=N-1; i>=0; i--) {
        int kill = min(A.at(i+1), B.at(i));
        ans += kill;
        B.at(i) -= kill;
        kill = min(A.at(i), B.at(i));
        A.at(i) -= kill;
        ans += kill;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() {
    ll n, c;
    scanf("%lld %lld", &n, &c);
    vector<pll> vec(n);
    forn(i, 0, n)
        scanf("%lld %lld", &vec[i].first, &vec[i].second);
    
    vector<ll> back(n);
    ll curGain = 0, ans = 0, prevPos = c;
    for (ll i = n - 1; i > -1; i--) {
        if (i < n - 1)
            back[i] = max(back[i + 1], curGain);
        pll cur = vec[i];
        curGain += cur.second - (prevPos - cur.first);
        ans = max(ans, curGain);
        prevPos = cur.first;
    }
    
    vector<ll> forward(n);
    curGain = prevPos = 0;
    for (ll i = 0; i < n; i++) {
        if (i > 0)
            forward[i] = max(forward[i - 1], curGain);
        pll cur = vec[i];
        curGain += cur.second - (cur.first - prevPos);
        ans = max(ans, curGain);
        prevPos = cur.first;
    }
    
    curGain = prevPos = 0;
    forn(i, 0, n) {
        pll cur = vec[i];
        curGain += cur.second - (cur.first - prevPos);
        ans = max(ans, max(curGain, curGain - cur.first + back[i]));
        prevPos = cur.first;
    }
    
    curGain = 0;
    prevPos = c;
    for (ll i = n - 1; i > -1; i--) {
        pll cur = vec[i];
        curGain += cur.second - (prevPos - cur.first);
        ans = max(ans, max(curGain, curGain - (c - cur.first) + forward[i]));
//        cout << curGain << " " << curGain - (c - cur.first) + forward[i] << " " << forward[i] << endl;
        prevPos = cur.first;
    }

    printf("%lld\n", ans);
    return 0;
}


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

int main(){
    int A,B;
    cin>>A>>B;
    cout<<A*B<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100000 + 50;
using namespace std;
int a[MAXN];
int b[MAXN];
int main()
{
	//freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
	int n;
	while(cin>>n){
		memset(b,0,sizeof(b));
	int idx=0;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		if(x<=100000)
		{
			a[idx++]=x;
			b[x]++;
		}
		else ans++;
	}
	//cout<<b[1]<<endl;

	for(int i=0;i<idx;i++)
	{
		if(b[a[i]]>a[i])
			{ans+=(b[a[i]]-a[i]);b[a[i]]=0;}
		else if(b[a[i]]<a[i])
			{ans+=b[a[i]];b[a[i]]=0;}
		else continue;
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	}
	
}

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

using namespace std;
typedef long long ll;
#define DBG(v) cerr << #v << " = " << (v) << endl;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &x:a)
        cin >> x;


    int res = INT_MAX;

    const int total = accumulate(a.begin(), a.end(), 0);
    int curr = 0;
    for (int x: a) {
        curr+= x;
        res = min(res, abs((total - curr) - curr));
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long long lcm(int a,int b){
    if(b>a){
        int tmp=b;
        b=a;
        a=tmp;
    }
    long long inia=a,inib=b;
    int r=a%b;
    while(r>0){
        a=b;
        b=r;
        r=a%b;
    }
    return inia*inib/b;
}
int main()
{   int c,d;
    long long a,b;
    scanf("%lld%lld",&a,&b);
    scanf("%d%d",&c,&d);
    long long co=lcm(c,d);
    long long ans=b-a+1;
    long long sub=0;
    sub+=(b/c+b/d-b/co);
    sub-=((a-1)/c+(a-1)/d-(a-1)/co);
    printf("%lld",ans-sub);
    return 0;
}


Measured memory_bytes: 128
n = int(input())

S = [[0 for i in range(26)] for j in range(n)]

for i in range(n):
    seek = 0
    s = input().rstrip()
    for x in s:
        S[i][ord(x) - 97] += 1

ans = ''
for i in range(26):
    m = 51
    for j in range(n):
        m = min(m, S[j][i])
    ans += chr(i + 97) * m

print(ans)


Measured memory_bytes: 3060
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	string s;
	cin >> s;
	ll n = s.size();

	rep(i, n/2){
		if(s[i] != s[n-i-2]){
			co(-1);
			return 0;
		}
	}
	if(s[n-1] == '1' || s[0] == '0'){
		co(-1);
		return 0;
	}
	s[n-1] = '1';

	ll p = 1;
	repr(i, n){
		if(!i) break;
		if(s[i-1] == '1'){
			co({p, n-i+1});
			p = n-i+1;
		}else co({p, n-i+1});
	}

	return 0;
}


Measured memory_bytes: 1664
import heapq

def main():
    N = int(input())
    A = list(map(int, input().split()))
    s = A[:N]

    t = A[2*N:]
    t = [-1*x for x in t]
    heapq.heapify(s)
    heapq.heapify(t)
    n = [0] * (N+1)
    m = [0] * (N+1)
    n[0] = sum(s)
    m[N] = - sum(t)
    for k in range(1, N+1):
        tmp = A[N-1+k]
        a = heapq.heappushpop(s, tmp)
        n[k] = n[k-1] + tmp - a

    for k in range(N-1, -1, -1):
        tmp = - A[N+k]
        a = heapq.heappushpop(t, tmp)
        m[k] = m[k+1] - tmp + a
    ans = -float("inf")
    for k in range(N+1):
        ans = max(ans, n[k]-m[k])
    print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 43872
n=int(input())
ene = list(map(int,input().split()))
power = list(map(int,input().split()))
ans=0
for i in range(n-1):
  ans+=min(power[i],ene[i])
  if ene[i]<power[i]:
    ans+=min((power[i]-ene[i]),ene[i+1])
    ene[i+1]=max(ene[i+1]-(power[i]-ene[i]),0)
ans+=min(power[-1],ene[-2])
if power[-1]>ene[-2]:
  ans+=min(ene[-1],(power[-1]-ene[-2]))
print(ans)

Measured memory_bytes: 19004
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
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 sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

double solve(double a) {
	vector<double> s(10);
	s[0] = a;
	FOR(i, 1, 10) {
		if (i % 2)s[i] = s[i - 1] * 2.;
		else s[i] = s[i - 1] / 3.;
	}

	double ret = accumulate(all(s), 0.);
	return ret;
}

int main() {
	double a;
	while (cin >> a) {
		printf("%.20f\n", solve(a));
	}
}


Measured memory_bytes: 3096
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var N, M int
	con.Scan(&N, &M)
	a := make([]int, N)
	b := make([]int, N)
	c := make([]int, M)
	d := make([]int, M)
	for i := 0; i < N; i++ {
		con.Scan(&a[i], &b[i])
	}
	for i := 0; i < M; i++ {
		con.Scan(&c[i], &d[i])
	}
	for i := 0; i < N; i++ {
		mind := int(1e9)
		minj := -1
		for j := 0; j < M; j++ {
			x := a[i] - c[j]
			if x < 0 {
				x = -x
			}
			y := b[i] - d[j]
			if y < 0 {
				y = -y
			}
			if x+y < mind {
				mind = x + y
				minj = j
			}
		}
		con.Println(minj + 1)
	}
	return nil
}


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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while(cin >> n, n){
        vector<string> s(n);
        rep(i, 0, n){
            cin >> s[i];
        } 
        vector<int> l(n);
        rep(i, 0, n){
            bool f = true;
            for(int j = s[i].size() - 1; j >= 0; j--){
                if(s[i][j] == '.'){
                    if(f){
                        s[i][j] = '+';
                        l[i] = j + 1;
                        f = false;
                    }else{
                        s[i][j] = ' ';
                    }
                }
            }
        }
        rep(i, 0, n){
            int r = i;
            rep(j, i + 1, n){
                if(l[j] == l[i]){
                    r = j; break;
                }
                if(l[j] < l[i]){
                    break;
                }
            }
            rep(j, i + 1, r){
                s[j][l[i] - 1] = '|';
            }
        }
        rep(i, 0, n){
            cout << s[i] << endl;
        }
    }   
}


Measured memory_bytes: 3412
#include<bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1,
                      5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<a.at(k-1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const unsigned long long MOD=1e9+7;
struct mat{
	unsigned long long a[55][55],n;
	mat(){
		memset(a,0,sizeof a);
		n=0;
	}
	inline mat operator * (const mat &b) const{
		mat res;
		res.n=n;
		for(int i=0;i<n;i++){
			for(int k=0;k<n;k++){
				for(int j=0;j<n;j++){
					res.a[i][j]+=(a[i][k]*b.a[k][j])%MOD;
				}
			}
		}
		for(int i=0;i<n;i++)for(int j=0;j<n;j++) res.a[i][j]%=MOD;
		return res;
	}
};
unsigned long long quickpow(mat &a,long long k){
	mat res,now;
	res.n=now.n=a.n;
	for(int i=0;i<res.n;i++) res.a[i][i]=1;
	for(int i=0;i<a.n;i++)for(int j=0;j<a.n;j++) now.a[i][j]=a.a[i][j];
	while(k){
		if(k&1) res=res*now;
		now=now*now;
		k>>=1;
	}
	unsigned long long ans=0;
	for(int i=0;i<res.n;i++)for(int j=0;j<res.n;j++) ans=(ans+res.a[i][j])%MOD;
	return ans;
}
mat ed;
int main(){
	long long k;
	cin>>ed.n>>k;
	for(int i=0;i<ed.n;i++){
		for(int j=0;j<ed.n;j++) cin>>ed.a[i][j];
	}
	cout<<quickpow(ed,k);
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
    int i,a,b,c;
    scanf("%d",&a);

    b = a /100;
    c = (a-b*100) /10;

    if(b == 7){
        printf("Yes");
    }else if(c == 7){
        printf("Yes");
    }else if(a-b*100-c*10==7){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 1708
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (true) {
      String x = sc.next();
      if (x.equals("0")) {
        break;
      }
      int i, j;
      int sum = 0;
      char s;
      for (i = 0; i < x.length(); i++) {
        s = x.charAt(i);
        j = s - '0';
        sum += j;
      }
      System.out.println(sum);
    }
  }
}



Measured memory_bytes: 26204
#include<bits/stdc++.h>
using namespace std;
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define vi vector<int>

int main()
{
    faster;
    ll a,b;
    cin>>a>>b;
    if((a*b)%2==1) cout<<"Odd"<<endl;
    else cout<<"Even"<<endl;

    return 0;
}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 210

// 約数
ll Cd[MAX_N] = {};

signed main()
{
    int N;
    cin >> N;

    // 約数の列挙
    for(int i = 1; i < MAX_N; ++i) {
        for(int j = 1; j <= i; ++j) {
            if(i % j == 0) { Cd[i]++; }
        }
    }

    int ans = 0;
    for(int i = 1; i <= N; ++i) { if(i % 2 != 0 && Cd[i] == 8) { ans++; } }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(int[]), x = rd[0], a = rd[1], b = rd[2];
  if (b-a <= 0)
    writeln("delicious");
  else if (b-a <= x)
    writeln("safe");
  else
    writeln("dangerous");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#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;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;
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;}
//struct area

//function area

//main area
int main(){
    int n;
    cin >> n;
    cout << abs(n-1) << endl;
}
/*



*/

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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> height(n);
    for(int i=0;i<n;i++)
    cin>>height[i];
    
    vector<int> ans(n);
    ans[0]=0;
    ans[1]=abs(height[1]-height[0]);
    for(int i=2;i<n;i++)
    {
        int a=INT_MAX;
        for(int j=1;j<=k&&(i-j)>=0;j++)
        {
            a = min(a,abs(height[i-j]-height[i])+ans[i-j]);
        }
        ans[i]=a;
    }
    cout<<ans[n-1];
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

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

  int64 N, K, S, T, L;
  cin >> N >> K >> S >> T;
  vector<int64> A, c(N+1, 0);
  auto comb = make_v<int64>(51, 51);
  fill_v<int64>(comb, 0);
  comb[0][0] = 1;
  REP(i, 50) {
    REP(j, i+1) {
      comb[i+1][j] += comb[i][j];
      comb[i+1][j+1] += comb[i][j];
    }
  }
  REP(i, N+1) {
    FOR(j, 1, min(K, N) + 1) {
      c[i] += comb[i][j];
    }
  }

  REP(i, N) {
    int64 a;
    cin >> a;
    int b = 0, cnt = 0;
    REP(i, 18) {
      if (((S >> i & 1) && !(a >> i & 1)) || (!(T >> i & 1) && (a >> i & 1))) {
        b = -1;
        break;
      }
      if ((S >> i & 1) || !(T >> i & 1)) continue;
      b |= (a >> i & 1) << (cnt++);
    }
    if (b != -1) {
      A.push_back(b);
      L = cnt;
    }
  }

  int64 res = 0;

  vector<int> cnt(1 << L, 0);
  REP(M, 1 << L) {
    REP(i, A.size()) {
      cnt[A[i] & M]++;
    }
    REP(i, A.size()) {
      res += (__builtin_popcount(M) % 2 ? -1 : 1) * c[cnt[A[i] & M]];
      cnt[A[i] & M] = 0;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 4240
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int n;cin >> n;
    int sum=0;
    set<int> st;
    for (int i = 0; i < n; i++) {
        int a;cin >> a;
        sum^=a;
        int k=0;
        while(a){
            if(a&1) break;
            k++;
            a>>=1;
        }
        st.insert(k);
    }
    int ans=0;
    for (int i = 30; i >= 0; i--) {
        if(sum&(1<<i)){
            ans++;
            if(st.find(i)!=st.end()) sum^=(1<<(i+1))-1;
            else{
                puts("-1");
                return 0;
            }

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


Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
    set<int> s;
    ll n;scanf("%lld",&n);
    for (int i = 0; i < n; ++i)
    {
        int a;cin >> a;
        if(s.find(a) != s.end())s.erase(a);
        else s.insert(a);
    }
    cout << s.size() << endl;

}


Measured memory_bytes: 4864
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int N;
int a[100004][3];
int dp[100004][3];
int main(){
	cin>>N;
	for (int i=0;i<N;i++) 
		for (int j=0;j<3;j++)
			cin>>a[i][j];
	for (int i=0;i<3;i++) dp[0][i]=a[0][i];
	for (int i=1;i<N;i++){
		for (int j=0;j<3;j++){
			for (int k=0;k<3;k++) if (k!=j){
				dp[i][j]=max(dp[i-1][k]+a[i][j],dp[i][j]);
			}
		}
	}
	int ans=0;
	for (int i=0;i<3;i++)
		ans=max(ans,dp[N-1][i]);
	cout<<ans;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char c = sc.next().charAt(0);
		sc.close();

		String answer;

		switch (c) {
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			answer = "vowel";
			break;
		default:
			answer = "consonant";
			break;
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 22868
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int[] h = new int[n];
        for(int i=0;i<n;i++)h[i] = fs.nextInt();
        for(int i=n-1;i>=1;i--){
            if(h[i]+1==h[i-1]){
                h[i-1]--;
            }else if(h[i-1] > h[i]){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
    static class FastScanner{
        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;
        }

        public boolean hasNext(){
            while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
            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();
            }
        }
        public int nextInt(){
            long nl = nextLong();
            if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
            return (int)nl;
        }
        public double nextDouble(){return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 22416
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

struct UnionFind {
    vector<int> r;

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

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

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


int main() {
    int n, m;
    cin >> n >> m;
    UnionFind UF(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        UF.unite(a, b);
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans = max(ans, UF.size(i));
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	n %= 1000;

	if(n == 0) cout << 0;
	else cout << 1000 - n;
	
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int a[100005];
int b[100005];

int main(){
	int n;
	cin >> n;
	int cnt = 1;
	for(int i = 0 ; i < n ; i++)
	{
		cin >> a[i];
		b[a[i] - 1] = cnt;
		cnt++;
	}
	for(int i = 0 ; i < n ; i++)
		cout << b[i] << " ";
}
    

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

auto chmin = [](auto&& l, auto r) { return r < l ? l = r, 1 : 0; };

constexpr int inf = 0x3f3f3f3f;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for_each(begin(a), end(a), [](int& e) { cin >> e; });
  for_each(begin(b), end(b), [](int& e) { cin >> e; });
  vector<vector<int>> dp(1 << n, vector<int>(n, inf));
  for (int i = 0; i < n; ++i) {
    dp[1 << i][i] = 0;
  }
  auto f = [&](int i, int to) {
    return ~(to - i) & 1 ? a[i] : b[i];
  };
  for (int bt = 1; bt < 1 << n; ++bt) {
    for (int i = 0; i < n; ++i) {
      if (bt >> i & 1) {
        for (int j = 0; j < n; ++j) {
          if (~bt >> j & 1) {
            int to = __builtin_popcount(bt);
            if (f(i, to - 1) > f(j, to)) {
              continue;
            }
            int c = __builtin_popcount(bt >> j);
            chmin(dp[bt | 1 << j][j], dp[bt][i] + c);
          }
        }
      }
    }
  }
  int res = *min_element(begin(dp.back()), end(dp.back()));
  cout << (res < inf ? res : -1) << '\n';
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
int N;
int main(){
    cin>>N;int V[N],C[N];for(int  i=0;i<N;i++)cin>>V[i];for(int i=0;i<N;i++)cin>>C[i];
    int ans;
    for(int i=0;i<N;i++)(V[i]-C[i]>0?ans+=V[i]-C[i]:ans=ans);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long n;
    cin >> n;
    long long ans=n;
    for(int i=1;i<=sqrt(n);++i) {
        if(n%i==0) {
            ans=min(ans,abs(i-1)+abs((n/i)-1));
        }
    }

    cout << ans << endl;
}

    


Measured memory_bytes: 384
def main():
    n = int(input())
    b = [i for i in map(int, input().split())]
    b.append(max(b)+1)
    a = []
    for j, num in enumerate(b):
        a.append(min(b[j-1], b[j]))

    print(sum(a))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

const vector<int> dx = {1,0,-1,0};
const vector<int> dy = {0,1,0,-1};

int main()
{
  int h,w;
  cin >> h >> w;
  vector<string> mass(h);
  for(int i=0;i<h;i++) cin >> mass[i];

  queue<pair<int,int>> que;
  vector<vector<int>> dist(h,vector<int>(w));
  for(int i=0;i<h;i++) dist[i].assign(w,-1);

  int black = 0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(mass[i][j] == '#') black++;
    }
  }

  //初期条件
  que.push(make_pair(0,0));
  dist[0][0] = 0;

  while(!que.empty()){
    pair<int,int> p = que.front();
    que.pop();

    int x = p.first;
    int y = p.second;

    for(int dir=0;dir<4;dir++){
      int nx = x + dx[dir];
      int ny = y + dy[dir];

      if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;

      if(dist[nx][ny] != -1) continue;
      if(mass[nx][ny] == '#') continue;

      dist[nx][ny] = dist[x][y] + 1;
      que.push(make_pair(nx,ny));
    }
  }

  if(dist[h-1][w-1] == -1) cout << "-1\n";
  else cout << h*w - black - (dist[h-1][w-1]+1) << endl;

}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		int N = 0, ans = 0;

		Scanner scanner = new Scanner(System.in);
		
		N = scanner.nextInt();
		int[] benefit = new int[N];
		
		for (int i = 0; i < N; i++) {
			benefit[i] = scanner.nextInt();
		}
		
		for (int i = 0; i < N; i++) {
			benefit[i] = benefit[i] - scanner.nextInt();
			ans = Math.max(ans, ans + benefit[i]);
		}
		
		scanner.close();
		
		System.out.println(ans);
		
		
	}

}


Measured memory_bytes: 22868