akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  std::string S, T; std::cin >> S >> T;

  std::unordered_map<char, char> t, u;
  for(int i=0; i<S.size(); i++) {
    if ( t.count(S[i]) == 0 ) t[S[i]] = T[i];
    else {
      if ( t[S[i]] != T[i] ) { std::cout << "No" << std::endl; return 0; }
    }
  }
  for(int i=0; i<S.size(); i++) {
    if ( u.count(T[i]) == 0 ) u[T[i]] = S[i];
    else {
      if ( u[T[i]] != S[i] ) { std::cout << "No" << std::endl; return 0; }
    }
  }

  std::cout << "Yes" << std::endl;
  return 0;
}


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

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

Measured memory_bytes: 3624
n = int(input())
works = [[]] * n
for i in range(n):
  a, b = map(int, input().split(' ')) # a = 時間, b = 締め切り
  works[i] = [a, b]

ans = 'Yes'
sorted_works = sorted(works, key=lambda x: x[1]) # 締切の早い順にソート
total = 0

for work in sorted_works:
  total += work[0]
  if total > work[1]:
    ans = 'No'
    break
  
print(ans)

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

int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='1') s[i]='9';
		else if (s[i]=='9') s[i]='1';
	}
	cout<<s<<endl;
} 

Measured memory_bytes: 3620
#include <stdio.h>
#include <algorithm>
int main() {
	char IA[101], IB[101];
	scanf("%s %s", IA, IB);
	int lengthA, lengthB;
	for (lengthA = 0; IA[lengthA] != 0x0; lengthA++);
	for (lengthB = 0; IB[lengthB] != 0x0; lengthB++);
	char A[100] = { 0 }, B[100] = { 0 };
	for (int i = 0; i < lengthA; i++)
		A[99 - i] = IA[lengthA - i - 1] - '0';
	for (int i = 0; i < lengthB; i++)
		B[99 - i] = IB[lengthB - i - 1] - '0';
	int i;
	for (i = 0; i < 100 && A[i] == B[i]; i++);
	if (i == 100)
		printf("EQUAL\n");
	else
		printf("%s\n", A[i] > B[i] ? "GREATER" : "LESS");
}

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

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		float x, y, b, p;
		cin >> x >> y >> b >> p;

		cout << min(double(x * b + y * p), 0.8 * (x * (b < 5 ? 5 : b) + y * (p < 2 ? 2 : p))) << endl;
	}

	return 0;
}

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

int const N = 5000000, md = 998244353;
int p2[N + 1], fc[N + 1], inv[N + 1], fcin[N + 1];

void ad(int &x, int y) { if ((x += y) >= md)x-= md; }
int ch(int n, int r) { return (ll)fc[n] * fcin[r] % md * fcin[n - r] % md; }

int main(){
	int n;
	scanf("%d", &n);
	n >>= 1;
	
	fc[0] = 1;
	f(i, 1, n + 1)fc[i] = (ll)fc[i - 1] * i % md;
	inv[1] = 1;
	f(i, 2, n + 1)inv[i] = md - md / i * (ll)inv[md % i] % md;
	fcin[0] = 1;
	f(i, 1, n + 1)fcin[i] = (ll)fcin[i - 1] * inv[i] % md;
	p2[0] = 1;
	f(i, 1, n + 1)ad(p2[i] = p2[i - 1], p2[i - 1]);
	
	int an = 0, s = 0;
	f(i, 1, n + 1){
		ad(s, (ll)ch(n, i - 1) * p2[i - 1] % md);
		ad(an, (ll)p2[n - i] * ch(n, i) % md * s % md);
	}
	ad(an, an);
	int z = 1;
	f(i, 0, n << 1)z = (ll)z * 3 % md;
	ad(z, md - an);
	printf("%d\n", z);
}

Measured memory_bytes: 78336
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y) { return (x / gcd(x, y) * y); }

//using pll = pair<long, long>;
//using W_graph = vector<vector<pll>>;

int main() {

	long N; cin >> N;
	long res = N + 1;

	for (long i = 1; i * i <= N; i++) if (N % i == 0) res = min(res , i + (N / i));
    
    res -= 2;
	cout << res << endl;
}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 998244353
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
//int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a, 
              const pair<int,int> &b) 
{   
    if(a.ff == b.ff){
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff); 
}

int n ,m;
int col[100005];
vi g[100005];
int ans[100005];
map<pair<int, int>, int> map1;
int32_t main()
{
    // IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int n;
    cin >>  n;
    vi v(100),c(100);
    rep(i, 0, n){
        cin >> v[i+1];
    }
    rep(i, 0, n){
        cin >> c[i+1];
    }

    int dp[100] = {0};
    if(v[1]-c[1]<0){
        dp[1] = 0;
    }
    else{
        dp[1] = v[1]-c[1];
    }
    // for(int i=2;i<=n;i++){
    //     if(v[i]-c[i] >=0){
    //         dp[i] = v[i]-c[i];
    //     }
    // }

    for(int i=2;i<=n;i++){
        for(int j=1;j<i;j++){
            int ci = dp[j];
            if(v[i] > c[i]){
                ci += v[i]-c[i];
            }
            dp[i] = max(ci, dp[i]);
        }
    }
    // rep(i, 1, n+1){
    //     cout << dp[i] << " ";
    // }
    cout << dp[n];
}


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

int main(void) {
	int a, b, c; cin >> a >> b >> c;
	if (a == b + c || b == a + c || c == a + b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
t = [0] * 5
t[0] = int(input())
t[1] = int(input())
t[2] = int(input())
t[3] = int(input())
t[4] = int(input())
k = int(input())

def check():
    if t[4] - t[0] > k:
        return ':('
    return 'Yay!'

print(check())


Measured memory_bytes: 3060
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
vector<P> city[100001];
int main()
{
	string S;
	cin >> S;
	S[5] = ' ';
	S[13] = ' ';
	cout << S << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	ll ans = 0LL;
	int N, W;
	cin >> N >> W;
	vl w(N), v(N);
	rep(i, N) cin >> w[i] >> v[i];
	deque<ll> V[4];
	rep(i, N) V[w[i]-w[0]].push_back(v[i]);
	rep(i, 4) sort(rall(V[i]));
	rep(i, 4) REP(j, 1, V[i].size()) V[i][j] += V[i][j-1];
	rep(i, 4) V[i].push_front(0LL);
	rep(i, V[0].size()) rep(j, V[1].size()) rep(k, V[2].size()) rep(l, V[3].size()) {
		ll now_W = 0LL;
		now_W += (ll)w[0]*(i);
		now_W += (ll)(w[0]+1)*(j);
		now_W += (ll)(w[0]+2)*(k);
		now_W += (ll)(w[0]+3)*(l);
		//cout << " i: " << i << " j: " << j <<" k: " << k << " l: " << l << " w: " << now_W << " v: " << V[0][i] + V[1][j] + V[2][k] + V[3][l] <<endl;
		if(now_W <= W) ans = max(ans, V[0][i] + V[1][j] + V[2][k] + V[3][l]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
alphabets = [""] + [s for s in "abcdefghijklmnopqrstuvwxyz"]

s = int(input())

nums = []

while s > 0:
  nums.append((s - 1) % 26 + 1)
  s = (s - 1) // 26

res = ""
  
for _ in range(len(nums)):
  res = res + alphabets[nums.pop()]

print(res)

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


void solve(long long N, std::vector<long long> P){
    long long fmin = INT_MAX;
    int ans = 0;
    for(auto x:P)
    {
        if(fmin > x) ans++;
        fmin = min(fmin,x);
    }
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    solve(N, std::move(P));
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long m = 0;
        long a = 0;
        long r = 0;
        long c = 0;
        long h = 0;
        
        while (n-- > 0) {
            char chr = sc.next().charAt(0);
            
            switch (chr) {
                case 'M':
                    m++;
                    break;
                case 'A':
                    a++;
                    break;
                case 'R':
                    r++;
                    break;
                case 'C':
                    c++;
                    break;
                case 'H':
                    h++;
                    break;
            }
        }
        
        long count = 0;
        count += m * a * r;
        count += m * a * c;
        count += m * a * h;
        count += m * r * c;
        count += m * r * h;
        count += m * c * h;
        count += a * r * c;
        count += a * r * h;
        count += a * c * h;
        count += r * c * h;
        
        System.out.println(count);
    }
}


Measured memory_bytes: 42312
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <complex>
using namespace std;

#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto& e:c)

typedef complex<double> P;
typedef vector<P> G;
double const inf=1e10;
double const eps=1e-8;

inline double cross(const P& a, const P& b) {
    return imag(conj(a)*b);
}

inline double dot(const P& a, const P& b) {
    return real(conj(a)*b);
}

struct L : public vector<P> {
    L(const P &a, const P &b) {
        push_back(a); push_back(b);
    }
};

inline int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;
    if (cross(b, c) < 0)   return -1;
    if (dot(b, c) < 0)     return +2;
    if (norm(b) < norm(c)) return -2;
    return 0;
}

inline P projection(const L &l, const P &p) {
    double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}

inline bool intersectSS(const L &s, const L &t) {
    return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
        ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

inline bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < eps; // triangle inequality
}

bool intersectRS(const G &r, const L &l){
    if(r[0].real()<=l[0].real() && l[0].real()<=r[2].real() &&
       r[0].imag()<=l[0].imag() && l[0].imag()<=r[2].imag() &&
       r[0].real()<=l[1].real() && l[1].real()<=r[2].real() &&
       r[0].imag()<=l[1].imag() && l[1].imag()<=r[2].imag()){
        return true;
    }
    rep(i,4){
        L m(r[i],r[(i+1)%4]);
        if(intersectSS(l,m)) return true;
    }
    return false;
}

inline double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

int n;
L l{0,0};
G rs[50];
double hs[50];

double maxr(P p, G const& rect, double h){
    double res=inf;
    rep(i,4){
        double d=distanceSP({rect[i],rect[(i+1)%4]},p);
        if(d<h) res=min(res,d);
        else res=min(res,(d*d+h*h)/(2*h));
    }
    // printf(" %lf\n",res);
    return res;
}

double solve(){
    double ans=inf;
    rep(i,n){
        if(intersectRS(rs[i],l)) return 0;
    }
    rep(i,n){
        rep(j,4){
            P prj = projection(l,rs[i][j]);
            if(!intersectSP(l,prj)) continue;
            ans=min(ans, maxr(prj,rs[i],hs[i]));
        }
        // printf(" %lf\n",ans);
        ans=min(ans,maxr(l[0],rs[i],hs[i]));
        ans=min(ans,maxr(l[1],rs[i],hs[i]));
    }
    return ans;
}

int main(){
    while(cin>>n && n){
        double sx,sy,ex,ey;
        cin >> sx>>sy>>ex>>ey;
        l = L{P(sx,sy),P(ex,ey)};
        rep(i,n){
            double mx,my,Mx,My;
            cin>>mx>>my>>Mx>>My >> hs[i];
            rs[i] = {P(mx,my),P(Mx,my),P(Mx,My),P(mx,My)};
        }
        printf("%.5lf\n",solve());
    }
}

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }

    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
	int m = ri();
	int a[n+m-1], b[n+m-1];
	vector<set<int> > to(n);
	vector<set<int> > rev(n);

	FOR(i,n+m-1) a[i] = ri()-1, b[i] = ri()-1, to[a[i]].insert(b[i]), rev[b[i]].insert(a[i]);

	int root = 0;
	while (rev[root].size()) {
		root = *rev[root].begin();
	}

	int dist[n];INIT(dist,INF);dist[root] = 0;
	int updated[n]; INIT(updated,-1);
	queue<int> que; que.push(root);

	set<pair<int,int> > removes;
	while (que.size()) {
		int i = que.front(); que.pop();
		for (auto j : to[i]) {
			if (dist[j] == INF) {
				dist[j] = dist[i] + 1;
				updated[j] = i;
				if (rev[j].size() == 1) {
					que.push(j);
				}
			} else {
				assert(dist[i]+1 != dist[j]);
				if (dist[j] > dist[i] + 1) while(1) { volatile int x; x = 1; }
				dist[j] = dist[i] + 1;
				removes.insert({updated[j],j});
				to[updated[j]].erase(j);
				rev[j].erase(updated[j]);
				updated[j] = i;
				if (rev[j].size() == 1) {
					que.push(j);
				}
			}
		}
	}

	assert(removes.size() == m);
	FOR(i,n) {
		cout << (i == root ? 0 : *rev[i].begin()+1) << endl;
	}

    return 0;
}


Measured memory_bytes: 21504
#include<stdio.h>
#include<string.h>

int main(){
	char number[1001]={0};
	int i,sum,lon;
	while(1){
	scanf("%s",number);
	if(strcmp(number,"0")== 0) break;
	lon = strlen(number);
		for(i=0;i<lon;i++){
			sum +=number[i]-'0';
		}
	printf("%d\n",sum);
	sum = 0;
	}
}

Measured memory_bytes: 964
class FenwickTree:
    """FenwickTree (Binary Indexed Tree, 0-index)

    Queries:
        1. add(i, val): add val to i-th value
        2. sum(n): sum(bit[0] + ... + bit[n-1])

    complexity: O(log n)

    See: http://hos.ac/slides/20140319_bit.pdf
    """

    def __init__(self, a_list):
        self.N = len(a_list)
        self.bit = a_list[:]
        for _ in range(self.N, 1 << (self.N - 1).bit_length()):
            self.bit.append(0)
        for i in range(self.N-1):
            self.bit[i | (i+1)] += self.bit[i]

    def add(self, i, val):
        while i < self.N:
            self.bit[i] += val
            i |= i + 1

    def sum(self, n):
        ret = 0
        while n >= 0:
            ret += self.bit[n]
            n = (n & (n + 1)) - 1
        return ret

    def query(self, low, high):
        return self.sum(high) - self.sum(low)


N = int(input())
P = [int(x) for x in input().split()]
P_idx = [(x, i) for i, x in enumerate(P)]
P_idx.sort()
fwt = FenwickTree([0] * N)
ans = 0
for x, idx in reversed(P_idx):
    if fwt.sum(idx) == idx:
        ans += 1
    fwt.add(idx, 1)
print(ans)


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

int main(){ 
  int n, K;
  ll L, R;
  cin >> n >> K >> L >> R;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  int l = n/ 2;
  int r = n - l;

  vector<vector<ll>> left(41), right(41);

  for (int bit = 0; bit < (1 << l); bit++) {
    ll sum = 0;
    for (int i = 0; i < l; i++) if (bit & (1 << i)) sum += a[i];
    left[__builtin_popcount(bit)].emplace_back(sum); 
  }

  for (int bit = 0; bit < (1 << r); bit++) {
    ll sum = 0;
    for (int i = 0; i < r; i++) if (bit & (1 << i)) sum += a[l + i];
    right[__builtin_popcount(bit)].emplace_back(sum); 
  }

  for (int i = 0; i <= l; i++) sort(left[i].begin(), left[i].end());
  for (int i = 0; i <= r; i++) sort(right[i].begin(), right[i].end());

  ll res = 0;

  for (int d = 0; d <= l; d++) {
    int x = K - d;
    if (x > r) continue;
    if (x < 0) break;
    ll add = 0;
    for (auto e : left[d]) add += upper_bound(right[x].begin(), right[x].end(), R - e) - lower_bound(right[x].begin(), right[x].end(), L - e);
    res += add;
  }
  cout << res << endl;
  return 0;
} 


Measured memory_bytes: 23400
#include<stdio.h>
int main(void)
{
	int w,h,c,i,j;
	scanf("%d%d%d",&w,&h,&c);
	for(i=1;i<=h||i<=w;i++){
		if(w%i==0&&h%i==0){
			j=(w/i)*(h/i);
		}
	}
	printf("%d\n",j*c);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int calcTrackNum(vector<int> &w, int P)
{
    int ret = 1;
    int tmp_P = 0;
    for (int i = 0; i < w.size(); i++)
    {
        if (w[i] > P)
        {
            return -1;
        }
        else if (tmp_P + w[i] > P)
        {
            ret++;
            tmp_P = w[i];
        }
        else
        {
            tmp_P += w[i];
        }
    }

    return ret;
}

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

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

    int left = 0;
    int right = accumulate(w.begin(), w.end(), 0);
    int mid = right / 2;
    int ans = 0;
    while (left <= right)
    {
        int n = calcTrackNum(w, mid);
        if (n > k || n == -1)
        {
            left = mid + 1;
        }
        else
        {
            ans = mid;
            right = mid - 1;
        }
        mid = (left + right) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

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

    int r = N-W+1;
    int c = N-H+1;
    cout << r*c << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] ={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
        
        
        
        
        System.out.println(A[N-1]);
    }
}


Measured memory_bytes: 35648
import heapq
n = int(input())
v = list(map(int, input().split()))
heapq.heapify(v)
count = 0
ab = 0
while count < n-1:
    a = heapq.heappop(v)
    b = heapq.heappop(v)
    ab = (a+b)/2
    heapq.heappush(v, ab)
    count += 1

ans = ab
print(ans)


Measured memory_bytes: 38256
package main

import (
  "fmt"
  // "math"
)

func main(){
  var N int
  fmt.Scan(&N)
  a := make([][]int, N)
  for i:=0; i<N; i++{
    a[i] = make([]int, 3)
    for j:=0; j<3; j++{
      fmt.Scan(&a[i][j])
    }
  }
  result := 1 // okなら１　ダメなら0
  for i:= 0; i<N; i++{
    if i==0{
      t := a[i][0]
      // x := a[i][1]
      // y := a[i][2]
      if AbsDistance([]int{0,0,0}, a[i]) > t{
        result = 0
      }else if AbsDistance([]int{0,0,0}, a[i])%2 != t%2{
        result = 0
      }
      continue
    }
    t := a[i][0]-a[i-1][0]
    // fmt.Println(t)
    if AbsDistance(a[i-1],a[i]) > t{
      result = 0
    }else if AbsDistance(a[i-1], a[i])%2 != t%2{
      result = 0
    }
    // fmt.Println(AbsDistance(a[i-1], a[i]))
  }
  if result == 0{
    fmt.Println("No")
  }else if result ==1{
    fmt.Println("Yes")
  }
}

func AbsDistance(a1 []int ,a2 []int) int{ //絶対値和を求める
  x1 := a1[1]
  y1 := a1[2]
  x2 := a2[1]
  y2 := a2[2]
  x := x1-x2
  if x < 0{
    x = -x
  }
  y := y1-y2
  if y < 0{
    y = -y
  }

  return x+y

}


Measured memory_bytes: 10756
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
 
using ld = long double;
using ll = long long;
using ii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vii = vector <ii>;
using vpll = vector<pll>;

vector <int> a;
int n,k;

bool can(int m){
  int cnt = 0;
  for(int i=0;i<n;i++){
    cnt += (a[i]+m-1)/m - 1;
  }


  return cnt <= k; 
}

int main(){
 
  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);
  
  cin >> n >> k;
  a.resize(n);
  for(int i=0;i<n;i++)
    cin >> a[i];

  int l = 1;
  int r = 1e9;

  int ans = r;

  while(l <= r){
    int m = (l+r)/2;
    if(can(m)){
      ans = m;
      r = m-1;
    }else{
      l = m+1;
    }
  }

  cout << ans << endl;

  return 0;
}

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

const double PI=acos(-1);

int main(){
    long n, sum = 0;
    cin >> n;
    map<long, long> l, o;
    vector<long> m(n);
    for(long i = 0; i < n; i++){
        cin >> m[i];
        l[m[i]]++;
    }
    for(auto i : l){
        o[i.first] = i.second*(i.second-1)/2;
        sum += o[i.first];
    }
    long summ = sum;
    for(int i = 0; i < n; i++){
        sum = summ;
        sum -= o[m[i]];
        long a = (l[m[i]]-1)*(l[m[i]]-2)/2;
        if(a > 0) sum += a;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 18944
N = int(input())
rm = 0
r = -float('inf')
robot = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: x[0] + x[1])

for x, l in robot:
    if x - l < r:
        rm += 1
    else:
        r = max(r, x + l)

print(N - rm)


Measured memory_bytes: 33064
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<bool> vb;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 100000005;
const int N = 200007, M = N;
int i,j,idx,cnt,par;

void solve() {
  ll n,m;
  cin>>n>>m;

  ll x,y;
  vpii vec;

  fo(i,0,n) cin>>x>>y , vec.pb({x,y});
  multiset<ll>mp;

  sortall(vec);

  int idx = 0;
  ll ans = 0;
  fo(i,1,m+1) {
    while(idx<n && vec[idx].ff<=i) mp.insert(vec[idx].ss),idx++;
    if(!mp.empty()) {
        auto it = mp.end();
        it--;
        ans+=*it;
        mp.erase(it);
    }
  }
  cout<<ans<<"\n";

}

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

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

    return 0;
}




Measured memory_bytes: 8748
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

#define rep(i, a, n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template<typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------

bool check(ll x) {

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //CLion Standard Input for DEBUG
    //--------------------------------------------------------------------------
//    ifstream in("/Users/ryo/Dropbox/competition/CompetitivePrograming/in.txt");
//    cin.rdbuf(in.rdbuf());
    //--------------------------------------------------------------------------

    ll m, n, x;
    cin >> m >> n;
    if (m > n / 2)
        x = n / 2;
    else
        x = m + (n - m * 2) / 4;
    cout << x << endl;
    return 0;

}

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


int main(){
  int n,m;
  cin >> n >> m;
  int ans = 0;
  if(n>=2){
    ans += (n*(n-1))/2;
  }
  if(m>=2){
    ans += (m*(m-1))/2;
  }
  cout << ans;
}


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

int	main(void)
{
	char	s[1001];
	char	t[1001];
	int		num[1000] = {0};
	int		slen;
	int		tlen;
	int		max;

	scanf("%s", s);
	scanf("%s", t);
	slen = strlen(s);
	tlen = strlen(t);
	for (int i = 0; i <= slen - tlen; i++)
	{
		for (int j = 0; j < tlen; j++)
		{
			if (s[i + j] == t[j])
				num[i]++;
		}
	}
	max = 0;
	for (int i = 0; i <= slen - tlen; i++)
	{
		if (max < num[i])
			max = num[i];
	}
	printf("%d\n", tlen - max);
	return 0;
}

Measured memory_bytes: 1720
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int ans;
	if(n<2)ans=1;
	else if(n<4)ans=2;
	else if(n<8)ans=4;
	else if(n<16)ans=8;
	else if(n<32)ans=16;
	else if(n<64)ans=32;
	else ans=64;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  string S,X;
  int res=999;
  cin >> S;
  for(int i=0;i<S.size()-2;i++){
    X = S.substr(i,3);
    res = min(res,abs(stoi(X)-753));
  }
  
  cout << res << endl;
  return 0;
}

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

int cur = 0, A, B, n, dif;
vector<int> ans;

void gray(deque<int> pos, deque<int> care) {
    int sz = pos.size();
    if(sz == 0) return;
    // if(sz == 1) { 
    //     cur ^= (1 << pos[0]);
    //     gray(care, deque<int>());
    //     printf("%d ", cur); 
    //     return; 
    // }

    int fr = pos.front();
    pos.pop_front();
    gray(pos, care);

    gray(care, deque<int>());
    cur ^= (1 << fr);
    ans.push_back(cur ^ A);

    gray(pos, care);
}

void mono(deque<int> ones, deque<int> care) {
    if(ones.size() == 0) return;
    if(ones.size() == 1) {
        care.push_front(ones.front());
        gray(care, deque<int>());
        return;
    }
    bool more = ones.size() > 1;
    int fr = ones.front();
    ones.pop_front();
    gray(ones, care);

    int se = ones.front();

    gray(care, deque<int>());
    cur ^= (1 << fr);
    ans.push_back(cur ^ A);
    care.push_back(se);
    ones.pop_front();
    mono(ones, care);
}

void solve() {
    deque<int> cg, ncg;
    for(int i = 0; i < n; ++i) {
        if(dif >> i & 1) cg.push_back(i);
        else ncg.push_back(i);
    }
    mono(cg, ncg);
}

bool vis[1<<18];
int last ;
bool check() {
    last = -1;
    if(ans[0] != A || ans[ans.size()-1] != B) {
        printf("Not\n");
        return 0;
    }
    if(ans.size() != (1u<<n)) { puts("SMALL"); return false; }
    for(auto g : ans) {
        if(vis[g]) { puts("WA"); return false; }
        if(last >= 0) {
            int dif = abs(g - last);
            if(dif != (dif&(-dif))) { puts("WA"); return false; }
            last = g;
        }
        vis[g] = true;
    }
    puts("AC");
    return true;
}
int main() {
    cin >> n >> A >> B;
    dif = A ^ B;
    if(__builtin_popcount(dif) & 1) {
        puts("YES");
        ans.push_back(cur ^ A);
        solve();
        for(auto g : ans) printf("%d ", g);
    } else puts("NO");

    return 0;
}

Measured memory_bytes: 1652
#include <bits/stdc++.h>
using namespace std;
const int N=1050;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int a[N];
int main(){
    int n=gi(),s,las=gi(),ans=0;
    for (int i=2; i<=n; ++i){
	s=gi();
	if (s==las) s=0,++ans;
	las=s;
    }
    cout<<ans;
    return 0;
}


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

int n, a[1000000], c[1000000];

int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], c[i] = a[i];
    sort(c+1, c+n+1);
    for (int i = 1; i <= n; i++){
        if (a[i] <= c[(n+1)/2]) cout << c[(n+1)/2 + 1] << endl;
        else cout << c[(n+1)/2] << endl;
    }
}

Measured memory_bytes: 7040
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    std::ios_base::sync_with_stdio(false); std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(12);
    return true;
}();

const double PI = acos(-1);
typedef long long ll;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

/* calc positions of hands by angle */
void solve() {
    cini(a); cini(b);
    cini(h);
    cini(m);
    h%=12;
    m%=60;

    double angH=(2*PI*h)/12 + (2*PI*m)/(12*60);
    double angM=(2*PI*m)/60;

    double xH=sin(angH)*a;
    double yH=cos(angH)*a;
    double xM=sin(angM)*b;
    double yM=cos(angM)*b;

    double dist=hypot(xH-xM, yH-yM);
    cout<<dist<<endl;

}

signed main() {
    solve();
}

// DO NOT JUMP BETWEEN PROBLEMS


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

int main(){
    int n, m, a;
    while(cin >> n >> m >> a, n+m+a){
        int h, p, q;
        int amida[1001][101] = {};
        for(int i = 0; i < m; i++){
            cin >> h >> p >> q;
            amida[h][p] = q;
            amida[h][q] = p;
        }
        for(int i = 1000; i >= 1; i--){
            if(amida[i][a] != 0)    a = amida[i][a];
        }
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3452
n = int(input())
a = [0] + list(map(int, input().split()))
def pi(i):
    global a, n
    s = f"node {i}: key = {a[i]}, "
    if i != 1:
        s += f"parent key = {a[int(i / 2)]}, "
    if i * 2 <= n:
        s += f"left key = {a[2 * i]}, "
        if i * 2 + 1 <= n:
            s += f"right key = {a[2 * i + 1]}, "
    print(s)

for i in range(1, n + 1):
    pi(i)


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

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

    vector<int> sb(N, 0);
    rep(i, N) {
        sb[i] = (i==0 ? 0 : sb[i-1]) + (S[i]=='#' ? 1 : 0);
    }
    int black = sb.back();
    // int white = N - black;

    int ans = INT_MAX;
    rep(i, N+1) {
        int l_black = (i-1>=0) ? sb[i-1] : 0;  
        int r_white = N - i - (black - l_black);
        chmin(ans, l_black + r_white);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1428
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    ll r = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) {
            r += j;
        }
    }

    cout << r << endl;

    return 0;
}

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

int main(){
    ll H,W,K;
    ll res=0;
    cin>>H>>W>>K;
    vector<string> C;
    for (ll i=0;i<H;i++){
        string line;
        cin>>line;
        C.emplace_back(line);
    }
    for(ll maskR=0;maskR<((1<<H)-1);maskR++){ //(correspond 0 to 2^H -1)
        for(ll maskC=0;maskC<((1<<W)-1);maskC++){
            ll black=0;
            for(ll i=0;i<H;i++){
                for(ll j=0;j<W;j++){
                   if(((maskR >> i) & 1) == 0  && ((maskC >> j) & 1) == 0 && C[i][j]=='#'){
                       black++; // will not paint 
                    }
                }
            }
            if (black==K)res+=1;
        }
    }
    cout<<res;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long> V(64,0);
  for(int i=0;i<N;i++){
    long long a;
    cin >> a;
    bitset<64> B(a);
    for(int j=0;j<64;j++) if(B.test(j)) V[j]++;
  }
  
  long long ans=0,mod=1000000007;
  for(int i=0;i<64;i++){
    long long x = (V[i]*(N-V[i]))%mod;
    long long y = pow(2,i);
    y %= mod;
    ans += (x*y)%mod;
    ans %= mod;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
int main(){
  string str;
  ll x=0;
  cin>>str;
  for(ll i=0;i<(ll)str.size();i++){
    if(i%2==0 && str.at(i)=='L'){x++;}
    if(i%2==1 && str.at(i)=='R'){x++;}
  }
  if(x>0){cout<<"No"<<endl;}
  else{cout<<"Yes"<<endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 200010
#define INF 1e18
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
ll n,l,a[N],b[N],sa[N],sb[N],ansn;
ll getans(int x){
	ll sum=0;
	int y=n-x;
	if (x<=y){sum=(sa[x]+sb[x+x]-sb[x])*2-a[x];}
	else{sum=(sa[x]-sa[x-y-1]+sb[n]-sb[x])*2-a[x];}
	return sum;
}
int main(){
	read(l);read(n);
	for (int i=1;i<=n;i++)read(a[i]);
	for (int i=1;i<=n;i++)b[i]=l-a[i];
	for (int i=1;i<=n;i++)sa[i]=sa[i-1]+a[i],sb[i]=sb[i-1]+b[i];
	for (int i=1;i<=n;i++){ansn=max(ansn,getans(i));}
	reverse(a+1,a+n+1);reverse(b+1,b+n+1);
	for (int i=1;i<=n;i++)swap(a[i],b[i]);
	for (int i=1;i<=n;i++)sa[i]=sa[i-1]+a[i],sb[i]=sb[i-1]+b[i];
	for (int i=1;i<=n;i++){ansn=max(ansn,getans(i));}
	cout<<ansn<<endl;
	return 0;
}

Measured memory_bytes: 6528
<?php
  fscanf(STDIN,"%d %d",$k,$n);
  $a = explode(" ",trim(fgets(STDIN)));
  $dis = [];
  for($i=0; $i<$n; $i++){
    if($i == 0){
      $dis[] = ($a[0])+($k-$a[$n-1]);
    }else{
      $dis[] = $a[$i] - $a[$i-1];
    }
  }
  rsort($dis);
  $min_dis = 0;
  for($i=1; $i<count($dis); $i++){
    $min_dis += $dis[$i];
  }
  echo $min_dis."\n";

Measured memory_bytes: 29164
#include <iostream>
#include <list>
#include <string>
#include <algorithm>
using namespace std;
void print_list(const list<int> &);
int main()
{
	int N;
	cin >> N;

	list<int> ls;
	string command;

	int n;

	for (int i = 0; i < N; i++)
	{
		cin >> command;
		if (command == "insert")
		{
			cin >> n;
			ls.push_front(n);
		}
		if (command == "delete")
		{
			cin >> n;
			auto it = find(ls.begin(), ls.end(), n);
			if (it != ls.end())
			{
				ls.erase(it);
			}
		}
		if (command == "deleteFirst")
		{
			ls.pop_front();
		}
		if (command == "deleteLast")
		{
			ls.pop_back();
		}
	}
	print_list(ls);
}
void print_list(const list<int> &ls)
{

	for (auto it = ls.begin(); it != --ls.end(); it++)
	{
		cout << *it << ' ';
	}
	cout << ls.back() << endl;
}


Measured memory_bytes: 34388
#include<bits/stdc++.h>
using namespace std;
#define max 100005
int main(){

  int n, m;
  cin >> n >> m;
  int ac=0, wa =0;
  unordered_map<int,int> umap;

  int x;string s;
  int arr[max]={};

  for(int i=0; i<m; i++){
    cin >> x >> s;
    if(s=="AC"){
      if(umap.find(x)==umap.end()){
        wa+=arr[x];
        ac++;
        umap[x]++;
      }
    }else{
      arr[x]++;
    }
  }

  cout << ac << " " << wa << "\n";

  return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define per(i, a, b) for (int i = (a); i >= int(b); i--)
using namespace std;

const int maxn = 1e7, mod = 1e9 + 7;
int n, A, fact[maxn + 5], finv[maxn + 5];

int qpow(int a, int b) {
	int c = 1;
	for (; b; b >>= 1, a = 1ll * a * a % mod) if (b & 1) c = 1ll * a * c % mod;
	return c;
}

inline void mod_add(int &x, int y) { x += y, x < mod ? 0 : x -= mod; }

void prework(int n) {
	fact[0] = 1;
	rep(i, 1, n) fact[i] = 1ll * fact[i - 1] * i % mod;
	finv[n] = qpow(fact[n], mod - 2);
	per(i, n, 1) finv[i - 1] = 1ll * finv[i] * i % mod;
}

int binom(int n, int m) {
	return 1ll * fact[n] * finv[m] % mod * finv[n - m] % mod;
}

int main() {
	scanf("%d %d", &n, &A);
	prework(n);
	int ans = 0;
	rep(i, 2, A + 1) {
		int a = i - 1, b = n - A, c = max(0, A - i), res = 0;
		rep(j, 0, a) {
			int x = 1ll * binom(a, j) * j % mod * qpow(j + b, mod - 2) % mod * fact[j + b + c] % mod;
			if ((a - j) & 1) mod_add(res, mod - x);
			else mod_add(res, x);
		}
		mod_add(ans, res);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 81956
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int n;
	double x;
	cin>>n;
	if(n%2==0)
	cout<<0.5;
	else
	{
		x=double(n+1)/double(2*n);
		cout<<x;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef ONLINE_JUDGE
#include <custom/prettyprint.hpp>
#endif
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define pow10(n) stoll("1"+string(n,'0'))
#define dbg(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9+7; //998244353
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;
const ld PI = acos((ld)-1);
const int dx[8] = {1,0,-1,0,1,1,-1,-1}, dy[8] = {0,1,0,-1,-1,1,1,-1};
mt19937_64 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll n) { return uniform_int_distribution<ll>(0, n)(rng); }
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

int main() {
    
    setIO("input");
    string s; cin >> s;
    int sum = 0;
    for(auto& i : s) {
        sum += i - '0';
    }
    cout << (sum % 9 == 0 ? "Yes\n" : "No\n");

}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

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

const int INF = 1001001001;

int main(){
   int n;
   cin >> n;
   set<int> s;
   for(int i=1;i<10;i++){
       for(int j=1;j<10;j++){
           s.insert(i * j);
       }
   }
   if(s.count(n)){
       cout << "Yes";
   }else{
       cout << "No";
   }

}

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

using namespace std;

long n;
map<long,long> mp;

long number(long x){
   long cnt=0;
  for(auto v:mp){
   if(v.second>=x-1) cnt++;
  }
  return cnt;  
}

int main(){
 
  cin >> n;
  for(long i=2;i<=n;i++){
    long num=i;
    while(num%2==0){
     mp[2]++;
      num/=2;
    }
    for(long j=3;j<=num;j+=2){
     while(num%j==0){
      mp[j]++;
       num/=j;
     }
    }
  
  }


  cout << number(75)+number(25)*(number(3)-1)+number(15)*(number(5)-1)+(number(5)*(number(5)-1)*(number(3)-2))/2 << endl;
   

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int x[11];
	int r, d;	
	cin >> r >> d >> x[0];
	repn(i, 1, 11){
		x[i] = r * x[i - 1] - d;
		cout << x[i] << endl;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100005
#define INF 1000000005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    vector<int>T(n);
    vector<int>A(n);
    REP(i,n)cin>>T[i];
    REP(i,n)cin>>A[i];
    vector<P>x(n);
    vector<P>y(n);
    x[0]={T[0],1};
    y[n-1]={A[n-1],1};
    REP(i,n-1){
        if(T[i]<T[i+1]){
            x[i+1]={T[i+1],1};
        }else{
            x[i+1]={T[i+1],0};
        }
    }
    for(int i=n-2;i>=0;i--){
        if(A[i+1]<A[i]){
            y[i]={A[i],1};
        }else{
            y[i]={A[i],0};
        }
    }
    ll ans=1;
    REP(i,n){
        if(x[i].second==0&&y[i].second==0){
            ans*=min(x[i].first,y[i].first);
            ans%=MOD;
        }else if(x[i].second==1&&y[i].second==1){
            if(x[i].first!=y[i].first)ans=0;
        }else{
            if(x[i].second==0){
                if(x[i].first<y[i].first)ans=0;
            }else{
                if(x[i].first>y[i].first)ans=0;
            }
        }
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 2560