akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;
using ll = long long;

int main() {
	int k;
	string s;
	cin >> k;
	cin >> s;
	if(s.size() <= k) {
		cout << s << endl;
	} else {
		cout << s.substr(0,k) + "..." << endl;
	}
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int n;

int calc(int x, int y, int z) {
    return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main() {
    cin >> n;
    vector<int> ans(n + 1, 0);
    for (int x = 1; x <= n; x++) {
        for (int y = 1; y <= n; y++) {
            for (int z = 1; z < n; z++) {
                int t = calc(x, y, z);
                if (t > n) {
                    break;
                }
                ans[t] += 1;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3556
S = input()

if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print("Yes")
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
    print("Yes")
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s,t,u ;
	cin >> s >> t >> u ;
	cout << s.at(0) << t.at(0) << u.at(0) << endl ;
}


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

int N, x;
int *A;
long long ans=0;

int main() {

    scanf("%d %d", &N, &x);
    A = malloc(sizeof(int) * N);

    for (int i = 0; i < N; i++) scanf("%d", &A[i]);

    for (int i = 0; i < N - 1; i++) {
        if (A[i] + A[i + 1] > x) {
            ans += A[i] + A[i + 1] - x;
            if (A[i] + A[i + 1] - x > A[i + 1]) {
                A[i + 1] = 0;
            } else {
                A[i + 1] -= A[i] + A[i + 1] - x;
            }
        }
        fprintf(stderr, "%d\n", A[i + 1]);
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 3572
//https://atcoder.jp/contests/dwacon5th-prelims/tasks/dwacon5th_prelims_b

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <stack>
#include <math.h>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second > b.second;
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)
#define BIGNUM (ll(1e18))

int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, K;
    cin >> N >> K;
    vector<ll> a(N);
    vector<ll> s(N+1, 0);
    REP(i, N) {
        cin >> a[i];
        s[i+1] = s[i]+a[i];
    }
    
    vector<ll> beauty;
    REP(i, N) {
        SREP(j, i+1, N+1) {
            ll b = s[j]-s[i];
            beauty.push_back(b);
        }
    }

    ll M = beauty.size();
    ll score = 0;
    REP(i, 64) {
        int bcnt = 0;
        REP(j, M) {
            if((((beauty[j] & score) == score) || score == 0)  && (beauty[j] & (1L << (63-i))))
                bcnt++;
        }
        if (bcnt>=K) {
            score += 1L << (63-i);
        }
    }
    cout << score << endl;
}


Measured memory_bytes: 6512
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_H = 100;
const int MAX_N = MAX_H * MAX_H;
int H, W, N, a[MAX_N];

void solve() {
    int now_c = 0;
    int ans[H][W];
    REP(h, H) {
        if (h % 2 == 0) {
            REP(w, W) {
                if (a[now_c] == 0) now_c++;
                a[now_c]--;
                ans[h][w] = now_c + 1;
            }
        } else {
            REPR(w, W) {
                if (a[now_c] == 0) now_c++;
                a[now_c]--;
                ans[h][w] = now_c + 1;
            }
        }
    }
    REP(h, H) {
        REP(w, W) {
            printf("%d ", ans[h][w]);
        }
        printf("\n");
    }
}

int main() {
    cin >> H >> W >> N;
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	int n;
	cin>>n;
	string str;
	getline(cin,str);
	for(int m = 0; m < n; m++){
		getline(cin,str);
		string nstr;
		int prvIdx=0;
		bool start=false;
		for(int i = 0; i < str.size(); i++){
			if(i+6<str.size()&&str.substr(i,7)=="Hoshino"){
				nstr+="Hoshina";
				i+=6;
			}
			else{
				nstr+=str[i];
			}
			//if(i==str.size()-1){
			//	if(!start){
			//		nstr+=str[i];
			//	}
			//	else{
			//		string ss=str.substr(prvIdx,i-prvIdx+1);
			//		if(ss=="Hoshino"){
			//			nstr+="Hoshina";
			//		}
			//		else
			//			nstr+=ss;
			//	}
			//}
			//else if(((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z'))){
			//	if(!start){
			//		start=true;
			//		prvIdx=i;
			//	}
			//}
			//else{
			//	if(start){
			//		string ss=str.substr(prvIdx,i-prvIdx);
			//		if(ss=="Hoshino"){
			//			nstr+="Hoshina";
			//		}
			//		else{
			//			nstr+=ss;
			//		}
			//		start=false;
			//	}
			//	nstr+=str[i];
			//}

			//if(i==str.size()-1){
			//	string ss=str.substr(prvIdx,str.size()-prvIdx);
			//	if(ss=="Hoshino"){
			//		nstr+="Hoshina";
			//	}
			//	else
			//		nstr+=ss;
			//}
			//else if(!((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z'))){
			//	string ss=str.substr(prvIdx,i-prvIdx);
			//	if(ss=="Hoshino"){
			//		nstr+="Hoshina";
			//	}
			//	else
			//		nstr+=ss;
			//	nstr+=str[i];
			//	prvIdx=i+1;
			//}
		}
		cout<<nstr<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
N=int(input())
array = [0]*4
for i in range(N):
    M=input()
    if M=='AC':
        array[0]+=1
    if M=='WA':
        array[1]+=1
    if M=='TLE':
        array[2]+=1
    if M=='RE':
        array[3]+=1
print('AC','x',str(array[0]))
print('WA','x',str(array[1]))
print('TLE','x',str(array[2]))
print('RE','x',str(array[3]))

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC171B()
{
	int N, K;
	cin >> N >> K;
	vi p(N);
	for (auto& x : p)
		cin >> x;
	sort(p.begin(), p.end());
	int sum = accumulate(p.begin(), p.begin() + K, 0);
	cout << sum << endl;
}
int main()
{
	ABC171B();
	return 0;
}


Measured memory_bytes: 3624
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int M1 = sc.nextInt();
    int D1 = sc.nextInt();
    int M2 = sc.nextInt();
    int D2 = sc.nextInt();

    if (M1 != M2) System.out.println(1);
    else System.out.println(0);
  }
}


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


int main(){
	int n; cin >> n;
	int p[20];
	for (int i = 0; i < n; i++)
		cin >> p[i];

	int a = 0;
	for (int i = 1; i < n - 1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1])a++;
		if (p[i - 1] > p[i] && p[i] > p[i + 1])a++;
	}

	cout << a << endl;

	return 0;
}


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

int main(void){
    int A, B, C, ANS;
    scanf("%d %d %d", &A, &B, &C);
    ANS = C-(A-B);
    if(ANS<0) printf("0\n");
    else printf("%d\n", ANS);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
#define MOD 1000000007
#define FormulaToConvertMicrosecondsToSeconds(duration) duration / 1e+6
#define _CRT_SECURE_NO_DEPRECATE
#define ll                    long long
#define nl                    '\n'                             // NL - sign of new line

#define upperString(str)      transform(str.begin(), str.end(), str.begin(), ::toupper); // make entire string uppercase
#define lowerString(str)      transform(str.begin(), str.end(), str.begin(), ::tolower); // make entire string lowercase

#define ps(x,y)               fixed << setprecision(y) << x     // usage: t=1.1234; cout << ps(t,4); // it means it will print 4 decimal places.

#define eb                    emplace_back
#define sortv(v)              sort(v.begin(), v.end());
#define rsortv(v)             sort(v.rbegin(), v.rend());
#define rev(v)		          reverse(v.begin(), v.end())       // reverse the vector

#define si                    set<int>

#define mii			          std::map <int,int>
#define multimii		      std::multimap <int,int>
#define mss			          map <string, string>
#define w(t)                  unsigned t; cin >> t; while(t--)
mt19937                       rng(chrono::steady_clock::now().time_since_epoch().count());

void solve();
//==================================

bool isPrime(int num) {
	if (num == 1) return false;
	for (int i = 2; i <= sqrt(num); i++) {
		if (num % i == 0) return false;
	}
	return true;
}

ll binarySearch(int a[], int l, int r, int x)
{
	while (l <= r)
	{
		int mid_index = l + (r - l) / 2;

		if (a[mid_index] == x)
			return mid_index;
		else if ( x > a[mid_index])
		{
			l = mid_index + 1;
		}
		else if ( x < a[mid_index])
		{
			r = mid_index - 1;
		}
	}
	return -1;
}

ll fast_power(ll base, ll power) {
	ll result = 1;
	while (power > 0) {

		// if( power % 2 == 1)
		if (power & 1) { // Can also use (power & 1) to make code even faster
			result = (result * base) % MOD;
		}
		base = (base * base) % MOD;

		// power /= 2
		power >>= 1; // Can also use power >>= 1; to make code even faster
	}
	return result;
}

//==================================
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//--------------------------------
	auto t1 = std::chrono::high_resolution_clock::now();

	//int t = 1;
	//cin >> t;
	//while (t--)
	//{

	solve();
	//}



	auto t2 = std::chrono::high_resolution_clock::now();
	auto duration = std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count();

	cerr << "\n\nTime taken : " << FormulaToConvertMicrosecondsToSeconds(duration) << " secs" << nl;
	return 0;
}

void solve() //Task A. Double Cola!!! Two teams composing !
{

	int h, a; cin >> h >> a;

	int c = 0;
	while (h > 0)
	{
		h -= a;
		++c;
	}
	cout << c;

} // !solve


/* TESTS:


*/

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main()
{
double A,B;
scanf("%lf %lf",&A,&B);
if(A>B)
printf("GREATER");
else if(A<B)
printf("LESS");
else if(A==B)
printf("EQUAL");
else
return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int  huru(string x,int d1,int d2,int d3,int d4,int d5,int d6){
	int a,b;
	for(int i = 0;i<x.size();i++){
		if(x.at(i) == 'E'){
			a = d3;
			d3 = d1;
			d1 = d4;
			d4 = d6;
			d6 = a;
		}
		if(x.at(i) == 'S'){
			a = d2;
			d2 = d1;
			d1 = d5;
			d5 = d6; 
			d6 = a;
		}
		if(x.at(i) == 'W'){
			a = d4;
			d4 = d1;
			d1 = d3;
			d3 = d6;
			d6 = a;
		}
		if(x.at(i) == 'N'){
			a = d5;
			d5 = d1;
			b = d6;
			d6 = a;
			a = d2;
			d2 = b;
			d1  =  a;
		}
		a = 0;
	}
		return d1;
	}
int main(){
	int s1,s2,s3,s4,s5,s6;
	cin>>s1>>s2>>s3>>s4>>s5>>s6;
	string x;
	cin>>x;
	
	cout<<huru(x,s1,s2,s3,s4,s5,s6)<<endl;
	return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll h,w,n,A[200000],B[200000],x[3]={-1,0,1},y[3]={-1,0,1},a,b,num[10]={0},sum=0;
    cin>>h>>w>>n;
    rep(i,n) cin>>A[i]>>B[i];
    map<pair<ll,ll>,ll> C;
    rep(i,n)rep(j,3)rep(k,3) C[make_pair(A[i]+x[j],B[i]+y[k])]++;
    for(auto i=C.begin();i!=C.end();++i){
        a=i->first.first,b=i->first.second;
        if(a>1&&a<h&&b>1&&b<w) num[i->second]++;
    }
    rep(i,10) sum+=num[i];
    cout<<(h-2)*(w-2)-sum<<endl;
    rep(i,9) cout<<num[i+1]<<endl;
}

Measured memory_bytes: 59008
import math

n, d = map(int,input().split())
x=[]
ans = 0
y = 0.0

for i in range(n):
    x.append(list(map(int,input().split()))) #リストに加える
    
for i in range(n):
    for j in range(i+1,n): #それより前にリストに入っていたものについて
        y = 0.0
        for k in range(d): #次元数だけループ
            y = y + (x[i][k] - x[j][k])**2 #距離を計算
        if math.sqrt(y).is_integer() == True: #距離が整数なら
            ans = ans + 1 #答えに1を加える

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int sheet[101][101] = {0},i,j,r,c,sum = 0,sum2 = 0;
    
    scanf("%d %d",&r,&c);
    
    for (i = 0; i < r; i++) {
        for (j = 0; j < c; j++) {
            scanf("%d",&sheet[i][j]);
        }
    }
    
    for (i = 0; i < r; i++) {
        for (j = 0; j < c; j++) {
            sum += sheet[i][j];
        }
        sheet[i][c] = sum;
        sum = 0;
    }
    
    for (i = 0; i < c; i++) {
        for (j = 0; j < r; j++) {
            sum += sheet[j][i];
        }
        sum2 += sum;
        sheet[r][i] = sum;
        sum = 0;
    }
    
    sheet[r][c] = sum2;
    
    for (i = 0; i <= r; i++) {
        for (j = 0; j <= c; j++) {
            if (c == j) {
                printf("%d",sheet[i][j]);
                continue;
            }
            printf("%d ",sheet[i][j]);
        }
        printf("\n");
    }
    return 0;

}

Measured memory_bytes: 652
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>

#define INF 1050000000
#define MOD 1000000007

using namespace std;

int main() {
	int n; cin >> n;
	long long int a[n];
	for (int i = 0; i < n; i++) {
		cin >>a[i];
	}
	for (int i = 1; i < n; i++) {
		a[i] += a[i - 1];
	}

	long long int ans = pow(10, 18);

	for (int i = 0; i < n - 1; i++) {
		long long int tmp = abs(a[i] - (a[n - 1] - a[i]));
		ans = min(ans, tmp);
	}

	cout << ans << endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define ok puts("OK");
#define int long long

using namespace std;

const int N = 1005, inf = 1e9 + 7;

int dp[N], n, x, ar[N], Dp[5005], old[5005];

vector <vector <int> > g;

void Do(int v, int p)
{
    for (int j = 0; j <= ar[v]; j++)
        old[j] = Dp[j] = inf;

    old[0] = 0;

    for (auto to : g[v])
    {
        if (to == p) continue;

        for (int j = 0; j <= ar[v]; j++)
        {
            if(j) Dp[j] = Dp[j - 1];

            if ( j >= ar[to] && Dp[j] > old[j - ar[to]] + dp[to] )
                Dp[j] = old[j - ar[to]] + dp[to];

            else if (j >= dp[to] && Dp[j] > old[j - dp[to]] + ar[to] )
                Dp[j] = old[j - dp[to]] + ar[to];
        }
        for (int j = 0; j <= ar[v]; j++)
            old[j] = Dp[j], Dp[j] = inf;
    }
    for (int j = 0; j <= ar[v]; j++)
        dp[v] = min(dp[v], old[j]);
}

void dfs (int v, int p = 0)
{
    if (g[v].size() == 1 && p)
    {
        dp[v] = 0;
        return ;
    }
    for (auto to : g[v])
    {
        if (to != p)
            dfs(to, v);
    }
    Do(v, p);
}

main ()
{
    cin >> n;

    g.resize(n + 1);

    for (int i = 2; i <= n; i++)
    {
        scanf("%lld", &x);
        g[i].pb(x);
        g[x].pb(i);
    }
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &ar[i]);
        dp[i] = inf;
    }
    dfs(1);
    if (dp[1] != inf)
        puts("POSSIBLE");
    else
        puts("IMPOSSIBLE");
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,a,b,i;
    long long int  v[200000];

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



    if(n%2==0)
    {
        for(i=n-1; i>0; i=i-2)
            cout<<v[i]<<" ";
        for(i=0; i<n; i=i+2)
            cout<<v[i]<<" ";
    }
    else
    {
        for(i=n-1; i>=0; i=i-2)
            cout<<v[i]<<" ";
        for(i=1; i<n; i=i+2)
            cout<<v[i]<<" ";
    }


}


Measured memory_bytes: 3712
n = int(input())
h = []
tmp = ["a", "b", "c", "d", "e", "f", "g", "h","i", 
        "j", "k", "l", "m", "n", "o", "p", "q","r",
        "s", "t", "u", "v", "w", "x", "y", "z"]
name = ""

while n != 0:
    mod = n % 26
    h.append(mod)
    n //= 26
    if mod == 0:
        n -= 1
for i in h.__reversed__():
    name += tmp[i - 1]
print(name)


Measured memory_bytes: 9072
#include<stdio.h>

int main()
{
	int W, H;
	int x, y, r;

	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	W -= r, H -= r;
	if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,n):
  dp[i] = min(dp[i-2] + abs(h[i-2]-h[i]), dp[i-1] + abs(h[i-1]-h[i]))
print(dp[n-1])

Measured memory_bytes: 52208
use proconio::input;
use std::f64::consts::PI;

fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }

    let h_theta = 2.0 * PI * (h + m / 60.0) / 12.0;
    let m_theta = 2.0 * PI * m / 60.0;

    let x = length(a * h_theta.cos(), b * m_theta.cos());
    let y = length(a * h_theta.sin(), b * m_theta.sin());

    println!("{}", (x * x + y * y).sqrt());
}

fn length(a: f64, b: f64) -> f64 {
    if a < b {
        return b - a
    } else {
        return a - b
    }
}


Measured memory_bytes: 2984
#include <bits/stdc++.h>
    
#define int long long

using namespace std;
    
    
    
const int MAXN = 200 * 1000 + 23, D = 1000 * 1000 * 1000 + 7;
    
    
    
int b, w, f[MAXN], in[MAXN], se[MAXN], si[MAXN], itp[MAXN], fs;
    
int inv(int x) {
    int y = D - 2, res = 1;
    for (; y; y >>= 1, x = 1ll * x * x % D)
        if (y & 1)
            res = 1ll * res * x % D;
    return res;
}
int ch(int x, int y) { return (x > y? 0: f[y] * in[x] % D * in[y - x] % D); }
    
    
    
    
    
    
    
    

int32_t main() {
    cin >> b >> w;
    f[0] = 1;
    itp[0] = inv(1);
    fs = inv(2);
    for (int i = 1; i < MAXN; i++)
        f[i] = 1ll * f[i - 1] * i % D;
    for (int i = 1; i < MAXN; i++)
        itp[i] = itp[i - 1] * fs % D;
    in[MAXN - 1] = inv(f[MAXN - 1]);
    for (int i = MAXN - 2; ~i; i--)
        in[i] = 1ll * in[i + 1] * (i + 1) % D;
    for (int i = 1; i <= b + w; i++)
        se[i] = (se[i - 1] + ch(w - 1, i - 1) * itp[i] % D) % D, si[i] = (si[i - 1] + ch(b - 1, i - 1) * itp[i] % D) % D;
    for (int i = 0; i < b + w; i++)
        cout << (fs * ((1 - se[i] - si[i] + 5 * D) % D) + se[i]) % D << '\n';
    return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    int N,F,S;
    F=0;
    S=0;
    int A[2000005];
    cin  >> N;
    rep(i,N){
        cin >> A[i];
        if(A[i]>F){
            F=A[i];
        }
        else if(A[i]>S){
            S=A[i];
        }
    }
    rep(i,N){
        if(A[i]==F){
            cout << S << endl;
        }
        else{
            cout << F << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <math.h>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 1e5+1;
const ll mod = 1e9+7;


int main(){

    FASTIO;
    PRECISION;

    ll a,b,n;
    cin>>a>>b>>n;

    ll r = min(b-1,n);

    cout<<((a*r)/b)<<"\n";
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<iomanip>
#include<boost/multi_array.hpp>

typedef unsigned long long uint64;
typedef long long int64;
template<uint64 Mod>class mod_t
{
	uint64 val;
public:
	static constexpr auto mod = Mod;
	mod_t(uint64 v) :val(v%Mod)
	{

	}
	mod_t(int64 v) :val(v%Mod)
	{

	}
	mod_t(int v = 0) : val(v%Mod)
	{

	}
	mod_t(unsigned v) :val(v%Mod)
	{

	}

	uint64 operator*()const
	{
		return val;
	}
};
template<uint64 Mod>mod_t<Mod> operator+(mod_t<Mod> lhs, mod_t<Mod> rhs)
{
	return (*lhs + *rhs);
}
template<uint64 Mod>mod_t<Mod> operator+(mod_t<Mod> lhs, int rhs)
{
	return (*lhs + rhs);
}
template<uint64 Mod>mod_t<Mod> operator+(int lhs, mod_t<Mod> rhs)
{
	return (lhs + *rhs);
}
template<uint64 Mod>mod_t<Mod> operator-(mod_t<Mod> lhs, mod_t<Mod> rhs)
{
	return (*lhs - *rhs + Mod);
}
template<uint64 Mod>mod_t<Mod> operator-(mod_t<Mod> lhs, int rhs)
{
	return (*lhs - rhs + Mod);
}
template<uint64 Mod>mod_t<Mod> operator-(int lhs, mod_t<Mod> rhs)
{
	return (lhs - *rhs + Mod);
}
template<uint64 Mod>mod_t<Mod> operator*(mod_t<Mod> lhs, mod_t<Mod> rhs)
{
	return (*lhs * *rhs);
}
template<uint64 Mod>mod_t<Mod> operator*(mod_t<Mod> lhs, int rhs)
{
	return (*lhs * rhs);
}
template<uint64 Mod>mod_t<Mod> operator*(int lhs, mod_t<Mod> rhs)
{
	return (lhs * *rhs);
}

typedef mod_t<1000000007> mod197;
template<class T>T pow(T val, int v)
{
	return 
		v == 0 ? T(1) :
		v == 1 ? val :
		v == 2 ? val*val :
		v % 2 == 0 ? pow(pow(val, v / 2), 2) :
		pow(pow(val, v / 2), 2)*val;
}

void Main();
int main()
{
	std::cin.sync_with_stdio(false);
	std::cout << std::setprecision(std::numeric_limits<long double>::digits10 + 1);
	Main();
}

void Main()
{
	int H, W, A, B;
	std::cin >> H >> W >> A >> B;
	std::vector<mod197> first;
	std::vector<mod197> second;
	first.emplace_back(1);
	second.emplace_back(1);
	for (int k = 1;k < W;++k)
	{
		auto x = k + H - A - 1;
		auto y = k + A - 1;
		auto inv = pow(mod197(k), mod197::mod - 2);
		first.emplace_back(x*first.back()*inv);
		second.emplace_back(y*second.back()*inv);
	}
	mod197 ret;
	for (int k = B;k < W;++k)
	{
		ret = ret + (first[k] * second[W - k - 1]);
	}
	std::cout << *ret << std::endl;
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back

#define N 100'005
int n, m;
vi c[N]; // ikisaki
vi e[N]; // oya
int d[N]; // nyuujihen count
int ind = 0;
int p[N]; // topsort vertex -> order
int ans[N]; // ans

void dfs(int a){
	if(d[a]) return;
	p[a]=ind++;
	for(int &i : c[a]){
		d[i]--;
		dfs(i);
	}
}

int main(){
	scanf("%d%d", &n, &m);
	REP(i, n-1+m){
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		c[a].PB(b);
		d[b]++;
		e[b].PB(a);
	}
	REP(i, n){
		dfs(i);
		if(ind==n) break;
	}
	fill(ans, ans+N, -1);
	REP(i, n){
		for(int &j: e[i]){
			if(!~ans[i] || p[ans[i]] < p[j]){
				ans[i] = j;
			}
		}
	}
	// REP(i, n) printf("%2d ", i); printf("\n");
	// REP(i, n) printf("%2d ", p[i]); printf("\n");
	REP(i, n) printf("%d\n", ans[i]+1);
}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define grep(i,u) for (int i = head[u],v = e[i].v; i; v = e[i = e[i].nxt].v)
#define il inline
#define LL long long
#define ULL unsigned LL
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<LL,LL>
#define fi first
#define se second
using namespace std;
il int read() {
	int res = 0,f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -f; ch = getchar();}
	while (isdigit(ch)) {res = res*10+ch-'0'; ch = getchar();} return res*f;
}
namespace qiqi {
	const int N = 5005,P = 1e9+7; int n,ecnt,head[N],f[N][N],g[N],h[N],siz[N]; struct Edge {int v,nxt;} e[N<<1]; il void add(int u,int v) {e[++ecnt] = (Edge){v,head[u]}; head[u] = ecnt;}
	void dfs(int u,int fa) {
		f[u][siz[u] = 1] = 1; grep(k,u) if (v != fa) {
			dfs(v,u); rep(i,1,siz[u]) {h[i] = f[u][i]; f[u][i] = 0;}
			rep(i,0,siz[u]) rep(j,0,siz[v]) f[u][i+j] = (f[u][i+j]+1LL*h[i]*f[v][j]%P)%P; siz[u] += siz[v];
		}
		rep(i,1,siz[u]>>1) f[u][0] = (f[u][0]-1LL*f[u][i<<1]*g[i]%P)%P;
	}
	void main() {n = read(); g[0] = 1; rep(i,0,n>>1) g[i+1] = 1LL*(i<<1|1)*g[i]%P; rep(i,1,n-1) {int u = read(),v = read(); add(u,v); add(v,u);} dfs(1,0); printf("%d\n",(-f[1][0]+P)%P);}
}
int main() {qiqi::main(); return 0;}

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

int dice[100][6];

bool rotateAndCheck(int d1, int d2, int s0, int s1, int s2){
	if(
		dice[d1][0] == dice[d2][s0-1] &&
		dice[d1][1] == dice[d2][s1-1] &&
		dice[d1][2] == dice[d2][s2-1] &&
		dice[d1][3] == dice[d2][6-s2] &&
		dice[d1][4] == dice[d2][6-s1] &&
		dice[d1][5] == dice[d2][6-s0]
	){
		return true;
	}
	return false;
}
int main(){
	int n;
	cin >> n;
	
	for(int i=0; i<n; i++)
		for(int j=0; j<6; j++) cin >> dice[i][j];
	
	for(int i=0; i<n-1; i++){
		for(int j=i+1; j<n; j++){
			if(
				rotateAndCheck(i, j, 1, 2, 3) ||
				rotateAndCheck(i, j, 1, 3, 5) ||
				rotateAndCheck(i, j, 1, 4, 2) ||
				rotateAndCheck(i, j, 1, 5, 4) ||
				rotateAndCheck(i, j, 2, 1, 4) ||
				rotateAndCheck(i, j, 3, 1, 2) ||
				rotateAndCheck(i, j, 4, 1, 5) ||
				rotateAndCheck(i, j, 5, 1, 3) ||
				rotateAndCheck(i, j, 2, 3, 1) ||
				rotateAndCheck(i, j, 3, 5, 1) ||
				rotateAndCheck(i, j, 4, 2, 1) ||
				rotateAndCheck(i, j, 5, 4, 1) ||
				rotateAndCheck(i, j, 2, 4, 6) ||
				rotateAndCheck(i, j, 3, 2, 6) ||
				rotateAndCheck(i, j, 4, 5, 6) ||
				rotateAndCheck(i, j, 5, 3, 6) ||
				rotateAndCheck(i, j, 2, 6, 3) ||
				rotateAndCheck(i, j, 3, 6, 5) ||
				rotateAndCheck(i, j, 4, 6, 2) ||
				rotateAndCheck(i, j, 5, 6, 4) ||
				rotateAndCheck(i, j, 6, 2, 4) ||
				rotateAndCheck(i, j, 6, 3, 2) ||
				rotateAndCheck(i, j, 6, 4, 5) ||
				rotateAndCheck(i, j, 6, 5, 3)
			){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

int main(){
  int n,m,i,s;
  cin >> n >> m;
  if(n>=m){
    cout << 0 << endl;
    return 0;
  }
  vector<int> x(m);
  for(i=0;i<m;i++){
    cin >> x.at(i);
  }
  sort(x.begin(),x.end());
  
  vector<int> d(m-1);
  for(i=0;i<m-1;i++){
    d.at(i)=x.at(i+1)-x.at(i);
  }
  sort(d.begin(),d.end());
  
  s=0;
  for(i=0;i<m-n;i++){
    s += d.at(i);
  }
  cout << s << endl;
}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11;
#define LL long long
LL ans, now;
int n, m;
LL tag[N], add, tong[N], a[N], cha[N];
int main(){
    //freopen("arc077e.in", "r", stdin);
    //freopen("arc077e.out", "w", stdout);
    cin>>n>>m;
    for(int i = 1;i <= n; i++){
        scanf("%lld", &a[i]);
        if(i > 1){
            cha[i] = a[i] - a[i-1] + (a[i] - a[i-1] < 0 ? m : 0);
            ans += cha[i];
            if(cha[i] == 1)continue;
            int x = a[i] + 2 - cha[i];
            int y = a[i] + 1;
            if(y > m)y = 1;
            if(x <= 0)x += m;
            if(a[i] < cha[i] - 1){
                tag[1]--;
                tong[1] += a[i] - cha[i];
                if(y > 1){
                    tong[y] += cha[i];
                    tag[y]++;
                }
                tong[x]--;
                tag[x]--;
            }
            else{
                tong[x]--;
                tag[x]--;
                if(y > x)tong[y] += cha[i], tag[y]++;
            }
            //printf("i=%d cha=%d x=%d y=%d\n", i, cha[i], x, y);
        }
    }
    now = ans;
    for(int i = 1;i <= m; i++){
        now += add + tong[i];
        add += tag[i];
        ans = min(ans, now);
        //printf("i=%d tong=%d tag=%d now=%d\n", i, tong[i], tag[i], now);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int gcd(int x,int y);
int main(){
  int x,y,a,b;
  while(cin >>x>>y){
    a = gcd(x,y);
    b = x/a*y;
    cout <<a<<" "<<b<<endl;
  }
  return 0;
}
int gcd(int x,int y){
  if(!x){return y;}
  return gcd(y%x,x);
}

Measured memory_bytes: 1160
import bisect

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

count = 0
for i in range(N-1,1,-1):
    for j in range(i-1,0,-1):
        count += max(0, j - bisect.bisect_right(L,L[i]-L[j]))

print(count)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s, t;

int main() {
	cin >> s >> t;
	
	sort(ALL(s));
	sort(ALL(t));
	reverse(ALL(t));
	
	cout << (s < t ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

ab.sort(key=lambda x: x[0])
index = 0
for i in range(n):
  index += ab[i][1]
  if index >= k:
    ans = ab[i][0]
    break

print(ans)

Measured memory_bytes: 29144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  string S; ll K;
  cin >> S >> K;
  if (K <= S.length()) {
    auto r = true;
    REP(i, K) {
      r = r && S[i] == '1';
    }
    if (r) {
      println(1);
      return 0;
    }
  }
  for (auto c : S) {
    if (c != '1') {
      println(c - '0');
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int n, m;
    long long num = 1e9+7;

    cin >> n >> m;
    vector<long long> fib(n+1);
    vector<bool> is_not_breaked(n, true);
    vector<int> a(m);

    for (int i = 0; i < m; ++i)
    {
        cin >> a[i];
        is_not_breaked[a[i]] = false;
    }

    if (is_not_breaked[0])
        fib[0] = 1;
    else
        fib[0] = 0;
    if (is_not_breaked[1])
        fib[1] = 1;
    else
        fib[1] = 0;

    for (int i = 2; i <= n; ++i) {
        if (is_not_breaked[i]) {
            fib[i] = fib[i - 1] + fib[i - 2];
            fib[i] %= num;
        }
        else {
            fib[i] = 0;
        }
    }

    cout << fib[n] % num << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    string s, t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;

    if(u == s){
        a--;
    }
    else{
        b--;
    }
    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
// atcoder/abc143/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

const int N = 300 + 5;
lli g[N][N];
lli cost[N][N];
const lli inf = 1LL << 60;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m, L;
  while (cin >> n >> m >> L) {
    fill(&g[0][0], &g[N - 1][N - 1] + 1, inf);
    fill(&cost[0][0], &cost[N - 1][N - 1] + 1, inf);
    for (int i = 0; i < m; ++i) {
      int a, b, c;
      cin >> a >> b >> c;
      --a;
      --b;
      g[a][b] = g[b][a] = c;
    }

    for (int k = 0; k < N; ++k) {
      for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
          setmin(g[i][j], g[i][k] + g[k][j]);
        }
      }
    }

    for (int src = 0; src < n; ++src) {
      queue<int> q;
      cost[src][src] = 0;
      for (q.push(src); q.size(); q.pop()) {
        int curr = q.front();
        for (int next = 0; next < n; ++next) {
          if (g[curr][next] <= L && (cost[src][next] == inf)) {
            cost[src][next] = cost[src][curr] + 1;
            q.push(next);
          }
        }
      }
    }

    int q;
    cin >> q;
    while (q--) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      cout << (cost[a][b] < inf ? cost[a][b] - 1 : -1) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
int N;
int X[101];
int main(){
    int ans = 0;
    int sum = 0;
    cin >> N;
    for (int i=0;i<N;i++){
        cin >> X[i];
        sum += X[i];
    }
    int mean = (sum + N/2)/N;
    for (int i=0;i<N;i++){
        ans += (mean- X[i])*((mean) - X[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

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

    vector<ll> v(N, 0);
    for(int i = 0; i < N; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    ll min_diff = 9999999999999;
    for(int i = 0; i < N - (K - 1); i++) {
        min_diff = min(min_diff, v[i + K - 1] - v[i]);
    }
    cout << min_diff << endl;
}

Measured memory_bytes: 1024
import bisect

N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for bi in range(1,N-1):
  for ai in range(0,bi):
    ci = bisect.bisect(L,L[bi]+L[ai]-1) - 1
    if bi<ci:
      ans += ci-bi
print(ans)

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  ll ans = 0;
  rrep(i, n-k) {
    int b = k+i;
    ans += n / b * i;
    if (n % b) {
      int remain = n % b - (k == 0 ? 0 : k-1);
      if (remain > 0) ans += remain;
    }
  }
  std::cout << ans << "\n";
}


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

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    int N,ans=0;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for(int i = 1; i < N; i++) {
        if(a[i] == a[i-1]) {
            ans++;
            i++;
        }
    }
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

int main(){
	ll n,k;cin>>n>>k;
	vector<ld>p(n);
	vector<ld>sum(n+1,0);
	rep(i,n){
		cin>>p[i];
		sum[i+1]=sum[i]+p[i];
	}
	ld ans=0;
	rep(i,n){
		if(i+k>n)continue;
		ans=max(ans,((sum[i+k]-sum[i])+k)/2);
	}
	cout<<fixed;
	cout<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 6528
s=input()
s1=int(s[0:2])
s2=int(s[2:4])
if 1<=s1<=12 and 1<=s2<=12:
    print("AMBIGUOUS")
elif 1<=s1<=12:
    print("MMYY")
elif 1<=s2<=12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string S;
    cin >> S;

    //文字列の後ろから比較していく
    reverse(ALL(S));

    ll index = 0;
    while (index < SIZE(S))
    {
        if (S.substr(index, 5) == "maerd" || S.substr(index, 5) == "esare")
        {
            index += 5;
        }
        else if (S.substr(index, 6) == "resare")
        {
            index += 6;
        }
        else if (S.substr(index, 7) == "remaerd")
        {
            index += 7;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 3728