akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}


 ll GCD(ll m, ll n) {
   if (m == 0) {
     return n;
   } 
   if (n == 0) {
     return m;
   }
 
   if (m >= n) {
     return GCD(m%n, n);
   } else {
     return GCD(m, n%m);
   }
 }

int N;
ll K;
ll a[110000];

int main () {
  cin >> N >> K;
  Rep(i, N) cin >> a[i];

  ll wa = a[0];
  ll saidai = a[0];

  for (int i=1;i<N;++i) {
    wa = GCD(wa, a[i]);
    saidai = max(a[i], saidai);
  }

  if (K % wa == 0 & K <= saidai) {
    cout << "POSSIBLE\n";
  } else {
    cout << "IMPOSSIBLE\n";
  }
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int W, H, N;
  cin>>W>>H>>N;
  int xmin=0, xmax=W, ymin=0, ymax=H;
  int x, y, a;
  for(int i=0;i<N;++i){
    cin>>x>>y>>a;
    if(a==1){
      if(xmin<x) xmin = x;
    }
    if(a==2){
      if(xmax>x) xmax = x;
    }
    if(a==3){
      if(ymin<y) ymin = y;
    }
    if(a==4){
      if(ymax>y) ymax = y;
    }
  }
  if(xmin>xmax || ymin>ymax) cout<<0<<endl;
  else cout<<(xmax-xmin)*(ymax-ymin)<<endl;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
//#ifndef ONLINE_JUDGE
//    #include "/home/lochness/Documents/lochness.h"
//#endif
using namespace std;
#define pii             pair< int , int >
#define inf             1000000011
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n")
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define pcs(a)          printf("Case %d: ", a)
#define mp              make_pair
#define vi              vector< int >
#define _ceil(n, a)     ((n)%(a)==0?((n)/(a)):((n)/(a)+1))
#define pb              push_back
#define mem(a, b)       memset(a, b, sizeof(a))
#define all(X)          X.begin(), X.end()
#define lg2(n)          (31-__builtin_clz(n))
#define ext(a)          {printf("%s\n", a); return 0;}
#define oka(x, y)       ((x)>=0&&(x)<row&&(y)>=0&&(y)<col)
#define x               first
#define y               second
#define lc              (2*i)
#define rc              (2*i+1)
#define mod             1000000007
#define M               100010

typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1,0};int dy[]={0,1,1,1,0,-1,-1,-1,0};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (n & (1<<pos))>>pos;} //typecast 1 in case of int
//int  on(int n, int pos) {return n | (1<<pos);} //typecast 1 in case of int
//int  off(int n, int pos) {return n & ~(1<<pos);} //typecast 1 in case of int
//bool operator < (const data &d) const{return cost<d.cost;} //reverse in priority queue

vi A[M];
vi val[M];
int vis[M];
int x[M];

void dfs(int u, int root) {
    vis[u] = 1;
    val[root].pb(x[u]);
    for (int v : A[u]) if (!vis[v]) dfs(v, root);
}

int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("/home/lochness/Documents/in.txt", "r", stdin);
////    freopen("/home/lochness/Documents/out.txt", "w", stdout);
//#endif
    ios_base::sync_with_stdio(false);

    int n, m;
    int i, j, k;

    in2(n, m);

    int sdeg = 2*(n-m-1);
    if (sdeg > n) {
        printf("Impossible\n");
        return 0;
    }

    for (i = 0; i < n; i++) in(x[i]);
    while (m--) {
        in2(i, j);
        A[i].pb(j);
        A[j].pb(i);
    }

    int cmp = 0;
    LL ans = 0;
    vi rest;
    for (i = 0; i < n; i++) {
        if (!vis[i]) {
            cmp++;
            dfs(i, i);
            sort(all(val[i]));
            reverse(all(val[i]));
            ans += val[i].back();
            val[i].pop_back();
            sdeg--;
            for (int v : val[i]) rest.pb(v);
        }
    }

    sort(all(rest));
    for (int v : rest) {
        if (sdeg == 0) break;
        ans += v;
        sdeg--;
    }

    printf("%lld\n", cmp == 1 ? 0 : ans);


    return 0;
}


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

int main(void){
    string s,t;
    cin >> s;
    cin >> t;
    int ans = 0;
    for(int i=0; i<3; i++){
        if(s[i]==t[i]) ans+=1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

typedef struct{
    int rank,h,w;
}point;

int mp[1000][1000],h,w,mh[4] = {1,0,-1,0},mw[4] = {0,1,0,-1},ans;

int isOK(int i,int j){
    if(i >= 0 && i < h && j >= 0 && j < w)return true;
    else return false;
}

int main(){   
    cin>>h>>w;
    queue<point>que;
    rep(i,h)rep(j,w){
        char ch;
        cin>>ch;
        if(ch == '#'){
            mp[i][j] = 1;
            que.push({0,int(i),int(j)});
        }
    }    
    while(!que.empty()){
        point top = que.front();
        que.pop();
        if(top.rank != ans){
            ans = top.rank;
        }
        rep(i,4){
            int nh = top.h + mh[i],nw = top.w + mw[i];
            if(isOK(nh,nw) && mp[nh][nw] == 0){
                mp[nh][nw] = 1;
                que.push({top.rank + 1,nh,nw});
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 16272
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  double n,d;
  cin >> n >> d;
  int i,j;
  vector<vector<double>> v(n,vector<double>(2));
  for(i=0;i<n;i++){
    for(j=0;j<2;j++){
      cin >> v[i][j];
    }
  }
  int cnt = 0;
  for(i=0;i<n;i++){
    if(d>=sqrt(pow(v[i][0],2)+pow(v[i][1],2))) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 14380
from sys import stdin, exit
N = int(stdin.readline().rstrip())
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])

time = 0
for a, b in AB:
    time += a
    if time > b:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 83292
import sys

def main():
    line = sys.stdin.readline().rstrip('\n').split()
    N , M = int(line[0]), int(line[1])
    ans = 0

    conditions = {}
    for i in range(M):
        line = sys.stdin.readline().rstrip('\n').split()
        if int(line[0]) not in conditions.keys():
            conditions[int(line[0])] = int(line[1])
        else:
            if conditions[int(line[0])] != int(line[1]):
                print(-1)
                return

    if ((1 in conditions.keys()) and conditions[1]==0 and N!=1):
       print(-1)
       return

    if (1 in conditions.keys()):
        ans += conditions[1]*(10**(N-1))
    else:
        if (N!=1):
            ans += 10**(N-1)

    if (2 in conditions.keys()):
        ans += conditions[2]*(10**(N-2))

    if (3 in conditions.keys()):
        ans += conditions[3]

    print(ans)

main()


Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
 
void solve(){

    return;
}
 
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    long double a,b,c;
    cin >> a >> b >> c;
    if (a / c <= b){
        ctn("Yes");
    }
    else{
        ctn("No");
    }
    return 0;
}


Measured memory_bytes: 3716
import java.util.*;

public class Main {

	public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = 0;
		int x = 0;
		int y = 0;
		boolean result = true;
		for (int i = 0; i < n; i++) {
			int t2 = sc.nextInt() - t;
			int x2 = Math.abs(x - sc.nextInt());
			int y2 = Math.abs(y - sc.nextInt());
			int diff = t2 - x2 - y2;
			if (diff < 0) {
				result = false;
			}
			if (diff % 2 != 0) {
				result = false;
			}
		}
		System.out.println(result ? "Yes" : "No");
	}
}


Measured memory_bytes: 86076
N,K=gets.split.map &:to_i
W=$<.map &:to_i
l=0
r=$$**3
m=r/2
def can? m
  i=k=sum=0
  while i<N
    return false if W[i]>m
    sum+=W[i]
    if m<sum
      sum=W[i]
      k+=1
    end
    i+=1
  end
  k<K
end
while l+1<r
can?(m)?r=m :l=m
m=(l+r)/2
end
p l+1

Measured memory_bytes: 7032
#include<bits/stdc++.h>
#include<stdint.h>
#define ff first
#define ss second

using namespace std;


#define MOD 1e9+7
#define ll long long int


void solve()
{
	int n,i,j;
	cin>>n;
	int ar[n+1];
	for(i=1;i<=n;++i)
	{
		cin>>ar[i];
	}
	map<int,int> mp;
	ll ans=0;
	for(i=1;i<=n;++i)
	{
		ans=ans+mp[i-ar[i]];
		mp[i+ar[i]]++;
	}
	cout<<ans<<endl;
}



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

	#ifndef ONLINE_JUDGE 
      	freopen("_input.txt", "r", stdin); 
  	freopen("_output.txt", "w", stdout); 
  	#endif 
	

    solve();

	
}

Measured memory_bytes: 21352
// Aizu Vol-1 0181: Bookshelf

#include <stdio.h>
#include <string.h>

#define INF 0x7fffffff
#define MAX(a,b) ((a)>=(b)?(a):(b))
int c[22][102][102];
int w[102];

int main()
{
	int m, n, i, j, k, l;

	while (scanf("%d%d", &m, &n) && m) {
		memset(c, 0, sizeof(c));
		for (w[0] = k = 0, i = 1; i <= n; i++) {
			scanf("%d", &l), w[i] = w[i-1] + l;
			if (l > k) k = l;
		}
		if (n <= m) { printf("%d\n", k); continue; } 

		for (i = 1; i <= n; i++) c[1][1][i]= w[i];
		for (k = 2; k <= m; k++) {
			for (i = 1; i <= n; i++) for (j = i; j < n; j++) for (l = j; l < n; l++)
				if (c[k-1][i][j] > 0) {
					int t = MAX(w[l+1]-w[j], c[k-1][i][j]);
					if (c[k][j+1][l+1] == 0 || t < c[k][j+1][l+1]) c[k][j+1][l+1] = t;
				}
		}
		for (k = INF, i = 1; i <= n; i++)
			if (c[m][i][n] > 0 && c[m][i][n] < k) k = c[m][i][n];
		printf("%d\n", k);
	}
	return 0;
}

Measured memory_bytes: 2604
def check(arr, c):
  for each in arr:
    if each == c or each == "U" or each == "D":
      pass
    else:
      return False
  return True

steps = input()
odds = steps[::2]
evens = steps[1::2]
if check(odds, "R") and check(evens, "L"):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        long[] a = new long[N];
        long sum1 = 0;
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextInt();
        }
        sum1 = Arrays.stream(a).sum();
        long sum2 = 0;

        long min = Long.MAX_VALUE;
        for (int i = N - 1; i >= 1; --i) {
            sum1 -= a[i];
            sum2 += a[i];
            if (Math.abs(sum1 - sum2) < min) {
                min = Math.abs(sum1 - sum2);
            }
        }
        _out.println(min);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 65220
#include<stdio.h>
int main()
{
	int n,a,b;
	while(~scanf("%d %d %d",&n,&a,&b))
	{
		n=n*a;
		if(n>b)
		{
			printf("%d\n",b);
		}
		else
		{
			printf("%d\n",n);
		}
	}
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=1e9+7;
LL f[1010][1010],n,a,b,c,d,C[1010][1010],inv[1010][1010],fac[1010],finv[1010];
void pre()
{
	inv[0][1]=inv[1][1]=1;fac[0]=fac[1]=1;
	for(LL i=2;i<=1000;i++) inv[i][1]=(mod-mod/i)*inv[mod%i][1]%mod,fac[i]=fac[i-1]*i%mod;
	for(LL i=2;i<=1000;i++) inv[i][1]=inv[i-1][1]*inv[i][1]%mod;
	for(LL i=1;i<=1000;i++)
		for(LL j=2;j<=1000;j++) inv[i][j]=inv[i][1]*inv[i][j-1]%mod;
	for(LL i=1;i<=1000;i++)
		for(LL j=1;j<=i;j++) C[i][j]=fac[i]*inv[i-j][1]%mod;
}
LL get(LL x,LL y,LL i)
{
	//printf("get:%lld %lld %lld %lld %lld %lld %lld\n",x,y,i,C[x][i*y],inv[y][i],inv[i][1],C[x][i*y]*inv[y][i]%mod*inv[i][1]%mod);
	return C[x][i*y]*inv[y][i]%mod*inv[i][1]%mod;
}
LL dfs(LL x,LL y)
{
	if(f[x][y]!=-1) return f[x][y];
	if(x==0) return 1;
	if(y<a) return 0;
	f[x][y]=0;
	for(LL i=c;i<=d;i++)
	{
		LL num=i*y;
		if(num<=x) (f[x][y]+=dfs(x-num,y-1)*get(x,y,i)%mod)%=mod;
		else break;
		//printf("%lld %lld %lld %lld\n",x,y,i,get(x,y,i));
	}
	(f[x][y]+=dfs(x,y-1))%=mod;
	return f[x][y];
}
int main()
{
	pre();
	scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
	memset(f,-1,sizeof(f));
	printf("%lld",dfs(n,b));
}

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

bool isok(vector<int> &b,vector<vector<int>> &pos){
    for(int i=0;i<b.size();i++){
        if(!pos[i][b[i]]) return false;
    }
    return true;
}
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];

    vector<vector<int>> pos(n,vector<int>(51,0));
    for(int i=0;i<n;i++){
        pos[i][a[i]]=true;
    }
    long long int res=0;
    int ub=51;
    while(ub>1 && !isok(b,pos)){
        int llb=0;
        int uub=ub;
        while(uub-llb>1){
            int mid=(llb+uub)/2;
            //possible with k<=mid
            vector<vector<int>> pos2=pos;
            for(int k=mid;k>=1;k--){
                for(int i=0;i<n;i++){
                    for(int x=0;x<=50;x++){
                        pos2[i][x%k]|=pos2[i][x];
                    }
                }
            }
            if(isok(b,pos2)){
                uub=mid;
            }
            else{
                llb=mid;
            }
        }
        if(uub==ub){
            cout<<-1<<endl;
            return 0;
        }
        ub=uub;
        for(int i=0;i<n;i++){
            for(int x=0;x<=50;x++){
                pos[i][x%ub]|=pos[i][x];
            }
        }
        res+=1LL<<ub;
    }
    cout<<res<<endl;

    return 0;
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m; string str;
double ans;
vc<pii> v;
int solve(){
    cin>>n;
    rep(i,0,n-1){
        int a,b; cin>>a>>b;
        v.pb({a,b});
    }
    rep(i,0,n-1){
        rep(j,0,n-1){
            double s=(v[i].fr-v[j].fr)*(v[i].fr-v[j].fr)+(v[i].sc-v[j].sc)*(v[i].sc-v[j].sc);
            s=sqrt(s);
            ans+=s;
        }
    }
    ans/=(double)n;
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	int temp,temp1,temp2;
	int N,flag;
	int arr[51];

	scanf("%d",&N);
	for(temp=1;temp<=N;temp++){
		scanf("%d",&arr[temp]);
	}

	for(temp=1,flag=0;temp<=N;temp++){
		if(arr[temp]!=temp){
			if(flag==0){
				temp1=arr[temp];
				arr[temp]=temp;
				arr[temp1]=temp1;
				flag++;
			}
			else{
				printf("NO\n");
				return 0;
			}
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
L,R=map(int,input().split())
mod=2019
ans=[]
if R-L>2017:
    print(0)
elif L%mod>R%mod:
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans.append(i*j%mod)
    print(min(ans))

Measured memory_bytes: 75332
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;

int a[105];
int ans,cnt,sum,ma;
int main()
{
    int n,x;
    cin>>n>>x;
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        v.push_back(a[i]);
    }
    for(int i=0;i<v.size();i++)
    {
        ans=ans+v[i];
        cnt=x-ans;
    }
    sum=v[0];
    for(int i=1;i<v.size();i++)
    {if(v[i]<sum)
    sum=v[i];}
    cout<<(cnt/sum)+n;

    return 0;
} 

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	while(true){
		int N=in();
		if(!N) break;
		auto V=vecin(N);
		ll max_v = -(1LL<<60);
		ll sum=0;
		REP(i,N){
			sum += V[i];
			max_v = max(max_v,sum);
			if(sum<0) sum=0;
		}
		out(max_v);
	}
	
	return 0;
}



Measured memory_bytes: 3040
#include<iostream>

#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	int x = 0;
	int i = 1;
	while (1) {
		CI x;
		if (x == 0) {
			return 0;
		}
		CO "Case " << i << ": " << x E
		++i;
	}
}

Measured memory_bytes: 1160
//Name: Calculation of Area
//Level: 1
//Category: やるだけ
//Note:

#include <iostream>

using namespace std;

bool solve() {
    int a, b;
    cin >> a >> b;
    cout << a*b/3.305785 << endl;
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  string S; cin>>S;
  map<char,int> M;
  rep(i,0,N) M[S[i]]++;
  int ans=1;
  for(auto p:M){
    ans*=p.second+1;
    ans%=MOD;
  }
  ans+=MOD-1;
  ans%=MOD;
  cout<<ans<<endl;
  }


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

import math

a = math.ceil(N/A)
b = math.ceil(N/B)
c = math.ceil(N/C)
d = math.ceil(N/D)
e = math.ceil(N/E)

#print(a,b,c,d,e)
f = max([a,b,c,d,e])
print(f+4)

Measured memory_bytes: 3064
inputList = []
for i in range(5):
    inputList.append(int(input()))

k = int(input())

ret = 'Yay!'
for i in range(4):
    for j in range(i+1, 5):
        if inputList[j] - inputList[i] > k:
            ret = ':('
            break
print(ret)

Measured memory_bytes: 3060
#include <stdio.h>
int max(int a, int b) {
	return a > b ? a : b;
}
int main(void) {
	char S[11] = {0};
	scanf("%s", S);
	int cnt = 0;
	int ans = 0;
	for (int i = 0; i < 11; i++)
	{
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G')
		{
			cnt++;
			ans = max(cnt, ans);
		}
		else
		{
			cnt = 0;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

unsigned long F(unsigned long v){
  if(v%2 == 1){
    if((v-1)%4 == 0){
      return 0;
    }
    else{
      return 1;
    }
  }
  else{
    return F(v-1) ^ v;
  }
}

int main(){
  unsigned long A,B;
  cin >> A >> B;
  cout << (F(A-1) ^ F(B)) << endl;
  return 0;
}


Measured memory_bytes: 256
def c_dubious_document(N, S):
    import collections
    import string
    # 各文字列の中に共通した文字はあるか？
    d = [None for _ in range(N)]  # i番は文字列Siに出現する文字の一覧と個数
    for i, s in enumerate(S):
        d[i] = collections.Counter(s)

    common = collections.defaultdict(str)  # 文字列の中で共通する文字の一覧と個数
    for c in string.ascii_lowercase:
        low = float('inf')
        for i in range(N):
            low = min(low, d[i][c])
        if low != 0:
            common[c] = low
    common = sorted(common.items())

    ans = ''
    for c, v in common:
        ans += c * v
    return ans

N = int(input())
S = [input().strip() for _ in range(N)]
print(c_dubious_document(N, S))

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

int main()
{
	int n;
	int l[100000], r[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> l[i] >> r[i];
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += (r[i] - l[i]) + 1;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans0=0, ans1=0;
  for(int i=0; i<s.length(); i++){
    if(s.at(i)-'0' != i%2){
      ans0++;
    }
    if(s.at(i)-'0' != (i+1)%2){
      ans1++;
    }
  }
  int ans;
  ans = min(ans0, ans1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
//#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
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; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(max(a*c, a*d), max(b*c, b*d)) << endl;

  return 0;
}


Measured memory_bytes: 3636
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int N;
    
    cin >> N;
    if(N%2==0){
        cout << N;
    }else{
        cout << N * 2;
    }


    

}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 120
using namespace std ;
 
int a[N],n;
double s;
 
int main () {
	cin >> n;
	for(int i = 1 ; i <= n ; i++) {
		double x ;
		cin >> x ;
		x = 1/x ;
		s += x ;
	}
	cout << 1/s <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	char str,strr;
	scanf("%c %c",&str,&strr);	
	if(str=='H') printf("%c\n",strr);
	else if (str=='D'){
		if(strr=='H') printf("D\n");
		else printf("H\n");
	}
	return 0;
}

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

int main(){
	int l[10];
	double v1, v2;
	char tmp;
	double place;

	while(cin >> l[0] >> tmp){
		place = l[0];
		for(int i=1; i < 10; i++){
			cin >> l[i] >> tmp;
			place += l[i];
		}
		cin >> v1 >> tmp >> v2;
		place = place * (v1 / (v1 + v2));
		for(int i=0; i < 10; i++){
			place -= l[i];
			if(place <= 0){
				cout << i+1 << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1228
n = int(input())
MOD = 10**9+7

memo = [{} for _ in range(n+1)]

def ok(last4):
  for i in range(4):
    temp = list(last4)
    if i >= 1:
      temp[i-1], temp[i] = temp[i], temp[i-1]
    if ''.join(temp).count('AGC') >= 1:
      return False
  return True

def dfs(cur, last3):
  if last3 in memo[cur]:
    return memo[cur][last3]
  if cur == n:
    return 1
  ret = 0
  for c in 'ACGT':
    if ok(last3+c):
      ret = (ret + dfs(cur+1, last3[1:]+c))%MOD
  memo[cur][last3] = ret
  return ret
        
print(dfs(0, 'TTT'))

Measured memory_bytes: 3856
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<algorithm>
#include<string>
using namespace std;
#define mkp make_pair
#define veb vector<bool>
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
#define pin pair<long long,long long>
int gc(int a, int b) {
	if (b > a) { swap(a, b); }
	if (b == 0) { return a; }
	int r = a % b;
	return gc(b, r);
}
int main() {
	int n; cin >> n;
	int ans; cin >> ans;
	for (int i = 1; i < n; i++) {
		int a; cin >> a;
		ans = gc(ans, a);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int n = ni();
        int a = ni(), b = ni();
        long[] v = nla(n);

        Arrays.sort(v);
        for (int i = 0; i < n / 2; i++) {
            long tmp = v[i];
            v[i] = v[n - 1 - i];
            v[n - 1 - i] = tmp;
        }

        double ave = 0;
        for (int i = 0; i < a; i++) {
            ave += v[i];
        }
        ave /= a;

        int begin = a - 1;
        while (begin > 0 && v[begin - 1] == v[a - 1]) begin--;

        int end = a - 1;
        while (end < n - 1 && v[end + 1] == v[a - 1]) end++;

        if (begin == 0) {
            int m = end + 1;
            long cnt = 0;
            for (int i = a; i <= b && i <= m; i++) {
                long tmp = 1;
                for (int j = 0; j < i; j++) {
                    tmp *= m - j;
                    tmp /= j + 1;
                }
                cnt += tmp;
            }
            out.println(ave);
            out.println(cnt);
        } else {
            int m = end - begin + 1;
            int k = a - begin;
            long cnt = 1;
            for (int i = 0; i < k; i++) {
                cnt *= m - i;
                cnt /= i + 1;
            }
            out.println(ave);
            out.println(cnt);
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 23120
{-# LANGUAGE OverloadedStrings #-}
import Data.Char
import Data.List
import Control.Monad
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  s <- BS.getLine
  q <- head.parseLine <$> BS.getLine
  qs <- replicateM q (BS.words <$> BS.getLine)
  let [h,m,l] = solve s qs
  BS.putStr h
  BS.putStr m
  BS.putStrLn l
  where
    parseLine = unfoldr (BS.readInt . BS.dropWhile isSpace)


solve :: BS.ByteString -> [[BS.ByteString]] -> [BS.ByteString]
solve s qs = lastProcess $ foldl process (True,[],[],s) qs

lastProcess :: (Bool, [BS.ByteString], [BS.ByteString], BS.ByteString) -> [BS.ByteString]
lastProcess (True, headStr, lastStr, s) = [BS.concat headStr, s, BS.concat.reverse $ lastStr]
lastProcess (False, headStr, lastStr, s) = [BS.concat headStr, BS.reverse s, BS.concat.reverse $ lastStr]

process :: (Bool, [BS.ByteString], [BS.ByteString], BS.ByteString) -> [BS.ByteString] -> (Bool, [BS.ByteString], [BS.ByteString], BS.ByteString)
process (dir, h, l, m) ("1":_) = (not dir, l, h, m)
process (dir, h, l, m) ("2":"1":c:_) = (dir, (c:h), l, m)
process (dir, h, l, m) ("2":"2":c:_) = (dir, h, (c:l), m)

Measured memory_bytes: 72828
//created by pyoxiao on 2020/04/12
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
int n;
void solve() {
    scanf("%d", &n);
    LL ans = 0;
    for(int i = 1; i <= n; i ++) {
        for(int j = 1; j <= n; j ++) {
            for(int k = 1; k <= n; k  ++) {
                ans += __gcd(__gcd(i, j), k);
            }
        }
    }
    printf("%lld\n", ans);
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 3820
program ABC_075_A_OneoutofThree
   implicit none
   integer A, B, C
   read(*, *) A, B, C
   if(A == B) then
       write(*, *) C
   else if(A == C) then
       write(*, *) B
   else
       write(*, *) A
   end if
end program ABC_075_A_OneoutofThree

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
#define  PI 3.141592
int main(void){
    long double x=0.0, y=0.0;
    int distance, angle, angle_total=0;
    char commma;
    
   
    while(1){
        cin >> distance>> commma >> angle;
        if(angle == 0 && distance == 0) break;
        x += distance * cos((90-angle_total)*PI/180);
        y += distance * sin((90-angle_total)*PI/180);
        angle_total += angle;
        


    }
    int int_x = x;
    int int_y = y;
    cout <<  int_x << endl << int_y << endl;
    return 0;
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

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

int main() {
  // std::cout<<std::fixed<<std::setprecision(10);
  int n;cin>>n;
  const int NM = 3*1e5+10;
  char s[NM];
  int wcnt = 0;
  rep(i,n){
    cin>>s[i];
    if(s[i]=='W') wcnt++;
  }
  int cur = n-wcnt;
  if(s[0]=='E') cur--; //0の場合
  cerr<<cur<<endl;
  int ans = cur;
  for(int i=1;i<=n; i++){
    if(s[i]=='E') cur--;
    if(s[i-1]=='W') cur++; 
    ans = min(ans, cur);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<sstream>
#include<math.h>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int k, n;
	cin >> k >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	sort(a.begin(), a.end());
	int diff = 0;
	for(int i=1;i<n;i++) {
		diff = max(a[i] - a[i - 1],diff);
	}
	diff = max(k - a[n - 1] + a[0], diff);
	cout << k - diff << endl;
	return 0;
}


Measured memory_bytes: 1024
import sys

s = list(input())
for i in range(len(s)):
    if (i+1)%2 ==0:
        if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
            continue
        else:
            print('No')
            sys.exit()
    else:
        if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
            continue
        else:
            print('No')
            sys.exit()

print('Yes')


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

typedef long long ll;


long long fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}







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

  for(int i = 1; i <= K; i++){

   cout <<  (COM(K-1,i-1) * COM ( N-K + 1, i)) % MOD << endl;}
   
  
   return 0;}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
vector<ll> divisor(ll n){
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++){
        if (n % i == 0){
            res.push_back(i);
            if (i != n / i) res.push_back(n/i);
        }
    }
    return res;
}
int main(){
    int n, tmp; sc(n);
    vector<int> a(n+1), cnt(n+1,0), b;
    vector<ll> d;
    rep(i, 1, n+1) sc(a[i]);
    for (int i = n; i > 0; i--){
        d = divisor(i);
        if (cnt[i]%2==a[i]) tmp = 0;
        else tmp = 1;
        rep(j, 0, d.size()) cnt[d[j]] += tmp;
        if (tmp) b.push_back(i);
    }
    cout << b.size() << endl;
    rep(i, 0, b.size()){
        if (i==0) cout << b[i];
        else cout << " " << b[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  double a, b, h;
  cin >> a >> b >> h;
  D((a + b) * h / 2);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define pback push_back
#define mpair make_pair
#define MODN 1000000007

using namespace std;

int main(){

    int n,d;
    cin >> n >> d;

    int able = 2 * d + 1;

    cout << (n + able - 1)/ able << endl;

    
    return 0;
}

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 200001
#define mod 1000000007

int comp, ans;
vector<int> adj[MAXN];
bool visited[MAXN];

void dfs(int s)
{
  comp++;
  ans = max(ans, comp);
  visited[s] = true;
  for (auto const &i : adj[s])
    if (!visited[i])
      dfs(i);
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  for (int i = 0; i < n; i++)
    if (!visited[i])
      comp = 0, dfs(i);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 20920
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

a,b,c=nii()
k=int(input())

cnt=0
while a>=b:
  b*=2
  cnt+=1

while b>=c:
  c*=2
  cnt+=1

print('Yes' if cnt<=k else 'No')

Measured memory_bytes: 9164
using System;
using System.Linq;
using static System.Math;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var WHxy = Console.ReadLine().Split().Select(double.Parse).ToArray();

            double s = WHxy[0] * WHxy[1] / 2;
            bool isAbleToDivideMany = false;

            double q = WHxy[0] / 2;

            if (WHxy[0] / 2 == WHxy[2] && WHxy[1] / 2 == WHxy[3])
            {
                isAbleToDivideMany = true;
            }

            Console.WriteLine("{0} {1}", s, isAbleToDivideMany ? "1" : "0");

        }
    }
}


Measured memory_bytes: 13396
s=input()
n=len(s)
m=n//2
a=0
for i in range(m):
    if s[i] != s[n-1-i]:
        break
    a += 1
for j in range(m//2):
    if s[j] != s[m-1-j]:
        break
    a += 1
print("Yes" if a==m+m//2 else "No")

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

  int main(void)
  {
   char A[11],B[11],C[11];

   scanf("%s%s%s",A,B,C);

   int ae = strlen(A);
   int be = strlen(B);

   if(A[ae-1]==B[0]&&B[be-1]==C[0])
     printf("YES\n");
   else
     printf("NO\n");

   return 0;
  }


Measured memory_bytes: 128
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define WAIT system ("pause")
#define rt0 return 0
using namespace std;
int main()
{
 //   WAIT;
 int A,B;
 int count=0;
 cin>>A>>B;
 for(int i=A;i<=B;i++)
{
if((i/10000)!=(i%10))continue;
int x=(i/1000)%10;
int y= (i/10)%10;
if(x!=y) continue;
count++;
 } 
 
 cout<<count;
    rt0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
int n;
int sz[5005];
ll dp[5005][5005],f[5005],h[2][5005];
vector<int> ve[5005];
void dfs(int x,int fa){
	for(auto to:ve[x]) if(to!=fa) dfs(to,x);
	int cur=0; memset(h[cur],0,sizeof(h[cur])); h[cur][sz[x]=1]=1;
	for(auto to:ve[x]) if(to!=fa){
		memset(h[cur^=1],0,sizeof(h[cur]));
		for(int i=1;i<=sz[x];++i) for(int j=1;j<=sz[to];++j){
			if(~j&1) (h[cur][i]-=h[cur^1][i]*dp[to][j]%mod*f[j])%=mod;
			(h[cur][i+j]+=h[cur^1][i]*dp[to][j])%=mod;
		}
		sz[x]+=sz[to];
	}
	for(int i=1;i<=sz[x];++i) dp[x][i]=h[cur][i];
}
int main(){
	scanf("%d",&n); ll ans=0;
	for(int i=1,x,y;i<n;++i) scanf("%d%d",&x,&y),ve[x].push_back(y),ve[y].push_back(x);
	for(int i=(f[0]=1,2);i<=n;i+=2) f[i]=f[i-2]*(i-1)%mod;
	for(int i=(dfs(1,0),2);i<=n;i+=2) (ans+=dp[1][i]*f[i])%=mod;
	return printf("%lld\n",(ans+mod)%mod),0;
}

Measured memory_bytes: 92788
/*フロイド法(AIZU_vol2_0200)*/
import java.util.Scanner;

class Main{
    
    public static void main(String[] args){   //メイン     
	
	String str1,str2;
	int INF=100000000;
	int SIZE=3002;  //配列サイズ
	int i,j,k,l;
	int n,m;    //線路の情報の数n,駅の数m
	int a,b;    //線路がつなぐ二つの駅a,b
	int p,q,r;  //出発駅p,到着駅q,出力する値r
	int[][] cost,time;  //料金cost[][],移動時間time[][]
	cost = new int[SIZE][SIZE];
	time = new int[SIZE][SIZE];

	Scanner in = new Scanner(System.in);  //入力のやつ

	while(true){  //無限ループ

	    n=in.nextInt();
	    m=in.nextInt();

	    //cost,timeを初期化
	    for(i=1;i<m+1;i++){
		for(j=1;j<m+1;j++){
		    cost[i][j]=INF;
		    time[i][j]=INF;
		}
	    }

	    //終了条件
	    if(n==0 && m==0)break;

	    //データの入力
	    for(i=0;i<n;i++){

		a=in.nextInt();
		b=in.nextInt();
		cost[a][b]=in.nextInt();
		time[a][b]=in.nextInt();

		cost[b][a]=cost[a][b];
		time[b][a]=time[a][b];
	    }

	    //ワーシャルフロイド法で最小コスト、最短時間を求める
	    for(i=1;i<m+1;i++){
		for(j=1;j<m+1;j++){
		    for(k=1;k<m+1;k++){
			cost[j][k]=Math.min(cost[j][k],cost[j][i]+cost[i][k]);
			time[j][k]=Math.min(time[j][k],time[j][i]+time[i][k]);
		    }
		}
	    }

	    l=in.nextInt();

	    //データの出力
	    for(i=0;i<l;i++){

		p=in.nextInt();
		q=in.nextInt();
		r=in.nextInt();

		if(r==1){
		    System.out.println(time[p][q]);
		} else {
		    System.out.println(cost[p][q]);
		}
	    }
	}

    }
	

}

Measured memory_bytes: 176904
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1000000007;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n;
  cin >> n;
  ll arr[n + 5];
  multimap<ll, ll> par;
  for (ll i = 1; i <= n; i++) {
    cin >> arr[i];
    par.insert({arr[i], 1});
  }

  for (ll i = 1; i <= n; i++) {
    par.erase(par.find(arr[i]));
    cout << par.rbegin()->first << en;
    par.insert({arr[i], i});
  }

  return 0;
}

Measured memory_bytes: 15744
n = int(input())

c = ['z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y']

k = 1
n1 = n

while n1-26**k>0:
	n1 = n1-26**k
	k+=1

ans = ''

ans = c[n1%26]+ans

for i in range(k-1):
	if n1%26!=0:
		n1 = n1//26+1
	else:
		n1 = n1//26
	ans = c[n1%26]+ans

print(ans)

Measured memory_bytes: 9080
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

A = require('fs').readFileSync(config.input, 'ascii')
  .split(config.newline, 2);
A = A[1].split(' ').map(Number);
A.unshift(null);

buildMaxHeap(A);

A[0] = '';
console.log(A.join(' '));

function maxHeapify(A, i) {
  var left, right, largest, tmp;
  left = 2 * i;
  if (left >= A.length) left = null;
  right = 2 * i + 1;
  if (right >= A.length) right = null;
  largest = i;
  if (left && A[left] > A[largest]) largest = left;
  if (right && A[right] > A[largest]) largest = right;
  if (largest !== i) {
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest);
  }
}

function buildMaxHeap(A) {
  for (var i = Math.floor(A.length - 1); i >= 1; i--)
    maxHeapify(A, i);
}

Measured memory_bytes: 101832
from sys import stdin, stdout
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, k = rli()
	H = list(rli())
	dp = [INF for _ in range(n)]
	dp[0] = 0
	for i in range(1, n):
		for j in range(max(0, i-k), i):
			cost = abs(H[j] - H[i])
			dp[i] = min(dp[i], dp[j] + cost)
	print(dp[-1])
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 41836