akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <stack>
using namespace std;

int main()
{
    stack<int> S;
    string str;
    int a, b;

    while (cin >> str)
    {
        if (str[0] == '+')
        {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a + b);
        }
        else if (str[0] == '-')
        {
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a - b);
        }
        else if (str[0] == '*')
        {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a * b);
        }
        else
        {
            S.push(stoi(str));
        }   
    }

    cout << S.top() << endl;

    return 0;
}


Measured memory_bytes: 3148
#include <iostream>

int Combination(int n, int p){
    long ans = 1, P = 1, tmp = 1;
    for(auto i = 0; i < p; i++){
        ans *= n;
        P *= tmp;
        n--;
        tmp++;
    }

    return ans / P;
}

int main(){
    int N, M;

    std::cin >> N >> M;

    int ans = Combination(N, 2) + Combination(M, 2);

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
i = 0
n = gets
while line = gets
  if i == 3
    break
  end
  if line.split(' ').map(&:to_i).uniq.size == 1
    i += 1
  else
    i = 0
  end
end

if i == 3
  puts "Yes"
else
  puts "No"
end


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

int main(){
    int a,b,c,x,y,a1,a2,a3,ans;
    cin >> a >> b >> c >> x >> y;
    int m = min(x,y);
    a1 = c*2*m+a*(x-m)+b*(y-m);
    a2 = a*x+b*y;
    a3 = max(x,y)*2*c;
    ans = min(a1,a2);
    cout << min(ans,a3) << endl;
}

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

//std::priority_queue<std::pair<long, int>, std::vector<int>, std::greater<int>> pq;

int main(){
    int n, m;
    std::cin >> n >> m;
    std::vector<std::pair<unsigned long long, unsigned long long>> vec;
    for(int i = 0; i < n; i++){
        long a, b;
        std::cin >> a >> b;
        vec.push_back({a, b});
    }
    unsigned long long ans = 0;
    std::sort(vec.begin(), vec.end());
    for(auto i : vec){
        if(m < i.second){
            ans += i.first * m;
            m = 0;
        }else{
            ans += i.first * i.second;
            m -= i.second;
        }
        if(!m){
            std::cout << ans << std::endl;
            return 0;
        }
    }


}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1<<20)
#define white 0
#define gray 1
#define black 2

int n;
vector<pair<int,int> > W[10000]; 
int color[10000],d[10000],p[100];

void dijkstra(int s) {
  d[s] = 0;
  priority_queue<pair<int,int> > PQ;
  PQ.push(make_pair(0,s));

  while(!PQ.empty()) {
    pair<int,int> f = PQ.top();PQ.pop();
    int u = f.second;
    color[u] = black;

    if(d[u] < f.first * (-1)) continue;

    for(int i = 0;i < W[u].size();i++) {
      int v = W[u][i].first;
      if(color[v] == black) continue;
      if(d[v] > d[u] + W[u][i].second) {
        d[v] = d[u] + W[u][i].second;
        PQ.push(make_pair(d[v] * (-1),v));
      }
    }
  }

  for(int i = 0;i < n;i++) {
    cout << i << " " << d[i] << endl;
  }
}

int main() {

  cin >> n;
  

  for(int i = 0;i < n;i++) {
    int u,k;
    cin >> u >> k;
    color[i] = white;
    d[i] = INF;
    for(int j = 0;j < k;j++) {
      int v,c;
      cin >> v >> c;
      W[u].push_back(make_pair(v,c));
    }
  }

  dijkstra(0);

}



Measured memory_bytes: 7988
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,v;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  for(i=1;i<=n;i++){
v = A[i];
j=i-1;
while(j>=0 && A[j]>v){
A[j+1] = A[j];
j--;
A[j+1] = v;
}
trace(A,n);
}

  return 0;
}

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

main(){
  int X,Y,i;
  i=0;
  cin >> X >> Y;
  while(i<X+1){
    if(2*i+4*(X-i)==Y){
      cout << "Yes" <<endl;
      i=X+1;
    }
    if(i==X){
      cout << "No" <<endl;
    }
    i++;
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int arr[100005]={0};
int dp[100005]={0};
bool is_completed[100005]={0};
int dynamic(int a)
{
    if(a<2)
        return dp[a];
    else if(is_completed[a]==true)
    {
        return dp[a];
    }
    else
    {
        is_completed[a]=true;
        dp[a]=min(dynamic(a-1)+abs(arr[a]-arr[a-1]),dynamic(a-2)+abs(arr[a]-arr[a-2]));
        return dp[a];
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    is_completed[0]=is_completed[1]=true;
    cout<<dynamic(n-1);
}


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

#pragma warning(disable:4996)
using namespace std;


int main() {
	int H,W;cin>>H>>W;
	vector<int>as(H);
	for(int y=0;y<H;++y)cin>>as[y];
	sort(as.begin(),as.end(),greater<int>());
	for (int x = 0; x < W; ++x) {
		int k;cin>>k;
		for (int j = 0; j < k; ++j) {
			as[j]--;
		}
		sort(as.begin(),as.end(),greater<int>());
	}
	if (all_of(as.begin(), as.end(), [](const int a) {return a == 0; })) {
		cout<<1<<endl;
	}
	else {
		cout<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num;
		while ((num = in.nextInt()) != 0) {
			long ans = 0;
			for (int i = 27; i >= 0; i -= 3) {
				int v = Integer.rotateRight(num, i) & 7;
				if (v >= 4) {
					v++;
					if (v >= 6) {
						v++;
					}
				}
				ans = ans * 10 + v;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 47300
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    string S;
    cin >> S;
    int k=0;
    REP(i,S.size()){
        if(S[i]=='C' && (k%2==0)){
            k++;
        }
        if(S[i]=='F' && ((k/2)%2==0) && (k%2==1)){
            k+=2;
        }
    }
    //cout << k << endl;
    
    if(k==3){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
llint f(int x, vector<llint> &s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	return  s[x] = f(x - 1, s) + f(x - 2, s);
	
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



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

// mod. m での a の逆元 a^{-1} を計算するよ！
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;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {
	int x = 0;
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
	cout << x << endl;
}
void press(string& v) { v.erase(unique((v).begin(), (v).end()), v.end()); }

llint min(llint a, llint b) {
	if (a < b)return a;
	return b;
}
llint max(llint a, llint b) {
	if (a < b)swap(a, b);
	return a;
}
llint p(int n) {
	if(n==1)return 1;
	return n * p(n - 1);
}

int main() {
	int n;
	int ans = 0;
	cin >> n;
	hei(llint) a(100003,0);
	rep(i, 0, n) {
		int s;
		cin >> s;
		a[s]++;
		a[s + 1]++;
		a[s + 2]++;
	}
	rep(i, 0, 100003) {
		if (ans < a[i])ans = a[i];
	}
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

int main() {
  int n,k,L[100];
  cin >> n >> k;
  for(int i = 0; i < n; i++) 
    cin >> L[i];
  
  sort(L,L+n);
  int sum = 0;
  for(int i = n-1; i >= n-k; i--)
    sum += L[i];

  cout << sum << endl;
}

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

int main() {
	int n, m,A[100][100],b[100];
	cin >> n >> m;
	for(int i=0;i<n;i++)
		for (int s = 0; s < m; s++) {
			int e;
			cin >> e;
			A[i][s] = e;
		}
	for (int s = 0; s < m; s++) {
		int w;
		cin >> w;
		b[s] = w;
	}
	for (int i = 0; i < n; i++) {
		int c=0;
		for (int t = 0; t < m; t++) {
			c += A[i][t] * b[t];
		}
		cout << c << endl;
	}
	return 0;
}

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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li l[1010];

int main() {
	string s;
	cin >> s;
	stack<char> stk;
	rep(i, sz(s)) {
		if (s[i] == '1') {
			stk.push(s[i]);
		} else if (s[i] == '0') {
			stk.push(s[i]);
		} else {
			if (!stk.empty())stk.pop();
		}
	}
	string res = "";
	while (!stk.empty()) {
		res = stk.top() + res;
		stk.pop();
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import numpy as np


#@profile
def solve(n, ax):
    substract_ax_from_i = []

    for i in range(n):
        substract_ax_from_i.append(ax[i]-i-1)
    substract_ax_from_i.sort()
    med = int(np.median(substract_ax_from_i))
    ans = sum(list(map(lambda x: abs(x-med), substract_ax_from_i)))

    return ans


if __name__ == '__main__':
    n = int(input())
    ax = list(map(int, input().split()))
    print(solve(n, ax))


Measured memory_bytes: 37444
#include<iostream>
#include<string>
using namespace std;
int main(){
 int a,b;
 cin>>a>>b;
 string s;
 cin>>s;
 int cnt=0;

 for(int i=0;i<a;i++){
  if(s.at(i)!='-'){
   cnt++;
  }
 }
 if(s.at(a)=='-'){
  cnt++;
 }
 for(int i=a+1;i<a+b+1;i++){
  if(s.at(i)!='-'){
   cnt++;
  }
 }
 if(cnt==a+b+1){
  cout<<"Yes"<<endl;
 }
 else{
  cout<<"No"<<endl;
 }
}
 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 100000
using namespace std;

int main(){
  int a, b; cin >> a >> b;
  if(a&1 && b&1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++) cin >> p[i];
    sort(p.begin(), p.end());
    p[n-1] /= 2;
    int sum = 0;

    for(int a : p) {
        sum += a;
    }
    cout << sum << endl;
}



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

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

    int n;
    cin >> n;
    string s;
    int ans = 0;
    cin >> s;
    for (int i = 0; i < n - 2; i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
  int cnt=0;
  char S[1001], T[1001];
  scanf("%s %s", S, T);
  int len1=strlen(S);
  int len2=strlen(T);
  int min=len2;
  for(int i=0; i<=len1-len2; i++){
    cnt=0;
    for(int j=i; (j-i)<len2; j++) {
    	if(S[j]!=T[j-i]){
      		cnt++;
        }
    }
    if(cnt<min)min=cnt;
  }
  printf("%d", min);
  return 0;
}

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

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

  for(i = 0; i < N; i++){
    cin >> S;
    
    if(S == "Y"){ // Yが出たらFourが確定
      break;
    }
  }
  if(S == "Y"){
    cout << "Four" << endl;
  } else{
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, K, C;
    string S;
    cin >> N >> K >> C >> S;

    vector<int> constraints_backward(N); 
    int must = K;
    int k = K+1, last_k_idx = N;
    FORR(i, N-1, 0) {
        if(S[i] == 'o') {
            if(last_k_idx == N || i < last_k_idx - C) {
                // constraints_backward[i] = constraints_backward[i + C] - 1;
                constraints_backward[i] = --k;
                last_k_idx = i;
            } else {
                constraints_backward[i] = k;
            } 
        }
    }

    vector<int> constraints_forward(N);
    k = 0;
    int first_k_idx = -1;
    FOR(i, 0, N-1) {
        if(S[i] == 'o') {
            if(i > first_k_idx + C || first_k_idx == -1) {
                constraints_forward[i] = ++k;
                first_k_idx = i;
            } else {
                constraints_forward[i] = k;
            }
       }
    }

    vector<vector<int> > ans(K+1);
    REP(i, N) {
        if(S[i] == 'o' && constraints_backward[i] > 0 && constraints_backward[i] == constraints_forward[i])
            ans[constraints_backward[i]].push_back(i);
    }

    FOR(k, 1, K) {
        if(ans[k].size() == 1) cout << ans[k][0] + 1 << endl;
    }

    return 0;
}

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

int main(){
  int n,k;
  string s;
  cin>>n >>s >>k;
  char e=s[k-1];
  
  for(int i=0;i<n;i++){
    if(s[i]==e){
      cout<<e;
    }else{
      cout<<'*';
    }
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) cerr << #A << " = "; for (int i=1; i<=n; ++i) cerr << A[i] << ' '; cerr << '\n';
#define PR0(A, n) cerr << #A << " = "; for (int i=0; i<n; ++i) cerr << A[i] << ' '; cerr << '\n';

const int maxn = 52;
const int inf = 1e9;

int n, a[maxn], b[maxn], f[maxn];
bool ok[maxn];

int calc(int u, int v) {
	//debug(u); debug(v);
	if (u<v)
		return inf;
	if (u==v)
		return 0;
	f[u] = inf;
	for (int i=1; i<=50; ++i) {
		if (u%i==u)
			continue;
		if (ok[i])
			f[u] = min(f[u], calc(u%i, v));
		else
			f[u] = min(f[u], max(i, calc(u%i, v)));
	}
	return f[u];
}

int main() {
	//freopen("data.inp", "r", stdin);
	//freopen("data.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i=1; i<=n; ++i)
		cin >> a[i];
	for (int i=1; i<=n; ++i) 
		cin >> b[i];
	int64_t res = 0;
	for (int i=49; i>0; --i) {
		for (int j=1; j<=n; ++j) {
			memset(f, 0, sizeof(f));
			int tmp = calc(a[j], b[j]);
			if (tmp==1e9) {
				cout << -1;
				return 0;
			}
			if (calc(a[j], b[j])==i)
				ok[i] = true;
		}
		if (ok[i])
			res += 1LL<<i;
	}
	cout << res;
}

Measured memory_bytes: 256
import math
n = int(input())
v1 = map(float, input().split())
v2 = map(float, input().split())

v = [abs(x - y) for (x,y) in zip(v1, v2)]

d1 = sum(v)
d2 = math.sqrt(sum([x**2 for x in v]))
d3 = math.pow(sum([x**3 for x in v]), 1.0/3.0)
d4 = max(v)

print(d1)
print(d2)
print(d3)
print(d4)


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    string s; cin >> s; int n = s.size();
    string t = s; reverse(all(t));

    bool f = true;
    if(s != t) f = false;
    if(s.substr(0, (n-1)/2) != t.substr((n+1)/2)) f = false;
    if(s.substr((n+1)/2) != t.substr(0, (n-1)/2)) f = false;
    yn(f);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn = 2e5 + 200;

int c[maxn], a[maxn];

int cmp(int a, int b)
{
	return a>b;
}

int main()
{
	int N, K;
	while (scanf("%d%d", &N, &K) == 2)
	{
		memset(c, 0, sizeof(c));
		int t = 0,m=0;
		for (int i = 0; i<N; i++) {
			scanf("%d", &a[i]);
			c[a[i]]++;
			m = max(m, a[i]);
		}
		sort(c, c + m+1,cmp);
		for (int i = 0; i <= m; i++) {
			if (!c[i]) {
				t = i;
				break;
			}
		}
		if (K >= t) printf("0\n");
		else {
			int ans = 0;
			for (int i = K; i <t;i++)
				ans += c[i];
			printf("%d\n", ans);
		}
	}
	return 0;
}


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

int main() {

    int n;
    int min_num;
    long long int sum = 1;
    cin >> n;

    cin >> min_num;

    for(int i = 2; i <= n; ++i) {

        int num;
        cin >> num;

        if(min_num >= num)
            sum++;

        min_num = min(min_num, num);


    }

    cout << sum << endl;

    return 0;

}

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

signed main(void)
{
	int n, m, k, ans;
	ll sum;
	cin >> n >> m >> k;	
	vector<ll> a(n + 1, 0), b(m + 1, 0);
	a[0] = b[0] = 0;
	for (int i = 1; i <= n; i++)
	{
		int A;
		cin >> A;
		a[i] = A;
	}
	for (int i = 1; i <= m; i++)
	{
		int B;
		cin >> B;
		b[i] = B;
	}
	rep(i, n) a[i + 1] += a[i];
	rep(i, m) b[i + 1] += b[i];
	ans = 0;
	rep(i, n + 1)
	{
		sum = a[i];
		if (sum > k) continue;
		int lo, hi;
		lo = 0; hi = m + 1;
		while (hi - lo > 1)
		{
			int mid = (hi + lo) / 2;
			if ((ll)sum + b[mid] > k)
				hi = mid;
			else
				lo = mid;
		}
		ans = max(lo + i, ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6332
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	double ans;
	int n, k, su=0, ma=-1;
	vector<int> v;

	cin>> n >> k;
	v.resize(n);
	for(int i=0;i<n;i++) cin>> v[i];

	for (int i = 0;i < k;i++) su += v[i];
	ma = su;

	for (int i = k;i < n;i++) {
		su += v[i];
		su -= v[i - k];
		ma = max(ma, su);
		//cout << su << endl;
	}

	ans = (ma + k)/2.0;

	cout << fixed << setprecision(8);
	cout<< ans << endl;


}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)

int main() {
	ll x; cin >> x;
	ll ans = 0;
	rep(i, 0, 100000) {
		if (x <= i * (i + 1) / 2) {
			ans = i;
			break;
		}
	}

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

Measured memory_bytes: 256
###
### atcorder test program
###

import sys

### math class
class math:
    ### pi
    pi = 3.14159265358979323846264338

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Prime number search
    def Pnum(self, a):
        if a == 1: return False
        for i in range(2,int(a**0.5)+1):
            if a % i == 0:
                return False
        return True

    ### Circle area
    def caria(self, r):
        return r*r*self.pi

math = math()

### input sample
#i = input()
#A, B, C = [x for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

#A, B, C = [int(x) for x in input().split()]

def get_input():
  N = []
  while True:
    try:
      N.append(input())
      #N.append(int(input()))
    except EOFError:
      break
  return N
 
N = get_input()

for S in N:
    i = 0
    while True:
        if i >= len(S):
            break
        if (S[i]=='@'):
            for j in range(int(S[i+1])):
                print(S[i+2], end='')
            i += 3
        else:
            print(S[i], end='')
            i += 1
        
    print()








Measured memory_bytes: 5632
N,K,Q = map(int,input().split())
A = list(map(int,input().split()))
SA = sorted(A)

def calc_max_a(min_a):
    cands = []
    seq = 0
    for i,a in enumerate(A):
        if a < min_a:
            if seq >= K:
                cands += sorted(A[i-seq:i])[:seq-K+1]
            seq = 0
        else:
            seq += 1
    if seq >= K:
        cands += sorted(A[-seq:])[:seq-K+1]
    if len(cands) < Q:
        return -1
    else:
        return sorted(cands)[Q-1]

min_a = 0
ans = float('inf')
for a in SA:
    if a == min_a: continue
    min_a = a
    max_a = calc_max_a(min_a)
    if max_a < 0: break
    ans = min(ans, max_a - min_a)
print(ans)

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

#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;
using P = pair<ll, ll>;

int main() {
    int n, m, s, t; cin >> n >> m >> s >> t;
    s--, t--;
    vector<P> G1[100010], G2[100010];
    loop (m, i) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        G1[u].push_back({v, a});
        G1[v].push_back({u, a});
        G2[u].push_back({v, b});
        G2[v].push_back({u, b});
    }

    // forward
    priority_queue<P, vector<P>, greater<P>> Q;
    Q.push({0, s});
    ll d_f[100010] = {};
    fill(d_f, d_f + 100010, -1);
    while (!Q.empty()) {
        auto p = Q.top(); Q.pop();
        int u = p.second;
        if (d_f[u] >= 0) continue;
        d_f[u] = p.first;
        for (auto v : G1[u]) {
            if (d_f[v.first] < 0) {
                Q.push({p.first + v.second, v.first});
            }
        }
    }

    // backward
    Q.push({0, t});
    ll d_b[100010] = {};
    fill(d_b, d_b + 100010, -1);
    while (!Q.empty()) {
        auto p = Q.top(); Q.pop();
        int u = p.second;
        if (d_b[u] >= 0) continue;
        d_b[u] = p.first;
        for (auto v : G2[u]) {
            if (d_b[v.first] < 0) {
                Q.push({p.first + v.second, v.first});
            }
        }
    }

    vec<ll> ans(n + 1);
    ans[n] = 1LL<<61;
    loop (n, i) {
        ll k = n - 1 - i;
        ans[k] = min(ans[k + 1], d_f[k] + d_b[k]);
    }
    loop (n, i) cout << 1000000000000000L - ans[i] << endl;
    return 0;
}

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

using namespace std;

void solve()
{
  int n, m;
  cin >> n >> m;
  int d = (n - m);
  int onetime = d * 100 + m * 1900;
  int da = pow(2, m);
  onetime *= da;
  cout << onetime << "\n";
}

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

Measured memory_bytes: 256
#!/usr/bin/env perl

chomp($_=<STDIN>);
@s=split(//);
chomp($_=<STDIN>);
@t=split(//);

%h = {};
%r = {};

$ok=1;
for ($i=0;$i<@s;$i++) {
  $x=$s[$i];
  $y=$t[$i];
  !$h{$x} || $h{$x} eq $y or $ok = 0;
  !$r{$y} || $r{$y} eq $x or $ok = 0;

  $h{$x} = $y;
  $r{$y} = $x;
}

print $ok ? "Yes" : "No";


Measured memory_bytes: 43084
#include <bits/stdc++.h>
#define tam 100010

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vii> graph;

bool comp(int a, int b) {
	return a > b;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	map <char, char> kika;
	kika['A'] = 'T';
	kika['T'] = 'A';
	kika['G'] = 'C';
	kika['C'] = 'G';
	char letra;
	cin >> letra;
	cout << kika[letra] << "\n";
	return 0;
}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string s;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> s;
  bool f = false;
  for(int i=0;i<s.size();i++){
    if(s[i]=='7')f=true;
  }
  cout << (f?"Yes":"No") << endl;


return 0;
}
///....


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

int main()
{
	int n, a, max = -1, min = 1001;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (max < a) max = a;
		if (min > a) min = a;
	}
	cout << max - min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}



int main()
{
   ll sum;
   cin>>sum;
   ld a=sum/3.0;

   ld vol=a*a*a;
   cout<<fixed<<setprecision(8)<<vol;






    return 0;

}


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

int main()
{
    string s;
    string t;

    cin >> s >> t;
    int i;
    for (i = 0; i < s.size(); i++)
    {
        if(s[i] != t[i])break;
    }
    
    if(s.size() != i)cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3572
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int dp[210][10010];
void mainmain(){
	int n;
	int w;
	cin>>n>>w;
	vint v(n);
	rep(i,n){
		cin>>v[i];
	}
	v.PB(0);
	sort(ALL(v));
	vint s(n+1,0);
	s[0]=v[0];
	rep(i,n){
		s[i+1]=s[i]+v[i+1];
	}
	int ans=0;
	rep(i,n+1){
		if(v[i]==v[i+1]) continue;
		rep(j,210) rep(k,10010) dp[j][k]=0;
		int b=w-v[i];
		if(s[i]>b) break;
		dp[i][s[i]]=1;
		reep(j,i+1,n+1){
			for(int k=b;k>=0;--k){
				dp[j][k]=dp[j-1][k];
				if(k-v[j]>=0) dp[j][k]+=dp[j-1][k-v[j]];
				dp[j][k]%=MOD;
			}
		}
		reep(j,w-v[i+1]+1,b+1){
			(ans+=dp[n][j])%=MOD;
		}
	}
	cout<<ans<<endl;
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 9432
N ,Y = map(int, input().split())

flg = True

for x in range(N+1):
    for y in range(N-x+1):
        z = N - (x + y)
        if 10000 * x + 5000 * y + 1000 * z == Y:
            ans = [x, y, z]
            flg = False
            break

if flg:
    ans = [-1, -1, -1]

print(' '.join(map(str, ans)))

Measured memory_bytes: 3060
#include<stdio.h>

int main(void) {
	int a, b;
	int sum = 0;
	scanf("%d %d", &a, &b);

	for (int i = 0; i < 2; i++) {
		if (a > b) {
			sum += a;
			a--;
		}
		else {
			sum += b;
			b--;
		}
	}

	printf("%d\n", sum);

	return 0;
}

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

int main(){
	vector<int>ame(3);
	for (int i = 0; i < 3; ++i)
	{
		cin >> ame.at(i);
	}
	sort(ame.begin() ,ame.end());
	if(ame.at(0) + ame.at(1) == ame.at(2)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let (a, b) = get!(i64, i64);

    println!("{}", [a + b, a - b, a * b].iter().max().unwrap());
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
 
std::vector<long long> divisor(long long n){
    std::vector<long long > res;
    for(long long i = 1LL; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            long long j = n / i;
            if(i != j)res.push_back(j);
        }
    }
    std::sort(res.begin(),res.end(),std::greater<long long>());
    return res;
}

int main()
{
    long long n,m;
    std::cin >> n >> m;
    long long res;
    std::vector<long long> div = divisor(m);
    for(long long i = 0; i < (long long)div.size(); i++){
        if(m / div[i] >= n){res = div[i];break;}
    }
    std::cout << res << std::endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
using namespace std;
int  gcd(int a, int b) {
	if (a < b) gcd(b, a);
	int r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
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;
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string ans = "NO";
	for (int i = 0; i < s.length(); i++) {
		for (int j = i; j <= s.length(); j++) {
			string test = "";
			for (int k = 0; k < s.length(); k++) {
				if (k >= i&&k < j);
				else test += s[k];
			}
			if (test == "keyence") { ans = "YES"; break; }
		}
	}
	cout << ans;
}

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

using namespace std;

// input
string s;

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

    cin >> s;

    cout << s[0] << s.size()-2 << s[s.size()-1] << "\n";
    
}

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

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
 double PI=3.141592653589793238;
 double rada = 30*h + 0.5*m;
 double radb = 6*m;
 double rad = rada - radb;
 double coscos = cos(rad*PI/180);
 if(rad == 90 || rad == 270) coscos = 0;
 if(rad == 0 || rad == 360) coscos = 1;
 if(rad == 180) coscos = -1;
 
 double x = a*a + b*b -2*a*b*coscos;
 double y = sqrt(x);
 cout << fixed << setprecision(20);
 cout << y << endl;
}

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse

//方針　dp
//テーブルには回数を保持させる
// j点にするのに最小の問題数を求める

int main(){
    int D,G,MAX=0;
    cin>>D>>G;
    G/=100;

    vector<pair<int,int> > PC(D);
    rep(i,D){
        int a,b;
        cin>>a>>b;
        b/=100;
        MAX=MAX+(i+1)*a+b;
        PC[i]=make_pair(a,b);
    }

    /*
    どんなテーブルが必要か、i,jでi問目を解く時、j点にする最小の手数を考える。
    この時jは最大点である
    遷移式は？
    dp[i+1][j]=min(dp[i][j-a],dp[i][j])これじゃね？
    いやでもこれじゃ何問解くべきかわからない。
    足していく必要がある。
    if(j-a>=0)dp[i+1][j]=dp[i][j-a]+1;
    chmin(dp[i+1][j],dp[i+1][j])
    こうじゃないか？
    初期化INFかな
    comを考える必要はあるけど、大体はこれな気がする
    */

    vector<vector<int> > dp(11,vector<int>(205000,INF));
    dp[0][0]=0;

    for(int i=0;i<D;i++){
        int a=PC[i].first,b=PC[i].second;
        for(int j=1;j<=a;j++){
            int p=j*(i+1);
            if(j==a)p+=b;
            for(int k=0;k<=MAX;k++){
                if(k-p>=0)dp[i+1][k]=dp[i][k-p]+j;
                chmin(dp[i+1][k],dp[i][k]);
            }
        }
    }

    int ANS=INF;
    for(int i=G;i<=MAX;i++){
        ANS=min(dp[D][i],ANS);
    }
    cout<<ANS<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
#define int long long
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
typedef pair<int, int> P;
signed main()
{
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e6+5;
typedef long long ll;
int a[N], n, inv[N];
int prime[N], phi[N], pcnt;ll cnt[N];
bool v[N];

const int mod = 998244353;
inline void sieve(int n = 2e6){
	inv[1]=1;
	for(int i=2;i<=n;i++)inv[i] = 1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=n;i++)for(int j=i*2;j<=n;j+=i){cnt[i]+=cnt[j];cnt[i]%=mod;}
}
ll ans=0;
int main()
{
	cin >> n;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),cnt[a[i]]+=a[i];
	sieve();
	for(int i=1000000;i;i--){
		// if(i<=6)cout << cnt[i] << endl;
		cnt[i] = cnt[i]*cnt[i]%mod;
		for(int j=i*2;j<=1000000;j+=i){
			cnt[i] -= cnt[j];
			cnt[i] += mod;
			cnt[i] %= mod;
		}
		// if(i<=6)cout << i << ":" << cnt[i] << endl;
		ans += cnt[i] *inv[i] % mod;
		ans += mod;
		ans %=mod;
	}
	for(int i=1;i<=n;i++)ans -= a[i], (ans+=mod)%=mod;
	ans = ans * ((mod+1)/2) % mod;
	cout << ans << endl;
}


Measured memory_bytes: 18816
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time

def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N, M = MI()
    A = LI()
    D = {}

    for i in range(M):
        B, C = MI()
        if C not in D:
            D[C] = 0
        D[C] += B

    for i in range(N):
        if A[i] not in D:
            D[A[i]] = 0
        D[A[i]] += 1

    sorted_items = sorted(D.items(), reverse=True)
    total = 0
    ans = 0
    for integer, num in sorted_items:
        if total + num > N:
            ans += integer * (N - total)
            total = N
            break
        else:
            total += num
            ans += integer * num

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 88444
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
map<ll,VL> mp;
void solve()
{
	ll n,m;
	rl2(n,m);
	fr(i,0,m)
	{
		ll k;
		rl(k);
		fr(j,0,k)
		{
			ll s;
			rl(s);
			mp[s-1].PB(i);
		}
	}
	VL p(m);
	fr(i,0,m)
		rl(p[i]);
	ll pset=pow(2,n);
	ll ct=0;
	fr(i,0,pset)
	{
		VL b(m,0);
		fr(j,0,n)
		{
			if(i&(1<<j))
			{
				VL tmp=mp[j];
				fr(x,0,SZ(tmp))
				{
					b[tmp[x]]++;
				}
			}
		}
		ll flag=1;
		fr(j,0,m)
		{
			if(p[j]!=(b[j]%2))
				flag=0;
		}
		if(flag)
			ct++;
	}
	wl(ct);
	NL;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>
#include <climits>
#include <cmath>
#include <algorithm>

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

	std::vector<int64_t> vec(n);
	for (auto&& e : vec)
		std::cin >> e;

	int64_t sum = 0;
	for (auto&& e : vec)
		sum += e;

	int64_t cur = vec[0], ans = std::numeric_limits<int64_t>::max();
	for (int i = 1; i < n; ++i) {
		ans = std::min(ans, std::abs(sum - cur - cur));

		cur += vec[i];
	}

	std::cout << ans << std::endl;
}

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

using namespace std;

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

	int k;
	cin >> k;

	vector<int> si;
	for(char c : s)
	{
		si.push_back((c - 'a') % 26);
	}

	auto j = s.begin();
	for(auto i = si.begin(); i != si.end() && k > 0; i++)
	{
		if(*i != 0 && (26 - *i) <= k)
		{
			k -= 26 - *i;
			*i = 0;
			*j = 'a';
		}
		j++;
	}

	if(k > 0)
	{
		s[s.size() - 1] = (char)((s[s.size() - 1] - 'a' + k) % 26 + 'a');
	}

	cout << s;

	return 0;
}

Measured memory_bytes: 1020
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	long long int p = 1;

	for (int i = 0; i < a; i++) {
		if (p * 2 <= p + b)p *= 2;
		else p += b;
	}
	cout << p << endl;

	return 0;
}

Measured memory_bytes: 256