akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

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

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

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

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

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

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

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

    long long N;
    cin >> N;
    vector<double> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    double ans = 0;
    rep(i, N) { ans += 1 / A[i]; }

    cout << 1 / ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define rep(j, n) for(int j = 0; j < (n); j++)
typedef long long ll;
typedef long double ld;
using namespace std;


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

  int n, k;
  string s;
  cin >> n >> s >> k;
  --k;
  for (int i = 0; i < n; i++) {
    if (s[i] != s[k]) cout << '*';
    else cout << s[i];
  }
  cout << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<cassert>
#include<iomanip>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-8
#define equals(a,b) (fabs((a)-(b)) < EPS) 
using namespace std;

struct P
{
  int s,t;
  long double u;
  P(int s=0,int t=0,long double u=0):s(s),t(t),u(u){}
}; 

int N;
long double L;


bool check(int *usage,long double volume)
{
  long double tank = L;
  vector<long double> dist;

  rep(j,2)
    {
      rep(i,86400)
	{
	  tank = min(L,tank+(volume-*(usage+i)));
	  if(tank <= EPS)return false;
	}
      dist.push_back(tank);
    }
  
  return dist[0] < dist[1]+EPS;
}

int main()
{
  while(cin >> N >> L,N|(int)L)
    {
      long double mincost = 0;
      P schedule[N];
      int usage[86401];
      rep(i,86400)usage[i] = 0;
      rep(i,N)
	{
	  cin >> schedule[i].s >> schedule[i].t >> schedule[i].u;
	  REP(j,schedule[i].s,schedule[i].t)
	    usage[j] = schedule[i].u;
	}
      
      long double l = 0;
      long double r = 1100000;
      long double mid;
      rep(j,100)
	{
	  mid = (l+r)/(long double)2.0;// in
	  if(!check(usage,mid))l = mid;
	  else       r = mid;	 
	}
	 
      cout << setiosflags(ios::fixed) << setprecision(8) << mid << endl;
    }
  return 0;
}

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

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().run();
        return 0;
    }

    void run()
    {
        Scanner cin = new Scanner();
        while (true)
        {
            int n = cin.nextInt();
            if (n == 0) break;
            List<int> lnums = new List<int>();
            for (int i = 0; i < n; i++)
            {
                lnums.Add(cin.nextInt() * 2000 + cin.nextInt());
            }
            int m = cin.nextInt();
            for (int i = 0; i < m; i++)
            {
                lnums.Add(cin.nextInt() * 2000 + cin.nextInt());
            }
            int[] nums = lnums.ToArray();
            Array.Sort(nums);
            int len = nums.Length;
            int[] h = new int[len];
            int[] r = new int[len];
            for (int i = 0; i < len; i++)
            {
                h[i] = nums[i] / 2000;
                r[i] = nums[i] % 2000;
            }

            int[] dp = new int[len];
            for (int i = 0; i < len; i++)
            {
                dp[i] = 1;
            }

            int ret = 0;
            for (int i = 0; i < len; i++)
            {
                for (int j = 1; j < len; j++)
                {
                    if (h[i] < h[j] && r[i] < r[j])
                    {
                        dp[j] = Math.Max(dp[j], dp[i] + 1);
                    }
                }
                ret = Math.Max(dp[i], ret);
            }
            Console.WriteLine(ret);
        }

    }

}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

}

Measured memory_bytes: 5864
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007;
li divisibilityCheck(li arr[], li n) 
{ 
    unordered_set<int> s; 
    li max_ele = INT_MIN,i,j; 
    for (i = 0; i < n; i++) { 
        s.insert(arr[i]);
        max_ele = max(max_ele, arr[i]); 
    } 
    unordered_set<li> res; 
    for ( i = 0; i < n; i++) { 
        if (arr[i] != 0) {  
            for (j = arr[i] * 2; j <= max_ele; j += arr[i]) { 
                if (s.find(j) != s.end()) 
                    res.insert(j); 
            } 
        } 
    } 
    unordered_map<li,li> mp; 
    for ( i = 0; i < n; i++) 
        mp[arr[i]]++; 
  
    unordered_map<li,li>::iterator it; 
    vector<li> ans; 
    for (it = mp.begin(); it != mp.end(); it++) { 
        if (it->second >= 2) { 
            if (res.find(it->first) == res.end()) { 
                li val = it->second; 
                while (val--) 
                    ans.push_back(it->first); 
            } 
        } 
        if (res.find(it->first) != res.end()) { 
            li val = it->second; 
            while (val--) 
                ans.push_back(it->first); 
        } 
    } 
    return ans.size();
} 
int main()
{
	li n,x,i,j,c=1;
	cin>>n;
	set<li>s;
	li a[n];
	F {
	cin>>a[i];
	s.insert(a[i]);
	}
	if(s.size()==1 && n!=1)
	{
		cout<<0;
		return 0;
	}
	x=divisibilityCheck(a,n);
	cout<<n-x;
}

Measured memory_bytes: 41848
import math
S = input()
K = int(input())
s = list(S)
c1 = 0
for i in range(len(s)-1):
    if s[i+1] == s[i]:
        c1 += 1
        s[i+1] = 0
s = list(S*2)
c2 = 0
for i in range(len(s)-1):
    if s[i+1] == s[i]:
        c2 += 1
        s[i+1] = 0
c = S[0]
for s in S:
    if s != c:
        print(c1+(c2-c1)*(K-1))
        exit()
print(math.floor(len(S)*K/2))


Measured memory_bytes: 61704
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (inline split-ints-into-vector))
(defun split-ints-into-vector (string dest-vector &key (offset 0) (key #'identity))
  (declare (string string)
           (function key)
           ((array * (*)) dest-vector)
           ((integer 0 #.most-positive-fixnum) offset))
  (loop with position = 0
        for idx from offset below (length dest-vector)
        do (setf (values (aref dest-vector idx) position)
                 (parse-integer string :start position :junk-allowed t))
           (setf (aref dest-vector idx) (funcall key (aref dest-vector idx)))
        finally (return dest-vector)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (let* ((n (read))
         (m (read))
         (c (read))
         (bs (make-array m :element-type 'int32))
         (as (make-array m :element-type 'int32)))
    (split-ints-into-vector (read-line) bs)
    (println
     (loop repeat n
           do (split-ints-into-vector (read-line) as)
           count (> (+ c
                       (loop for a across as
                             for b across bs
                             sum (* a b)))
                    0)))))

#-swank(main)


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

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
cxp int lgc(int x){return 64-__builtin_clzll(x-1);}
cxp int lgf(int x){return 63-__builtin_clzll(x);}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
int getint(){int x;cin>>x;return x;}
char getchr(){char x;cin>>x;return x;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Misc
int sz(const auto& x){return x.size();}
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}
template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
#define defer(x) auto _##__COUNTER__ = defer([&](){x;});
#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
#define reduce accumulate

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

signed main(){
	int x,n; cin>>x>>n;
	int a[n]; rep(i,n) cin>>a[i];
	bool b[101]{};
	rep(i,n)
		b[a[i]]=true;
	int l=x;
	while(l and b[l])l--;
	int r=x;
	while(r<101 and b[r])r++;
	if(x-l <= r-x)
		cout<<l<<endl;
	else if(x-l > r-x)
		cout<<r<<endl;
	return 0;
}



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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
    string s; cin >> s;
    int n = s.size();
    bool flag = 0;
    rep(i, (n-1)/2) {
        int j = (n-1)/2 -1 -i;
        if (i > j) break;
        if (s[i] != s[j]) flag = 1;
    }

    FOR(i, (n+3)/2 - 1, n) {
        int ni = i - (n+3)/2;
        int j = n-i - ni;
        if (i > j) break;
        if (s[i] != s[j]) flag = 1;
    }

    rep(i, n) {
        int j = n-1-i;
        if (i > j) break;
        if (s[i] != s[j]) flag = 1;
    }

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



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
//typedef pair<ll, ll> P;

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

int main() {
    // input
    ll N;
    cin >> N;

    // process
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        if (i % 3 == 0) {
            continue;
        }
        if (i % 5 == 0) {
            continue;
        }
        ans += i;
    }

    cout << ans;

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll k, a, b;
	cin >> k >> a >> b;

	if (b - a <= 2 || k < a - 1) {
		out(k + 1);
		return 0;
	}

	ll ans = a;
	k -= a - 1;

	if (k % 2) {
		ans++;
		k--;
	}

	ans += (b - a) * (k / 2);

	out(ans);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sc scanf
using namespace std;
const int N=3e5+5;
typedef unsigned long long ull;
typedef long long ll;
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll w,h,x,y;
int main(){
    cin>>w>>h>>x>>y;
    double ans=0;
    //if(x*h==w*y||(w-x)*h==w*y||x==0&&y==0||x==w&&y==0||x==0&&y==h||x==w&&y==h){
        int d=0;
        if(2ll*x==w&&2ll*y==h)d=1;
        printf("%.9lf %d\n",h*w*1.0/2,d);
        return 0;
   // }
}


Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()

ans = 0
for a in range(1,n):
    ans += (n-1)//a        

print(ans)

Measured memory_bytes: 31144
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int i=s.nextInt();
		int n=1;
		while(i!=0){
			System.out.println("Case "+n+": "+i);
			n++;
			i=s.nextInt();
		}
	}
}

Measured memory_bytes: 32996
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,mod,tot,fac[6001],mi2[6001],mi3[6001],inv[6001];
inline int kuai(int p,int q,int mod) {int tot=1;for(;q;p=(ll)p*p%mod,q>>=1) if(q&1) tot=(ll)tot*p%mod;return tot;}
#define inc(x,y) x+=y,x>=mod?x-=mod:0
int main()
{
	read(n),read(mod),fac[0]=mi2[0]=mi3[0]=1,mi2[1]=kuai(2,mod-2,mod),mi3[1]=kuai(3,mod-2,mod);
	for(res i=1;i<=3*n;++i) fac[i]=(ll)fac[i-1]*i%mod;
	inv[3*n]=kuai(fac[3*n],mod-2,mod);
	for(res i=3*n-1;~i;--i) inv[i]=(ll)inv[i+1]*(i+1)%mod;
	for(res i=2;i<=3*n;++i) mi2[i]=(ll)mi2[i-1]*mi2[1]%mod,mi3[i]=(ll)mi3[i-1]*mi3[1]%mod;
	for(res i=0;i<=n;++i)
	  for(res j=0;j<=n-i;++j) //3*n-3i-2j>=j
	  	inc(tot,(ll)mi3[i]*mi2[j]%mod*inv[i]%mod*inv[j]%mod*inv[3*n-3*i-2*j]%mod);
	print((ll)tot*fac[3*n]%mod,'\n');  
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 


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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> h(n); rep(i, n) cin >> h[i];

	bool flag = true;
	for (int i = 0; i < n - 1; ++i) {
		if (h[i] < h[i + 1]) {
			h[i + 1]--;
		} else if (h[i] > h[i + 1]) {
			flag = false;
			break;
		}
	}
	printf("%s\n", flag ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 640
n = int(input())
d = list(map(int,input().split()))
j = 0
count = 0
i = 1
while j < n:
    if j + i < n:
        count += d[j] * d[j + i]
        i += 1
    else:
        j += 1
        i = 1
print(count)


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

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		long X=sc.nextLong();
		long M=sc.nextLong();
		long ans=0;
		int[] vis=new int[(int)M];
		long[] sum=new long[(int)M];
		Arrays.fill(vis, -1);
		int p=0;
		while (N-->0) {
			ans+=X;
			vis[(int)X]=p++;
			sum[(int)X]=ans;
			X=X*X%M;
			if (vis[(int)X]!=-1) {
				int T=p-vis[(int)X];
				ans+=N/T*(ans-sum[(int)X]+X);
				N%=T;
			}
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


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

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    long long int A[n][m], B[m][l], C[n][l];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> B[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            C[i][j] = 0;
            for(int k = 0; k < m; k++){
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            if(j > 0) cout << " ";
            cout << C[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3332
n,m=map(int,input().split())
H=list(map(int,input().split()))
L=[]
for i in range(m):
    a,b=map(int,input().split())
    if H[a-1]<H[b-1]:
        L.append(a)
    elif H[a-1]>H[b-1]:
        L.append(b)
    else:
        L.append(a)
        L.append(b)
print(n-len(set(L)))

Measured memory_bytes: 19984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    ll k;
    cin >> n >> k;
    const int mx = 61;
    int to[mx][n];
    rep(i, 0, n) {
        cin >> to[0][i];
        to[0][i]--;
    }
    rep(i, 1, mx) {
        rep(j, 0, n) {
            to[i][j] = to[i - 1][to[i - 1][j]];
        }
    }
    int now = 0;
    for (int i = mx - 1; i >= 0; i--) {
        if (k & (1LL << i)) {
            now = to[i][now];
        }
    }
    cout << now + 1 << endl;
    return 0;
}


Measured memory_bytes: 51212
def calc():
    n = 10**6

    dataset = [t * (t + 1) * (t + 2) // 6 for t in range(1, 181)]

    dp = [1000] * (n+1)
    dp_odd = dp.copy()
    dp[0] = 0
    dp_odd[0] = 0
    for j in range(n):
        for d in dataset:
            if j + d > n:
                break
            if dp[j + d] > dp[j] + 1:
                dp[j + d] = dp[j] + 1
            if d%2:
                if dp_odd[j + d] > dp_odd[j] + 1:
                    dp_odd[j + d] = dp_odd[j] + 1

    return dp, dp_odd


all, odd = calc()

while True:
    n = int(input())
    if n == 0:
        break

    a = all[n]
    o = odd[n]

    print(a, o)



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

int r[10],g[10],b[10];

bool rec(int n){
  if(!n)return true;

  for(int i=1;i<10;i++){
    if(r[i]>=3){
      r[i] -= 3;
      if(rec(n-1))return true;
      r[i] += 3;
    }
    if(g[i]>=3){
      g[i] -= 3;
      if(rec(n-1))return true;
      g[i] += 3;
    }
    if(b[i]>=3){
      b[i] -= 3;
      if(rec(n-1))return true;
      b[i] += 3;
    }
  }
  for(int i=1;i<8;i++){
    if(r[i] && r[i+1] && r[i+2]){
      r[i]--;
      r[i+1]--;
      r[i+2]--;
      if(rec(n-1))return true;
      r[i]++;
      r[i+1]++;
      r[i+2]++;
    }
  if(g[i] && g[i+1] && g[i+2]){
      g[i]--;
      g[i+1]--;
      g[i+2]--;
      if(rec(n-1))return true;
      g[i]++;
      g[i+1]++;
      g[i+2]++;
    } 
  if(b[i] && b[i+1] && b[i+2]){
      b[i]--;
      b[i+1]--;
      b[i+2]--;
      if(rec(n-1))return true;
      b[i]++;
      b[i+1]++;
      b[i+2]++;
    }
  }
  return false;
}

int main(){
  int tmp[10];
  int t;

  cin >> t;
  while(t--){
    for(int i=1;i<10;i++){
      r[i] = 0;
      g[i] = 0;
      b[i] = 0;
      cin >> tmp[i];
    }
    for(int i=1;i<10;i++){
      char c;
      cin >> c;
      if(c == 'R')r[tmp[i]]++;
      if(c == 'G')g[tmp[i]]++;
      if(c == 'B')b[tmp[i]]++;
    }

    if(rec(3))cout << 1 << endl;
    else cout << 0 << endl;
  }
}

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

int n;
int a[210];

int main(){
    cin>>n;
    rep(0,i,n) cin>>a[i];

    int res = 0;
    
    while(true){
        bool exist_odd = false;
        rep(0,i,n){
            if(a[i]%2!=0) exist_odd = true;
        }
        if(exist_odd) break;

        rep(0,i,n){
            a[i] /= 2;
        }

        res++;
    }
    cout << res << endl;
}

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

using namespace std;

int N, a[300009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
int s = 0, all0 = 1;
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]), s ^= a[i], all0 &= (a[i] == 0);
if (s != 0) printf ("No\n");
else
if (N % 3 != 0)
{
    if (all0) printf ("Yes\n");
    else printf ("No\n");
}
else
{
    sort (a + 1, a + N + 1);
    int K = N / 3;
    if (a[1] != a[K] || a[K + 1] != a[2 * K] || a[2 * K + 1] != a[3 * K]) printf ("No\n");
    else printf ("Yes\n");
}
return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int n;
char t[1000];
int c[1000];
int main(){
	cin>>n;
	rep(i,n)cin>>t[i];
	rep(i,n){c[t[i]-'A']++;}
	int ans=0;
	rep(i,1000)if(c[i]>0)ans++;
	if(ans==3)cout<<"Three"<<endl;
	else cout<<"Four"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    p=0
    l=[-1]*N
    cl=[0]*N
    for i in range(N):
        l[i]=p
        cl[p]=1
        p=A[p]-1
        if cl[p]!=0:
            x=l.index(p)
            r=i+1-x
            break
        r=N
        x=0
    #print(l,x,r)
    if K<=x:
        ans=l[K]
        print(ans+1)
    else:
        ans=l[x+(K-x)%r]
        print(ans+1)
    



if __name__ == "__main__":
    main()

Measured memory_bytes: 95828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n;
    cin >> n;
    vector<vector<pair<ll, ll>>> e(n);
    rep(i, 0, n - 1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        e[a].push_back(make_pair(b, c));
        e[b].push_back(make_pair(a, c));
    }

    ll q, k;
    cin >> q >> k;
    k--;

    ll dist[n] = {};
    rep(i, 0, n) dist[i] = -1;
    queue<ll> que;
    que.push(k);
    dist[k] = 0;
    while (!que.empty()) {
        ll nowpos = que.front();
        que.pop();
        rep(i, 0, (int)e[nowpos].size()) {
            ll nextpos = e[nowpos][i].first;
            ll nextcost = e[nowpos][i].second;
            if (dist[nextpos] != -1) continue;
            dist[nextpos] = dist[nowpos] + nextcost;
            que.push(nextpos);
        }
    }


    rep(i, 0, q) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << dist[x] + dist[y] << endl;
    }

    return 0;
}


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

int main() {
    int a,b; cin >> a >> b;
    string s; cin >> s;
    int i = 0;
    bool ok = true;
    while(i<s.size()){
        if(i==a and s[i] != '-') ok = false;
        if(i!=a and s[i] == '-') ok = false;
        i++;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

map<int, long long> primes;

void calcPrimes(int n)
{
	int max_it = (int)sqrt(n);
	// cout << "primes of " << n << " is ";
	for(int i = 2; i <= max_it; i++){
		if(!(n % i)){
			// cout << i << " ";
			primes[i]++;
			n /= i;
			i--;
		}
	}
	// cout << n << endl;
	if(n != 1) primes[n]++;
}


int main()
{
	int N;
	cin >> N;
	long long prod = 1;
	for(int i = 2; i <= N; i++){
		calcPrimes(i);
	}
	for(map<int, long long>::iterator it = primes.begin(); it != primes.end(); it++){
		// cout << it->first << " " << it->second << endl;
		prod = (prod * (it->second + 1)) % 1000000007;
	}
	cout << prod << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
const int N=1e5+10;
int t[N][2],sz=1;
void add(string s)
{
    int i,cur=0;
    for (i=0;i<s.length();i++)
    {
        if (t[cur][s[i]-'0']==0)
            t[cur][s[i]-'0']=sz++;
        cur=t[cur][s[i]-'0'];
    }
}
long long ans=0,l;
void dfs(int x, int d)
{
    if (bool(t[x][0])!=bool(t[x][1]))
        ans^=(l-d)&(d-l);
    if (t[x][0])
        dfs(t[x][0],d+1);
    if (t[x][1])
        dfs(t[x][1],d+1);
}
int main()
{
    int n,i;
    string s;
    scanf("%d%lld",&n,&l);
    for (i=1;i<=n;i++)
    {
        cin>>s;
        add(s);
    }
    dfs(0,0);
    if (ans)
        printf("Alice\n");
    else
        printf("Bob\n");
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> V(5);
  for(int i=0; i<5; i++){
    cin>>V.at(i);
  }
  int K=0;
  for(int i=0; i<5; i++){
    if(V.at(i)==0){
      K=i;
    break;
    }
    else continue;
  }
  cout<<K+1<<endl;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int sum=0;
  rep(i, 5) { int a;
  cin >> a;
  sum += a;
  }
  cout << 15-sum << endl;
  return 0;
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
from collections import *

def bfs():
    q = deque([0])
    visited = [False]*N
    visited[0] = True
    
    while q:
        v = q.popleft()
        
        for nv in G[v]:
            if not visited[nv]:
                add[nv] += add[v]
                q.append(nv)
                visited[nv] = True

N, Q = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

add = [0]*N

for _ in range(Q):
    p, x = map(int, input().split())
    add[p-1] += x

bfs()
print(*add)

Measured memory_bytes: 93716
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,x;
    cin>>n>>x;
    x=2*x+1;
    cout<<(n%x==0 ? n/x : (n/x)+1)<<endl;
return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  vl a(n);
  rep(i,n) {
    cin >> a[i];
  }
  sort(all(a));
  reverse(all(a));
  vl sum(n+1, 0);
  rep(i,n){
    sum[i+1] = sum[i] + a[i];
  }

  rep(i,n) {
    if (i < p) {
      continue;
    }
    if (a[i-1] == a[i]) {
      continue;
    }
    
    if (a[i] + m < a[p - 1]) {
      cout << i << endl;
      return 0;
    }
    
    
    ll rem = max(0LL, v - (n - i) - (p - 1));
    ll w = i - (p - 1);
    ll vol = sum[i] - sum[p-1];
    if (w * (a[i] + m) - vol < rem * m) {
      cout << i << endl;
      return 0;
    }
  }
  cout << n << endl;
}


Measured memory_bytes: 1920
#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++)
#define rep3(i, n) for(int i = n-1; i >= 0; i--)
#define rep4(i, x, n) for(int i = x; i > n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N;
    cin >> N;
    double x[N], y[N];
    rep(i, N) cin >> x[i] >> y[i];
    double sum = 0;
    rep(i, N){
        rep2(j, i+1, N){
            sum += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    cout << setprecision(15) << sum*2/N << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int H, W;
    while (std::cin >> H >> W) {
        if (H == 0 && W == 0) {
            break;
        }
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                std::cout << "#";
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>
#define ll long long

using namespace std;

int main() {

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

	ll A;
	long double B;

	cin >> A >> B;

	ll g = (A * round(B * 100)) / 100LL;

	cout << g << endl;

	
	return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factrial(int n){
  if(n == 0) return 1;
  return n*factrial(n-1);
}

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }

vector<pair<int,pair<int,int>>> v;

int main(){
  int N;
  cin >> N;
  rep(i,N){
    int a,b;
    cin >> a >> b;
    v.push_back(make_pair(b,make_pair(a,b)));
  }
  int day = 0;
  sort(v.begin(),v.end());
  // rep(i,N){
  //   cout << v[i].first << endl;
  // }
  bool f = true;
  rep(i,N){
    day += v[i].second.first;
    if(v[i].second.second < day) f = false;
    // cout << "day = " << day << endl;
   }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  




Measured memory_bytes: 4852
import sys
# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
# from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
# from itertools import permutations, combinations, product, accumulate, groupby
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
# inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []; mod = 10 ** 9 + 7
# dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n = i()
a = wi()
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b)

l_gcd = [a[0]]#左から
r_gcd = [a[-1]]#右から
kl = a[0]
kr = a[-1]
for i in range(n - 2):
    kl = gcd(kl, a[i + 1])
    l_gcd.append(kl)
    kr = gcd(kr, a[-(i + 2)])
    r_gcd.append(kr)

ansli = []
for i in range(n):
    if i == 0:
        ansli.append(r_gcd[-1])
    elif i == n - 1:
        ansli.append(l_gcd[-1])
    else:
        ansli.append(gcd(l_gcd[i - 1], r_gcd[-(i + 1)]))

print(max(ansli))

Measured memory_bytes: 68844
implicit none
character(100) s
integer :: i,j,n
read *,s
n = len_trim(s)
i = scan(s(1:n-1),'C')
if (i /= 0) then
   j = scan(s(i+1:n),'F')
   if (j /= 0) then
      print '(a)','Yes'
      stop
   endif
endif
print '(a)','No'
stop
end

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

int main()
{
    ll H,N;
    cin >> H >> N;
    vector<ll> A(N);
    for(ll i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    ll damage = 0;

    for(ll i = 0; i < N; i++)
    {
        H -= A.at(i);
    } 

    if(H > 0)cout << "No";
    else cout << "Yes";
    cout << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
typedef long long LL;//64ビット以上のサイズ
LL Baggage[100000];
int n,k;

int check(LL P){//トラックに荷物を乗せていく
	int num = 0;
	for(int j = 0; j < k; j++){
		LL s = 0;
		while(s + Baggage[num] <= P){//最大積載量を超えないように処理をする
			s += Baggage[num];
			num++;
			if(num == n){
				return n;
			}
		}
	}
	return num;
}

int solve(){//2分探索で適切な最大積載量の値を求める
	LL lower_limit = 0;//下限
	LL upper_limit = 100000 * 10000;//上限
	LL mid;
	while(upper_limit - lower_limit > 1){
		mid = (lower_limit + upper_limit) / 2;
		if (check(mid) >= n){
			upper_limit = mid;
		}
		else{
			lower_limit = mid;
		}
	}
	return upper_limit;//求めた値を返す
}

int main(){
	scanf("%d %d", &n, &k);//荷物の個数とトラックの台数を入力
	for(int i = 0; i< n; i++){
		scanf("%lld", &Baggage[i]);//配列に入力する
	}
	LL ans = solve();
	printf("%lld\n", ans);//ansを出力
	return 0;
}


Measured memory_bytes: 3536
/**
 * @author      : omgursocute
 * @created     : 27/01/2020
 * @task        : D
 */

// ===== TEMPLATE STARTS HERE ===== //

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define FORa(i, a, b) for(ll i = (a); i <= (b); ++i)
#define FORb(i, a, b, c) for(ll i = (a); i <= (b); i += (c))
#define FORn(i, n) for(ll i = 0; i < (n); ++i)
#define FORra(i, a, b) for(ll i = (a); i >= (b); --i)
#define FORrb(i, a, b, c) for(ll i = (a); i >= (b); i -= (c))
#define FORrn(i, n) for(ll i = ((n)-1); i >= 0; --i)
#define NUMARGC(_1, _2, _3, _4, NAME, ...) NAME
#define FOR(...) NUMARGC(__VA_ARGS__, FORb, FORa, FORn)(__VA_ARGS__)
#define RFOR(...) NUMARGC(__VA_ARGS__, FORrb, FORra, FORrn)(__VA_ARGS__)

#define XFOR(i, x) for(__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define RXFOR(i, x) for(__typeof((x).rbegin()) i = (x).rbegin(); i != (x).rend(); ++i)

#define pll pair<ll, ll>
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define range(x, a, b) ((x).begin()+a), ((x).begin()+b)
#define pb push_back

#define sqr(x) 1ll*(x)*(x)
#ifndef ONLINE_JUDGE
#define debug(x) cerr << '[' << #x << ']' << " = " << x << '\n'
#else
#define debug(x) "cute"
#endif

namespace io {
	void Speed() {
		ios::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	}
#ifndef ONLINE_JUGDE
	void In(string s) {freopen(s.c_str(), "r", stdin);}
	void Out(string s) {freopen(s.c_str(), "w", stdout);}
	void setIO(string s) {In(s + ".inp"); Out(s + "out");}
#endif
}

// ======= TEMPLATE ENDS HERE ======= //

int main() {
	io::Speed();
	
	ll n;
	cin >> n;
	
	ll ct = 0;
	ll x = 1;

	while(n) {
		n >>= 1;
		ct += x;
		x <<= 1;
	}

	cout << ct;

	return 0;
}



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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint 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,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;


    cin >> k >> x;

    if( k * 500 >= x)
    cout << "Yes" << endl;
    else cout << "No" << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
int a[100009];
ll sum[100009];
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	rep(i,n+1) cin>>a[i];
	ll cur = 1,tot=0;
	sum[n]=a[n];
	repD(i,n-1,0) sum[i]=a[i]+sum[i+1];
	rep(i,n) {
		tot+=cur;
		if(cur<a[i]){
			cout<<-1;
			return 0;
		}
		cur-=a[i];
		if(2*cur<sum[i+1]){
			cur=2*cur;
		}
		else if(sum[i+1]<cur){
			cout<<-1;
			return 0;
		}
		else{
			cur=sum[i+1];
		}
	}
	if(cur==a[n]) tot+=cur;
	else tot=-1;
	cout<<tot;
	return 0;
}



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

int main() {
  int n, i;
  ll a, h, w, ans = 0;
  map<ll, ll> mp;
  set<ll> st1, st2;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    mp[a]++;
  }
  for (auto p = mp.begin(); p != mp.end(); ++p) {
    if (p->second > 1) {
      st1.insert(p->first);
    }
    if (p->second > 3) {
      st2.insert(p->first);
    }
  }
  if (st1.size() > 1) {
    auto p = st1.end();
    --p;
    h = *p;
    --p;
    w = *p;
    ans = h * w;
  }
  if (st2.size() > 0) {
    auto p = st2.end();
    --p;
    h = *p;
    ans = max(ans, h * h);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)

#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;

int main() {
	string s; cin >> s;
	if (s.size() == 1) {
		cout << s << endl;
		return 0;
	}

	bool all9 = true;
	rep(i, 1, s.size()) {
		if (s[i] != '9') {
			all9 = false;
		}
	}
	if (all9) {
		cout << ((s[0] - '0') + (s.size() - 1) * 9) << endl;
		return 0;
	}

	ll ans = (s.size() - 1) * 9 + (s[0] - '0') - 1;
	cout << ans << endl;
	return 0;
}

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

#define N 105

int n, m;

array<bitset<N>, N> G;

signed main(void)
{
	for (auto &i : G)
		i.reset();
	
	cin >> n >> m;
	
	for (int u, v; m--; )
	{
		cin >> u >> v;
		G[u][v] = true;
	}
	
	for (int k = 0; k < n; ++k)
		for (int i = 0; i < n; ++i)if (G[i][k])
			for (int j = 0; j < n; ++j)if (G[k][j])
				G[i][j] = true;
				
	bool answer = false;
	
	for (int i = 0; i < n; ++i)
		if (G[i][i])answer = true;
	
	cout << answer << endl;
}

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

int main() {
  int N, K;
  scanf("%d%d", &N, &K);

  vector<int> x(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &x.at(i));
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += min(2 * x.at(i), 2 * abs(K - x.at(i)));
  }

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

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

signed main() {
	cout.precision(16);
	int n;
	cin >> n;
	vector<int> x(n), y(n);
	for (int i = 0; i < n; ++i)cin >> x[i] >> y[i];
	double sum = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			sum += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
		}
	}
	cout << sum / n << endl;
}

Measured memory_bytes: 256