akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
 
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef complex<double> P;
typedef complex<double> Vec;
typedef pair<int, int> pii;
typedef pair<int, pii> p;
 
#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
const ll MOD = 1000000007ll;

int n, ma, mb;
int a[40], b[40], c[40];

int main() {
	cin >> n >> ma >> mb;
	REP(i, n) scanf("%d %d %d", a + i, b + i, c + i);
	
	int ans = INF;
	
	vector<pii> sa;
	REP(i, 1 << (n / 2)) {
		int suma = 0, sumb = 0, sumc = 0;
		REP(j, n / 2) if (i >> j & 1) {
			suma += a[j];
			sumb += b[j];
			sumc += c[j];
		}
		int diff = sumb * ma - suma * mb;
		if (sumc > 0 && diff == 0) chmin(ans, sumc);
		
		sa.push_back(pii(diff, sumc));
	}
	sort(ALL(sa));
		
	REP(i, 1 << (n - n / 2)) {
		int suma = 0, sumb = 0, sumc = 0;
		REP(j, n - n / 2) if (i >> j & 1) {
			suma += a[j + n / 2];
			sumb += b[j + n / 2];
			sumc += c[j + n / 2];
		}
		int diff = sumb * ma - suma * mb;
		
		vector<pii>::iterator it = lower_bound(ALL(sa), pii(-diff, 0));
		if (it == sa.end()) continue;
		if (it->first != -diff || it->second + sumc == 0) continue;
		
		chmin(ans, it->second + sumc);
	}
	if (ans == INF) ans = -1;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8556
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
       #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=3e5+9;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}


int32_t main()
{
    int n=in(),m=in(),r=in(),c=in();
    vector<string> ans(n,string(m,'0'));
    for(int i=0;i<n-c;i++){
        for(int j=0;j<m;j++) ans[i][j]=(j<r?'0':'1');
    }
    for(int i=n-c;i<n;i++){
        for(int j=0;j<m;j++) ans[i][j]=(j<r?'1':'0');
    }
    for(int i=0;i<n;i++) puts(ans[i].c_str());
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1



Measured memory_bytes: 2304
N, K, S = map(int, input().split())
if S == 10 ** 9:
    ans = [10 ** 9] * K
    ans.extend([1] * (N - K))
else:
    ans = [S] * K
    ans.extend([S + 1] * (N - K))
print(' '.join([str(x) for x in ans]))

Measured memory_bytes: 57292
import numpy as np
n,m = map(int,input().split())
h = list(map(int,input().split()))

base = np.ones(n)

for i in range(m):
  a,b =  map(int,input().split())
  if h[a-1] > h[b-1]:
    base[b-1] = 0
  elif h[a-1] < h[b-1]:
    base[a-1] = 0
  elif h[a-1] == h[b-1]:
    base[a-1] = 0
    base[b-1] = 0
    
print(int(np.sum(base)))

Measured memory_bytes: 38468
#include<stdio.h>
#include<math.h>
  
int main(){
  int s[1000];
  int n,i;
  double a,m,z;
  
  while(1){
    scanf("%d",&n);
    if(!n)
      return 0;
  
    m=0;
    for(i=0;i<n;i++){
      scanf("%d",&s[i]);
      m+=s[i];
    }
  
    m=m/n;
    z=0;
    for(i=0;i<n;i++)
      z+=(s[i]-m)*(s[i]-m);
  
    a=sqrt(z/n);
    printf("%lf\n",a);
  }
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;
const int nmax=112345;

int dp[3012],mpos,tmp;
char s[3012],t[3012];
vector<vector<int> > v1(3012);

int main()
{
    scanf("%s",s+1);
    scanf("%s",t+1);
    int tmax=strlen(t+1)+1;
    for(int i=1; s[i]!=0; ++i)
    {
        tmp=mpos=0;
        for(int j=tmax-1; j>0; --j)
        {
            if(tmp!=0 && dp[j]>dp[mpos])
                mpos=j;
            if(t[j]==s[i])
            {
                if(tmp!=0 && dp[tmp]<=dp[mpos])
                {
                    dp[tmp]=dp[mpos]+1;
                    v1[tmp]=v1[mpos];
                    v1[tmp].pb(tmp);
                }
                tmp=j;
                mpos=0;
            }
        }
        if(tmp!=0 && dp[tmp]<=dp[mpos])
        {
            dp[tmp]=dp[mpos]+1;
            v1[tmp]=v1[mpos];
            v1[tmp].pb(tmp);
        }
    }
    mpos=0;
    for(int j=1; j<tmax; ++j)
        if(dp[j]>dp[mpos])
            mpos=j;
    for(int j=0;j<v1[mpos].size();++j)
            printf("%c",t[v1[mpos][j]]);
    return 0;
}


Measured memory_bytes: 26112
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

d = {'r': p, 's': r, 'p': s}

point = 0
for i in range(k):
    point += d[t[i]]

for i in range(k, n):
    if t[i] == t[i - k]:
        t[i] = 'x'
        continue
    point += d[t[i]]

print(point)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;

int n, m;
VVI g;
map<pair<int, int>, int> edge;

void wf() {
    REP(k,n) {
        REP(i,n) {
            REP(j,n) {
                MIN(g[i][j], g[i][k] + g[j][k]);
                g[j][i] = g[i][j];
            }
        }
    }
}

int main()
{
    cin>>n>>m;
    g.resize(n, VI(n, INF));
    REP(i,m) {
        int a, b, c;
        cin>>a>>b>>c;
        a--; b--;
        g[a][b] = c;
        g[b][a] = c;
        if (a > b) swap(a,b);
        edge[make_pair(a,b)] = c;
    }
    REP(i,n) g[i][i] = 0;

    wf();

    int cnt = m;
    REP(i,n) {
        REP(j,n) {
            REPITR(itr,edge) {
                if (g[i][j] == g[i][itr->e1.e1] + itr->e2 + g[itr->e1.e2][j]) {
                    //cout<<i<<" "<<j<<" "<<itr->e1.e1<<" "<<itr->e1.e2<<" "<<g[i][j]<<" "<<g[i][itr->e1.e1] + edge[itr->e1] + g[itr->e1.e2][j]<<endl;
                    auto tmp = itr;
                    itr--;
                    edge.erase(tmp);
                    cnt--;
                }
            }
        }

        if (edge.empty())
            break;
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int k,a,b;
	scan(k>>a>>b);
	int flag=0;
	for(int i=a;i<=b;i++){
		if(i%k==0) flag=1;
	}
	if(flag) prin("OK");
	else prin("NG");
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    double r,s,l;
    cin >>r;
    s=3.141592653589*r*r;
    l=3.141592653589*2*r;
    cout << fixed << setprecision(7);
    cout << s << " " << l << endl;
}



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

using namespace std;
 
 


//c++ templte for help............................................................................................................................................



typedef long long ll;

template<typename... T>
void print1(T... t){
	((cout<<t<<" "),...);
}

template<typename... T>
void print2(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			if(i!=0) cout<<"\t\t";
			else cout<<"\t";
			for(ll j=0;j<(ll)ans[i].size();j++){
				cout<<ans[i][j]<<" ";
			}
			if(i!=(ll)ans.size()-1)
			cout<<endl;
		}
}	
#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;


 
//c++ template for help...........................................................................................................................................


ll  solve(){
	ll n;
	cin>>n;
	
	vector<ll> vec(n);
	for(int i=0;i<n;i++) cin>>vec[i];
	
	ll ans=0;
	for(int i=1;i<n;i++){
		//deb(vec[i],vec[i-1]);
		if(vec[i]<vec[i-1]){
			ans+=vec[i-1]-vec[i];
			vec[i]=vec[i-1];
		}
		//deb(ans);
	}
	
	return ans;
	
}

int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ofstream myfile;
	//myfile.open("output.txt");
	

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		//solve();
		ll ans=solve();
		cout<<ans<<endl;
	//}
	//myfile.close();
	return 0;
}


Measured memory_bytes: 4780
#include <iostream>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.length(); i++) {
    if (int(s[i]) + n > 90) {
      s[i] = char(int(s[i]) + n - 90 + 64);
    } else {
      s[i] = char((int(s[i]) + n));
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define N 1000;
using namespace std;
int numcheck(int A, int B, int C);

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B + C == 17)
    {
        if(numcheck(A,B,C) == 1){
            cout << "YES";
        }
    }else{
        cout << "NO";
    }
}

int numcheck(int A, int B, int C)
{
    if (A == 7 && B == 5 && C == 5)
    {
        return 1;
    }
    if (A == 5 && B == 7 && C == 5)
    {
        return 1;
    }

    if (A == 5 && B == 5 && C == 7)
    {
        return 1;
    }

    return 0;
}


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

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

const ll mod=1e9+7;
const ll inf=1ll<<60;

/*---------------------*/

ll n,a,ans[100009];
vector<pair<ll,ll>>p;

int main(){
    cin>>n;
    rep(i,n){
        cin>>a;
        p.push_back({a,i});
    }
    sort(p.begin(),p.end(),greater<pair<ll,ll>>());
    ll mn=1e9;
    rep(i,n){
        chmin(mn,p[i].second);
        ans[mn]+=(i==n-1?p[i].first:p[i].first-p[i+1].first)*(i+1);
    }
    rep(i,n)cout<<ans[i]<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  vector<char> vec;
  string s;
  cin >> s;
  rep(i, s.size()) {
    vec.push_back(s[i]);
  }
  int n;
  cin >> n;
  // true 元
  // false 逆
  bool f = true;
  int F;
  char c;
  rep(i, n) {
    int num;
    cin >> num;
    if (num == 1) {
      f = !f;
    } else {
      cin >> F >> c;
      if ((f and (F == 1)) or ((not f) and F == 2)) {
        vec.insert(vec.begin(), c);
      } else {
        vec.push_back(c);
      }
    }
  }
  if (f) {
    rep(i, vec.size()) {
      cout << vec[i];
    }
  } else {
    for (int i = vec.size() - 1; i >= 0; --i) {
      cout << vec[i];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1144
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int array[] = new int[3];
        array[0] = sc.nextInt();
        array[1] = sc.nextInt();
        array[2] = sc.nextInt();
        
        if(array[0]>array[1]){
            int temp = array[0];
            array[0] = array[1];
            array[1] = temp;
        }
        if(array[1]>array[2]){
            int temp = array[1];
            array[1] = array[2];
            array[2] = temp;
        }
        if(array[0]>array[1]){
            int temp = array[0];
            array[0] = array[1];
            array[1] = temp;
        }
        
        
        
        System.out.println(array[0]+" "+array[1]+" "+array[2]);
    }
    
}



Measured memory_bytes: 26096
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int main(){


int W,H,x,y,r;

cin>>W>>H>>x>>y>>r;

if(x==0||y==0||x==W||y==H){
  cout<<"No"<<endl;
  return 0;
}
else if(x+r>W || x-r<0){
  cout<<"No"<<endl;
  return 0;
}
else if(y+r>H || y-r<0){
  cout<<"No"<<endl;
  return 0;
}
else cout<<"Yes"<<endl;

return 0;

}

Measured memory_bytes: 1156
from operator import itemgetter

N = int(input())

restaurnats = []
for i in range(N):
    name, points = input().split()
    restraunt = [name, int(points), i+1]   
    restaurnats.append(restraunt)

restaurnats = sorted(restaurnats, key=itemgetter(1), reverse=True)
restaurnats = sorted(restaurnats, key=itemgetter(0))
for i in restaurnats:
    print(i[2])

Measured memory_bytes: 3060
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};


int main(int argc, char const *argv[]) {
  int n;
  double sum=0.000;
  std::cin >> n;
  double x[20];
  string u[20];
  for(int i=0; i<n; i++){
    std::cin >> x[i] >> u[i];
  }

  for(int i=0; i<n; i++){
    if(u[i]=="JPY") sum+=x[i];
    else sum+=380000.0*x[i];
  }
  printf("%f10",sum);

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
using LL = long long;
using ULL = unsigned long long;
#define NUM 1000000007

using namespace std;

int main()
{
    ULL ans = 1;
    int n;
    cin >> n;
    for (size_t i = 1; i <= n; i++)
    {
        ans *= i;
        ans %= NUM;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int r = 0;
            int b = 0;
            for(int i=0; i < s.Length; i++)
            {
                if (s[i] == '0') r++;
                else b++;
            }
            Console.WriteLine(2 * (int)Math.Min(r, b));
        }
    }
}


Measured memory_bytes: 26232
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int> > Matrix;
const int MOD = 1e9+7;


int main(){
 string s; cin>>s;
 int n=s.size();
 int res=0;
 if(n%2==0){
 REP(i,n/2){
     if(s[i]!=s[n-1-i])res++;
 }
 }
 else{
     REP(i,(n-1)/2)if(s[i]!=s[n-1-i])res++;
 }

cout<<res<<endl;
}


Measured memory_bytes: 384
n = gets.to_i
hash = {}
for i in 1..n
  s = gets.chomp.split("").sort.join
  if hash[s]
    hash[s] += 1
  else
    hash[s] = 1
  end
end

ctn = 0
hash.values.each do |v|
  ctn += v * (v - 1) / (1 * 2)
end

puts ctn

Measured memory_bytes: 19324
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mxn 100005
#define mp make_pair
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long int ll;
int main(){
	int n,k; cin>>n>>k;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	int dp[n+1];
	dp[0]  = 0;
	dp[1]  = abs(arr[1] - arr[0]);
	for(int i=2; i<n; i++){
		dp[i] = dp[i-1]  + abs(arr[i] - arr[i-1]);
		for(int j=2; j<=k; j++){
			if(i-j<0) break;
			dp[i] = min(dp[i] , dp[i-j] + abs(arr[i] - arr[i-j]));
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> cp(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        cp[i] = a[i];
    }
    sort(a.begin(),a.end());
    int mx;
    int sx;
    mx = a[n-1];
    sx = a[n-2];
    for(int i=0; i<n; i++){
        if(cp[i]==mx){
            cout << sx << endl;
        }else{
            cout << mx << endl;
        }
    }
    return 0;
}




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

int countDivisors(int n)
{
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {

            if (n / i == i)
                cnt++;

            else // Otherwise count both
                cnt = cnt + 2;
        }
    }
    return cnt;
}
int main()
{
  int n,ans=0;
  cin>>n;

  for(int c=1;c<n;c++)
  {
      int k=countDivisors(n-c);
      ans+=k;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
long long int val[200];
long long int wei[200];
long long int dp[200005];

int main(){
	
	int n,w;
	cin>>n>>w;
	
	for(int i=1;i<=n;i++){
		cin>>wei[i]>>val[i];
	}
	memset(dp,-1,sizeof dp);
	dp[0]=0;
	long long int cvp=0;
	for(int i=1;i<=n;i++){
		for(int j=w;j>=0;j--){
			if(dp[j]==-1)continue;
			dp[j+wei[i]]=max(dp[j+wei[i]],+dp[j]+val[i]);
		}
	}
	for(int i=0;i<=w;i++){
	//	cout<<"dp["<<i<<"]="<<dp[i]<<"\n";
		cvp=max(dp[i],cvp);
	}
	cout<<cvp;
	
	return 0;
}

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

#define ll long long

const ll MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> arr(N);
    ll sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> arr[i];
        sum += arr[i];
        sum %= MOD;
    }

    ll ans = 0;
    for(int i = 0; i < N; i++) {
        sum -= arr[i];
        if(sum < 0) sum += MOD;
        ans += arr[i] * sum;
        ans %= MOD;
    }
    cout << ans;
}

Measured memory_bytes: 4828
#include <iostream>

using namespace std;

int main()
{
    int N, D, X, A[105], ans = 0;
    cin >> N;
    cin >> D >> X;
    for (int i = 1; i <= N; i++)
        cin >> A[i];
    for (int i = 1; i <= N; i++){
        int nr = 1;
        int x = 1 + A[i];
        while (x <= D){
            nr++;
            x += A[i];
        }
        ans += nr;
    }
    cout << ans + X;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k;
	cin>>n>>k;
	vl h(n);
	ll sum=0;
	for(ll i=0;i<n;i++){
		cin>>h[i];
		sum+=h[i];
	}
	sort(all(h));
	for(ll i=n-1;i>=0;i--){
		if(k==0)
			break;
		sum-=h[i];
		k--;
	}
	cout<<sum<<"\n";
}

Measured memory_bytes: 4752
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 200000;

ll n;
ll x[MAX_N];

int main(){
  cin >> n;
  REP(i, n) cin >> x[i];
  ll y[n];
  REP(i, n) y[i] = x[i];
  sort(y, y + n);
  REP(i, n) {
    if(x[i] < y[n / 2]) cout << y[n / 2] << endl;
    else cout << y[n / 2 - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  string O, E;
  cin >> O >> E;

  int N = O.length();
  int M = E.length();
  if (N == M){
    for (int i = 0; i < N; i++){
      cout << O[i] << E[i];
    }
  }else{
    for (int i = 0; i < N - 1; i++){
      cout << O[i] << E[i];
    }
    cout << O[N - 1] << endl;
  }
}


Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
ll a[100005];
ll b[100005];
ll c[100005];
ll memoa[100005];
ll memob[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) {
    cin >> a[i];
  }
  REP(i, n) {
    cin >> b[i];
  }
  REP(i, n) {
    cin >> c[i];
  }

  sort(a, a + n);
  sort(b, b + n);
  sort(c, c + n);

  fill(memoa, memoa + n, 0);
  fill(memob, memob + n, 0);
  REP(i, n) {
    ll *cc = upper_bound(c, c + n, b[i]);
    memob[i] = (c + n - cc);
  }

  ll sum = 0;
  RREP(i, n) {
    sum += memob[i];
    memoa[i] = sum;
  }

  ll ans = 0;
  REP(i, n) {
    ll *bb = upper_bound(b, b + n, a[i]);
    ans += memoa[bb - b];
  }

  cout << ans << endl;
}


Measured memory_bytes: 4224
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const int mod = ((int)1e9 + 7);
// loop
#define rep(i, n) for(int i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(int i = b; i < e; i++)
#define erep(i, b, e) for(int i = b; i <= e; i++)
#define rrep(i, b, e) for(int i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
// function
int gcd(int a, int b){return b ? gcd(b, a % b) : a;}
void prime(vint& v, int n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}

signed main(){
    int x, a;
    cin >> x >> a;
    cout << ((x < a) ? 0 : 10) << endl;
	
	return 0;
}

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

int main(){

const int MAX_NO=100000;
int m[MAX_NO],f[MAX_NO],r[MAX_NO];
char hyouka[MAX_NO];
int a=0;

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

cin>>m[i]>>f[i]>>r[i];

a++;

if(m[i]==-1 && f[i]==-1 && r[i]==-1){
goto aa;
}

if(m[i]==-1 || f[i]==-1){
hyouka[i]='F';
}

else if((m[i]+f[i])>=80){
hyouka[i]='A';
}
else if((m[i]+f[i])>=65){
hyouka[i]='B';
}

else if((m[i]+f[i])>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])>=30 && r[i]<50){
hyouka[i]='D';
}
else if((m[i]+f[i])>=30 && r[i]>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])<30){
hyouka[i]='F';
}

}

aa:;

long long MX = 20000000;

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

for(int j=1;j <= MX; j++)
{
for(int k = 1; k <= MX; k++) {}
}

cout<<hyouka[i]<<endl;

}

return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    int a, b, k;
    int cnt = 0;
    cin >> a >> b >> k;
    //REP1(i, min(a, b)) {
    for(int i = min(a, b); i >= 1; i--) {
        if(a % i == 0 && b % i == 0) {
            cnt ++;
            if(cnt == k) {
                cout << i << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bitset>
using namespace std;
int main(){
	int N, A[2010]; 
	cin >> N;
	int S = 0; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; S += A[i]; 
	}
	bitset<4000010> B; 
	B.reset();
	B.set(0, 1); 
	for(int i = 0; i < N; i++){
		B |= (B << A[i]); 
	}
	for(int i = (S+1)/2; i <= S; i++){
		if(B.test(i)){
			cout << i << endl; return 0; 
		}
	}
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*(._.)*/
int main(){
	int A,B; cin >> A >> B;
	int ans = A + B;
	chmax(ans,A-B);
	chmax(ans,A*B);
	cout << ans << endl;
}


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

int main() {
  int N; cin >> N;
  string S; cin >> S;

  int ans = 0;
  string tmp;
  for (int i=0; i<S.length()-2; i++) {
    tmp = S[i];
    tmp += S[i+1];
    tmp += S[i+2];
    if (tmp == "ABC") ans++;
//    cout << tmp << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
    Author: Shivam Shukla
    Title : DP_F_StringAnswer.cpp
    Date : 26/08/2020   >> 00:27:45
*/

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
#define INF(x) numeric_limits<x>::max()
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
    fastio();
    auto tstart= clock();
 
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      freopen("error.txt","w",stderr);
    #endif   

    str s, t; cin >> s >> t;
    int n = sz(s), m = sz(t);

    vc(vl) dp(n + 1, vl(m + 1, 0));
    rep(i, 1, n + 1) {
        rep(j, 1, m + 1) {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            else 
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);    
        }
    }
    

    int i = n, j = m;
    str ans = "";

    while (i > 0 && j > 0) {
        if (s[i - 1] == t[j - 1]) 
            ans += s[i - 1], i--, j--;    
        else if (dp[i - 1][j] > dp[i][j - 1])
            i--;
        else
            j--;        
    }
    reverse(all(ans));
    cout << ans << endl;

    cerr << setprecision(2) << fixed<<"Time elapsed: " << (double)(clock() - tstart)/CLOCKS_PER_SEC << endl; 
    return 0; 
}

Measured memory_bytes: 73648
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int a, b;

    cin >> a >> b;

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible";
    } else {
        cout << "Impossible";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
use strict;
use warnings;
use utf8;

my ($N) = split /\s/, <STDIN>;
my (@H) = split /\s/, <STDIN>;

my $cnt = 1;
for (my $i = 1; $i < @H; $i++) {
    my $flag = 1;
    for (my $j = 0; $j < $i; $j++) {
        if ($H[$j] <= $H[$i]) {
        } else {
            $flag = 0;
        }
    }
    if ($flag) {
        $cnt++;
    }
}

printf "%s\n", $cnt;


Measured memory_bytes: 640
/*input
3
-10 5 -4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int a[maxn];
int meow[maxn];
int main(){
	IOS;
	int n;
	cin>>n;
	bool flag=0;
	REP(i,n){
		cin>>a[i];
		if(a[i]<0) flag=!flag,a[i]=-a[i];
	}
	sort(a,a+n);

	if(flag) a[0]=-a[0];
	ll ans=0;
	REP(i,n) ans+=a[i];
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main () {
    int N, K;
    scanf("%d %d",&N,&K);
    int a[N+1];
	for (int i=1; i<=N; i++) {
        scanf("%d", &a[i]);
    }
    for (int i=K+1; i<=N; i++) {
        if ( a[i] > a[i-K]) {
            printf("Yes\n");
        } else {
        	printf("No\n");
        }
    }
    return 0;
}

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

int digits(int number){
   int digit = 0;
   while(number!=0){
      number = number / 10;
      ++digit;
   }
   return digit;
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1;i<=N;i++){
        if(digits(i)%2 == 1){
            ans++;
        }
    }

    cout << ans << endl;   
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = 0;
        int ans = 0;
        int a = Integer.parseInt(sc.next());
        String[] ary = sc.next().split("");
        for(int i = 0; i < a; i++)
        {
            if("I".equals(ary[i])) x++;
            else if("D".equals(ary[i])) x--;
            if(ans < x) ans = x;
        }
        System.out.println(ans);      
    }
}

Measured memory_bytes: 21716
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)
}

func main() {
	n := scanInt()
	type music struct {
		s string
		t int
	}
	ms := make([]music, n)
	for i := range ms {
		ms[i].s, ms[i].t = scanString(), scanInt()
	}
	x := scanString()

	isSleep := false
	ans := 0
	for _, m := range ms {
		if m.s == x {
			isSleep = true
			continue
		}

		if isSleep {
			ans += m.t
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main() {
	double ax, ay, bx, by, xx, yy;
	double a, b, c, s=0.0, z;
	fscanf(stdin, "%lf,%lf", &ax, &ay);
	fscanf(stdin, "%lf,%lf", &bx, &by);
	while (~fscanf(stdin, "%lf,%lf", &xx, &yy)) {
		a = sqrt(pow(bx - xx, 2) + pow(by - yy, 2));
		b = sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
		c = sqrt(pow(ax - xx, 2) + pow(ay - yy, 2));
		z = (a + b + c) / 2.0;
		s += sqrt(z*(z - a)*(z - b)*(z - c));
		bx = xx, by = yy;
	}
	fprintf(stdout, "%lf\n", s);
	return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }


int main() {
  long long n, k; cin>>n>>k;
  vector<long long> a(n);
  rep(i, n) cin>>a[i];
  sort(a.begin(), a.end());

  long long ok = LLINF, ng = 0;
  while (ng + 1 < ok) {
    long long mid = (ok + ng) / 2;
    long long cnt = 0;
    rep(i, n) {
      if (mid >= a[i]) continue;
      long long t = a[i] / mid;
      // if (a[i] % mid != 0) ++t;
      cnt += t;
    }
    // print(ok, ng, mid, cnt);
    if (cnt <= k) ok = mid;
    else ng = mid;
  }
  print(ok);

  return 0;
}

Measured memory_bytes: 4780
#include <iostream>

int main() {
    int N;
    std::cin >> N;
    if (N%1000 == 0) {
        std::cout << 0 << std::endl;
    } else {
        std::cout << (N + 1000) / 1000 * 1000 - N << std::endl;
    }
}


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

typedef long long ll;
typedef pair<int, int> pi;
constexpr int inf = 0x3f3f3f3f;
constexpr double EPS = 1e-30;
constexpr double PI = atan(1) * 4;

template <class T> inline void chmax(T& x, T y) {if (x < y) x = y;}
template <class T> inline void chmin(T& x, T y) {if (x > y) x = y;}
inline int LSB(int i) {return (i & -i);}

constexpr int maxn = 2e4+5;

int n, a[maxn];

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

    cin >> n;
    int i = 1;
    if (n == 3){
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }

    if (n & 1){
        n--;
        for (int c = 2; i <= n / 2 && c <= 30000; i += 2, c += 6) a[i] = c, a[i + 1] = c + 2;
        for (int c = 3; i <= n && c <= 29997; i++, c += 6) a[i] = c;
        for (int c = 6; i <= n + 1 && c <= 30000; i++, c += 6) a[i] = c;
        for (int i = 1; i <= n + 1; i++) cout << a[i] << " ";
    }
    else {
        for (int c = 2; i <= n / 2 && c + 2 <= 30000; i += 2, c += 6) a[i] = c, a[i + 1] = c + 2;
        for (int c = 3; i <= n && c <= 29997; i++, c += 6) a[i] = c;
        for (int c = 6; i <= n && c <= 30000; i++, c += 6) a[i] = c;
        for (int i = 1; i <= n; i++) cout << a[i] << " ";
    }

    /*
    ll s = accumulate(a + 1, a + n + 1, 0LL);
    for (int i = 1; i <= n; i++){
        //cout << a[i] << " " << s - a[i] << endl;
        if (__gcd(1LL * a[i], s - a[i]) == 1) cout << i << " " << s - a[i] << endl;
    }*/
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
typedef long long ll;

const int Maxd=1e5+7;
int a[Maxd];
int n,m,p,v;
bool check(int d)
{
	if(d>=n-p)return true;
	ll zan=(ll) m*(ll) (v-p);
	ll lim=a[d]+m;
	for(int i=0;i+p<=n;i++)
	{
		if(i==d)continue;
		ll c=min((ll) m,(ll) lim-a[i]);
		if(c<0)return false;
		zan-=c;
	}
	return zan<=0;
}

int main()
{
	cin>>n>>m>>v>>p;
	REP(i,n)cin>>a[i];
	sort(a,a+n);
	int l=-1,r=n;
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(check(mid))r=mid;
		else l=mid;
	 } 
	cout<<n-r<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(), greater<int>());
    
    if(s<t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
        
    }
    
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int H = input[0];
            int W = input[1];

            int[,] dp = new int[H, W];

            int maxWidth = 0;

            for (int i = 0; i < H; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                for (int j = 0; j < W; j++)
                {
                    dp[i, j] = input[j] == 0 ? 1 : 0;
                    maxWidth |= dp[i, j];
                }
            }

            for (int i = 1; i < H; i++)
            {
                for (int j = 1; j < W; j++)
                {
                    if (dp[i, j] != 0)
                    {
                        int temp = Math.Min(dp[i - 1, j], dp[i, j - 1]);
                        dp[i, j] = Math.Min(dp[i - 1, j - 1], temp) + 1;
                        maxWidth = Math.Max(maxWidth, dp[i, j]);
                    }
                }
            }

            Console.WriteLine(maxWidth * maxWidth);
        }
    }
}

Measured memory_bytes: 23308
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#define FOR(i, a, b) for (int i = a, i##_len = (b); i < i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS (1e-7)
#define INF (1e9)

using namespace std;

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

  int a[3];
  REP(i, 3) { cin >> a[i]; }
  sort(a, a + 3);
  int sum = 0;
  REP(i, 2) { sum += abs(a[i] - a[i + 1]); }
  cout << sum << endl;
}


Measured memory_bytes: 888
import sys
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    ans = 1000000000
    _n = int(input())
    a = list(map(int, input().rstrip().split()))
    for i in range(-100, 101):
        tmp = 0
        for v in a:
            tmp += pow((v - i), 2)
        ans = min(tmp, ans)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	int D, G; cin >> D >> G;
	int p[11];
	int c[11];
	for (int i = 0; i < D; ++i) {
		cin >> p[i] >> c[i];
	}
	int ans = INF;
	for (int bit = 0; bit < (1 << D); ++bit) {
		ll sum = 0;
		int cnt = 0;
		for (int i = 0; i < D; ++i) {
			if (bit&(1 << i)) {
				cnt += p[i];
				sum += p[i] * 100 * (i + 1);
				sum += c[i];
			}
		}
		if (sum >= G) {
			ans = min(ans, cnt);
		}
		else {
			bool key = true;
			for (int i = D - 1; i >= 0; --i) {
				if (bit&(1 << i))continue;
				for (int j = 0; j < p[i]; ++j) {
					sum += 100 * (i + 1);
					cnt++;
					if (sum >= G) {
						key = false;
						break;
					}
				}
				if (!key)break;
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    long long N, Q, A, K;
    std::cin >> N >> K >> Q;
    vector<long long> points(N, -Q);

    for(long long i = 0; i < Q; i++){
        std::cin >> A;
        points[A-1]++;
    }

    for(long long i = 0; i < N; i++){
        if(points[i] > -K){
            std::cout << "Yes\n";
        }else{
            std::cout << "No\n";
        }
    }

}

Measured memory_bytes: 4028
n = int(input())
a = list(map(int,input().split()))
count = 0
check = 0

for i in range(n):
    check += a[i]
    if i%2==0 and check <= 0:
        count += 1-check
        check =  1
    elif i%2==1 and check >= 0:
        count += 1+check
        check = -1
ans = count
count = 0
check = 0

for i in range(n):
    check += a[i]
    if i%2==0 and check >= 0:
        count += 1+check
        check = -1
    if i%2==1 and check <= 0:
        count += 1-check
        check = 1
print(ans if ans < count else count)

Measured memory_bytes: 14212