akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const ll maxn=5*1e5+10;
const ll inf=99999999999;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<int> uid(l, r); return uid(rng); }
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) { return out << "(" << a.F << ", " << a.S << ")"; }
template <class A> ostream& operator << (ostream& out, const vector<A> &v) { 
out << "["; for (int i=0;i<v.size();i++) { if(i) out << ", "; out << v[i]; } return out << "]"; } 
	


void solve(){
	
	long double a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	long double x=abs(a-b);
	long double y=v-w;
	if (y!=0 && x<=t*y && (x/y)>0){
		cout<<"YES";
	}
	else cout<<"NO";
	
	
	
	return;
}
 
int main(){ 
    
    #ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 
 	
	//T{ solve(); }
	solve();
	
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	unordered_map<unsigned long long, int> D;
	for (int i = 0; i < n; ++i) {
		unsigned long long index;
		cin >> index;
		if (D.find(index) == D.end()) {
			D[index] = 0;
		}
		++D[index];
	}
	int m;
	cin >> m;
	unsigned long long* T = new unsigned long long[m];
	for (int i = 0; i < m; ++i) {
		cin >> T[i];
	}
	bool success = true;

	for (int nowM = 0; nowM < m; ++nowM) {
		if (D[T[nowM]] > 0) {
			--D[T[nowM]];
		}
		else {
			success = false;
			break;
		}
	}
	cout << (success ? "YES" : "NO") << endl;
}

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

poker :: Int -> Int -> Ordering
poker x y
    | all (/= 1) [x, y] = x `compare` y
    | otherwise =
        case (x, y) of
            (1, 1) -> EQ
            (_, 1) -> LT
            (1, _) -> GT

main :: IO ()
main = do
    [a, b] <- fmap read . words <$> getLine :: IO [Int]
    case a `poker` b of
        LT -> putStrLn "Bob"
        EQ -> putStrLn "Draw"
        GT -> putStrLn "Alice"

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

string x[3] = {"KIH", "B", "R"};

int main() {
    string s;
    cin >> s;

    for(int b = 0; b < (1 << 4); b++) {
        string t = "";
        rep(i, 4) {
            if( b & (1 << i) ) {
                t += "A";
            }
            if(i < 3) {
                t += x[i]; 
            }
        }

        if(t == s) {
            cout << "YES" << endl;
            return 0; 
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
const int INF = 10000000;
int A[210];
int main() {
  int a = 0;
  cin >> a;
  for (int i = 0;i < a;++i){
    cin >> A[i];
  }
  int res = INF;

  for (int i = 0;i < a;++i){
    int count = 0;
    while(A[i]%2==0){
      A[i] = A[i]/2;
      count = count+1;
    }
    if (res > count){
      res = count;
    }
  }
  cout << res <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
//#include <bits/stdc++.h>
using namespace std;

// long int f(vector<long int> a,vector<long int> b,vector<long int> c,vector<long int> d,int N, int M){
     
 //}

long int ans=0;
int N,M,Q;
vector<int> A;
vector<long int> a,b,c,d;

void f(int n){
    if (n==N){
        long int x=0;
        for (int i=0;i<Q;i++){
            if(A[b[i]-1]-A[a[i]-1]==c[i]) x+=d[i];
        }
        ans=max(ans,x);
        return;
    }
    else{
        for (int i=(n==0?1:A[n-1]);i<=M;i++){
            A.push_back(i);
            f(n+1);
            A.pop_back();
        }
        return;
    }
}

int main(){
    cin>>N>>M>>Q;
    long int x;
    for (int i=0;i<Q;i++){
        cin>>x;a.push_back(x);
        cin>>x;b.push_back(x);
        cin>>x;c.push_back(x);
        cin>>x;d.push_back(x);
    }
    f(0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    int n;
    cin >> n;
    vector< int > v(SIZE), r_v(SIZE);
    for( int i = 0; i < SIZE; ++i ) {
        v[i] = r_v[i] = 1;

    }

    int a[n + 1];
    for( int i = 1; i <= n; ++i ) {
        cin >> a[i];

    }
    v[1] = a[1];
    r_v[n] = a[n];
    for( int i = 2; i <= n; ++i ) {
        v[i] = __gcd( v[i - 1], a[i] );

    }
    for( int i = n - 1; i >= 1; --i ) {
        r_v[i] = __gcd( r_v[i + 1], a[i] );

    }

    int res = 0;
    for( int i = 1; i <= n; ++i ) {
        int tmp;
        if( i == 1 ) {
            tmp = r_v[i + 1];

        } else if( i == n ) {
            tmp = v[i - 1];

        } else {
            tmp = __gcd( r_v[i + 1], v[i - 1] );

        }
        res = max( res, tmp );

    }
    cout << res << endl;
    return 0;
}



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

using namespace std;
using ll = long long;
const int maxn = 3005;
ll dp[maxn][maxn][4];
int good[maxn][maxn];
int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif

    ll r, c, k;
    cin >> r >> c >> k;
    for(int i = 0; i < k; i++){
        ll x, y, z;
        cin >> x >> y >> z;
        good[x][y] = z;
    }
//    for(int i = 1; i <= c + 1; i++){
//        for(int j = 0; j <= 3; j++) {
//            dp[r + 1][i][j] = 0;
//        }
//    }
//    for(int i = 1; i <= r + 1; i++){
//        for(int j = 0; j <= 3; j++) {
//            dp[i][c + 1][j] = 0;
//        }
//    }




        for(int j = r; j >= 1; j--){
            for(int q = c; q >= 1; q--){
                for(int i = 3; i >= 0; i--){
                if(i > 0 and good[j][q] > 0){
                    dp[j][q][i] = max(dp[j+1][q][3] , dp[j][q+1][i-1]) + good[j][q];
                    dp[j][q][i] = max(dp[j][q][i] , dp[j+1][q][3]);
                    dp[j][q][i] = max(dp[j][q][i] , dp[j][q+1][i]);
                }
                else {
                    dp[j][q][i] = max(dp[j+1][q][3] , dp[j][q+1][i]);
                }
            }
        }
    }

    ll ans = dp[1][1][3];
//    ll ans = -1;
//    for(int i = 0; i < 4; i++){
//        ans = max(ans , dp[1][1][i]);
//    }
//    ll tmp[6][6];
//    memset(tmp, -1, sizeof(tmp));
//    for(int i = 1; i <= 2; i++){
//        for(int j = 1; j <= 5; j++){
//            for(int q = 0; q <= 3; q++){
//                tmp[i][j] = max(tmp[i][j] , dp[i][j][q]);
//            }
//        }
//    }
    //cout << dp[1][2][1] ;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 320360
// “Incredible change happens in your life when you decide to take control of what
// you do have power over instead of craving control over what you don't.

// Dear online judge:
//  I've read the problem, and tried to solve it.
//  Even if you don't accept my solution, you should respect my effort.
//  I hope my code compiles and gets accepted.

#include <bits/stdc++.h>
typedef long long ll;
#define forn(i, start, end) for (ll i = start; i < ll(end); i++)
#define input(arr, n) forn(i, 0, n) cin >> arr[i];
#define input2d(arr, n, m) forn(i, 0, n) forn(j, 0, m) cin >> arr[i][j];
#define MOD 1000000007
#define pb push_back
#define ppb pop_back
#define mk make_pair
#define f first
#define s second
#define tc    \
    ll T;     \
    cin >> T; \
    while (T--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;

int32_t main()
{
    FAST;
    //tc
    {
        string s,t;
        cin>>s >> t;
        t.pop_back();
        if(s==t)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
ll a[maxn];

int main(){	
	int n;
	ll res = 0;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i) scanf("%lld",&a[i]),res ^= a[i];
	for(int i = 1;i <= n;++i) printf("%lld%c",res^a[i],i == n ?'\n' :' ');
	return 0;
}


Measured memory_bytes: 5280
from collections import defaultdict
N = int(input())
ans = 0
for i in range(N + 1):
  if i % 2 == 0:
    continue
  t, j, dic, r = i, 2, defaultdict(int), 1
  while True:
    while t % j == 0:
      t /= j
      dic[j] += 1
    j += 1
    if j * j > i:
      break
  if t > 1:
    dic[t] += 1
  for key in dic:
    r *= dic[key] + 1
  if r == 8:
    ans += 1
print(ans)


Measured memory_bytes: 3828
import bisect
A, B, Q =  map(int, (input().split(' ')))
power = 10**11+1
a_list = [-power]+[int(input()) for _ in range(A)] + [power]
b_list = [-power]+[int(input()) for _ in range(B)] + [power]
for _ in range(Q):
    x = int(input())
    right_s = abs(x - a_list[bisect.bisect_left(a_list, x)])
    right_t = abs(x - b_list[bisect.bisect_left(b_list, x)])
    left_s = abs(x - a_list[bisect.bisect_right(a_list, x)-1])
    left_t = abs(x - b_list[bisect.bisect_right(b_list, x)-1])
    print(
            min(
                max(left_t, left_s),
                max(right_t, right_s),
                left_t + (left_t + right_s),
                left_s + (left_s + right_t),
                right_t + (right_t + left_s),
                right_s + (right_s + left_t)
            )
    )


Measured memory_bytes: 12800
lmap = lambda f, s: list(map(f, s))
n, m = map(int, input().split())
a = [lmap(int, input().split()) for i in range(n)]
a = lmap(lambda xs: xs + [sum(xs)], a)
a.append(lmap(sum, zip(*a)))
for xs in a: print(*xs)


Measured memory_bytes: 6256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC59C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for(int i = 0; i < n; i++)
            {
                a[i] = int.Parse(str[i]);
            }
            long x = 0;
            long y = 0;
            int f = 0;
            int sum = 0; 
            for(int i = 0; i < n; i++)
            {
                sum += a[i];
                if (f == 1 && sum >= 0)
                {
                    x += (sum + 1);
                    f = 0;
                    sum = -1;
                }else if (f == 0 && sum <= 0)
                {
                    x += (1 - sum);
                    f = 1;
                    sum = 1;
                }else
                {
                    f = 1 - f;
                }
            }
            sum = 0;
            f = 1;
            for (int i = 0; i < n; i++)
            {
                sum += a[i];
                if (f == 1 && sum >= 0)
                {
                    y += (sum + 1);
                    f = 0;
                    sum = -1;
                }
                else if (f == 0 && sum <= 0)
                {
                    y += (1 - sum);
                    f = 1;
                    sum = 1;
                }
                else
                {
                    f = 1 - f;
                }
            }
            x = Math.Min(x, y);
            Console.WriteLine(x);
        }
    }
}


Measured memory_bytes: 26844
#include <cstdio>
const int maxn = 100010;

char s[maxn];


int main() {
  static int ans;
  scanf("%*d%s", s + 1);
  for (int i = 1; s[i]; ++i) ans += (s[i] != s[i - 1]);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<int> a(n+1);
	rep(i,n)cin >> a[i+1];
	vector<int> dp(n+1);
	dp[1] = 1000;
	for(int i = 2;i <= n;i++){
		dp[i] = dp[i-1];
		for(int j = 1;j <i;j++){
			int tmp = dp[j]/a[j];
			dp[i] = max(dp[i],dp[j] + tmp*(a[i] - a[j]));
		}
	}
	cout << dp[n] << endl;
	return 0;
}

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

#define fo(i, n) for(int i = 0; i < int(n); i ++)
#define ff(i, n) for(int i = 1; i < int(n); i ++)
 
typedef long long ll;

#define INF 1000000000000
 
ll dp[2010][2010];
ll a[2010];
 
 
int main(){
    int N;ll hog,res;
    bool fla;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    if(N == 1) {
        cout << a[0] << endl;
        return 0;
    }
    dp[0][N-1] = a[N-1];

    for(int i = 1; i < N; i++) dp[i][N-1] = a[i-1];
    fla=false;
    for(int i = N-2; i>=1; i--){
        if(fla){
            dp[0][i]=max(dp[0][i+1]+a[i],dp[N-1][i+1]+a[N-1]);
            for(int j=1;j<N;j++){
                dp[j][i]=max(dp[j][i+1]+a[(j+i)%N],dp[j-1][i+1]+a[j-1]);
            }
        }
        else{
            hog=-INF;
            if(a[0]<a[i]){
                hog=dp[0][i+1];
            }
            if(a[N-1]>a[i-1]){
                hog=max(hog,dp[N-1][i+1]);
            }
            dp[0][i]=hog;
            for(int j=1;j<N;j++){
                hog=-INF;
                if(a[j]<a[(i+j)%N]){
                    hog=dp[j][i+1];
                }
                if(a[j-1]>a[(i+j-1)%N]){
                    hog=max(hog,dp[j-1][i+1]);
                }
                dp[j][i]=hog;
            }
        }
        fla=!fla;
    }
    res=-INF;
 
    if(fla){
        for(int i=0;i<N;i++){
            res=max(res,dp[i][1]+a[i]);
        }
    }
    else{
        for(int i=0;i<N;i++){
            res=max(res,dp[i][1]);
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 32588
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    cin >> n;
    int sum = 0;

    vector<int> w;
    rep(i,n){
        int tmp;
        cin >> tmp;
        w.pback(tmp);
        sum += tmp;
    }
  

    int ans = INT_MAX;
    int tmp_sum = 0;

    rep(i,n){

        tmp_sum += w[i];
        int rest = sum - tmp_sum;

        ans = min(ans, abs(tmp_sum - rest));

    }

    cout << ans << endl;


}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  string s;
  cin >> s;

  bool success = true;
  for (size_t i = 0; i < s.size(); i++)
  {
    if ((i + 1) % 2 == 0)
    {
      //偶数
      if (s[i] == 'R')
      {
        success = false;
      }
    }
    else
    {
      if (s[i] == 'L')
      {
        success = false;
      }
    }
  }

  if (success)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

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


int main(){
    string s;
    cin >> s;
    cout << s;
    if (s[s.size()-1] == 's') cout << "es" << endl;
    else cout << "s" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
vector<vector<int>> a;
vector<int> b;
vector<int> s;
vector<int> t;
int c = 1;

void dfs(int x)
{
  if (b[x]==1) return;
  b[x] = 1;
  s[x] = c; c++;
  for (auto v:a[x]) {
    dfs(v);
  }
  t[x] = c; c++;
}

int main()
{
  int n; cin>>n;
  a.resize(n);
  b.resize(n); rep(i, n) b[i]=0;
  s.resize(n); rep(i, n) s[i]=0;
  t.resize(n); rep(i, n) t[i]=0;
  rep(i, n) {
    int u; cin>>u; u--;
    int k; cin>>k;
    rep(j, k) {
      int v; cin>>v; v--;
      a[u].push_back(v);
    }
  }
  rep(i, n) dfs(i);
  rep(i, n) printf("%d %d %d\n", i+1, s[i], t[i]);

  return 0;
}



Measured memory_bytes: 3264
#include <iostream>
#include <cstdio>

using namespace std;

int a[3][3];
bool flag[3][3] = {false};

bool check(bool flag[3][3]) {
	int i, j;
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			if (!flag[i][j]) break;
		}
		if (j == 3) return true;
	}
	for (j = 0; j < 3; j++) {
		for (i = 0; i < 3; i++) {
			if (!flag[i][j]) break;
		}
		if (i == 3) return true;
	}
	
	if (flag[0][0] && flag[1][1] && flag[2][2]) return true;
	if (flag[0][2] && flag[1][1] && flag[2][0]) return true;
	return false;
}

int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	
	int n, cnt = 0;
	cin >> n;
	while (n--) {
		int x;
		cin >> x;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (a[i][j] == x) flag[i][j] = true;
			}
	    }
	}
	
	if (check(flag)) puts("Yes");
	else puts("No");
	
	return 0;
}

Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 100005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
 ll modularExponentiation(ll x,ll n)
 {
     int result=1;
     while(n>0)
     {
         if(n % 2 ==1)
             result=(result * x)%MOD;
         x=(x*x)%MOD;
         n=n/2;
     }
     return result;
 }
 
void solve()
{
   ll maxi = 0,mini = 0;
   ll n,k;
   cin >> n >> k;
   ll a[n];
   for(ll i=0;i<n;i++)   cin >> a[i];
   sort(a,a+n);
   ll fact[N],inv[N];
   fact[0] = inv[0] = 1;
   for(ll i=1;i<N;i++)
   {
   	   fact[i] = (fact[i-1] * i) % MOD;
   	   inv[i] = modularExponentiation(fact[i],MOD-2);
   }
   for(ll i=k-1;i<n;i++)
   {
   	    ll temp = (fact[i]*inv[k-1])%MOD;
   	    temp = (temp * inv[i-k+1])%MOD;
   	    temp = (temp * a[i])%MOD;
   	    maxi += temp;
   }
   for(ll i=0;i<=n-k;i++)
   {
   	    ll temp = (fact[n-i-1] * inv[k-1]) %MOD;
   	    temp = (temp * inv[n-i-k])%MOD;
   	    temp = (temp * a[i])%MOD;
   	    mini += temp;
   }
   maxi = (maxi - mini + MOD)%MOD;
   cout<<maxi;
}

int main()
{
    FAST;
    ll t = 1;
 //   cin >> t;
    while(t--)
    {
    	solve();
    }
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int a[10005];
int b[10005];
int main() {
	string s, t;
	cin >> s >> t;
	for(int i =0; i < s.size(); i++) {
		a[s[i]]++;
		b[t[i]]++;
	}
	for(int i = 0; i < 200; i++) {
		for(int j = 0; j < 200; j++) {
			if(a[i] == b[j]) {
				a[i] = b[j] = 0;
			}
		}
	}
	int s1 = 0;
	int s2 = 0;
	for(int i = 0; i < 200; i++) {
		s1 += a[i];
		s2 += b[i];
	}
	if(s1 == s2 && s1 == 0) {
		cout << "Yes" << endl;
	} else {
		cout <<"No" << endl;
	}
	return 0;
}

Measured memory_bytes: 776
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits



def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))



sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n, k = MAP()

s = list(input())



s[k - 1] = s[k - 1].swapcase()

s=''.join(s)

print(s)




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

int main(){
  int L;
  cin >> L;
  int v=2;
  int e=2;
  vector<vector<int> > E = {{1,2,0},{1,2,1}};
  int check = 2;
  while(L >= check*2){
    E.push_back({v, v+1, check});
    E.push_back({v, v+1, 0});
    v++; e+=2;
    check*=2;
  }
  int cmax = check;
  int goal = v;
  int res = L%cmax;
  while (res > 0){
    int check = 1;
    for (int i=1; i<=20; i++){
      if (check*2<=res){
        check*=2;
        continue;
      }
      E.push_back({i, goal, cmax});
      e++;
      cmax += check;
      res %= check;
      break;
    }
  }
  cout << v << ' ' << e << endl;
  for (int i=0; i<e; i++){
    cout << E[i][0] <<' ' << E[i][1] << ' ' << E[i][2] << endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		BigDecimal[] a = new BigDecimal[n];
		for (int i = 0; i < n; i++) {
			a[i] = new BigDecimal(br.readLine());
		}
		br.close();

		BigInteger b2 = BigInteger.valueOf(2);
		BigInteger b5 = BigInteger.valueOf(5);
		BigDecimal b = BigDecimal.valueOf(1000000000);
		int[] c2 = new int[n];
		int[] c5 = new int[n];
		for (int i = 0; i < n; i++) {
			BigInteger bi = a[i].multiply(b).toBigInteger();
			while (bi.mod(b2).compareTo(BigInteger.ZERO) == 0) {
				bi = bi.divide(b2);
				c2[i]++;
			}
			while (bi.mod(b5).compareTo(BigInteger.ZERO) == 0) {
				bi = bi.divide(b5);
				c5[i]++;
			}
		}

		int[][] sum = new int[50][50];
		for (int i = 0; i < n; i++) {
			sum[c2[i]][c5[i]]++;
		}
		for (int i = 49; i >= 0; i--) {
			for (int j = 48; j >= 0; j--) {
				sum[i][j] += sum[i][j + 1];
			}
		}
		for (int i = 48; i >= 0; i--) {
			for (int j = 49; j >= 0; j--) {
				sum[i][j] += sum[i + 1][j];
			}
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			int m2 = Math.max(18 - c2[i], 0);
			int m5 = Math.max(18 - c5[i], 0);
			ans += sum[m2][m5];
			if (m2 <= c2[i] && m5 <= c5[i]) {
				ans--;
			}
		}
		System.out.println(ans / 2);
	}
}


Measured memory_bytes: 75908
import std.stdio;
import std.conv;
import std.string;

void main() {
    ulong h, w;
    string[] a;

    readf(" %s %s\n", &h, &w);

    foreach (_; 0..h) {
         string input = readln.chomp;
         bool f = false;
         foreach (i; input) {
            if (i != '.')
                f = true;
         }
         if (f)
            a ~= input;
    }
    h = a.length;

    auto ans = new char[][](h, 0);
    foreach (i; 0..w) {
        bool f = false;
        foreach (j; 0..h) {
            if (a[j][i] != '.') {
                f = true;
                break;
            }
        }
        if (f)
            foreach (j; 0..h)
                ans[j] ~= a[j][i];
    }
    foreach (i; ans)
        i.writeln;
}


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

int abs(int a){
    if(a>0){
        return a;
    }else{
        return -a;
    }
}
int main() {
    int n,x,y;
    cin >> n >> x >> y;
    int N =n;
    int X= x;
    int Y = y;
    
    int INF = 5000000;
    int dist[N+1][N+1];
    
    rep(i,N+1){
        rep(j,N+1){
            dist[i][j]=INF;
        }
    }
    
    int toing = n;
    int shortcut = INF;
    rep(froming,N){
        if(froming==0){
            continue;
        }
        toing = n;
        while (toing > froming) {
            if(toing==0){
                continue;
            }
            shortcut = abs(froming-X)+abs(toing-Y)+1;
            dist[froming][toing] = min(toing-froming,shortcut);
            
            toing--;
        }
    }
    
    int ans[N-1];
    rep(i,N-1){
        ans[i]=0;
    }
    rep(i,N+1){
        rep(j,N+1){
            if(dist[i][j]<INF){
                ans[dist[i][j]-1]+=1;
            }
        }
    }
    
    rep(i,N-1){
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 15872
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N,M=map(int, input().split())
B=[tuple(map(int, input().split())) for _ in range(M)]

P=list(range(N+1))
C=[1 for _ in range(N+1)]
C[0] = 0

def root(x):
    if P[x]==x: return x
    P[x] = root(P[x])
    return P[x]

def unite(a,b):
    ra = root(a)
    rb = root(b)
    C[ra] += C[rb]
    C[rb] = 0
    P[rb] = ra

def same(a,b):
    return root(a) == root(b)

def count(x):
    return C[root(x)]

ans=[0]*(M+1)
ans[M] = N * (N-1)

for i in range(M-1,-1,-1):
    a,b = B[i]
    if same(a,b):
        ans[i] = ans[i+1]
        continue
    ans[i] = ans[i+1] - count(a) * count(b)
    unite(a,b)

for i in range(1,M+1):
    print(ans[i] - ans[0])

Measured memory_bytes: 35928
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    vector<int> ans;
    while(v.size()) {
        bool flag = false;
        for(int i = (int)v.size()-1; i>=0; i--) {
            if(v[i]==i+1 && (int)v.size()>=v[i]) {
                ans.push_back(v[i]);
                v.erase(v.begin()+i);
                flag = true;
                break;
            }
        }
        if(!flag) {
            cout << -1 << endl;
            return 0;
        }
    }
    reverse(ALL(ans));

    rep(i,ans.size()) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))

    ans = [K - A[i] + A[i - 1] for i in range(1, N)]
    print(min(min(ans), A[-1] - A[0]))


main()


Measured memory_bytes: 26444
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=2e5+10;
int N;
int A[MAXN];
int cnt[MAXN];
void solve()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    for(int u=1;u<=N;u++){
        cin>>A[u];
        cnt[A[u]]++;
    }
    ll sum=0;
    for(int u=1;u<=N;u++){
        sum+=(ll)cnt[u]*(cnt[u]-1)/2;
    }
    for(int u=1;u<=N;u++){
        int t=A[u];
        ll pre=(ll)cnt[t]*(cnt[t]-1)/2;
        ll aft=(ll)(cnt[t]-1)*(cnt[t]-2)/2;
        cout<<sum-pre+aft<<'\n';
    }
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
#define REP(i,n) for(int i=0;i<n;i++)

int N, M;


int main() {
    cin.tie(0);
    bool flag_ans = false;
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int l = S.length();
    if(S[0] =='A'){
      int count = 0;
      int pos = 0;
      for (int i = 2; i<l-1;++i){
        if(S[i] == 'C'){
          ++count;
          pos = i;
        }
      }
      if(count == 1){
        bool flag = true;
        for (int i = 1; i < l; ++i){
          if(i!=pos){
            if ((S[i] >= 'A')&& (S[i]<='Z')){
              flag = false;
            }

          }
        } 
        if(flag){
          flag_ans = true;
        }
      }
    }
    if(flag_ans){
      cout << "AC"<<endl;
    }else{
      cout << "WA"<<endl;
    }
    
}


Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,a[100010],b[100010],now=0,res=0,ans;
multiset <pii> s,t;

void calc(int i)
{
	if(i==0)
	{
		int x=s.begin()->se,y=s.begin()->fi;
		s.erase(s.begin());
		t.erase(t.find({-x,y}));
		if(x<=now&&now<=y) return;
		if(abs(now-x)<abs(now-y))
		{
			res+=abs(now-x);
			now=x;
		}
		else
		{
			res+=abs(now-y);
			now=y;
		}
	}
	else
	{
		int x=-(t.begin()->fi),y=t.begin()->se;
		t.erase(t.begin());
		s.erase(s.find({y,x}));
		if(x<=now&&now<=y) return;
		if(abs(now-x)<abs(now-y))
		{
			res+=abs(now-x);
			now=x;
		}
		else
		{
			res+=abs(now-y);
			now=y;
		}
	}
}

int main()
{
	cin>>n;
	rep(i,n)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		s.insert({b[i],a[i]});
		t.insert({-a[i],b[i]});
	}
	for(int i=0,j=0;i<n;i++,j^=1) calc(j);
	res+=abs(now);
	ans=res;
	rep(i,n)
	{
		s.insert({b[i],a[i]});
		t.insert({-a[i],b[i]});
	}
	now=res=0;
	for(int i=0,j=1;i<n;i++,j^=1) calc(j);
	res+=abs(now);
	ans=max(ans,res);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <string>
 
using namespace std;
 
bool check(int n, int a, int b);
 
int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (check(i, a, b)) {
			ans += i;
		}
	}
	cout << ans << endl;
	
	return 0;
}
 
bool check(int n, int a, int b)
{
	int t = 0;
	while (n != 0) {
		t += n % 10;
		n /= 10;
	}
 
	if (a <= t && t <= b) {
		return true;
	}
	else {
		return false;
	}
}

Measured memory_bytes: 256
// Last Change: 04/12/2020 21:16:18.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

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

  ll res = 0;
  for (ll i = 0; i <= N; ++i) {
    if (!(i % 3 == 0 or i % 5 == 0)) {
      res += i;
    }
  }
  cout << res << endl;
}


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

int main(){
  int n,k; cin >> n >> k;
  vector<bool> a(n,false);
  rep(i,k) {
    int d; cin >> d;
    rep(j,d) {
      int tmp; cin >> tmp;
      tmp--;
      a[tmp] = true;
    }
  }

  int count=0;

  rep(i,n) {
    if(a.at(i) == false){
      count++;
    }
  }

  cout << count << endl;
}



Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
int main(){
  int i,b,dice[7],ans,len;
  char couse[101];
  for(i=1;i<=6;i++)scanf("%d",&dice[i]);
  scanf("%s",couse);
  len=strlen(couse);
  for(i=0;i<len;i++){
    if(couse[i]=='S'){
      b=dice[1];
      dice[1]=dice[5];
      dice[5]=dice[6];
      dice[6]=dice[2];
      dice[2]=b;
    }
    if(couse[i]=='W'){
      b=dice[1];
      dice[1]=dice[3];
      dice[3]=dice[6];
      dice[6]=dice[4];
      dice[4]=b;
    }
    if(couse[i]=='N'){
      b=dice[1];
      dice[1]=dice[2];
      dice[2]=dice[6];
      dice[6]=dice[5];
      dice[5]=b;
    }
    if(couse[i]=='E'){
      b=dice[1];
      dice[1]=dice[4];
      dice[4]=dice[6];
      dice[6]=dice[3];
      dice[3]=b;
    }
  }
  printf("%d\n",dice[1]);
  return 0;
}


Measured memory_bytes: 2112
"""
Writer: SPD_9X2
https://atcoder.jp/contests/abc128/tasks/abc128_f

左端から一定個数おきにおいていく(好きな個数だけ)。
これを中心に対して反転したときに、重ならないならば、反転してor演算したものは構成可能
あとは、1～N-1に関して約数を探索するので計算量は
O(N√N)

コーナーケースっぽいwa!!
→うーんなんだろう？
→半分以上に関しては不可能なので、0にしておくべき？

左から並べたやつの右端より右に少なくとも1つの右が必要
"""

N = int(input())

s = list(map(int,input().split()))
now = [0] * N
ans = [0] * N

for i in range(1,N):

    j = 1

    while j ** 2 <= i:

        if i % j == 0:

            if (N-1) % j == 0 and 2+i*2 > N:
                pass
            elif i + j > N:
                pass
            else:
                #print (i,j)
                now[j] += s[i] + s[N-1-i]
                ans[j] = max(ans[j],now[j])

        if i % j == 0 and j**2!=i:

            j2 = i // j

            if (N-1) % j2 == 0 and 2+i*2 > N:
                pass
            elif i+j2 > N:
                pass
            else:
                #print (i,j2)
                now[j2] += s[i] + s[N-1-i]
                ans[j2] = max(ans[j2],now[j2])

        j+=1
    #print (now)

pra = 0
for i in range(0,N//2):
    pra = max(pra,ans[i])

#print (ans)
print (pra)
            

    



Measured memory_bytes: 66388
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
#define clr0(n) (memset(n,0,sizeof n))
#define clr1(n) (memset(n,-1,sizeof n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	// online submission
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
}
int main()
{
	
	fast();
	int t;
	t=1;
	while (t--){
		int n, m;
		cin >> n >> m;
		vector<vector<int>>gh(n);
		for (int i = 0; i < m; i++){
			int u, v;
			cin >> u >> v;
			u--, v--;
			gh[u].push_back(v);
			gh[v].push_back(u);
		}
		for (int i = 0; i < n; i++){
			cout << gh[i].size() << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
int N,M,si,ti;

struct edge {
  int to,fi,se;
};

vector< edge > G[MAX_N];

vector< vector< edge > > nG[MAX_N];

vector< int > g[MAX_N];
vector< int > d[MAX_N];

typedef pair< int ,int > P;
typedef pair< int , P > PP;

int getId(int pos,int t){
  vector<int> :: iterator it;
  it= lower_bound( g[pos].begin() , g[pos].end() , t );
  assert(g[pos].end()!=it);
  assert(*it==t);
  return it-g[pos].begin();
}

int dijkstra(){
  for(int i=0;i<N;i++){
    d[i].resize(g[i].size());
    for(int j=0;j<(int)d[i].size();j++)
      d[i][j]=1e9;
  }
  d[si][0]=0;
  priority_queue< PP , vector<PP> , greater<PP> > Q;
  Q.push( PP( 0 , P(si,0) ) );
  while(!Q.empty()){
    PP pp=Q.top();Q.pop();
    int pos=pp.second.first;
    int tm=pp.second.second;
    int cost=pp.first;
    if( d[pos][tm] < cost )continue;

    if( pos == ti )return cost;
    
    for(int i=0;i<(int)nG[pos][tm].size();i++){
      edge e=nG[pos][tm][i];
      int ntm=getId(e.to,e.se);

      if(d[e.to][ntm]>cost){
        d[e.to][ntm]=cost;
        Q.push(PP(cost,P(e.to,ntm)));
      }
      
    }

    if(tm+1==(int)g[pos].size())continue;
    
    int ncost=cost+g[pos][tm+1]-g[pos][tm];
    if(d[pos][tm+1]>ncost){
      d[pos][tm+1]=ncost;
      Q.push( PP(ncost,P(pos,tm+1) ) );
    }
  }
  assert(0);
  return -1;
}

int main(){
  scanf("%d %d %d %d",&N,&M,&si,&ti);
  si--,ti--;
  
  g[si].push_back(0);
  for(int i=0;i<M;i++){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    a--,b--;
    
    G[a].push_back( (edge){b,c,c+d} );
    g[a].push_back(c);
    //    g[a].push_back(c+d);
    //    g[b].push_back(c);
    g[b].push_back(c+d);
  }

  for(int i=0;i<N;i++){
    sort(g[i].begin(),g[i].end());
    g[i].erase( unique(g[i].begin(),g[i].end()) , g[i].end() );
  }

  for(int i=0;i<N;i++){
    nG[i].resize( g[i].size() );
    for(int j=0;j<(int)G[i].size();j++){
      edge e=G[i][j];
      int id=getId(i,e.fi);
      nG[i][id].push_back(e);
    }
  }

  printf("%d\n",dijkstra());
  return 0;
}

Measured memory_bytes: 40340
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def nCr(n, r, MOD):
    """ 組み合わせの数(大きいnに対して使用する。計算量はr) """

    if n < r: return 0
    # 10C7 = 10C3
    r = min(r, n-r)
    num = den = 1
    # 分子の計算
    for i in range(n, n-r, -1):
        num *= i % MOD
        num %= MOD
    # 分母の計算
    for i in range(r, 0, -1):
        den *= i % MOD
        den %= MOD
    # logがつくため、MOD除算は最後の1回だけにする
    return num * pow(den, MOD-2, MOD) % MOD
N, a, b = MAP()

ans = pow(2, N, MOD) - 1 - nCr(N, a, MOD) - nCr(N, b, MOD)
print(ans%MOD)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
char t;
int n;
int ans=0,cur;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t;
		if(t=='I')
		{
			cur++;
			ans=max(ans,cur);
		}
		if(t=='D') cur--;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int*num = new int[n];
    for (int i = 0; i < n; i++)
    {
        cin >> num[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (i == n - 1)cout << num[0] << endl;
       else cout << num[n - 1 - i] << " ";

    }

    return 0;
}

Measured memory_bytes: 1188
import math
N = int(input())
ps = []
for i in range(N):
  x, y = map(int, input().split())
  ps.append((x, y, i))
ps.sort()

# i -> j のベクトル
def vec(pi, pj):
  return (pj[0] - pi[0], pj[1] - pi[1])
# i -> j 向きの外積
def det(vi, vj):
  return vi[0] * vj[1] - vi[1] * vj[0]

# 凸包を求める
cvx = []
for i in list(range(N)) + list(range(N-1))[::-1]:
  while len(cvx) >= 2 and det(vec(ps[cvx[-2]], ps[cvx[-1]]), vec(ps[cvx[-1]], ps
[i])) < 0:
    cvx.pop()
  cvx.append(i)

# 凸包の各頂点について、頂点から出る2辺のなす角を計算
ans = {}
pi = None
for i in cvx:
  x, y, j = ps[i]
  if pi is not None:
    px, py, pj = ps[pi]
    slope = math.atan2(y-py, x-px)
    if j not in ans: ans[j] = [0, 0]
    if pj not in ans: ans[pj] = [0, 0]
    ans[j][0] = slope
    ans[pj][1] = slope
  pi = i

for i in range(N):
  if i not in ans:
    print(0)
    continue
  v1, v2 = ans[i]
  if v2 < v1:
    v2 += 2*math.pi
  print(round((v2-v1) / (2*math.pi), 8))

Measured memory_bytes: 3188
import static java.lang.Math.*;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			int d = scanner.nextInt();
			System.out.println(max(min(b, d) - max(a, c), 0));
		}
	}
}


Measured memory_bytes: 23764
n, a, b = map(int, input().split(' '))

if a==0:
    print(0)
    exit(0)

ans = 0

num_rb = n//(a+b)

if num_rb == 0:
    if n >= a:
        print(a)
        exit(0)
    else:
        print(n)
        exit(0)

ans += (num_rb)*a
ans += min(a, n - num_rb*(a+b))

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MAX_N 3000
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-48);
}
int n; lnt P, C[MAX_N+5][MAX_N+5];
lnt f[MAX_N+5], g[MAX_N+5][MAX_N+5];
lnt Pow(lnt x, lnt k, lnt P) {
	lnt ret = 1;
	for (; k; k >>= 1, x = x*x%P)
		if (k&1) ret = ret*x%P;
	return ret;
}
int main() {
	read(n), read(P);
	for (int i = 0; i <= n; i++) C[i][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i; j++)
			C[i][j] = (C[i-1][j-1]+C[i-1][j])%P;
	for (int i = 0; i <= n; i++) g[i][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i; j++)
			g[i][j] = (g[i-1][j-1]+g[i-1][j]*(j+1)%P)%P;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= i; j++)
			(f[i] += g[i][j]*Pow(2, (n-i)*j, P)%P) %= P;
	for (int i = 0; i <= n; i++)
		(f[i] *= Pow(2, Pow(2, n-i, P-1), P)) %= P;
	lnt tot = 0;
	for (int i = 0; i <= n; i++)
		(tot += Pow(-1, i, P)*C[n][i]*f[i]%P) %= P;
	return printf("%lld\n", (tot+P)%P), 0;
}


Measured memory_bytes: 139648
B,Z,W,J,I,X,Y,N,M,A['   '];main(){scanf("%d%d",&N,&M);for(;~scanf("%d%d",&X,&Y);){B=Y+1;for(J=1;J*J<=M;J++){Z=(X+J-1)/J,W=Y/J;A[Z]++;A[W+1<B?W+1:B]--;B=Z;}for(I=1;I<B;I++){if((X-1)/I<Y/I){A[I]++;A[I+1]--;}}}for(I=1;I<=M;I++){A[I]+=A[I-1];printf("%d\n",A[I]);}}

Measured memory_bytes: 1280
N, A, B = map(int, input().split())

if (B-A)%2==0:
  ans = (B-A)//2
else:
  C = min(A,B)
  D = max(A,B)
  if D-1 < N-C:
    ans = C+(D-C-1)//2
  else:
    ans = N-D+1+(D-C-1)//2

print(ans)

Measured memory_bytes: 3060
import numpy as np


# input the data
k, n = (int(x) for x in input().split())
a = [int(i) for i in input().split()]

# culculate each distance between the houses
distance = []
for i in range(n-1):
    distance.append(a[i+1] - a[i])
# exeption (distance between 1st house and n_th house)
distance.append(k - a[n-1] + a[0])

# compare max(distance) and spesial distance
dis_max = np.max(distance)

# answer
ans = k - dis_max
print(ans)


Measured memory_bytes: 35116
import java.util.Scanner;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a<b){
            System.out.println("a < b");
        }
        else if(a>b){
            System.out.println("a > b");
        }
        else {
            System.out.println("a == b");
        }
    }
}


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

int main(){
  int W,H,N;
  cin >> W >> H >> N;
  int x,y,a;
  int xmax,xmin,ymax,ymin;
  xmin = 0;
  xmax = W;
  ymin = 0;
  ymax = H;
  for(int i = 0; i < N; i++){
    cin >> x >> y >> a;
    switch(a){
      case 1:
        if(xmin < x) xmin = x;
        break;
      case 2:
        if(xmax > x) xmax = x;
        break;
      case 3:
        if(ymin < y) ymin = y;
        break;
      case 4:
        if(ymax > y) ymax = y;
        break;
    }
  }
  int xans = xmax-xmin;
  int yans = ymax-ymin;
  if(xans>=0 && yans>=0) printf("%d\n",xans*yans);
  else printf("%d\n",0);
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M)  //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) {           //bit計算
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) {   //素数判定
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

signed main() {
    int N;
    cin >> N;
    vector<int> t;
    vector<string> s;
    rep(i, N) {
        string S;
        int T;
        cin >> S >> T;
        t.push_back(T);
        s.push_back(S);
    }
    string X;
    cin >> X;
    int ans = 0;
    bool check = false;
    rep(i, N) {

        if (check) {
            ans += t[i];
        }
        if (s[i] == X) {
            check = true;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    pair<string, int> s,t;
    cin >> s.first >> t.first;
    cin >> s.second >> t.second;
    string u;
    cin >> u;
    if(u==s.first) s.second--;
    else t.second--;
    printf("%d %d\n",s.second,t.second);

    return 0;
}

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


int main() {

  string s;
  cin>>s;

  int cnt_a=0,cnt_b=0,cnt_c=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='a')
      cnt_a++;
    else if(s.at(i)=='b')
      cnt_b++;
    else
      cnt_c++;
  }

  if(max(cnt_a,max(cnt_b,cnt_c))-min(cnt_a,min(cnt_b,cnt_c)) <=1)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 512