akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int a,b,c,d,mn,mx,mnn,mxn;
   cin>>a>>b>>c>>d;
   if(a>0&&c>0&&b>0&&d>0) cout<<(b*d)<<endl;
   else {
      mx=max(c,d);
      mxn=max(a,b);
      mn=min(c,d);
      mnn=min(a,b);
      long long int a1=mnn*mx;
      long long int a2=mnn*mn;
      long long int a3=mxn*mx;
      long long int a4=mxn*mn;
      cout<<max(max(max(a3,a4),a2),a1)<<endl;
   }
}


Measured memory_bytes: 3632
aa=list(map(int,input().split()))
a=aa[0]
b=aa[1]
c=aa[2]
if a==b and a==c:
    print("No")
elif a==b:
    print("Yes")
elif a==c:
    print("Yes")
elif b==c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int a,b,c,k;
int main() {
  cin>>a>>b>>c>>k;
  int x=b;
  while(x<=a) {
    x*=2;
    --k;
  }
  while(c<=x) {
    c*=2;
    --k;
  }
  if(k>=0) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
bool check(int yr,int mo) {
    return mo>=1 && mo<=12;
}
int main()
{
    int n;
    int x,y;
    while (~scanf("%d", &n)) {
        x = n/100;
        y = n%100;

        if (check(x,y) && check(y,x)) puts("AMBIGUOUS");
        else if (check(x,y)) puts("YYMM");
        else if (check(y,x)) puts("MMYY");
        else puts("NA");
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int x=0,y=0;
	string s;
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
			x++;
			}
		else{
			if(x>y){
				y=x;
				x=0;
				}
			}
		}
		if(x>y){
				y=x;
				x=0;
			}
	cout<<y<<endl;
	return 0;
}



Measured memory_bytes: 256
N=gets.to_i
ary=gets.split.map(&:to_i)
count = 0
type = :NONE
1.upto(N-1) do |n|
  case type
  when :NONE
      if ary[n] == ary[n-1]
        next
      end
      if ary[n] < ary[n-1]
      type = :DEC
    else
      type = :INC
    end
  when :INC
    if ary[n] < ary[n-1]
      count += 1
      type = :NONE
    end
  when :DEC
    if ary[n-1] < ary[n]
      count += 1
      type = :NONE
    end
  end
end
puts count + 1


Measured memory_bytes: 8460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int n;
    cin>>n;
    cout<<(180*(n-2))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	double x[4],y[4];
	for(int i=0;i<4;i++){
		cin>> x[i]>> y[i];
	}
	if(x[1]==x[0] || x[3]==x[2]){
		if(x[1]==x[0] && x[3]==x[2]){
			cout<< "YES"<< endl;
		}else{
			cout<< "NO"<< endl;
		}
		return true;
	}
	double rad1 = atan( (y[1]-y[0]) / (x[1]-x[0]) );
	double rad2 = atan( (y[3]-y[2]) / (x[3]-x[2]) );
	if(rad1 == rad2){
		cout<< "YES"<< endl;
	}else{
		cout<< "NO"<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		solve();
	}
	return 0;
}

 

Measured memory_bytes: 1268
//https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_b
// clang-format off
#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 ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int K;
void f(int &mine, int &others, int i)
{
    if (i == K)
        return;
    // iターン目が自分の番
    // 自分の枚数が奇数のとき、自分の枚数(mine)を1枚減らす
    if (mine % 2 == 1)
    {
        mine = mine - 1;
    }

    int gift = mine / 2; //受け渡しする枚数

    //自分の半分(gift)を相手に渡す
    mine -= gift;
    others += gift;

    // 相手の番
    f(others, mine, i + 1);
}
int main()
{
    int A, B;
    cin >> A >> B >> K;
    f(A, B, 0);
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}

int t,n,m,ans;
int MOD=1e9+7;
int cnt[100005];

int main()
{
	int i,j,k,l,r=0;
	gn(n);gn(m);
	repu(i,1,n){
		gn(cnt[i]);
		if(cnt[i]+cnt[i-1]>r){
			r=cnt[i]+cnt[i-1];
			j=i-1;
		}
	}
	if(r>=m){
		puts("Possible");
		repu(i,1,j-1)printf("%d\n",i);
		repd(i,n-1,j+1)printf("%d\n",i);
		printf("%d\n",j);
	}
	else puts("Impossible");
	return 0;
}



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



int main(void)
{


    int x,y;

    cin>>x>>y;

    if(y%2!=0)
    {
        cout<<"No"<<endl;
        return 0;
    }
    for (int i=0; i<=x; i++)
    {
        if((2*(x-i)+4*i)==y)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

    return 0;
}



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

using namespace std;

bool compare(int a, int b)
{
    return a > b;
}

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

    int n;
    cin >> n;

    vector<int> arr(n);

    for(int i = 0; i < n; ++i)
        cin >> arr[i];

    sort(arr.begin(), arr.end(), compare);

    int answer = 0;

    for(int i = 0; i < n; ++i)
    {
        if(i & 1)
            answer -= arr[i];
        else
            answer += arr[i];
    }


    cout << answer << '\n';


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 200005;
bool isPrime[MAXN];
vector<int> pr;
vector<int> ans;
void sieve()
{
    memset(isPrime, 1, sizeof isPrime);
    isPrime[0] = isPrime[1] = 0;

    for (int i = 2; i * i <= MAXN; i += 1 + (i & 1))
    {
        if (isPrime[i])
        {

            for (int j = i * i; j < MAXN; j += i)
                isPrime[j] = 0;
        }
    }
    for(int i=0; i<MAXN; i++)
    {
        if(isPrime[i])
        {

            ans.push_back(i);
        }
    }
}

ld power(ld x, ll y)
{
    ll temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
        return x * temp * temp;
}

void debug_out()
{
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll n;
ll arr[1010];


int main()
{
    FAST
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    ll cur=1000;
    for(int i=1;i<n;i++){
        if(arr[i]>arr[i-1]){
            ll stocks=cur/arr[i-1];
            cur=(stocks*arr[i])+(cur%arr[i-1]);
        }
    }
    cout<<cur<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

struct query {
	int t, f;
	char c;
	query() : t(0), f(0), c(' ') {}
};

signed main()
{	
	string s;
	int q;
	cin >> s;
	cin >> q;
	V<query> qs(q);
	REP(i, q) {
		cin >> qs[i].t;
		if (qs[i].t == 2) {
			cin >> qs[i].f >> qs[i].c;
		}
	}

	int rev = 1;
	string front(""), back("");
	REP(i, q) {
		if (qs[i].t == 1) {
			rev *= -1;
			continue;
		}
		if (rev > 0) {
			if (qs[i].f == 1) {
				front += qs[i].c;
			}
			else {
				back += qs[i].c;
			}
		}
		else {
			if (qs[i].f == 1) {
				back += qs[i].c;
			}
			else {
				front += qs[i].c;
			}
		}
	}

	if (rev > 0) {
		reverse(ALL(front));
		s = front + s + back;
	}
	else {
		reverse(ALL(s));
		reverse(ALL(back));
		s = back + s + front;
	}
	col(s);
	return 0;
}


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

typedef long long ll;
#define re(n) cin >> n
#define all(a) a.begin(),a.end()
#define fast std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define te(t) ll t; re(t); while(t--)

int main(){
	ll r;
	re(r);
	cout << r*r << endl;
	return 0;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	map<string, int> mapper;
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		string s;
		cin>>s;
		mapper[s]++;
	}

	string a[] = {"AC", "WA", "TLE", "RE"};
	for(i=0;i<4;i++){
		cout<<a[i] << " x "<< mapper[a[i]]<<endl;
	}

	
	return 0;
};

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int x;
    cin >> x;
    if (x == 0) {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define COUT(x) cout << #x << " = " << (x) << ", "
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  ll X; cin >> X;
  int tmp1 = X / 500;
  X = X % 500;
  int tmp2 = X / 5;
  cout << tmp1 * 1000 + tmp2 * 5 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  vector<char> str;
  while(n)
  {
      long long p = n%26;
      if(p==0){
      str.push_back('z');
      n = (n / 26) - 1;} 
      else{
      n = n/26;
     str.push_back('a'+p-1);}
  }
for(long long i=str.size()-1;i>=0;i--)
printf("%c",str[i]);
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 1145141919
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)

using namespace std;

int main(void){
  string S;
  unsigned long long int K,check=0,rem=0;
  cin >> S >> K;
  unsigned long long int L=S.length();
  rep(i,min(L,K)){
    if(S[i]!='1'){
      check=1;
      rem=i;
      break;
    }
  }
  if(check==0) cout << "1" << endl;
  else cout << S[rem] << endl;
}

Measured memory_bytes: 256
import sys
rl=sys.stdin.readline

def main():
    n,m=map(int,rl().strip().split())
    eaw=[list(map(int,rl().strip().split())) for _ in range(m)]
    d=dict(((x[0]-1,x[1]-1),-x[2]) for x in eaw)
    inf=10**14
    mdl=[inf]*n
    mdl[0]=0
    def blrelax(dl,k):
        for _ in range(k):
            for e in iter(d):
                if dl[e[0]]+d[e]<dl[e[1]]:
                    dl[e[1]]=dl[e[0]]+d[e]
    blrelax(mdl,n-1)
    a1=mdl[n-1]
    blrelax(mdl,n)
    a2=mdl[n-1]
    if a1>a2:
        print('inf')
    else:
        print(-a1)
    
if __name__=='__main__':
    main()


Measured memory_bytes: 9784
import sys

N = int(input())
# 二分探索っぽい感じ
print("0")
sys.stdout.flush()
zero = input()
high = N - 1
low = 0
if zero != "Vacant":
    while True:
        mid = (high + low) // 2
        print(mid)
        sex = input()
        if sex == "Vacant":
            break
        if (mid % 2 == 0 and sex == zero) or (mid % 2 == 1 and sex != zero):
            low = mid + 1
            # zero -> midには存在しない
        else:
            high = mid - 1




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

int main()
{
  char c[1000];
  int sum,i,k,out[1000];
  sum=k=0;
  while(1){
    scanf("%s",c);
    if(c[0]=='0') break;
    for(i=0;i<strlen(c);i++) sum+=c[i]-48;
    out[k]=sum;
    sum=0;
    k++;

  }
  for(i=0;i<k;i++) printf("%d\n",out[i]);
  return 0;
}

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

int n;
int a[101];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int ans=0;
	for(int i=1;i<n;i++){
		if(a[i-1]==a[i]){
			a[i]=10001;
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> vs;
  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    vs.push_back(s);
  }

  int mv_x[4] = {-1, 0, 1, 0};
  int mv_y[4] = {0, 1, 0, -1};
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (vs[i][j] == '#') {
        bool ok = false;
        for (int k = 0; k < (int)(sizeof(mv_x) / sizeof(int)); k++) {
          int x = i + mv_x[k];
          int y = j + mv_y[k];
          if (x < 0 || x >= h || y < 0 || y >= w) continue;
          if (vs[x][y] == '#') {
            ok = true;
            break;
          }
        }
        if (!ok) {
          puts("No");
          return 0;
        }
      }
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    int  k,n;
    double p[200001];
    cin>>n>>k;
    rep(i,n) cin>>p[i];
    rep(i,n) p[i]=(p[i]+1)/2;
    double ans,a=0;
    rep(i,k) a+=p[i];
    ans=a;
    rep(i,n-k){
        a-=p[i];
        a+=p[i+k];
        ans=max(a,ans);
    }
    cout<<setprecision(10)<<ans;
}

Measured memory_bytes: 1792
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
applyBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
applyBin op f g x = op (f x) $ g x
applyUni :: (a -> b -> c) -> (a -> b) -> a -> c
applyUni op f x = op x $ f x
applyTuple :: (a -> b, a -> c) -> a -> (b, c)
applyTuple (f,g) a = (f a, g a)
-- end of templete

check = check' . map length . group . sort . concat :: [[Int]] -> Bool
  where
    check' (f:s:t) = odd f && odd s && all even t

main = map (cond "OK" "NG" . check) . endBy [[0,0]] . map (map readInt . words) . lines <$> getContents >>= mapM_ putStrLn

Measured memory_bytes: 4968
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w) puts("NO");
	else {
		if (abs(a - b) <= 1ll * (v - w) * t) puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>

main()
{
	int h,w;
	int i,j;
	
	do{
		scanf("%d %d",&h,&w);
		
		if(h == 0 && w == 0){
			break;
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if((i+j)%2 == 0){
					printf("#");
				} else {
					printf(".");
				}
				
				if(j == w-1){
					printf("\n");
				}
			}
		}
		printf("\n");
	}while(1);
	
	return 0;
}

Measured memory_bytes: 572
X = int(input())

B = [n**5 for n in range(200)]

A = []

for i in range(200):
    a = i**5- X if i**5 >= X else X-i**5
    A.append(a)

for j in range(200):
    if A[j] in B:
        a = j
        b = B.index(A[j])
        if a**5-b**5 == X:
            print(a,b)
        elif a**5+b**5 == X:
            print(a,-b)
        else:
            print(b,a)
        break


Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;//
template <typename T>
T sq (T x) {
  return x * x;
}

int cnt = 0;
signed main () {
  lint A,B,N;
  lint ans;
  cin >> A >> B >> N;

  if(B-1 > N){
    ans = (A * N) / B;
  }else{
    ans = (A * (B-1)) / B;
  }
  cout << ans <<endl;
  return 0;
}



Measured memory_bytes: 3636
n = int(input())
if n==0:
    print(0)
    exit()
x = n
ans = []
while x!=1:
    if x%2==0:
        ans.append("0")
    else:
        ans.append("1")
        x -= 1
    x = x//(-2)
ans.append("1")
print("".join(ans[::-1]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define el '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define all(x) x.begin(),x.end()
#define int long long
int inf = 1e18;

int32_t main()
{
    fastIO
    int t=1;
    //cin>>t;

    while(t--)
    {
        int n;
        cin>>n;
        int arr[n];
        int sum =0;
        fo(i,n){
        cin>>arr[i];
        sum+= arr[i];
        }
        int sum1 =  0;
        int minn = inf;
        fo(i,n)
        {
            sum1+= arr[i];
            minn  =min(abs(sum1-(sum-sum1)),minn);
        }
        cout<<minn<<el;

   }
    return 0;
}
// always test the corner cases ALWAYS;


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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum=0;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    sum=sum+a.at(i);
  }
  vector<ll> b(n-1);
  ll suma=0;
  for(int i=0;i<n-1;i++){
    suma=suma+a.at(i);
    b.at(i)=abs(2*suma-sum);
  }
  sort(b.begin(),b.end());
  cout << b.at(0) << endl;
}



Measured memory_bytes: 6312
use std::fmt::Debug;
use std::io;
use std::collections::{VecDeque};
use std::io::Write;

#[cfg(test)]
mod tests;

fn main() {
    // a();
    // b();
    c();
    // d();
}

fn c() { 
    let mut buf = String::new();
    let handle = io::stdin();
    handle.read_line(&mut buf).unwrap();
    let n: isize = buf.trim().parse().unwrap();

    let num_length = format!("{}", n).len() as isize;


    let options = vec![3, 5, 7];
    let mut sets = Vec::new();
    let mut bases = VecDeque::new();
    bases.push_front(vec![]);

    let ans_vec: Vec<isize> = permutation(
        options, bases, sets, num_length as usize
    ).into_iter()
    .filter(|a| include_sichigosan(a))
    .map(|a| vec_to_int(a))
    .filter(|a| a <= &n ).collect();

    println!("{}", ans_vec.len());
}


fn vec_to_int(v: Vec<isize>) -> isize {
    let mut total = 0;
    for (i, v) in v.into_iter().enumerate() {
        total += v * 10_i32.pow(i as u32) as isize; 
    }
    total
}

fn permutation<T: Clone + Debug + Copy>(
    options: Vec<T>,
    mut bases: VecDeque<Vec<T>>,
    mut sets: Vec<Vec<T>>, 
    length: usize
) -> Vec<Vec<T>> {
    let bases_len = bases.len();
    if bases[0].len() == length {
        return sets;
    }
    for b in 0..bases_len {
        let target = bases.pop_back().unwrap();
        for i in &options {
            let mut new_v = target.clone();
            new_v.push(i.clone());
            bases.push_front(new_v.clone());
            sets.push(new_v);
        }
    }
    permutation(options, bases, sets, length) 
}

fn include_sichigosan(v: &Vec<isize>) -> bool {
    let mut check = [false, false, false, true];
    for i in v {
        match *i {
            3 => check[0] = true,
            5 => check[1] = true,
            7 => check[2] = true,
            _ => check[3] = false,
        }
    }
    
    !(check.into_iter().any(|&a| a == false))
}

Measured memory_bytes: 10492
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    string s;
    cin>>s;
    if((s[5]-'0')*10+(s[6]-'0')<=4){
        fin("Heisei");
    } else fin("TBD");

}


Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))

    ans = 0
    for _ in range(N):
        A = list(map(int, input().split()))
        check = 0
        for i in range(M):
            check += A[i] * B[i]
        if check + C > 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from itertools import accumulate

def is_prime(n):
   if n == 1:
       return False
   for i in range(2, int(n ** 0.5) + 1):
       if n % i == 0:
           return False
   return True

q = int(input())

l, r = [],[]
for _ in range(q):
    t, tt = map(int, input().split())
    l.append(t)
    r.append(tt)

m_r = max(r)

table = [0] * (m_r + 2)
for i in range(1, m_r + 1, 2):
    if is_prime(i) and is_prime((i + 1) // 2):
        table[i] = 1

acc_table = list(accumulate(table))

for i in range(q):
    print(acc_table[r[i]] - acc_table[l[i]-1])

Measured memory_bytes: 15524
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define en         cout<<endl;
#define pb         push_back
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long

ll vis[1000005],a[200005];
int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,c,res,c1,x,y,w,z,c2;
    ci>>n;
    for(ll i=1;i<=n;i++)
    {
        ci>>a[i];
    }
    sort(a+1,a+n+1);
    c=0;
    for(ll i=1;i<=n;i++)
    {
        if(a[i]==a[i-1]) vis[a[i]]=1;
    }
     for(ll i=1;i<=n;i++)
     {
         if(vis[a[i]]!=1) c++;
         if(a[i]!=a[i-1])
         {
             for(ll j=2*a[i];j<=1000000;j+=a[i])
             {
                 vis[j]=1;
             }
         }
     }
    co<<c;
}



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

using namespace std;

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

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());

	long long ans1 = 0, ans2 = 0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			if (ans1 == 0) {
				ans1 = a[i];
				i++;
			} else if (ans2 == 0) {
				ans2 = a[i];
				
				cout << ans1 * ans2 << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;

	return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  int ans =0;
  if (S[0] == 'o') ans += 100;
  if (S[1] == 'o') ans += 100;
  if (S[2] == 'o') ans += 100;
        
  cout << ans + 700 << endl;
}


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

void QSort(int *x, int left, int right);
void Swap(int *x, int i, int j);
int count = 0;

int main()
{
	int n, k, i, j, tmp;
	unsigned long long int sum = 0;
	int *h;
	scanf("%d %d", &n, &k);
	if(n <= k){
		printf("0\n");
		return 0;
	}
	h = (int *)malloc(sizeof(int) * n);
	for(i = 0; i < n; i++){
		scanf("%d", &h[i]);
	}
	/*
	for(i=0; i<n; ++i) {
    for(j=i+1; j<n; ++j) {
      if(h[i] > h[j]) {
        tmp =  h[i];
        h[i] = h[j];
        h[j] = tmp;
      }
    }
  }*/
  	QSort(h, 0, n - 1);
	for(i = 0; i < n - k; i++){
		sum += h[i];
	}
	printf("%llu\n", sum);
	
	return 0;
}

void QSort(int *x, int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }
    //ShowData(x, 10);               /* 途中経過を表示 */

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

void Swap(int *x, int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
using Graph = vector<vector<pair<int, int>>>;
void assign_color(Graph &g, vector<int>&c, int s) {
	queue<int>q;
	q.push(s);
	while (!q.empty()) {
		int x = q.front(); q.pop();
		if (c[x] == 0)c[x] = 1;
		else continue;

		rep(i, 0, g[x].size()) {
			q.push(g[x][i].first);
		}
	}
}
// O( ( |V| + |E| ) * log|V| )
const int W = 0, B = 1;
//重み付き有効グラフの隣接リスト表現
vector<int> dijkstra(const vector<vector<pair<int, int>>> &g, int s) {
	int n = g.size();
	priority_queue<pair<int, int>>pq;// cost, node
	vector<int>color(n, W), d(n, INF);
	d[s] = 0;
	pq.push(make_pair(0, s));

	while (!pq.empty()) {
		pair<int, int>f(pq.top()); pq.pop();// d[v], v
		color[f.second] = B;

		if (d[f.second] < (-1)*f.first)continue; // 最小値を取り出し、それが最短でなければ無視

		rep(i, 0, g[f.second].size()) {
			pair<int, int>v(g[f.second][i]);
			if (color[v.first] != B&&d[f.second] + v.second < d[v.first]) {
				d[v.first] = d[f.second] + v.second;
				pq.push(make_pair(d[v.first] * (-1), v.first)); // priority_queueはデフォルトで大きい値を優先するため-1を掛ける
			}
		}
	}
	return d;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	Graph g(N);
	rep(i, 0, N - 1) {
		int a, b; cin >> a >> b;
		a--, b--;
		g[a].emplace_back(make_pair(b, 1)); g[b].emplace_back(make_pair(a, 1));
	}
	vector<int>b(N, 0), w(N, 0);
	b[N - 1] = -1, w[0] = -1;
	//assign_color(g, b, 0); assign_color(g, w, N - 1);

	auto d_from1 = dijkstra(g, 0), d_fromN = dijkstra(g, N - 1);
	int cntb(0), cntw(0), cntelse(0);
	//rep(i, 0, N) {
	//	if (b[i] == 1 && w[i] == 1) {
	//		if (d_from1[i] <= d_fromN[i])cntb++;
	//		else cntw++;
	//	}
	//	else if (b[i] == 1 && w[i] != 1)cntb++;
	//	else if (b[i] != 1 && w[i] == 1)cntw++;
	//}
	rep(i, 0, N) {

		if (d_from1[i] <= d_fromN[i])cntb++;
		else cntw++;
	}
	cout << (cntb > cntw ? "Fennec" : "Snuke") << endl;
	return 0;
}

Measured memory_bytes: 8444
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto K = RD;
	auto A = RDA;
	auto F = RDA;
	A.sort!"a > b"();
	F.sort();

	bool f(long x)
	{
		long cnt;
		foreach (i; 0..N)
		{
			auto c = x / F[i];
			cnt += max(0, A[i] - c);
		}
		return cnt <= K;
	}

	long ok = (10L^^12)+1, ng = -1;
	while (abs(ok-ng) > 1)
	{
		auto mid = (ok+ng) / 2;
		if (f(mid))
			ok = mid;
		else ng = mid;
		debug writeln("ok:", ok, " ng:", ng);
	}
	
	writeln(ok);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 15328
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{it.toInt()}
    var cnt1 = 0
    var cnt4 = 0
    var cnt2 = 0
    a.forEach{
        if(it % 4 == 0) cnt4++
        else if(it % 2 == 1) cnt1++
        else cnt2++
    }
    if(cnt2 != 0) println(if(cnt4 >= cnt1) "Yes" else "No")
    else println(if(cnt4 >= cnt1 - 1) "Yes" else "No")
}


Measured memory_bytes: 51744
#include <iostream>

using namespace std;
int main() {
    char S[16];
    cin >> S;
    int win = 0;
    int play = 0;
    for (int i=0; S[i]; i++) {
        play++;
        if (S[i] == 'o') win++;
    }
    int rest = 15 - play;
    cout << (win+rest >= 8 ? "YES" : "NO") << endl;
    return 0;
}



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

int main() {
	
	vector<vector<int>>a(3,vector<int>(3));
	for(auto &i : a) for(auto &j : i) cin >> j;
	int n;
	cin >> n;
	vector<vector<bool>>c(3,vector<bool>(3));
	for(int k=0; k<n; k++){
		int b;
		cin >> b;
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				if(a.at(i).at(j)==b) c.at(i).at(j)=1;
			}
		}
	}
	bool flg=0;
	for(int i=0; i<3; i++){
		if(c.at(i).at(0)==1 && c.at(i).at(1)==1 && c.at(i).at(2)==1) flg=1;
		if(c.at(0).at(i)==1 && c.at(1).at(i)==1 && c.at(2).at(i)==1) flg=1;
	}
	if(c.at(0).at(0)==1 && c.at(1).at(1)==1 && c.at(2).at(2)==1) flg=1;
	if(c.at(0).at(2)==1 && c.at(1).at(1)==1 && c.at(2).at(0)==1) flg=1;
	if(flg) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;  
  cin >> N;
  int64_t ans;
  cin >> ans;
  for (int i = 1; i < N; i++) {
    int64_t T;
    cin >> T;
    ans = lcm(ans, T);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;


int main(){
    int N,W;cin >> N >> W;
    vector<pair<int,int>> vec;
    for(int i = 0;i < N;i++){
        int b;cin >>b;
        int c;cin >> c;
        vec.push_back({b,c});
    }
    vector<vector<LL>> dp(N+1, vector<LL>(1000000,1e18));
    for(int a = 0;a <= N;a++)dp.at(a).at(0)=0;
    for(int a = 1;a <= N;a++){
        for(int b = 1;b <= 1000000;b++){
            if(b - vec.at(a-1).second >= 0){
                if(dp[a-1][b-vec.at(a-1).second] != 1e18){
                    dp[a][b] = min(dp[a-1][b-vec.at(a-1).second] + vec.at(a-1).first,dp[a][b]);
                }
            }
            if(dp[a-1][b] != 1e18)dp[a][b] = min(dp[a][b],dp[a-1][b]);
        }
    }
/*
    for(int a = 0;a <= N;a++){
        for(int b = 0;b <= 30;b++){
            if(dp[a][b] != 1e9)cout<<dp[a][b]<<" ";
            else cout<<"1e ";
        }
        cout<<endl;
    }
*/
    int ans = 0;
    for(int a = 0;a < 1000000;a++){
        if(dp.back()[a] != 1e18 && dp.back()[a] <= W)ans = a;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 797440
#include<stdio.h>
#include<string.h>
int A[1001][1001];
int main(){
  int n,i,j,k,x,y;
  char str1[1001],str2[1001];
  scanf("%d",&n);
  for(k=0;k<n;k++){
    scanf("%s%s",str1,str2);
    x=strlen(str1);
    y=strlen(str2);
    for(i=-1;i<x;i++){
      for(j=-1;j<y;j++){
	if(i==-1||j==-1)
	A[i+1][j+1]=0;
	else{
	  if(str1[i]==str2[j])
	    A[i+1][j+1]=A[i][j]+1;
	  else{
	    if(A[i][j+1]>A[i+1][j])
	      A[i+1][j+1]=A[i][j+1];
	    else
	      A[i+1][j+1]=A[i+1][j];
	  }
	}
      }
    }
    printf("%d\n",A[x][y]);
  }


  return 0;
}



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

int main(){
	int n, x, t;
  	cin >> n >> x >> t;
  
   	int ans = 0;
  	while(n > 0){
    	n -= x;
      	ans += t;
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
M=a.index(max(a))
m=a.index(min(a))
if max(a)>=-min(a):
	r=max(a)
	for i in range(n):
		a[i]+=r
	print(n*2-2)
	for i in range(n):
		if i!=M:
			print(M+1,i+1)
	for i in range(n-1):
		print(i+1,i+2)
else:
	print(n*2-2)
	r=min(a)
	for i in range(n):
		a[i]+=r
	for i in range(n):
		if i!=m:
			print(m+1,i+1)
	for i in range(n-1):
		print(n-i,n-i-1)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int p = 0;
		sc.nextLine();
		for(int i=0;i<n;i++){
			String s = sc.nextLine();
			StringBuffer sb = new StringBuffer();
			for(int j=0;j<26;j++){
				if(j%2==1 && j!=13){
					for(int k=0;k<26;k++){
						for(int t=0;t<s.length();t++){
							p = s.codePointAt(t) - 97;
							if(p==-65){
								sb.append(" ");
							}else{
								sb.append((char)((j*p+k)%26+97));
							}
						}
						if(sb.indexOf("that")!=-1 || sb.indexOf("this")!=-1){
							System.out.println(sb);
							k=26;
							j=26;
						}else{
							sb.delete(0, s.length());
						}
					}
				}
			}
		}
		
	}	
}

Measured memory_bytes: 21616
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

ll combi(ll n, ll k)
{
	if (k >= n || k <= 0)
		return 1;
	ll r = 1;
	for (ll i = 1; i <= k; i++, n--)
		r *= n, r /= i;
	return r;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	ll h, n;
	cin >> h >> n;
	ll s = 0;
	for (ll i = 0; i < n; i++)
	{
		ll in;
		cin >> in;
		s += in;
	}

	if (s >= h)
		printf("Yes");
	else
		printf("No");


	return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

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

    int k;
    cin >> k;

    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    vector<int> sum;
    for (int i = 0; i < n; i++) {
        int sm = 0;
        for (int j = i; j < n; j++) {
            sm += v[j];
            sum.push_back(sm);
        }
    }
    int ans = 0;
    for (int i = 60; i >= 0; i--) {
        int tp = ans | (1ll << i), ct = 0;
        for (auto x: sum) if ((x & tp) == tp)ct++;
        if (ct >= k)ans = tp;
    }
    cout << ans << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 6384
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
const int MaxN=200050;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
int n,k;
int a[MaxN];
inline bool check(double lim)
{
	reg int cnt=0;
	for(int i=1;i<=n;++i)
		cnt+=(int)ceil(a[i]/lim)-1;
	return cnt<=k;
}
signed main(void)
{
	cin>>n>>k;
	reg double maxi=0.0;
	for(int i=1;i<=n;++i)
		read(a[i]),maxi=max(maxi,(double)a[i]);
	reg double l=0.0,r=maxi,mid,ans=maxi;
	while(r-l>1e-6)
	{
		mid=(l+r)/2.0;
		if(check(mid))
			ans=mid,r=mid;
		else
			l=mid;
	}
	printf("%d\n",(int)ceil(ans));
	return 0;
}




Measured memory_bytes: 4440
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const ll limit = (ll) 1e18;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	ll res = 1;
	ll A[n];
	for (int i = 0; i < n; i++) cin >> A[i];
	for (int i = 0; i < n; i++) {
		if (A[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		ll a = A[i];
		if (res <= limit / a) {
			res *= a;
		} else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << res << endl;
}



Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
typedef long long ll;
ll a[maxn];
map<ll,int> mp;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,k;cin>>n>>k;
    rep(i,1,n) {cin>>a[i];a[i]+=a[i-1];}
    rep(i,1,n){a[i]=(a[i]-(ll)i+k)%k;}
    ll ans=0;
    
    rep(j,0,n){//a[0]=0
        if(j>=k)mp[a[j-k]]--;
        if(mp.count(a[j]))ans+=mp[a[j]];
        mp[a[j]]++;
    }
    cout<<ans<<endl;
}
/* 
1 2
1

5 4
1 4 2 3 5

求# str S: sum(S) mod k == len(S)
sum[j]-sum[i] mod k == j - i
sum[j]-j== sum[i]-i  j-i<k

trick

partial_sum(begin(a), end(a), begin(a));
 */

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
if (a*b>c*d)
{
    cout<<a*b<<endl;
}
else
{
    cout<<c*d<<endl;
}

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define STRING_LIMIT 100
#define SCORE_WIN 3
#define SCORE_DRAW 1

void InputNumber(int* number, int limitLow, int limitHigh);
void InputString(char* str);
int ArraySize(char* arr, char specific);
int StringComparing(char* str1, char* str2);
char* StringTocken(char* str, char* delimeter);
int equals(char ch, char* specific);


int main (void) {
	int n;
	int idx;
	int player1 = 0;
	int player2 = 0;
	char delimeter[] = { ' ', '\0' };
	char** input;

	InputNumber(&n, 1, 1000);

	input = (char**)malloc(sizeof(char*) * n);
	for (idx = 0; idx < n; idx++) {
		char buf[100];
		InputString(buf);

		int tmpSize = ArraySize(buf, '\0');
		*(input + idx) = (char*)malloc(sizeof(char) * (tmpSize + 1));
		memcpy(*(input + idx), buf, tmpSize + 1);
	}

	for (idx = 0; idx < n; idx++) {
		char* p1 = StringTocken(*(input + idx), delimeter);
		char* p2 = StringTocken(NULL, delimeter);

		int res = StringComparing(p1, p2);
		if (res < 0) {
			player2 += SCORE_WIN;
		} else
		if (res == 0) {
			player1 += SCORE_DRAW;
			player2 += SCORE_DRAW;
		} else {
			player1 += SCORE_WIN;
		}

		free(p1);
		free(p2);
	}

	printf("%d %d\n", player1, player2);

	for (idx = 0; idx < n; idx++) {
		free(*(input + idx));
	}
	free(input);
}

void InputNumber(int* number, int limitLow, int limitHigh) {
	int x;
	do {
		scanf("%d", &x);
	} while (x < limitLow || x > limitHigh);
	*number = x;
}

void InputString(char* str) {
	do {
		scanf(" %[^\n]s", str);
	} while (0);
}

int ArraySize(char* arr, char specific) {
	int size;
	for (size = 0; *(arr + size) != specific; size++);
	return size;
}

int StringComparing(char* str1, char* str2) {
	return strcmp(str1, str2);
}

char* StringTocken(char* str, char* delimeter) {
	static char* tmpString = 0;
	static int pivot = 0;

	int saving;
	int idx;
	int resIdx;
	char* res;

	int mSize;

	if (str != NULL) {
		int size = ArraySize(str, '\0') + 1;
		if (tmpString != 0) {
			free(tmpString);
		}
		tmpString = (char*)malloc(sizeof(char) * size);
		memcpy(tmpString, str, size);
		pivot = 0;
	} else {
		pivot++; //　以前のdelimeter削除
	}

	saving = pivot;
	resIdx = 0;
	mSize = 0;

	for (; !equals(*(tmpString + pivot), delimeter); pivot++, mSize++);

	res = (char*)malloc(sizeof(char) * (mSize + 1));
	for (idx = saving; idx < pivot; idx++) {
		*(res + resIdx++) = *(tmpString + idx);
	}
	*(res + resIdx) = '\0';

	return res;
}

int equals(char ch, char* specific) {
	int idx;
	int resFlag = 0;
	int size = ArraySize(specific, '\0');

	for (idx = 0; idx < size + 1; idx++) {
		char tmp = *(specific + idx);
		if (ch == tmp) {
			resFlag = 1;
			break;
		}
	}

	return resFlag;
}


Measured memory_bytes: 2048
import math 

N, P = map(int, input().split(" "))

def factorize(n):
    fct = list()
    base, exp = 2, 0
    while base * base <= n:
        while n % base == 0:
            n = n // base
            exp = exp + 1

        if exp > 0:
            fct.append((base, exp))

        base, exp = base + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

fs = sorted(factorize(P), reverse=True)


ans = 1
for f in fs:
	if f[1] >= N:
		a = f[1] // N
		ans *= f[0] ** a

print(ans)

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main()
{
  int H;
  int W;
  int i;
  int j;
  
  while(1)
  {
    cin >> H >> W;
    
    if(H==0 && W==0)
      goto EXIT;
    
    for(i=0;i<H;i++)
    {
      for(j=0;j<W;j++)
      {
        if(i==0 || i==(H-1) ||j==0 || j==(W-1))
          cout << "#";
        else
          cout << ".";
      }
      cout <<"\n";
    }
  
  cout << "\n";
  }
  EXIT:;
}

Measured memory_bytes: 1120
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b){if (b == 0) return a;return gcd(b, a % b);}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main(){
    int N, ans, p, q;
    cin >> N;
    vector<int> P(N), Q(N);
    for(int i = 0; i < N; ++i) cin >> P[i];
    for(int i = 0; i < N; ++i) cin >> Q[i];

    vector<int> ind(N);
    iota(ind.begin(), ind.end(), 1);
    int cnt = 0;
    do{
        if(ind == P) p = cnt;
        if(ind == Q) q = cnt;
        cnt++;
    } while (next_permutation(ind.begin(), ind.end()));
    ans = abs(q - p);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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



Measured memory_bytes: 3212