akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [1000000001 for i in range(N)]
dp[0] = 0
for i in range(N):
    for j in range(1, K+1):
        if i+j <= N-1:
            dp[i+j] = min(dp[i] + abs(h[i+j] - h[i]), dp[i+j])

print(dp[N-1])


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

using namespace std;

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

    long N, M, K;
    cin>>N>>M>>K;

    const long MOD = 1e9+7;
    auto mod = [&](long x) {return x % MOD;};
    vector<long> fact(200001);
    fact[0] = 1;
    for (int i = 1; i < fact.size(); i++)
        fact[i] = mod(fact[i-1] * i);
    auto mod_pow = [&](long x, long p) {
        long t = 1;
        long u = x;
        for (int i = 0; i < 32; i++) {
            if (p >> i & 1)
                t = mod(t * u);
            u = mod(u * u);
        }
        return t;
    };
    auto mod_div = [&](long x, long y) {
        return mod(x * mod_pow(y, MOD-2));
    };
    auto mod_comb = [&](long x, long y) -> long {
        if (x < 0 or y < 0)
            return 0;
        else
            return mod_div(fact[x], mod(fact[y] * fact[x-y]));
    };

    auto all_cost = [&](long x, long y) {
        long res = 0;
        for (long d = 2; d <= x; d++) {
            auto pos = mod((x-d+1) * mod_pow(y, 2));
            auto pat = mod_comb(mod(N*M-2), K-2);
            res = mod(res + mod((d-1) * mod(pos * pat)));
        }
        return res;
    };

    long ans = all_cost(N,M) + all_cost(M, N);
    ans = mod(ans);

    cout << ans << endl;

    
    return 0;
}



Measured memory_bytes: 1792
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
ll gcd(ll a,ll b){return b ? gcd(b, a % b) : a;} //最大公約数
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll T;
    cin >> T;
    while(T--) {
        ll A,B,C,D;
        cin >> A >> B >> C >> D;
        if(A < B){
            print("No");
        }else if(B > D){
            print("No");
        }else if(C >= B-1){
            print("Yes");
        }else{
            // C+1 <= (A + kD) mod B <= B-1
            // C+1-A <= kD mod B <= B-A-1
            ll L = ((C - A + 1) % B + B) % B;
            ll R = ((B - A - 1) % B + B) % B;
            if(L <= R){
                ll v = gcd(B, D);
                if(R / v == L / v && L % v != 0){
                    print("Yes");
                }else{
                    print("No");
                }

            }else{
                // print(T);
                print("No");
            }
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
    int n,x,t,m,ans=0;
    scanf("%d %d %d", &n, &x, &t);
    do{
        n=n-x;
        ans=ans+t;
    }while(n>0);
    
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] X = sc.next().toCharArray();
		char[] Y = sc.next().toCharArray();
		
		if (X[0] > Y[0])
			System.out.println(">");
		else if (X[0] < Y[0])
			System.out.println("<");
		else if (X[0] == Y[0])
			System.out.println("=");
		
	}
}


Measured memory_bytes: 23764
N = int(input())

num_array = [[0]*2 for i in range(N)]
for i in range(N):
    x, l = map(int, input().split())
    small = x-l
    if small <= 0:
        small = 0
    big = x+l

    num_array[i][1] = small
    num_array[i][0] = big

num_array.sort()

tmp_r = -(10**18)
count = 0
for r, l in num_array:
    if tmp_r > l:
        continue
    count += 1
    tmp_r = r

print(count) 

Measured memory_bytes: 20016
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi   vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;


int main()
{

	ll i,j,k,l,n,test_case,m,r;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		cin>>n;
		ll dp[n+1][4];

		rep(i,0,n){
			rep(j,0,4){
				dp[i][j]=LLONG_MIN/100000;
			}
		}
		vl vec(n);
		ren cin>>vec[i];
		
		dp[0][0]=vec[0];
		dp[1][1]=vec[1];
		dp[2][0]=vec[0]+vec[2];
		dp[2][2]=vec[2];
		rep(i,3,n){
			dp[i][0]=vec[i]+dp[i-2][0];
			dp[i][1]=max(vec[i]+dp[i-3][0],vec[i]+dp[i-2][1]);
			dp[i][2]=(max(vec[i]+dp[i-2][2],vec[i]+dp[i-3][1]));
			if(i>=4)
			dp[i][2]=max(dp[i][2],vec[i]+dp[i-4][0]);
		}
		ll ans=LLONG_MIN;
		if(n&1){
			ans=max(ans,dp[n-1][2]);
			ans=max(ans,dp[n-2][1]);
			ans=max(ans,dp[n-3][0]);
		}else{
			ans=max(ans,dp[n-1][1]);
			ans=max(ans,dp[n-2][0]);
		}
		cout<<ans<<"\n";



	}
	
	return 0;
}


Measured memory_bytes: 11152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

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

    vector<ll> a(n), f(n);
    rep2(i, n) cin(a[i]);
    rep2(i, n) cin(f[i]);

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

    ll left = -1, right = 1e12;
    while(left + 1 < right) {
        ll middle = (left + right) / 2;

        bool ok = [&]{
            ll sum = 0;
            rep2(i, n) {
                sum += max(0ll, a[i] - middle / f[i]);
            }
            return sum <= k;
        }();

        if (ok) right = middle;
        else left = middle;
    }

    print(right);
    return 0;
}

Measured memory_bytes: 6448
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define pp pair<ll,ll>
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
int main()
{
    fastio
    int a,b,c,d,e; cin>>a>>b>>c>>d>>e;
    if(a==0) cout<<1;
    else if(b==0) cout<<2;
    else if(c==0) cout<<3;
    else if(d==0) cout<<4;
    else cout<<5;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    long long int n;
    cin>>n;

    long long int sum=0;

    if(n!=1)
    {
        long long int temp=n/(n-1);
        if(n*temp==n)
            sum+=n-1;
    }
    for (long long int i = 2; i*i <=n ; ++i) {
        if(n%i==0)
        {
            long long int a=n/(i-1);
            if(a*i==n)
                sum+=i-1;

            long long int z=n/i;
            a=n/(z-1);
            if(a*z==n)
                sum+=z-1;
        }

    }
    cout<<sum;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3188
s = int(input())
li = [s]

for i in range(1000000):
    a = 0
    if li[i]%2 == 0:
        a = li[i]//2
    else :
        a = 3*li[i]+1
        
    if a in li:
        print(i+2)
        break
    else:
        li.append(a)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1e+9;
 
int main()
{
	int n, m = 0;
	cin >> n >> m;
    vector<int> l_list(m);
    vector<int> r_list(m);
    int r_min = INF;
    int l_max = -99999;
    int l = 0;
    int r = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> l;
        l_max = max(l_max, l);

        cin >> r;
        r_min = min(r_min, r);

    }

    int ct = 0;
    for (int i = 1; i < n + 1; i++)
    {
        if (l_max <= i && i <= r_min)
        {
            ct++;
        }
    }
    cout << ct << "\n";

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String h = sc.next();
		int flag =0;
		for(int i=0;i<h.length()-1;i++) {
			if(h.charAt(i)==h.charAt(i+1)) {
				flag =1;
				break;
			}
		}
		if(flag==0) {
			System.out.println("Good");
		}
		else {
			System.out.println("Bad");
		}

	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    int ans=0;
    for(int i=2;i<=sqrt(n);i++){
        int pw=0;
        while(n%i==0){
            n/=i;
            pw++;
        }
        int nn=0;
        while((nn+1)*(nn+2)/2<=pw)
            nn++;
        ans+=nn;
    }
    if(n==1)
    cout<<ans;
    else{
        cout<<ans+1;
    }

}


Measured memory_bytes: 3696
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <array>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;


int main() {
  array<bool, 1000000> is_p;
  fill(all(is_p), true);
  is_p[0] = is_p[1] = false;
  for (int i = 2; i * i < (int)is_p.size(); i++) if (is_p[i])
    for(int j = i * 2; j < (int)is_p.size(); j += i) is_p[j] = false;
  
  vi prime;
  rep(i, is_p.size()) if (is_p[i]) prime.pb(i);


  for (int N, P; cin >> N >> P, N + P != -2; ) {
    int p = 0;
    while(prime[p] <= N) p++;

    priority_queue<int, vi, greater<int>> que;

    rep(i, 100) rep(j, 100) que.push(prime[p + i] + prime[p + i + j]);

    rep(i, P - 1) que.pop();
    
    cout << que.top() << endl;



  }
  
  
  return 0;
}

Measured memory_bytes: 2568
#include <stdio.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
const ll MOD = 1000000007;

int dp[25][50101] = {0};
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int c[25];
    rep(i, m) scanf("%d", &c[i]);

    rep(j, n+1) dp[0][j] = MOD;
    rep(i, m+1) dp[i][0] = 0;
    rep(i, m){
        rep(j, n+1){
            dp[i+1][j] = dp[i][j];
            if(j - c[i] >= 0){
                dp[i+1][j] = min(dp[i+1][j], dp[i][j-c[i]] + 1);
                dp[i+1][j] = min(dp[i+1][j], dp[i+1][j-c[i]] + 1);
            }
        }
    }

    printf("%d\n", dp[m][n]);
}


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

int h, w, maxd;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
char mat[25][25];
bool vis[25][25];

int ans = -1;
void bfs(int x, int y){
    for(int i = 0; i<25; i++){
        for(int j = 0; j<25; j++) vis[i][j] = 0;
    }

    vis[x][y] = 1;
    queue<pair<pair<int, int>, int>> q;

    int dist[25][25], d = 0;
    for(int i = 0; i<25; i++){
        for(int j = 0; j<25; j++) dist[i][j] = 0;
    }

    q.push({{x,y},0});
    while(!q.empty()){
        x = q.front().first.first;
        y = q.front().first.second;
        d = q.front().second;
        q.pop();
        for(int i = 0; i<4; i++){
            int x1 = x+dx[i], y1 = y+dy[i];
            if(x1>=0 && x1<h && y1>=0 && y1<w && mat[x1][y1]!='#' && !vis[x1][y1]){
                vis[x1][y1] = 1;
                dist[x1][y1] = d+1;
                q.push({{x1, y1}, d+1});
            }
        }
    }

    maxd = 0;
    for(int i = 0; i<h; i++){
        for(int j = 0; j<w; j++) maxd = max(maxd, dist[i][j]);
    }
    //cout<<maxd<<"\n";
    ans = max(ans, maxd);
}

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

    //good luck kittu!
    cin>>h>>w;
    string s;
    for(int i = 0; i<h; i++){
        cin>>s;
        for(int j = 0; j<w; j++) mat[i][j] = s[j];
    }

    for(int i = 0; i<h; i++){
        for(int j = 0; j<w; j++){
            if(mat[i][j]=='.') bfs(i, j);
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_B
while true
    cards = gets.chomp
    break if cards == '-'
    n = gets.to_i
    n.times do
        x = gets.to_i
        cards = cards[x..-1] + cards[0,x]
    end
    puts cards
end

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

void run() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> has(1000001), cnt(1000001);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ++has[a[i]];
    }
    for (int i = 1; i <= 1000000; i++) if (has[i]) {
        for (int j = i + i; j <= 1000000; j += i) {
            ++cnt[j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (cnt[a[i]] == 0 && has[a[i]] == 1) {
            ++ans;
        }
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    run();
    return 0;
}


Measured memory_bytes: 11912
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;


#define REP(i,n) for(int i=0;i<(int)n;i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()


double EPS = 1e-10;

double add(double a, double b){
	if(abs(a+b) < EPS * (abs(a) + abs(b))) return 0;
	return a+b;
}

struct P{
	double x,y;
	P(){}
	P(double x, double y) : x(x), y(y){
	}
	P operator +(P p){
		return P(add(x,p.x), add(y,p.y));
	}
	P operator -(P p){
		return P(add(x,-p.x), add(y,-p.y));
	}
	P operator *(double d){
		return P(d*x, d*y);
	}
	double dot (P p){
		return add(x*p.x, y*p.y);
	}
	double det (P p){
		return add(x*p.y, -y*p.x);
	}
	void print (){
		cout << x << " " << y <<endl;
		return;
	}
};

int onCheck(P &p, P &q, P &r){
	bool a = ((q-p).det(r-p)==0);
	bool b = ((p-q).dot(r-q) >=0 );
	bool c = ((p-r).dot(q-r)  >= 0 );
	if(a&&b&&c){
		return 1;
	}else{
		return 0;
	}
}

int intersectionCheck(P &p0, P &p1, P &p2, P &p3){
	P q0 = p1-p0;
	P q1 = p3-p2;
	if(q0.det(q1)==0){
		bool a =onCheck(p0,p2, p3) ;
		bool b =onCheck(p1,p2, p3) ;
		bool c = onCheck(p2,p0, p1) ;
		bool d = onCheck(p3,p0, p1);
		if (!a && !b && !c && !d){
			return 0;
		}else{
			return 1;
		}
	}

	P r = p0 + (p1-p0)*(q1.det(p2-p0)/q1.det(q0));
	bool e = onCheck(r, p0, p1);
	bool f = onCheck(r, p2, p3);
	if(e && f){
		return 1;
	}else{
		return 0;
	}
}

/*
int intersectionCheck(P &p0, P &p1, P &p2, P &p3){
	P q0 = p1-p0;
	P q1 = p3-p2;
	if(q0.det(q1)==0){
		if((p2-p1).det(p2-p0)!=0) return 0;
		if(((p2-p0).dot(p2-p1)<=0)||((p3-p0).dot(p3-p1)<=0) || ((p1-p2).dot(p1-p3)<=0)){
			return 1;
		}else{
			return 0;
		}
	}

	P r = p0 + (p1-p0)*(q1.det(p2-p0)/q1.det(q0));
	if ((p0-r).dot(p1-r) <=0 && (p2-r).dot(p3-r) <=0){
		return 1;
	} else{
		return 0;
	}
}
*/

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

	REP(i, q){
		P p0, p1, p2, p3;
		cin >> p0.x >> p0.y >>p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y ;
		cout << intersectionCheck(p0, p1, p2, p3) << endl;
	}
	return 0;
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define MAX 5100000
typedef long long ll;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int X,Y; cin >> X >> Y;
    COMinit();
    if ((X+Y)%3 != 0) cout << 0 << endl;
    else {
        int N = (X+Y)/3;
        cout << COM(N,X-N) << endl;
    }
    return 0;
}


Measured memory_bytes: 119808
n = int(input())
ans = [0] * n

def f(x, y, z):
  return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x

cnt = 0
l = int(n ** 0.5)

for x in range(1, l):
  for y in range(1, l):
    for z in range(1, l):
      if f(x, y, z) <= n:
        ans[f(x, y, z) - 1] += 1
        
ans.append(cnt)

for j in range(n):
  print(ans[j])

Measured memory_bytes: 9572
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x_max=0,ans=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n;i++){
    if(s.at(i)=='I'){
      ans++;
    }else{
      ans--;
    }
    if(ans>x_max){
      x_max=ans;
    }
  }
  cout<<x_max<<endl;
}


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

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1), c(n);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    for (int i = 1; i < n; i++) {
        cin >> c[i];
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += b[a[i]];
        if (i > 1 && a[i] == 1 + a[i - 1]) {
            ans += c[a[i - 1]];
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>
bool chmin(T &a,T b){
    if(a<=b)return 0;
    a=b;
    return 1;
}

long double eps = 1e-10;

typedef long double ld;

ld x[222],y[222],z[222],r[222];
ld dx[222],dy[222],dz[222],dr[222];

ld f(ld a,ld b){
    return (a-b)*(a-b);
}

ld dist(int i,int j,ld t){
    return  {f(x[i]+dx[i]*t, x[j]+dx[j]*t) +
             f(y[i]+dy[i]*t, y[j]+dy[j]*t) +
             f(z[i]+dz[i]*t, z[j]+dz[j]*t)};
}

ld d_r(int i,int j,ld t){
    return (r[i]-dr[i]*t+r[j]-dr[j]*t)*(r[i]-dr[i]*t+r[j]-dr[j]*t);
}

signed main(){
    cout << fixed << setprecision(20);
    //ofstream cout("out.txt");

    int n;
    while(cin>>n){
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin>>x[i]>>y[i]>>z[i]>>dx[i]>>dy[i]>>dz[i]>>r[i]>>dr[i];
        }
        vector<pair<ld,pair<int,int>>> v;
        for(int i=0;i<n;i++){
            // sizen
            v.push_back({(ld)(r[i]/dr[i]),{i,i}});
            for(int j=i+1;j<n;j++){
                // sanbu
                ld low=-eps,up=max(r[i]/dr[i],r[j]/dr[j])+eps,mid1,mid2;
                for(int _=0;_<77;_++){
                    mid1 = (low*2.0+up)/3.0;
                    mid2 = (low+up*2.0)/3.0;
                    ld d1 = dist(i,j,mid1) - d_r(i,j,mid1);
                    ld d2 = dist(i,j,mid2) - d_r(i,j,mid2);
                    if(d1<=0.0){
                        up=mid1;
                        continue;
                    }
                    if(d1>d2)low=mid1;
                    else up=mid2;
                }
                ld d = dist(i,j,low) - d_r(i,j,low);
                if(low>=0.0 && d <= eps){
                    v.push_back({low,{i,j}});
                }

            }
        }
        sort(v.begin(),v.end());
        bool used[n]={};
        ld ans[n];
        for(int i=0;i<v.size();i++){
            if(used[v[i].second.first] || used[v[i].second.second]) continue;
            ans[v[i].second.first] = v[i].first;
            ans[v[i].second.second] = v[i].first;
            used[v[i].second.first] =1;
            used[v[i].second.second] = 1;
        }
        for(int i=0;i<n;i++){
            cout << ans[i] << "\n";
        }
    }
}



Measured memory_bytes: 3496
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec = vector<T>;

template <typename T>
using vvec = vector<vector<T>>;

int main(){
  int k;
  cin>>k;
  if(k%2==0||k%5==0){
    cout<<"-1"; return 0;
  }
  int a=7%k,b=a,n=1;
  while(n<=k){
    if(b==0){
      cout<<n;
      return 0;
    }
    a=(a*10)%k;
    b+=a;
    b%=k;
    n++;
//    cout<<b<<endl;
  }
  //(10^n-1)/9*7
}


/* きょむ〜 */


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

using namespace std;

vector<int> getList(int i) {
    int a;
    vector<int> vec(i);
    for (int j = 0; j < i; ++j) {
        cin >> a;
        vec.at(j) = a;
    }
    return vec;
}

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

    int n;
    cin >> n;
    vector<int> vec = getList(n);
    vector<int> backUp = vec;

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    int ma = vec.at(0);
    int second = vec.at(1);
    vec = backUp;

    for (int i = 0; i < n; ++i) {
        if (vec.at(i) == ma) {
            cout << second << endl;
        } else {
            cout << ma << endl;
        }
    }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    int V[52];
    int C[52];
    int ans = 0;
    cin >> N;
    rep(i,N) cin >> V[i];
    rep(i,N) cin >> C[i];
    rep(i,N) {
        int S = V[i]-C[i];
        if(S > 0) ans+=S;
    }

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] a) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);
        int i = 0;
        int one=0;
        int two=0;
        int three=0;

        while(i<10){
        	int num=Integer.parseInt(br.readLine());
        	if(one<=num){
        		three=two;
        		two=one;
        		one=num;
        	}else if(two <= num){
        		three = two;
        		two=num;
        	}else if(three <=num){
        		three=num;
        	}
        	i++;
        }
        System.out.println(one);
        System.out.println(two);
        System.out.println(three);
	}
}

Measured memory_bytes: 23996
soe = [0]*(10**7+1)
soe[1] = 1
for i in range(2,10**7+1):
    if soe[i]==0:
        for j in range(i,10**7+1,i):
            if soe[j]==0:
                soe[j]=i
n = int(input())
res = 0
for i in range(1,n+1):
    t = i
    d = dict()
    ans = 1
    
    while soe[t]!=t:
        d[soe[t]]=d.get(soe[t],0)+1
        t//=soe[t]
    if t!=1:
        d[soe[t]]=d.get(soe[t],0)+1
    for j in d:
        ans*=(d[j]+1)
    
    res+=ans*i

print(res)

Measured memory_bytes: 152368
# solution
import io
import math

(a, b, x) = map(int, input().split(' '))
if x >= a*a*b/2:
    print(180 * math.atan(2*b/a-2*x/(a*a*a)) / math.pi)
else:
    print(180 * math.atan(a*b*b/(2*x)) / math.pi)

Measured memory_bytes: 3060
n,w = map(int,input().split(" "))
c = int(input())
ar = [[0 for i in range(w)] for j in range(n)]
br = list(map(int,input().split(" ")))
z = 1
for i in range(n):
    if i % 2 ==0:
        for j in range(w):
            ar[i][j] = z
            br[z-1] -= 1
            if br[z-1] == 0:
                z += 1
    else:
        for j in range(w-1,-1,-1):
            ar[i][j] = z 
            br[z-1] -= 1
            if br[z-1] == 0:
                z += 1
for r in ar:
    for i in range(w-1):
        print(r[i],end=" ")
    print(r[w-1])

Measured memory_bytes: 3948
#include <iostream>
#include <queue>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <set>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>

using namespace std;
typedef long long ll;
ll d[3001][3001][4];
ll a[3001][3001];
int R, C, K;
ll go(int x, int y, int z) {
	if (x == R && y == C) {
		if (z < 3)return a[R][C];
		else return 0;
	}
	ll &ret = d[x][y][z];
	if (ret != -1)return ret;
	ret = 0;
	if (x + 1 <= R)
		ret = max(ret, go(x + 1, y, 0));
	if (y + 1 <= C) {
		ret = max(ret, go(x, y + 1, z));
	}
	if (z < 3) {
		if (x + 1 <= R)
			ret = max(ret, go(x + 1, y, 0) + a[x][y]);
		if (y + 1 <= C) {
			ret = max(ret, go(x, y + 1, z + 1) + a[x][y]);
		}
	}
	return ret;

}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> R >> C >> K;
	for (int i = 0; i < K; i++) {
		int x, y, z; cin >> x >> y >> z;
		a[x][y] = z;
	}
	memset(d, -1, sizeof(d));
	cout << go(1, 1, 0) << '\n';




}

Measured memory_bytes: 355280
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())

sum_a = t1 * a1 + t2 * a2
sum_b = t1 * b1 + t2 * b2

if sum_a == sum_b:
    print('infinity')
    exit()
    
if sum_a > sum_b:
    big_sum = sum_a
    big_1 = a1*t1
    big_2 = a2*t2
    sml_sum = sum_b
    sml_1 = b1*t1
    sml_2 = b2*t2
else:
    big_sum = sum_b
    big_1 = b1*t1
    big_2 = b2*t2
    sml_sum = sum_a
    sml_1 = a1*t1
    sml_2 = a2*t2
    
if sml_1 < big_1:
    print(0)
    exit()
    
#print(big_sum,sml_sum)
    
n = (big_1-sml_1) // (sml_sum-big_sum)

if (big_1-sml_1) % (sml_sum-big_sum) == 0:
    print(n*2)
else:
    print(n*2+1)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int A,B,ans;
    double d;

    cin >> A;
    cin >> B;
    
    if(5*(A+1) <= 4*B || 4*(B+1) <= 5*A){
        std::cout << "-1" << endl;
        return 0;
    }else if(5*A <= 4*B && 4*B <<5*(A+1)){
        ans =10*B;
    }else{
        d=A;
        ans=(int)((25*d/2)+0.5);
    }
    std::cout << ans << endl;

    return 0;    
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ (VU.head xs) + (VU.last xs) + VU.sum (VU.zipWith min xs $ VU.tail xs)

Measured memory_bytes: 508
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void)
{
	char s[110]={};
	int i, l;

	scanf("%s", &s);
	l=strlen(s);

	for(i=0;i<l;i++){
		s[i]='x';
	}

	printf("%s", s);
	return 0;
}

Measured memory_bytes: 128
#include <climits>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <sstream>
 #include <string>
using namespace std;

void merge(vector<int> &A, int left, int mid, int right, int &count) {
    // cout << "--- merge ---\n";
    // for (int i = 0; i < A.size(); ++i)
    // {
    //     cout << A[i] << " ";
    // }
    // cout << endl;

    //左用の配列と右用の配列を作る
    int size_left  = mid - left;
    int size_right = right - mid;
    vector<int> L(size_left + 1), R(size_right + 1);

    //各配列に要素をコピーする
    // cout << "     --- vector<int> L ---\n";
    for (int i = 0; i < size_left; ++i)
    {
        L[i] = A[left + i];
        // printf("     %d\n", L[i]);
    }
    // cout << endl;
    // cout << "     --- vector<int> R ---\n";
    for (int i = 0; i < size_right; ++i)
    {
        R[i] = A[mid + i];
        // printf("     %d\n", R[i]);
    }
    // cout << endl;

    //番兵
    //  "サイズ+1"の配列を作っているので、"size_x"に入れても大丈夫("size_x-1"でなくて良い)
    L[size_left]  = INT_MAX;
    R[size_right] = INT_MAX;

    //ソート
    //  分割した2つの配列から昇順になるように要素をもとの配列に戻す
    //     -> 再帰により「要素1」の配列に分解されたあとに統合していくので、L・Rは昇順にソートされている
    int i = 0;
    int j = 0;
    for (int k = left; k < right; ++k)
    {
        count++;
        if(L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(vector<int> &A, int left, int right, int &count) {
    //分割できなくなったら終了
    if(left + 1 >= right) {
        return;
    }

    //ソート
    int mid = (left + right) / 2;
    // cout << "mid : " << mid << endl;
    mergeSort(A, left, mid, count);
    mergeSort(A, mid , right, count);
    merge(A, left, mid, right, count);
    
}


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

    vector<int> S(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> S[i];
    }

    //ソート
    int count = 0; //ソートの交換回数
    mergeSort(S, 0, n, count);

    //出力
    for (int i = 0; i < n; ++i)
    {
        cout << S[i];
        if(i < n-1) {
            cout << " ";
        }
    }
    cout << endl;
    cout << count << endl;


    return 0;
}



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

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

    int east_outers = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'E') east_outers++; 
    }

    int ans = 300000;
    int east_inners = 0;
    int west_outers = 0;
    for (int i = 0; i < N; i++) {
        int opposits;
        if (S[i] == 'E') {
            east_outers--;
            opposits = east_outers + west_outers;
        } else {
            opposits = east_outers + west_outers;
            west_outers++;
        } 
        ans = min(ans, opposits);
    }

    cout << ans << endl;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  uli ans=0ll;
  for(int b=0;b<(1<<(n));b++)if(b&(1<<(n-1))){
    uli v=0;
    uli sum=0;
    for(int i=0;i<n;i++){
      v=v*10+s[i]-'0';
      if(b&(1<<i)){
        sum+=v;
        v=0;
      }
    }
    ans+=sum;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const int INF = (int)1E9;
#define MAXN 200005

int N, M, A[MAXN], cnt[MAXN], cover[MAXN];
int main() {
  cin >> N >> M;
  int ans = N;
  REP(i,1,N+1) cover[i] = i+1;
  REP(i,1,N+1) {
    scanf("%d", A+i);
    cover[A[i]]--;
    if (cover[A[i]] >= 1) {
      if (cnt[cover[A[i]]] == 0) ans--;
      cnt[cover[A[i]]]++;
    }
  }
  while(M--) {
    int x,y;
    scanf("%d%d", &x, &y);
    if (cover[A[x]] >= 1) {
      if (cnt[cover[A[x]]] == 1) ans++;
      cnt[cover[A[x]]]--;
    }
    cover[A[x]]++;

    cover[y]--;
    if (cover[y] >= 1) {
      if (cnt[cover[y]] == 0) ans--;
      cnt[cover[y]]++;
    }
    A[x] = y;
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 3840
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    int w, h, t, p;
    while (cin >> w >> h >> t >> p, w) {
        int zx = 0, zy = 0, mx = w, my = h;
        map<pair<int, int>, int> field;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) field[{i, j}] = 1;
        }
        while (t--) {
            int d, c; cin >> d >> c;
            // d = 1: 左側から c, d = 1: 下側から c 折り曲げる
            if (d == 1) {
                for (int t = 0; t < c; t++) {
                    for (int i = 0; i < my; i++) {
                        field[{i, zx + 2 * c - 1 - t}] += field[{i, zx + t}];
                        field[{i, zx + t}] = 0;
                    }
                }
                zx += c;
                mx = max(mx, zx + 2 * c);
            } else {
                for (int t = 0; t < c; t++) {
                    for (int j = 0; j < mx; j++) {
                        field[{zy + 2 * c - 1 - t, j}] += field[{zy + t, j}];
                        field[{zy + t, j}] = 0;
                    }
                }
                zy += c;
                my = max(my, zy + 2 * c);
            }
        }
        while (p--) {
            int x, y; cin >> x >> y;
            cout << field[{zy + y, zx + x}] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3488
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string S; cin >> S;
    int out = -1;
    for(int i=0;i<S.size();i++){
        int cnt=0;
        for(int j=i;j<S.size();j++){
            if(S[j]=='A' || S[j]=='C' || S[j]=='G' || S[j]=='T'){
                cnt++;
            }else{
                break;
            }
        }
        if(out<cnt)out = cnt;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
int N,M,ans,i;
long long int inu=1,saru=1,wr=1000000007;
scanf("%d%d",&N,&M);
if(N-M>1||M-N>1){printf("%d",0);
return 0;}
if(N-M==1){
  for(i=1;i<=N;i++){
    if(i!=N){
      saru*=i;
    }
    inu*=i;
    if(inu>wr){inu=inu%wr;
    saru=saru%wr;};
  }}
  
else if(M-N==1){
  for(i=1;i<=M;i++){
    if(i!=M){
      inu*=i;
    }
    saru*=i;
    if(saru>wr){inu=inu%wr;
    saru=saru%wr;};
  }

}
else{
  for(i=1;i<=N;i++){
    saru*=i;
    inu*=i;
    if(inu>wr){inu=inu%wr;
    saru=saru%wr;};

}
inu*=2;}

ans=(inu*saru)%wr;
printf("%d",ans);
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

	int n, k;

	cin >> n >> k;

	if (n % 2 == 1) n = n / 2 + 1;
	else n /= 2;

	if (k <= n) Out("YES");
	else Out("NO");
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a;
	scanf("%d", &a);

	char b[a + 1];
	scanf("%s", b);

	if (a % 2 == 1) {
		puts("No");
		return 0;
	}
	for (int i = 0; i < (a/ 2); i++) {
		if (b[0 + i] != b[a/ 2 + i]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;

}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    string s, t;
    cin >> s >> t;
    vector<ll>S(256, 0), T(256, 0);
    for(ll i = 0; i < s.size(); i++){
        S[s[i]]++;
        T[t[i]]++;
    }
    sort(S.begin(), S.end());
    sort(T.begin(), T.end());
    ll flg = 1;
    for(ll i = 0; i < 256; i++){
        if(S[i] != T[i])flg = 0;
    }
    cout << (flg ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 776
N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N)
A = [[] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
for _ in range(len(ans)):
    if _ == 0:
        continue
    print(ans[_])




Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  int n,k;
  cin >> n >> k;
  vector<bool>chack(n,false);
  for(int i=0;i<k;i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
      int a;
      cin >> a;
      a--;
      chack[a]=true;
    }
  }
  int ans = 0;
  for(int i=0;i<n;i++){
    if(!chack[i]) ans++;
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 3632
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        switch(sc.next()){
            case "a":
            case "i":
            case "u":
            case "e":
            case "o":
                System.out.println("vowel");
                break;
            default:
                System.out.println("consonant");
        }
    }
    
 
}

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

int main(){
	int x;
	cin >> x;
	int ans = 1;
	for(int i=2; i*i<=x; i++){
		int prod = i;
		while(prod <= x){
			ans = max(ans, prod);
			prod *= i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int ans = (n-1) / (k-1) + ((n-1) % (k-1) != 0 ? 1 : 0);
		
		for (int i = 0; i < n; i++)
			sc.next();
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 45320
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

ll comb[52][52];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, a, b;
	cin >> n >> a >> b;
	vector<ll> v(n);
	rep(i, n) cin >> v[i];
	sort(all(v)); reverse(all(v));
	ll sum = 0;
	rep(i, a) sum += v[i];
	cout << (double)sum / a << '\n';
	int cnt = 0;
	rep(i, n) if (v[i] == v[a - 1]) cnt++;
	int use = 0;
	rep(i, a) if (v[i] > v[a - 1]) use++;
	comb[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		rep(j, i + 1) {
			comb[i][j] += comb[i - 1][j];
			if (j != 0) comb[i][j] += comb[i - 1][j - 1];
		}
	}
	ll ans = comb[cnt][a - use];
	if (sum == v[a - 1] * a) for (int i = a - use + 1; i <= b - use; i++) ans += comb[cnt][i];
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, a, b; cin >> n >> a >> b;
    string s; cin >> s;
    int x = 0, y = 0;
    FOR(i, 0, n) {
        if (s[i] == 'a') {
            if (x < a + b) {
                cout << "Yes\n";
                ++x;
            }
            else cout << "No\n";
        }
        else if (s[i] == 'b') {
            if (x < a + b && y < b) {
                cout << "Yes\n";
                ++x, ++y;
            }
            else cout << "No\n";
        }
        else cout << "No\n";
    }
}

Measured memory_bytes: 848
MOD = 10**9 + 7

n,k= map(int,input().split())

k = min(n-1,k)

dp = [0] * (k+1) # the number of empty room is i
dp[0] = 1
dp[1] = (n * (n-1)) % MOD

comn = 200000
fact = [1]*(comn+1)
inv = [1]*(comn+1)
ifact = [1]*(comn+1)
for i in range(1,comn+1):
    fact[i] = fact[i-1]*i % MOD
    inv[i] = pow(i,MOD-2,MOD)
    ifact[i] = ifact[i-1]*inv[i] % MOD

def nCr(n,r):
    return fact[n] * ifact[r] * ifact[n-r] % MOD

for i in range(2,k+1):
    dp[i] = (nCr(n,i) * nCr(n-1,i)) % MOD

print(sum(dp) % MOD)



Measured memory_bytes: 66908
package main

import "fmt"

func roundup(a, b int) int {
	if a%b == 0 {
		return a / b
	}
	return a/b + 1
}

func main() {
	var n int
	fmt.Scan(&n)
	xs := make([]int, 5)
	for i := range xs {
		fmt.Scan(&xs[i])
	}

	min := xs[0]
	for _, x := range xs {
		if x < min {
			min = x
		}
	}

	fmt.Println(4 + roundup(n, min))
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
bool cmp(int a,int b)
{return a>b;}
int main()
{
	int m,n,a[1005],i;
	double sum=0.0;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{scanf("%d",&a[i]);
	sum+=a[i];}
	sort(a,a+n,cmp);
	if((double)a[m-1]>=sum/(4*m)) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string s;
int main(){
	cin>>s;
	int t=0,maxn=0;
	if(s[0]=='R') t++,maxn=1;
	for(int i=1;i<s.length();++i){
		if(s[i-1]=='R'&&s[i]=='R') t++;
		else if(s[i]=='R') t=1;
		else t=0;
		maxn=max(maxn,t);
	}
	cout<<maxn<<endl;
	return 0;
} 

Measured memory_bytes: 3588