akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		
		long c = 0;
		long d = 0;
		long cd = 0;
		
		long koub = 0;
		
		koub = C * D / gcd(C, D);
		
		if(A == B) {
			if(A % C != 0 && A % D != 0) {
				System.out.println(1);
				return;
			} else {
				System.out.println(0);
				return;
			}
		}
		
		if(C == D) {
			long x = 0;
			if(A % C != 0) {
				x = (B - (A / C + 1) * C) / C + 1;
			} else {
				x = (B - A) / C + 1;
			}
			System.out.println(B - A + 1 - x);
			return;
		}
		
	
		if(A % C != 0) {
			if(A > C) {
				c = (B - (A / C + 1) * C) / C + 1;
			} else {
				if(C <= B) {
					c = (B - C) / C + 1;
				} else {
					c = 0;
				}
			}
		} else {
			if(A > C) {
				c = (B - A) / C + 1;
			} else {
				if(C <= B) {
					c = (B - C) / C + 1;
				} else {
					c = 0;
				}
			}
		}
		
		if(A % D != 0) {
			if(A > D) {
				d = (B - (A / D + 1) * D) / D + 1;
			} else {
				if(D <= B) {
					d = (B - D) / D + 1;
				} else {
					d = 0;
				}
			}
		} else {
			if(A > D) {
				d = (B - A) / D + 1;
			} else {
				if(D <= B) {
					d = (B - D) / D + 1;
				} else {
					d = 0;
				}
			}
		}
		
		if(A % koub != 0) {
			if(A > koub) {
				cd = (B - (A / koub + 1) * koub) / koub + 1;
			} else {
				if(koub <= B) {
					cd = (B - koub) / koub + 1;
				} else {
					cd = 0;
				}
			}
		} else {
			if(A > koub) {
				cd = (B - A) / koub + 1;
			} else {
				if(koub <= B) {
					cd = (B - koub) / koub + 1;
				} else {
					cd = 0;
				}
			}
		}
		
		System.out.println(B - A + 1 - c - d + cd);
	}
	
	public static long gcd(long a, long b) {
		if(b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}
}


Measured memory_bytes: 21588
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;


int main() 
{
    int N, T;
    cin >> N >> T;
    vector<int> A(N);
    for(int i = 0; i < N; ++i)
        cin >> A[i];

    vector<int> maxA(N);
    maxA[N-1] = A[N-1];
    for(int i = N-2; i >= 0; --i)
        maxA[i] = max(maxA[i+1], A[i]);

    vector<int> inds{0};
    for(int i = 1; i < N; ++i)
    {
        if(maxA[i] - A[i] > maxA[inds[0]] - A[inds[0]])
            inds.clear(), inds.push_back(i);
        else if(maxA[i] - A[i] == maxA[inds[0]] - A[inds[0]])
            inds.push_back(i);
    }
    cout << inds.size() << endl;

    return 0;
}

Measured memory_bytes: 1408
n, k = map(int, input().split())
p = [0] * n

for i in range(1, n+1):
    score = i
    cnt = 0
    while score < k:
        score *= 2
        cnt += 1
    if cnt==0:
        proba = 1.0
    else:
        proba = (1/2)**cnt
    p[i-1] = proba

ans = 0
for pp in p:
    ans += (1/n)*pp

print(ans)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> a(n), b(m);
  rep(i,n) {
    int x, y;
    cin >> x >> y;
    a[i]=make_pair(x,y);
  }
  rep(i,m) {
    int x, y;
    cin >> x >> y;
    b[i]=make_pair(x,y);
  }
  rep(i,n) {
    int DIS=1000000000, ans;
    rep(j,m) {
      int dis = abs(a[i].first-b[j].first)+abs(a[i].second-b[j].second);
      if(dis<DIS) {
        DIS=dis;
        ans=j+1;
      }
    }
    cout << ans << endl;
  }
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

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

  cout << "Christmas";
  for( int i=0; i<25-D; i++ ){
    cout << " Eve";
  }
  cout << endl;
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
template<typename T = int> using V = vector<T>;
template<typename T = int> using P = pair<T, T>;
using Vi = V<int>;
using Pi = P<int>;
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
const int INF  = 1<<30;


int main() {
  int h, w; cin >> h >> w;

  set<Pi> S, T;
  rep(i, w) S.emplace(i, 0);
  rep(i, w) T.emplace(0, i);

  Vi ans(h);

  rep(k, h) {
    int a, b; cin >> a >> b;
    --a;

    auto l = S.lower_bound({a, -1});
    auto r = S.lower_bound({b, -1});

    int x = INF;
    while (l != r) {
      auto [i, j] = *l;
      chmin(x, j-i+b);
      l = S.erase(l);
      T.erase({j, i});
    }

    if (x < INF && b < w) S.emplace(b, x);
    if (x < INF && b < w) T.emplace(x, b);

    if (T.empty()) ans[k] = -1;
    else ans[k] = k+1 + T.begin()->first;
  }
  
  cout << ans << '\n';
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n, k;
  cin >> n >> k;
  if (k == 1)
    print(0);
  else
    print(n - k);
}


Measured memory_bytes: 256
y, m, d = map(int, input().split("/"))

if y < 2019:
    print("Heisei")
elif y == 2019 and m < 4:
    print("Heisei")
elif y == 2019 and m == 4 and d <= 30:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 38384
#include <iostream>
#include <stdlib.h>
#define llint long long

using namespace std;

int X, Y, Z;
int A, B, C, N;
llint ans[1005];
llint Line[1005], LineSum[1005][1005];
llint Plane[1005], PlaneSum[1005][1005];

int main(void)
{
	cin >> X >> Y >> Z >> A >> B >> C >> N;
	
	for(int i = 0; i < N; i++) Line[i] = 0;
	for(int x = 0; x < X; x++) Line[abs(x-A)%N]++;
	
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < N; j++) LineSum[i][j] = LineSum[i-1][j] + Line[(j-i+N)%N];
	}
	
	
	
	
	for(int i = 0; i < N; i++) Plane[i] = Line[i];
	for(int i = 0; i < N; i++){
		for(int j = 0; j < B/N; j++) Plane[i] += LineSum[N][i];
		Plane[i] += LineSum[B%N][i];
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < (Y-B-1)/N; j++) Plane[i] += LineSum[N][i];
		Plane[i] += LineSum[(Y-B-1)%N][i];
	}
	
	
	
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < N; j++) PlaneSum[i][j] = PlaneSum[i-1][j] + Plane[(j-i+N)%N];
	}
	
	for(int i = 0; i < N; i++) ans[i] = Plane[i];
	for(int i = 0; i < N; i++){
		for(int j = 0; j < C/N; j++) ans[i] += PlaneSum[N][i];
		ans[i] += PlaneSum[C%N][i];
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < (Z-C-1)/N; j++) ans[i] += PlaneSum[N][i];
		ans[i] += PlaneSum[(Z-C-1)%N][i];
	}
	
	for(int i = 0; i < N; i++) {
		cout << ans[i];
		if(i != N-1) cout << " ";
		else cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 18812
N = int(input())
X = list(map(int, input().split()))
med1 = sorted(X)[N // 2 - 1]
med2 = sorted(X)[N // 2]
for i in range(N):
    tmp = X[i]
    if tmp <= med1:
        print(med2)
    else:
        print(med1)


Measured memory_bytes: 30940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int n,k,cnt,q,h[N];
struct edge{
	int to,nt,w;
}e[N<<1];
ll d[N];
void add(int u,int v,int w){
	e[++cnt]={v,h[u],w},h[u]=cnt;
	e[++cnt]={u,h[v],w},h[v]=cnt;
}
void dfs(int u,int fa){
	for(int i=h[u];i;i=e[i].nt){
		if(e[i].to==fa) continue;
		int v=e[i].to,w=e[i].w;
		d[v]=d[u]+w;
		dfs(v,u);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		add(u,v,w);
	}
	scanf("%d%d",&q,&k);
	dfs(k,0);
	while(q--){
		int x,y;
		scanf("%d%d",&x,&y);
		printf("%lld\n",d[x]+d[y]);
	} 
	return 0;
}

Measured memory_bytes: 13480
#include <stdio.h>
int main(){
  int a[101]={0};
  int i,j;
  while(scanf("%d",&i) != EOF){
    a[i]=a[i]+1;
  }
  for(i=1;i<101;i++){
    if(i == 1){
      j=a[i];
    }
    else if(a[i] > j){
      j=a[i];
    }
  }
  for(i=1;i<101;i++){
    if(a[i] == j){
      printf("%d\n",i);
    }
  }
  return (0);
}

Measured memory_bytes: 596
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		long n=gLong();
		long a=gLong();
		long b=gLong();

		long r1=n/(a+b)*a;
		long r2=Math.min(n%(a+b),a);
		System.out.println(r1+r2);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main(){
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> graph(h);
	rep(i,h){
		cin >> graph[i];
	}
	int res = 0;

	rep(i,1<<h){
		rep(j,1<<w){
			vector<string> temp = graph;
			rep(a,h){
				if((i>>a)&1){
					rep(k,w){
						temp[a][k] = 'r';
					}
				}
			}
			// rep(k,h){
			// 	cout << temp[k] << endl;
			// }
			rep(b,w){
				if((j>>b)&1){
					rep(k,h){
						temp[k][b] = 'r';
					}
				}
			}
			// rep(k,h){
			// 	cout << temp[k] << endl;
			// }
			// return 0;
			int black = 0;
			rep(k, h)
			{
				rep(l,w){
					if(temp[k][l] == '#'){
						black++;
					}
				}
			}
			if(black == k){
				res++;
			}

		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3604
def main():
    h, w = map(int, input().split())
    coord = [list(input()) for _ in range(h)]
    dys = [-1, 0, 1, 0]
    dxs = [0, 1, 0, -1]
    for y in range(h):
        for x in range(w):
            if coord[y][x] == '.':
                continue
            can_paint = False
            for dy, dx in zip(dys, dxs):
                ny = y + dy
                nx = x + dx
                if ny < 0 or h <= ny or nx < 0 or w <= nx:
                    continue
                if coord[ny][nx] == '#':
                    can_paint = True
                    break
            if not can_paint:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
const char fin[]={"AKIHABARA"};
char ch[110];
bool b[110];

int main()
{
	scanf("%s",ch);
	int cnt=0,i,n=strlen(ch);
	for(i=0;cnt<9;cnt++)
		if(ch[i]==fin[cnt])
		{
			b[cnt]=1;
			i++;
		}
	if(i<n)
	{
		puts("NO");
		return 0;
	}
	for(i=0;i<9;i++)
	{
		if(!b[i])
			if(fin[i]!='A')
			{
				puts("NO");
				return 0;
			}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 128
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

string s[N];
int n;

int main() {
	qr(n); for(int i=1;i<=n;i++) cin>>s[i];
	sort(s+1,s+n+1); pr2(unique(s+1,s+n+1)-(s+1));
	return 0;
}



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

int main() {
  int n,k,op;
  cin >> n >> k;
  rep(i,n){
    int a;
    cin >> a;
    if(a == 1) op = i;
  }
  op++;
  int l,r,ans = 1e5;
  rep(i,k){
    l = op-i;
    r = op+k-1-i;
    if(l < 0 || r > n) continue;
    int temp = 1;
    if(l != 0){
      temp += (l-1)/(k-1);
      if((l-1)%(k-1) != 0) temp++;
    }
    if(r != n){
      temp += (n-r)/(k-1);
      if((n-r)%(k-1) != 0) temp++;
    }
    ans = min(ans,temp);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

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

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N;

vi v(5);

signed main(){

    in(N);
    in(v);

    sort(all(v));


    out(5+N/v[0]+(N%v[0]!=0?0:-1));

    return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
      int m = sc.nextInt();
      ArrayList<String>line=new ArrayList<String>();
      String aqqqqq=sc.nextLine();
      for(int i=0;i<n;i++){
        String a=sc.nextLine();
        line.add(a);
      }
      String check="";
      for(int i=0;i<m;i++){
        check+=".";
      }
      for(int i=0;i<line.size();i++){
      	if(line.get(i).equals(check)){
          line.remove(i);i--;
        }
        
      }
      boolean b[]=new boolean[m];
      for(int i=0;i<m;i++)b[i]=true;
      for(int i=0;i<line.size();i++){
      	for(int j=0;j<m;j++){
          b[j]=!(line.get(i).substring(j,j+1).equals("#")||!b[j]);
      	}
      }
      for(int i=0;i<line.size();i++){
      	for(int j=0;j<m;j++){
        	if(!b[j]){
      			System.out.print(line.get(i).substring(j,j+1));
        	}
      	}
      	System.out.println();
      }
        
    }
}

Measured memory_bytes: 24508
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
#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 INF 999999999

ll N,K,k,c;
string S;

int main(){
  cin >> N >> K;
  cin >>S;
  k=S.length();
  c=0;
  REP(i,k-1){
    if(S[i]!=S[i+1]){c++;}
  }
    printf("%lld",min(k-(c-2*K+1),k-1));

}


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

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

    int W[N] = {0};

    for (int h = 0; h < N; h++)
    {
        cin >> W[h];
    }

    int dif = 1e9;
    for (int i = 0; i < N; i++)
    {
        int s1 = 0, s2 = 0;
        for (int l = 0; l < i; l++)
        {
            s1 += W[l];
        }
        for (int k = i; k < N; k++)
        {
            s2 += W[k];
        }
        dif = min(dif, abs(s1 - s2));
    }
    cout << dif << endl;

    return 0;
}

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

int main()
{
  string s;
  int n;
  cin >> s >> n;
  stack<int> a;
  for(int i = 0; i < (int)s.size(); i++){
    if(isdigit(s[i])){
      a.push(s[i]-'0');
    }else if(s[i] == '*'){
      int x = a.top() * (s[++i] - '0');
      a.pop();
      a.push(x);
    }
  }
  int x = 0;
  while(!a.empty()){
    x += a.top();
    a.pop();
  }
  for(int i = 0; i < (int)s.size(); i++){
    if(isdigit(s[i])){
      a.push(s[i]-'0');
    }else if(s[i] == '*'){
      int x = a.top() * (s[++i] - '0');
      a.pop();
      a.push(x);
    }else if(s[i] == '+'){
      int x = a.top() + (s[++i] - '0');
      a.pop();
      a.push(x);
    }
  }
  int y = a.top();
  if(n == x && n == y)
    cout << 'U';
  else if(n == x)
    cout << 'M';
  else if(n == y)
    cout << 'L';
  else
    cout << 'I';
  cout << endl;
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

int main()
{

    int n, m, i, j;
    scanf("%d", &n);
    char blue[n][12];
    for (i = 0; i < n; i++)
    {
        scanf("%s", &blue[i]);
    }

    scanf("%d", &m);
    char red[m][12];
    for (i = 0; i < m; i++)
    {
        scanf("%s", &red[i]);
    }

    int max = 0, cnt;
    for (i = 0; i < n; i++)
    {
        cnt = 0;
        for (j = 0; j < n; j++)
        {
            if (strcmp(blue[i], blue[j]) == 0)
                cnt++;
        }
        for (j = 0; j < m; j++)
        {
            if (strcmp(blue[i], red[j]) == 0){
                cnt--;
            }
        }
        if (max < cnt)
            max = cnt;
    }

    printf("%d\n", max);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int N, L;
   cin >> N >> L;
   int sum = (L*N) + N*(N-1)/2;

   if (L <= 0 && L+N-1 >= 0){
       cout << sum << endl;
   } else {
       int d = min(abs(L), abs(L+N-1));
       if(d == abs(L)){
         cout << sum - L << endl;
       } else {
           cout << sum - (L+N-1) << endl;
       }
   }

    return 0;
}

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int x, y, z;
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y;
}


Measured memory_bytes: 3544
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N, D;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }
  auto dist = [&](int i, int j) {
    int ret = 0;
    for (int k = 0; k < D; k++) {
      ret += (X[i][k]-X[j][k]) * (X[i][k]-X[j][k]);
    }
    return ret;
  };
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int sd = dist(i, j);
      int d = 0; while (d*d < sd) d++;
      if (sd == d*d) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
P=list(map(int,input().split()))
A=[]
for num in P:
    num=(num+1)*0.5
    A.append(num)

T=sum(A[:K])
ans=sum(A[:K])
for i in range(N-K):
    a=T-A[i]+A[i+K]
    ans=max(ans,a)
    T=a
print(ans)

Measured memory_bytes: 101848
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

	string S;
	cin >> S;
	char l = ' ';
	int ans = 0;
	for(int i=0; i<S.size(); i++){
		if(l != S[i]){
			ans++;
			l = S[i];
		}
	}
	cout << ans-1 << endl;

	return 0;
}


Measured memory_bytes: 512
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

int prevv[200010]; //頂点の最大数
struct edge{int to,cost;};

vector<ll> dijkstra(int n,vector<vector<edge> > G,int sv){
  fill(prevv,prevv+n,-1);
  priority_queue<pll,vector<pll>,greater<pll> > que;
  vector<ll> dist(n,lnf);
  dist[sv]=0;
  que.push(pll(0,sv));
  while(!que.empty()){
    ll cost; int v;
    tie(cost,v)=que.top();
    que.pop();
    if(dist[v]<cost) continue;
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      ll ec=e.cost;
      int nv=e.to;
      if(dist[nv]>dist[v]+ec){
        dist[nv]=dist[v]+ec;
        prevv[nv]=v;
        que.push(pll(dist[nv],nv));
      }
    }
  }
  return dist;
}

//頂点への最短路
vector<int> get_path(int t){
  vector<int> path(0);
  for(;t!=-1;t=prevv[t]) path.push_back(t);
  reverse(path.begin(),path.end());
  return path;
}

int main(){
  itn n; cin >> n;
  if(n==1){
    cout << "First" << endl;
    return 0;
  }
  vector<vector<edge> > g(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back({b,1});
    g[b].push_back({a,1});
  }
  vector<ll> dist1=dijkstra(n,g,0);
  itn v=-1;
  ll mx=-1;
  rep(i,n){
    if(chmax(mx,dist1[i])) v=i;
  }
  vector<ll> dist2=dijkstra(n,g,v);
  itn u=-1;
  mx=-1;
  rep(i,n){
    if(chmax(mx,dist2[i])) u=i;
  }
  int dia=mx+1;
  if((dia-2)%3==0){
    cout << "Second" << endl;
  }
  else cout << "First" << endl;
}

Measured memory_bytes: 39316
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

unsigned long long int gcd(unsigned long long int a,unsigned long long int b){
	if(a%b==0){
		return b;
	}else{
		return gcd(b,a%b);
	}
}
int main(){
	unsigned long long int N,T[100],ans;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>T[i];
	}
	ans=T[0];
	for(int i=0;i<N;i++){
		ans=(ans/gcd(ans,T[i]))*T[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
let inp = readLine()!.split(separator: " ").map { Int($0)! }
let (N, M) = (inp[0], inp[1])
let Hs = readLine()!.split(separator: " ").map { Int($0)! }
let roads = (1...M).map { _ -> (Int, Int) in
    let s = readLine()!.split(separator: " ").map { Int($0)! }
    return (s[0], s[1])
}

let dic0 = Dictionary(grouping: roads) { $0.0 }
let dic1 = Dictionary(grouping: roads) { $0.1 }

var r = 0
hr: for (i, h) in Hs.enumerated() {
    let js = (dic0[i+1] ?? []).map { $0.1 }
    if js.contains(where: { Hs[$0-1] >= h }) {
        continue
    }
    let ks = (dic1[i+1] ?? []).map { $0.0 }
    if ks.contains(where: { Hs[$0-1] >= h }) {
        continue
    }
    r += 1
}

print(r)


Measured memory_bytes: 24104
#include <bits/stdc++.h>
using namespace std;
const int N=505;
int n,m;
char g[N][N],R[N][N],B[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%s",g[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			R[i][j]=B[i][j]='.';
	for (int i=1;i<=m;i++)
		R[1][i]=B[n][i]='#';
	for (int i=2;i<n;i++)
		for (int j=1;j<=m;j++)
			if (j&1)
				R[i][j]='#';
			else
				B[i][j]='#';
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (g[i][j]=='#')
				R[i][j]=B[i][j]='#';
	for (int i=1;i<=n;i++)
		puts(R[i]+1);
	puts("");
	for (int i=1;i<=n;i++)
		puts(B[i]+1);
	return 0;
}

Measured memory_bytes: 1536
import numpy as np
N = int(input())
hs = input().split()
hs = np.array([int(h) for h in hs])

# hs = np.array([0,4,23,75,23,0,96,50,100])

def split_array(hs):
    split_indexes = np.where(hs==0)[0]
    n = len(split_indexes)
    split_list = []
    if n > 0:
        split_list.append(hs[0:split_indexes[0]])
        if n > 1:
            for i in range(n-1):
                split_list.append(hs[split_indexes[i]+1:split_indexes[i+1]])
        split_list.append(hs[split_indexes[-1]+1:])
    return split_list

def make_shower(l):
    count = l.min()
    return count, l-count

all_count = 0
c, hs = make_shower(hs)
split_list = split_array(hs)
all_count += c
zero_count = 0
#全部のリストが空になったところで終了
while True:
    zero_count = 0
    split_list_new = []
    for l in split_list:
        if len(l) == 0:
            zero_count += 1
            continue
        count, l_showered = make_shower(l)
        # print("count",count,l,l_showered)
        all_count += count
        split_list_ = split_array(l_showered)
        split_list_new.extend(split_list_)

    len_split_list = len(split_list) # リストの長さを取っておく
    split_list = [l for l in split_list_new] #代入
    
    if zero_count == len_split_list:
        break
print(all_count)


Measured memory_bytes: 13096
n = int(input())
s = input()

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

count = r_count*g_count*b_count


for i,elem in enumerate(s):
    length = min(i,n-1-i)
    for j in range(1,length+1):
        elem_2 = s[i-j]
        elem_3 = s[i+j]
        if elem != elem_2 and elem != elem_3 and elem_2 != elem_3:
            count -= 1

print(count)

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

const ll PrimeMax = 400000;
int is_prime[PrimeMax],K = 0;
void Eratosthenes(){
  for(int i = 0; i < PrimeMax; i++){
    is_prime[i] = 1;
  }
  is_prime[0] = 0;
  is_prime[1] = 0;
  for(int i = 2; i < PrimeMax ; i++){
    if(is_prime[i]){
      ++K;
      for(int j = 0; i * (j + 2) < PrimeMax; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;
  cin >> a;
  Eratosthenes();
  vector<int> v(K);
  map<int,int> m;
  REP(i,2,K){
    if(is_prime[i]){
      v[i] = i;
    }
  }
  ll c = 1,d = 0;
  for(int i = a; i >= 2 ;--i){
    for(auto && n : v){
      int j = i;
      if(n > i) break;
      while(1){
        if(n == 0) break;
        if(j % n == 0){
          j /= n;
          ++d;
        }
        else{
          /* cout << i << '=' << n <<  "^" << d << endl; */
          break;
        }
      }
      m[n] += d;
      d = 0;
    }
  }
  for(auto &&n :m){
    c = c % mod * (n.se + 1) %mod;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

int main() {
  string s, t;
  cin >> s >> t;
  int res = s.size();
  rep(i, s.size())
  {
    if (i + t.size() > s.size()) {
      break;
    }
    int cnt = 0;
    rep(j, t.size())
    {
      if (s[i+j] != t[j])
        cnt++;
    }
    res = min(res, cnt);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3588
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> graph(n);
    REP(i, n){
        graph[i].resize(n);
        REP(j, n){
            graph[i][j] = 0;
        }
    }
    int u, k, dst;
    REP(i, n){
        cin >> u >> k;
        u--;
        REP(j, k){
            cin >> dst;
            dst--;
            graph[u][dst]++;
        }
    }
    bool isFst = true;
    REP(i, n){
        REP(j, n){
            if(isFst){
                isFst = false;
                cout << graph[i][j];
            }
            else {
                cout << " " << graph[i][j];
            }
        }
        cout << endl;
        isFst = true;
    }
    return 0;
}


Measured memory_bytes: 3132
# include <cstdio>
# include <vector>
# include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i =0;i<n;i++)
int N , M ;
int P [100000] , Y [100000];
vector < int > yd [100001];
int main ()
{
    scanf("%d%d",&N,&M);
    rep(i,M){
        scanf("%d%d",&P[i],&Y[i]);
        yd[P[i]].push_back(Y[i]);}
    
    rep (i,N) sort(yd[i+1].begin(),yd[i+1].end());
    rep (i,M) printf ("%012lld\n",ll(P[i])*1000000+ int(lower_bound(yd[P[i]].begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
}


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

  int c[1001][1001];
  char Array1[1001],Array2[1001];
  int LCSLength();
int main(){
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;i++)
    {
        scanf("%s",Array1);
        scanf("%s",Array2);
        printf("%d\n",LCSLength(Array1,Array2));
    }
    return 0;
}
  
  
int LCSLength()
{
    int m, n;
    m=strlen(Array1)+1;
    n=strlen(Array2)+1;
    for(int i=1;i<m;i++)
    {
        c[0][i]=0;
    }
    for(int i=0;i<n;i++)
    {
        c[i][0]=0;
    }
    for(int i=1;i<m;i++)
    {
        for(int j=1;j<n;j++)
        {
            if(Array1[i-1]==Array2[j-1])
                c[i][j]=c[i-1][j-1]+1;
            else if(c[i-1][j]>=c[i][j-1])
                c[i][j]=c[i-1][j];
            else 
                c[i][j]=c[i][j-1];
        }
    }  
    return c[m-1][n-1];
}







Measured memory_bytes: 5780
import datetime

while True:
    T,H,S = map(int,input().split())
    if T == -1 and H == -1 and S == -1:
        break

    s0 = 2 * 60**2
    s  = T * 60**2 + H * 60 *1 + S

    s1 = s0 - s
    s3 = 3 * s1

    T1 = s1//60**2
    H1 = (s1-T1*60**2)//60
    S1 = s1 - T1*60**2 - H1*60*1

    if H1 < 10 and S1 < 10:
        print("0%d:0%d:0%d" %(T1,H1,S1))

    elif H1 <10 and S1 >=10:
        print("0%d:0%d:%d" %(T1,H1,S1))

    elif S1 <10:
        print("0%d:%d:0%d" %(T1,H1,S1))
    else:
        print("0%d:%d:%d" %(T1,H1,S1))


    T3  = s3//60**2
    H3 = (s3-T3*60**2)//60
    S3 = s3 - T3*60**2 - H3*60*1

    if H3 < 10 and S3 < 10:
        print("0%d:0%d:0%d" %(T3,H3,S3))

    elif H3 <10 and S3 >=10:
        print("0%d:0%d:%d" %(T3,H3,S3))

    elif S3 <10:
        print("0%d:%d:0%d" %(T3,H3,S3))
    else:
        print("0%d:%d:%d" %(T3,H3,S3))



Measured memory_bytes: 6044
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n, m;
    cin >> n;
    vector<int> d(n);
    map<int, int> mp;
    REP(i, n) {
        cin >> d[i];
        mp[d[i]]++;
    }
    cin >> m;
    vector<int> t(m);
    bool can = 1;
    REP(i, m) {
        cin >> t[i];
        if (mp[t[i]] != 0) mp[t[i]]--;
        else {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    

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

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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int N;
vector<vector<int>> G(110, vector<int>());
vector<int> d(110), f(110), k(110);
vector<bool> visited(110, false);
int t = 0;

void dfs(int v) {
	visited[v] = true;
	d[v] = t;
	//cout << v << " d[" << v << "]:" << d[v] << " " << t << endl;
	rep(i, k[v]) {
		if(visited[G[v][i]]) continue;
		t++;
		//cout << G[v][i] << " " << t << endl;
		dfs(G[v][i]);
		//cout << G[v][i] << " " << t << endl;
	}
	t++;
	f[v] = t;
	//cout << v << " f[" << v << "]:" << f[v] << endl;
	return;
}

int main() {
	cin >> N;
	rep(i,N) {
		int u;
		cin >> u >> k[i];
		G[i] = vector<int>(k[i]);
		rep(j,k[i]) {
			cin >> G[i][j];
			G[i][j]--;
		}
	}
	rep(i,N) {
		if(visited[i] == false) t++,dfs(i);
	}
	rep(i,N) cout << i+1 << " " << d[i] << " " << f[i] << endl;


  return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;
ll mod = 1e9+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}


const double PI=3.14159265358979323846;

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

  vector<int> L(N);
  rep(i, N) cin >> L[i];

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

  ll ans = 0;

  rep(a, N-2){
    for(int b=a+1; b<N-1; b++){
      int idx = lower_bound(L.begin(), L.end(), L[a]+L[b]) - L.begin();
      idx--;

      // cout << "a:" << L[a] << endl;
      // cout << "b:" << L[b] << endl;
      // cout << "c:" << L[idx] << endl;
      // cout << "added:" << idx - b << endl;

      ans += idx - b;
    }
  }

  cout << ans << endl;


  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    int A[5000];
    while (cin >> n && n)
    {
        for (int i = 0; i < n; i++)
        {
            cin >> A[i];
        }
        int S[5000];
        S[0] = A[0];
        int max = A[0];
        for (int i = 1; i < n; i++)
        {
            S[i] = S[i - 1] + A[i];
        }
        for (int i = 0; i < n; i++)
        {
            for (int j = i; j < n; j++)
            {
                int sum = 0;
                if (i != 0)
                {
                    sum = S[j] - S[i - 1];
                }
                else
                {
                    sum = S[j];
                }
                if (max < sum)
                {
                    max = sum;
                }
            }
        }
        cout << max << endl;
    }
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 4001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll,ll,ll>>>;

// MOD確認

int main(){
    string S;
    cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


Measured memory_bytes: 3572
import java.util.*;

public class Main{
  public static void main (String[]args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int N = sc.nextInt();
    int S = sc.nextInt();
    boolean c = false;
    for(int i = 1; i<= N; i++){
      if((i * A) % N == S){
        c = true;
      }
    }
    if(c){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>

using namespace std;

bool dfs(int a[14], int r[54], int n, int s, int p)
{
	if(p == n && s == 0){
		cout << r[n-1];
		for(int i = n-2; i >= 0;  i--){
			cout << " " << r[i];
		}
		cout << endl;
		return true;
	}
	if(p == n || s <= 0){
		return false;
	}
	
	for(int i = 1; i <= 13; i++){
		if(a[i] && (s-i)%i == 0){
			a[i]--;
			r[p] = i;
			if(dfs(a, r, n, s-i, p+1)){
				return true;
			}
			a[i]++;
		}
	}
	
	return false;
}

int main()
{
	int n, a[14], s, t, r[54];
	
	while(cin>>n && n){
		fill(a, a+14, 0);
		s = 0;
		for(int i = 0; i < n; i++){
			cin >> t;
			a[t]++;
			s += t;
		}
		
		if(!dfs(a, r, n, s, 0)){
			cout << "No" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 880
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int main(){
    int n,g,ng,max=0,ans;
    cin>>n;
    vector<int>a(n),gn(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>max)max=a[i];
    }
    g=a[0];
    for(int i=1;i<n;i++)g=gcd(g,a[i]);

    ans=g;

    for(int i=0;i<n;i++)gn[i]=a[i]/g;

    sort(a.begin(),a.end());
    //cout<<a[1]<<endl;

    for(ng=a[1]/g;ng>1;ng--){
        int count=0;
        for(int i=0;i<n;i++)if(gn[i]%ng)count++;
        if(count==1){cout<<g*ng<<endl;return 0;}
    }
    cout<<g<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i,x,y,tmp;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		if(y>x){
			tmp = x;
			x = y;
			y = tmp;
		}
		while(true){
			if(x%y == 0) {
				System.out.println(y);
				System.exit(0);
			}
			tmp = y;
			y = x % y;
			x = tmp;
		}
	}

}



Measured memory_bytes: 26400