akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}




int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    vector<ll>v(5);
    ll k;
    for(int i=0;i<5;i++){
        cin>>v[i];
    }
    cin>>k;
    sort(v.begin(),v.end());
    ll res=0;
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            if(i==j)continue;
            if(abs(v[i]-v[j])>k)res++;
        }
    }
    if(res>0)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
    return 0;

}


Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var n,x=[],y=[],c=[];
var q = 360;

console.log(main());
function main(){
  n = o.a();
  for(var i = 0; i < n; i++){
    var a = o.a(), b = o.a();
    if(a === 0 && b === 0)continue;
    x.push(a);
    y.push(b);
    c.push(f(a,b));
  }
  n = x.length;
  var ans = 0;
  for(var i = 0; i < q; i++){
    var v = i*360/q;
    var tx = 0, ty = 0;
    for(var j = 0; j < n; j++){
      if(c[j] < v-270 || (v-90 < c[j] && c[j] < v+90) || v+270 < c[j]){
        tx += x[j], ty += y[j];
      }
    }
    var z = tx*tx+ty*ty;
    if(ans < z)ans = z;
  }
  return Math.sqrt(ans);
}

function f(a,b){
  if(a === 0){
    return b > 0 ? 90 : 270;
  }
  if(b === 0){
    return a > 0 ? 0 : 180;
  }
  var r = Math.atan(b/a)/Math.PI*180;
  if(a < 0)r += 180;
  if(r < 0)r += 360;
  return r;
}

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

int main()
{
  char c;
  
  vector<int> found(26);
  while (cin >> c)
  {
    if (found.at((int)c - 97) > 0)
    {
      cout << "no";
      return 0;
    }
    found.at((int)c - 97) ++;
  }
  
  cout << "yes";
  return 0;
}


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

int x;
string s,t;

int main() {
  cin >> x;
  int ans; bool p=true;
  if(x==2){
  cout << 2 << endl; return 0;
  }
  if(x%2==0) x++;
  while(1){
    for(int i=2;i*i<=x;i++){
      if(x%i==0) p=false;
    }
    if(p){
     ans=x; break;
    }
    x+=2; p=true;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{	
	int n;
	cin >> n;
	V<LL> a(n);
	RBF(ai, a) {
		cin >> ai;
	}
	downsort(a);

	queue<LL> que;
	que.push(a[0]);

	LL com = 0;
	int i = 1;
	while (i < n) {
		com += que.front();
		que.pop();
		que.push(a[i]);
		que.push(a[i]);
		i++;
	}

	col(com);
	return 0;
}


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

using namespace std;

struct Node
{
    int data;
    struct Node* left;
    struct Node* right;
    Node(int x)
    {
        data=x;
        left=NULL;
        right=NULL;
    }
};
#define Node struct Node

ll modpow(ll a, ll n)
{
    ll m=1e9+7;
    if(n==0)
        return 1;
    ll y=modpow(a,n/2)%m;
    if(n%2==0)
        return (y*y)%m;
    return (((y*y)%m)*a)%m;
}

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

    }
    return 0;
}
















Measured memory_bytes: 3620
#include<stdio.h>
#include<math.h>
int main(void)
{
	int i,n,s[1001];
	double m,a;
	while(1)
	{
		scanf("%d",&n);
		if(n==0){break;}
		m=0.0;a=0.0;
		for(i=0;i<n;i++)
		{
			scanf("%d",&s[i]);
			m+=1.0*s[i];
		}
		m/=n;
		for(i=0;i<n;i++)
		{
			a+=(s[i]-m)*(s[i]-m);
		}
		a/=n;
		a=sqrt(a);
		printf("%lf\n",a);
	}
	return 0;
}

Measured memory_bytes: 636
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

t = input()
s = t.replace("0", "")
q = len(s) # 1の数
n = len(t)
ps = [None]*(q+1)
c = 0
j = 0
for tmp in t:
    if tmp=="1":
        ps[j] = c
        j += 1
        c = 0
    else:
        c += 1
ps[-1] = c

dp = [0] * q # インデックスqの1までのベストな配置のときの奇数の個数
pp = [0] * (q+1) # 上を実現するために使うpsの個数
if not dp:
    print(0)
else:
    dp[0] = 1
    j = 1 # j : トータルのインデックス(1はじまり)
    for i in range(1,q):
        j += 1
        p = ps[i]
        if j%2:
            pp[i] = 0
            dp[i] = dp[i-1] + 1
        elif p:
            pp[i] = 1
            j += 1
            dp[i] = dp[i-1] + 1
        else:
            pp[i] = 0
            dp[i] = dp[i-1]
    if q%2==0:
        ans = q//2 * (q//2 + 1)
    else:
        ans = q//2 * (q//2 + 1) + q//2 + 1
    
    # 1をすべて入れたあとに得られる利得
    # ppを前から順にいれていく
    j = 0
    for i in range(q+1):
        j += 1
        if not pp[i]:
            continue
        # 0を１個いれる
        j += 1
        ans += dp[i]
        if j%2:
            ans += (q-i-1) // 2
        else:
            ans += (q-i-1) // 2 + (q-i-1)%2
    
    # 残りのpsを後ろから順にいれていく
    o = 0 # 現時点より後ろの(jを0としたときの)奇数番目の1の個数
    e = 0 # 現時点より後ろの(jを0としたときの)偶数番目の1の個数
    j = q + sum(pp) # 現在地のインデックス(1はじまり)
    for i in range(q, 0, -1):
        num = ps[i] - pp[i]
        if num>0:
            ans += dp[i-1] * num
            if num%2==0:
                ans += (num//2)*o + (num//2)*e
            else:
                ans += (num//2)*o + (num//2)*e + (e if j%2==0 else o)
                e,o = o,e
        j -= 1
        if pp[i-1]:
            j -= pp[i-1]
            e += 1
        else:
            o, e = 1 + e, o

    # 最初の0を入れる
    num = ps[0] - pp[0]

    if num%2==0:
        ans += (num//2)*o + (num//2)*e
    else:
        ans += (num//2)*o + (num//2)*e + e if j%2==0 else o

    print(ans)

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


int main(void) {
    int N, L, allpie;
    scanf("%d %d", &N, &L);

    allpie = N*(N+1)/2+N*(L-1);

    if (1-L < 1) {
        printf("%d\n", allpie - L);
    } else if (1-L > N) {
        printf("%d\n", allpie - (L + N -1));
    } else {
        printf("%d\n", allpie);
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int x;
		int i = 1;
	    for(;;){
	    	x = s.nextInt();
	    	if(x == 0) break;
	    	System.out.println("Case " + i + ": " + x);
	    	i++;
	    }
	    
	}
	public static void main(String[] args) {
		
		new Main().run();
		
	}
}

Measured memory_bytes: 42736
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;
long long h[100010];
long long dp[100010];

int main(){
int N;cin >> N;
int h[N];

for(int i = 0; i < N;i++){
    cin >> h[i];
}

for(int i = 0; i < 100010; i++){
    dp[i] = INF;
}

dp[0] = 0;

for(int i = 1; i < N; i++){
    chmin(dp[i],dp[i-1] + abs(h[i] - h[i-1]));
    if(i > 1){
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
}

cout << dp[N-1] << endl;

return 0;
}

Measured memory_bytes: 1408
n, l = map(int, input().split())

def func(x):
  return(x+l)

a = list(range(n))
b = list(map(func, a))

m = l
for i in range(len(b)):
  if abs(m) > abs(b[i]):
    m = b[i]

ans = sum(a)+l*n-m
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

vector<PII> G[100010];
queue<PII> que;// que{Verticle, Distance}
priority_queue<PII, vector<PII>, greater<PII> > pq;
int main(void){
	int N, M, K, S;
	int P, Q;
	cin >> N >> M >> K >> S;
	cin >> P >> Q;
	int isDanger[100010] = {};
	REP(i, K){
		int C;
		cin >> C;
		C--;
		que.push({C, 0});
		isDanger[C] = 2;
	}
	REP(i, M){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back({0, b});
		G[b].push_back({0, a});
	}
	while(que.size()){
		PII p = que.front(); que.pop();
		if(p.second > S) continue;
		if(isDanger[p.first] == 1) continue;
		if(isDanger[p.first] == 0) isDanger[p.first] = 1;
		REP(i, G[p.first].size()){
			que.push({G[p.first][i].second, p.second+1});
		}
	}
	REP(i, N){
		REP(j, G[i].size()){
			if(isDanger[G[i][j].second]) G[i][j].first = Q;
			else G[i][j].first = P;
		}
	}

	ll d[100010];
	fill(d, d+N, INF_LL);
	d[0] = 0;
	pq.push({0, 0});
	while(pq.size()){
		PII p = pq.top(); pq.pop();
		if(d[p.second] < p.first) continue;
		if(isDanger[p.second] == 2) continue;

		REP(i, G[p.second].size()){
			int v = G[p.second][i].second;
			int e = G[p.second][i].first;

			if(d[v] > d[p.second] + e){
				d[v] = d[p.second] + e;
				pq.push({d[v], v});
			}
		}
	}
	if(isDanger[N-1]) cout << d[N-1] - Q << endl;
	else cout << d[N-1] - P << endl;
}

Measured memory_bytes: 13280
using namespace std;

#include <cstdio>
#include <cstdint>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

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

    int     A = 0;
    int     B = 0;
    int     C = 0;
    int     D = 0;
    string  ans;
    cin >> A >> B >> C >> D;

    int Ttime = 0;
    int Atime = 0;

    while(1){
        A = A - D;
        Ttime++;
        if(A <= 0){
            break;
        }
    }
    while(1){
        C = C - B;
        Atime++;
        if(C <= 0){
            break;
        }
    }

    if(Ttime >= Atime){
        ans = "Yes";
    }else{
        ans = "No";
    }
    cout << ans << "\n";
    return 0;
    
}

Measured memory_bytes: 3640
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            list.add(A[i]);
        }

        Collections.sort(list);

        for(int i=0; i<N; i++){
            if(A[i]==list.get(N-1)){
                System.out.println(list.get(N-2));
            }
            else{
                System.out.println(list.get(N-1));
            }
        }
    }
}

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

template <typename T>
void print_vector(vector<T>& vec) {
    cout << "print_vector -> ";
    for(int i=0; i<vec.size(); i++) {
        if(i == vec.size()-1) {
            cout << vec[i] << endl;
        }
        else {
            cout << vec[i] << " ";
        }
    }
    return;
}

int main() {

    int N;
    unsigned long long K;
    cin >> N >> K;

    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    vector<int> data(N+1);
    vector<bool> find_map(N+1, false);

    int point = 1;
    unsigned long long count = 0;
    int loop_start = -1;
    int loop_end = -1;
    int loop_town = -1;
    for(int i=0; i<N; i++) {
        if(find_map[point]) {
            loop_end = i;
            loop_town = point;
        }
        data[i] = point;
        find_map[point] = true;
        point = A[point-1];
    }

    for(int i=0; i<N; i++) {
        if(data[i] == loop_town) {
            loop_start = i + 1;
            break;
        }
    }

    unsigned long long index;
    if(K < loop_start) {
        index = K;
    }
    else {
        index = (K - loop_start) % (loop_end - loop_start + 1) + loop_start;
    }

    cout << data[index] << endl;

    return 0;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    void merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return;
        if (-par[x] < -par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
};

int main(){
    int n;
    cin >> n;
    vec<P<int, int>> xy;
    rep(i, n) {
        int x, y; cin >> x >> y;
        xy.emplace_back(x, y);
    }
    vec<P<int, int>> px(n), py(n);
    rep(i, n) {
        px[i] = P<int, int>(xy[i].first, i);
        py[i] = P<int, int>(xy[i].second, i);
    }
    sort(px.begin(), px.end());
    sort(py.begin(), py.end());
    vec<P<ll, P<int, int>>> edges;
    int idx_prev = px[0].second;
    int idy_prev = py[0].second;
    rep(i, n-1) {
        int idx = px[i+1].second;
        int idy = py[i+1].second;
        ll costx = abs(xy[idx].first - xy[idx_prev].first);
        ll costy = abs(xy[idy].second - xy[idy_prev].second);
        edges.emplace_back(costx, P<int, int>(idx_prev, idx));
        edges.emplace_back(costy, P<int, int>(idy_prev, idy));
        idx_prev = idx, idy_prev = idy;
    }

    sort(edges.begin(), edges.end());
    UnionFind uf(n);
    long long res = 0;
    for (auto e : edges) {
        int u = e.second.first, v = e.second.second;
        long long cost = e.first;
        if (uf.issame(u, v)) continue;
        uf.merge(u, v);
        res += cost;
    }
    cout << res << endl;
}

Measured memory_bytes: 8816
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    s = input()
    n = len(s)
    l = []
    a,b = 0,0
    for i in range(n):
        if s[i] == "<":
            if b > 0:
                l.append(b)
                b = 0
            a+=1
        else:
            if a > 0:
                l.append(a)
                a = 0
            b += 1
    if a > 0:
        l.append(a)
        a = 0
    if b > 0:
        l.append(b)
        b = 0
    ans = 0
    #print(l)
    if s[0] == "<":
        for i in range(0, len(l) - len(l) % 2, 2):
            if l[i] == l[i + 1]:
                ans += l[i]*l[i]
            elif l[i] < l[i + 1]:
                ans += l[i] * (l[i] - 1) // 2
                ans += l[i + 1] * (l[i + 1] + 1) // 2
            else:
                ans += l[i] * (l[i] + 1) // 2
                ans += l[i + 1] * (l[i + 1] - 1) // 2
        if len(l) % 2 == 1:
            ans += l[len(l) - 1] * (l[len(l) - 1] + 1) // 2
    else:
        ans += l[0]*(l[0]+1)//2
        for i in range(1, (len(l)-1) - (len(l)-1) % 2, 2):
            if l[i] == l[i + 1]:
                ans += l[i]*l[i]
            elif l[i] < l[i + 1]:
                ans += l[i] * (l[i] - 1) // 2
                ans += l[i + 1] * (l[i + 1] + 1) // 2
            else:
                ans += l[i] * (l[i] + 1) // 2
                ans += l[i + 1] * (l[i + 1] - 1) // 2
        if (len(l)-1) % 2 == 1:
            ans += l[len(l) - 1] * (l[len(l) - 1] + 1) // 2

                

    print(ans)
             
        
        
            

    
   


if __name__ == '__main__':
    main()


Measured memory_bytes: 8360
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int K;
  cin >> K;
  queue<ll> que;
  for (int i=1; i<=9; i++) que.push(i);
  for (int i=0; i<K; i++) {
    ll x = que.front();
    if (i==K-1) {
      cout << x << endl;
      return 0;
    }
    que.pop();
    if (x%10!=0) que.push(10*x+(x%10)-1);
    que.push(10*x+x%10);
    if (x%10!=9) que.push(10*x+(x%10)+1);
  }
}

Measured memory_bytes: 5148
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))}
const main=()=>{
  let s=ts().split('').sort()
  if(s[0]!='a'){
    to('a')
    return
  }
  for(let i=1;i<s.length-1;i++){
    if(s[i+1].charCodeAt(0)-s[i].charCodeAt(0)>1){
      to(String.fromCharCode(s[i].charCodeAt(0)+1))
      return
    }
  }
  if(s[s.length-1]!='z'){
    to(String.fromCharCode(s[s.length-1].charCodeAt(0)+1))
    return
  }
  to('None')
}
main()

Measured memory_bytes: 9528
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        var S = String ();

        if (S == "Sunny") {
            Console.WriteLine ("Cloudy");
        } else if (S == "Cloudy") {
            Console.WriteLine ("Rainy");
        } else if (S == "Rainy") {
            Console.WriteLine ("Sunny");
        }
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 13140
from collections import Counter

n = int(input())
a = input().split()
q = int(input())
counter = Counter(a)
total = 0
for k, v in counter.items():
    total += int(k) * v
for _ in range(q):
    b, c = input().split()
    if counter.get(b):
        total = total - int(b) * counter.get(b) + int(c) * counter.get(b)
        if counter.get(c):
            counter[c] = counter.get(b) + counter.get(c)
        else:
            counter[c] = counter.get(b)
        counter[b] = 0
    print(total)


Measured memory_bytes: 21468
N = int(input())
X = list(map(int, input().split()))

ans = []
count = 0

for i in range(0,101):
    number = 0
    count = 0
    for j in X:
        number = number + ((j-i)**2)
        count = count + 1
        if N == count:
            ans.append(number)

print(min(ans))

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for( int i = 0; i < n; i++)
using namespace std;
using ll = unsigned long long;
int main()
{
    
    int x, n;
    cin >> x >> n ;
    int p[n];
    rep(i,n)cin >> p[i] ;
   
    int ans = 101; 
    //for( int i = -100; i <= 100; i++){
    for( int i = -100; i <= 100; i++){
      bool batu = false;
      rep(j,n){
        if( i == p[j] ){
            batu = true;
            break;
        }
      }
      if( batu ) continue;
      int diftmp = x - i;
      if( abs( diftmp ) < abs( x - ans ) ) {
        ans = i;
      }
      else if( abs( diftmp ) == abs( x - ans ) ) {
        if( i < ans ) ans = i;
      }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
A = input()
B = input()

lans = list()
if len(A) == len(B):
    for i in range(len(A)):
        lans.extend([A[i],B[i]])

else:
    for i in range(len(A)-1):
        lans.extend([A[i],B[i]])
    lans.extend(A[-1])

#print(lans)
lans=''.join(lans)
print(lans)

Measured memory_bytes: 3060
#include<iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define MOD 1000000007ll
const int MAX=10000;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    COMinit();

    ll n, k;
    cin >> n >> k;
    ll ans;


    for (ll i = 1; i <= k; i++){
        ans = ((COM(k-1, i-1))%MOD * COM(n-k+1, i)%MOD)%MOD;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 512
# coding=utf-8

n = int(input())
n4 = 0
n2 = 0
n1 = 0
for x in input().split(" "):
    x = int(x)
    if x%4==0:
        n4 += 1
    elif x%2==0:
        n2 += 1
    else:
        n1 += 1

if n2>1:
    n2 = 1

if n1+n2-1<=n4:
    print("Yes")
else:
    print("No")


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

int main(){
int n;
int max = 0;
string s;
cin >> n >> s;
int l = s.size();
for (int i=0;i<l-1;i++){
    int count;
    bool x;
    count = 0;
    for(int j=0;j<=i;j++){
        x = true;
        for(int m=0;m<j;m++){
        if(s.at(m)==s.at(j)){
            x=false;
            break;
        }
    }
    if(x){
        for(int k=i+1;k<l;k++){
            if(s.at(j)==s.at(k)){
                count++;
                break;
            }
        }
    }
    }
    if(max<count) max=count;
}
cout << max;
}

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

int main(){
  using namespace std;
  int h,w,count=0;
  char c;
  cin >> h >> w;
  vector<vector<char>> area(h+2,vector<char>(w+2));
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin >> c;
      area.at(i).at(j)=c;
    }
  }

  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      count = 0;
      if(area.at(i).at(j)=='.'){
        for(int k=i-1;k<=i+1;k++){
          for(int l=j-1;l<=j+1;l++){
            if(area.at(k).at(l)=='#') count++;
          }
        }
        area.at(i).at(j) = count + '0';
      }
      cout << area.at(i).at(j);
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): any => {
  const N = +lines[0]
  lines.shift()
  const An = lines.map(line => line.split(` `).map(num => +num))
  const obj = { N, An }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  const { N, An } = parseLines(lines)
  let point = 0;
  let tmp = null;
  for(let i = 0; i < N; i++) {
    point += An[1][i]
    if (tmp !== null && An[0][tmp] + 1 === An[0][i]) {
      point += An[2][An[0][tmp] - 1]
    }
    tmp = i
  }
  return `${point}`

}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 7500
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int p[n]; for (auto &pi:p) cin >> pi;
    sort(p, p+n);
    int ans = 0; for (int i=0; i<k; i++) ans += p[i];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3600
from itertools import accumulate

N, W = map(int, input().split())
wv = {}
w1 = 0
for i in range(N):
  w, v = map(int, input().split())
  if i == 0:
    w1 = w
  if w in wv:
    wv[w].append(v)
  else:
    wv[w] = [v]

for w in wv:
  wv[w].sort(reverse=True)
  wv[w] = [0] + list(accumulate(wv[w]))

w2 = w1+1; w3 = w1+2; w4 = w1+3
for w in [w1, w1+1, w1+2, w1+3]:
  if w not in wv:
    wv[w] = [0]

ans = 0
for n1 in range(len(wv[w1])):
  for n2 in range(len(wv[w2])):
    for n3 in range(len(wv[w3])):
      for n4 in range(len(wv[w4])):
        w = w1*n1 + w2*n2 + w3*n3 + w4*n4
        if w <= W:
          ans = max(ans, wv[w1][n1]+wv[w2][n2]+wv[w3][n3]+wv[w4][n4])

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
char a,b;
char dh[] = {'D', 'H'};

int f(char c){
  return c=='D' ? 0:1;
}

int main(){
  cin>>a>>b;
  if(f(a))
    cout << dh[f(b)] << endl;
  else
    cout << dh[1-f(b)] << endl;

  return 0;
}


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

const int MOD = 1e9+7;
int n;
int li[30][30];

int memo[23][(1<<21)];

int dp(int id, int mask){
   if(id>=n) return 1;
   int &ret = memo[id][mask];
   if(ret != -1) return ret;
   ret = 0;
   for(int i=0;i<n;i++){
      if((1<<i) & mask) continue;
      if(li[id][i] == 0) continue;
      ret += dp(id+1,(1<<i) | mask);
      ret %= MOD;
   }
   return ret;
}

int main(){
   memset(memo,-1,sizeof(memo));
   scanf("%d",&n);
   for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
         scanf("%d",&li[i][j]);
      }
   }
   int ans = dp(0,0);
   printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 188672
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int n = scanner.nextInt();
    LinkedList<Integer> list = new LinkedList<>();
    for (int i = 0; i < n; i++) {
      int a = scanner.nextInt();
      if (i % 2 == 0) list.addFirst(a);
      else list.addLast(a);
    }
    if (n % 2 == 0) Collections.reverse(list);
    StringBuilder sb = new StringBuilder();
    for (int b : list) sb.append(b).append(" ");
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 98488
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			long sum = 0;
			for(int i = 0; i < n; i++){
				sum += sc.nextInt();
			}
			System.out.println(n == 0 ? 0 : sum / n);
		}
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 29332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> V;
const long long MOD=1000000007LL;
const long long INFL=1LL << 60;
const int INF=1<<29;


int main() {
    int A,P;
    cin >>A>>P;
    cout<<(3*A+P)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
h=[int(i) for i in input().split()]
dp=[0 for i in range(N)]
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])


Measured memory_bytes: 13936
#include <stdio.h>
#include <limits.h>

#define MAX_N 50001
#define MAX_M 21
int m, n;
int c[MAX_M] = {0};

void showT(int A[], int i) {
	int j;
	printf("%d\n", i);
	
	for (j = 0; j <= n; ++j) {
		printf("%d ", A[j]);
	}
	putchar('\n');
}

int getTheNumberOfCoin() {
	int i, j;
	int T[MAX_N] = {0};
	
	for (i = 0; i <= n; ++i) {
		T[i] = INT_MAX;
	}
	T[0] = 0;

	for (i = 0; i < m; ++i) {
		for (j = c[i]; j <= n; ++j) {
			T[j] = ((T[j] < T[j - c[i]] + 1) ? T[j] : T[j - c[i]] + 1);
		}
		//	showT(T, i);
	}
	return T[n];
}

int main(void) {
	int i;
	scanf("%d %d", &n, &m);

	for (i = 0; i < m; ++i) {
		scanf("%d", &c[i]);
	}

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

Measured memory_bytes: 800
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n;
    cin>>n;
    int a[n][3];
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            cin>>a[i][j];
        }
    }
    int dp[n][3];
    for (int i = 0; i < 3; ++i)
    {
        dp[0][i] = a[0][i];
    }
    for (int i = 1; i < n; ++i)
    {
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i][0];

        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + a[i][1];

        dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + a[i][2];      
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    printclock;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define endl '\n'
#define dri(X) int X; cin>>X
#define drii(X, Y) int X, Y; cin>>X>>Y
//#define __fd cout.setf(ios::fixed); cout.precision(18)
#define preturn(X) cout<<X<<endl; return 0
typedef long long ll;
//typedef int64_t ll;
//const ll MOD = 1e9+7;







int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);
	ll x;
	cin>>x;
	int i=1;
	while((i*(i+1))/2 < x){
		i++;
	}
	preturn(i);	
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()
winner = ''
winner_f = ''
for i in S:
    if i == 'a':
        if len(winner)<A+B:
            print('Yes')
            winner += 'a'
        else:
            print('No')
    elif i == 'b':
        if len(winner)<A+B and len(winner_f)<B:
            print('Yes')
            winner += 'b'
            winner_f += 'b'
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4400
n,k=map(int,input().split())
a=list(map(lambda x:(int(x)-1)%k,input().split()))
s=[0]
for i in a:
    s.append((s[-1]+i)%k)
mp={}
ans=0
for i in range(len(s)):
    if i-k>=0:
        mp[s[i-k]]-=1
    if s[i] in mp:
        ans+=mp[s[i]]
        mp[s[i]]+=1
    else:
        mp[s[i]]=1
print(ans)


Measured memory_bytes: 41224
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        string S = NextString();
        int w = NextInt();
        for (int i = 0; i < S.Length; i += w) Console.Write(S[i]);
        Console.WriteLine();
    }
}


public class PriorityQueue<Tkey, Tvalue> where Tkey : IComparable
{
    private static List<Tkey> list = new List<Tkey>();
    private static List<Tvalue> value = new List<Tvalue>();
    public int Count { get; private set; } = 0;
    private static bool Descending;
    public PriorityQueue(bool b = true) { Descending = b; list = new List<Tkey>(); value = new List<Tvalue>(); }
    private static int Compare(Tkey a, Tkey b)
    {
        if (Descending) return a.CompareTo(b);
        else return b.CompareTo(a);
    }
    public void Enqueue(Tkey e, Tvalue n)
    {
        Count++;
        int now = Count - 1;
        list.Add(e);
        value.Add(n);
        while (now != 0)
        {
            int par = (now - 1) / 2;
            if (Compare(list[par], e) <= 0) break;
            Tkey a = list[now]; list[now] = list[par]; list[par] = a;
            Tvalue b = value[now]; value[now] = value[par]; value[par] = b;
            now = par;
        }
    }
    public Tvalue Dequeue()
    {
        if (Count == 0) return (Tvalue)(object)(-1);
        Tvalue e = value.First();
        if (Count == 1) { list = new List<Tkey>(); value = new List<Tvalue>(); Count--; return e; }
        Tkey x = list[Count - 1];
        Tvalue y = value[Count - 1];
        int i = 0;
        while (i * 2 + 1 < Count)
        {
            int l = i * 2 + 1;
            int r = i * 2 + 2;
            if (r < Count && Compare(list[r], list[l]) < 0) l = r;
            if (Compare(list[l], x) >= 0) break;
            list[i] = list[l];
            value[i] = value[l];
            i = l;
        }
        list[i] = x;
        value[i] = y;
        Count--;
        return e;
    }
    public Tvalue Top() { return value[0]; }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
#include <stdio.h>

int main(void) {
	int n, i, j;
	double sum;
	
	sum=100000.0;
	
	scanf("%d", &n);
	
	for(i=0;i<n;i++)
	{
	sum*=1.05;
	
		for(j=0;;j++){
		if(sum<=1000*j)
		break;
	}
	
	sum=1000*j;
	
	}
	

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

Measured memory_bytes: 592
n,m = map(int,input().split())
H = [int(i) for i in input().split()]
H_max = [True for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    if H[a-1]>H[b-1]:
        H_max[b-1] = False
    elif H[a-1]<H[b-1]:
        H_max[a-1] = False
    else:
        H_max[a-1] = False
        H_max[b-1] = False
ans = 0
for i in range(n):
    if H_max[i] == True:
        ans += 1
print(ans)

Measured memory_bytes: 20124
// Author : Epsilon573
// If it works, don't touch it.

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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf  = LLONG_MAX;
const ll minf = LLONG_MIN;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cerr << #x << " " << x << endl
#define pi  3.141592653589793
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll a,b,h,m;
    cin >> a >> b >> h >> m;
    
    db angle;

    angle = 2*pi*abs( (db)m/60 - (db)h/12 - ((db)m/60)/(db)12  );

    cout << setprecision(12) << fixed << sqrt(a*a+b*b-2*a*b*cos(angle)); 
    return 0;
} 

Measured memory_bytes: 4248
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;

void div(vi&p, int x)
{
	for(int i=2;i*i<=x;i++)
	{
		if(x%i==0)
		{
			for(;x%i==0;x/=i)
			{
				p[i]++;
			}
		}
	}
	if(x>1) p[x]++;
}


int nPm(int n, int m)
{
	int ret=1;

	if(n<m) return 0;

	for(int i=0;i<m;i++)
	{
		ret*=n-i;
	}
	return ret;
}


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		int pn=n+1;
		vi p(pn);

		for(int i=2;i<=n;i++)
		{
			div(p, i);
		}

		int cn=75;
		vi c(cn);
		for(int i=0;i<pn;i++)
		{
			c[min(p[i], 74)]++;
		}
		for(int i=cn-1;i>0;i--)
		{
			c[i-1]+=c[i];
		}

		int ans=0;

		ans+=nPm(c[4], 2)/2*(c[2]-c[4])+nPm(c[4], 3)/2;
		ans+=c[14]*(c[4]-c[14])+nPm(c[14], 2);
		ans+=c[24]*(c[2]-c[24])+nPm(c[24], 2);
		ans+=c[74];

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n, m, a[100] = {},k=0;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        k += a[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = n - 1; j > i; j--) {
            if (a[j] > a[j - 1]) swap(a[j - 1], a[j]);
        }
    }
    if (a[m - 1] >= 1. *k/ (4 * m)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c,s,m,l;
    scanf("%d %d %d", &a, &b, &c);
    if(a<b){
        if(c<a){
            s=c;m=a;l=b;
        }else if(b<c){
            s=a;m=b;l=c;
        }else{
            s=a;m=c;l=b;
        }
    }else{
        if(c<b){
            s=c;m=b;l=a;
        }else if(a<c){
            s=b;m=a;l=c;
        }else{
            s=b;m=c;l=a;
        }
    }


    printf("%d %d %d\n",s,m,l);
    return 0;
}


Measured memory_bytes: 2096
n=int(input())
B=list(map(int,input().split()))
# print(B)
ans = [[] for i in range(n)]
ans[0] = B[0]
ans[-1]= B[-1]
for i in range(1,n-1):
  ans[i] = [B[i-1],B[i]]
# print(ans)
for i in range(1,n-1):
  ans[i] = min(ans[i])
print(sum(ans))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< long long int, long long int > prime_factor(long long int n) {//素因数分解
    map< long long int, long long int > ret;
    for(long long int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main() {

    int N;
    cin >> N;
    int p[N];
    for(int i=0;i<N;i++){
        cin >> p[i];
    }

    int count=1;


    for(int i=0;i<N-1;i++){
        if(p[i]==i+1){
           count++;
        }
    }

    if((N-count)<=2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }


}








Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;


int main(){

    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    int pay;
    if ( N >  K){
        int count = 0;
        
        for ( int i = 1; i << N; i++){

            if (i <=  K  ){
                count++;
            }   
        }
        pay = count * X + (N - count) * Y;
    }
        

    else pay = N * X;

    cout << pay<< endl;
}





Measured memory_bytes: 256
import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  val Array(n, noOfTrucks) = readLine.split(" ").map(_.toInt)
  val weights: Array[Int] = new Array[Int](n)
  var sum = 0L
  for (i <- 0 until n) {
    val w = readInt
    weights(i) = w
    sum += w
  }
  val ans = allocation(noOfTrucks, weights, sum)
  println(ans)

  def allocation(noOfTrucks: Int, weights: Array[Int], sum: Long): Long = {
    var start = 0L
    var end = sum
    while (true) {
      val p = (start + end) / 2
      val success = canAllocate(p, weights, noOfTrucks);
      if (success && start == end) {
        return p
      }
      if (success) {
        end = p - 1
      } else {
        start = p + 1
      }
      if (start > end) {
        end = start
      }
    }
    -1
  }

  def canAllocate(p: Long, weights: Array[Int], noOfTrucks: Int): Boolean = {
    var truckCount = 1
    var load = 0
    weights.foreach( w => {
      if (w > p) return false
      if (load + w <= p) {
        load += w
      } else {
        truckCount += 1
        if (truckCount > noOfTrucks) {
          return false
        }
        load = w
      }
    })
    true
  }
}



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

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

	vector<string> S( n );
	for( auto& v: S ) { cin >> v; }

	vector<vector<int>> cm( n, vector<int>(256) );
	for( int i = 0; i < n; ++i ) {
		for( auto ch: S[i] ) { cm[i][ch] += 1; }
	}

	for( char i = 'a'; i <= 'z'; ++i ) {
		int x = INT_MAX;

		for( int j = 0; j < n; ++j ) {
			if( cm[j][i] < x ) {
				x = cm[j][i];
			}
		}

		while( x-- ) {
			cout << i;
		}
	}

	cout << endl;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
  public static void main  (String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ret = (a + b) / 2;
    if ((a + b) % 2 != 0) {
      ret ++;
    }
    System.out.println(ret);
  }
}

Measured memory_bytes: 22740
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 998244353
mans = inf ;ans = 0 ;count = 0 ;pro = 1
sys.setrecursionlimit(10**6)

n = int(input())
XD = [tuple(map(int,input().split())) for i in range(n)]
XD.append((-10**10,inf))
XD.sort()

def dfs(node):
  res = 1
  i = node + 1
  while i < n+1:
    if XD[i][0] < XD[node][0] + XD[node][1]:
      pro,i = dfs(i)
      res *= pro
      res %= mod
    else: break

  return res + 1 , i
print((dfs(0)[0]-1)%mod)


Measured memory_bytes: 202380