akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std ;


const int N = 200010;
int n , s , t , tot , r ;
int fire[N] , nex[2*N] , to[2*N] , Ans[N] , dep[N] ;

int read()
{
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {  // ch 不是数字时
    if (ch == '-') w = -1;        // 判断是否为负
    ch = getchar();               // 继续读入
  }
  while (ch >= '0' && ch <= '9') {  // ch 是数字时
    x = x * 10 + (ch - '0');  // 将新读入的数字’加’在 x 的后面
    // x 是 int 类型，char 类型的 ch 和 ’0’ 会被自动转为其对应的
    // ASCII 码，相当于将 ch 转化为对应数字
    // 此处也可以使用 (x<<3)+(x<<1) 的写法来代替 x*10
    ch = getchar();  // 继续读入
  }
  return x * w;  // 数字 * 正负号 = 实际数值
}

void add(int u , int v){
    nex[++tot] = fire[u] ;
    fire[u] = tot ;
    to[tot] = v ;
}

void dfs1(int x , int fr){
    dep[x] = dep[fr] + 1 ;
    Ans[x] = dep[x] ;
    for(int i = fire[x] ; i ; i = nex[i] ){
        int v = to[i] ;
        if( v == fr ) continue ;
        dfs1( v , x ) ;
        Ans[x] = max( Ans[x] , Ans[v] ) ;
    }
}

int dfs2(int x , int fr , int now )
{
    if( now >= dep[x] ) return 0 ;
    for(int i = fire[x] ; i ; i = nex[i] ){
        int v = to[i] ;
        if( v == fr ) continue ;
        if( dfs2( v , x , now + 1 ) == 0 ) {
            r = x ;
        }
    }
    return 1 ;
}

int main()
{
    n = read();
    s = read();
    t = read();
    for(int i = 1 ; i <= n - 1 ; i++ ){
        int u , v ;
        u = read();
        v = read();
        add( u , v ) ; add( v , u ) ;
    }
    dfs1( t , 0 ) ;
    dfs2( s , 0 , 0 ) ;
    printf("%d\n" , Ans[r] - 2 ) ;
    return 0 ;
}

Measured memory_bytes: 7808
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
    int i,j,a,sum=0;
    stack<int> S1;
    stack<pair<int, int> > S2;
    string ch;
    getline(cin, ch);
    for(i=0;i<ch.size();i++){
        if(ch[i]=='\\') S1.push(i);
        else if(ch[i]=='/' && S1.size()>0){
            j = S1.top();S1.pop();
            sum += i - j;
            a = i - j;
            while(S2.size()>0 && S2.top().first > j){
                a += S2.top().second; S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    while(S2.size()>0) {ans.push_back(S2.top().second); S2.pop();}
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(i=0;i<ans.size();i++){
        cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int a[10000];

int main(){
	int n=read();
	int s=0,sum=0;
	for(int i=1;i<=n;i++){
		a[i]=read();
		if(a[i]!=a[i-1]){
			sum+=s/2;
			s=0;
		}
		s++;
	}
	sum+=s/2;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int num, min, max, temp, count;
    long long int total = 0;
    int* array;
    
    cin >> num;
    count = num;
    array = new int[num];
    for (int i = 0; i < num; ++i) {
        cin >> *(array + i);
        total += *(array + i);
    }
    for (int i = 0; i < count; --count) {
        for (int j = 0; j < (count - 1); ++j) {
            if (*(array + j) > *(array + (j + 1))) {
                temp = *(array + j);
                *(array + j) = *(array + (j + 1));
                *(array + (j + 1)) = temp;
            }
        }
    }
    min = *array;
    max = *(array + (num - 1));
    cout << min << ' '
         << max << ' '
         << total << endl;
    delete[] array;
    
    return 0;
}


Measured memory_bytes: 3116
import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine

  val month = (1 to 12)
  val first = if(month.contains(s.take(2).toInt)) true else false
  val second = if(month.contains(s.drop(2).toInt)) true else false

  val ans = (first, second) match {
    case (true, true) => "AMBIGUOUS"
    case (true, false) => "MMYY"
    case (false, true) => "YYMM"
    case _ => "NA"
  }
  println(ans)
}

Measured memory_bytes: 25548
import java.util.*;
import java.io.*;

class Mod{
    static final int MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

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

        long[][] dp = new long[N][N];
        //dp[i][j] : the way of arranging 'i' elements where 'j' elms are greater than p[i-1]
        //0<= i <N, 0<= j <=N-i

        Arrays.fill(dp[0],1);
        for(int n=1; n<N; n++){
            boolean gt = s.charAt(n-1)=='<';
            if(gt){
                dp[n][N-n] = 0;
                for(int j=N-n-1; j>=0; j--){
                    //dp[n][j] = dp[n-1][j] + dp[n-1][j+1] + ... + dp[n-1][N-n]
                    dp[n][j] = Mod.add(dp[n][j+1], dp[n-1][j+1]);
                    //System.err.printf("<%d %d %d\n", n,j,dp[n][j]);
                }
            }else{
                dp[n][0] = dp[n-1][0];
                for(int j=1; j<N-n; j++){
                    //dp[n][j] = dp[n-1][0] + dp[n-1][1] + ... + dp[n-1][j]
                    dp[n][j] = Mod.add(dp[n][j-1], dp[n-1][j]);
                    //System.err.printf(">%d %d %d\n", n,j,dp[n][j]);
                }
            }
        }


        //for(int n=0; n<N; n++) System.err.println(Arrays.toString(dp[n]));
        System.out.println(dp[N-1][0]);


    }
}


Measured memory_bytes: 129748
#include<stdio.h>
#define NUM 100000
/* 値を入れ替える関数 */
void swap(int *x, int *y) {
	int temp;    // 値を一時保存する変数

	temp = *x;
	*x = *y;
	*y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition(int array[], int left, int right) {
	int i, j, pivot;
	i = left;
	j = right + 1;
	pivot = left;   // 先頭要素をpivotとする

	do {
		do { i++; } while (array[i] < array[pivot]);
		do { j--; } while (array[pivot] < array[j]);
		// pivotより小さいものを左へ、大きいものを右へ
		if (i < j) { swap(&array[i], &array[j]); }
	} while (i < j);

	swap(&array[pivot], &array[j]);   //pivotを更新

	return j;
}

/* クイックソート */
void quick_sort(int array[], int left, int right) {
	int pivot;

	if (left < right) {
		pivot = partition(array, left, right);
		quick_sort(array, left, pivot - 1);   // pivotを境に再帰的にクイックソート
		quick_sort(array, pivot + 1, right);
	}
}
int main() {
	
	int i, n;
	int count = 0;
	int p[NUM] = { 0 };
	scanf("%d\n", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	quick_sort(p, 0, n-1);
	count = p[n / 2] - p[n / 2 - 1];
    printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(std::string S, std::string T){
    string str;
    // for (ll i = 0; i < 100; i++) {
    //     if(i<T.length()){
    //         str += T[i];
    //     }
    //     if(i<S.length()){
    //         str += S[i];
    //     }
    // }
    cout << T+S << "\n";
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	998244353//1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

int func(int a, int b)
{
	if (a < b)
		return func(b, a);
	int r;
	while (r = a % b)
	{
		a = b;
		b = r;
	}
	return b;
}

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

	while (n > 0)
		if (n % 10 == 7)
		{
			printf("Yes");
			return 0;
		}
		else
			n /= 10;
	printf("No");
	return 0;
}

Measured memory_bytes: 3256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    xu = [LSS() for _ in range(N)]

    ans = 0
    for x, u in xu:
        if u == 'JPY':
            ans += int(x)
        else:
            ans += float(x) * 380000

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9972
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,a[200],count=0;
    bool flag=true;
  	cin >> N;
    for(int i=0;i<N;i++){
    	cin >> a[i];
    }
  	while(flag){
  		for(int i=0;i<N;i++){
    		if(a[i]%2!=0){
            	flag=false;
                break;
            }else{
            	a[i]/=2;
            }
    	}
      	if(flag) count++;
    }
	cout << count << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    count = 0
    add = []
    mini = 0

    cb = [None]*m
    for i in range(m):
        b, c = map(int, input().split())
        cb[i] = (c, b)

    cb.sort(reverse=True)

    for c, b in cb:
        count += b
        add += [c]*b
        if count >= n:
            mini = c
            break

    add = add[:n]  # 追加のカードを削るかどうか
    a.sort()  # 昇順
    idx = len(a)//2
    for _ in range(10):
        if a[idx] <= mini:  # aの中央がminiより小さい
            a = a[idx:]
            idx = len(a)//2
        else:
            idx //= 2

    new_a = a + add
    new_a.sort(reverse=True)

    print(sum(new_a[:n]))


if __name__ == '__main__':
    main()


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

const int N = 1e5 + 10;

vector <int> G[N];
int used[N], rec[N];
int cnt1, cnt2, cnt3;
queue <int> q;

void bfs(int x){
	int cnt = 0, flag = 1;
	while (!q.empty()) q.pop();
	q.push(x);
	rec[x] = 1;
	while (!q.empty()){
		int u = q.front(); q.pop();
		cnt++;
		for (int i = 0; i < G[u].size(); i++){
			int v = G[u][i];
			if (!rec[v]){
				q.push(v);
				rec[v] = 3 - rec[u];
			}
			else if (rec[v] != 3 - rec[u]){
				flag = 0;
				break;
			}
		}
		if (!flag) break;
	}
	if (!flag) cnt3++;
	else if (cnt == 1) cnt1++;
	else cnt2++;
	while (!q.empty()) q.pop();
	q.push(x);
	used[x] = 1;
	while (!q.empty()){
		int u = q.front(); q.pop();
		for (int i = 0; i < G[u].size(); i++){
			int v = G[u][i];
			if (!used[v]){
				q.push(v);
				used[v] = 1;
			}
		}
	}
}

int main(){
	int n, m, u, v;
	long long ans;
	scanf("%d %d",&n,&m);
	for (int i = 1; i <= m; i++){
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	memset(used, 0, sizeof(used));
	memset(rec, 0, sizeof(rec));
	cnt1 = cnt2 = cnt3 = 0;
	for (int i = 1; i <= n; i++){
		if (!used[i]) bfs(i);
	}
	ans = 2LL * cnt1 * n - 1LL * cnt1 * cnt1 + 2LL * cnt3 * cnt2 + 1LL * cnt3 * cnt3 + 2LL * cnt2 * cnt2;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 7680
'''
FizzBuzz列 a1,a2,... を次のように定めます。
    i が 3 でも　5 でも割り切れるなら、ai=FizzBuzz
    そうではなく i が 3 で割り切れるなら、ai=Fizz
    そうではなく i が 5 で割り切れるなら、ai=Buzz
    そうではないなら、ai=i

FizzBuzz列の N項目までに含まれる数の和を求めてください。
'''

# 制約
# 1 ≦ N ≦ 1000000

# 標準入力から N の値を取得する
n = int(input())

# FizzBuzz の処理をし、結果を出力する

result = 0  # 結果格納用
for i in range(1, n + 1):
    if i % 15 == 0:
        # print('FizzBuzz')
        result += 0 # この時は、何もしない（≒ 0を足す）
    elif i % 3 == 0:
        # print('Fizz')
        result += 0 # この時は、何もしない（≒ 0を足す）
    elif i % 5 == 0:
        # print('Buzz')
        result += 0 # この時は、何もしない（≒ 0を足す）
    else:
        result += i

print(result)


Measured memory_bytes: 9172
N,M,K = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
B = list(map(int,input().split(" ")))

time_A = [0]*(N+1)
time_B = [0]*(M+1)

for i in range(N):
    time_A[i+1] = time_A[i] + A[i]
for j in range(M):
    time_B[j+1] = time_B[j] + B[j]

ans = 0
l = M

for k in range(N+1):
    if time_A[k] > K:
        break
    while time_A[k] + time_B[l] > K:
        l -= 1
    ans = max(ans,k+l)

print(ans)

Measured memory_bytes: 47684
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
char to(char c)
{
    return c - 'a' + 'A';
}
int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    cout << to(a[0]) << to(b[0]) << to(c[0]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long L1=2, L2=1, L_new = L1 + L2, temp;
  int N;
  
  cin >> N;
  
  if(N==1) cout << L2 << endl;
  
  else{
    while(N!=1){
      L_new = L1 + L2;
      L1 = L2;
      L2 = L_new;
      N--;
    }
    cout << L_new << endl;
  }
  
  return 0;
}


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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

using ll = long long;

int main() {
    IN(int, a);
    IN(int, b);
    cout << (b+a-3)/(a-1) << endl;
    return 0;
}


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

class Hash {
private:
	static const int MOD = 1046527;
	
	inline int my_ctoi(char c) {
		if (c == 'A') return 0;
		if (c == 'C') return 1;
		if (c == 'G') return 2;
		if (c == 'T') return 3;
		return 4;
	}
	
	inline int getKey(const string& str) {
		int key = 0;
		size_t len = str.size();
		for (size_t i = 0; i < len; ++i) key = 5 * key + my_ctoi(str[i]);
		return key;
	}
	
	inline int hash1(int key) {
		return key % MOD;
	}
	
	inline int hash2(int key) {
		return 1 + (key % (MOD - 1));
	}
	
public:
	Hash() {}
	
	int getHash(const string& str, int collision_count) {
		int key = getKey(str);
		return (hash1(key) + collision_count * hash2(key)) % MOD;
	}
};

class Dictionary {
private:
	string NIL;
	vector< string > table;
	
	Hash hash;
	
public:
	Dictionary() {
		NIL = "#";
		table.assign(1046527, NIL);
	}
	
	void insert(string& str) {
		int collision_count = 0;
		
		while (1) {
			int hs = hash.getHash(str, collision_count);
			
			if (table[hs] == NIL) {
				table[hs] = str;
				break;
			} else {
				++collision_count;
			}
		}
	}
	
	bool find(string& str) {
		int collision_count = 0;
		
		while (1) {
			int hs = hash.getHash(str, collision_count);
			
			if (table[hs] == str) {
				return true;
			} else if (table[hs] == NIL) {
				return false;
			} else {
				++collision_count;
			}
		}
	}
};

int main() {
	Dictionary dict;
	
	int n;
	cin >> n;
	
	char buf1[128], buf2[128];
		
	for (int i = 0; i < n; ++i) {
		scanf("%s %s", buf1, buf2);
		
		string op(buf1), str(buf2);
		
		if (op == "insert") {
			dict.insert(str);
		}
		
		if (op == "find") {
			if (dict.find(str)) puts("yes");
			else puts("no");
		}
	}
}

Measured memory_bytes: 35916
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  string s;
  ll a,b,f=0;
  cin>>a>>b;
  cin>>s;
  for(ll i=0;i<a;i++){
	if( s[i] < '0' || s[i] > '9' ){
      f++;
    }
  }
  if(s[a]!='-'){
	f++;
  }
  for(ll i=a+1;i<s.size();i++){
    if(s[i] < '0' || s[i] > '9' ){
	f++;
    }
  }
  if(f>0){
    cout<<"No\n";
  }else{
    cout<<"Yes\n";
  }
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

const double pi = 3.14159265358979323846;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    
    double ha = 30.0*(h+m/60.0);
    double ma = 6.0*m;
    
    double diff = abs(ha-ma);
    diff = min(diff,360.0-diff);
    // cout<<diff<<"\n";
    double ans = sqrt(a*a + b*b - 2.0*a*b*cos((pi*diff)/180.0));
    printf("%.20f", ans);
}


Measured memory_bytes: 4188
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
def bit(xx):return [format(x,"b") for x in xx]
popcnt=lambda x:bin(x).count("1")

def solve(xx,a,b):
    if len(xx)==2:return [a,b]
    k=(a^b).bit_length()-1
    aa=[]
    bb=[]
    for x in xx:
        if (x>>k&1)==(a>>k&1):aa.append(x)
        else:bb.append(x)
    i=0
    mid=aa[i]
    while mid==a or (mid^1<<k)==b or popcnt(a)&1==popcnt(mid)&1:
        i+=1
        mid=aa[i]
    #print(bit(xx),a,b,k,bit(aa),bit(bb),format(mid,"b"))
    return solve(aa,a,mid)+solve(bb,mid^1<<k,b)

def main():
    n,a,b=MI()
    if (popcnt(a)&1)^(popcnt(b)&1)==0:
        print("NO")
        exit()

    print("YES")
    print(*solve(list(range(1<<n)),a,b))

main()


Measured memory_bytes: 14888
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a==1&&b==2)
    cout << 3;
    else if(a==1&&b==3)
    cout << 2;
    else if(a==2&&b==1)
    cout << 3;
    else if(a==2&&b==3)
    cout << 1;
    else if(a==3&&b==1)
    cout << 2;
    else if(a==3&&b==2)
    cout << 1;


}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());
            var str = Console.ReadLine();
            if (str.Length > k) Console.WriteLine(str.Substring(0, k) + "...");
            else Console.WriteLine(str);
        }
    }
}

Measured memory_bytes: 27480
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	
	queue<string> que;
	
	map<string, int> m;
	
	string fs = "";
	
	for(int i = 0; i < 9; i++){
		string s;
		cin >> s;
		fs += s;
	}
	
	que.push(fs);
	
	for(int loop = 0; loop < 1000; loop++){
		if(que.empty()){
			break;
		}
		int sz = que.size();
		for(int num = 0; num < sz; num++){
			string str = que.front();
			que.pop();
			if(m.find(str) != m.end()){
				continue;
			}
			m[str] = loop;
			for(int i = 0; i < 9; i++){
				if(str[i] == '0'){
					if(i >= 3){
						swap(str[i], str[i - 3]);
						que.push(str);
						swap(str[i], str[i - 3]);
					}
					if(i < 6){
						swap(str[i], str[i + 3]);
						que.push(str);
						swap(str[i], str[i + 3]);
					}
					if(i % 3 > 0){
						swap(str[i], str[i - 1]);
						que.push(str);
						swap(str[i], str[i - 1]);
					}
					if(i % 3 < 2){
						swap(str[i], str[i + 1]);
						que.push(str);
						swap(str[i], str[i + 1]);
					}
				}
			}
		}
	}
	
	cout << m["123456780"] << endl;
	
	return 0;
}


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

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

	int n;
	cin>>n;
	string s;
	cin>>s;
	set<string> faans;
	vector<int> adj[10];
	for(int i=0; i<n; ++i){
		adj[s[i]-'0'].push_back(i);
	}

	auto check = [&](int i, int j, int k){
		if( adj[i].empty() ){ return false; }
		int start = adj[i][0];
		auto nxt = upper_bound(adj[j].begin(),adj[j].end(),start);
		if( nxt == adj[j].end() ){ return false; }
		int nxtint = *nxt;
		auto nxnxt = upper_bound(adj[k].begin(),adj[k].end(),nxtint);
		if( nxnxt == adj[k].end() ){ return false; }

		return true;
	};


	for(int i=0; i<10; ++i){
		for(int j=0; j<10; ++j){
			for(int k=0; k<10; ++k){
				if( check(i,j,k) ){
					string ans = "";
					ans += to_string(i);
					ans += to_string(j);
					ans += to_string(k);
					faans.insert(ans);
				}
			}
		}
	}

	cout<<(int)faans.size()<<'\n';

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
using namespace  std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> data(N);
	for (int i = 0; i < N; i++) {
		cin >> data.at(i);
	}
	sort(data.begin(), data.end());
	int cost = 0;
	for (int i = 0; i < K; i++) {
		cost += data.at(i);
	}
	cout << cost << endl;
	return 0;
}

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

using namespace std;

int main()
{
	int q,w[20],e=1,t;
	cin>>q;
	for(int r=1;r<=q;r++)  cin>>w[r];
    t=w[1];	
    for(int r=2;r<=q;r++)
	if(w[r]>=t)  
	{
	t=w[r];
	e++;
	}
	
	
	cout<<e;
	
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
 
#include <iostream>
#include <math.h>
#include <vector>
#include <fstream>
#include <iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <queue>
#include <stack>
#include <string.h>
#include <unordered_map>
#include <random>
#include <cassert>
#include <unistd.h>
 
#define ll int
#define ld long double
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pi acos(-1.0)
#define uniq(v) (v).erase(unique((v).begin(),(v).end()),(v).end())
#define fcin(a) ifstream cin(a);
#define fcout(a) ofstream cout(a);
#define inf (1e16)
#define MOD 1000000007

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
    
    
    
    
    
    
    
    
}


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

int n;
long double dp[3005][3005] = {0.0};
long double p[3005] = {0.0};

long double solve();

int main() {
  cout << fixed << setprecision(10);
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> p[i];
  cout << solve() << endl;
  return 0;
}

long double solve() {
  long double ans = 0;
  dp[0][0] = 1.0 - p[0];
  dp[0][1] = p[0];
  for(int i = 1; i < n; ++i)
    for(int j = 0; j <= n; ++j) {
      dp[i][j] = dp[i - 1][j] * (1.0 - p[i]);
      if(j != 0) dp[i][j] += dp[i - 1][j - 1] * p[i];
    }
  for(int i = n / 2 + 1; i <= n; ++i) ans += dp[n - 1][i];
  return ans;
}

Measured memory_bytes: 141056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class339
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            if (N == 1)
            {
                Console.WriteLine("Hello World");
            }
            else if (N == 2)
            {
                int A = int.Parse(Console.ReadLine());
                int B = int.Parse(Console.ReadLine());
                Console.WriteLine(A + B);
            }
        }
    }
}


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

ll GCD(ll m, ll n) {
	if (n == 0) return m;
	return GCD(n, m % n);
}

ll LCM(ll a, ll b) {
	return a / GCD(a, b) * b;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<ll> A(N);

	ll lcm = 1;
	int parity = 1;
	rep(i, N) {
		ll a;
		cin >> a;
		A[i] = a / 2;
		
		if (i == 0) {
			while (A[i] % (parity * 2) == 0) {
				parity *= 2;
			}
			lcm = A[i];
		}
		else {
			if (A[i] % parity != 0) {
				cout << 0 << endl;
				return 0;
			}
			else if (A[i] % (parity * 2) == 0) {
				cout << 0 << endl;
				return 0;
			}

			lcm = LCM(lcm, A[i]);
			if (lcm > M) {
				cout << 0 << endl;
				return 0;
			}
		}
	}

	int ans = 0;
	ll count = 1;
	ll tot = lcm;
	while (tot <= M) {
		ans++;
		count += 2;
		tot = lcm * count;
	}

	cout << ans << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 303;

int n;
int cnt[4];
ld dp[2][N][N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    cnt[a]++;
  }
  for (int k = 0; k <= n; k++) {
    for (int j = 0; j+k <= n; j++) {
      for (int i = 0; i+j+k <= n; i++) {
        if (!i && !j && !k) continue;
        ld e = n-i-j-k;
        ld add = (n - e) / (n * (1 - e/n) * (1 - e/n)) - 1;
        dp[1][i][j] = add;
        //cerr << i << " " << j << " " << k << " -> " << add << nl;
        if (i) {
          ld p = (ld) i / (i + j + k);
          dp[1][i][j] += p * (dp[1][i-1][j] + 1);
        }
        if (j) {
          ld p = (ld) j / (i + j + k);
          dp[1][i][j] += p * (dp[1][i+1][j-1] + 1);
        }
        if (k) {
          ld p = (ld) k / (i + j + k);
          dp[1][i][j] += p * (dp[0][i][j+1] + 1);
        }
      }
    }
    swap(dp[0], dp[1]);
    if (k == cnt[3]) {
      cout << fixed << setprecision(10) << dp[0][cnt[1]][cnt[2]] << nl;
      return 0;
    }
  }
  assert(0);
  return 0;
}


Measured memory_bytes: 1664
def foo(xs, k):
    d = {}
    for x in xs:
        d[x] = d.get(x, 0) + 1

    ys = sorted(d.items(), key=lambda x: x[1])
    return sum(map(lambda x:x[1], ys[:-k])) 


if __name__ == "__main__":
    n, k = list(map(int, input().split()))
    xs = list(map(int, input().split()))
    print(foo(xs, k))


Measured memory_bytes: 38964
def calc(a, b, op):
    if op == "+":
        return a + b;
    elif op == "-":
        return a - b;
    elif op == "*":
        return a * b;
    elif op == "/":
        return a / b;
    elif op == "?":
        return None;

while True:
    a, op, b = input().split()
    result = calc(int(a), int(b), op)
    if result is not None:
        print(int(result));
    else:
        break;

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

using namespace std;
#define pb push_back
#define ld long double
const int Nmax = 200000 + 5;
int a[Nmax], n, q, vl[Nmax];
vector<int>v[Nmax];

bool viz[Nmax];

void dfs(int nod, int bost)
{
    viz[nod] = 1;
    bost += vl[nod];
    a[nod] += bost;

    for(auto i : v[nod])
        if(!viz[i])
            dfs(i, bost);

}
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif */

    cin >> n >> q;
    for(int i = 1, a, b; i <= n - 1; ++i)
    {
        cin >> a >> b;
        v[a].pb(b);
    }

    for(int i = 1, rt, incr; i <= q; ++i)
    {
        cin >> rt >> incr;
        vl[rt] += incr;
    }

    dfs(1, 0);

    for(int i = 1; i <= n; ++i)cout << a[i] <<' ';
    return 0;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    rep(_,K) {
        if (B <= A) B *= 2;
        else if (C <= B)
            C *= 2;
    }
    if (B > A && C > B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

#define N 123
char a[N], b[N], c[N];

int main(){
	int n; scanf("%d", &n);
	scanf("%s%s%s", a, b, c);
	int ans = 0;
	REP(i, n){
		if(a[i] == b[i]){
			if(b[i] == c[i]){
			}else {
				ans+=1;
			}
		}else if(a[i]==c[i]) ans+=1;
		else if(b[i]==c[i]) ans+=1;
		else ans+=2;
	}
	printf("%d\n", ans);
}


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

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

    vector<int> d(3);
    int count = 0;

    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            for(int k=0;k<=9;k++){
                d = {100000,100000,100000};
                for(int m=0;m<N;m++){
                    if(d[0]==100000&&S[m]==i+'0') d[0]=m;
                    if(m>d[0]&&d[1]==100000&&S[m]==j+'0') d[1]=m;
                    if(m>d[1]&&d[2]==100000&&S[m]==k+'0'){
                        d[2]=m;
                        count++;
                    }
                }
            }
        }
    }

    cout << count << endl;

    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
int a[100001];

void input(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    vector<ll> c2;
    vector<ll> c4;
    map<int, int> mp;
    for(int i=0;i<n;i++) mp[a[i]]++;
    for(auto e: mp){
        if(e.second >= 2) c2.push_back(e.first);
        if(e.second >= 4) c4.push_back(e.first);
    }
    ll ans1 = 0;
    ll ans2 = 0;
    if(c2.size() >= 2) ans1 = c2[c2.size()-1]*c2[c2.size()-2];
    if(c4.size() >= 1) ans2 = c4[c4.size()-1]*c4[c4.size()-1];
    cout << max(ans1, ans2) << endl;                               
    return 0; 
}

Measured memory_bytes: 5376
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
int n;
int A[20];
bool memo[2001];
bool Search(int ite, int SUM){
	if (SUM == 0) return true;
	if (ite == n || SUM<0) return false;
	return (Search(ite+1,SUM-A[ite]) || Search(ite+1,SUM));
}
int main(){
	scanf("%d",&n);
	for (int i = 0; i < n; ++i) scanf("%d", &A[i]);
	int q; scanf("%d", &q);
	for (int i = 0; i < q; ++i){
		int m; scanf("%d", &m);
		if (memo[m] || Search(0, m)){
			cout << "yes\n";
			memo[m] = true;
		}
		else cout << "no\n";
	}
}

Measured memory_bytes: 1172
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

int dx[8] = { 1,0,0,-1,1,1,-1,-1 };
int dy[8] = { 0,-1,1,0,-1,1,-1,1 };

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    int a[100005];
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) {
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    int now = 1;
    rep(i, n) {
        if ((int)(1000000000000000000) / a[i] < now) {
            cout << -1 << endl;
            return 0;
        }
        now *= a[i];
    }

    cout << now << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a), t(b);
  rep(i, a) cin >> s[i];
  rep(i, b) cin >> t[i];

  s.push_back(INF64);
  s.insert(s.begin(), -INF64);
  t.push_back(INF64);
  t.insert(t.begin(), -INF64);

  vector<ll> ans;
  rep(i, q) {
    ll x; cin >> x;
    auto it1 = upper_bound(ALL(s), x), it2 = upper_bound(ALL(t), x);
    ll rs = *it1, rt = *it2;
    --it1; --it2;
    ll ls = *it1, lt = *it2;
    ll res = INF64;
    chmin(res, abs(rs-x)+abs(rs-rt));
    chmin(res, abs(rs-x)+abs(rs-lt));
    chmin(res, abs(rt-x)+abs(rt-rs));
    chmin(res, abs(rt-x)+abs(rt-ls));
    chmin(res, abs(x-ls)+abs(ls-rt));
    chmin(res, abs(x-ls)+abs(ls-lt));
    chmin(res, abs(x-lt)+abs(lt-rs));
    chmin(res, abs(x-lt)+abs(lt-ls));
    ans.push_back(res);
  }
  for(auto x : ans) cout << x << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return (a*( b/ gcd(a,b)));}

void f()
{
  int n;
  cin>>n;
  cout<<"Christmas";
  for(int i=1;i<=25-n;i++)
  {
    cout<<" Eve";
  }
  cout<<nl;
}

int main()
{
    su;

    f();
    return 0;
}


Measured memory_bytes: 3520
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;
  return (0 ^ _ ^ 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(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

void recursive_debug(string) { cerr << endl; }

template<class H,class... T>
void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}

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

template<class T>
ostream& operator<<(ostream &ost, const vector<T> &v) {
    ost << "[";
    for(T t : v) ost << t << ",";
    ost << "]";
    return ost;
}

struct State {
    ll score;
    vector<int> last;
    vector<int> types;
    bool operator<(const State& rhs) const {
        return (score < rhs.score);
    }
    bool operator>(const State& rhs) const {
        return (score > rhs.score);
    }
};


int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int D, M = 26;
    cin >> D;
    vector<ll> c(M);
    rep(m,M) cin >> c[m];
    vector<vector<ll>> s(D, vector<ll>(26));
    rep(d,D) rep(m,M) cin >> s[d][m];

    set<State> cur_states = {{0, vector<int>(M, -1), {}}};
    size_t SIZE = 850;

    rep(d,D) {
        set<State> nxt_states;
        for (auto &cur_itr : cur_states) {
            State state = cur_itr;
            ll minus_score = 0;
            rep(i,M) {
                minus_score -= c[i] * (d - state.last[i]);
            }
            rep(m,M) {
                State nxt_state;
                nxt_state.score = state.score + s[d][m] + minus_score + c[m] * (d - state.last[m]);
                nxt_state.last = state.last;
                nxt_state.last[m] = d;
                nxt_state.types = state.types;
                nxt_state.types.push_back(m);
                
                nxt_states.insert(nxt_state);
                if (nxt_states.size() > SIZE) {
                    nxt_states.erase(nxt_states.begin());
                }
            }
        }

        cur_states = std::move(nxt_states);
    }

    for (int t : cur_states.begin()->types) {
        cout << t+1 << endl;
    }
    // debug(cur_states[0].score);

    return 0;
}


Measured memory_bytes: 6960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main() {
    string S;
    cin >> S;
    int cnt=0;
    int ans=0;
    for(int i = 0; i < 3; i++){
        if(S.at(i) == 'R'){
            cnt++;
            ans = max(ans,cnt);
        }
        else{
            cnt = 0;
            continue;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
import queue
n = int(input())


#ab = [[]*(n)]
ab = [[] for _ in range(n+1)]
#print(ab)

li = []

for i in range(n-1):
    a,b = map(int,input().split())
    ab[a].append([b,i])
    ab[b].append([a,i])
    #li.append([a,b])

#ab_color = [[None for _ in range(n+1)] for _ in range(n+1)]
ans = [0] * (n-1)

q = queue.Queue()
check = [0] * (n+1)
#check[1] == 1
check_color = [0] * (n+1)

q.put(1)
color_num = 1
#mae_color = 0

while not q.empty():
    tmp_color = 0
    tmp = q.get()
    #print(tmp)
    #tmp_color = mae_color
    mae_color = check_color[tmp]
    for i in range(len(ab[tmp])):
        if check[ab[tmp][i][0]] == 1:
            #print(i,tmp)
            continue
        else:
            #print(mae_color,tmp_color,tmp,i)
            tmp_color += 1
            q.put(ab[tmp][i][0])
            if tmp_color == mae_color:
                tmp_color += 1
            check_color[ab[tmp][i][0]] = tmp_color
            ans[ab[tmp][i][1]] = tmp_color
            #ab_color[ab[tmp][i]][tmp] = tmp_color
            #ab_color[tmp][ab[tmp][i]] = tmp_color
            check[tmp] = 1
            if color_num < tmp_color:
                color_num = tmp_color
            #color_num = max(color_num,tmp_color)
            #print(check,i)

print(color_num)
for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 47668
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

m = (n-1)//2

if (n-1) % 2 == 1:
    print(sum(a[:m]) + sum(a[1:m+1]) + a[m])
else:
    print(sum(a[:m]) + sum(a[1:m+1]))

Measured memory_bytes: 104696