akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <complex>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

#define EPS 1e-7

typedef complex<double> point;
typedef const point &rpoint;
typedef pair<point,point> line;

double cross(rpoint va, rpoint vb){
	return real(va) * imag(vb) - imag(va) * real(vb);
}

double distance_l_p(rpoint a, rpoint b, rpoint c){
	return abs(cross(b - a, c - a)) / abs(b - a);
}

line tangent(point p, double r, double theta){
	point a = polar(r, theta);
	point b( imag(a), -real(a) );

	return make_pair(p + a, p + a + b);
}

vector<line> common_tangent(point p1, double r1, point p2, double r2){
	vector<line> ret;

	p2 -= p1;
	double a = arg(p2);
	double b = (r1 - r2) / abs(p2);
	if( b < -1.0 || b > 1.0 ){ return ret; }
	double c = asin(b) - asin(1.0);
	ret.push_back( tangent(p1, r1, a - c) );
	ret.push_back( tangent(p1, r1, a + c) );

	b = (r1 + r2) / abs(p2);
	if( b < -1.0 || b > 1.0 ){ return ret; }
	c = asin(b) - asin(1.0);
	ret.push_back( tangent(p1, r1, a - c) );
	ret.push_back( tangent(p1, r1, a + c) );
	return ret;
}

int n;
point p[50];
double r[50];
double m[50];
int ans;


void check(rpoint p1, double r1, rpoint p2, double r2){
	vector<line> v = common_tangent(p1, r1, p2, r2);
	for(int i = 0; i < v.size(); ++i){
		int c = 0;

		for(int j = 0; j < n; ++j){
			double d = distance_l_p(v[i].first, v[i].second, p[j]);
			if( d > r[j] - EPS && d < m[j] + EPS ){
				++c;
			}
		}
		
		ans = max(ans, c);
	}
}

int main(){
	double x, y;
	
	while( scanf("%d", &n), n != 0 ){
		ans = 1;
		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf%lf", &x, &y, &r[i], &m[i]);
			m[i] += r[i];
			p[i] = point(x, y);
		}
		
		for(int i = 1; i < n; ++i)
		for(int j = 0; j < i; ++j){
			check(p[i], r[i], p[j], r[j]);
			check(p[i], r[i], p[j], m[j]);
			check(p[i], m[i], p[j], r[j]);
			check(p[i], m[i], p[j], m[j]);
		}
		printf("%d\n", ans);
	}
}

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

using namespace std;

const int N = 3000300;
const int mod = 998244353;

void add(int &x, int y) {
	x += y;
	if (x >= mod) x -= mod;
}

void sub(int &x, int y) {
	x -= y;
	if (x < 0) x += mod;
}

int mul(int x, int y) {
	return (long long) x * y % mod;
}

int pw(int x, int y) {
	int ans = 1;
	for (; y > 0; y >>= 1, x = mul(x, x)) {
		if (y & 1) ans = mul(ans, x);
	} 
	return ans;
}

int fact[N];
int ifact[N];

int C(int n, int k) {
	if (n < k || k < 0) return 0;
	return mul(fact[n], mul(ifact[k], ifact[n - k]));
}

void precalc() {
	fact[0] = 1;
	for (int i = 1; i < N; ++i) {
		fact[i] = mul(fact[i - 1], i);
	}		
	ifact[N - 1] = pw(fact[N - 1], mod - 2);
	for (int i = N - 1; i > 0; --i) {
		ifact[i - 1] = mul(ifact[i], i);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	precalc();
	int n, m;
	cin >> n >> m;
	int ans = C(3 * m + n - 1, n - 1);
	sub(ans, mul(n, C(m - 1 + n - 1, n - 1)));
	for (int i = m + 2; i <= n; i += 2) {
		sub(ans, mul(C(n, i), C((3 * m - i) / 2 + n - 1, n - 1)));
	}
	cout << ans << "\n";
}

Measured memory_bytes: 23680
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>

#define rep0(i,N) for(int i=0;i<N;i++)
#define rep1(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005

using namespace std;

int main(){
	double p;
	lint x;
	cin>>x>>p;
	double ans;
	double c;
	if(p==100){
	if(x%2==0)
	cout<<x/2;
	else
	cout<<(x+1)/2;
	return 0;
	}
	if(x%2==1)
		x++;
	c=-1*p/100+1*(100-p)/100;
	ans=x/(1-c);
	cout<< fixed << setprecision(8) << ans;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=1,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n;
  vector<string>v;
  map<string,int>hash;
  rep(i,0,n) {cin>>s;hash[s]++;}
  for(auto x:hash)
  {
    if(x.ss>k)k=x.ss;
  }
  for(auto it=hash.begin();it!=hash.end();it++)
  {
    if(it->ss==k) cout<<it->ff<<endl;
  }
  /*rep(i,0,v.size()) hash[v[i]]++;
  int max_count = 0, res = -1; 

    for (auto i : hash) { 

        if (max_count < i.second) { 

            //res = i.first; 

            max_count = i.second; 

        } 

    }
    vector<string>vec;
    for (auto i : hash) { 

        if (max_count == i.second) { */
/*r=i.first;
sort(r.begin(),r. end());
            cout<<r<<endl;*/
            /*  vec. pb(i.first);

            max_count = i.second; 

        } }
        rep(i,0,vec.size()) cout<<vec[i]<<endl;*/
    
  /*sort(all(v));
  rep(i,0,v.size())
  {
    if(v[i]==v[i+1] && i+1<v.size()) {k++;continue;}
    if(k>m) {m=k;k=0;}
  }
  k=0;
  rep(i,0,v.size())
  {
    if(v[i]==v[i+1] && i+1<v.size()) {k++;continue;}
    if(k==m) {sort(v[i].begin(),v[i].end());cout<<v[i]<<endl;}
    k=0;
  }*/
  
  /*sort(r.begin(),r. end());
  cout<<r;*/
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

string tl(string s){
	transform(s.begin(), s.end(), s.begin(), ::tolower);
	return s;
}
int main(){
	string w, t, end;
	
	cin >> w;
	tl(w);
	
	end = "END_OF_TEXT";
	
	int ans = 0;
	
	while( true ){
		cin >> t;
		if(t == end) break;
		if(tl(t) == tl(w)) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3228
import math

a, b, h, m = map(int, input().split())

mk = m*6
hk = h*30+(m/60)*30

t = abs(mk-hk)
# print(t)
theta = t/180*math.pi

aa = (math.sin(theta)*a)**2
if t > 90:
    bb = (b + (math.cos(theta)) * a) ** 2
else:
    bb = (b - (math.cos(theta)) * a) ** 2
# print(aa, bb)

ans = math.sqrt(a**2+b**2-2*a*b*math.cos(theta))
print(ans)

Measured memory_bytes: 62288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n;
    cin >> n;
    vector<int> a(n + 2);
    for(int i = 1; i <= n; i++) cin >> a[i];
    int path = 0;
    for(int i = 0; i <= n; i++){
        path += abs(a[i] - a[i + 1]);
    }
    for(int i = 1; i <= n; i++){
        int cpath = path - abs(a[i - 1] - a[i]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]);
        cout << cpath << "\n";
    }
}

Measured memory_bytes: 3744
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


class question {
public:
	int N, W;
	vector<int> w, v;
	ll dp() {
		static ll memo[101][100001];
		for (int i = 1;i <= N;i++) {
			for (int j = 0;j <= W;j++) {
				memo[i][j] = memo[i - 1][j];
				if (j >= w[i - 1]) memo[i][j] = max(memo[i][j], memo[i - 1][j - w[i - 1]] + v[i - 1]);
			}
		}
		return memo[N][W];
	}
	void ans() {
		cin >> N >> W;
		w.resize(N);
		v.resize(N);
		REP(i, N) cin >> w[i] >> v[i];
		cout << dp() << "\n";
	}
};

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

	question q;
	q.ans();

	return 0;
}

Measured memory_bytes: 78336
import sys
sys.setrecursionlimit(4100000)

l,r = [int(i) for i in input().split()]
if abs(l - r) >= 2019:
    temp = 0
else:
    temp = float('inf')
l = l%2019
r = r%2019
if l>r:
    r,l = l,r

for i in range(l,r+1):
    for k in range(i+1,r+1):
        if i*k%2019 < temp:
            temp = (i*k)%2019

print(temp) if l != r else print(temp)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl l[n];
    cin(i,l);
    sort(l,l + n);
    intl cnt = 0;
    rep(i, n){
        repi(j, i + 1, n){
            intl c = lower_bound(l, l + n, l[i] + l[j]) - l;
            cnt += c - j - 1;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))
ceil = lambda a, b: (a + b - 1) // b

n, k = inm()
a = inl()
print(ceil(n-1, k-1))

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353ll

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ld a, b, x, y;
    cin >> a >> b >> x >> y;
    cout << (a*b)/2.0 << " ";
    if (a/2.0 == x && b/2.0 == y)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}


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

class UnionFindTree:
    def __init__(self, x):
        self.parent = self
        self.id = x
        self.rank = 0

    def find(self):
        if self.id == self.parent.id:
            return self
        else:
            return self.parent.find()


# main
n, q = map(int, input().split())
nodes = [UnionFindTree(i) for i in range(n)]
for i in range(q):
    com, x, y = map(int, input().split())
    x_root = nodes[x].find()
    y_root = nodes[y].find()
    if com == 0:
        # union
        if x_root.rank > y_root.rank:
            y_root.parent = x_root
        elif y_root.rank > x_root.rank:
            x_root.parent = y_root
        elif x_root.id != y_root.id:
            y_root.parent = x_root
            x_root.rank += 1
    else:
        # same
        same = 1 if x_root.id == y_root.id else 0
        print(same)
            

Measured memory_bytes: 9796
h,n = map(int,input().split())
AB=[list(map(int,input().split()))for _ in range(n)]
dp=[10**9]*(h+1)
dp[0]=0
for ab in AB:
    a,b=ab
    for i in range(h+1):
        dp[i]=min(dp[i],dp[max(0,i-a)]+b)
print(dp[h])

Measured memory_bytes: 42844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int r = 0;
    int b = 0;
    rep(i,n) {
        if (s[i] == '0') r++;
        else b++;
    }
    cout << min(r, b) * 2 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  int N;
  cin >> N;
  map<int,int> A;
  REP(i,N){
    int a;
    cin >> a;
    A[a]++;
  }
  string ans = "YES";
  for(auto a :A){
    if(1 != a.second){
      ans = "NO";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n ; cin >> n ;
	vi v(n); re(v);
	vi tmp = v;
	sort(all(tmp));
	int a = tmp[n/2];
	int b = tmp[n/2-1];
	trav(it,v){
		if(it<=b) cout << a << endl ;
		else cout << b << endl;
	}
}
signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 6340
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007;
#define pb push_back
#define vi vector<int>
#define  eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()


int32_t main(){
int n;cin>>n;
int a[n+1];for(int i=1;i<=n;i++)cin>>a[i];
vi dp(n+1);
for(int i=0;i<=n;i++)dp[i]=INT_MAX;
dp[0]=0;
dp[1]=0;
for(int i=2;i<=n;i++){
	if(i>2)
  dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),min(dp[i-1]+abs(a[i]-a[i-1]),dp[i]));
  else dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i]);
}
// for(auto it:dp)cout<<it<<" ";
cout<<dp[n];
}




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

using namespace std;

int N, M, sz[100009];
bool ap[100009];

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

scanf ("%d %d", &N, &M), ap[1] = 1;
for (int i=1; i<=N; i++)
    sz[i] = 1;
while (M --)
{
    int x, y;
    scanf ("%d %d", &x, &y), sz[x] --, sz[y] ++;
    if (ap[x])
    {
        ap[y] = 1;
        if (sz[x] == 0) ap[x] = 0;
    }
}
int sol = 0;
for (int i=1; i<=N; i++)
    sol += (ap[i] == 1);
printf ("%d\n", sol);

return 0;
}


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

int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  int N = 5;

  vector<int> Time = {a,b,c,d,e};
  vector<int> nextTime(N);
  for (int i = 0; i < N; i++) {
    nextTime[i] = (Time[i] + 9) / 10 * 10;
  }
  int bestTime = 99999999;

  for (int i = 0; i < N; i++) {
    int sumTime = 0;
    for (int j = 0; j < N; j++) {
      if (i == j) sumTime += Time[j];
      else sumTime += nextTime[j];
    }

    bestTime = min(bestTime, sumTime);
  }

  cout << bestTime << endl;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  solve n <$> replicateM n f >>= mapM_ print
  where
    f = (\[s, p] -> (s, read p)) <$> words <$> getLine

solve :: Int -> [(String, Int)] -> [Int]
solve n sps = map snd $ sortBy f spis
  where
    spis = zip sps [1 .. n]
    f ((s1, p1),_) ((s2, p2),_)
      | s1 == s2 = compare p2 p1
      | otherwise = compare s1 s2


Measured memory_bytes: 1020
import math

n,k = list(map(int, input().split(" ")))
nums  = list(map(int, input().split(" ")))
nums.sort()

mod = 10**9 + 7
f = [1]
for i in range(1,10**5+1):
    f.append(f[-1] * i % mod)

def nCr(n,r):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

minSum = 0
maxSum = 0

for i in range(n-k+1):
    minSum += nums[i] * nCr(n-1-i, k-1)
    maxSum += nums[-i-1] * nCr(n-1-i,k-1)

print((maxSum - minSum + mod) % mod)

Measured memory_bytes: 14168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,j,n) for (int i = n; j<=i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

int main(){
  string S;cin>>S;
  ll c0=0,c1=0;
  REP(i,0,S.size()){
    if(S.at(i)=='0'){c0++;}
    else {c1++;}
  }
  print(2*min(c0,c1))
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
vector<llint> vec;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint a, b, sum = 0;
	for(int i = 1; i <= n; i++){
		cin >> a >> b;
		sum += a;
		vec.push_back(sum);
		sum += b;
	}
	for(int i = 0; i < vec.size(); i++) vec[i] %= 86400;
	sort(vec.begin(), vec.end());
	for(int i = 0; i < n; i++) vec.push_back(vec[i]+86400);
	
	llint ans = 0;
	for(llint i = 0; i < vec.size(); i++){
		ans = max(ans, upper_bound(vec.begin(), vec.end(), vec[i]+10800) - vec.begin() - i);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+6;
vector<int> e[30];

int main()
{
    string s,t;cin>>s>>t;
    int len=s.length();int len2=t.length();
    for(int i=0;i<len;i++)
    {
    	e[s[i]-'a'].push_back(i);
	}
	ll now=0;ll cnt=0;int flag=1;
	for(int i=0;i<len2;i++)
	{
		int u=t[i]-'a';
		if(e[u].size()==0) 
		{
			flag=0;break;
		}
		if(flag==0) break;
		int pos=lower_bound(e[u].begin(),e[u].end(),now)-e[u].begin();
		if(pos>=e[u].size())
		{
			now=0;cnt++;
			pos=lower_bound(e[u].begin(),e[u].end(),now)-e[u].begin();
		}
		now=e[u][pos]+1;	
	}
	ll ans=1ll*cnt*len+now;
	if(ans<0) while(1);
	if(flag)
	cout<<ans<<endl;
	else  cout<<-1<<endl;
}

Measured memory_bytes: 1216
# coding: utf-8
# Your code here!

def sumSuccessionNum(n):
    s = 0
    for i in range(n):
        s += i + 1
    
    return s

N, L = map(int, input().split())

ans = sumSuccessionNum(N) + (L - 1) * N
tasteMax = L + N - 1
tasteMin = L

if(tasteMax > 0 and tasteMin > 0):
    ans -= tasteMin
elif(tasteMax < 0 and tasteMin < 0):
    ans -= tasteMax

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <string>

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define REP(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u64 x, y;
  cin >> x >> y;

  u64 foot = 0;
  REP(i, x + 1) {
    if (y == i * 2 + (x - i) * 4) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <inttypes.h>

uint64_t gcd(uint64_t a, uint64_t b) {
	while (b > 0) {
		uint64_t r = a % b;
		a = b;
		b = r;
	}
	return a;
}

uint64_t lcm(uint64_t a, uint64_t b) {
	return a / gcd(a, b) * b;
}

int main(void) {
	int n, i;
	uint64_t a, result = 1;
	if (scanf("%d", &n) != 1) return 1;
	for (i = 0; i < n; i++) {
		if (scanf("%"SCNu64, &a) != 1) return 1;
		result = lcm(result, a);
	}
	printf("%"PRIu64"\n", result);
	return 0;
}



Measured memory_bytes: 2120
#include<stdio.h>
int main()
{
	double t500,t1000;
	int i,j;
	int r500,r1000;
	int re;
	while(scanf("%lf",&t500)!=EOF){
		scanf("%lf",&t1000);
		if	   (t500<35.50)r500=0;
		else if(t500<37.50)r500=1;
		else if(t500<40.00)r500=2;
		else if(t500<43.00)r500=3;
		else if(t500<50.00)r500=4;
		else if(t500<55.00)r500=5;
		else if(t500<70.00)r500=6;
		else r500=7;
		
		if	   (t1000<71.00)r1000=0;
		else if(t1000<77.00)r1000=1;
		else if(t1000<83.00)r1000=2;
		else if(t1000<89.00)r1000=3;
		else if(t1000<105.00)r1000=4;
		else if(t1000<116.00)r1000=5;
		else if(t1000<148.00)r1000=6;
		else r1000=7;
		
		if(r500<r1000)re=r1000;
		else if(r500>r1000)re=r500;
		else if(r500==r1000)re=r500;
		
		switch(re){
			case 0:
				puts("AAA");
				break;
			case 1:
				puts("AA");
				break;
			case 2:
				puts("A");
				break;
			case 3:
				puts("B");
				break;
			case 4:
				puts("C");
				break;
			case 5:
				puts("D");
				break;
			case 6:
				puts("E");
				break;
			case 7:
				puts("NA");
				break;
			default :
				break;
		}
	}
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;

const ll N = 200001;
const ll MOD = 1000000007;
const ll INF = LLONG_MAX;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl
#define space ' '
#define nl '\n'

void COUT(vector<ll>v){for(auto it:v)cout<<it<<space;cout<<nl;}
void CIN(vector<ll>&v){for(auto &it:v)cin>>it;}

ll ok(ll n)
{
    return (n*(n-1))/2;
}
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        cout<<ok(n)+ok(m)<<endl;
    }
}


Measured memory_bytes: 256
import itertools

n,m=map(int, input().split()) 
ab=[list(map(int, input().split())) for _ in range(m)]
#ab=Input.split()
#d：隣接行列

d = [[] for i in range(n)]
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    d[a-1].append(b-1)
    d[b-1].append(a-1)
    
#per：順列列挙
per= itertools.permutations(range(1,n))
ans=0
for i in per:
    cnt=1
    x = [0]+list(i)
    for j in range(1,n):
        #隣接していなければ終了
        if not x[j] in d[x[j-1]]:
            break
        else:
            cnt+=1
    if(cnt==n):
        ans+=1
print(ans)
        

Measured memory_bytes: 40176
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  dump(b-a == c-b ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int monsterCount = sc.nextInt();
		int hissatuCount = sc.nextInt();
		long tairyokuList[] = new  long[monsterCount];
		long kougekiCount = 0;
		for(int i= 0; i<monsterCount;  i++) {
			tairyokuList[i] = sc.nextInt();
		}
		Arrays.sort(tairyokuList);
		if(monsterCount< hissatuCount) {
			hissatuCount = monsterCount;
		}
		for(int i=0; i<hissatuCount; i++) {
			tairyokuList[tairyokuList.length-1-i] = 0;
		}
		for(int i= 0; i<monsterCount;  i++) {
			kougekiCount = kougekiCount + tairyokuList[i];
		}
		System.out.println(kougekiCount);
	}
}

Measured memory_bytes: 92112
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n, a, b;
    cin >> n >> a >> b;

    if(abs(a-b)%2 == 0){
        cout << abs(a-b)/2 << endl;
    }else{
        long l = min(a,b) - 1, r = n - max(a,b); 
        long lans = l + 1 + (max(a,b) - l - 1)/2, rans = r + 1 + (n - min(a,b) - r - 1)/2;
        cout << min(lans, rans) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using static System.Console;

class Program {
  static void Main() {
    var a = int.Parse(ReadLine());
    ReadLine();
    ReadLine();
    ReadLine();
    var e = int.Parse(ReadLine());
    var k = int.Parse(ReadLine());
    WriteLine(e - a <= k ? "Yay!" : ":(");
  }
}

Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main(){
	int n,number;
	char c;
	cin >> n;
	bool work[4][13];
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 13; j++){
			work[i][j] = 0;
		}
	}
	for(int i = 0; i < n; i++){
		cin >> c >> number;
		if(c == 'S'){
			work[0][number - 1] = 1;
		}else if(c == 'H'){
			work[1][number - 1] = 1;
		}else if(c == 'C'){
			work[2][number - 1] = 1;
		}else if(c == 'D'){
			work[3][number - 1] = 1;
		}
	}
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 13; j++){
			if(work[i][j] == 0){
				if(i == 0){
					cout << "S ";
				}else if(i == 1){
					cout << "H ";
				}else if(i == 2){
					cout << "C ";
				}else if(i == 3){
					cout << "D ";
				}
				cout << j + 1 << endl;
			}
		}
	}
	return 0;
}

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

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    rep(i, N) {
        int A;
        cin >> A;
        for (int j = 1; j <= D; j = j + A) {
            ++X;
        }
    }
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N, K;
  cin >> N >> K;
  int A[10000];
  REP(i, K) {
    int d;
    cin >> d;
    REP(j, d) {
      int n;
      cin >> n;
      n--;
      A[n] = 1;
    }
  }
  int ans = 0;
  REP(i,N){
    if(A[i]==0){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main(){
  int f,N[10],j,maxj,a,h;
 
  /*N[a]Ã£ÂÂ«Ã¥ÂÂ¤Ã£ÂÂÃ¤Â»Â£Ã¥ÂÂ¥*/

 for(a=0;a<10;a++)
   {
    scanf("%d",&N[a]);
   }

 /*Ã¤Â¸Â¦Ã£ÂÂ³Ã¦ÂÂ¿Ã£ÂÂÃ£ÂÂ*/

  for(f=0;f<10;f++)
    {
      maxj=f;

      for(j=f;j<10;j++)
	{

	if(N[maxj]<N[j])
	  {

	  maxj=j;
	}
      }
    /*N[a]Ã£ÂÂN[maxj]Ã£ÂÂ«*/

      h=N[f];
    N[f]=N[maxj];
    N[maxj]=h;

  }

  /*Ã¤Â¸ÂÃ¤Â½ÂÃ¯Â¼ÂÃ£ÂÂ¤Ã£ÂÂÃ¥ÂÂºÃ¥ÂÂ*/

    printf("%d\n%d\n%d\n",N[0],N[1],N[2]);
  return 0;
}

Measured memory_bytes: 0
from functools import reduce
import math
def main():
    n, s = map(int, input().split())
    X = list(map(lambda x:abs(int(x) - s), input().split()))
    ans = reduce(lambda x, y :math.gcd(x, y), X, X[0])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20736
N = int(input())
A = [tuple(map(int, input().split())) for _ in range(N)]
A = [(0, 0, 0)] + A

dp = [[0 for _ in range(3)] for _ in range(N + 1)]
# dp[日付, 1-indexed][その日の行動0/1/2]

for i in range(1, N + 1):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + A[i][j])

print(max(dp[N]))


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

using namespace std;
using Int = int64_t;

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

    vector<pair<Int, Int>> V;
    for (Int i = 1; i < N + 1; i++) {
        Int p;
        cin >> p;
        V.emplace_back(p, i);
    }

    sort(begin(V), end(V));
    reverse(begin(V), end(V));

    multiset<Int> S{0, 0, N + 1, N + 1};

    Int ans = 0;
    for (auto &v : V) {
        Int value = v.first;
        Int index = v.second;

        auto it = S.lower_bound(index);

        Int r1 = *it++;
        Int r2 = *it--;

        it--;

        Int l1 = *it--;
        Int l2 = *it;

        ans += value * (
            (r2 - r1) * (index - l1) +
            (l1 - l2) * (r1 - index)
        );

        S.insert(index);
    }

    cout << ans << '\n';
}


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

using namespace std;

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

    struct Restaurant {
        string city;
        int score, id;
        // 比較関数が必要
        bool operator<(const Restaurant &rhs) {
            return (this->city < rhs.city) ||
                (this->city == rhs.city && this->score >= rhs.score);
        }
    };

    vector<Restaurant> rs(n);
    for (int i = 0; i < n; ++i) {
        cin >> rs[i].city >> rs[i].score;
        rs[i].id = i + 1;
    }

    sort(rs.begin(), rs.end());

    for (const auto &r : rs)
        cout << r.id << '\n';

    return 0;
}

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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<n; i++)


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

    long long ans;
    ans =  ( H * W + 1) / 2;

    if (H == 1 || W ==1){
        cout << 1 << endl;
    }else{
    cout << ans << endl;
    }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = Integer.parseInt(readInputLine())
    
    val aList = readInputLine().split(" ").map { Integer.parseInt(it) }
    var ans = Int.MAX_VALUE
    
    for (a in aList) {
        var shiftTmp = a
        var cnt = 0
        while (shiftTmp and 1 != 1) {
            shiftTmp = shiftTmp shr 1
            cnt++
        }
        if (cnt < ans) {
            ans = cnt
        }
    }
    
    println(ans)
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37996
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int windowWidth = sc.nextInt();
		int curtainWidth = sc.nextInt();

		int culc = windowWidth - (curtainWidth * 2);
		int ans = Math.max(culc, 0);

		System.out.print(ans);
		sc.close();
	}
}


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

#define REP(i, a, b) for(int i = a; i <= b; i ++)
#define REPG(i, x) for(int i = head[x]; i; i = g[i].nxt)

#define clr(x, y) memset(x, y, sizeof(x));

using namespace std;

typedef long long LL;
typedef double LF;

LL Max(LL a, LL b){return a > b ? a : b;}
LL Min(LL a, LL b){return a < b ? a : b;}
LL abs(LL x){return x > 0 ? x : -x;}

inline int read(){
	int r = 0, z = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-') z = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9'){r = r * 10 + ch - '0'; ch = getchar();}
	return r * z;
}

void work(){
	int a = read();
	printf("%d\n", 48 - a);
}

int main(){
	work();
	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            for (int len = S.Length; len > 0; len--)
            {
                for (int j = 0; j < S.Length - len + 1; j++)
                {
                    var subS = S.Substring(j, len);
                    if (!Regex.IsMatch(subS, "[^ACGT]"))
                    {
                        Console.WriteLine(len);
                        return;
                    }
                }
            }
            Console.WriteLine(0);
        }
    }
}


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

int main() {
    string s;
    cin >> s;
    if(s[0]!='A'){
        cout << "WA" <<endl;
        return 0;
    }
    int cnt = 0;
    for(int i = 2;i<s.size()-1;++i){
         if(s[i]=='C')
         cnt++;
         
    }
    if(cnt !=1) {
        cout << "WA" <<endl;
        return 0;
    }
    int mini = 0;
    for(int i = 1;i<s.size();++i){
    for(char x = 'a';x<='z' ;++x){
        if(s[i]==x) mini++;
    }
    }
    if(mini!=s.size()-2) {
        cout << "WA" <<endl;
        return 0;
    }
    cout << "AC" <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
struct edge{int cost, p1, p2;};

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;
}

struct UnionFind {
  vector<int> par,rank;

  UnionFind (int N) : par(N),rank(N){
    for (int i=0;i<N;i++){
      par[i]=i;
      rank[i]=0;
    }
  }

  int root(int x){
    if (par[x]==x){
      return x;
    }
    return par[x]=root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if (rx == ry){
      return;
    }
    if (rank[rx]<rank[ry]){
      par[rx]=ry;
    }
    else {
      par[ry] = rx;
      if (rank[rx]==rank[ry]){
        rank[rx]++;
      }
    }
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};
int main(){
    int Case=0;
    int n,t,k,c=0;
    while(cin >> n >> t >> k,n>0){
        c++;
        vector<vector<int>> es(n-1,vector<int>(3));
        vector<vector<int>> G(n);
        rep(i,n-1){
            cin >> es[i][1] >> es[i][2] >> es[i][0];
            es[i][1]--,es[i][2]--;
            int a=es[i][1],b=es[i][2];
            G[a].push_back(b);
            G[b].push_back(a);
        }
        sort(es.begin(),es.end());
        reverse(es.begin(),es.end());
        set<int> s;
        vector<ll> count(n,0);
        rep(i,t){
            int a;
            cin >> a;
            a--;
            s.insert(a);
            count[a]++;
        }
        ll ans=0;
        UnionFind tree(n);
        priority_queue<ll,vector<ll>,greater<ll>> pq;
        rep(i,n-1){
            int p=es[i][1],q=es[i][2];
            if (count[tree.root(p)]>0&&count[tree.root(q)]>0){
                pq.push(es[i][0]);
                continue;
            }
            ll x=count[tree.root(p)]+count[tree.root(q)];
            count[tree.root(p)]=count[tree.root(q)]=x;
            tree.unite(p,q);
        }
        rep(i,k){
            ll x=pq.top();
            pq.pop();
            ans+=x;
        }
        cout << "Case " << c << ": " << ans << endl;
    }
}


Measured memory_bytes: 4772
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void) {
	string s;
	cin >> s;
	while (true) {
		if(s.size() <= 3) break;
		//cout << s << endl;
		int f = 1;
		if(s.substr(0, 3) == "ABC") f = 0;
		else if(s.substr(s.size()-3, 3) == "ABC") f = 2;
		int sz = s.size();
		bool up = false;
		REP(i, sz-2) {
			//cout << i << " " << s << " " << s.substr(i, 3) << endl;
			if(i >= s.size()) break;
			if(f == 0 && s[i] == 'A' && s.substr(i, 3) != "ABC") {cout << "No" << endl; return 0;} 
			if(f == 1 && s[i] == 'B' && i > 0 && s.substr(i-1, 3) != "ABC") {cout << "No" << endl; return 0;} 
			if(f == 2 && s[i] == 'C' && i > 1 && s.substr(i-2, 3) != "ABC") {cout << "No" << endl; return 0;} 
			if(s.substr(i, 3) == "ABC") {
				if(f == 0) s = s.substr(0, i) + "A" + s.substr(i+3);
				else if(f == 1) s = s.substr(0, i) + "B" + s.substr(i+3);
				else if(f == 2) s = s.substr(0, i) + "C" + s.substr(i+3);
				up = true;
			}
		}
		if(!up) break;
	}
	//cout << s << endl;
	if(s == "ABC") cout << "Yes" << endl;
	else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3224
#include <queue>
#include <utility>
#include <vector>
#include <unordered_map>
#include <map>
// #include <fstream>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>

using namespace std;
const long long mmod = 1000000007;

vector<long long> fact(100001);
vector<long long> ifact(100001);
vector<long long> inv(100001);

template<typename T>
T mod(T x) {
    x %= mmod;
    if (x < 0)
        x += mmod;
    return x;
}

// x must be relatively prime to p
template<typename T>
T inverse(T x) {
    x = mod(x);
    if (x == 1)
        return x;
    return mod(1LL * (-mmod / x) * (inverse(mmod % x)));
}

long long NcR(long long n, long long r) {
    long long ret = (1LL * ifact[n - r] * ifact[r]) % mmod ;
    ret = (1LL * ret * fact[n]) % mmod;
    return ret;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<long long> A(n);
    vector<long long> B(n);
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = 1LL * fact[i - 1] * i % mmod;
    }

    ifact[0] = 1;
    for(int i = 1; i <= n; i++) {
        inv[i] = inverse(i);
        ifact[i] = 1LL * ifact[i - 1] * inverse(i) % mmod;
    }
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    long long ans = 0;
    if (k > 1) {
        for (int i = 1; n-i >= k-1; i++) {
            long long d = mod(NcR(n-i,k-1)*A[i-1]);
            ans = mod(ans - d);
        }
        for (int i = 1; n-i >= k-1; i++) {
            long long d = mod(NcR(n-i,k-1)*A[n-i]);
            ans = mod(ans + d);
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 4224
import java.io.*;

public class Main{
	public static void main(String[] arsg) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str[] = new String[4];
		str = br.readLine().split(" ");
		
		double x1 = Double.parseDouble(str[0]);
		double y1 = Double.parseDouble(str[1]);
		double x2 = Double.parseDouble(str[2]);
		double y2 = Double.parseDouble(str[3]);
		
		System.out.println(Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2)));
	}
} 

Measured memory_bytes: 24424
#include <iostream>
#include <vector>

std::vector<int> readVector(int n) {
  std::vector<int> v;
  for (int i = 0; i < n; ++i) {
    int id;
    std::cin >> id;
    v.push_back(id);
  }
  return v;
}

struct Tree {
  int left = -1;
  int right = -1;
};

struct SubVector {
  int begin;
  int end;
};

class Trees {
private:
  int root;
  std::vector<Tree> trees;
  std::vector<int> preordered;
  std::vector<int> inordered;
  int r_makeTree(SubVector pre, SubVector in);
  void r_postorderTreeWalk(int n);
public:
  Trees(std::vector<int>& pre, std::vector<int>& in, int n);
  std::vector<int> postordered;
  void makeTree();
  void postorderTreeWalk();
};

Trees::Trees(std::vector<int>& pre, std::vector<int>& in, int n) {
  trees = std::vector<Tree>(n);
  preordered = pre;
  inordered = in;
}

int Trees::r_makeTree(SubVector pre, SubVector in) {
  if (pre.end - pre.begin == 0)
    return -1;
  int r = preordered[pre.begin];
  if (pre.end - pre.begin == 1) {
    return r;
  }
  int partition = 0;
  for (int i = 0; i < in.end - in.begin; ++i) {
    if (inordered[in.begin + i] == r) {
      partition = i;
      break;
    }
  }
  trees[r-1].left = r_makeTree({pre.begin + 1, pre.begin + 1 + partition},
                             {in.begin, in.begin + partition});
  trees[r-1].right = r_makeTree({pre.begin + partition + 1, pre.end},
                              {in.begin + partition + 1, in.end});
  return r;
}

void Trees::makeTree() {
  root = r_makeTree({0, (int)preordered.size()}, {0, (int)inordered.size()});
}


void Trees::r_postorderTreeWalk(int n) {
  if (trees[n-1].left != -1)
    r_postorderTreeWalk(trees[n-1].left);
  if (trees[n-1].right != -1) {
    r_postorderTreeWalk(trees[n-1].right);
  }
  postordered.push_back(n);
}

void Trees::postorderTreeWalk() {
  r_postorderTreeWalk(root);
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> preordered = readVector(n);
  std::vector<int> inordered = readVector(n);
  Trees t(preordered, inordered, n);
  t.makeTree();
  t.postorderTreeWalk();
  for (int i = 0; i < n; ++i)
    std::cout << t.postordered[i] << (i == n-1 ? "\n" : " ");
  return 0;
}

Measured memory_bytes: 3144
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()

# 2 3 1
L = inpl()

#1 2 3 
Lsort = sorted(L)

#(2,1) (3,2) (1,3)
zL = list(zip(L, Lsort))

zL.sort(key = lambda x: x[0])
ansL = [_[1] for _ in zL] 
print(' '.join(map(str, ansL)))

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

using namespace std;

#define rep(i,n) for(int i=0; i< n; i++)
#define ll = long long;
#define P = pair<int, int>;

void printVector(std::vector <int> const &a) {
   std::cout << "The vector elements are : ";
   for(int i=0; i < a.size(); i++)
      std::cout << a.at(i) << ' ';
}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)
		cin >> a[i];
	bool answer = true;
	rep(i,n){
		if(a[i] % 2 == 1) continue;
		if(a[i] % 3 != 0 && a[i] % 5 != 0)
			answer = false;
	}
	answer ? cout<<"APPROVED"<<endl : cout<<"DENIED"<<endl;
	return 0;
}

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

int main () {
  int d, n;
  cin >> d >> n;
  if (d == 0)  {
    if (n == 100) {
      cout << 101 << endl;
    }
    else cout <<  n;
  }  
  else if (d == 1)  {
    if (n == 100) {
      cout << 100 * (n + 1);
    }
    else cout << 100 * n;
  }
  else if (d == 2){
    if (n == 100) {
      cout << 10000 * (n + 1);
    }
    else cout << 10000 * n;
  }
  cout << endl;  
  return 0;
}

//なんでこれでだめかわからん
//nが100だったら101らしい？？？
//d=1 n=100 のときをかんがえる
//100でわりきれる100番目に小さい数。
//nが100だったら10000でこれだと100で2回われる。
//だから100のときは n 101 にして 100番目を担保する
//d=0のときわすれてた てへ///

//全探査

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		String[] square = new String[h];
		for (int i = 0; i < square.length; i++) {
			square[i] = sc.next();
		}
		
		for (int i = 0; i < h; i++) {
			System.out.println(square[i]);
			System.out.println(square[i]);
		}
	}
}

Measured memory_bytes: 23380
#include <stdio.h>
 
int main (void){
  int charcters[26] = {0};
  char ch;
  int i;
 
  while (scanf("%c", &ch) != EOF) {
    if (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')) {
      if('a' <= ch && ch <= 'z') {
        charcters[ch - 'a']++;
      } else {
        charcters[ch - 'A']++;
      }
    }
  }
 
  for (i = 0; i < 26; i++) {
    printf("%c : %d\n", 'a' + i, charcters[i]);
  }
 
  return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();
	String S = sc.next();

	String T[] = S.split("");
	boolean bl = true;
	if (N % 2 == 1) {
	    bl = false;
	} else {
	    for (int i = 0; i < N / 2; i++) {
		if (!T[i].equals(T[N / 2 + i]))
		    bl = false;
	    }
	}

	if (bl)
	    System.out.println("Yes");
	else
	    System.out.println("No");
    }
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main()
{
	int r = in();
	cout << 'A' << (r < 1200 ? 'B' : r < 2800 ? 'R' : 'G') << 'C' << endl;
}

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

int main(){
    int n,k; cin >> n >> k;
    double p[n];
    double f[n], sum[n];
    cin >> p[0];
    sum[0] = p[0];
    for(int i = 1; i < n; i++){
        cin >> p[i];
        sum[i] = sum[i-1] + p[i];
        f[i] = (p[i]+1)/2;
    }

    double ma =  sum[k-1];
    for(int i = k; i < n; i++){
        if(ma <= sum[i]-sum[i-k]){
            ma = sum[i]-sum[i-k];
        }
    }

    printf("%.10f\n", ma/2.0+k/2.0);

    return 0;
}

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

using namespace std;

const long long inf = 1e18 + 5;

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#ifdef LOCAL
    freopen("input.in" , "r" , stdin);
#endif
    int n;
    long long k;
    cin >> n >> k;

    vector<int> neg , pos;
    for (int i = 0 ;i < n ;i++) {
        int x;
        cin >> x;
        if (x >= 0)
            pos.push_back(x);
        else
            neg.push_back(x);
    }

//    vector<long long> test;
//    for (int i = 0 ;i < n ;i++)
//        for (int j = i + 1 ;j < n ;j++)
//            test.push_back(a[i] * 1ll * a[j]);
//
//    sort(test.begin() , test.end());
//    for (int i = 0 ;i < test.size() ;i++) {
//        cout << i + 1 << ' ' << test[i] << endl;
//    }
//
//    cout << endl;

    sort(pos.begin() , pos.end());
    sort(neg.rbegin() , neg.rend());

    auto get = [&] (long long product) {
        long long ret = 0;
        int r = pos.size() - 1;
        for (int i = 0 ;i < pos.size() ;i++) {
            while (r >= 0 && pos[r] * 1ll * pos[i] > product)
                r--;
            ret += max(0 , r - i);
        }

        r = neg.size() - 1;
        for (int i = 0 ;i < neg.size() ;i++) {
            while (r >= 0 && neg[r] * 1ll * neg[i] > product)
                r--;
            ret += max(0 , r - i);
        }

        r = neg.size() - 1;
        for (int i = 0 ;i < pos.size() ;i++) {
            while (r >= 0 && neg[r] * 1ll * pos[i] <= product)
                r--;
            ret += neg.size() - r - 1;
        }

        return ret;
    };

    long long l = -inf , r = inf , ans = -1;
    while (l <= r) {
        long long mid = l + (r - l) / 2;
        long long cnt = get(mid);
        if (cnt >= k) {
            ans = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }

    cout << ans;
}

Measured memory_bytes: 4316