akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.time.chrono.MinguoDate;

public class Main {
    public static void main(String[] args) throws IOException {
        try (PrintWriter writer = new PrintWriter(System.out); InputReader reader = new InputReader(System.in)) {
            int[] inputs = reader.readIntsSplitByDelimiter(" ");
            int min = reader.readInt();
            int c = 1;
            inputs[1] -= min;
            for (int i = 1; i < inputs[0]; i++) {
                int m = reader.readInt();
                if (m < min) {
                    min = m;
                }
                inputs[1] -= m;
                c++;
            }
            
            c += inputs[1] / min;
            System.out.println(c);
        }
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.br.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.br.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.br.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.br.readLine().split(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.br.readLine().split(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    @Override
    public void close() throws IOException {
        br.close();
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


main(){
  int w,h,n;
  cin>>w>>h>>n;
  vector<P> a;

  rep(i,n){
    int x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;

    if(y1&&y1!=h&&x1&&x1!=w) continue;
    if(y2&&y2!=h&&x2&&x2!=w) continue;

    if(y1==0){
      a.PB(P(x1,i));
    }else if(x1==w){
      a.PB(P(w+y1,i));
    }else if(y1==h){
      a.PB(P(2*w+h-x1,i));
    }else if(x1==0){
      a.PB(P(2*(w+h)-y1,i));
    }

    x1=x2;
    y1=y2;


    if(y1==0){
      a.PB(P(x1,i));
    }else if(x1==w){
      a.PB(P(w+y1,i));
    }else if(y1==h){
      a.PB(P(2*w+h-x1,i));
    }else if(x1==0){
      a.PB(P(2*(w+h)-y1,i));
    }


  }

  sort(all(a));


  stack<int> st;
  for(auto e:a){
    int p=e.S;
    if(!st.empty()&&st.top()==p){
      st.pop();
    }else{
      st.push(p);
    }
  }

  cout<<(st.empty()?"YES":"NO")<<endl;
}
      


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;

  if((a+b+c)/2 == a+b || (a+b+c)/2 == b+c ||(a+b+c)/2==a+c){
    cout << "Yes"; return 0;
  }
  else{
    cout << "No";
  }
return 0;
}

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

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&v){int i=0;for(auto x:v)++i!=v.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>I){int i=0;for(auto x:I)++i!=I.size()?show(x):showendl(x);} //初期化子リスト出力
  template<class T>void debug(multiset<T>&M){int i=0;for(auto x:M)++i!=M.size()?show(x):showendl(x);} //multiset出力
}

int main(){
  cout<<fixed<<setprecision(15);
  ld N,K;cin>>N>>K;

  ld ans = 0;

  for(int i=1; i<=N; i++){
    int r = ceill(log2l(K/i));
    if(r<0)r=0;
    //DEBUG(i,r);
    ans += 1.0/(1<<r);
    //DEBUG(1.0/(1<<r));
  }
  ans /= N;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int n,m,student[501][501],i,j,t1,t2,lp[501],check[501],count;
    while (1) {
        scanf("%d %d",&n,&m);
        if (n==0&&m==0) break;
        count=0;
        for (i=1; i<=n; i++) lp[i]=0,check[i]=0;
        for (i=0; i<m; i++) {
            scanf("%d %d",&t1,&t2);
            student[t1][lp[t1]]=t2;
            student[t2][lp[t2]]=t1;
            lp[t1]++;
            lp[t2]++;
        }
        check[1]=1;
        for (i=0; i<lp[1]; i++) {
            count++;
            check[student[1][i]]=1;
        }
        for (i=0; i<lp[1]; i++) {
            for (j=0; j<lp[student[1][i]]; j++) {
                if (check[student[student[1][i]][j]]==0) {
                    check[student[student[1][i]][j]]=1;
                    count++;
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 1584
using System;
using System.Collections.Generic;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int k = int.Parse(In[0]);
            int l = int.Parse(In[1]);
            int n = k * (k - 1) / 2;
                n += l * (l - 1) / 2;
            Console.WriteLine(n);
        
        }
    }
}


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

int main() {
    int k,s,ans=0;
    cin>>k>>s;
    for (int x=0; x<=k; x++) {
        for (int y=0; y<=k; y++) {
            int z=s-x-y;
            if (0<=z&&z<=k) ans++;
        }
    }
    cout<<ans<<endl;
}


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

int main(){
  int a[10][331]={0};
  int p[10]={0,1,2,3,4,5,6,7,8,9};
  int q[10]={362880,40320,5040,720,120,24,6,2,1,1};
  int s,n;
  do{
    s=0;
    for(int i=0;i<10;++i){
      s+=(i+1)*p[i];
      a[i][s]++;
    }
  }while(next_permutation(p,p+10));
  while(cin>>n>>s){
    if(s>330) cout<<0;
    else cout<<a[n-1][s]/q[n-1];
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};
#[fastout]
fn main() {
    input!(k: usize, a: usize, b: usize);

    println!("{}", if (b / k) * k >= a { "OK" } else { "NG" });
}


Measured memory_bytes: 2176
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n,m = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	for i in 2:n
		a[i] += a[i-1]
	end
	for i in 1:n
		a[i] = a[i]%m
	end
	k = 0
	d = Dict{Int,Int}()
	d[0] = 1
	for i in 1:n
		if haskey(d,mod(a[i]-m,m))
			k += d[mod(a[i]-m,m)]
		end
		if haskey(d,a[i])
			d[a[i]]+=1
		else
			d[a[i]] = 1
		end
	end
	println(k)
end

main()

Measured memory_bytes: 184820
#include<iostream>
using namespace std;
 
int main(){
    int n,m;
    cin>>n>>m;
    int a[n][m],b[m],c[n];
     
    for(int i=0;i<n;i++){
        c[i]=0;
    }
 
    for(int h=0;h<n;h++){
        for(int w=0;w<m;w++){
            cin>>a[h][w];
        }
    }
    for(int i=0;i<m;i++){
        cin>>b[i];   
    }
 
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            c[i]+= (a[i][j]*b[j]);
        }
    }
 
    for(int i=0;i<n;i++){
        cout<<c[i]<<endl;
    }
}


Measured memory_bytes: 3104
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
typedef int fuko[yuzu|10];
typedef ll azusa[yuzu|10];
fuko p,c;

int main() {
  int i,j,n,k;
  read(n),read(k);
  for (i=1;i<=n;++i) p[i]=read();
  for (j=1;j<=n;++j) c[j]=read();
  ll ans=-2e9;
  for (i=1;i<=n;++i) {
    vector<ll> v;
    ll tmp=c[i];
    v.push_back(c[i]);
    for (j=p[i];j^i;j=p[j]) v.push_back(tmp+=c[j]);
    for (j=0;j<v.size();++j) {
      ll res=k-j-1;
      if (res<0) break;
      ans=max(ans,v[j]+res/(ll)v.size()*max(tmp,0ll));
    }
  }
  cout<<ans<<'\n';
}

Measured memory_bytes: 3752
num = STDIN.gets.to_i
line0 = STDIN.gets.split(" ")
vec0 = Array.new(num) { |i|  i = line0[i].to_i}
line1 = STDIN.gets.split(" ")
vec1 = Array.new(num) { |i|  i = line1[i].to_i}

max = 0.0
for i in 1..3 do
  output = 0.0
  for j in 1..num do
    output += (vec0[j - 1] - vec1[j - 1]).abs ** i
    if i == 1 then
      if j == 1 then
        max = (vec0[j - 1] - vec1[j - 1]).abs
      else
        d = (vec0[j - 1] - vec1[j - 1]).abs
        if d > max then
          max = d
        end
      end
    end
  end
  puts sprintf("%.6f", output ** (1.0 / i))
end

puts sprintf("%.6f", max)

Measured memory_bytes: 6196
#include <bits/stdc++.h>
using LL = long long ;
#define ALL(v) (v).begin(),(v).end()
#define showtime fprintf(stderr,"time = %.15f\n",clock() / (double)CLOCKS_PER_SEC)

const int N = 2000 + 5;
int n,K;
std::vector<int> edges[N];

int dfs(int u,int fa,int limit) {
    if (limit == 0) {
        return 1;
    }
    int ret = 1;
    for (int v : edges[u]) {
        if (v != fa)
            ret += dfs(v,u,limit - 1);
    }
    return ret;
}

int work() {
    int ret = n;
    if (~K & 1) {
        for (int u = 0; u < n; ++ u) {
            ret = std::min(ret,n - dfs(u,-1,K / 2));
        }
    } else {
        for (int u = 0; u < n; ++ u) {
            for (int v : edges[u]) {
                ret = std::min(ret,n - dfs(v,u,K / 2) - dfs(u,v,K / 2));
            }
        }
    }
    return ret;
}

int main() {
    scanf("%d",&n);
    scanf("%d",&K);
    for (int i = 0; i < n - 1; ++ i) {
        int a,b;
        scanf("%d%d",&a,&b); a --; b --;
        edges[a].emplace_back(b);
        edges[b].emplace_back(a);
    }
    printf("%d\n",work());
}

Measured memory_bytes: 384
n, k = map(int, input().split())

result = 0
x_n = n*(n+1)//2

for i in range(k, n+1):
    x_min = (i-1)*i//2
    x_max = x_n - (n-i)*(n-i+1)//2
    result += (x_max - x_min + 1)
    
result += 1
print(result%(10**9+7))

Measured memory_bytes: 9196
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left,bisect_right
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    class RangeBIT:
        def __init__(self,n):
            self.p=self.BIT(n+1)
            self.q=self.BIT(n+1)
        
        def add(self,s,t,x):
            self.p.add(s,-x*s)
            self.p.add(t,x*t)
            self.q.add(s,x)
            self.q.add(t,-x)
        
        def sum(self,s,t):
            return self.p.sum(t)+self.q.sum(t)*t-self.p.sum(s)-self.q.sum(s)*s
        
        class BIT:
            def __init__(self,n):
                self.num=n
                self.dat=[0]*(self.num+1)
            
            def add(self,i,x):
                i+=1
                while i<=self.num:
                    self.dat[i]+=x
                    i+=i&-i
            
            def sum(self,i):
                i+=1
                s=0
                while i>0:
                    s+=self.dat[i]
                    i-=i&-i
                return s

    N,D,A=map(int,input().split())
    X=[0]*N
    XH=[]
    for i in range(N):
        X[i],H=map(int,input().split())
        XH.append((X[i]-1,H))
    XH.sort()
    X.sort()
    l=[0]*N
    for i in range(N):
        l[i]=bisect_right(X,X[i]+D*2)-i
    
    b=RangeBIT(N)
    index=0
    ans=0
    while index<N:
        h=XH[index][1]-b.sum(index,index+1)
        if h<=0:
            index+=1
            continue
        d=-(-h//A)
        ans+=d
        b.add(index,index+l[index],d*A)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 72028
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;

int main(int argc, char* argv[]) {
	stack<int> s1;
	stack<pair<int ,int> > s2;
	char ch;
	int sum = 0;

	for (int i = 0; cin >> ch; ++i) {
		if (ch == '\\') s1.push(i);
		else if (ch == '/' && s1.size() > 0) {
			int j = s1.top(); s1.pop();
			sum += i - j;
			int a = i - j;

			while (s2.size() > 0 && s2.top().first > j) {
				a += s2.top().second; s2.pop();
			}
			s2.push(make_pair(j, a));
		}
	}

	vector<int> ans;
	while (s2.size() > 0) {
		ans.push_back(s2.top().second); s2.pop();
	}
	reverse(ans.begin(), ans.end());

	cout << sum << endl;
	cout << ans.size();

	for (int i = 0; i < ans.size(); ++i) {
		cout << " " << ans[i];
	}
	cout << endl;
    return 0;
}


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

int main(){
	int h, w;
	int i,j;
	while(1){
		scanf("%d %d", &h, &w);
		if(!h && !w)break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				putchar('#');
			}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1004
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=3e5+5;
int n,m,p,q,nm,cnt,ans,come[N],num,choose[N],c;

struct apple{
	int x,k;
	inline bool operator < (const apple &nt) const {
		return x>nt.x;
	}
}a[N];




signed main(){
	read(p);read(q);read(n);read(m);read(nm);
	for(int i=1,x;i<=n;i++) a[++cnt]=(apple){read(x),1};
	for(int i=1,x;i<=m;i++) a[++cnt]=(apple){read(x),2};
	for(int i=1,x;i<=nm;i++) a[++cnt]=(apple){read(x),0};
	sort(a+1,a+1+cnt);
	for(int i=1;(p||q)&&i<=cnt;i++){
		if(a[i].k==1){
			if(p) p--,choose[++c]=a[i].x,ans+=a[i].x;
		}
		if(a[i].k==2){
			if(q) q--,choose[++c]=a[i].x,ans+=a[i].x;
		}
		if(a[i].k==0){
			come[++num]=a[i].x;
		}
	}
	sort(choose+1,choose+1+c);
	sort(come+1,come+1+num,greater<int>());
	for(int i=1;i<=num&&i<=c;i++) if(come[i]>choose[i]) ans+=come[i]-choose[i];
	write(ans);
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  string s;
  cin >> s;
  int n = s.size();
  int i = 0, j = n - 1;
  while(i < j) {
    char a = s[i], b = s[j];
    if(a == 'x' && b == 'x') {
      i++, j--;
    }
    else if(a == 'x' && b != 'x') {
      ans++;
      i++;
    }
    else if(a != 'x' && b == 'x') {
      ans++;
      j--;
    }
    else if(a != 'x' && b != 'x') {
      if(a != b) {
        cout << "-1\n";
        return 0;
      }
      i++, j--;
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
	int N,A,B,C,mp=INF;
	cin >> N >> A >> B >> C;
	vector<int> l(N);

	rep(i,N)
		cin >> l.at(i);
	
	rep(i, 1<<N) {
		int tl;
		vector<int> t;

		rep(j,N)
			if(i>>j & 1)
				t.push_back(l.at(j));

		tl = t.size();
		if(tl < 3)
			continue;

		rep(j, pow(3,tl)) {
			vector<int> s;
			int x=j, ta=0, tb=0, tc=0, tmp, ua=-1, ub=-1, uc=-1;

			rep(k,tl) {
				s.push_back(x%3);
				x /= 3;
			}

			rep(k,tl)
				if(s.at(k) == 0) {
					ta += t.at(k);
					++ua;
				} else if(s.at(k) == 1) {
					tb += t.at(k);
					++ub;
				} else {
					tc += t.at(k);
					++uc;
				}
			if(ua<0 || ub<0 || uc<0)
				continue;

			tmp = (ua+ub+uc)*10 + abs(A-ta) + abs(B-tb) + abs(C-tc);
			mp = min(mp, tmp);
		}
	}

	cout << mp << endl;
}

Measured memory_bytes: 256
# Green Bin
n = int(input())
s = [input() for i in range(n)]
m = 0
list = {}
for i in s:
  i = ' '.join(sorted(i))
  if i in list:
    list[i] = list[i] + 1
  else:
    list[i] = 1
for i in list.values():
  l = i -1
  m = m + int(((l * (l + 1)) / 2))
print(m)

Measured memory_bytes: 25748
def getPt(h):
    if h == "s":
        return R
    elif h == "p":
        return S
    elif h == "r":
        return P

N, K = map(int,input().split())
R, S, P = map(int,input().split())
T = list(input())
pt = 0
for i in range(N):
    if i < K:
        pt += getPt(T[i])
    else:
        if T[i] == T[i-K]:
            T[i] = ""
        else:
            pt += getPt(T[i])
print(pt)

Measured memory_bytes: 4084
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int n,sum = 0,min_v=0,num;
    vector<int> A;
    cin >> n;
    for(int i=0;i<n;i++){
        int x;cin >> x;A.push_back(x);
    }
    sort(A.begin(),A.end());
    int min = A[0];
    sort(A.begin(),A.end(),greater<int>());
    int max = A[0];
    
    for(int i = min;i<=max;i++){
        sum = num = 0;
        for(int j=0;j<n;j++){
            num = (A[j] - i)*(A[j] - i);
            sum += num;
        }
        if(i==min) min_v = sum;
        
        if(min_v > sum) min_v = sum;
    }
    cout << min_v;
     
}


Measured memory_bytes: 256
n,x,*a=`dd`.split.map &:to_i
c=0
1.upto(n-1){|i|
  if a[i-1]+a[i]>x
    k=[a[i-1]+a[i]-x,a[i]].min
    c+=k
    a[i]-=k
  end
  if a[i-1]+a[i]>x
    k=a[i-1]+a[i]-x
    c+=k
    a[i-1]-=k
  end
}
p c

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

int main()
{
    char a[11], b[11], c[11];
    scanf("%s%s%s",a, b, c);
    if (a[strlen(a)-1] == b[0] && b[strlen(b)-1] == c[0]) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
	int n,i;
	cin>>n;
	char a[n],b[n];
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0;i<n;i++)cin>>b[i];
	char ans[n+n];
	for(i=0;i<=n+n-2;i+=2)ans[i]=a[i/2];
	for(i=1;i<=n+n-1;i+=2)ans[i]=b[(i-1)/2];
	for(i=0;i<=n+n-1;i++)cout<<ans[i];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll A[N], B[N];
    rep(i, N) cin >> A[i] >> B[i];

    ll ans = 0;

    for( int i = N-1; i >= 0; i--) {
        if ( B[i] != 1 && (A[i]+ans) % B[i] != 0) {
            ans += B[i] - ((A[i]+ans) % B[i]);
            //dump(ans);
        }
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;

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

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll N, A;

    cin >> N >> A;
    
    cout << N * N - A << endl;

    return 0;
}

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

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

#define int long long

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = 1e18;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();

int adj[201][201];
int color[201];
  int n;
int ff = 0;
void dfs(int u) {
  for(int i = 1; i <= n; i++) {
    if(adj[u][i] and color[i] == color[u])
      ff = 1;
    if(adj[u][i] and color[i] == 0) {
      color[i] = -color[u];
      dfs(i);
    }
  }
}

int32_t main(){
  fast;

  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  
  cin >> n;
  FOR(i,1,n) {
    string s;
    cin >> s;
    for(int j = 0; j < n; j++)
      adj[i][j+1] = s[j]-'0';
  }

  FOR(i,1,n) {
    if(color[i] == 0) {
      color[i] = 1;
      dfs(i);
    }
  }

  if(ff){
    cout << "-1";
    return 0;
  }
  int ans = 0;
  FOR(i,1,n) {
    queue<int>q;
    int lvl[n+1] = {0};
    q.push(i);
    lvl[i] = 1;
    int maxlvl = 1;
    int vis[n+1] = {0};
    vis[i] = 1;
    while(!q.empty()) {
      int u = q.front();
      q.pop();
      for(int j = 1; j <= n; j++) {
        if(adj[u][j] and vis[j] == 0) {
          q.push(j);
          lvl[j] = 1 + lvl[u];
          vis[j] = 1;
          maxlvl = max(maxlvl,lvl[j]);
        }
      }
    }
    // cout << i << " " << maxlvl << "\n";
    ans = max(ans,maxlvl);
  }
  cout << ans << "\n";
  time_p=clock()-time_p;
  cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
  
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int ans[100002] = {};
	rep(i, 100002) ans[i] = i;
	ans[0] = 1000000;
	int A[6];
	int B[5];
	A[0] = 6;
	B[0] = 9;
	rep(i, 5) A[i + 1] = A[i] * 6;
	rep(i, 4) B[i + 1] = B[i] * 9;
	vector<int> v;
	rep(i, 6) v.push_back(A[i]);
	rep(i, 5) v.push_back(B[i]);
	v.push_back(1);
	sort(v.begin(), v.end(), greater<int>());
	for (int k = 0; k < 12; k++) {
		int cnt = 0;
		// cout << k << endl;
		for (int i = v[k]; i <= N; i += v[k]) {
			cnt = min(cnt + 1, ans[i - v[k]] + 1);
			ans[i] = min({ ans[i], cnt });
			// cout << i  << " " << ans[i] << endl;
		}

		for (int i = 2; i <= N; i++) {
			if (i - v[k] < 0) continue;
			ans[i] = min(ans[i], ans[i - v[k]] + 1);
		}
	}
	cout << ans[N] << endl;

    return 0;
}


Measured memory_bytes: 640
n = int(input())
ls = []
for i in range(n):
    x,l = map(int,input().split())
    ls.append([x-l,l+x])
    
ls = sorted(ls, key=lambda x: x[1])
ans = n

for i in range(1,n):
    if ls[i][0] < ls[i-1][1]:
      ls[i][1] = ls[i-1][1]
      ans -=1
        
print(ans)

Measured memory_bytes: 26292
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long int ll;
using namespace std;

class a1 {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n; in>>n;
        ll A, B;
        in>>A>>B;
        f(i, n-1){
            ll x, y; in>>x>>y;
            ll num = max(1+(A-1)/x, 1+(B-1)/y);
            A=num*x, B=num*y;
        }
        out<<A+B;

	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	a1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
using CompLib.Util;
using System;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int x = sc.NextInt();
        int a = sc.NextInt();
        int b = sc.NextInt();

        if (-a + b <= 0)
        {
            Console.WriteLine("delicious");
            return;
        }

        if (-a + b <= x)
        {
            Console.WriteLine("safe");
            return;
        }


        Console.WriteLine("dangerous");


    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;
    class Scanner
    {
        private int _index;
        private string[] _line;
        const char separator = ' ';

        public Scanner()
        {
            _index = 0;
            _line = new string[0];
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(separator);
                _index = 0;
            }
            return _line[_index++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(separator);
            _index = _line.Length;
            return _line;
        }
        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
Array = list(map(int, input().split()))
K = int(input())

ans_array =Array
counter = 0
for i in range(7):
  if ans_array[0] >= ans_array[1]:
    ans_array[1] = ans_array[1] * 2
  else:
    if ans_array[1] >= ans_array[2]:
      ans_array[2] = ans_array[2] * 2
      if ans_array[1] < ans_array[2]:
        counter = i + 1
        if counter <= K:
          print("Yes")
        else:
          print("No")
        exit()
    else:
        if counter <= K:
          print("Yes")
        else:
          print("No")
        exit()
else:
  print("No")



Measured memory_bytes: 9240
import java.io.*; 
import java.util.*; 
  
class Graph { 
	
    ArrayList<Integer> adjArr[];
  
	@SuppressWarnings("unchecked")
	Graph(int v) {
        adjArr = new ArrayList[v]; 
        for (int i=0; i <v; i++) 
            adjArr[i] = new ArrayList<Integer>(); 
    } 
  
 
    void addToGraph(int id, int neighbor) { 
    	adjArr[id].add(neighbor); 
    	}
    
 
    void topoSort(int v, boolean visited[], Stack<Integer> s) {  
      
    	visited[v] = true; 
        int i; 

        Iterator<Integer> next = adjArr[v].iterator(); 
        while (next.hasNext()) { 
            i = next.next(); 

            if (!visited[i]) 
            	topoSort(i, visited, s); 
        } 
        s.push(v); 
    }
}

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

		int totalVertex = sc.nextInt();
		Graph adj = new Graph(totalVertex);
		
		int total = sc.nextInt();
		
		int id;
		int neighbor;
		
		for (int j = 0; j < total; j++) {
			id = sc.nextInt();
			neighbor = sc.nextInt();
			adj.addToGraph(id, neighbor);
		}
		
		Stack<Integer> stack = new Stack<Integer>();
		
		boolean[] visited = new boolean[totalVertex];

		for(int k = 0; k < totalVertex; k++){
			visited[k] = false;
		}
		
		for(int l = 0; l < totalVertex; l++) {
			if(!visited[l]) {
				adj.topoSort(l, visited, stack);
			}
		}
		
		while(!stack.isEmpty()) {
			System.out.println(stack.pop());
		}
    }
}


Measured memory_bytes: 70252
using System;

namespace AOJapps
{
    class Program
    {
        static void Main(string[] args)
        {
            string data = Console.ReadLine();
            string[] values = data.Split(' ');
            int a = int.Parse(values[0]);
            int b = int.Parse(values[1]);

            while ( a*b!=0 ) { if (a < b) { b = b % a; } else { a = a % b; } }
            
            if (a == 0) { Console.WriteLine(b); } else { Console.WriteLine(a); }
        }
    }
}

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

int main()
{
	int n, m, x;
	cin >> n >> m >> x;

	int count = 0;
	for (int i = 0; i < m; ++i) {
		int a;
		cin >> a;
		if (a < x) {
			++count;
		}
	}

	if (count < m - count) {
		cout << count << endl;
	}
	else {
		cout << m - count << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
const int N  = 100007;
bool comp(pii p1 , pii p2){
    return p2.S < p1.S;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n , x; 
    cin >> n;
    map<int, int> m1 , m2;
    for(int i = 1;i <= n ; i++){
        cin >> x;
        if(i&1)
            m1[x]++;
        else
            m2[x]++;
    }
    vector<pii> v1 , v2;
    for(auto it : m1)
        v1.pb(it);
    for(auto it : m2)
        v2.pb(it);
    sort(all(v1) , comp);
    sort(all(v2) , comp);
    if(v1[0].F == v2[0].F){
        if(n == 2)
            cout << 1 << endl;
        else
        {
            if(v1.size() == 1 && v2.size() == 1)
                cout << n/2 << endl;
            else if(v1.size() == 1)
                cout << n/2 - v2[1].S << endl;
            else if(v2.size() == 1)
                cout << n/2 - v1[1].S << endl;
            else{
                int a = n - v1[0].S - v2[1].S;
                int b = n - v1[1].S - v2[0].S;
                cout << min(a , b) << endl;
            }
        }
    }
    else
    {
        int ans = n - v1[0].S - v2[0].S;
        cout << ans << endl;
    }
    
    return 0;
}

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

int main() {
  long long a; cin >> a;
  if(a>=2000){
    cout << 1 << endl;
    exit(0);
  }
  else{
    for(int x=0; x<20; x++){
      for(int y=0; y<20; y++){
        for(int z=0; z<20; z++){
          for(int t=0; t<20; t++){
            for(int u=0; u<20; u++){
              for(int v=0; v<20; v++){
                if(100*x+101*y+102*z+103*t+104*u+105*v==a){
                  cout << 1 << endl;
                  exit(0);
                }
              }
            }
          }
        }
      }
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
// abc118_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    REP(i, M) cin >> A[i];
    sort(ALL(A));

    vector<int> num{2, 5, 5, 4, 5, 6, 3, 7, 6};
    vector<P> candidates;
    REP(i, M){
        bool flag = true;
        for (auto &p: candidates){
            if (num[A[i]-1] == p.first){
                p.second = A[i];
                flag = false;
                break;
            }
        }
        if (flag){
            candidates.emplace_back(num[A[i]-1], A[i]);
        }
    }
    sort(ALL(candidates));

    vector<string> dp(100);
    dp[0] = "0";
    REPN(i, 1, candidates.size()){
        ll cnt = candidates[i].first;
        string n = to_string(candidates[i].second);
        REPN(j, cnt, 100){
            if (dp[j - cnt] == ""){
                continue;
            } else if (dp[j - cnt] == "0"){
                dp[j] = n;
            } else {
                dp[j] = dp[j - cnt] + n;
                sort(ALL(dp[j]), greater<char>());
            }
        }
    }
    dp[0] = "";


    string s = "";
    int tmp = N;
    int n = candidates[0].first;
    while (tmp - n >= 0){
        s += to_string(candidates[0].second);
        tmp -= n;
    }

    string ans = "";
    if (tmp == 0) {
        ans = s;
    } else{
        while (s != "" && tmp < 100) {
            if (dp[tmp] != ""){
                string t = dp[tmp] + s;
                sort(ALL(t), greater<char>());
                if (t.size() >= ans.size() && t >= ans){
                    ans = t;
                }
            }
            tmp += n;
            s = s.substr(1);
        }
    }

    sort(ALL(ans), greater<char>());
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	int c=a+b;
	if(a%3==0||b%3==0||c%3==0)
		cout<<"Possible";
	else cout<<"Impossible";
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,k,i,a,l[200010]={},s=0;
  cin >> n >> k;
  for (i=0;i<n;i++){
    cin >> a;
    l[a]++;
  }
  sort(l,l+n,greater<int>());
  for (i=0;i<k;i++) s+=l[i];
  cout << n-s << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,m,l;
  cin >> n >> m >> l;
  ll d[n][n];
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      d[i][j]=inf;
    }
  }

  for(ll i=0;i<m;i++){
    ll a,b,c;
    cin >> a >> b >> c;
    d[a-1][b-1]=c;
    d[b-1][a-1]=c;
  }

  for(int i=0;i<n;i++)d[i][i]=0;

  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(d[i][k]==inf || d[k][j]==inf);
        else d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }

  // for(ll i=0;i<n;i++){
  //   for(ll j=0;j<n;j++)cout << d[i][j] << " " ;
  //   cout << endl;
  // }

  ll d2[n][n];
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      if(d[i][j]<=l)d2[i][j]=1;
      else d2[i][j]=inf;
    }
  }

  for(int i=0;i<n;i++)d2[i][i]=0;

  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(d2[i][k]==inf || d2[k][j]==inf);
        else d2[i][j]=min(d2[i][j],d2[i][k]+d2[k][j]);
      }
    }
  }

  ll q;
  cin >> q;

  // for(ll i=0;i<n;i++){
  //   for(ll j=0;j<n;j++)cout << d2[i][j] << " " ;
  //   cout << endl;
  // }

  for(ll i=0;i<q;i++){
    ll s,t;
    cin >> s >> t;
    if(s>t)swap(s,t);
    if(d2[s-1][t-1]==inf)cout << -1 << endl;
    else cout << d2[s-1][t-1]-1 << endl;
  }

}



Measured memory_bytes: 5032
#include <stdio.h>

int main(void) {
	
	int a,i,sum=0,x;
	
	for(i=0;i < 5;i++){
		scanf("%d",&a);
		
		if(a < 40){
			a = 40;
		}
		
		sum = sum + a;
	}
	
    x = sum/5;
    
    printf("%d\n",x);
	
		
		return 0;
}

Measured memory_bytes: 600
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    int ans=0;
    chmax(ans,a*b);
    cin >> a >> b;
    chmax(ans, a * b);
    cout<<ans<<"\n";
}


Measured memory_bytes: 3612
# コンテスト中は無理やりなビット全探索[alias bit全探索]をしたが、正しく書き換えた

N, M = map(int, input().split())
S = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))

count = 0
for i in range(2 ** N):
    flg = True
    for m in range(M):
        on = 0
        for s in S[m]:
            if (i >> s - 1) & 1:
                on += 1
        if on % 2 != P[m]:
            flg = False
            break
    if flg:
        count += 1
print(count)


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

const int XN=200+11;

template <class T>
bool Enlarge(T &a,T const &b) {
    return a<b?a=b,1:0;
}

bool G[XN][XN];
int c[XN],n;
bool DFS(int pos,int color) {
    if(c[pos])
        return c[pos]==color;
    c[pos]=color;
    for(int i=1;i<=n;++i)
        if(G[pos][i] && !DFS(i,-color))
            return 0;
    return 1;
}

int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
   // freopen("input","r",stdin);
    std::cin>>n;
    for(int i=1;i<=n;++i) {
        static char s[XN];
        std::cin>>(s+1);
        for(int j=1;j<=n;++j)
            G[i][j]=s[j]-'0';
    }
    /*
    for(int i=1;i<=n;++i)
        for(int j=i+1;j<=n;++j)
            if(G[i][j])
                std::cerr<<i<<' '<<j<<'\n';
                */
    if(!DFS(1,-1))
        std::cout<<-1<<'\n';
    else {
        int Ans=0;
        for(int i=1;i<=n;++i) {
            static int d[XN];
            memset(d,0,sizeof(d));
            std::queue<int> Q;
            Q.push(i);
            d[i]=1;
            while(!Q.empty()) {
                int pos=Q.front();Q.pop();
                for(int u=1;u<=n;++u)
                    if(G[pos][u] && !d[u]) {
                        d[u]=d[pos]+1;
                        Q.push(u);
                    }
            }
            Enlarge(Ans,*std::max_element(d+1,d+1+n));
        }
        assert(Ans>=2);
        std::cout<<Ans<<'\n';
    }
	return 0;
}


Measured memory_bytes: 256
//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VVI = vector<VI>;


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


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    LL N,tmp;
    LL A[5];

    cin >> N >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
    tmp = A[0];
    REP(i,4){
        chmin(tmp,A[i+1]);
    }
    cout << (N + tmp - 1) / tmp + 4 << endl;

}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

	for (int i = 0; i < T; ++i) {
		solve();
	}
}

Measured memory_bytes: 256
alp=[chr(i) for i in range(97, 97+26)]
inf=10000000
check=[inf]*26

n=int(input())
for i in range(n):
    s=input()
    ls=len(s)
    check_sub=[0]*26
    for j in range(ls):
        #print(s[j])
        check_sub[alp.index(s[j])]+=1
    for k in range(26):
        check[k]=min(check[k],check_sub[k])
    #print(check_sub)
ans=""
for i in range(26):
    #print(check[i])
    ans+=check[i]*alp[i]
print(ans)


Measured memory_bytes: 3064
const MOD: i64 = 1e9 as i64 + 7;

fn solve(n: usize, k: usize) -> i64 {
    let sqn = (n as f64).sqrt() as usize;
    let q = n / (sqn + 1);
    let r = sqn + q;

    let mut dp = vec![vec![0i64; 2 * r]; k + 1];

    let mut num = vec![0; r + 1];
    for i in 1..(r + 1) {
        if i <= sqn {
            num[i] = 1;
            dp[1][i] = dp[1][i - 1] + 1;
        } else {
            num[i] = (n / (r - i + 1) - n / (r - i + 2)) as i64;
            dp[1][i] = dp[1][i - 1] + num[i];
        }
    }

    for i in 2..(k + 1) {
        for j in 1..(r + 1) {
            dp[i][j] = (dp[i - 1][r - j + 1] * num[j] + dp[i][j - 1]) % MOD;
        }
    }

    dp[k][r]
}

#[test]
fn solve_test() {
    assert_eq!(solve(3, 2), 5);
    assert_eq!(solve(10, 3), 147);
    assert_eq!(solve(314159265, 35), 457397712);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (n, k) = parse_line!(usize, usize);
    println!("{}", solve(n, k));
}


Measured memory_bytes: 209148