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

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

void solve() {

    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<bool> dp(k + 1, 0);

    // dp[i] = true if the frst player wins when i stones are remaining
    // note that a should be sorted(already sorted in question)

    for (int i = 0; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            if (a[j] <= i and dp[i - a[j]] == 0) {
                dp[i] = 1;
                break;
            }
        }
    }

    cout << (dp[k] == 1 ? "First" : "Second") << endl;

}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int n;
	cin>>n;
	ll work1=MAX,work2=0;
	rep(i,n){
		ll tmp;
		cin>>tmp;
		if(tmp < work1)work1=tmp;
		if(work2 < tmp)work2=tmp;
	}

	cout<<work2-work1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

int64_t cnt(int64_t x, int64_t d)
{
    if (x < 0) {
        return 0;
    } else {
        return x / d;
    }
}

int main()
{
    int t;
    cin >> t;
    rep(i, t)
    {
        int64_t a, b, c, d;
        cin >> a >> b >> c >> d;

        if (a < b || d < b) {
            cout << "No" << endl;
        } else if (c >= b) {
            cout << "Yes" << endl;
        } else {
            if (1 > b - c - 1) {
                cout << "Yes" << endl;
            } else if (1 <= (a - c) % b && (a - c) % b <= b - c - 1) {
                cout << "No" << endl;
            } else {
                int64_t g = gcd(b, d);
                if (g == b) {
                    cout << "Yes" << endl;
                } else {

                    int64_t l = (c - a % b + 1 + b) % b, r = (b - a % b - 1 + b) % b;

                    int64_t n;
                    if (l <= r) {
                        n = cnt(r, g) - cnt(l - 1, g);
                    } else {
                        n = cnt(b - 1, g) - cnt(l - 1, g) + cnt(r, g);
                    }
                    cout << (n > 0 ? "No" : "Yes") << endl;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int T,X;
   cin>>T>>X;
   double ans= (double)T/X;
   cout<<ans<<endl;
   
}

Measured memory_bytes: 3792
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>
#include<unordered_map>

using namespace std;
const double pi=acos(-1.0);
//memset ( a , 0 , n * sizeof(ll) ) ;

#define 	boost  		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // don't use if small inpts
#define 	endl 		'\n'
#define 	sl(n) 		scanf("%lld",&n)
#define		mp 			make_pair
#define 	pb 			push_back
#define 	ppb 		pop_back
#define 	fi 			first
#define 	se 			second
#define 	ll 			long long
#define 	ull 		unsigned long long
#define 	pii 		pair<int, int>
#define 	f(i,a,b) 	for(ll i = (ll)(a); i < (ll)(b); i++)
#define 	rf(i,a,b) 	for(ll i = (ll)(a); i > (ll)(b); i--)
#define 	ms(a,b) 	memset((a),(b),sizeof(a))
#define 	max(a,b) 	((a>b)?(a):(b))
#define 	min(a,b) 	((a<b)?(a):(b))
#define 	vec(g1) 	int temp;cin>>temp;g1,push_back(temp);
#define 	abs(x) 		((x<0)?(-(x)):(x))
#define 	MAX 		1000005
#define 	inf 		LLONG_MAX
#define 	MIN 		INT_MIN

//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}
////****************************************************************************************************************************************************************************************************************////
void print(int a[],ll sum,int idx,int time){
	 sum= sum-a[idx-1];
	 sum+=time;
	 cout<<sum<<endl;
}

int main(){
   int n;
   cin>>n;
   int t[n];
   ll sum=0;
   f(i,0,n){cin>>t[i]; sum+=t[i];}
   int m;
   cin>>m;
   while(m--){
   	 int idx,time;
   	 cin>>idx>>time;
   	   print(t,sum,idx,time);
   }

}

Measured memory_bytes: 256
import sys

board=[[0]*10 for i in xrange(10)]

large=[[0,0,1,0,0],
       [0,1,1,1,0],
       [1,1,1,1,1],
       [0,1,1,1,0],
       [0,0,1,0,0],]
middle=[[0,0,0,0,0],
        [0,1,1,1,0],
        [0,1,1,1,0],
        [0,1,1,1,0],
        [0,0,0,0,0],]
small=[[0,0,0,0,0],
       [0,0,1,0,0],
       [0,1,1,1,0],
       [0,0,1,0,0],
       [0,0,0,0,0],]

size=[0,small,middle,large]

def isOnBoard(y,x):
    return 0<=y<10 and 0<=x<10

for line in sys.stdin.readlines():
    x,y,s=map(int,line.strip().split(","))
    for i in xrange(-2,3):
        for j in xrange(-2,3):
            if isOnBoard(y+i,x+j):
                board[y+i][x+j]+=size[s][i+2][j+2]

a=[j for i in board for j in i]
print a.count(0)
print max(a)

Measured memory_bytes: 4276
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//  17:50-
//A 17:54 AC
//B 17:58 AC
//C 18:05 AC
//D 18:23 AC

/*

*/
bool solve(void){
	int n,i,j,k,s;cin>>n>>k>>s;
	if(n==0){return false;}
	vector<tuple<int,int,int>>zaa(n);
	for(i=0;i<n;i++){cin>>get<0>(zaa[i])>>get<1>(zaa[i])>>get<2>(zaa[i]);}
	if(k==1){cout<<s*s*6<<endl;return true;}
	vector<vector<int>>hen(n,vector<int>(n));
	vector<vector<int>>go(n);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			
			int xa,ya,za;tie(xa,ya,za)=zaa[i];
			int xb,yb,zb;tie(xb,yb,zb)=zaa[j];
			
			int xr=s-abs(xa-xb),yr=s-abs(ya-yb),zr=s-abs(za-zb);
			if(xr<0||yr<0||zr<0){continue;}
			hen[i][j]=(xr*yr+yr*zr+zr*xr)*2;
			hen[j][i]=(xr*yr+yr*zr+zr*xr)*2;
			go[i].pub(j);go[j].pub(i);
		}
	}
	int ans=mod;
	//線 か ドーナツ
	for(i=0;i<n;i++){
		for(auto sta:go[i]){
			int mae=i,now=sta,mta=2,gen=s*s*12-hen[i][sta];
			while(mta<k){
				if(go[now].size()<2){break;}
				int aa=now;
				now=go[now][0]+go[now][1]-mae;
				mae=aa;
				gen+=s*s*6-hen[now][mae];
				mta++;
			}
			if(mta<k){continue;}
			if(go[now].size()==2&&go[now][0]+go[now][1]-mae==i){gen-=hen[now][i];}
			mineq(ans,gen);
		}
	}
	if(ans==mod){ans=-1;}
	cout<<ans<<endl;
	return true;
}
int main(void){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 6864
import java.util.Scanner;
import java.util.*;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
    int[] plist = new int[n];
    int sum = 0;
    for(int i = 0; i < n; i++) {
		int p = scan.nextInt();
    plist[i] = p;
    }
    Arrays.sort(plist);
    for(int i = 0; i < k; i++) {
      sum += plist[i];
    }

      System.out.println(sum);
    }
}


Measured memory_bytes: 38856
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 1e5 + 5;
vector<pair<int,int>> w[nax];
long long sum[nax], answer[nax];
int subtree[nax];
int n;

void dfs(int a, int par) {
	subtree[a] = 1;
	for(pair<int,int> p : w[a]) {
		int b = p.first;
		if(b == par) continue;
		dfs(b, a);
		subtree[a] += subtree[b];
		int diff = abs((n - subtree[b]) - subtree[b]);
		if(diff)
			answer[p.second] = abs(sum[a] - sum[b]) / diff;
	}
}

long long two(int a, int par, long long so_far) {
	long long s = so_far;
	for(pair<int,int> p : w[a]) {
		int b = p.first;
		if(b == par) continue;
		s += two(b, a, so_far + answer[p.second]);
	}
	return s;
}

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n - 1; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		w[a].push_back({b, i});
		w[b].push_back({a, i});
	}
	for(int i = 1; i <= n; ++i)
		scanf("%lld", &sum[i]);
	dfs(1, -1);
	for(int i = 0; i < n - 1; ++i)
		if(answer[i] == 0)
			answer[i] = (sum[1] - two(1, -1, 0)) / (n / 2);
	for(int i = 0; i < n - 1; ++i) printf("%lld\n", answer[i]);
}


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

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using ml = map<ll,ll>;

#define ff first
#define ss second
#define endl '\n'
#define ins insert
#define eb emplace_back
#define sz(c) (ll) c.size()
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define itr(x,c) for(auto &x : c)
#define tc ll t; cin >> t; while(t--)
#define rep(i,a,n) for(ll i = a ; i < n ; ++i)
#define per(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) itr(x,c) cout << x << " "; cout << endl;
#define dm(m) itr(x,m) cout << x.ff << " -> " << x.ss << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);

int main() {
    godspeed;
    ll n; cin >> n;
    ll d; cin >> d;

    ll x, y, cnt = 0;
    while(n--) {
    	cin >> x >> y;
    	ld dis = sqrt(x*x + y*y);
    	if(dis <= d) cnt++;
    }

    cout << cnt;
}

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


void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = readln.split.map!(to!int).array;
    A[] -= 1;

    auto cnt = new int[][](M);
    foreach (i; 1..N) cnt[A[i]] ~= i; 

    auto imos = new long[](M * 2);
    foreach(i; 0..N-1) {
        if (A[i] <= A[i+1]) {
            imos[A[i] + 1] += 1;
            imos[A[i + 1] + 1] -= 1;
        } else {
            imos[A[i] + 1] += 1;
            imos[A[i + 1] + M + 1] -= 1;
        }
    }
    foreach (i; 0..2*M-1) imos[i+1] += imos[i];
    debug imos.writeln;

    long ans = 0;
    foreach (i; 0..N-1) {
        ans += min((A[i+1] + M - A[i]) % M, A[i+1] + 1);
    }

    long tmp = ans;
    debug tmp.writeln;
    foreach (x; 0..M-1) {
        foreach (i; cnt[x]) tmp += (A[i] + M - A[i-1]) % M;
        tmp -= imos[x] + imos[x+M];
        debug tmp.writeln;
        ans = min(ans, tmp);
    }

    ans.writeln;
}


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

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

    int l, r, sum = 0;
    for(int i = 0; i < N; i++){
        cin >> l >> r;
        sum += r - l + 1;
    }

    cout << sum << endl;
}


Measured memory_bytes: 3580
#include<cstdio>
#include<algorithm>
using namespace std;
const int INF=1e9+1;
const int maxn=100100;
struct node{
	int l,r;
}a[maxn];
bool cmp(const node &A,const node &B){
	return A.l<B.l;
}
void chkmax(int &x,int y){
	x=x>y?x:y;
}
int Max(int x,int y){
	return x>y?x:y;
}
int Min(int x,int y){
	return x<y?x:y;
}
int Len(int x,int y){
	return Max(y-x+1,0);
}
int Minr[maxn],Minl[maxn];
int main(){
//	freopen("B.in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].l,&a[i].r);
	int l1=0,l2=0,r1=INF,r2=INF;
	for(int i=1;i<=n;i++){
		if(a[i].l>=l1)
			l2=l1,l1=a[i].l;
		else if(a[i].l>=l2)
			l2=a[i].l;

		if(a[i].r<=r1)
			r2=r1,r1=a[i].r;
		else if(a[i].r<=r2)
			r2=a[i].r;
	}
	int ans=0,l,r;
	for(int i=1;i<=n;i++){
		if(a[i].l==l1) l=l2;
		else l=l1;
		if(a[i].r==r1) r=r2;
		else r=r1;
		chkmax(ans,Len(a[i].l,a[i].r)+Len(l,r));
	}
	sort(a+1,a+n+1,cmp);
	Minl[0]=INF;
	for(int i=1;i<=n;i++)
		Minl[i]=Min(Minl[i-1],a[i].r);
	Minr[n+1]=INF;
	for(int i=n;i>=1;i--)
		Minr[i]=Min(Minr[i+1],a[i].r);
	for(int i=1;i<n;i++)
		chkmax(ans,Len(a[i].l,Minl[i])+Len(a[n].l,Minr[i+1]));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,k;
    cin >> t;
    k=t;
    vector <int> side(t);
    int n;
    int p=0;
    while(k--)
    {
        cin>>side[p++];
    }
    sort(side.begin(),side.end(),greater<int>());
    int a=0,b=0,i,f=0;
    for(i=0;i<t-1;i++)
    {
        if(side[i]==side[i+1])
        {
            if(f==0){
                a=side[i];
                f++;
            }
            else if(f==1){
                b=side[i];
                f++;
            }
            i++;
        }
       // if(a>0 && b>0) break;
    }
    cout << a*1LL*b << endl;
}


Measured memory_bytes: 3676
import itertools

l = input().split(' ')

N = int(l[0])
M = int(l[1])

S = [[0 for i in range(N)]for j in range(N)]

for i in range(M):
    l = input().split(' ')
    a = int(l[0]) - 1
    b = int(l[1]) - 1 
    S[a][b] = 1
    S[b][a] = 1

seq = list(range(2,N+1))
lst = list(itertools.permutations(seq))

#print(lst)
def solve(lst):
    bef = 1
    for k in lst:
        if S[bef-1][k-1] == 1:
            bef = k
        else:
            return False

    return True


ans = 0
for list in lst:
    if solve(list):
        ans += 1

print(ans)





Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int n,ret;
int sum(int m){
	int r=0;while(m)r+=m%10,m/=10;return r;
}
int main(){
	cin>>n;ret=sum(n-1)+1;
	for(int i=1;i<n;i++)ret=min(ret,sum(i)+sum(n-i));
	cout<<ret<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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 (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

char s[11];

int main() {
  int n;
  while(cin>>n) {
    map<string, int> mp;
    REP(i,n) {
      scanf("%s", s);
      sort(s,s+strlen(s));
      mp[string(s)]++;
    }
    ll ans = 0;
    FOR(it, mp) {
      ll c = it->second;
      ans += c * (c - 1) / 2;
    }
    cout << ans << endl;
  }
}


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

constexpr int INF = 1e9;

int dp[110][110];

int main(){
  int n; cin >> n;
  int p[110];
  for( int i = 0; i < n; i++ ) cin >> p[i] >> p[i + 1];
  for( int i = 0; i < 110; i++ ){
    for( int j = 0; j < 110; j++ ){
      if( i != j ) dp[i][j] = INF;
    }
  }
  
  for( int l = 2; l <= n; l++ ){
    for( int i = 0; i < n - l + 1; i++ ){
      int j = l + i - 1;
      for( int k = i; k < j; k++ ){
	dp[i][j] = min( dp[i][j], dp[i][k] + dp[k + 1][j] + p[i] * p[k + 1] * p[j + 1] );
      }
    }
  }

  cout << dp[0][n - 1] << endl;
}



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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, k, a[100100], c;

signed main() {
	cin >> n >> k;
	rep(i,n) {
		cin >> a[i];
		if (a[i]==1) c = i+1;
	}
	int l = c-1, r = n-c, res = inf;
	rep(i,k) {
		int ll = l-i, rr = r-(k-1-i), t = 1;
		chmax(ll,0), chmax(rr,0);
		t += (ll+k-2)/(k-1) + (rr+k-2)/(k-1);
		chmin(res,t);
	}
	cout << res << ln;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();

        int n = nextInt(), a = nextInt(), b = nextInt();
        long mod = 1000000007;
        long ans = (3 * mod + twoPow(n, mod) - 1 - combinations(n, a, mod) - combinations(n, b, mod)) % mod;
        System.out.println(ans);
    }

    private static long twoPow(int pow, long p) {
        long res = 1;
        long base = 2;
        while (pow > 0) {
            if (pow % 2 == 1) res = (res * base) % p;
            pow /= 2;
            base = (base * base) % p;
        }
        return res;
    }

    private static int get_degree(long n, long p) { // returns the degree with which p is in n!
        int degree_num = 0;
        long u = p;
        long temp = n;

        while (u <= temp) {
            degree_num += temp / u;
            u *= p;
        }
        return degree_num;
    }

    private static long degree(long a, long k, long p) {
        long res = 1;
        long cur = a;

        while (k > 0) {
            if (k % 2 > 0) {
                res = (res * cur) % p;
            }
            k /= 2;
            cur = (cur * cur) % p;
        }
        return res;
    }

    private static long combinations(int n, int k, long p) {
        int num_degree = get_degree(n, p) - get_degree(n - k, p);
        int den_degree = get_degree(k, p);

        if (num_degree > den_degree) {
            return 0;
        }
        long res = 1;
        for (long i = n; i > n - k; --i) {
            long ti = i;
            while (ti % p == 0) {
                ti /= p;
            }
            res = (res * ti) % p;
        }
        for (long i = 1; i <= k; ++i) {
            long ti = i;
            while (ti % p == 0) {
                ti /= p;
            }
            res = (res * degree(ti, p - 2, p)) % p;
        }
        return res;
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include<stdio.h>
#include<climits>
#include<cfloat>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n-1);
	int sigma = 0;
	for(int i=0;i<n-1;i++){
		cin >> b.at(i);
	}
	a.at(0) = b.at(0);
	a.at(n-1) = b.at(n-2);
	for(int i=1;i<n-1;i++){
		a.at(i) = min(b.at(i-1),b.at(i));
	}
	for(int i=0;i<n;i++){
		sigma += a.at(i);
	}
	cout << sigma << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

h1 = h+ []
lng = len(h1)
ans = 0
while not all([i == 0 for i in h1]):
    left = lng
    right = 0
    amin = float("inf")
    for i in range(lng):
        if h1[i] == 0 and amin == float("inf"):
            continue
        if amin > 0 and h1[i] == 0:
            break
        amin = min(amin, h1[i])
        left = min(left, i)
        right = max(right, i)

    ans += amin
    for i in range(left, right+1):
        h1[i] -= amin

print(ans)

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

int main() {
	int w,h;
	scanf("%d%d", &w,&h);
	int x,y;
	scanf("%d%d", &x,&y);
	printf("%lf ", (double)w*h/2);
	if((x*2==w)&&(y*2==h)){
		printf("1\n");
	}else{
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 128
n, m = gets.split.map(&:to_i)

lst = []
n.times do
    lst << []
end

hh = {}
m.times do |i|
    pk, y = gets.split.map(&:to_i)
    pk -= 1
    lst[pk] << y
    hh[y] = i+1
end

ans = {}
lst.size.times do |i|
    lst[i].sort!
    lst[i].size.times do |j|
        ans[hh[lst[i][j]]] = sprintf("%06d%06d", i+1, j+1)
    end
end

ans = ans.to_a.sort!
ans.each do |s|
    puts s[1]
end


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<int>> coin(H, vector<int>(W));

    rep(i, H) {
        rep(j, W) {
            cin >> coin[i][j];
        }
    }

    int cnt = 0;
    int swi = 0;
    rep(i, H) {
        rep(j, W) {
            if (i == H - 1 && j == W - 1) break;
            if (i % 2 == 0) {
                if ((coin[i][j] + swi) % 2 != 0) {
                    swi = 1;
                    cnt++;
                }
                else {
                    swi = 0;
                }
            }
            else {
                if ((coin[i][W - j - 1] + swi) % 2 != 0) {
                    swi = 1;
                    cnt++;
                }
                else {
                    swi = 0;
                }
            }
        }
    }

    cout << cnt << endl;

    swi = 0;
    rep(i, H) {
        rep(j, W) {
            if (i == H - 1 && j == W - 1) break;
            if (i % 2 == 0) {
                if ((coin[i][j] + swi) % 2 != 0) {
                    swi = 1;
                    cout << i + 1 << " " << j + 1 << " ";
                    if (j == W - 1) {
                        cout << i + 2 << " " << j + 1 << endl;
                    }
                    else {
                        cout << i + 1 << " " << j + 2 << endl;
                    }
                }
                else {
                    swi = 0;
                }
            }
            else {
                if ((coin[i][W - j - 1] + swi) % 2 != 0) {
                    swi = 1;
                    cout << i + 1 << " " << W - j << " ";
                    if (j == W - 1) {
                        cout << i + 2 << " " << W - j << endl;
                    }
                    else {
                        cout << i + 1 << " " << W - j - 1 << endl;
                    }
                }
                else {
                    swi = 0;
                }
            }
        }
    }

    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> P(M);
  for (int i = 0; i < M; i++) cin >> P.at(i).second >> P.at(i).first;
  sort(P.begin(), P.end());
  int ans = 0, T = 1;
  for (int i = 0; i < M; i++) {
    if (T <= P.at(i).second) {
      ans++;
      T = P.at(i).first;
    }
  }
  cout << ans << endl;
}

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

#define ll long long
#define fi first
#define se second
#define mp make_pair

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;

int MOD = 1e9+7;

int main(){
	
	fastio();
	ll n,a[300000]={0};
	cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
		sum%=MOD;
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		sum -=a[i];
		if(sum<0)sum+=MOD;
		ans += sum*a[i];
		ans%=MOD;
	}

	cout<<ans<<endl;
	
	
	
	
	return 0;
}

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

typedef long long dnt;

dnt Gcd( dnt a, dnt b )
{
	return b == 0 ? a : Gcd(b, a % b);
}

int main()
{
	int n;
	dnt a, ans = 1;
	scanf( "%d", &n );
	for(int i = 1; i <= n; i++)
	{
		cin >> a;
		if(i != 1) ans = ans * (a / Gcd(a, ans));
        else ans *= a;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
const long long INF = 1LL << 60;
ll mod = 1e9 + 7;

int main()
{
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import product

dp = [[[0 for k in range(2)] for j in range(5)] for i in range(105)]

s = input()
n = len(s)
K = int(input())

#i:桁
#j:ゼロ以外の数
#k:上限フラグ
dp[0][0][0] = 1

for i, j, k in product(range(n), range(0,4),(0,1)):
  nd=int(s[i])
#  print(i,j,k)
  for d in range(0,10):
    ni,nj,nk=i+1,j,k
    #ゼロ以外だったらjをカウントアップ
    if d!=0:
      nj+=1
    #jがKより大きくなったらスキップ
    if nj>K:
      continue
    #ここまでの桁が上限に達している場合
    if k==0:
    #上限の桁を超えた場合スキップ
      if d>nd:
        continue
    #この桁は上限未満
      elif d<nd:
        nk=1
#    print(i,j,k,ni,nj,nk)
    dp[ni][nj][nk]+=dp[i][j][k]
#    print(dp[ni][nj][nk])
print(dp[n][K][0]+dp[n][K][1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b && b == c){
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  int maxNum = max(a,max(b,c));
  int diffMax[3];
  diffMax[0] = maxNum - a;
  diffMax[1] = maxNum - b;
  diffMax[2] = maxNum - c;
  bool flag;
  while(true){
    flag = true;
    rep(i,3){
      if(diffMax[i] >= 2) {
        diffMax[i] -= 2;
        ans++;
        flag = false;
      }
    }
    if(flag ) break;
  }

  //差が1以下
  int cnt = 0;
  rep(i,3){
    if(diffMax[i] != 0) cnt++;
  }
  if(cnt == 2) cout << ans + 1 << endl;
  else if(cnt == 0) cout << ans << endl;
  else if(cnt == 1) cout << ans +2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n;
    cin >> n;
    VL a(n);
    FOR(i, 0, n)cin >> a[i];

    SORT(a);
    int ans = 1;
    FOR(i, 0, n - 1) {
        if (a[i] * 2 >= a[i + 1])ans++;
        else ans = 1;
        a[i + 1] += a[i];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1024
N=int(input())
lst=[]

for i in range(N):
    A,B=map(int,input().split())
    lst.append([A,B])
lst.sort(key=lambda x: x[1])

def judge(N):
    worktime=0
    for i in range(N):
        worktime += lst[i][0]
        if worktime > lst[i][1]:
            return('No')
        if (i+1)==N:
            return('Yes')        
print(judge(N))

Measured memory_bytes: 38092
# include <stdio.h>
# include <string.h>
# include <math.h>
# include <stdlib.h>
# define INF 1000000000
# define MAXN 10000 
# define MAXM 100000
# define MAX(a,b) (a)>(b)?(a):(b)
# define MIN(a,b) (a)<(b)?(a):(b)
//int comp(const void * a, const void * b)

int vis[200005];
int main ()
{
	int n, x, i, cnt;
	scanf("%d%d",&n,&x);
	if (n==2) {
		if (x==2) puts("Yes\n1\n2\n3");
		else puts("No");
		return 0;
	}
	if (x==1||x==2*n-1) puts("No");
	else {
		puts("Yes");
		if (x==2*n-2) {
			vis[x+1]=vis[x-1]=vis[x]=vis[x-2]=1;
			cnt=0; i=1;
			while (cnt!=n-3) {
				if (vis[i]==0) printf("%d\n",i), cnt++;
				++i;
			}
			printf("%d\n%d\n%d\n%d\n",x-1,x+1,x,x-2);
			cnt=0;
			while (cnt!=n-2) {
				if (vis[i]==0) printf("%d\n",i), cnt++;
				++i;
			}
		}
		else {
			vis[x+1]=vis[x-1]=vis[x]=vis[x+2]=1;
			cnt=0; i=1;
			while (cnt!=n-3) {
				if (vis[i]==0) printf("%d\n",i), cnt++;
				++i;
			}
			printf("%d\n%d\n%d\n%d\n",x+1,x-1,x,x+2);
			cnt=0;
			while (cnt!=n-2) {
				if (vis[i]==0) printf("%d\n",i), cnt++;
				++i;
			}
		}
	}
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   string s;cin >>s;
   ll ans=0;
    for (int i = 0; i < 4; ++i) {
        if(s[i]=='+')ans++;
        else ans--;
    }
    cout <<ans <<endl;
   return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
////#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	int n, a, b;
	for (n = 6; fscanf(stdin, "%d%d", &a, &b),P(d, a - b),n--;);
		return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#define int long long
using namespace std;
int a, b, c, d, e, f;
vector < pair<int, pair<int, int>>>t[11];
int arr[11];
int dp[11][11];
int dfs(int n, int k)
{
	int j;
	if (n == a)
		return 0;
	int ans = 0;
	for (j = k; j <= b; j++)
	{
		arr[n] = j;
		int tans = 0;
		int y;
		for (y = 0; y < t[n].size(); y++)
		{
			if (arr[n] - arr[t[n][y].second.first] == t[n][y].second.second)
				tans += t[n][y].first;
		}
		tans += dfs(n + 1, j);
		ans = max(ans, tans);
	}
	return ans;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a>> b>> c;
	int i;
	for (i = 0; i < c; i++)
	{
		int g;
		cin >> d >> e >> f >> g;
		d--;
		e--;
		t[e].push_back({ g,{d,f} });
	}
	cout << dfs(0, 1);
}

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

int main() {
  
  int N;
  cin >> N;
  
  int hantei = 0;
  
  for ( int i = 1; i < 10; i ++){
    for ( int j = 1; j < 10; j ++){
      if ( N == i * j ){
        hantei = 1;
      }
    }
  }
  
  if (hantei){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


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

using namespace std;

#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)
#define not_equal(a,b) (!equal(a,b))
#define lt(a,b) (a-b < -EPS)

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }
double dist(const Point &a,const Point &b){
  return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;

int ccw(Point p0,Point p1,Point p2){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(cross(a,b) > EPS){ return COUNTER_CLOCKWISE; }
  if(cross(a,b) < -EPS){ return CLOCKWISE; }
  if(dot(a,b) < -EPS){ return ONLINE_BACK; }
  if(norm(a) < norm(b)){ return ONLINE_FRONT; }
  return ON_SEGMENT;
}

bool sortX(Point p1,Point p2){
  if(p1.x != p2.x){
    return (p1.x - p2.x < -EPS);
  }else{
    return (p1.y - p2.y < -EPS);
  }
}

bool sortY(Point p1,Point p2){
  if(p1.y != p2.y){
    return (p1.y - p2.y < -EPS);
  }else{
    return (p1.x - p2.x < -EPS);
  }
}

typedef vector<Point> Polygon;

Polygon convex_hull(Polygon &ps){
  int N = ps.size(),j = 0;
  Polygon pg(N*2);
  sort(ps.begin(),ps.end(),sortX);
  for(int i = 0 ; i < N ; i++,j++){
    while(j >= 2 && ccw(pg[j-2],pg[j-1],ps[i]) == -1){
      j--;
    }
    pg[j] = ps[i];
  }
  int k = j+1;
  for(int i = N-2 ; i >= 0 ; i--,j++){
    while(j >= k && ccw(pg[j-2],pg[j-1],ps[i]) == -1){
      j--;
    }
    pg[j] = ps[i];
  }
  pg.resize(j-1);
  return pg;
}

double getPolygonDiameter(Polygon &p){
  Polygon np = convex_hull(p);
  int N = np.size();
  if(N == 2){ return dist(np[0],np[1]); }
  int i = 0,j = 0;
  for(int k = 0 ; k < N ; k++){
    if(!sortX(np[i],np[k])){ i = k; }
    if(sortX(np[j],np[k])){ j = k; }
  }
  double res = 0;
  int si = i,sj = j;
  while(i != sj || j != si){
    res = max(res,dist(np[i],np[j]));
    Point p1 = np[(i+1)%N]-np[i];
    Point p2 = np[(j+1)%N]-np[j];
    if(cross(p1,p2) < 0){
      i = (i + 1) % N;
    }else{
      j = (j + 1) % N;
    }
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  Polygon p(N);
  for(int i = 0 ; i < N ; i++){
    cin >> p[i].x >> p[i].y;
  }
  printf("%.10f\n",getPolygonDiameter(p));
  return 0;
}

Measured memory_bytes: 4700
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int  ab=fabs(a-b),bc=fabs(b-c),ac=fabs(a-c);
	if(ac<=d)
	   cout<<"Yes"<<endl;
	else if(ab<=d&&bc<=d)
	   cout<<"Yes"<<endl;
	else
	   cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T

main :: IO ()
main = do
  let
    modulus = 1000000007 :: Int
    modAdd :: Int -> Int -> Int
    modAdd x y = (x + y) `mod` modulus
    modMul :: Int -> Int -> Int
    modMul x y = (x * y) `mod` modulus
    go :: Int -> Int -> [Int] -> Int
    go s c (x : xs) = s `seq` c `seq` go (s `modAdd` (c `modMul` x)) (c `modAdd` x) xs
    go s c _        = s
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getContents :: IO [Int]
  print . go 0 0 $ as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 4912
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi a(n),b(n),c(n);
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];
	REP(i,n) cin>>c[i];
	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));
	
	vector<llong> cnt(n);
	REP(i,n) cnt[i]=c.end()-upper_bound(ALL(c),b[i]);
	for(int i=n-2;i>=0;--i) cnt[i]+=cnt[i+1];
	cnt.push_back(0);
	//join(cnt);//!!!
	
	vector<llong> cntt(n);
	REP(i,n){
		cntt[i]=cnt[upper_bound(ALL(b),a[i])-b.begin()];
	}
	
	llong ans=0;
	REP(i,n) ans+=cntt[i];
	
	cout<<ans<<endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A, B, C;
	cin >> A >> B >> C;
	ll res = 0;
	res += B;
	if(C-1<=A+B){
		res += C;
	}else{
		res += A+B+1;
	}
	cout << res <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

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

	int N, A, B;
	cin >> N >> A >> B;
	int ans = 0;
	for(int i = 0; i < N; i++) {
		int t;
		cin >> t;
		if(A <= t && t < B) continue;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()

A_max = max(A)
dp = [True] * (A_max + 1)
count = 0
A_f = {a: 0 for a in A}
for a in A:
    A_f[a] += 1

for a in A:
    if dp[a]:
        for i in range(1, A_max + 1):
            if a * i > A_max:
                break
            dp[a * i] = False
        if A_f[a] == 1:
            count += 1

print(count)

Measured memory_bytes: 122592
import java.util.*;

public class Main{
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        long k = sc.nextLong();
        long[] counters = new long[100005];

        for(int i = 0; i < n; ++i){
            int a = sc.nextInt();
            long b = sc.nextLong();
            counters[a] += b;
        }

        long cnt = 0;
        for(int i = 1; i <= 100000; ++i){
            cnt += counters[i];
            if(cnt >= k){
                System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 85576
#include <bits/stdc++.h>
#define N 100
#define W 100002
#define ll long long
using namespace std;
ll tbl[2][W];

int main() {
     ll n,w,ww,v;
    cin>>n>>w;
  	for(int j=1;j<=w;j++)tbl[0][j]=0;
    for(int i=1,k=1;i<=n;i++){
        cin>>ww>>v;
        for(int j=1;j<=w;j++){
            if(ww<=j)tbl[k][j]=max(v+tbl[k-1][j-ww],tbl[k-1][j]);
            else tbl[k][j]=tbl[k-1][j];
        }
      	for(int j=1;j<=w;j++)tbl[0][j]=tbl[1][j];
    }
    cout <<tbl[1][w]<<"\n";
    return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep_r(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vp vector<pii>
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define INF 1e9
#define LLINF 1e18
#define PI (acos(-1))
#define MOD 1e9+7

int main(){
	int n;
	cin >> n;
	double p = 0;
	vi v(n);
	rep(i, n){
		cin >> v.at(i);
		p += (double)1 / v.at(i);
	}
	
	cout << 1 / p << endl;
	
	return 0;
}

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

int main() {
    ll n,k;
    cin >> n >> k;

    vector<ll> a(n), f(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> f[i];

    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());

    ll ng = -1, ok = 1e12 + 1;
    ll ans = 0;

    while(ok - ng > 1) {
        ll mid = (ng + ok) / 2;

        ll tot = 0;
        for (int i = 0; i < n; i++) {
            ll c = mid / f[i];
            tot += max(0LL, a[i] - c);
        }

        if(tot <= k) ok = mid;
        else ng = mid;
    }
    cout << ok << '\n';
}

Measured memory_bytes: 3456
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
try:
  up, lo = ceil(sum(A) / K), 0
  while up - lo > 1:
    mid = (up+lo) // 2
    cnt = 0
    for a in A:
      cnt += ceil(a / mid)-1
    if cnt > K:
      lo = mid
    else:
      up = mid
  print(up)
except ZeroDivisionError:
  print(max(A))

Measured memory_bytes: 31028
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define INFLL 0x3fffffffffffffffLL
#define INF 0x3f3fffff
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define exist(s,e) (s.find(e)!=s.end())
#define ff first
#define ss second
#define EPS 1e-8
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
const ll MOD=1000000007;
/////////////////// DEBUG MODE ///////////////////////////////////
#define D(x) cerr<<"DEBUG: "<<#x<<" is: "<<x<<'\n'
#define error(args...) {string _s=#args; replace(all(_s),',',' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string>) { cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
/////////////////// GLOBAL VARIABLES /////////////////////////////
vector<vector<pii>> adj; vector<bool> vis;
/////////////////// FUNCTIONS ////////////////////////////////////
ll mexp(ll x, ll n, ll m){
  ll res=1;  while(n){if(n&1) res=(res*x)%m;n>>=1; x=((x%m)*(x%m))%m;}
  return res;
}
bool ispow2(ll x){ return x && (!(x&(x-1))); }
ld pow(ld a, int n) {
  if(n == 0) return 1;if(n == 1) return a;
  double t = pow(a, n/2);return t * t * pow(a, n%2);
}
/////////////////// MAIN STARTS //////////////////////////////////
int main(){
  ios::sync_with_stdio(0);  cin.tie(0); cout<<fixed;   cerr<<fixed;
  cout<<setprecision(14); cerr<<setprecision(3);
  #ifdef DEBUG
  freopen("ip.txt","r",stdin); //freopen("op.txt","w",stdout);
  clock_t tStart = clock();
  #endif

	int ans=0;
	char c; for(int i=0;i<3;++i){
		cin>>c; if(c=='o') ++ans;
	}
	cout<<700+ans*100<<'\n';

	#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1e3<<"ms.\n";
	#endif
  return 0;
}


Measured memory_bytes: 256