akhauriyash/Code-Regression huggingface dataset:
n, q = map(int, input().split())
li = []
for i in range(n):
    p, ms = map(str, input().split())
    li.append([p, int(ms)])
t = 0
out = []
while True:
    if(len(out)==n):
        break
    a = li.pop(0)
    p, ms = a[0], a[1]
    if(ms <= q):
        t += ms
        out.append([p, t])
    else:
        ms -= q
        t += q
        li.append([p, ms])

for i in range(n):
    print(out[i][0], out[i][1])


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

int main() {
  
  int N;
  cin >> N;
  
  vector<int>p(N);
  for(int i=0; i<N; i++)  cin >> p.at(i);

  ///入力
  
  bool Ans=false;   ///回答の初期値入力"No"の状態
  
  vector<int> q(N);
  for(int i=0; i<N ; i++){
    q.at(i)+=i+1;
  }
  
  int count=0; ///相違の数を取得する値
  
  for(int i=0; i<N; i++){
    if(p.at(i)!=q.at(i)) count++;
  }
  
  
  if(count<=2) Ans=true;
  
  if(Ans==true) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(int argc, char **argv)
{
	int n ;
    cin>>n;
    
    int* vectorNum1 = new int[n];
    int* vectorNum2 = new int[n];
    
    for(int i =0;i<n;i++){
        cin>>vectorNum1[i];
    }
    
    for(int i =0;i<n;i++){
        cin>>vectorNum2[i];
    }
    
    // p = 1
    long double distance[4];
    for(int i=0;i<4;i++){
        distance[i] = 0.0;
    }
    
    for(int i =0 ;i<n;i++){
        int sum = abs(vectorNum1[i]-vectorNum2[i]);
        distance[0]+=sum;
    }
    cout.setf(ios::fixed);
    cout<<setprecision(6)<<distance[0]<<endl;
    
    // p = 2
    for(int i =0 ;i<n;i++){
        int sum = abs(vectorNum1[i]-vectorNum2[i]);
        distance[1]+= pow(sum,2);
    }
    
    
    distance[1] = sqrt(distance[1]);
    
    cout<<setprecision(6)<<distance[1]<<endl;
    
    // p = 3
    for(int i =0 ;i<n;i++){
        int sum = abs(vectorNum1[i]-vectorNum2[i]);
        distance[2]+= pow(sum,3);
    }
    
    distance[2] = cbrt(distance[2]);
    
    cout<<setprecision(6)<<distance[2]<<endl;
    
    long double max = 0;
    
    for(int i =0 ;i<n;i++){
        if(i==0){
            max = abs(vectorNum1[i]-vectorNum2[i]);
        }
        if(abs(vectorNum1[i]-vectorNum2[i])>max){
            max = abs(vectorNum1[i]-vectorNum2[i]);
        }
        
        distance[3] = max;
    }
    cout<<setprecision(6)<<distance[3]<<endl;
    
	return 0;
}

Measured memory_bytes: 3540
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

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

	int A, B, C;
	scanf("%1d%1d%1d", &A, &B, &C);

	printf("%d", (A == 1) ? 9 : (A == 9) ? 1 : A);
	printf("%d", (B == 1) ? 9 : (B == 9) ? 1 : B);
	printf("%d", (C == 1) ? 9 : (C == 9) ? 1 : C);
	printf("\n");

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

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

#define mod 1000000007
#define ll long long

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    if(n<=999)cout<<"ABC";
    else cout<<"ABD";
	
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S, T;
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s1, s2;
	cin >> s1 >> s2;
	if (s1.size() >= s2.size()) {
		for (int i = 0; i <= s1.size() - s2.size(); i++) {
			if (s2 == s1.substr(i, s2.size())) {
				printf("%d\n",i);
			}
		}
	}

	return 0;
}


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

         
                    
using namespace std;
                     
#define rep(i,a,b); for(long long int i=a;i<b;i++)
#define mk make_pair        
#define LIMIT 100007
#define MOD 1000000007
#define ll long long int
#define endl '\n'
#define min3(a,b,c) ((a>b)?((b>c?c:b):(a>c?c:a)))
#define max3(a,b,c) ((a<b)?((b<c?c:b):(a<c?c:a)))
#define min(a,b) (a>b?b:a)
// #define x.first x.f
// #define x.second x.s
#define max(a,b) (a<b?b:a)
#define pb push_back
#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

vector<ll> v;

void SieveOfEratosthenes(int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          v.pb(p); 
} 

ll smallestDivisor(ll n) 
{ 
    // if divisible by 2 
    if (n % 2 == 0) 
        return 2; 
  
    // iterate from 3 to sqrt(n) 
    for (ll i = 3; i * i <= n; i += 2) { 
        if (n % i == 0) 
            return i; 
    } 
  
    return n; 
}

int main() 
{ 
    FAST
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int x,n;
    cin>>x>>n;
    int p[n],t=0;
    rep(i,0,n) cin>>p[i];
    int v[101];
    memset(v,0,sizeof(v));
    rep(i,0,n) v[p[i]]=1;

    rep(i,0,102)
    {
    	if(v[i]==0 && abs(x-i)<abs(t-x)) t=i;
    }

    cout<<t;


    return 0; 
}  


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

int main(){
    int flag=0;
    int a,b,c;
    cin >>a>>b>>c;
    int ans=0;
    int MAX,maxmod2;
    int amod2=a%2,bmod2=b%2,cmod2=c%2;

    MAX=max(max(a,b),c);
    maxmod2 = MAX%2;

    ans += (MAX-a)/2 + (MAX-b)/2 + (MAX-c)/2;

    flag = abs(maxmod2-amod2) + abs(maxmod2-bmod2) +abs(maxmod2-cmod2);

    if(flag == 2)ans++;
    else if(flag == 1)ans += 2;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
//Orz yjz
#define ll long long
#define ull unsigned ll
const double EPS=1e-8;
const ll PR=19260817;
const ll inv2=500000004;
const ll inv3=333333336;
const int N=100005;
int n, a[N], cnt[2];
int main() {
	scanf("%d", &n);
	for (int i=0; i<n; i++) {
		scanf("%d", &a[i]);
		if (a[i]%2==0) {
			cnt[(a[i]%4)/2]++;
		}
	}
	int i=cnt[0]*2;
	if (i==n-1) i++;
	if (n-i>cnt[1]) puts("No");
	else puts("Yes");
	return 0;
}

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

//諸機能
#pragma region MACRO 
#define putans(x) cerr << "answer: " ; cout << (x) << endl
#define dputans(x) cerr << "answer: "; cout << setprecision(10) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define substr(s,i,l) string((s), (i), (l))
#define tos(x) (to_string((x)))
#ifdef _DEBUG //ファイルからテストデータを読み込む
	std::ifstream ifs("data.txt");
	#define input ifs >>
#else 
	#define input cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#ifndef _DEBUG
#define dbg1 {}
#define dbg2 {}
#define dbg3 {}
#define dbgArray {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll; 
typedef pair<int,int> pii; typedef pair<string,string> pss;typedef pair<int,string>pis;typedef pair<string,int>psi;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9 + 7)
#define INF (1e9)
#pragma endregion


int main()
{
	int n, k; input n >> k;
	int max = 100000;
	set<int> d;
	rep(i, k) {
		int di; input di;
		d.insert(di);
	}
	int tmp = n;
	while (true) {
		int judge = tmp;
		bool ok = true;
		while (judge != 0){
			dbg2(judge,judge - ( ( judge / 10 ) * 10 ));
			if (exist(d,judge - ((judge / 10)* 10))) {			
				ok = false;
				break;
			}
			judge /= 10;
		}
		if (ok){
			putans(tmp);
			break;
		}
		tmp++;
	}

	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()
if s[k-1]=="A":
	print(s[0:k-1]+"a"+s[k:n])
elif s[k-1]=="B":
	print(s[0:k-1]+"b"+s[k:n])
else:
	print(s[0:k-1]+"c"+s[k:n])
	


Measured memory_bytes: 3060
n = STDIN.gets.chomp.to_i
k = STDIN.gets.chomp.to_i
price = STDIN.gets.chomp.to_i
after_price = STDIN.gets.chomp.to_i

def calc(n,k,price,after_price)
  if n > k 
   return  k * price + (n-k) * after_price
  end

  if n <= k
    return n * price
  end
  
end

puts calc(n,k,price,after_price)

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define LLI long long int
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    int A,B,C,D;

    scanf("%d %d %d %d", &A, &B, &C, &D);

    for( i=0; A > 0 && C > 0; i++)
    {
        if( i&1)
        {
            A -= D;
        }
        else
        {
            C -= B;
        }
    }

    if( A > 0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 3684
/*
  Fuad Ashraful Islam
  University of Asia Pacific,Bangladesh
  Date:10th May 2020
  Category:DP
  ToDo:
 */
#include<bits/stdc++.h>
#define dbg(x) cerr <<__LINE__<<" where "<< #x << " = " << x << endl
#define all(x) (x).begin(),(x).end()

using namespace std;
template <class T> inline void read(T &res)
{
    res = 0; bool bo = 0; char c;
    while (((c = getchar()) < '0' || c > '9') && c != '-');
    if (c == '-') bo = 1; else res = c - 48;
    while ((c = getchar()) >= '0' && c <= '9')
        res = (res << 3) + (res << 1) + (c - 48);
    if (bo) res = ~res + 1;
}
const int N=2e5+5;
typedef long long ll;
int len,_,n,d,k,m,l,c,cs=1;
string s,t;

void HalfDead() 
{
  cin>>s;
  cin>>t;
  len=t.size();
  string temp=t.substr(0,len-1);
 // cout<<temp<<endl;
  s==temp?cout<<"Yes"<<endl:cout<<"No"<<endl;
}
int main()
{
  HalfDead();
  return 0;
}


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

int partition(int *a, int p, int r){
        int x = a[r];
        int i = p-1;
        for(int j=p;j<r;j++){
                if(a[j]<=x){
                        i++;
                        swap(a[i],a[j]);
                }
        }
        swap(a[i+1],a[r]);
        return i+1;
}

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

        int p = partition(a, 0, n-1);

        for(int i=0;i<n;i++){
                if(i==p) cout<<"[";
                cout<<a[i];
                if(i==p) cout<<"]";
                if(i<n-1) cout<<" ";
                else cout<<endl;
        }
        return 0;
}


Measured memory_bytes: 3484
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>

using namespace std;

#define ll long long
#define rep(i, n) for (i = 0; i < n; i++)

// n!が持つ2の素因数の個数
int div_by_two(int n)
{
  int j = 0;
  for (int i = 1; i < 20; i++)
  {
    j += (n / (1 << i)) * i;
  }
  return j;
}

// 二項係数計算
int COM(int n, int k)
{
  int l = (div_by_two(n) - div_by_two(k) - div_by_two(n - k));
  if (l == 0)
  {
    return 1;
  }
  else
  {
    return 0;
  }
}

int N;
string a;

int main()
{
  // 計算例
  // cout << COM(100000, 50000) << endl;

  cin >> N >> a;

  vector<int> b(N - 1);
  for (int i = 0; i < N - 1; i++)
  {
    b[i] = abs((a[i + 1] - '0') - (a[i] - '0'));
  }

  int even_or_odd = 0;
  for (int i = 0; i < N - 1; i++)
  {
    even_or_odd += b[i] * COM(N - 2, i);
    // cout << COM(N - 2, i) << endl;
    even_or_odd %= 2;
  }

  if (even_or_odd == 1)
  {
    cout << 1 << endl;
    return 0;
  }

  for (int i = 0; i < N - 1; i++)
  {
    if (b[i] == 1)
    {
      cout << 0 << endl;
      return 0;
    }
    b[i] /= 2;
  }

  even_or_odd = 0;
  for (int i = 0; i < N - 1; i++)
  {
    even_or_odd += b[i] * COM(N - 2, i);
    even_or_odd %= 2;
  }

  if (even_or_odd == 1)
  {
    cout << 2 << endl;
    return 0;
  }

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


Measured memory_bytes: 5252
#include <iostream>

using namespace std;


string s;

int main()
{
    int n,ans=1,i,j;
    cin>>n;
    cin>>s;
    for(i=0;i<s.size();)
    {
        j=i;
        while(j<s.size() - 1 &&s[j]==s[j+1])
            j++;
        if(j<s.size()-1)
            ans++;
        i=j+1;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;
class Main{


	static char[][] map;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		String n = sc.next();
		char[] cs = n.toCharArray();
		Arrays.sort(cs);
		if(cs[0] == cs[1] && cs[1] != cs[2] && cs[2] == cs[3]){
			System.out.println("Yes");
			return;
		}
		System.out.println("No");



	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



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




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}







	static int find(int index,int current,int[] students,int ans,int[][] memo){
		if(current == index){
			return 1;
		}

		if(memo[current][index] != 0){
			return memo[current][index];
		}

		memo[current][index] = find(index, students[current]-1, students, ans+1, memo)+1;

		return memo[current][index];
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



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




}






Measured memory_bytes: 23124
#include <iostream>

using namespace std;

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

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

    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3648
tanku = [5, 7, 5, 7, 7]
while True:
  n = int(input())
  if n==0:
    break
  w = [len(input()) for i in range(n)]
  ans = 0
  for i in range(n):
    sum = 0
    k = 0
    for j in range(i, n):
      sum += w[j]
      if sum == tanku[k]:
        sum = 0
        k += 1
        if k==5:
          ans = i+1
          break
      elif sum > tanku[k]:
        break
    if ans:
      break
  print(ans)


Measured memory_bytes: 5616
#include <stdio.h>

int main(void) {
	int x, i, n;
	scanf("%d", &n);
	for (i=1; i<=n; i++)
	{
		x=i;
		if (x%3==0)
		{
			printf(" %d", i);
		} 
		else
		{
			while (x!=0)
			{
				if (x%10==3)
				{
					printf(" %d", i);
					x=0;
				} 
				x/=10;
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 596
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = new String[2];
		int in[] = new int[2];
		int cnt;
		while(true){
			str = br.readLine().split(" ");
			in = parseInts(str);
			if(in[0]==0 && in[1]==0) break;
			cnt = 0;
			for(int n=1; n<in[0]-1; n++){
				for(int m=n+1; m<in[0]; m++){
					for(int l=m+1; l<=in[0]; l++){
						if(n+m+l==in[1]){
							cnt = cnt + 1;
						}
					}
				}
			}
			System.out.println(cnt);
		}
	}
	static int[] parseInts(String[] s){
		int[] x = new int[s.length];
		for(int i=0; i<s.length; i++){
			x[i] = Integer.parseInt(s[i]);
		}
		return x;
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

const int INF=1001001001;
const int INFLL=1001001001001001001ll;
const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

int N,M;
int X[111111],Y[111111];

bool ex[111111];
bool ne[444][444];

void calc(int s){
    ne[s][s]=true;
    for(int i=M-1;i>=0;i--){
        if(ne[s][X[i]]&&ne[s][Y[i]]){
            return;
        }
        if(ne[s][X[i]]||ne[s][Y[i]]){
            ne[s][X[i]]=ne[s][Y[i]]=true;
        }
    }

    ex[s]=true;
}

signed main(){
    cin>>N>>M;
    rep(i,M)cin>>X[i]>>Y[i],X[i]--,Y[i]--;

    rep(i,N)calc(i);

    int ans=0;
    for(int i=0;i<N;i++){
        if(!ex[i])continue;
        for(int j=i+1;j<N;j++){
            if(!ex[j])continue;
            bool ok=true;
            rep(k,N)if(ne[i][k]&&ne[j][k])ok=false;
            ans+=ok;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// a^n mod を計算する
// O(logn)
ll modpow(ll a, ll n, ll mod=998244353) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll cnt[100010];

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

    vector<ll> d(n);
    rep(i,n){
        cin>>d[i];
        cnt[d[i]]++;
    }

    if(d[0]!=0 || cnt[0]!=1){
        cout<<0<<endl;
        return 0;
    }

    ll ans=1;

    for(int i=1;i<100010;i++){
        ll tmp=modpow(cnt[i],cnt[i+1]);
        ans=(ans*tmp)%998244353;
    }

    cout<<ans<<endl;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, C, K;
    cin >> N >> C >> K;
    vector<ll> T(N);
    REP(i, N)
    {
        cin >> T[i];
    }
    sort(ALL(T));

    ll ans = 0;
    ll countNow = 0;
    ll timeLimitDeparture = 0;
    REP(i, N)
    {   
        if (countNow < C)
        {
            if (countNow == 0)
            {
                ans++;
                timeLimitDeparture = T[i] + K;
                countNow = 1;
            }
            else
            {
                if (timeLimitDeparture >= T[i])
                {
                    countNow++;
                }
                else
                {
                    ans++;
                    timeLimitDeparture = T[i] + K;
                    countNow = 1; 
                }
            }
            
        }
        else
        {
            ans++;
            timeLimitDeparture = T[i] + K;
            countNow = 1; 
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
import scala.io.StdIn.readLine

object Main extends App {

  val Array(n, k) = readLine.split(" ").map(_.toInt)
  val hs: List[Int] = (0 until n).map(_ => readLine.toInt).toList

  val sorted = hs.sorted.toArray

  var min = 2147483647

  (0 to (n - k)).foreach { i =>
    val sa = sorted(i + k - 1) - sorted(i)
    if (sa < min) min = sa
  }

  println(min)

}

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

int main(){

  long X;
  cin >> X;
  
  int cnt;
  int quo;
  int rem;
  cnt = 0;
  quo = (int)(X / 100);
  rem = X % 100;
  
  while(rem >= 5){
    rem = rem - 5;
    cnt = cnt + 1;
  }
  while(rem >= 4){
    rem = rem - 4;
    cnt = cnt + 1;
  }
  while(rem >= 3){
    rem = rem - 3;
    cnt = cnt + 1;
  }
  while(rem >= 2){
    rem = rem - 2;
    cnt = cnt + 1;
  }
  while(rem >= 1){
    rem = rem - 1;
    cnt = cnt + 1;
  }
  if(cnt <= quo){
    cout << 1;
  }
  else{
	cout << 0;
  }
  return 0;
}

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

int a[2005];

int main()
{
    int n,ans = 0;
    scanf("%d",&n);
    for(int i = 0;i < n;++i) scanf("%d",&a[i]);
    sort(a,a+n);

    for(int i = 0;i < n;++i){
        for(int j = i+1;j < n;++j){
            int t1 = upper_bound(a+j,a+n,a[j]-a[i]) - a;
            int t2 = lower_bound(a+j,a+n,a[j]+a[i]) - a - 1;

            ans += max(0,t2-t1);
        }
    }

    printf("%d",ans);
    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int p, q, r;
    cin >> p >> q >> r;
    int ans = p + q + r;
    int m = max(max(p, q), r);
    ans -= m;
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ll n,k,s;
    cin >> n >> k >> s;
    for(int i=0;i<k;i++){
        printf("%lld ",s);
    }
    ll ans=1000000000;
    if(s==1000000000)
        ans=1;
    for(int i=0;i<n-k;i++){
        printf("%lld ",ans);
    }
    return 0;
}

Measured memory_bytes: 1280
H, W = gets.split.take(2).map(&:to_i)
N = gets.to_i
A = gets.split.take(N).map(&:to_i)

DIRS = [[1, 0], [0, 1], [-1, 0], [0, -1]]

board = [[-1] * (W+2)] + H.times.map{[-1] + [0] * W + [-1]} + [[-1] * (W+2)]

dir_idx = 0
y = x = 1

A.each.with_index(1){|n, i|
  n.times{
    board[y][x] = i
    dx, dy = DIRS[dir_idx]
    if board[y + dy][x + dx] != 0
      dir_idx = (dir_idx + 1) % 4
    end
    dx, dy = DIRS[dir_idx]
    y += dy
    x += dx
  }
}

board[1..-2].each{|line|
  puts line[1..-2]*" "
}


Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
const int N = 2e6+5;
int n;
char s[N];
int g[N];
 
int v[N], h[N];
 
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	int mx=0,ss=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='1')ss++;
		else ss--;
		v[i]=h[i]=ss;
		mx=max(mx,ss);
	}
	int mn=0;
	for(int i=n-1;i;i--)v[i]=max(v[i],v[i+1]);
	// cerr << mx << "?" << endl;
	ss=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='1')ss++;
		else if(s[i]=='0')ss--;
		else if(s[i]=='?'){
			// cerr << ss+1+g[i+1] << " " << mx << endl;
			if(ss+v[i]+2-h[i-1]<=mx)ss++;
			else ss--;
		}
		// assert(ss<=mx);
		// cerr << ss << ",";
		// cerr << g[i+1] << "?" << endl;
		mn=min(mn,ss);
	}
	int ans=mx-mn;
	mn=ss=0;
	++mx;
	for(int i=1;i<=n;i++){
		if(s[i]=='1')ss++;
		else if(s[i]=='0')ss--;
		else if(s[i]=='?'){
			// cerr << ss+1+g[i+1] << " " << mx << endl;
			if(ss+v[i]+2-h[i-1]<=mx)ss++;
			else ss--;
		}
		// assert(ss<=mx);
		// cerr << ss << ",";
		// cerr << g[i+1] << "?" << endl;
		mn=min(mn,ss);
	}
	ans=min(ans,mx-mn);
	printf("%d\n",ans);
}


Measured memory_bytes: 12656
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 N;
    read(N);

    i64 p = 1;
    reps(i, 1, N) {
        p *= i;
        p %= (int(1e9) + 7);
    }

    print(p);

    return 0;
}


Measured memory_bytes: 256
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

typedef complex<double> P;
const double EPS = 1e-8;
struct C{P p;double r;};

struct Edge{
    int dst;
    double cost;
};

typedef vector<Edge> Node;
typedef vector<Node> Graph;

void add_edge(Graph& G, int a, int b, double c) {
    G[a].push_back({b, c});
}

double distance(C c1, C c2) {
    double d = abs(c1.p - c2.p);
    return max(0.0, d - c1.r - c2.r);
}

vector<double> dijkstra(const Graph& G, int s){
    typedef pair<double, int> P;
    priority_queue<P, vector<P>, greater<P>> que;
    vector<double> dist(G.size(), 1e60);
    que.push(P(0.0, s));
    dist[s] = 0.0;
    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        double c = p.first;
        if(c > dist[v]) continue;
        for(auto& e : G[v]){
            if(dist[e.dst] > dist[v] + e.cost){
                dist[e.dst] = dist[v] + e.cost;
                que.push(P(dist[e.dst], e.dst));
            }
        }
    }
    return dist;
}


int main(){
    iostream_init();
    double sx, sy, gx, gy;
    while(cin >> sx >> sy >> gx >> gy) {
        C start, goal;
        start.p = P(sx, sy);
        start.r = 0;
        goal.p = P(gx, gy);
        goal.r = 0;
        int N;
        cin >> N;
        vector<C> circles(N);
        REP(i, N) {
            double x, y, r;
            cin >> x >> y >> r;
            circles[i].p = P(x, y);
            circles[i].r = r;
        }
        circles.push_back(start);
        circles.push_back(goal);

        const int M = circles.size();
        Graph G(M);
        for(int i = 0; i < M; i++) {
            for(int j = 0; j < M; j++) {
                if(i != j) {
                    add_edge(G, i, j, distance(circles[i], circles[j]));
                }
            }
        }
        auto dist = dijkstra(G, M-2);
        cout << dist.back() << endl;
    }
    return 0;
}



Measured memory_bytes: 20604
#include <bits/stdc++.h>
    //#define int long long
    typedef long long ll;
    #define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
    #define forn(i, n) fore(i, 0, n)
    #define fori(i, l, r) fore(i, l, (r) + 1)
    #define sz(v) int((v).size())
    #define all(v) (v).begin(), (v).end()
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    using namespace std; 
     
    const double PI = atan(1)*4;

    int dx[8]={1,0,-1,0,1,-1,-1,1};
    int dy[8]={0,1,0,-1,1,1,-1,-1};
     
     
    bool isprime(int n)
    {
        for(int i=2;i*i<=n;i++)
            if(n%i==0)
                return false;
        return true;
    }
     
    bool comp(pair<int,int> a, pair<int,int> b)
    {
        return b.ff < a.ff ;
    }
     
    int modpow(int b,int p,int m)
    {
        if(p==0) return 1%m;
        if(p%2) return (b*modpow(b,p-1,m))%m;
        int u=modpow(b,p/2,m);
        return (u*u)%m;
    }
     
    int fn(int x,int y,int z)
    {
        int ans=((x-y)*(x-y) + (y-z)*(y-z) + (z-x)*(z-x) );
        //cout<<x<<" "<<y<<" "<<z<<"\n";
        return ans; 
    }
     
    /*void bsearch(int max,int min)   //  for function 
    //void bsearch(int a,int n, int x)     // for array
    {
        int k=min;
     
        //  for array
     
    /*    for(int b=n/2; b>=1; b/=2)
        {
            while(k+b<n && arr[k+b]<=x) k+=b; 
        }
     
        if(arr[k]==x)
            cout<<"found at "<<k+1;
        else
            cout<<"not found";
    */
     
        //  for function 
     
    /*    for(int b=max; b>=1; b/=2)
        {
            while( !fn(b+k) ) k+=b;
        }
        cout<<k+1;
     
    }*/
     
     
    int main()
    {
     
        int t=1;
        //cin>>t;
     
        while(t--)
        {
            string s,t;
            cin>>s>>t;
            t.pop_back();

            if(s==t)
                cout<<"Yes";
            else
                cout<<"No";
        }
        return 0;
    }

Measured memory_bytes: 3600
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim();
	let s1 = &s[0..2];
	let s2 = &s[2..4];
	let f1:i32 = s1.to_string().parse().ok().unwrap();
	let f2:i32 = s2.to_string().parse().ok().unwrap();
	if f1 > 12 && f2 > 12 {
		println!("NA");
	}else if f1 == 0 && f2 > 12{
		println!("NA");
	}else if f1 > 12 && f2 == 0{
		println!("NA");
	}else if f1 == 0 && f2 == 0{
		println!("NA");
	}else if f1 == 0 && f2 <= 12{
		println!("YYMM");
	}else if f1 <= 12 && f2 == 0{
		println!("MMYY");
	}else if f1 <= 12 && f2 > 12 {
		println!("MMYY");
	}else if f1 > 12 && f2 <= 12 {
		println!("YYMM");
	}else{
		println!("AMBIGUOUS");
	}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<vector<ll>> dp(2,vector<ll>(9,LLONG_MIN/5));
  dp[0][4] = 0;

  rep(i,n){
    vector<vector<ll>> ndp(2,vector<ll>(9,LLONG_MIN/5));
    rep(l,9){
      if((i+1)%2==0){
        if(l>0){
          ndp[0][l-1] = max(ndp[0][l-1],dp[1][l]);
          ndp[0][l-1] = max(ndp[0][l-1],dp[0][l]);
        }
        ndp[1][l] = max(ndp[1][l],dp[0][l]+a[i]);
      }
      else{
        ndp[0][l] = max(ndp[0][l],dp[1][l]);
        ndp[0][l] = max(ndp[0][l],dp[0][l]);
        if(l<8) ndp[1][l+1] = max(ndp[1][l+1],dp[0][l]+a[i]);
      }
    }
    // cout << ndp[0][4] << " " << ndp[1][4] << endl;
    swap(ndp,dp);
  }
  cout << max(dp[1][4],dp[0][4]) << endl;


  return 0;
    

}


Measured memory_bytes: 3944
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char * argv[])
{
	unsigned int n = 0;
	while (cin >> n) {
		vector<unsigned long long> t(n);
		vector<unsigned long long> a(n);

		unsigned long long max_t = 0;
		unsigned int max_index = 0;
		for (unsigned int i = 0;i < n; ++i) {
			cin >> t[i];

			if (t[i] > max_t) {
				max_t = t[i];
				max_index = i;
			}
		}
		for (unsigned int i = 0;i < n; ++i) {
			cin >> a[i];	
		}

		if (t[max_index] != a[max_index]) {
			cout << "0" << endl;
		}
		else {
			vector<unsigned long long> max(n);
			vector<unsigned long long> min(n);
			min[0] = t[0];
			max[0] = t[0];
			min[n - 1] = a[n - 1];
			max[n - 1] = a[n - 1];

			for (unsigned int i = 1; i < n - 1; ++i) {
				min[i] = 1;
				max[i] = t[i];
				if (t[i] > t[i - 1]) {
					min[i] = t[i];
				}
			}
			
			for (unsigned int i = 1; i < n - 1; ++i) {
				if (a[n - 1 - i] < max[n - 1 - i]) {
					max[n - 1 - i] = a[n - 1 - i];
				}
				if (a[n - 1 - i] > a[n - i]) {
					min[n - 1 - i] = a[n - 1 - i];
				}
			}
			
			unsigned long long count = 1;
			for (unsigned int i = 0; i < n; ++i) {
				count *= (max[i] - min[i] + 1) % (1000000000 + 7);
				count %= (1000000000 + 7);
			}
			cout << count << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;

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

	unordered_map<int, int> hashmap;
	int d;
	for (int i = 0; i < N; i++) {
		cin >> d;
		hashmap[d]++;
	}

	int count = 0;
	for (pair<int, int> p : hashmap) {
		count = count + 1;
	}
	cout << count << endl;
}

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

int main(){
  int n,m; cin >> n >> m;
  int r = 0, l = 10001000;
  for(int i = 0; i < m; i++){
    int a,b; cin >> a >> b;
    r = max(r,a);
    l = min(l,b);
  }
  int ans = 0;
  for(int i = r; i <= l; i++){
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

const int MAXN = 1000000;
Int fact[MAXN], inv[MAXN];

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

void init_fact() {
    fact[0] = 1;
    for(int i=1; i<MAXN; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    inv[MAXN - 1] = mod_pow(fact[MAXN - 1], MOD-2);
    for(int i=MAXN - 2; i>=0; i--) {
        inv[i] = (inv[i+1] * (i+1)) % MOD;
    }
}

Int comb(int n, int r) {
    if(r < 0 || n < r) return 0;
    return fact[n] * inv[n-r] % MOD * inv[r] % MOD;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

char s[100005];
char st;
void rec(char a, char b){
    if (a == 'T' && b == 'F') st = 'F';
    else st = 'T';
}
int field[10][10];
vector<int> ans;

int rec(int a, int b, int c, int d){
    int cnt = 0;
    for (int i = a; i <= c; i++){
        for (int j = b; j <= d; j++){
            if (field[i][j]){
                cnt++;
            }
        }
    }
    ans.push_back(cnt);
    return 0;
}

int main(){
    cin.tie(0);

    for (int i = 0; i < 8; i++){
        for (int j = 0; j < 8; j++){
            field[i][j] = 1;
            if (i % 2 == 0){
                if (j % 2){
                    field[i][j] = 0;
                }
            }
        }
    }
    int N; cin >> N;
    for (int i = 0; i < N; i++){
        int a, b, c, d; cin >> a >> b >> c >> d;
        rec(a-1, b-1, c-1, d-1);
    }
    for (int i = 0; i < N; i++){
        cout << ans[i] << endl;
    }
    

}



Measured memory_bytes: 3312
unittest
{
	assert( [ "5", "3", "2", "4", "3", "5" ].solve == 7 );
	assert( [ "10", "123", "123", "123", "123", "123" ].solve == 5 );
	assert( [ "10000000007", "2", "3", "5", "7", "11" ].solve == 5000000008 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto abcde = new long[ 5 ];
	foreach( ref x; abcde )
	{
		input.popFront;
		x = input.front.to!( long );
	}
	
	auto m = abcde.reduce!min;
	return 4 + ( n + m - 1 ) / m;
}


Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
int n,c,l[10];
double dp[500][(1<<7)],t,ans;
int main(){
    cin>>n>>c;
    for(int i=0;i<n;i++) cin>>l[i];
    sort(l,l+n);
    do{
        memset(dp,0,sizeof(dp));
        dp[l[n-1]*n][0]=1;
        for(int i=0;i<=n*c;++i)
        for(int j=i;j<=n*c;++j)
        for(int S=0;S<(1<<n-1);++S)
            if(i%n&&!((S>>(i%n-1))&1))
                dp[min(n*c,max(j,i+l[i%n-1]*n))][S|(1<<(i%n-1))]+=dp[j][S];
        ans+=dp[n*c][(1<<n-1)-1];
        t++;
    }while(next_permutation(l,l+n-1));
    printf("%.15lf",(double)ans/t/pow(c,n-1));
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n,m,i,j,k,s=0;
  string id[256],str;
  cin >> n;
  for(i=0;i<n;i++) cin >> id[i];
  cin >> m;
  for(i=0;i<m;i++){
    cin >> str;
    k=0;
    for(j=0;j<n;j++){
      if(id[j]==str) k=1;
    }
    if(k==0) cout << "Unknown " << str << endl;
    else if(s==0) {
      cout << "Opened by " << str << endl;
      s=1;
    }else{
      cout << "Closed by " << str << endl;
      s=0;
    }
  }
   
  
  return 0;
}

Measured memory_bytes: 1216
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    res = ""
    for i in range(0, len(s), 2):
        res += s[i]
    print(res)


if __name__ == '__main__':
    resolve()


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

int main() {
    int n,k,p[200010];
    double ans,hoge;
    double e[200010];
    cin >> n>> k;
    for(int i=0;i<n;i++){
        cin >> p[i];
        e[i] = 0.5*(1.0/(double)p[i])*(1+p[i])*p[i];
    }

    for(int i=0;i<n-k + 1;i++){
        if(i == 0){
            hoge = 0;
            for(int j=0;j<k;j++){
                hoge += e[j];
            }
            ans = hoge;
        }else{
            hoge -= e[i-1];
            hoge += e[i + k - 1];
            if(hoge > ans)ans = hoge;
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<functional>

using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

int n, m, s, t;

ll dis_from_s[100000], dis_from_t[100000];
ll cnt_dis_s[200000], cnt_dis_t[200000];
vector<vector<int>> edge;

void djk(int pos, ll dis[], ll cnt[]) {
	
	priority_queue<P, vector<P>, greater<P>> pq;
	pq.push(P(0, pos));
	dis[pos] = 0;
	while (pq.size()) {
		auto tmp = pq.top(); pq.pop();
		if (dis[tmp.second] < tmp.first)continue;

		cnt[tmp.first]++;

		for (int i = 0; i < edge[tmp.second].size(); i++) {
			int next = edge[tmp.second][i];
			if (dis[next] > dis[tmp.second] + 1) {
				dis[next] = dis[tmp.second] + 1;
				pq.push(P(dis[tmp.second] + 1, next));
			}
		}
	}
}

int main() {

	cin >> n >> m >> s >> t;
	s--, t--;
	edge.resize(n);
	for (int i = 0; i < n; i++)dis_from_s[i] = 100000000, dis_from_t[i] = 1000000000;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	djk(s, dis_from_s, cnt_dis_s), djk(t, dis_from_t, cnt_dis_t);
	
	ll ans = 0;
	
	int s_to_t = dis_from_s[t];

	for (int i = 0; i <= s_to_t - 2; i++) {
		ans += (cnt_dis_s[i] * cnt_dis_t[s_to_t - 2 - i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12544
import java.util.*;

class Main{
	public static void main(String args[]){
		int num = 3;
		int x;
		Scanner scan = new Scanner(System.in);
		StringBuffer sb = new StringBuffer();
		x = scan.nextInt();

		while(true){
			if(x < num){
				break;
			}
			if(num % 3 == 0 || Integer.toString(num).contains("3")){
				sb.append(" " + num);
			}
			num++;
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 28908
#include <iostream>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main()
{
	char a[11] = {0};
	char b[11] = {0};
	char c[11] = {0};
	
	cin >> a >> b >> c;

	a[0] = (toupper(a[0]));
	b[0] = (toupper(b[0]));
	c[0] = (toupper(c[0]));
	cout << a[0] << b[0] << c[0] << "\n";
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W, K;
ll DP[10];
ll ans[105][10];

int main(){
  cin >> H >> W >> K;

  DP[0] = 1; DP[1] = 1;
  for (int i = 2; i <= W; i++){
    DP[i] = DP[i-1] + DP[i-2];
  }

  ans[0][0] = 1;
  for (int i = 1; i <= H; i++){
    for (int j = 0; j < W; j++){
      ll now = ans[i-1][j];
      now *= DP[W-1-j];
      now *= DP[j];
      ans[i][j] += now; ans[i][j] %= MOD;
    }
    for (int j = 1; j < W; j++){
      ll now = ans[i-1][j-1];
      if (j-1 >= 0) now *= DP[j-1];
      if (W-1-j >= 0) now *= DP[W-1-j];
      ans[i][j] += now; ans[i][j] %= MOD;
    }

    for (int j = 0; j < W-1; j++){
      ll now = ans[i-1][j+1];
      if (W-2-j >= 0) now *= DP[W-2-j];
      now *= DP[j]; 
      ans[i][j] += now; ans[i][j] %= MOD;
    }
  }

  cout << ans[H][K-1] << endl;

  return 0;
}


Measured memory_bytes: 3656
n=97,t,s;
int c(int i,int j,int k){printf("< %d %d %d ",i,j,k);}
int a(int i,int j,int k){printf("+ %d %d %d ",i,j,k);}
int b(int i,int j,int k){a(i,j,98);c(n,98,99);a(k,99,k);}
int m(int i,int j,int k){for(t=0;t<59;++t){a(k,k,k);for(s=0;s<=t;++s)if(s<30&&s+30>t)b(i+t-s,j+s,k);}}
int d(int x,int i,int j){for(t=0;t<30;++t){a(j+t-1,j+t-1,j+t);a(j+t,n,j+t);for(s=t;s<29;++s)a(j+s,j+s,j+s+1);c(j+29,x,i+t);a(j+t-1,j+t-1,j+t);a(j+t,i+t,j+t);}}
main(){puts("3933");a(0,1,n);c(2,n,n);a(0,n,3);a(1,n,4);d(3,5,36);d(4,36,67);m(5,36,2);}

Measured memory_bytes: 1656
#include <iostream>

int main() {
	long A, B, C, D;
	std::cin >> A >> B >> C >> D;
	while (1) {
		C -= B;
		if(C <= 0) {
			std::cout << "Yes" << std::endl;
			break;
		}
		A -= D;
		if(A <= 0) {
			std::cout << "No" << std::endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3124
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int MAX_N=100009;
int tree[3*MAX_N];
int inv=0;

int N,Q;

void init(int _N,int iniv)
{
	for(N=1;N<=_N;)
		N*=2; 
	for(int i=0;i<2*N-1;i++)
		tree[i]=iniv;
}

void update(int p,int a)
{
	p+=N-1;
	tree[p]+=a;
	for(;p>0;)
	{
		p=(p-1)/2;
		tree[p]=tree[p*2+1]+tree[p*2+2];
	}
}

int query(int l,int r,int k,int nl,int nr)
{
	if(nr<=l||r<=nl)return inv;
	if(l<=nl&&nr<=r)return tree[k];
	 
	int vl=query(l,r,k*2+1,nl,(nl+nr)/2);
	int vr=query(l,r,k*2+2,(nl+nr)/2,nr);
	return vl+vr;
}


int main()
{
	scanf("%d%d",&N,&Q);
	init(N,inv);
	for(int i=0;i<Q;i++)
	{
		int con,x,y;
		scanf("%d%d%d",&con,&x,&y);
		if(!con)
			update(x,y);
		else
			printf("%d\n",query(x,y+1,0,0,N));
	}
}

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

int main() {
  string s;
  cin>>s;
  int j=0;
  std::vector<string> a(s.size());
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){a[j]='0';j++;}
    if(s[i]=='1'){a[j]='1';j++;}
    if(s[i]=='B'&&j>0)j--;
  }
  for(int i=0;i<j;i++)cout<<a[i];
  cout<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
a, b, m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = [list(map(int,input().split())) for i in range(m)]

ans = min(A) + min(B)
for i in range(m):
    ans = min(ans, A[C[i][0]-1] + B[C[i][1]-1] - C[i][2])
print(ans)


Measured memory_bytes: 77404