akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 500010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

///////////////////////////////////////////////////////////////////////

int N, K;

int A[5010];
bool dp[5010][5010];
ll S[5010];

void solve() {
	cin >> N >> K;
	rep(i, 0, N) {
		cin >> A[i];
	}
	sort(A, A + N);
	rep(i, 0, N) {
		S[i + 1] = A[i];
		S[i + 1] += S[i];
	}
	//debug(vec(S, S + N + 1));
	dp[N][0] = true;
	for(int i = N - 1; i >= 0; i--) {
		int a = -1, b = -1;
		for(int j = 0; j <= K; j++) {
			if(j - A[i] >= 0) dp[i][j] = max(dp[i][j], dp[i + 1][j - A[i]]);
			dp[i][j] = max(dp[i][j], dp[i + 1][j]);
			if(dp[i + 1][j] && j < K) a = j;
			if(dp[i][j] && j < K) b = j;
		}
		if(K - a <= A[i]) dp[i][K] = true;
		//debug(i, a, b, b + S[i]);
		if(dp[i][K] && b + S[i] < K && i != 0 && A[i] != A[i - 1]) {
			cout << i << "\n";
			return;
		}
	}
	if(!dp[0][K]) cout << N << "\n";
	else cout << "0\n";
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}




Measured memory_bytes: 24832
def main():
    arg = int(input())
    dig1 = arg % 10

    if dig1 in [2, 4, 5, 7, 9]:
        ans = 'hon'
    elif dig1 in [0, 1, 6, 8]:
        ans = 'pon'
    else:
        ans = 'bon'

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mp make_pair 
using namespace std;
const int maxn=100+10;

typedef pair<int,int>pii;

int x1[maxn],y1[maxn],x2[maxn],y2[maxn];

pii dis[maxn];

int main()
{
	int n,m;cin>>n>>m;
	for(int i=1;i<=n;++i)
		scanf("%d%d",x1+i,y1+i);
	for(int i=1;i<=m;++i)
		scanf("%d%d",x2+i,y2+i);
	
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			dis[j]=mp(abs(x1[i]-x2[j])+abs(y1[i]-y2[j]),j);
		}
		sort(dis+1,dis+m+1);
		printf("%d\n",dis[1].second);
	}
	return 0;
}


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

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    cout << ((100 * r + 10 * g + b) % 4 == 0 ? "YES" : "NO") << endl;

    return 0;
}

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

using namespace std;

const int N = 200005;

int n, w, h;
int val[N], res[N];

struct Ant {
	int x, y, id; 
	char t;
} a[N];

int main() {
	ios::sync_with_stdio(false);
	cin >> w >> h >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i].x >> a[i].y >> a[i].t, a[i].id = i;
		if (a[i].t == 'E') val[i] = w - a[i].x;
		else val[i] = h - a[i].y;
	}
	sort(a, a + n, [&] (Ant p, Ant q) {
		return p.x + p.y < q.x + q.y;
	});
	for (int i = 0; i < n; ++i) {
		vector<Ant> go[2];
		int j = i;
		while (i < n && a[j].x + a[j].y == a[i].x + a[i].y) {
			if (a[i].t == 'E') {
				go[a[i].y & 1].push_back(a[i]);
			}
			else {
				go[a[i].x & 1].push_back(a[i]);
			}
			i++;
		}
		i--;
		for (int j = 0; j < 2; ++j) {
			sort(go[j].begin(), go[j].end(), [&] (Ant p, Ant q) {
				return p.x == q.x ? p.t < q.t : p.x < q.x;
			});
			vector<Ant> vec;
			for (auto k : go[j]) {
				if (k.t == 'E') {
					k.x = w + 1, vec.push_back(k);
				}
				else {
					k.y = h + 1, vec.push_back(k);
				}
			}
			sort(vec.begin(), vec.end(), [&] (Ant p, Ant q) {
				return p.x == q.x ? p.y > q.y : p.x < q.x;
			});
			for (int k = 0; k < vec.size(); ++k) {
				res[go[j][k].id] = val[vec[k].id];
			}
		}
	}
	vector<int> p;
	for (int i = 0; i < n; ++i) p.push_back(i);
	sort(p.begin(), p.end(), [&] (int x, int y) {
		return res[x] == res[y] ? x < y : res[x] < res[y];
	});
	for (auto i : p) cout << i + 1 << '\n';
}


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


template <int mod>
struct ModInt {
  int val;
  int trim(int x) const { return x >= mod ? x - mod : x < 0 ? x + mod : x; }
  ModInt(int v = 0) : val(trim(v % mod)) {}
  ModInt(long long v) : val(trim(v % mod)) {}
  ModInt &operator=(int v) { return val = trim(v % mod), *this; }
  ModInt &operator=(const ModInt &oth) { return val = oth.val, *this; }
  ModInt operator+(const ModInt &oth) const { return trim(val + oth.val); }
  ModInt &operator+=(const ModInt &oth) { 
    val = trim(val + oth.val); 
    return *this;
  }
  ModInt operator-(const ModInt &oth) const { return trim(val - oth.val); }
  ModInt operator*(const ModInt &oth) const { return 1LL * val * oth.val % mod; }
  ModInt operator/(const ModInt &oth) const {
    function<int(int, int, int, int)> modinv = [&](int a, int b, int x, int y) {
      if (b == 0) return trim(x);
      return modinv(b, a - a / b * b, y, x - a / b * y);
    };
    return *this * modinv(oth.val, mod, 1, 0);
  }
  bool operator==(const ModInt &oth) const { return val == oth.val; }
  ModInt operator-() const { return trim(mod - val); }
  template<typename T> ModInt pow(T pw) {
    bool sgn = false;
    if (pw < 0) pw = -pw, sgn = true;
    ModInt ans = 1;
    for (ModInt cur = val; pw; pw >>= 1, cur = cur * cur) {
      if (pw&1) ans = ans * cur;
    }
    return sgn ? ModInt{1} / ans : ans;
  }
};

using mint = ModInt<int(1e9 + 7)>;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  string K;
  mint cur[2][100], pre[2][100];
  int D; cin >> K >> D;
  for (int i : {0, 1}) fill(cur[i], cur[i] + D, mint(0));
  cur[1][0] = 1;
  for (int i = 0; i < K.size(); ++i) {
    swap(cur, pre);
    for (int i : {0, 1}) fill(cur[i], cur[i] + D, mint(0));
    for (int d = 0; d < D; ++d) {
      for (int j = 0; j < 10; ++j) {
        for (int k : {0, 1}) {
          if (k and j > K[i] - '0') continue;
          cur[k and j == K[i] - '0'][(d + j) % D] += pre[k][d];
        }
      }
    }
  }
  cout << (cur[1][0] + cur[0][0] - mint(1)).val << '\n';
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define min(p,q)((p)<(q)?(p):(q))

typedef struct edge{ll s,g,c;}E;
int csort(const void*a,const void*b){
	ll p=(*(E*)a).c,q=(*(E*)b).c;
	return p<q?-1:p>q?1:0;
}

E e[90010];
ll a[310][310];
ll d[310][310];
int main(){
	int n,ecnt=0;
	scanf("%d",&n);
	rep(i,0,n)rep(j,0,n){
		int t;
		scanf("%d",&t);
		if(i<j){
			e[ecnt].s=i;
			e[ecnt].g=j;
			e[ecnt].c=t;
			ecnt++;
		}
		a[i][j]=t;
		if(i!=j)d[i][j]=INF;
	}
	qsort(e,ecnt,sizeof(E),csort);
	
	ll ans=0;
	rep(i,0,ecnt){
//		printf("%d %d %d\n",e[i].s,e[i].g,e[i].c);
		if(e[i].c<d[e[i].s][e[i].g]){
			ans+=e[i].c;
			d[e[i].s][e[i].g]=e[i].c;
			rep(p,0,n)rep(q,p+1,n){
				d[p][q]=min(d[p][q],d[p][e[i].s]+e[i].c+d[e[i].g][q]);
				d[p][q]=min(d[p][q],d[p][e[i].g]+e[i].c+d[e[i].s][q]);
				d[q][p]=d[p][q];
			}
/*
			rep(p,0,n){
				rep(q,0,n)printf("%2d ",min(d[p][q],99));
				puts("");
			}
			puts("");
*/
		}
	}

	rep(i,0,n)rep(j,i+1,n)if(d[i][j]!=a[i][j]){
		puts("-1");
		return 0;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    int x; cin >> x;
    if (a * a * b  <= x * 2) {
        cout << fixed << setprecision(12) << atan2(2 * (a * a * b - x), a * a * a) * 180 / PI << endl;
    } else {
        cout << fixed << setprecision(12) <<  90.0 - atan2(x * 2, a * b * b) * 180 / PI << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  cin >> N;
  
  int64_t p = 1;
  int64_t f = 1000000007;
 
  for (int i = 1; i <= N; i++) {
    p = p * i;
    p = p % f;
  }
  
  cout << p << endl;
 
}

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

#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1){ans = (ans*a);}b>>=1;a=a*a;}return ans;}
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}

int main() {
   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(20);
   ll a,b,h,m;
   cin>>a>>b>>h>>m;
   const double val=M_PI/180.0;
	double min_angle=m*6;
	double hrs_angle=0.5*(h*60 + m);
	double result=abs(min_angle - hrs_angle);
	result=min(360 - result,result);
	double d = a*a + b*b - 2*a*b*cos(result*val);
	d=sqrt(d);
	cout<<d<<endl;
	return 0;
}


Measured memory_bytes: 4304
n = int(input())
ans = n % 10
if ans == 2 or ans == 4 or ans == 5 or ans == 7 or ans == 9:
    print("hon")
elif ans == 0 or ans == 1 or ans == 6 or ans == 8:
    print("pon")
elif ans == 3:
    print("bon") 

Measured memory_bytes: 9172
#!/usr/bin/env python3

import collections
import sys
input=sys.stdin.readline

n=int(input())
ans=[0]*n
tmp=[]
for x in range(1,int(n**0.5)+1):
    for y in range(1,int(n**0.5)+1):
        for z in range(1,int(n**0.5)+1):
            tmp.append(x**2+y**2+z**2+x*y+y*z+z*x)

cnt=collections.Counter(tmp)
for i in range(1,n+1):
    print(cnt[i])

Measured memory_bytes: 146372
#pragma GCC optimize(2,3,"Ofast","unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in ll read()
	{
		ll x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<=32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
#define pb push_back
const int N=1e6+5;
int n,m,ans;ll k,a[N],b[N];
int main()
{
	n=read(),m=read(),k=read();
	for(int i=1;i<=n;i++) a[i]=read()+a[i-1];
	for(int i=1;i<=m;i++) b[i]=read()+b[i-1];
	for(int i=0;i<=n;i++) if(k>=a[i])
	{
		int j=upper_bound(b+1,b+m+1,k-a[i])-b;
		ans=max(ans,i+j-1);
	}
	write(ans,'\n');
	return ot(),0;
}
//Author: disangan233

Measured memory_bytes: 6772
using System;
using System.Collections.Generic;
using System.Linq;

class B2
{
    static void Main(string[] args)
    {
        int N = Input.Int();
        var tpl = new Tuple<string, int, int>[N];
        for (int i = 0; i < N; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            tpl[i] = Tuple.Create(s[0], int.Parse(s[1]), i + 1);
        }

        var ans1 = tpl.OrderBy(x => x.Item1);
        var ans2 = ans1.ThenByDescending(x => x.Item2);

        foreach (var item in ans2)
        {
            Console.WriteLine(item.Item3);
        }

    }

    /** Input Class */
    internal static class Input
    {
        /** input int */
        public static int Int() => int.Parse(Console.ReadLine());

        /** input str */
        public static string Str() => Console.ReadLine();

        /** input array of int */
        public static int[] IntArray() => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        /** input array of string */
        public static string[] StrArray() => Input.Str().Split(' ');

        /** input array of char */
        public static char[] charArray() => Input.Str().ToCharArray();
    }

}

Measured memory_bytes: 11732
#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long ll;
int n;
ll a,b,c,d;
int main()
{
	scanf("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	if(a>b)std::swap(a,b);
	ll L=0,R=0;d-=c;b-=a;n--;
	ll x,y;
	bool ans=0;
	if(d>=c)
	{
		if(b>c)ans=(n*d>=b);
		else ans=(n>=2);
	}
	else 
	{
		x=b/c;y=(n-x)>>1;x=n-y;
		L=y*d,R=x*d;a=(x-y)*c;
		ans=(b<=a+R)&&(b>=a-L);
	}
	if(ans)printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

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

    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> ams;
    if (N % 2 == 1) {
        for (int lb = 1, ub = N - 1; lb < ub; lb++, ub--) {
            ams.emplace_back(lb, ub);
        }
    } else {
        bool flag = false;
        for (int lb = 1, ub = N - 1; lb < ub; lb++, ub--) {
            if (!flag && ub - lb <= N / 2) {
                flag = true;
                ub--;
            }
            ams.emplace_back(lb, ub);
        }
    }

    for (int i = 0; i < M; i++) {
        cout << ams[i].first << " " << ams[i].second << endl;
    }

    return 0;
}



Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

		switch (a + b) {
		case 3:
			System.out.println(3);
			break;
		case 4:
			System.out.println(2);
			break;
		case 5:
			System.out.println(1);
			break;
		}
	}
}


Measured memory_bytes: 22612
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
map<string,int> data;
map<string,vector<string> >ren;

inline int res(string s){
	if(!ren.count(s))return data[s];
	int sum = 0;
	for(int i =0;i <ren[s].size();i++){
		sum +=res(ren[s][i]);
	}
	if(data[s]>sum){
		data[s]=sum;
	}
	return data[s];
}

int main(){
	int n,m;
	while(scanf("%d",&n),n){
		data.clear();
		ren.clear();
		for(int i =0;i < n;i++){
			string item;
			int cst;
			cin>>item>>cst;
			data[item] =cst;
		}
		cin>>m;
		int k;
		for(int i =0;i <m;i++){
			string renkin;
			cin>>renkin;
			scanf("%d",&k);
			//int sum=0;
			for(int j =0;j <k;j++){
				string tmp;
				cin>>tmp;
				ren[renkin].push_back(tmp);
			}
			//data[renkin]=min(sum,data[renkin]);
		}
		string ans;
		cin>>ans;
		cout <<res(ans)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1284
<?php
$x = (int)trim(fgets(STDIN));

if ($x === 2) {
	echo $x;
	exit();
}
if ($x % 2 === 0) {
	$x += 1;
}
while (true) {
	$p_list = primefactors($x);
	if (isset($p_list[$x])) {
		echo $x;
		exit();
	}
	$x += 2;
}




// 素因数分解
function primefactors($n){
	// １は確実に1回
	$result = [1 => 1];
	// 偶数なら2を素因数に追加
	while ($n % 2 === 0) {
		$n = (int)floor($n/2);
		if (isset($result[2])) {
			$result[2] += 1;
		}else{
			$result[2] = 1;
		}
	}
	// ３以上の奇数について素因数と乗数を計算（割残し$nの平方根にあたる数まで確認すればOK）
	for ($i=3; $i*$i <= $n; $i+=2) { 
		while ($n % $i === 0) {
			$n = (int)floor($n/$i);
			if (isset($result[$i])) {
				$result[$i] += 1;
			}else{
				$result[$i] = 1;
			}
		}
	}
	// 3以上の割残しがある場合、その数は素数なので素因数として追加する（例：26の素因数13とか）
	if ($n > 2) {
		$result[$n] = 1;
	}
	return $result;
}

Measured memory_bytes: 4856
// Maximum Difference

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

	int maxv = -1;

	for (int i = 0; i < N-1; ++i){
		for (int j = i+1; j < N; ++j){
			if (maxv < abs(a[i]-a[j]))
				maxv = abs(a[i]-a[j]);
		}
	}
	cout << maxv;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int n = (new Scanner(System.in)).nextInt();
        int sum = 100;
        for(int i = 0; i < n; ++i) {
            sum = (int)Math.ceil(sum * 1.05);
        }
        System.out.println(sum * 1000);
    }
}

Measured memory_bytes: 17164
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];
ll tre[3030][3030];
ll dp[3030][3030][4];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, x, t;
	cin >> n >> x >> t;
	ll ans = (n + x - 1) / x * t;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3544
#include <iostream>
//#include <vector>
using namespace std;
int main() {
    const int M=1000000007;
    const int B=4;
    const int A=0,C=1,G=2,T=3;
    int n;
    cin >> n;
    // AGC, GAC, ACG, A_GC, AG_C を含まない
    int i,j,k,h;
    int a[B][B][B], w[B][B][B];
    for(i=0;i<B;i++) {
        for(j=0;j<B;j++) {
            for(k=0;k<B;k++) {
                a[i][j][k]=1;
            }
        }
    }
    a[A][G][C]=0;
    a[G][A][C]=0;
    a[A][C][G]=0;

    for(int p=3;p<n;p++) {
        for(i=0;i<B;i++) {
            for(j=0;j<B;j++) {
                for(k=0;k<B;k++) {
                    w[i][j][k]=a[i][j][k];
                    a[i][j][k]=0;
                }
            }
        }

        for(i=0;i<B;i++) {
            for(j=0;j<B;j++) {
                for(k=0;k<B;k++) {
                    for(h=0;h<B;h++) {
                        if(h==A && k==C && (i==G||j==G)) continue;
                        a[i][j][k] += w[h][i][j];
                        a[i][j][k] %= M;
                    }
                }
            }
        }
        a[A][G][C]=0;
        a[G][A][C]=0;
        a[A][C][G]=0;
    }

    int r=0;
    for(i=0;i<B;i++) {
        for(j=0;j<B;j++) {
            for(k=0;k<B;k++) {
                r += a[i][j][k];
                r %= M;
            }
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i,n,m,p,x[128];
	double t=0;
	while(1){
		scanf("%d %d %d",&n,&m,&p);
		if(n==0&&m==0&&p==0)break;
		t=0;
		for(i=0;i<n;i++)scanf("%d",&x[i]);
		for(i=0;i<n;i++)t+=x[i]*100;
		t-=(double)p/100*t;
		if(x[m-1])t/=x[m-1];
		else t=0;
		printf("%d\n",(int)t);
	}
	return 0;
}

Measured memory_bytes: 600
#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>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
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)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

const int MAX = 114514;
int N, K;

int val[2100][2100];
int sum[2100][2100];

int main() {
	while (cin >> N >> K) {
		memset(val, 0, sizeof(val));
		memset(sum, 0, sizeof(sum));
		for (int i = 0; i < N; ++i) {
			int x, y;
			char c;
			cin >> x >> y >> c;
			if (c == 'B') y += K;
			x %= (K * 2);
			y %= (K * 2);
			val[x][y] += 1;
	
			//COUT(make_pair(x, y));
		}

		for (int i = 0; i <= K * 2; ++i) {
			for (int j = 0; j <= K * 2; ++j) {
				sum[i + 1][j + 1] = val[i][j];
				sum[i+1][j+1] += sum[i + 1][j];
				sum[i+1][j+1] += sum[i][j + 1];
				sum[i+1][j+1] -= sum[i][j];
				
				//cout << i << ", " << j << ": " << sum[i][j] << endl;
			}
		}

		int res = 0;
		for (int i = 0; i < K; ++i) {
			for (int j = 0; j < K; ++j) {
				int tmp1 = sum[i][j] + sum[0][0] - sum[0][j] - sum[i][0];
				int tmp2 = sum[i + K][j + K] + sum[i][j] - sum[i][j + K] - sum[i + K][j];
				int tmp3 = sum[i][K * 2] + sum[0][j + K] - sum[0][K * 2] - sum[i][j + K];
				int tmp4 = sum[K * 2][K * 2] + sum[i + K][j + K] - sum[i + K][K * 2] - sum[K * 2][j + K];
				int tmp5 = sum[K * 2][j] + sum[i + K][0] - sum[i + K][j] - sum[K * 2][0];
				int tmp = tmp1 + tmp2 + tmp3 + tmp4 + tmp5;
				chmax(res, tmp);
				chmax(res, N - tmp);

				//cout << i << ", " << j << ": " << tmp << "(" << tmp1 << ", " << tmp2 << ", " << tmp3 << ", " << tmp4 << ", " << tmp5 << ")" << endl;
			}
		}

		cout << res << endl;
	}
}




Measured memory_bytes: 34688
#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

int main(void){

  int e;

while(1){
    cin >> e;
    int ans = 100000000;
    if(e == 0) break;
      for(int y=0; y <= sqrt(e)+1; y++){
	for(int z=0;z <= cbrt(e)+1; z++){
	int x = e - y*y - z * z * z;
	  if(e == x + y*y + z*z*z && x >= 0){
	    ans = min(ans,x+y+z);
	    //cout << x << ' ' << y << ' ' << z << endl;
	  }
	}
      }

    cout << ans << endl;

 }
  return 0;
}

Measured memory_bytes: 1180
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
using namespace std;

const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    vector<long long> dp(4, 0);
    dp[0] = 1;
    for(int i=0; i<n; ++i){
        vector<long long> nextDp = dp;
        if(s[i] == '?'){
            for(int i=0; i<4; ++i){
                nextDp[i] *= 3;
                nextDp[i] %= MOD;
            }
        }
        for(int j=0; j<3; ++j){
            if(s[i] == 'A' + j || s[i] == '?'){
                nextDp[j+1] += dp[j];
                nextDp[j+1] %= MOD;
            }
        }
        dp = move(nextDp);
    }
    cout << dp[3] << endl;

    return 0;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n;cin>>n;

	vector<tuple<string,int,int>> mp;

	for(int i=1; i<=n; i++){
		string s; int tmp;
		cin>>s>>tmp;

		mp.emplace_back(s,tmp*-1,i);
	}
	sort(mp.begin(),mp.end());

	for(auto e: mp){

		cout<</*get<0>(e)<<" "<<get<1>(e)<<" "<<*/get<2>(e)<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <regex>

void input(std::string& str);
bool input_check(std::string& input);
void count_word(std::string word, std::string text, int& count);
void output(int count);

int main()
{
	std::string word;
	std::string text;
	int count = 0;

	input(word);
	while (input_check(text))
	{
		count_word(word, text, count);
	}
	output(count);
}

void input(std::string& str)
{
	std::cin >> str;
}

bool input_check(std::string& input)
{
	bool check;
	std::cin >> input;
	if (input != "END_OF_TEXT")
	{
		check = true;
	}
	else
	{
		check = false;
	}
	return check;
}

void count_word(std::string word, std::string text, int& count)
{
	std::transform(word.begin(), word.end(), word.begin(), toupper);
	std::transform(text.begin(), text.end(), text.begin(), toupper);

	if (text == word)	++count;
}

void output(int count)
{	
	std::cout << count << std::endl;
}






Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n;cin>>n;
    vi v(n);
    ll sum=0,ans=0;
    rep(i,n)cin>>v[i];
    rep(i,n)sum^=v[i];
    vector<bool> used(n,false);
    for(ll i=62;i>=0;i--){
        if(sum>>i&1){
            ans+=((ll)(1))<<i;
            continue;
        }
        ll w=inf;
        rep(j,n)if(!used[j]&&(v[j]>>i&1))w=j;
        if(w==inf){
            ll t=0;
            rep(j,n)if(v[j]>>i&1)t^=1;
            if(t)ans+=((ll)(1))<<i+1;
            continue;
        }
        used[w]=true;
        rep(j,n){
            if(j==w)continue;
            if(v[j]>>i&1)v[j]^=v[w];
        }
        ans+=((ll)(1))<<(i+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

lin n,a,b,c,d;
string s;

bool solve(lin src, lin dst)
{
    lin cur = src;

    while(cur < dst)
    {
        if(s[cur + 1] == '#' && s[cur + 2] == '#')
            return false;

        if(s[cur + 1] != '#')
            cur++;
        else
            cur += 2;
    }

    return true;
}

bool solve2(lin p1, lin p2)
{
    lin sp = 0;
    for(lin i = p1; i <= p2; i++)
    {
        if(s[i] == '#')
            sp = 0;
        else
            sp++;

        if(sp >= 3)
            return true;
    }

    return false;
}

int main(void)
{
    cin >> n >> a >> b >> c >> d >> s;
    a--;
    b--;
    c--;
    d--;

    bool res = false;
    if(c < d)
    {
        if(solve(a,c) && solve(b,d))
            res = true;
    }
    else
    {
        if(solve(a,c) && solve(b,d) && solve2(b-1,d+1))
            res = true;
    }

    if(res)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 640
while 1:
    n = int(input())
    if n == 0:
        break

    for _ in range(n):
        data = list(map(int, input().split()))
        c = data[0]*data[4] - data[1]*data[5] - \
            data[2]*data[6] - data[3]*data[7]
        i = data[0]*data[5] + data[1]*data[4] + \
            data[2]*data[7] - data[3]*data[6]
        j = data[0]*data[6] - data[1]*data[7] + \
            data[2]*data[4] + data[3]*data[5]
        k = data[0]*data[7] + data[1]*data[6] - \
            data[2]*data[5] + data[3]*data[4]
        print(c, i, j, k)



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

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int count=0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            if ((500*i + 100*j) <= x && (x-(500*i + 100*j))/50 <= c) count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  var temp,pointer;
  const A=input[1].split(' ').map(e=>{
    return e-0;
  });
  var memo=[];
  pointer=0;
  temp=0;
  while(pointer<N&&((temp^A[pointer])===(temp+A[pointer]))){
    temp=temp+A[pointer];
    pointer++;
  }
  memo.push(pointer-1);
  for(var i=1;i<N;i++){
    temp=temp^A[i-1];
    while(pointer<N&&((temp^A[pointer])===(temp+A[pointer]))){
      temp=temp+A[pointer];
      pointer++;
    }
    memo.push(pointer-1);
  }
  console.log(memo.reduce((acc,cur,index)=>{
    return acc+(cur-index+1);
  },0));
                          
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 52100
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

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

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	rep(i, m) {
		int k; cin >> k;
		n -= k;
	}
	if (n < 0)n = -1;
	cout << n << endl;
}


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

int main() {
  string A;
  cin>>A;
  int b=0;
  for(int i=0;i<3;i++){
    if(A.at(i)=='7'){
      b++;
    }
  }
     if(b>0){
       cout<<"Yes"<<endl;
     }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
	int N;
	cin >> N;
	double v[10000];
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
	}
	sort(v + 1, v + N + 1);
	double kati = v[1];
	for (int i = 2; i <= N; i++) {
		kati = (kati + v[i]) / 2;
	}
	printf("%.12f\n", kati);
}

Measured memory_bytes: 256
// 2通りやって

#include <iostream>

using namespace std;

typedef unsigned long long ull;

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

    ull ans = 0, num1, num2;
    if (K % 2 != 0)
    {
        ans = N / K;
        ans = ans * ans * ans;
    }
    else if(N >= K/2)
    {
        // あまりがK/2 or 0
        num1 = (N - K / 2) / K + 1;
        num2 = (N / K);
        ans = num1 * num1 * num1 + num2 * num2 * num2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
int main(void)
{
	int n,i,j;
	int cnt;
	char a[11],m[21],b[11];
	cnt=0;
	scanf("%s %d",a,&n);
	for (i=0;i<n;i++) {
		scanf("%s",m);
		strcpy(b,m);
		strcat(m,b);
		if (strstr(m,a)) {
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1056
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int gcd(int a, int b) {
	if (a < b) swap(a, b);
	while (b != 0) {
		a = a%b;
		swap(a, b);
	}
	return a;
}

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

	for (int i = 0; i < N; ++i) {
		
		//最初にあれば終わり
		if (A[i] == K) {
			cout << "POSSIBLE" << endl;
			return 0;
		}

		//差分列挙
		if (A[i] > K) v.push_back(A[i] - K);

		//ユニークだけを列挙
		st.insert(A[i]);
	}

	//最大値がKより小さい場合
	if (v.size() == 0) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	int mini = 0, mini2 = *min_element(A.begin(),A.end());

	//最小値が更新される限りループ
	while (mini2 != mini) {
		mini = mini2;

		//割り切れればPOSSIBLE
		for (int i = 0; i < v.size(); ++i) {
			if (v[i] % mini == 0) {
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}

		vector<int> u;
		//gcdを作っていく
		for (auto itr = st.begin(); itr != st.end(); ++itr) {
			int g = gcd(mini, *itr);
			u.push_back(g);
		}
		for (int i = 0; i < u.size(); ++i) st.insert(u[i]);
		mini2 = *min_element(u.begin(), u.end());
	}

	cout << "IMPOSSIBLE" << endl;
	return 0;
}



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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N, M, V, P;
ll A[100005];

bool check(ll n) {
    ll s = M * (V - 1);
    vector<ll> v(N, 0);
    REP(i, N) {
        if (i == n)
            continue;
        ll m = std::min({M, s, std::max(0LL, A[n] + M - A[i])});
        v[i] += m;
        s -= m;
    }
    for (ll i = N - 1; i >= 0; --i) {
        if (i == n)
            continue;
        ll m = std::min(s, M);
        m = std::min(m, M - v[i]);
        v[i] += m;
        s -= m;
    }
    ll p = 0;
    REP(i, N) {
        if (i == n)
            continue;
        if (v[i] + A[i] > A[n] + M)
            p++;
    }
    return p < P;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> V >> P;
    REP(i, N) {
        cin >> A[i];
    }
    sort(A, A + N);
    ll ans = N - 1, ng = -1;
    while (abs(ans - ng) > 1) {
        ll mid = (ans + ng) / 2;
        if (check(mid))
            ans = mid;
        else
            ng = mid;
    }
    cout << N - ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++)
#define ll long long 

int main() {
    int n;
    cin >> n;
    
    int p = 0;
    vector<int> prime;
    if(n == 2) {
        cout << 2 << endl;
        return 0;
    }
    rep(i, n, 100100) {
        int flag = 0;
        rep(j, 2, sqrt(i)+1) {
            if(i % j == 0) {
                flag = 1;
                break;
            }
        }
        if(flag == 1) {

        }
        else {
            if(i >= n) {
                cout << i << endl;
                return 0;
            }
            prime.push_back(i);
        }
        
    }

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=200001;
int n;
int a[N];
int sum[N];
long long c[N<<1];
long long ask(int x){
	long long ans=0;
	for(;x;x-=x&(-x))
	  ans+=c[x];
	return ans;
}
void change(int x,int y){
	for(;x<=3*n;x+=x&(-x))
	  c[x]+=y;
}
int check(int x){
  long long ans=0;
  memset(sum,0,sizeof(sum));
  for(int i=1;i<=n;++i)
    sum[i]=(a[i]<=x?1:-1);
  for(int i=1;i<=n;++i)
    sum[i]+=sum[i-1];
  for(int i=0;i<=n;i++)
    sum[i]+=n+1;
  memset( c , 0 , sizeof c );
  for(int i=0;i<=n;i++){
    ans+=ask(sum[i]-1);
    change(sum[i],1);
  }
  return ans>=1ll*n*(n+1)/2/2+1;
}
main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%d",&a[i]);
  }
  int l=0,r=1e9;
  int answer=0;
  while(l<=r){
    int mid=l+r>>1;
    if(check(mid))
      r=mid;
    else
      l=mid+1;
    if(r-l<=1){
      answer=check(l)?l:r;
      goto shit;
    }
    answer=mid;
  }
  shit:;
  printf("%d\n",answer);
  return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int cur = 0;
	for (int i = 1; i <= N; i++) {
		if (i == N || A[i - 1] < A[i]) {
			res = max(res, cur);
			cur = 0;
		}
		else {
			cur++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, M;
int k[15];
int s[15][15];
int p[15];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        cin >> k[i];
        for(int j = 1; j <= k[i]; j++) {
            cin >> s[i][j];
        }
    }
    for(int i = 1; i <= M; i++) cin >> p[i];
    int ans = 0;
    for(int bits = 0; bits < (1 << N); bits++) {
        bool clear = true;
        for(int i = 1; i <= M; i++) {
            int sum = 0;
            for(int j = 1; j <= k[i]; j++) {
                if(bits & (1 << (s[i][j] - 1))) sum++;
            }
            if(!(sum % 2 == p[i])) clear = false;
        }
        if(clear) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N;
  cin>>N;

  int ct=0;
  int ma=0;
  rep(i,N){
    char aa;
    cin>>aa;
    if(aa=='I') ct++;
    else ct--;
    ma=max(ct,ma);
  }

  cout << ma <<"\n";

}


//-----------------------------------
int main(){
  cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}
//-----------------------------------


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

long long gcd(long long a, long long b){
    long long x = min(a, b);
    long long y = max(a, b);
    while(x != 0){
        long long t = y % x;
        long long s = x;
        x = t;
        y = s;
    }
    return y;
}

long long md(long long a, long long b){
    long long ans = a;
    long long n = b+1;
    while(n * n <= a){
        if(a % n == 0){
            ans = n;
            break;
        }
        else n++;
    }
    return ans;
} 

int main(){
    long long A, B;
    cin >> A >> B;
    long long j = 1;
    long long GCD = gcd(A, B);
    long long cnt = 1;
    while(GCD > 1){
        cnt++;
        j = md(GCD, j);
        while(GCD % j == 0){
            GCD /= j;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np

input = sys.stdin.readline
n, k = map(int, input().split())

p = list(map(lambda x: (x + 1) / 2, map(int, input().split())))
# 1 - pi
# print(p)
p_cumsum = np.cumsum(p)
# print(p_cumsum)
ans = p_cumsum[k-1]

for i in range(0, n - k):
    # print(i, i + k)
    cum = p_cumsum[i + k] - p_cumsum[i]
    ans = max(ans, cum)


print('{:.12f}'.format(ans))

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

int main() {
    std::string str;
    std::cin >> str;

    long long int ret = 0;
    long long int n = 0;
    for (auto c : str) {
        ret += c - '0';
        n = n * 10 + (c - '0');
    }

    std::cout << ((n % ret == 0)?"Yes":"No") << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,x;
  scanf("%d",&n);
  scanf("%d",&x);

  int count=0;
  int l[n];
  int d,i;
  int c=0;

  for(i=0;i<n; i++){
    scanf("%d",&l[i]);
  }

  d = c;
  if(d<=x){
    count++;
  }
  for(i=0; i<n; i++){
    d = c + l[i];
    if(d<=x){
      count++;
    }
    c = d;
  }

  printf("%d",count);

  return 0;
}


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

typedef int i32;
typedef long long i64;
typedef unsigned int u32;
typedef unsigned long long u64;


template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};


#define debug(x)  cerr<<x<<"\n";
#define loop(i,n) for(i32 i = 0; i < n; ++i)
#define pi  pair<i32,i32>
#define ti  triple<i32,i32,i32>
#define mk  make_pair
#define vi  vector<i32>
#define vll vector<i64>
#define fastInOut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pr(a) for(auto x:a) cout<<x<<" ";
#define prmap(m) for(auto x:m) cout<<x.first<<" "<<x.second<<"\n";
using namespace std;

bool isPrime(i64 x){
	
	for(i64 i=2;i*i<=x;i++)
		if(x%i==0)
			return false;
	return true;
}

vi V;
const i32 N=7e7+9;
bool prime[N]; 
void SieveOfEratosthenes() 
{
    for (int  p=2; p*p<=N; p++){ 
        if (prime[p] == false){ 
            for (int  i=p*p; i<=N; i += p) 
                prime[i] = true; 
        } 
    } 
    int u=0,mx=0;
    for (int p=2; p<=N; p++) 
      if (!prime[p]) {
          V.push_back(p);
    }
   
}

i64 q,x,t;
char a,b;
void solve(){
    cin>>a>>b;
    if(a==b)
       cout<<"H";
    else 
         cout<<"D";

}

int main(){
   	fastInOut
    solve();
    return 0;
}


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

const long long MAXN = 3e3 + 9, MAXA = 1e6 + 6, SQRT = 447;
long long n, ans;
long long Arr[MAXN];

long long f(long long m) {
    long long res = 0;
    for (long long i = 0; i < n; i++)
        res += m % Arr[i];
    ans = max(ans, res);
}

int main() {
    scanf("%lld", &n);
    for (long long i = 0; i < n; i++) {
        scanf("%lld", &Arr[i]);
        ans += Arr[i] - 1;
    }
    printf("%lld", ans);
}

Measured memory_bytes: 256
// finish date: 2018/02/18

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    int A;
    cin >> N >> A;
    N = N % 500;
    if (A >= N) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}




Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    if(S[0]=='S')
    cout << "Cloudy" << endl;
    else if (S[0]=='C')
    cout <<"Rainy"  << endl;
    else
    cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

line1 = input()
line2 = input()
sN, sX = line1.split()
N = int(sN)
X = int(sX)
sL = line2.split()
L = []
for sl in sL:
    L.append(int(sl))

D = 0
cnt = 1

for l in L:
    D += l
    if D <= X:
        cnt += 1

print(cnt)


Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input!{
        n: usize,
    }
    let mut s : u64 = 0;
    let f_max = ((n + 1) as f64).sqrt() as usize;
    for f in 1..f_max {
        if n % f == 0 {
            s += (n / f) as u64 - 1;
        }
    }
    println!("{}", s);
}



Measured memory_bytes: 4476