akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Scanner;
class Main
{

	public static void main(String[] args)throws IOException
	{
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt(),w=sc.nextInt();
		int [] al=new int [26];
		String[] a=new String[h];
		for(int i=0;i<h;i++)
		{
			a[i]=sc.next();
			for(int j=0;j<w;j++)
			{
				String buf=a[i].substring(j, j+1);
				char[] alp=buf.toCharArray();
				int cnt=0;
				char z='a';
				while(alp[0]!=z)
				{
					z++;cnt++;
				}
				al[cnt]++;
			}
		}

		int hh=h/2;int ww=w/2;int end=0;
		if(h%2==1&&w%2==1)
		{
			for(int x=0;end==0&&x<hh*ww;x++)
			{
				for(int i=0;i<26;i++)
				{
					if(al[i]>=4){al[i]-=4;break;}
					if(i==25){end=1;}
				}
			}
			for(int x=0;end==0&&x<hh+ww;x++)
			{
				for(int i=0;i<26;i++)
				{
					if(al[i]>=2){al[i]-=2;break;}
					if(i==25){end=1;}
				}
			}
		}

		if(h%2==0&&w%2==0)
		{
			for(int x=0;end==0&&x<hh*ww;x++)
			{
				for(int i=0;i<26;i++)
				{
					if(al[i]>=4){al[i]-=4;break;}
					if(i==25){end=1;}
				}
			}
		}


		if(h%2==1&&w%2==0)
		{
			for(int x=0;end==0&&x<hh*ww;x++)
			{
				for(int i=0;i<26;i++)
				{
					if(al[i]>=4){al[i]-=4;break;}
					if(i==25){end=1;}
				}
			}
			for(int x=0;end==0&&x<ww;x++)
			{
				for(int i=0;i<26;i++)
				{
					if(al[i]>=2){al[i]-=2;break;}
					if(i==25){end=1;}
				}
			}
		}

		if(h%2==0&&w%2==1)
		{
			for(int x=0;end==0&&x<hh*ww;x++)
			{
				for(int i=0;i<26;i++)
				{
					if(al[i]>=4){al[i]-=4;break;}
					if(i==25){end=1;}
				}
			}
			for(int x=0;end==0&&x<hh;x++)
			{
				for(int i=0;i<26;i++)
				{
					if(al[i]>=2){al[i]-=2;break;}
					if(i==25){end=1;}
				}
			}
		}


		if(end==0){System.out.println("Yes");}
		else{System.out.println("No");}
	}

}

Measured memory_bytes: 26260
#include<bits/stdc++.h>
#define endl  "\n"
#define ll long long
#define PI acos(-1.0)
#define test cout<<"\n****\n"
#define precise fixed(cout);cout<<setprecision(12)
#define fast  ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using  namespace  std;


int main(){


    double n;
    cin>>n;

    ll res = 0;

    if(n/500>0){
        ll temp = floor(n/500);
        res = temp*1000;

        n = n - temp*500;

        if(n/5>0){
            ll temp2 = floor(n/5);
            res = res + (temp2*5);
        }
    } else{
        if(n/5>0){
            ll temp2 = floor(n/5);
            res = res + (temp2*5);
        }
    }

    cout<<res;




    return 0;
}

Measured memory_bytes: 3656
/*input
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef unsigned long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e3+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
ll dp[4][105][2];
int k;
string s;
ll rec(int cnt,int len,int same){
	if(cnt>k) return 0;
    if(len>=sz(s)){
        if(cnt==k) return 1;
        return 0;
    }
    if(dp[cnt][len][same]!=-1) return dp[cnt][len][same];
    ll ans=0;
    REP(i,10){
        if(same and i>s[len]-'0') break;
        if(i!=0){
            if(same and i==s[len]-'0') ans+=rec(cnt+1,len+1,same);
            else ans+=rec(cnt+1,len+1,0);
        }
        else{
            if(same and i==s[len]-'0') ans+=rec(cnt,len+1,same);
            else ans+=rec(cnt,len+1,0);        	
        }
    }
    return dp[cnt][len][same]=ans;
}
ll f(){
    REP(i,4) REP(j,105) REP(z,2) dp[i][j][z]=-1;
    ll ans=0;
    REP1(i,s[0]-'0'){
        ans+=rec(1,1,i==(s[0]-'0'));
    }
    for(int k=2;k<=sz(s);k++){
        ans+=9LL*rec(1,k,0);
    } 
    return ans;
}
int main(){
    cin>>s>>k;
    cout<<f();
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
  c[i] = v[i] - c[i]
  if(c[i] < 0):
    c[i] = 0
  ans += c[i]

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


int main() {
	ll n;
	cin >> n;
	ll a = (n + 1) / 2;
	cout << (double)a / n << endl;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
ll vis[200001]={0},ans=1;
void dfs(vll adj[],ll v)
{
    vis[v]=1;
    for(auto i:adj[v])
    {
        if(vis[i]==0)
        {
            ans++;
            dfs(adj,i);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,u,v,res=0;
    cin>>n>>m;
    vll adj[n+1];
    umll p;
    for(ll i=1;i<=m;i++)
    {
        cin>>u>>v;
        p[u]++;
        p[v]++;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(ll i=1;i<=n;i++)
    {
        if((p.find(i)!=p.end())&&(vis[i]==0))
        {
            res=max(ans,res);
            ans=1;
            dfs(adj,i);
        }
    }
    res=max(ans,res);
    cout<<res;
    return 0;
}


Measured memory_bytes: 33240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int R,B;
ll f[MAXN];
ll modpow(ll base, ll expo){
	ll res=1;
	while(expo>0){
		if(expo&1)res=res*base%MOD;
		base=base*base%MOD;
		expo>>=1;
	}
	return res;
}
ll nCr(int n, int r){
	if(r<0||r>n)return 0;
	return f[n]*modpow(f[n-r],MOD-2)%MOD*modpow(f[r],MOD-2)%MOD;
}
ll get(int k){
	ll res=1;
	res=res*nCr(B-1,k-1)%MOD;
	ll tmp=nCr(R-1,k-1)+nCr(R-1,k-2)+nCr(R-1,k-1)+nCr(R-1,k);
	res=res*tmp%MOD;
	//~ if(B%k==0&&R%k==0&&k>1)res=(res-1+MOD)%MOD;
	return res;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	f[0]=1;
	FOR(i,1,MAXN-1)f[i]=f[i-1]*i%MOD;
	cin>>R>>B;
	R-=B;
	if(R==0){
		cout<<"1\n";
		FOR(i,2,B){
			cout<<"0\n";
		}
		return 0;
	}
	FOR(i,1,B){
		cout<<get(i)<<"\n";
	}
}
/*
*/


Measured memory_bytes: 1792
import sys
input=sys.stdin.readline
#input = open(sys.argv[1], "r").readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    tmp = A.copy()
    mi = -1
    for j in range(2):
        A = tmp.copy()
        s = 0
        n = 0
        if j == 0: # 偶数番目までの和が正 ⇒ A[0] を負にする
            if A[0] >= 0:
                n += abs(A[0] +1)
                A[0] = -1
        else:   # 奇数番目までの和が正 ⇒ A[0] を正にする
            if A[0] <= 0:
                n += abs(A[0] -1)
                A[0] = 1
        s = A[0]
#        print(A)
        for i in range(1,N):
            if s * (s+A[i]) >= 0:
                if s < 0:
                    n += abs(-s+1 -A[i])
                    A[i] = -s+1
                else:
                    n += abs(-s-1 -A[i])
                    A[i] = -s-1
            s += A[i]
        if mi == -1:
            mi = n
        else:
            mi = min(mi, n)
    print(mi)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14336
import Data.List

ans' :: Int -> [[Int]] -> Maybe [Int]
ans' s [] = Just [s]
ans' s ([a,b]:xs) =
  let s' = s + a - b
      r  = ans' s' xs
  in
    if s' < 0
    then Nothing
    else
      case r of
        Just r' -> Just (s:r')
        Nothing -> Nothing

ans s c =
  let a = ans' s c
  in
    case a of
      Just a  -> maximum a
      Nothing -> 0

main = do
  _ <- getLine
  s <- getLine
  c <- getContents
  let s' = read s :: Int
      c' = map (map read) $ map words $ lines c :: [[Int]]
      o  = ans s' c'
  print o

Measured memory_bytes: 5508
N,M = gets.split.map &:to_i
Cakes = (0...N).map{ gets.split.map &:to_i }
S = [-1,+1]
sgns = S.map{ |s1| S.map{ |s2| S.map{ |s3| [s1,s2,s3] } } }.flatten(2)
p sgns.map{ |s1,s2,s3|
  vs = [0,0,0]
  Cakes.sort_by{ |x,y,z| s1*x + s2*y + s3*z }[0...M].each{ |x,y,z|
    vs[0] += x
    vs[1] += y
    vs[2] += z
  }
  vs.reduce(0){ |a,b| a.abs + b.abs }
}.max


Measured memory_bytes: 1916
using System;

class program
{
    public static void Main()
    {
        while (true)
        {
            char[] str = Console.ReadLine().ToCharArray();
            int sum = 0;

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

            for (int i = 0; i < str.Length; i++)
            {
                sum += int.Parse(str[i].ToString());
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 5672
#include <stdio.h>
#include <string.h>

int main(void) {
	int a, z;
	char s[200001];
	scanf("%s", s);
	for(int i=0; i<strlen(s); i++){
		if(s[i] == 'A'){
			a = i;
			break;
		}
	}
	for(int j=strlen(s)-1; j>=0; j--){
		if(s[j] == 'Z'){
			z = j;
			break;
		}
	}
	printf("%d", z-a+1);
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void){
    long long n;
    cin >> n;
    
    long long a[100000];
    int i;
    for(i = 0; i < n; i++){
        cin >> a[i];
    }
    
    sort(a, a + n);
    long long r = 0;
    for(i = 0; i < n; i++){
        if(abs(a[n - 1] - a[i] * 2) < abs(a[n - 1] - r * 2)){
            r = a[i];
        }
    }
    
    printf("%lld %lld\n", a[n - 1], r);
    
    return 0;
}


Measured memory_bytes: 1024
class Node
  attr_accessor :child, :visited
  def initialize
    @child = {}
  end
end

def visit(p, v, g)
  d = []
  dia = 0
  dmax = 0
  pos = v
  stack = [p, v]
  visited = {}
  visited[v] = true
  while stack.size > 1
    p = stack[-2]
    v = stack[-1]
    flag = true
    g[v].child.each{|dst, w|
      next if visited[dst]
      if dst != p
        visited[dst] = true
        stack << dst
        dia += w
        d << w
        flag = false
        break
      end
    }
    if flag == true
      break if d.size == 0
      if dmax < dia
        dmax = dia
        pos = v
      end
      stack.pop
      dia -= d.pop
    end
  end
  return dmax, pos
end

n = gets.to_i
g = Array.new(n){Node.new}
(n-1).times{
  s, t, w = gets.split.map(&:to_i)
  g[s].child[t] = w
  g[t].child[s] = w
}

r = visit(-1, 0, g)
t = visit(-1, r[1], g)

puts t[0]

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

using namespace std;

int main(){
  int N;
  cin >> N;
  if(N <= 9)
  {
    if(N == 2 || N == 4 || N ==5 || N == 7 || N == 9)
    {
      cout << "hon" << endl;
    }if(N == 0 || N == 1 || N == 6 || N == 8)
    {
      cout << "pon" << endl;
    }
    if( N == 3)
    {
      cout << "bon" << endl;
    }
    
  }
  if(N >= 10 && N <= 99)
  {
    N = N % 10;
    if(N == 2 || N == 4 || N ==5 || N == 7 || N == 9)
    {
      cout << "hon" << endl;
    }if(N == 0 || N == 1 || N == 6 || N == 8)
    {
      cout << "pon" << endl;
    }
    if( N == 3)
    {
      cout << "bon" << endl;
    }
    
  }
  if(N >= 100 && N <= 999)
  {
    N = N % 100;
    N = N % 10;
    if(N == 2 || N == 4 || N ==5 || N == 7 || N == 9)
    {
      cout << "hon" << endl;
    }if(N == 0 || N == 1 || N == 6 || N == 8)
    {
      cout << "pon" << endl;
    }
    if( N == 3)
    {
      cout << "bon" << endl;
    }
    
  }
  return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

int main(){

  long n;
  cin >> n;

  string ans ="";

  int i=0;
  while(n>0){
    long temp = n%26;
    if(temp==0){
      temp=26;
    }
    char a = temp+96;
    ans = a + ans;

    // n = (n-(long)pow(26.0, i)*temp)/26;
    n = (n-temp)/26;
    i++;
  }

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


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

using ll = long long;

constexpr int MAX_N = 1e5*2;
unsigned int A[MAX_N];

int main() {
  int N;
  cin >> N;
  for (int i{}; i < N; ++i)
    cin >> A[i];

  ll ans{};
  int sum{};
  int right{};
  for (int left{}; left < N; ++left) {

    while (right < N
      // rightを1進めるための満たすべき条件
      && sum + A[right] == (sum ^ A[right])
        ) {
      // 条件更新となる処理
      sum += A[right];
      ++right;
    }

    // 条件を満たすright取得時の処理
    ans += (right - left);

    if (left == right) {
      ++right;
    } else {
      // leftを1進めるときの処理
      sum -= A[left];
    }
  }

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


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <map>

using namespace std;

long cnt[300000];
long sum[300001];
long cumsum[300001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    long N;
    cin >> N;
    for(long i = 0; i < N; i++){
        long a;
        cin >> a;
        a--;
        cnt[a]++;
    }
    sort(cnt, cnt+N);
    for(long i = 0; i < N; i++){
        if(i == 0) cumsum[i] = cnt[i];
        else cumsum[i] = cumsum[i-1]+cnt[i];
    }
    
    cout << N << endl;
    for(long i = 2; i <= N; i++){
        long l = 0;
        long r = N;
        while(r-l > 1){
            long c = (l+r)/2;
            long *p = upper_bound(cnt, cnt+N, c);
            long m = p-cnt;
            long t = cumsum[m-1]+c*(N-m);
           // cout << c << ' ' << t << ' ' << m << endl;
            if(t >= c*i) l = c;
            else r = c;
        }
        cout << l << endl;
    }
}

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

using namespace std;

const int N = 5005;
const int mod = 1e9+7;
int add(int a, int b) {
	return a + b >= mod ? a + b - mod : a + b;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}
int fexp(int b, int e = mod - 2) {
	int ans = 1;
	while(e) {
		if(e & 1) ans = mul(ans, b);
		b = mul(b, b);
		e /= 2;
	}
	return ans;
}

int n, p[N];
int k;
vector<int> g[N];
int vis[N];

int dfs(int u) {
	int sz = 1;
	vis[u] = 1;
	for(int v : g[u]) if(!vis[v]) {
		sz += dfs(v);
	}
	return sz;
}

int sz[N];

int dp[N];

int main() {
	scanf("%d", &n);

	for(int i = 1; i <= n; i++) scanf("%d", p + i);

	for(int i = 1; i <= n; i++) {
		if(p[i] != -1) {
			g[ p[i] ].push_back(i);
			g[i].push_back(p[i]);
		}
	}

	for(int i = 1; i <= n; i++) {
		if(p[i] == -1) {
			sz[k++] = dfs(i);
		}
	}

	int ans = mul(n, fexp(n - 1, k));

	for(int i = 1; i <= n; i++) if(!vis[i]) {
		int tmp = dfs(i);
		ans = add(ans, mod - fexp(n - 1, k));
	}

	dp[0] = 1;
	for(int i = 0; i < k; i++) {
		for(int j = i + 1; j > 0; j--) {
			dp[j] = add(dp[j], mul(sz[i], dp[j - 1]));
		}
	}

	int fat = 1;
	for(int i = 2; i <= k; i++) {
		fat = mul(fat, i - 1);
		ans = add(ans, mod - mul(mul(dp[i], fat), fexp(n - 1, k - i)));
	}
	for(int i = 0; i < k; i++) {
		ans = add(ans, mod - mul(sz[i] - 1, fexp(n - 1, k - 1)));
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 4148
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int[] read= inta();
        if(read[0] >= read[1]){
            Write(1);
        }
        WriteLine(0);
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    static long[] longa(){
        string[] read_str_array = ReadLine().Split(' ');
        long[] return_long_array = new long[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_long_array;
    }
    static double[] doublea(){
        string[] read_str_array = ReadLine().Split(' ');
        double[] return_double_array = new double[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_double_array;
    }
    // A/B小数点以下切上
    static long divideup(long divided,long divid){
        long temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
    static long GCD(long a,long b){
        if(a < b){
            long temp = a;
            a = b;
            b = temp;
        }
        if(a % b == 0){ return b; }
        else{
            long temp = b;
            b = a%b;
            a = temp;
            return GCD(a,b);
        }
    }
    static long LCM(long a,long b){
        return a * b / GCD(a,b);
    }
}
//知見
// (string) hogestr -> (char[]) hoge
    // char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
    // string hoge = new string(hoge);
// Hashtable ×  Dictionary ○
// Dictionary hoge<string,int>
    // hoge.ContainsKey(string) -> return boolean
    // hoge[string] -> return int
    // hoge[int] -> CE
// Dictionary hoge<int1,int2>
    // hoge<int1,int2>: hoge[int1] -> return int2
    // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー　-> 幅優先 ???
// スタック -> 深さ優先 ???


Measured memory_bytes: 13140
import scala.io.StdIn.readInt

object Main {

  def getMax(i:Int,r:Int, minv:Int,maxv:Int):Int = {
    val m = r-minv
    if(i==1) {
      if(m>maxv) m else maxv
    }
    else {
      getMax(i-1,readInt,if(m<0) r else minv,if(m>maxv) m else maxv)
    }
  }

  def main(args:Array[String]) {
    val n = readInt
    val minv = readInt
    val maxv = Int.MinValue
    println(getMax(n-1,readInt,minv,maxv))
  }
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{
  gearup;
  string s,t; cin >> s >> t;
  ll res = 0;
  rep(i,s.size())if(s[i] == t[i])res++;
  out(res);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    string s;
    while(true){
        getline(cin,s);
        if(s == "END OF INPUT") break;
        string div;
        s+=' ';
        rep(i,s.size()){
            if(s[i] == ' '){
                cout << div.size();
                div = "";
            }else{
                div+=s[i];
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

using T = tuple<int, int, int>;
const int INF = 1001001001;

struct edge { int to, cost; };

int m, n, k, d;
int c[11];
vector<edge> g[111];
int dp[111][1 << 6];

int f(string s) {
    if (s == "H") return 0;
    if (s == "D") return n + m + 1;
    if (s[0] == 'C') return (s[1] - '0') + n;
    if (s[0] == 'L') {
        string x = s.substr(1, s.size() - 1);
        return stoi(x);
    }
}

void dijkstra(int s) {
    priority_queue<T, vector<T>, greater<T>> que;
    for (int i = 0; i < 111; i++) {
        for (int bit = 0; bit < (1 << 6); bit++) {
            dp[i][bit] = INF;
        }
    }
    dp[s][(1 << m) - 1] = 0;
    que.push(T(0, s, (1 << m) - 1));
    while (que.size()) {
        T t = que.top(); que.pop();
        int v = get<1>(t);
        int bit = get<2>(t);
        for (auto e : g[v]) {
            int u = -1;
            bool flag = true;
            for (int i = n + 1; i <= n + m; i++) {
                if (e.to == i) {
                    if (bit >> (i - n - 1) & 1) u = i - n - 1;
                    else {
                        flag = false;
                        break;
                    }
                }
            }
            if (!flag) continue;
            if (u == -1) {
                if (dp[e.to][bit] > dp[v][bit] + e.cost) {
                    dp[e.to][bit] = dp[v][bit] + e.cost;
                    que.push(T(dp[e.to][bit], e.to, bit));
                }
            } else {
                if (dp[e.to][bit ^ (1 << u)] > dp[v][bit] + e.cost - c[u]) {
                    dp[e.to][bit ^ (1 << u)] = dp[v][bit] + e.cost - c[u];
                    que.push(T(dp[e.to][bit ^ (1 << u)], e.to, bit ^ (1 << u)));
                }
            }

        }
    }
}

int main() {
    while (cin >> m >> n >> k >> d && (m != 0 || n != 0 || k != 0 || d != 0)) {
        vector<edge> vec[111];
        swap(g, vec);
        for (int i = 0; i < m; i++) cin >> c[i];
        for (int i = 0; i < d; i++) {
            string s, t;
            int e;
            cin >> s >> t >> e;
            g[f(s)].push_back(edge{ f(t), e * k });
            g[f(t)].push_back(edge{ f(s), e * k });
        }
        dijkstra(f("H"));
        int ans = INF;
        for (int bit = 0; bit < (1 << m); bit++) {
            ans = min(ans, dp[f("D")][bit]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3372
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    fast;
    int a,b,c;
    int k;
    int f=0;
    cin>>a>>b>>c;
    cin>>k;
    int cnt=0,cnt1=0;
   while(1)
   {
       if(b>a)
       {
           f=1;
           break;
       }
       else
       {
           b*=2;
           k--;
       }
   }
   while(k--)
   {
       c*=2;
   }
   if(c>b)
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
    return 0;
}





Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(void){
	
	int H,W,i,j;
	
	while(1){
	
	scanf("%d %d",&H,&W);
	
	if(H==0 && W==0)break;
	
	else{
		for(i=0;i<H;i++){
		
		for(j=0;j<W;j++){
			
		if(i%2 == 0){
			if(j%2 == 0)printf("#");
			else printf(".");}
			
		else {
			if(j%2 == 0)printf(".");
			else printf("#");}
			
			}
		printf("\n");
		}
	}
	
	printf("\n");
	
	}
	
return 0;}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  map<int, vector<string>> data;
  //cout << data.max_size() << endl;
  int p;
  string str;
  vector<string> S;
  for (int i = 0; i < M; i++) {
    cin >> p >> str;
    data[p].push_back(str);
   // cout << p << str << endl;
    //cout << get<0>(data.at(i)) << get<1>(data.at(i)) << endl;
  }
  
  int count = 0;
  int penalty = 0;
  int wa_count = 0;
  for (auto iter = data.begin(); iter != data.end(); iter++) {
    wa_count = 0;
    for (string s: iter->second) {
    //for (auto iter2 = iter->second.begin(); iter2 != iter->second.end(); iter2++) {
     // string s = *iter2;
      if (s == "WA") {
        wa_count++;//penalty++;
      }
      else {
        count++;
        penalty += wa_count;
        wa_count = 0;
        break;
      }
    }
  }
  cout << count << " " << penalty << endl;
  
}


Measured memory_bytes: 15872
/*  
    And solitare's the only game in town
    And every road that takes him
    Takes him down
    And by himself it's easy to pretend
    He'll never love again
    _________________________
    _________________________
    984 Hours of Solitude
    Quarantine_Day : 41
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 200005

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

    int n; cin>>n;
    vi v(n); REP(i, n) cin>>v[i];
    SORT(v);
    cout<<v[n - 1] - v[0]<<"\n";

    return 0;
}


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

class UnionFind {
  vector<int> parents;

public:
  UnionFind(int N) : parents(N, -1) {}

  int find(int x) {
    if (this->parents[x] < 0) return x;
    return this->parents[x] = this->find(this->parents[x]);
  }

  int size(int x) {
    return -this->parents[this->find(x)];
  }

  void marge(int x, int y){
    x = this->find(x);
    y = this->find(y);
    if (x == y) return;
    if (this->parents[x] > this->parents[y])
      swap(this->parents[x], this->parents[y]);
    this->parents[x] += this->parents[y];
    this->parents[y] = x;
  }

  bool is_same(int x, int y) {
    return this->find(x) == this->find(y);
  }

  void check(){
    for(auto& parent : parents) cerr << parent << " ";
    cerr << endl;
  }

  int num_union(int lower=1, int upper=INT_MAX){
    return count_if(this->parents.begin(), this->parents.end(), [&](const int& a){
      return (lower <= -a) && (-a <= upper);
    });
  }
};


int main(){
  int N, M, K;
  cin >> N >> M >> K;

  vector<int> num_friend(N, 0);
  UnionFind uf(N);
  for(int ii=0; ii<M; ii++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    num_friend[a]++;
    num_friend[b]++;
    uf.marge(a, b);
  }

  vector<set<int>> E(N);
  for(int ii=0; ii<K; ii++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    E[a].insert(b);
    E[b].insert(a);
  }

  for(int ii=0; ii<N; ii++){
    int ans = uf.size(ii) - num_friend[ii] - 1;
    for(auto& e : E[ii]){
      if(uf.is_same(e, ii)) ans--;
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)


int main(){
    string s,t;
    cin >> s;
    cin >> t;
    vector<int> scnt(26,0);
    vector<int> tcnt(26,0);
    for(int i = 0; i < s.size(); i++){
        scnt[s[i]-'a']++;
        tcnt[t[i]-'a']++;
    }
    sort(scnt.begin(),scnt.end());
    sort(tcnt.begin(),tcnt.end());
    if(scnt == tcnt){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a,b,c;
	cin >> a >> b>>c;
	if (c <= (a + b)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#define int long long 
#define mod 1000000007
using namespace std;

signed main(){
//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s,s1="es",s2="s";cin>>s;
int l =s.length();

if(s[l-1] == 's') cout<<s+s1<<endl;
else cout<<s+s2<<endl;
//cout<<s<<endl;
//else cout<<s<<'s'<<endl;





}





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

int main()
{
  i64 n;
  cin >> n;
  vector<i64> p(n), q(n);
  for (i64 i = 0; i < n; i++)
    cin >> p[i];
  for (i64 i = 0; i < n; i++)
    cin >> q[i];
  vector<i64> t = p;
  sort(t.begin(), t.end());
  i64 pn, qn, cnt = 0;
  do
  {
    if (t == p)
      pn = cnt;
    if (t == q)
      qn = cnt;
    cnt++;
  } while (next_permutation(t.begin(), t.end()));
  cout << abs(pn - qn) << endl;
  return 0;
}


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


using namespace std;

#define MAXN 12
#define MAXM 12

int n, m;
int k[MAXM];
int s[MAXM][MAXN];
int p[MAXM];


int main() {
    scanf("%d %d", &n, &m);
    int i, j;
    for (i=1; i<=m; i++) {
        scanf("%d", &k[i]);
        for (j=1; j<=k[i]; j++) {
            scanf("%d", &s[i][j]);
            s[i][j]--;
        }
    }
    for (i=1; i<=m; i++) {
        scanf("%d", &p[i]);
    }

    int ans = 0;
    int conj;
    for (conj=0; conj<(1<<n); conj++) {
        int tot = 0;
        for (i=1; i<=m; i++) {
            int soma = 0;
            for (j=1; j<=k[i]; j++) {
                if (((1<<s[i][j])&conj)>0) {
                    soma++;
                }
            }
            if (soma%2==p[i]) {
                tot++;
            }
        }
        if (tot==m) {
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}








Measured memory_bytes: 256
H,W,K=map(int,input().split())
dp=[[0]*W for i in range(H+1)]
dp[0][0]=1
if W==1:
  print(1)
  exit()
  
import itertools
A=list(itertools.product([0,1], repeat=W-1))

B=[]
for i in A:
  x=0
  for j in range(W-2):
    if i[j]==1 and i[j+1]==1:
      x=1
  if x==0:
    B.append(i)

D=[[0,0,0] for i in range(W)]
for i in B:
  for j in range(W-1):
    if i[j]==1:
      D[j+1][0]+=1
      D[j][2]+=1
    if j==0 and i[j]==0:
      D[j][1]+=1
    if j==W-2 and i[j]==0:
      D[j+1][1]+=1
    if j<W-2:
      if i[j]==0 and i[j+1]==0:      
        D[j+1][1]+=1
dp=[[0]*W for i in range(H+1)]
mod=10**9+7
dp[0][0]=1
for i in range(H):
  for j in range(W):
    if j==0:
      dp[i+1][j]=dp[i][j]*D[j][1]+dp[i][j+1]*D[j][2]
    elif j==W-1:
      dp[i+1][j]=dp[i][j]*D[j][1]+dp[i][j-1]*D[j][0]
    else:
      dp[i+1][j]=dp[i][j]*D[j][1]+dp[i][j-1]*D[j][0]+dp[i][j+1]*D[j][2]
    dp[i+1][j]%=mod
print(dp[-1][K-1])

Measured memory_bytes: 9340
import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {
	
	static boolean[] ans;
	static Node[] list;
	static int n;
	static int m;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			n = sc.nextInt();
			m = sc.nextInt();
			if(n == 0 && m == 0) break;
			list = new Node[n];
			for (int i = 0; i < n; i++) {
				list[i] = new Node(i);
			}
			for (int i = 0; i < m; i++) {
				int a = sc.nextInt() - 1;
				int b = sc.nextInt() - 1;
				list[a].list.add(list[b]);
				list[b].list.add(list[a]);
			}
			ans = new boolean[n];
			dfs(0, 0);
			int count = 0;
			for (int i = 1; i < n; i++) {
				if (ans[i]) {
					count++;
				}
			}
			System.out.println(count);
		}
		
		
	}
	static void dfs(int a, int b) {
		if(b == 0)
			for(int i = 0; i < list[a].list.size(); i++) {
				ans[list[a].list.get(i).id] = true;
				dfs(list[a].list.get(i).id,1);
			}
		if(b == 1)
			for(int i = 0; i < list[a].list.size(); i++) {
				ans[list[a].list.get(i).id] = true;
			}
	}
	
	
	static class Node {
		int id;
		ArrayList<Node> list = new ArrayList<Node>();
		Node(int a) {
			id = a;
		}
	}
}

Measured memory_bytes: 46316
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,z,w = li()
a = list(li())

if n == 1:
    print(abs(w-a[-1]))
else:
    print(max(abs(a[-2]-a[-1]), abs(w-a[-1])))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vi a(N);
    cin >> a;
    int cnt = 1;
    REP(i, N) {
        if (a[i] == cnt) {
            cnt++;
        }
    }
    if (cnt == 1) {
        cout << -1 << endl;
    } else
        cout << N - (cnt - 1) << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
  int n;
  scanf("%d", &n);
  char c[4]="0000" , d;
  for (int i = 0; i < n; i++){
    scanf(" %c", &d);
    if (d == 'P'){
      c[0]='1';
    }
    if (d == 'W'){
      c[1]='1';
    }
    if (d == 'G'){
      c[2]='1';
    }
    if (d == 'Y'){
      c[3]='1';
    }
  }
  if (c[0]=='1' && c[1]=='1' &&c[2]=='1' &&c[3]=='1'){
    printf("Four\n");
  }
  else{
    printf("Three\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int n,i;
  long long a[101],max=0,min=1000000001;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
	scanf("%lld",&a[i]);
    if(a[i]>max){
      max=a[i];
    }
    if(a[i]<min){
      min=a[i];
    }
  }
  printf("%lld",max-min);
}


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

int main(){
    int H,N;
    cin >> H >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    int sum = 0;
    rep(i,N){
        H -= A[i]; 
    }
    if(H <= 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
signed main() {
    cin >> N;
    vint P(N), Q(N);
    rep(i, N) { cin >> P[i]; }
    rep(i, N) { cin >> Q[i]; }
    vint perm(N);
    rep(i, N) { perm[i] = i + 1; }
    int a, b;
    int cnt = 0;
    do {
        if (P == perm) { a = cnt; }
        if (Q == perm) { b = cnt; }
        cnt++;
    } while (next_permutation(all(perm)));
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define int long long
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

main(void){
	scanf("%lld %lld",&n,&k);
	FOR{
		scanf("%lld",&a[i]);
	}
	int bas=1;
	int son=10000000000;
	while(bas<=son){
		cev=0;
		FOR{
			cev+=(a[i]-1)/ort;
		}
		if(cev>k)bas=ort+1;
		else son=ort-1;
	}
	printf("%lld\n",bas);
	return 0;
}



Measured memory_bytes: 5380
N,M = map(int,input().split())
ls = []
for i in range(N):
    ls.append(list(input()))
yoko = []
tate = [i for i in range(M)]
for i in range(N):
    if ls[i].count('.') == M:
        yoko.append(i)
for i in range(N):
    for j in range(M):
        if ls[i][j] == '#' and j in tate:
            tate.remove(j)
tate2 = list(range(M))
for i in range(M):
    if i in tate:
        tate2.remove(i)

ansls = []
for i in range(N):
    if not i in yoko:
        ansls.append([ls[i][j] for j in tate2])
for i in ansls:
    print(''.join(i))

Measured memory_bytes: 9252
// https://atcoder.jp/contests/abc164/tasks/abc164_e
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
#define MAX_N 55
#define MAX_M 105
#define MAX_A 55
struct EDGE{int to,cost,time;};
struct NODE{int gain,time;};
vector<EDGE> edge[MAX_N]; 
NODE node[MAX_N];
ll dp[MAX_N][MAX_N*MAX_A];
const ll INF = 1e18;
int main() {
	int n,m,s;
	cin >> n >> m >> s;
	int cmax=0;
	rep(i,m){
		int from,to,c,t;
		cin >> from >> to >> c >>t;
		from--;to--;
		edge[from].push_back((EDGE){to,c,t});
		edge[to].push_back((EDGE){from,c,t});
		if(c>cmax)cmax=c;
	}
	cmax *= n;
	rep(i,n){
		int g,t;
		cin >> g >>t;
		node[i] = (NODE){g,t};
	}
	rep(i,n)rep(j,cmax) dp[i][j] = INF;

	priority_queue<pair<ll,P>,vector<pair<ll,P> >,greater<pair<ll,P> > > que;
	// rep(j,min(s+1,cmax)){
	// 	dp[0][j]=0;
	// 	que.emplace(0,P(0,j));
	// }
	dp[0][min(s,cmax-1)]=0;
	que.emplace(0,P(0,min(s,cmax-1)));


	while(!que.empty()){
		pair<ll,P> p = que.top();que.pop();
		int v=p.second.first,c=p.second.second;
		if(dp[v][c]<p.first)continue;

		int next_c = c + node[v].gain;
		ll stay_t = dp[v][c] + node[v].time;
		if(stay_t < dp[v][next_c]){
			dp[v][next_c] = stay_t;
			que.emplace(stay_t,P(v,next_c));
		}
	
		rep(u,edge[v].size()){
			int next_c = c-edge[v][u].cost;
			if(next_c<0)continue;
			int next_v = edge[v][u].to;
			ll move_t = dp[v][c] + edge[v][u].time;
			if(move_t < dp[next_v][next_c]){
				dp[next_v][next_c] = move_t;
				que.emplace(move_t,P(next_v,next_c));
			}
		}
	}
	for(int i=1;i<n;i++){
		ll t_min=INF;
		rep(j,cmax)t_min = min(t_min,dp[i][j]);
		cout << t_min << endl;
	}


    return 0;
}



Measured memory_bytes: 6384
k, n = map(int, input().split())
a = list(map(int, input().split()))

m = 0
for i in range(n-1):
    d = a[i+1] - a[i]
    m = max(m, d)
d_last = k - a[n-1] + a[0]
m = max(m, d_last)

res = k - m
print(res)

Measured memory_bytes: 26100
use std::io;

fn main() {
    let status = read_vec::<i32>();
    let spattack = read_vec::<i32>();

    let h: i32 = status[0];

    let mut sum: i32 = 0;
    for num in spattack{
        sum = sum + num;
    }

    if sum >= h {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut line = String::new();
    io::stdin().read_line(&mut line)
        .ok()
        .expect("Faild to read Vec");
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

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

int main(){
  int N,A,B; cin >> N>>A>>B;
  int tein = A+B;
  string s; cin >> s;
  int count = 0;
  int rank_inb = 1;
  REP(i,N){
    char p = s[i];
    if(p=='a'){
      if(count<tein){
        cout << "Yes\n";
        count++;
      }else{
        cout << "No\n";
      }
    }else if(p=='b'){
      if(count<tein){
        if(rank_inb<=B){
          cout << "Yes\n";
          count++;
          rank_inb++;
        }else{
          cout << "No\n";
        }
      }else{
        cout << "No\n";
      }
    }else{
      cout << "No\n";
    }
  }
}

Measured memory_bytes: 896
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    a = list(map(int, rl().split()))
    
    ans = 0
    for i in range(0, N, 2):
        if i % 2 == 0 and a[i] % 2 == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 61920
#include <cstdio>

int n;
int plus[100005];
int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		plus[a]++;
		plus[b+1]--;
	}
	int sum=0,res=0;
	for(int i=2;i<=100001;i++){
		sum+=plus[i];
		if(sum+1>=i)res=i-1;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 3132
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
bool work[17][17];
int memo[17][17];
int C(int x, int y){
  if(x==0||y==0) return 0;
  if(x==1&&y==1) return 1;
  if(work[x][y]) return 0;
  if(memo[x][y]!=-1) return memo[x][y];
  return (memo[x][y]=C(x-1,y) + C(x,y-1));
}
int main(void){
  int a,b;
  while(cin>>a>>b){
    if(a==0) break;
    memset(work,0,sizeof(work));
    memset(memo,-1,sizeof(memo));
    int n,x,y;
    cin>>n;
    REP(i,n){
      cin>>x>>y;
      work[x][y]=true;
    }
    cout<<C(a,b)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
 
#define rep(i,n,m) for(int i=n;i<m;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define desc_sort(v) sort(v.rbegin(),v.rend())
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define M 1000000007 
#define pushll(head,d) push_into_linkedlist(&head,d)
#define popll(head) dp_delete_first(&head)
#define eol cout<<"\n"
#define N 1000000
 
typedef set<int> si;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector < vector<int> >  vii; 
 
 
int main()
{   
    ios
    int T=1;
    //cin>>T;
    while(T--)
    {
      int n;
      string s;
      cin>>n>>s;
      if(n>=3200)
        cout<<s;
      else
        	cout<<"red";
      
    }
}

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

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

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	vector<string> a(N);
	vector<int> b(N);
	rep(i, N) {
		cin >> S[i];
		b[i] = 1;
	}
	sort(S.begin(), S.end());
	int j = 0;
	int k = 0;
	int max = 0;
	
	a[0] = S[0];
	rep(i, N-1) {
		if (S[i] == S[i + 1])b[j]++;
		else {
			if (max < b[j]) {
				max = b[j];
				k = 0;
				a[0] = S[i];
				j++;
				
			}
			else if (max == b[j]) {
				k++;
				a[k] = S[i];
				j++;
				
			}
			else j++;


			
			
		}
	}

	if (max < b[j]) {
		max = b[j];
		k = 0;
		a[0] = S[N-1];
		j++;

	}
	else if (max == b[j]) {
		k++;
		a[k] = S[N-1];
		j++;

	}
	

	for (int l = 0;l < k+1;l++) {
				cout << a[l]<<endl;
	}

		}
	

Measured memory_bytes: 16640