akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
N=int(input())
T=list(map(int,input().split()))
S=[]
S.append("")
for i in range(N-1):
    if T[i]==T[i+1]:
        S.append("E")
    elif T[i]>T[i+1]:
        S.append("D")
    else:
        S.append("U")
    
#print(T)
#print(S)

pos=1
ans=1000
stock=0

buyflag=False

while pos<N:
    if buyflag==False:
        if S[pos]=="U":
            stock=ans//T[pos-1]
            ans=ans-T[pos-1]*stock
            buyflag=True
    elif buyflag==True:
        if S[pos]=="D":
            ans=ans+T[pos-1]*stock
            stock=0
            buyflag=False
    
    pos+=1
ans+= stock*T[pos-1]

print(ans)

Measured memory_bytes: 9240
package main

import (
	"fmt"
	"sort"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	var r float64
	r = (float64(a[0]) + float64(a[1])) / 2
	for i := 2; i < n; i++ {
		r = (r + float64(a[i])) / 2
	}
	fmt.Println(r)
}


Measured memory_bytes: 512
def get_int
  gets.to_i
end

def get_int_array
  gets.chomp.split(' ').map(&:to_i)
end

def main
  n = get_int
  ls = get_int_array

  longest = ls.max
  sum = ls.inject(:+) - longest

  puts longest < sum ? 'Yes' : 'No'
end

main


Measured memory_bytes: 1788
#include<stdio.h>

int main(void)
{
  int D = 0, N = 0;
  long ans = 0;
  scanf("%d%d", &D, &N);

  if(D == 0){
    if(N == 100){
      ans = 101;
    }else{
      ans = 1 * N;
    }
  }else if(D == 1){
    if(N == 100){
      ans = 10100;
    }else{
    ans = 100 * N;
    }
  }else{
    if(N == 100){
      ans = 1010000;
    }else{
      ans = 10000 * N;
    }
  }

  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    deque<ll> que;
    rep(i,N){
        auto itr = lower_bound(que.begin(),que.end(),A[i]);
        if(itr == que.begin()){
            que.push_front(A[i]);
        }else{
            *(--itr) = A[i];
        }
    }
    cout << que.size() << endl;
}

Measured memory_bytes: 4768
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

vector<ll> sum;

ll merge_count(vector<ll> &a){
    int n=a.size();
    if(n<=1) return 0;

    ll cnt=0;
    vector<ll> b(a.begin(),a.begin()+n/2);
    vector<ll> c(a.begin()+n/2,a.end());

    cnt+=merge_count(b);
    cnt+=merge_count(c);

    ll ai=0,bi=0,ci=0;
    while(ai<n){
        if(bi<b.size() && (ci==c.size() || b[bi]<=c[ci])){
            a[ai++]=b[bi++];
        }
        else{
            cnt+=n/2-bi;
            a[ai++]=c[ci++];
        }
    }
    return cnt;
}

int main(){
    ll n,k; cin>>n>>k;
    vector<ll> a(n,0);
    sum.assign(n+1,0);
    rep(i,n){
        cin>>a[i]; a[i]-=k;
        sum[i+1]=sum[i]+a[i];
    }
    cout<<n*(n+1)/2-merge_count(sum)<<endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    int a, b;
    rep(0, i, M)
    {
        cin >> a >> b;
        a--;
        b--;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }

    vector<int> dist(N, -1);
    queue<int> que;
    vector<bool> seen(N, false);

    dist.at(0) = 0;
    que.push(0);
    seen.at(0) = true;

    while (que.size())
    {
        int v = que.front();
        que.pop();
        for (auto g : graph.at(v))
        {
            if (seen.at(g))
            {
                continue;
            }
            dist.at(g) = dist.at(v) + 1;
            que.push(g);
            seen.at(g) = true;
        }
        seen.at(v) = true;
    }

    rep(0, i, N)
    {
        if (dist.at(i) == -1)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    rep(0, i, N)
    {
        if (i == 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            int m = N;
            int index;
            for (auto g : graph.at(i))
            {
                if (m > dist.at(g))
                {
                    m = dist.at(g);
                    index = g;
                }
            }
            cout << index + 1 << endl;
        }
    }
}

Measured memory_bytes: 10128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final int K = scn.nextInt();

			int sum = 0;
			for (int a = 1; a <= K; a++) {
				for (int b = 1; b <= K; b++) {
					int ab = gcd(Math.max(a, b), Math.min(a, b));
					for (int c = 1; c <= K; c++) {
						sum += gcd(Math.max(ab, c), Math.min(ab, c));
					}
				}
			}
			System.out.println(sum);
		}
	}

	static int gcd(int a, int b) {
		if (a == 0) {
			return b;
		} else if (b == 0) {
			return a;
		}
		if (a > b) {
			return gcd(a % b, b);
		} else {
			return gcd(b % a, a);
		}
	}
}


Measured memory_bytes: 27656
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

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

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main() {
	ll n;
	cin >> n;
	vll P(n);
	for (auto& e : P)cin >> e;
	ll i;
	ll ans = 0;
	for (i = 1; i < n - 1; i++) {
		ll m = min(min(P[i - 1], P[i]), P[i + 1]);
		ll M = max(max(P[i - 1], P[i]), P[i + 1]);
		if (m != P[i] && M != P[i]) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
s = input()
s_n = int(s)
dig = len(s)

if dig == 1:
	cnt = 0
	for i in range(len(s)):
		cnt += int(s[i])
	print(cnt)
	exit(0)

flg = 1
for i in range(1,len(s)):
	if s[i] != '9':
		flg = 0
		break

if flg == 1:
	cnt = 0
	for i in range(len(s)):
		cnt += int(s[i])
	print(cnt)
	exit(0)

if s[0] == '1':
	print(9*(dig-1))
else:
	print(9*(dig-1) + int(s[0]) - 1)



Measured memory_bytes: 3064
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner s = null;
		try {
			s = new Scanner(System.in);

			while (s.hasNextLong()) {
				long[] num = { s.nextLong(), s.nextLong() };
				System.out.println(gcd(num) + " " + lcm(num));
			}

		} finally {
			s.close();
		}

	}

	// ?????????????????????????????????
	// ??§??????????????°??????????????????????????°?????§?????£?????????
	// ??°??????0????????£?????¨??????????????????????????°???????????§??¬?´???°
	private static long gcd(long[] num) {

		long x = 0;
		long a = num[0];
		long b = num[1];
		do {
			x = a % b;
			a = b;
			b = x;
		} while (x != 0);

		return a;

	}

	 //2????????°?????????????????????????????§??¬?´???°??§?????£?????°??????
	 //????°???¬?????°
	 private static long lcm(long[] num) {
	 return (num[0] * num[1]) / gcd(num);
	 }
}

Measured memory_bytes: 15392
MOD = 1_000_000_007

def factorial(n)
  ans = 1
  (1..n).each do |i|
    ans = (ans * i) % MOD
  end
  ans
end

N, M = gets.split.map(&:to_i)

if N == M
  puts (2 * factorial(N) ** 2) % MOD
elsif (N - M).abs == 1
  puts (factorial(N) * factorial(M)) % MOD
else
  puts 0
end


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

typedef pair<int,int> P;

int N;

signed main(){
  
  cin >> N;
  
  map<int,int> A;

  int sum = 0;
  
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    sum += a;
    A[a]++;
  }
  
  int q;
  cin >> q;
  
  while( q-- ){
    
    int b, c;
    cin >> b >> c;
    
    int bcnt = A[b];
    
    sum -= b * bcnt;
    sum += c * bcnt;
    
    A[b] = 0;
    A[c] += bcnt;
    
    cout << sum << endl;
    
  }
  
  return 0;
}


Measured memory_bytes: 9472
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        char[] s = scanner.next().toCharArray();
        if (s[0] == s[1] && s[0] == s[2]) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
const ll MOD = 998244353;
const ll INF = 1e18;
using namespace std;


main(){    
    #ifdef XOX
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin >> n;
    ll d = 0, s = 0;
    ll u, v;
    for(int i = 0; i < n; i++){
        cin >> u >> v;  
        d += v, s += u*v;
    }

    cout << d - 1ll + ((s - 1) / 9ll);
}

Measured memory_bytes: 256
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  let [, nums] = content
    .trim()
    .split('\n')
    .map(line => line.split(' ').map(n => +n));
  bubbleSort(nums);
});

const bubbleSort = nums => {
  let flag = true;
  let cnt = 0;
  let min = 1;
  while(flag) {
    flag = false;
    for (let i = nums.length - 1; i >= min; i--) {
      if (nums[i] < nums[i - 1]) {
        flag = true;
        const tmp = nums[i];
        nums[i] = nums[i - 1];
        nums[i - 1] = tmp;
        cnt++;
      }
    }
    min++;
  }

  console.log(nums.join(' '));
  console.log(cnt);
};


Measured memory_bytes: 15616
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>

int main()
{
std::vector<long long int> a(3,0);
std::cin >> a[0] >> a[1] >> a[2];
std::sort(a.begin(), a.end());
long long int v = (a[2] % 2) * a[1] * a[0];
std::cout << v << std::endl;
return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll a,b,c;cin>>a>>b>>c;
  lb aa=sqrtl(a),bb=sqrtl(b),cc=sqrtl(c);

  if(aa+bb+1e-14<cc)out("Yes");
  else out("No");



  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstdint> // int64_t, int*_t
using namespace std;

int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

int main() {
int K; cin >> K;
int sum = 0;
for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      for (int k = 1; k <= K; k++) {
      sum += my_gcd(my_gcd(i,j),k);
      }
    }
  }
  cout << sum << endl;
  }


Measured memory_bytes: 3596
import sys

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
    def find(self, x):
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parent[x] = y

def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for i in range(M):
        X, Y, Z = map(int, input().split())
        uf.union(X-1, Y-1)
    s = set()
    for i in range(N):
        s.add(uf.find(i))
    print(len(s))

if __name__ == "__main__":
    sys.setrecursionlimit(10**6)
    main()


Measured memory_bytes: 29876
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
const int mod=1e9+7;
typedef long long ll;
ll fac[N],inv[N];
int n;
ll A,B,C,ans;
ll pw(ll x,ll p){
	ll ret=1;
	while(p){
		if(p&1)ret=ret*x%mod;
		x=x*x%mod;
		p>>=1;
	}
	return ret;
}
void init(){
	const int MX=200000;
	fac[0]=1;
	for(int i=1;i<=MX;i++)fac[i]=fac[i-1]*i%mod;
	inv[MX]=pw(fac[MX],mod-2)%mod;
	for(int i=MX-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
ll cal(ll n,ll m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod; 
}
int main(){
	cin>>n>>A>>B>>C;
	ll ttt=A+B;
	init();
	A=A*pw(ttt,mod-2)%mod;
	B=B*pw(ttt,mod-2)%mod;
	for(int t=n;t<=n*2-1;t++){
		ll tmp=cal(t-1,t-n)*(pw(A,t-n)%mod*pw(B,n)%mod+pw(B,t-n)%mod*pw(A,n)%mod)%mod;
		ans=ans+tmp*t%mod;
	}
	ans=ans*100%mod*pw(ttt,mod-2)%mod;
	ans=(ans%mod+mod)%mod;
	printf("%lld\n",ans);
	return 0;
}
/*
4 50 50 0
*/

Measured memory_bytes: 3328
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    map<int, string> ma;
    int n, Q;
    cin >> n >> Q;
    
    string res = "kogakubu10gokan";
    for (int i = 0; i < n; ++i) {
        int y; string str;
        cin >> y; cin >> str;
        if (y <= Q) {
            res = str;
        }
    }
            
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 1208
# encoding: utf-8
import sys
# input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))

ans = 10 ** 9 + 7
for i in range(min(a), max(a) + 1):
    ans_tmp = 0
    for j, aj in enumerate(a):
        ans_tmp += (i - a[j]) ** 2
    if ans > ans_tmp: ans = ans_tmp

print(ans)

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

int main() {
    int n,i,j,temp,ans=0;
    cin >> n;
    for(i=1;i<=n;i+=2){
        temp=0;
        for(j=1;j<=i;j++){
            if(i%j==0)temp++;
        }
        if(temp==8)ans++;
    }
    std::cout << ans << std::endl;
    // cout << "\n" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}

const ll N=1005;
ll t[N][N];
char mat[N][N];
ll grid(ll i,ll j,ll n,ll m)
{
    if(mat[i][j]=='#' || i>n || j>m)
        return 0;
    if(i==n && j==m)
        return 1;
    if(t[i][j]!=-1)
        return t[i][j];
    t[i][j]=(grid(i+1,j,n,m)+ grid(i,j+1,n,m));
        return (t[i][j]%mod);
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inputh.txt", "r", stdin);
    freopen("outputh.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
   // cin>>test;
    while(test--)
    {
            memset(t,-1,sizeof(t));
            ll n,m;
            cin>>n>>m;
            for(int i=1;i<=n;i++)
            {
                for(int j=1;j<=m;j++)
                {
                    cin>>mat[i][j];
                }
            }
            cout<<grid(1,1,n,m);

//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not





Measured memory_bytes: 12612
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<utility>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int inf=10000000000000007;
signed main(){
  int n,d,a;cin>>n>>d>>a;
  vector<pair<int,int>> enemy(n);
  rep(i,n)cin>>enemy[i].first>>enemy[i].second;
  sort(enemy.begin(),enemy.end());
  vector<int> x(n);
  vector<int> h(n);
  rep(i,n){
    x[i]=enemy[i].first;
    h[i]=enemy[i].second;
  }
  x.push_back(inf);
  h.push_back(0);
  vector<int> damage(n+1,0);
  vector<int> end(n+1,0);
  vector<int> front(n+1,0);
  int left=0;
  int now=0;
  int res=0;
  rep(i,n){
    left=i;
    now-=end[i];
    if(now*a>=h[i])continue;
    int buf=(h[i]-1)/a+1-now;
    res+=buf;
    now+=buf;
    front[i]+=buf;
    auto it=upper_bound(x.begin(),x.end(),x[i]+2*d);
    int index=it-x.begin();
    end[index]+=buf;
  }
  cout<<res<<endl;
  /*rep(i,n){
    cout<<enemy[i].first<<" "<<enemy[i].second<<endl;;
  }*/
  return 0;
}


Measured memory_bytes: 12616
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {

	int n, tmp, q;
  	vector<int> v;
	set<int> s;

	cin >> n;
	v.resize(n);
	for (int i = 0;i<n;i++) cin >> v[i];
  
	for (int i = 1;i<(1<<n);i++) {
      	//cout<< "#" << i <<endl;
      	tmp=0;
      	for(int j=0;j<n;j++){
          	//cout<< "$" << ((i>>j)%2) <<endl;
          	if(((i>>j)%2)==1){
              	tmp+=v[j];
          		//cout<< j << " ";
            }
        }
      	//cout<< tmp <<endl;
      	s.insert(tmp);
	}

  	cin>> q;
  	for(int i=0;i<q;i++){
      	cin>> tmp;
      	auto it = s.find(tmp);
      
  		if (it != s.end()) cout << "yes" << endl;
  		else cout << "no" << endl;
  	}

}


Measured memory_bytes: 3128
s = input()
t = input()

s_list = []
[s_list.append(_) for _ in s]

t_list = []
[t_list.append(_) for _ in t]

s_list.sort()
t_list.sort(reverse = True)

count_list = []
if len(s_list) < len(t_list):
    for i in range(len(s_list)):
        if s_list[i] < t_list[i]:
            print('Yes')
            break
        elif t_list[i] < s_list[i]:
            print('No')
            break
        else:
            count_list.append(True)
    if len(count_list) == len(s_list):
        print('Yes')
else:
    for i in range(len(t_list)):
        if s_list[i] < t_list[i]:
            print('Yes')
            break
        elif t_list[i] < s_list[i]:
            print('No')
            break
        else:
            count_list.append(True)
    if len(count_list) == len(t_list):
        print('No')


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int A, B;
	cin >> A >> B;
	ce(max({A+B,A-B,A*B}))
    return 0;
}



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  char x,y;
  cin >> x >> y;

  char ans;
  if(x<y)
    ans = '<';
  else if(y<x)
    ans = '>';
  else
    ans = '=';

  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // cin, cout の高速化
#define MOD 1000000007
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)

#define MAX_N 10000000

int main()
{
    int N;
    cin >> N;
    string w;
    vector<string> words;

    REP(i, N)
    {
        cin >> w;
        if (words.size())
        {
            string last = words.back();

            auto itr = find(words.begin(), words.end(), w);
            if (last[last.length() - 1] != w[0] || itr != words.end())
            {
                cout << "No" << endl;
                return 0;
            }
        }
        words.push_back(w);
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,vis[500005];
vector< vector<int> > g(1000000);
void dfs(int u)
{
    vis[u]=1;
    for(int v:g[u])
    {
        if(vis[v]==0)
        dfs(v);
    }
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        int d;
        cin>>d;
        while(d--)
        {
            int x;
            cin>>x;
            g[x+n].push_back(i);
            g[i].push_back(x+n);
        }
    }
    dfs(1);
    int c=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==1)
        c++;
    }
    if(c==n)
    cout<<"YES"<<endl;
    else
    {
        cout<<"NO"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 27776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
int main() {
    int n;
    scanf("%d", &n);
    int a[100000];
    rep(i, n) cin >> a[i];

    vector<int> v; //可変長配列
    map<int, int> cnt; //出現数調べるときによく使うやつ
    rep(i, n) {
        cnt[a[i]]++;
        if (cnt[a[i]] == 2) cnt[a[i]] = 0, v.push_back(a[i]); //同じ長さが2本あったら、また2本来たときにカウントできるように初期化してから、v配列に追加
    }
    sort(v.begin(), v.end(), greater<int>()); //大きい順に並び替え

    ll ans = 0;
    if (2 <= v.size()) ans = 1LL * v[0] * v[1]; //同じ長さの棒が2組以上あったら、大きいものから順に乗算してlong longにキャストする。
    printf("%lld\n", ans);
}

Measured memory_bytes: 8660
#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++)

const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a%=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}

void comb(ll *c, ll n){
  c[0] = 1;
  rep1(i,n){
    c[i] = mu(c[i - 1], mu(n + 1 - i, dv(1,i)));
  }

}




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

  ll n,k;
  cin >> n >> k;

  ll C[n + 1];
  ll D[n];
  comb(C, n);
  comb(D, n-1);
  ll ans=0;
  rep(i,min(k+1,n)){
    ans = ad(ans,mu(C[i],D[i]));
  }
  cout << ans << endl;
  
  return 0;
    

}


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

int main(){
    int N;
    cin >> N;
    int P[N];
    for(int i=0;i<N;i++) cin >> P[i];

    int min_j[N];
    min_j[0] = P[0];
    for(int i=1;i<N;i++){
        min_j[i] = min(P[i],min_j[i-1]);
    }

    int count=0;
    for(int i=0;i<N;i++){
        if(P[i]<=min_j[i]){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
  string N; cin>>N;
  int sum = 0;
  REP(i,N.size()){
    sum += N[i]-'0';
  }
  if(sum%9==0) cout << "Yes";
  else cout << "No";
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int ans = 0;
    char c[h][w];
    rep(i, h) {
        rep(j, w) {
            cin >> c[i][j];
        }
    }
    for (int bit1 = 0; bit1 < (1 << h); ++bit1) {
        for (int bit2 = 0; bit2 < (1 << w); ++bit2) {
            bool dammy[h][w];
            int count = 0;
            rep(i, h) {
                rep(j, w) {
                    if (c[i][j] == '#')
                        dammy[i][j] = true;
                    else {
                        dammy[i][j] = false;
                    }
                }
            }
            for (int i = 0; i < h; i++) {
                if (bit1 & (1 << i)) {
                    rep(a, w) {
                        dammy[i][a] = false;
                    }
                }
            }
            for (int i = 0; i < w; i++) {
                if (bit2 & (1 << i)) {
                    rep(a, h) {
                        dammy[a][i] = false;
                    }
                }
            }
            rep(i, h) {
                rep(j, w) {
                    if (dammy[i][j])
                        count++;
                }
            }
            if (count == k)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

int main() {
  int a, b;

  cin >> a >> b;

  cout << (b - 1 + a - 1 - 1) / (a - 1)<< endl;
	return 0;
}

Measured memory_bytes: 256
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def r_sort(a) a.sort{|a,b|b<=>a} end

a = gets.chomp
b = gets.chomp
ans = 0
a.size.times do |i|
  ans += 1 if(a[i] == b[i])
end
p ans

Measured memory_bytes: 1788
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int[] A=cin.ReadIntArray(2);
            int N = A[0];
            int K = A[1];
            double answer = 0;

            for(int i = 1; i <= N; i++)
            {
                int coinCount = 0;
                int j = i;
                while (j < K)
                {
                    j=2*j;
                    coinCount += 1;
                    if (j < K) continue;
                    else break;
                }
                if (coinCount == 0)
                {
                    answer += (1.0 / N);
                }
                else
                {
                    double E=Pow(1.0/2.0,(double)coinCount);
                    answer += (1.0 / N) * (double)E;
                }
                
            }
            Console.WriteLine($"{answer:F12}");

        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
from itertools import accumulate

MOD = 10 ** 9 + 7

n = int(input())
a = list(map(int, input().split()))

csum_invs = [0] + list(accumulate([pow(i, MOD - 2, MOD) for i in range(1, n + 1)]))
# csum_invs = [0]
# t = 0
# for i in range(1, n + 1):
#     t += pow(i, MOD - 2, MOD)
#     t %= MOD
#     csum_invs.append(t)
# print(csum_invs)

fact = []
t = 1
for i in range(1, n + 1):
    t *= i
    t %= MOD
    fact.append(t)
# print(fact)

ans = 0
for i in range(n):
    # print(i)
    t = a[i] * (csum_invs[n - i] + csum_invs[i + 1] - 1)
    t %= MOD
    ans += t

ans *= fact[-1]
ans %= MOD

print(ans)

Measured memory_bytes: 15808
import math

def checkPrime(n):
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True

if __name__ == "__main__":
    N = input()
    cnt = 0
    for i in range(N):
        n = input()
        if checkPrime(n):
            cnt += 1
    print cnt

Measured memory_bytes: 6924
s = gets.chomp

if s.match(/^.*keyence$|^keyence.*$|^key.*ence$|^k.*eyence$|^ke.*yence$|^key.*ence$|^keye.*nce$|^keyen.*ce$|^keyenc.*e$/)
  puts 'YES'
else
  puts 'NO'
end

Measured memory_bytes: 1788
#include<stdio.h>
int n,i,a,s,x,of,bh[100001],bf[100001];
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a);
		bh[i]=a;
	}
	
	x=1;
	while(1){
		s++;
		bf[x]++;
		if(bf[x]>=2){
			of=1;
			break;
		}
		x=bh[x];
		if(x==2)break;
	}
	
	if(of==1)printf("-1\n");
	else printf("%d\n",s);
	
	return 0;
}

Measured memory_bytes: 896
# -*- coding: utf-8 -*-

import sys
from collections import defaultdict

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

# dp0[i][j] := i個目の要素まで見て、選んだ要素-選ばなかった要素=jで、直前を使っていない時の最大値
dp0 = [defaultdict(lambda: -INF) for i in range(N+1)]
# dp1[i][j] := i個目の要素まで見て、選んだ要素-選ばなかった要素=jで、直前を使った時の最大値
dp1 = [defaultdict(lambda: -INF) for i in range(N+1)]
dp0[0][0] = 0
for i, a in enumerate(A):
    for j in range(-2, 2):
        if j != -2:
            # 今回のaを使わない
            dp0[i+1][j-1] = max(dp0[i+1][j-1], dp0[i][j])
            dp0[i+1][j-1] = max(dp0[i+1][j-1], dp1[i][j])
        # 今回のaを使う
        dp1[i+1][j+1] = max(dp1[i+1][j+1], dp0[i][j] + a)
# 最終的に欲しい位置は偶奇で場合分け
if N % 2 == 0:
    # 偶数の時は使った数と使わなかった数が同じ
    ans = max(dp0[N][0], dp1[N][0])
else:
    # 奇数の時は使わなかった数が1つ多い
    ans = max(dp0[N][-1], dp1[N][-1])
print(ans)


Measured memory_bytes: 281840
h,w=map(int,input().split())
l=[]
for i in range(h):
  l.append(input())
for i in range(h-1):
  for j in range(w-1):
    if l[i][j]=='#'and l[i][j+1]=='#'and l[i+1][j]=='#'and l[i+1][j+1]=='#':
      print('Impossible')
      exit()
    if l[i][j]=='.'and l[i][j+1]=='#'and l[i+1][j]=='#'and l[i+1][j+1]=='#':
      print('Impossible')
      exit()
    if l[i][j]=='#'and l[i][j+1]=='#'and l[i+1][j]=='#'and l[i+1][j+1]=='.':
      print('Impossible')
      exit()
print('Possible')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll INF = 1LL << 58;

//xより以下の要素へのindex
template <class T> int former(const vector<T> &v, T x) {
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素へのindex
template <class T> int latter(const vector<T> &v, T x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int comb(int n,int k){
    int ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,x;
    cin>>a>>b>>x;
    if(a<=x && x<=a+b){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int A, B, C, D, E, F;

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

    cin >> A >> B >> C >> D >> E >> F;

    int sg = 0;
    int wg = A;
    double maxd = 0;

    for (int c0 = 0; c0 <= F / (100 * A); c0++) {
        for (int c1 = 0; c1 <= F / (100 * B); c1++) {
            int w = A * c0 + B * c1;
            for (int c2 = 0; c2 <= (F - 100 * w) / C; c2++) {
                if (w * E - C * c2 < 0 || F - w * 100 - C * c2 < 0)
                    continue;
                int c3e = (w * E - C * c2) / D;
                int c3f = (F - w * 100 - C * c2) / D;
                int c3 = min(c3f, c3e);
                int s = C * c2 + D * c3;
                if (maxd < double(s) / (100 * w + s)) {
                    sg = s;
                    wg = w;
                    maxd = double(s) / (100 * w + s);
                }
            }
        }
    }

    cout << 100 * wg + sg << " " << sg << "\n";

    return 0;
}

Measured memory_bytes: 3696
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main (){
  ll a,b,k;
  cin>>a>>b>>k;
  ll ans=min(a,b);
  for(ll i=0;i<k;i++){
    while(a%ans!=0||b%ans!=0)ans--;
    ans--;
  }
  ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

menuTimeList = [A, B, C, D, E]
menuExtraTimeList = [0, 0, 0, 0, 0]

maxExtraTime = 0
for i in range(5):
    extraTime = 0
    if menuTimeList[i] % 10 == 0:
        menuExtraTimeList[i] = 0 
    else:
        extraTime = 10 - menuTimeList[i] % 10
        menuExtraTimeList[i] = extraTime
    if maxExtraTime < extraTime:
        maxExtraTime = extraTime

answer = sum(menuTimeList) + sum(menuExtraTimeList) - maxExtraTime
print(answer)

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;

  // 木構造なら, ∑(連結成分) = ∑(頂点数) - ∑(辺数)
  ll ans = 0;
  // 頂点数 i の集合が n-i+1 個
  rep3(i, 1, n + 1) ans += i * 1LL * (n - i + 1);
  cerr << ans << endl;

  // 両端点を含むようその外側の点を選ぶ
  // n = 7, 端点の番号が 3, 5 なら, L = {1, 2, 3}, R = {5, 6, 7} から選ぶ
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    ans -= a * 1LL * (n - b + 1);
  }
  cout << ans << endl;
}


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

int main()
{
  int n,m,l,i,j,k,mat1[100][100],mat2[100][100];
  long long int ans[100][100]={0};

  cin>>n>>m>>l;
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      cin>>mat1[i][j];
  for(i=0;i<m;i++)
    for(j=0;j<l;j++)
      cin>>mat2[i][j];
  for(i=0;i<n;i++)
    for(j=0;j<l;j++)
      for(k=0;k<m;k++){
	ans[i][j]+=mat1[i][k]*mat2[k][j];
      }
  for(i=0;i<n;i++)
    for(j=0;j<l;j++){
      if(j<l-1) cout<<ans[i][j]<<" ";
      if(j==l-1) cout<<ans[i][j]<<endl;
  }
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
int main(){
	FAST
	ll n,m,k,ans=0;
	cin>>n>>m>>k;
	char grid[n][m];
	FOR(i,0,n-1)FOR(j,0,m-1)cin>>grid[i][j];
	FOR(b1,0,(1<<n)-1)FOR(b2,0,(1<<m)-1){
		ll black=0;
		FOR(i,0,n-1)FOR(j,0,m-1){
			if(1<<i&b1)continue;
			if(1<<j&b2)continue;
			black += grid[i][j]=='#';
		}
		if(black==k){
			// cerr<<b1<<' '<<b2<<'\n';
			++ ans;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 3616
unittest
{
	assert( [ "4", "2 10 8 40" ].parse.expand.solve == 2 );
	assert( [ "4", "5 13 8 1000000000" ].parse.expand.solve == 1 );
	assert( [ "3", "1000000000 1000000000 1000000000" ].parse.expand.solve == 1000000000 );
}



import std.algorithm;
import std.conv;
import std.numeric : gcd;
import std.range;
import std.stdio;
import std.typecons;

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	// 最大公約数をとる
	auto ans = as[ 0 ];
	foreach( a; as[ 1 .. $ ] )
	{
		ans = ans.gcd( a );
	}
	return ans;
}


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

#define INF 1e+9
#define MAX_V 300005

struct edge {
  int to;
  int cost;
};

using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d+V, INF);
  d[s] = 0;
  que.push(P(0, s));

  while ( !que.empty() ) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) { continue; }

    for ( int i = 0; i < G[v].size(); i++ ) {
      edge e = G[v][i];
      if ( d[e.to] > d[v] + e.cost ) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  V = n*3;
  for ( int i = 0; i < m; i++ ) {
    int u, v;
    cin >> u >> v;
    u--; u *= 3;
    v--; v *= 3;
    G[u].push_back({v+1, 1});
    G[u+1].push_back({v+2, 1});
    G[u+2].push_back({v, 1});
  }
  
  int start, goal;
  cin >> start >> goal;
  start--; start *= 3;
  goal--;  goal *= 3;

  dijkstra(start);
  
  int ans = ( d[goal] != INF ) ? d[goal]/3 : -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 21100
// 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int X;
    cin >> X;
    if (X >= 30)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
    
    return 0;
}


Measured memory_bytes: 3624
N, M, X, Y = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
y = list(map(int, input().split()))
y.sort()

zx = x[N-1] + 1
zy = y[0]
if (zx <= zy) and (Y >= zx) and (zy > X):
    print ('No War')
else:
    print ('War')

Measured memory_bytes: 3064