akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define	INF	0x3f3f3f3f
#define	LL	long long
#define	MAXN	210
#define	MAXS	100010
#define	mod	1000000007
using namespace std;
int n, x, w[MAXN];
int f[MAXN][MAXS];

template <typename T> void chkmin(T &x, T y){x = min(x, y);}
template <typename T> void chkmax(T &x, T y){x = max(x, y);}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

void update(int &x, const int &y){x = (x + y >= mod) ? (x + y - mod) : (x + y);}
int mul(const int &x, const int &y){return 1ll * x * y % mod;}
int inc(const int &x, const int &y){return (x + y >= mod) ? (x + y - mod) : (x + y);}

int main(){
	read(n), read(x);
	for (int i = 1; i <= n; ++i)
		read(w[i]);
	sort(w + 1, w + 1 + n);
	for (int i = 0; i <= x; ++i)
		f[0][i] = i;
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= x; ++j){
			if (!f[i - 1][j]) continue;
			update(f[i][j], mul(f[i - 1][j], i - 1));
			if (w[i] > j) {
				for (int t = 0; j + t <= x; t += w[i])
					update(f[i][j + t], f[i - 1][j]);
			}
		}
	printf("%d\n", f[n][x]);
	return 0;
}

Measured memory_bytes: 80128
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  H = 1
  for i in range(int(M//N), 1, -1):
    if M % i == 0:
      H = i
      break

  print(H)

if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
using namespace std;

int main(){
  int n,i,j;
  cin >> n;
  int a[n];
  int sum=0;
  double h;
  for(i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  h = (double)sum/n;
  double m = 20000;
  for(i=0;i<n;i++){
    if(m>fabs((double)a[i]-h)){
      m = fabs((double)a[i]-h);
      j = i;
    }
  }
  cout << j << endl;
  return 0;
}


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

using namespace std;

long long gcd(long long a, long long b)
{
  if(!b) {
    return a;
  }
  return gcd(b, a % b);
}

int main()
{
  int n;
  cin >> n;
  vector<long long> t(n);
  for(auto&& i : t) {
    cin >> i;
  }
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end());
  n = t.size();
  long long ans = t[0];
  for(int i = 1; i < n; i++){
    t[i] /= gcd(ans, t[i]);
    ans *= t[i];
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
def solve(N, Q, ABs, PXs):
    values = {i: 0 for i in range(N + 1)}
    ans = [-1 for i in range(N + 1)]
    vertexes = {}
    for a, b in ABs:
        vertexes.setdefault(a, []).append(b)
        vertexes.setdefault(b, []).append(a)

    for p, x in PXs:
        values[p] += x

    queue = []
    queue.append((1, 0))
    while queue:
        index, parent_value = queue.pop()
        value = parent_value + values[index]
        ans[index] = value
        for child in vertexes[index]:
            if ans[child] == -1:
                queue.append((child, value))
    return " ".join([str(a) for a in ans[1:]])


if __name__ == "__main__":
    N, Q = tuple(map(int, input().split(" ")))
    ABs = [tuple(map(int, input().split(" "))) for _ in range(N - 1)]
    PXs = [tuple(map(int, input().split(" "))) for _ in range(Q)]
    print(solve(N, Q, ABs, PXs))


Measured memory_bytes: 143584
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

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

int main(){
    ll n, k;
    cin >> n >> k;
    ll rem = n % k;
    cout << min(rem, k - rem) << endl;
    return 0;
}


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

int GetDigitsCount(int targetNumber, int baseNumber=10) {
	int digitsCount = 0;
	while (targetNumber != 0) {
		digitsCount++;
		targetNumber /= baseNumber;
	}
	return digitsCount;
}

int main()
{
	int n; cin >> n;
	
	int ans = 0;

	for (int i = 1; i <= n; i++) {
		if (GetDigitsCount(i) % 2 == 1) ans++;
	}

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

Measured memory_bytes: 256
d = {'1': ['.', ',', '!', '?', ' '], '2': ['a', 'b', 'c'], '3': ['d', 'e', 'f'], '4': ['g', 'h', 'i'], '5': ['j', 'k', 'l'], '6': ['m', 'n', 'o'], '7': ['p', 'q', 'r', 's'], '8': ['t', 'u', 'v'], '9': ['w', 'x', 'y', 'z']}

n = int(input())
m = [input() for i in range(n)]
for mm in m:
    l = [x for x in mm.split('0') if not x == '']
    buf = ''
    for x in l:
        buf += d[x[0]][len(x)%len(d[x[0]]) - 1]
    print(buf)



Measured memory_bytes: 5664
import sys

input = sys.stdin.readline

def main():
    n = int(input())
    
    for i in range(1, n+1):
        if i % 3 == 0:
            print(' ' + str(i), end="")
        elif "3" in str(i):
            print(' ' + str(i), end="")
    print("")

if __name__ == "__main__":
    main()


Measured memory_bytes: 5880
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int res;

        if(360%N==0){
            res = 360/N;
        }else{
            res = 360;
            if(N%2==0){
                res = 180;
                if(N%4==0){
                    res = 90;
                    if(N%8==0){
                        res = 45;
                    }
                }
            }
            if(N%3==0){
                res = res/3;
                if(N%9==0){
                    res = res/3;
                }
            }
            if(N%5==0){
                res = res/5;
            }
        }
        

        
        
        System.out.println(res);
        
        }
    }

Measured memory_bytes: 35672
package main

import (
	"fmt"
	"math"
)

func isInteger(f float64) bool {
	return f == float64(int(f))
}

func main() {
	var n int
	fmt.Scan(&n)
	for i := n; i >= 1; i-- {
		if isInteger(math.Sqrt(float64(i))) {
			fmt.Println(i)
			return
		}
	}
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>

int isPrime(int n){
  int i;
  
  if(n < 2)
    return 0;
  else if(n == 2)
    return 1;
  
  if(n % 2 == 0)
    return 0;
  
  for(i = 3; i <= (int)sqrt(n); i+=2){
    if(n % i == 0)
      return 0;
  }
  return 1;
  
  
}

int main(){
  int n, i,cnt = 0;
  int p[10000];

  scanf("%d", &n);

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

  for(i = 0; i < n; i++)
    if(isPrime(p[i]))
       cnt++;
  
  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 628
import sys
a = list(map(int,input().split()))
b = list(map(int,input().split()))
t = int(input())
if a[1] <= b[1]:
    print('NO')
    sys.exit()
elif abs(a[0]-b[0])/abs(a[1]-b[1]) <= t:
    print('YES')
    sys.exit()
else:
    print('NO')

Measured memory_bytes: 9116
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
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 (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

int main() {
    
    int n, a, b;
    cin >> n >> a >> b;

    vector<int> p(n, 0);
    REP(i, n) cin >> p[i];

    int q1 = 0, q2 = 0, q3 = 0;
    REP(i, n) {
        if (p[i] <= a) q1++;
        else if (p[i] <= b) q2++;
        else q3++;
    }
    cout << min(q1, min(q2, q3));
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main()
{
  int t;
  cin>>t;
  REP(cnt,t) {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if (a < b) {
      cout << "No" << endl;
      continue;
    }
    if (d < b) {
      cout << "No" << endl;
      continue;
    }
    if (c >= b-1) {
      cout << "Yes" << endl;
      continue;
    }
    long double lower = c - a;
    long double upper = b - a;
    ll g = gcd(b, d);
    if (floor(lower / g) + 1 <= ceil(upper / g) - 1) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int a[3];
int main()
{
	for (int i=0;i<3;i++) cin >>a[i];
	sort(a,a+3);
	cout <<a[0]+a[1];
	return 0; 
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int h = input[0];
        string tmp;
        for (int i = 0; i < h; i++)
        {
            tmp = Console.ReadLine();
            Console.WriteLine(tmp);
            Console.WriteLine(tmp);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // 998244353 //  //100000000
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << " "; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a/__gcd(a, b))*b; }

void solve(){
    ll n, m;
    cin >> n >> m;
    if(abs(n-m) > 1) ANS(0);
    if(n == m){
        ll k = 1;
        for(ll i = 1; i <= n; i++) k = (k*i)%MOD;
        k = (k*k)%MOD;
        k = (k*2)%MOD;
        cout << k;
    }
    else{
        if(n > m)swap(n, m);
        ll k = 1;
        for(ll i = 1; i <= n; i++) k = (k*i)%MOD;
        k = (k*k)%MOD;
        k = (k*m)%MOD;
        cout << k;
    }
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
import scala.io.StdIn

object Main {

  def main(args: Array[String]) {
    val n = StdIn.readInt()
    for (i <- 1 to n) {
      if (toShow(i)) {
        print(s" $i")
      }
    }
    println()
  }
  
  def toShow(x: Int): Boolean = {
    var res = false
    if (x % 3 == 0) {
      res = true
    } else {
      var v = x
      while (v > 0 && !res) {
        if (v % 10 == 3) {
          res = true
        }
        v = v / 10
      }
    }
    res
  }
}



Measured memory_bytes: 47660
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<min3(a+b,b+c,c+a);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
struct UnionFind {
	int *par;
	int *rank;
	UnionFind(int n) {
		par = new int[n];
		rank = new int[n];
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 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);
	}
};
int main() {
	int N, K, L;
	cin >> N >> K >> L;
	UnionFind road(N), rail(N);
	rep(i, K) {
		int p, q;
		cin >> p >> q;
		p--; q--;
		road.unite(p, q);
	}
	rep(i, L) {
		int r, s;
		cin >> r >> s;
		r--; s--;
		rail.unite(r, s);
	}
	map<PI, int> cnt;
	rep(i, N) {
		cnt[MP(road.find(i), rail.find(i))]++;
	}
	rep(i, N) {
		cout << cnt[MP(road.find(i), rail.find(i))] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 15104
from fractions import Fraction
import math

n = int(input())


ab = []
ba = []

a0 = 0
b0 = 0
ab0 = 0


def irr(a, b):
    gcd = math.gcd(a, b)
    a = a // gcd
    b = b // gcd

    if b < 0:
        return (-a, -b)
    else:
        return (a, b)


for i in range(n):
    a, b = map(int, input().split())
    if a != 0 and b != 0:
        ab.append(irr(a, b))
        ba.append(irr(-b, a))
    elif a == 0 and b == 0:
        ab0 += 1
    elif a == 0 and b != 0:
        a0 += 1
    elif a != 0 and b == 0:
        b0 += 1


d_ab = dict()
d_ba = dict()

# d_done = dict()

for i in range(len(ab)):
    cur = ab[i]
    if cur in d_ab:
        d_ab[cur] += 1
    else:
        d_ab[cur] = 1

    cur = ba[i]
    if cur in d_ba:
        d_ba[cur] += 1
    else:
        d_ba[cur] = 1

mod = 1000000007
ans = 1

d_done = set()

for k, v in d_ab.items():
    x = v
    if k in d_ba:
        if k in d_done:
            continue
        else:
            y = d_ba[k]
            kake = 0
            kake += ((2**x) % mod + (2**y) % mod - 1)
            ans *= kake
            ans %= mod
            # d_done[Fraction(-k.denominator, k.numerator)] = 1
            d_done.add(irr(-k[1], k[0]))
    else:
        kake = (2**x) % mod
        ans *= kake
        ans %= mod

ans *= ((2**a0) % mod+(2**b0) % mod-1)
ans %= mod

ans -= 1

ans += ab0
ans %= mod

print(ans)


Measured memory_bytes: 168464
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<ty-sy;i++) sb.append("U");
        for(int i=0;i<tx-sx;i++) sb.append("R");
        for(int i=0;i<ty-sy;i++) sb.append("D");
        for(int i=0;i<tx-sx;i++) sb.append("L");
        sb.append("L");
        for(int i=0;i<=ty-sy;i++) sb.append("U");
        for(int i=0;i<=tx-sx;i++) sb.append("R");
        sb.append("D");
        sb.append("R");
        for(int i=0;i<=ty-sy;i++) sb.append("D");
        for(int i=0;i<=tx-sx;i++) sb.append("L");
        sb.append("U");
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  int sum=0;
  REP(i,1,N){
    if(i%3!=0&&i%5!=0) sum+=i;
  }
  cout<<sum<<endl;
  }


Measured memory_bytes: 3596
n = int(input())
A = list(map(int, input().split()))
R = [0 for i in range(9)]
for i in range(n):
    if A[i] < 3200: R[A[i]//400] += 1
    else: R[8] += 1
mi = 0
for i in range(8):
    if R[i] > 0: mi += 1
if mi == 0 and R[8] > 0:
    print(mi+1, mi+R[8])
else:
    print(mi, mi+R[8])

Measured memory_bytes: 3064
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
    
    ll n,i,j;
    cin>>n;
    ll a[n+2];
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n,greater<ll>());
    if(n==2) cout<<a[0];
    else 
    {
    	ll ans = a[0] ;
    	ll cn=1;
    	for(i=1;i<n;i++)
    	{
    		if(cn<n-1)
    		{
    			cn++;
    			ans += a[i];
    		}
    		if(cn<n-1)
    		{
    			cn++;
    			ans += a[i];
    		}
    		if(cn==n-1) break;
    	}
    	cout<<ans;
    }
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 2e5 + 10;
vector<int> oc[26];
int near[maxn][26];
int pnt[26];
int vis[maxn];
int par[maxn];
char best[maxn];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    string str;
	cin >> str;
	int ind = 1;
    for (char ch : str){
        oc[ch - 'a'].pb(ind);
        ind++;
    }
    for (int i = 0;i <= str.length();i++){
        for (int c = 0 ;c < 26;c++){
            while(pnt[c] < oc[c].size() && oc[c][pnt[c]] <= i){
                pnt[c]++;
            }
            if (pnt[c] < oc[c].size()) near[i][c] = oc[c][pnt[c]];
            else near[i][c] = -1;
        }
    }
    queue<int> q;
    q.push(0);
    par[0] = -1;
    vis[0] = 1;
    while(!q.empty()){
        ind = q.front();q.pop();
       // cout << ind << endl;
        for (int c = 0;c < 26;c++){
        //    cout << ind << ' ' << near[ind][c] << endl;
            if (near[ind][c] == -1){
                stack<char> s;
                s.push(c + 'a');
                while(par[ind] != -1){
                    s.push(best[ind]);
                    ind = par[ind];
                }
                while(!s.empty())cout << s.top(),s.pop();
                return 0;
            }else {
                if (vis[near[ind][c]] == 0){
                    vis[near[ind][c]] = 1;
                    best[near[ind][c]] = c + 'a';
                    par[near[ind][c]] = ind;
                    q.push(near[ind][c]);
                }
            }
        }
    }
}


Measured memory_bytes: 23444
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (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 FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa
{
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;

std::vector<int> fac(450001);  //n!(mod M)
std::vector<int> ifac(450001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

int mpow(int x, int n)
{
    int ans = 1;
    while (n != 0)
    {
        if (n & 1)
            ans = (ans * x) % MOD;
        x = (x * x) % MOD;
        n = n >> 1;
    }
    return ans;
}

int comb(int a, int b)
{ //aCbをmod計算
    if (a == 0 && b == 0)
        return 1;
    if (a < b || a <= 0)
        return 0;
    int tmp = ifac[a - b] * ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

signed main()
{
    int n, k;
    cin >> n >> k;
    fac[0] = 1;
    ifac[0] = 1;
    for (int i = 0; i < 450000; i++)
    {
        fac[i + 1] = fac[i] * (i + 1) % MOD;                // n!(mod M)
        ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    if (k + 1 >= n)
    {
        cout << comb(2 * n - 1, n - 1) << endl;
    }
    else
    {
        int sum = 0;
        for (int i = 0; i <= k; i++)
        {
            sum += (comb(n, i) * comb(n - 1, n - i - 1)) % MOD;
            sum %= MOD;
        }
        cout << sum << endl;
    }
    return 0;
}

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

int main() {
    int N;
    cin>>N;
    long tmp;
    long ans=0;
    for(int i=0;i<N;++i){
        cin>>tmp;
        ans ^= tmp;
    }
    if(!ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++){
		cin >> p[i];
	}
	int k = 0;
	for (int i = 0; i < n; i++){
		if(p[i] != i + 1) k++;
	}
	if (k <= 2) cout << "YES";
	else cout << "NO";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,i,m;
	cin>>n;
	int maxv=-2000000000;
	cin>>m;
	int minv=m;
	for(i=1;i<=n-1;i++)
	{
		cin>>m;
		maxv=max(maxv,m-minv);
		minv=min(minv,m);
	}
	cout<<maxv<<endl;;
	return 0;
}


Measured memory_bytes: 3108
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans=0;
    if(k){
        ans+=mmin(k,a);
        k-=mmin(k,a);
    }
    if(k){
        k-=mmin(k,b);
    }
    if(k){
        ans-=mmin(k,c);
        k-=mmin(k,c);
    }
    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































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

using namespace std;

int main(){


	map<int,int>ma;

	int n,aux;

	cin >> n;

	for(int i=0;i<n-1;i++){
		cin >> aux;
		ma[aux]++;
	}

	for(int i=1;i<=n;i++)
		cout << ma[i] << endl;

	return 0;
}

Measured memory_bytes: 13012
function Main(input) {
  input = input.split(" ");
  var a = parseInt(input[0], 10);
  var b = parseInt(input[1], 10);
  if(a === b) {
    console.log('%d',a + b);
  } else if(a > b) {
    if((a - 1) > b) {
      console.log('%d',a * 2 - 1);
    } else {
      console.log('%d',a + b);
    }
  } else {
    if((b - 1) > a) {
      console.log('%d',b * 2 - 1);
    } else {
      console.log('%d',a + b);
    }
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;

int main() {
    int a; cin >> a;
    cout << a + a* a + a * a * a << endl;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var m = ReadInt();
            var list = Enumerable.Range(1, 2 * n).ToList();
            for (int i = 0; i < m; i++)
            {
                var k = ReadInt();
                if (k == 0)
                {
                    //リフルシャッフル
                    var tmplist = new List<int>();
                    for (int j = 0; j < n; j++)
                    {
                        tmplist.Add(list[j]);
                        tmplist.Add(list[n + j]);
                    }
                    list = tmplist;
                }
                else
                {
                    //カット
                    var tmplist = new List<int>();

                    for (int j = k; j < 2*n; j++)
                    {
                        tmplist.Add(list[j]);
                    }
                    for (int j = 0; j < k; j++)
                    {
                        tmplist.Add(list[j]);
                    }

                    list = tmplist;
                }
            }



            foreach (var item in list)
            {
                WriteLine(item);
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 20244
#include <stdio.h>

int main(){
  int n,i,result=0,max=0;
  char s[101];
  
  scanf("%d",&n);
  scanf("%s",s);
  
  for(i=0;i<n;i++){
    if(s[i]=='I'){
      result++;
      if(max<result){
        max=result;
      }
    } else if(s[i]=='D'){
      result--;
    }
  }
  
  printf("%d",max);
}

Measured memory_bytes: 128
from collections import deque

S = deque(list(input()))
Q = int(input())
r = False
left = deque()
right = deque()
for i in range(Q):
    q = input().split()
    if q[0] == "1":
        r = not r
    else:
        f, c = q[1:]
        if f == "1":
            if r:
                right.append(c)
            else:
                left.appendleft(c)
        else:
            if r:
                left.appendleft(c)
            else:
                right.append(c)

S, left, right = map(list, (S, left, right))
left.extend(S)
left.extend(right)
print("".join(left[::-1] if r else left))

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

int main(int argc, char const *argv[]) {
  int l, m, n, x, i, j, k;

  cin >> n >> m >> l;
  int matrixA[n][m];
  int matrixB[m][l];
  long matrix[n][l] = {};

  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> x;
      matrixA[i][j] = x;
    }
  }
  for (i = 0; i < m; i++) {
    for (j = 0; j < l; j++) {
      cin >> x;
      matrixB[i][j] = x;
    }
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < l; j++) {
      for (k = 0; k < m; k++) {
        matrix[i][j] += matrixA[i][k] * matrixB[k][j];
      }
    }
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < l; j++) {
      cout << matrix[i][j];
      if (j != l - 1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3232
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=100,mod=1e9+7;
int main(){
	ll x,y;
	int ans=0;
	scanf("%lld%lld",&x,&y);
	while(x<=y) x<<=1,ans++;
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    string str;
    cin >> str;
    int price = 700;
    if (str[0] == 'o') price += 100;
    if (str[1] == 'o') price += 100;
    if (str[2] == 'o') price += 100;
    cout << price << endl;
}

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

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



Measured memory_bytes: 3080
# include <iostream>
# include <string>

using namespace std;

bool solve(string s) {
    while(1) {
        if (s.length() == 0) {
            // cout << "aaa" << endl;
            return true;
        }
        if (s.length() < 5) {
            // cout << s << endl;
            // cout << "bbb" << endl;
            return false;
        }
        if (s.substr(0,5) == "erase") {
            if (s.substr(5,1)=="r") {
                s.erase(0,6); // eraser
            }else{
                s.erase(0,5); // erase
            }
        } else if (s.substr(0,5) == "dream") {
            if (s.substr(5,3) == "erd" || s.substr(5,3) == "ere") {
                s.erase(0,7); // dreamer
            }else if(s.length() == 7 && s.substr(0,7)== "dreamer"){
                s.erase(0,7); // dreamer
            }else{
                s.erase(0,5); // dream
            }
        } else {
            // cout << "ccc" << endl;
            return false;
        }
    }
    // cout << "ERROR" << endl;
    return false;
}

int main(){
    string s;
    cin >> s;
    if (solve(s)) {
        cout << "YES" << endl;
        return 0;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N = (int)1e5+5;
long long int a[N];
long long int aa[N];
int main()
{
    int t;
    string s;
    cin>>s;
  if(s[0]==s[1]&&s[0]==s[2]&&s[1]==s[2])
     {
            cout<<"No"<<endl;

     }
  else
  {
      cout<<"Yes"<<endl;
  }


    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,i,c,count=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;i++)
    {
        if(c%i==0)
            count++;
    }
    printf("%d\n",count);

   return 0;
}



Measured memory_bytes: 2100
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I 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 = 10010010010010;
const long long MOD = 998244353;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//fac[]はn! inv[]はMODにおける逆元 finv[]はinv[]とfinv[]の累積積
const long long MAX = 510000;
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;
    }
}

// 二項係数計算(nCkをO(1)で)
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() {
    int N;cin >> N;
    vector<long long> retu(N);
    map<long long,long long> M;
    for(int i = 0;i<N;i++) {
        cin >> retu.at(i);
        M[retu.at(i)]++;
    }
    if(retu.at(0) != 0 || M[0] != 1){
        cout << 0 << endl;
        return 0;
    }
    sort(retu.begin(),retu.end());
    for(int i = 0;i<N-1;i++){
        if(retu.at(i+1)-retu.at(i) >= 2){
            cout << 0 << endl;
            return 0;
        } 
    }
    long long dist = 0;
    long long vertexes = 1;
    long long ans = 1;
    for(auto V : M){
        int dist = V.first;
        if(dist == 0){
            vertexes = V.second;
            continue;
        }
        ans *= mod_pow(vertexes,V.second);
        ans %= MOD;
        vertexes = V.second;
    }
    cout << ans%MOD << endl;
}


Measured memory_bytes: 7296
#include <iostream>
using namespace std;
int gcd(int a,int b)
{
    int t;
    if(b>a)
    {
        t=b;
        b=a;
        a=t;
    }
    while(t=a%b)
    {
        a=b;
        b=t;
    }
    return b;
}
int main(int argc, const char * argv[])
{
    int n,x,t,d,ans;
    cin>>n>>x;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        if(x>t)
            d=x-t;
        else
            d=t-x;
        if(i==0)
            ans=d;
        else
            ans=gcd(ans,d);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args : Array<String>) {
        val scn = Scanner(System.`in`)
        val r = scn.nextInt()
        val D = scn.nextInt()
        var x = scn.nextInt()

        for (i in 1..10) {
                x = r * x - D
                println(x)
        }
}

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

int main(){
    int e,y,ans;
    char c;
    cin >> e >> y;
    switch( e ){
        case 0:
            if( y <= 1911 ){
                c = 'M';
                ans = y - 1867;
            }else if( y <= 1925 ){
                c = 'T';
                ans = y - 1911;
            }else if( y <= 1988 ){
                c = 'S';
                ans = y - 1925;
            }else{
                c = 'H';
                ans =  y - 1988;
            }
            cout << c;
            break;
        case 1:
            ans = 1867 + y;
            break;
        case 2:
            ans = 1911 + y;
            break;
        case 3:
            ans = 1925 + y;
            break;
        case 4:
            ans = 1988 + y;
            break;
    }
    cout << ans << "\n";
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << n / 2 + (n % 2) << endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys
import math

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a, b, h, m = na()
hh = math.pi*2*(h/12+m/60/12)
mm = math.pi*2*m/60
# print(a, b)
ax = math.cos(hh)*a
ay = math.sin(hh)*a
bx = math.cos(mm)*b
by = math.sin(mm)*b
print(f"{math.sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by)):.14f}")


Measured memory_bytes: 62528
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve(); int main() { solve(); return 0; }

void solve() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  int n = s.size();
  if (n==26) {
    cout << "None" << endl;
    return;
  }
  
  loop(i,0,26) {
    char c = (char)(i+'a');
    if (c != s[i]) {
      cout << c << endl;
      return;
    }
  }
}


Measured memory_bytes: 3660
#include "bits/stdc++.h"
#pragma once
using namespace std;
int main() {
    int N;
    cin >> N;
    int L;
    cin >> L;
    int min_diff = 300;
    for(int i = 1; i <= N; i++){
        min_diff = min(min_diff, abs(L + i - 1));
    }
    int sum = 0;
    int eat_apple = 0;
    for(int i = 1; i <= N; i++){
        if(abs(L + i - 1) == min_diff){
            eat_apple = i;
        }
        sum += L + i - 1;
    }
    sum -= L + eat_apple - 1;

    cout << sum << endl;
}

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

int main(void){
	int N,i,P,max,min;
	//int P[200000];
	int count = 0;
	scanf("%d", &N);
	/*
	min = 99;
	for(i = 0; i < N; i++) {
		scanf("%d", &P[i]);
		if(P)
	}
	max = min = P[N - 1];
	for (i = N - 1; i > 0; i--) {
	}
	*/
	
	scanf("%d", &P);
	min = P;
	for (i = 1; i < N; i++) {
		scanf("%d", &P);
		if (min >= P) {
			count++;
			min = P;
		}
	}
	printf("%d \n", count+1);

	return 0;
}

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

int main() {
  int n, m, l, h;
  cin >> n >> m;
  int max = n;
  int min = 0;
  for (int i=0; i<m; i++){
    cin >> l >> h;
    if (l > min) min = l;
    if (h < max) max = h;
  }
  int ans = max - min + 1;
  if (ans < 0) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
lr_list = list(list(map(int,input().split())) for _ in range(m))
res = [0]*(n+2)
for l,r in lr_list:
    res[l] += 1
    res[r+1] -= 1

for i in range(1,n+2):
    res[i] += res[i-1]

max_num = max(res)
if max_num == m:
    print(res.count(max_num))
else:
    print(0)

Measured memory_bytes: 31300
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
#define INF 0x7FFFFFFF

//オーバーフロー


int main(){
  string s;
  cin >> s;
  int f=0;
  while((s[0]>='0'&&s[0]<='9')||s[0]=='X'){
    f=0;
    for(int i=1;i<10;i++){
      mp::int512_t a;
      mp::int512_t b;
      mp::int512_t c;
      a=0;
      b=0;
      c=0;
      int g=0;
      int t;
      for(t=0;t<s.size()&&s[t]!='+';t++){
        //if(a==0&&((s[t]=='X'&&i==0)||s[t]=='0')) g|=1;
        a*=10;
        if(s[t]!='X'){
          a+=s[t]-'0';
        }
        else{
          a+=i;
        }
      }
      for(t++;t<s.size()&&s[t]!='=';t++){
        //if(b==0&&((s[t]=='X'&&i==0)||s[t]=='0')) g|=2;
        b*=10;
        if(s[t]!='X'){
          b+=s[t]-'0';
        }
        else{
          b+=i;
        }
      }
      for(t++;t<s.size();t++){
        if(c==0&&((s[t]=='X'&&i==0)||s[t]=='0')) g|=4;
        c*=10;
        if(s[t]!='X'){
          c+=s[t]-'0';
        }
        else{
          c+=i;
        }
      }
      if(a==0) g&=0b110;
      if(b==0) g&=0b101;
      if(c==0) g&=0b011;
      if(c==a+b&&g==0){
        f++;
        cout << i << endl;
        break;
      }
    }

    for(int i=0;i<1&&f==0;i++){
      string a,b,c,ab;
      int t;
      for(t=0;t<int(s.size())&&s[t]!='+';t++){
        if(s[t]!='X'){
          a.push_back(s[t]);
        }
        else{
          a.push_back(i+'0');
        }
      }
      for(t++;t<int(s.size())&&s[t]!='=';t++){
        if(s[t]!='X'){
          b.push_back(s[t]);
        }
        else{
          b.push_back(i+'0');
        }
      }
      for(t++;t<int(s.size());t++){
        if(s[t]!='X'){
          c.push_back(s[t]);
        }
        else{
          c.push_back(i+'0');
        }
      }
      reverse(a.begin(),a.end());
      reverse(b.begin(),b.end());
      reverse(c.begin(),c.end());
      int j;
      int k=0;
      int l=0;
      for(j=0;j<int(a.size())&&j<int(b.size());j++){
        k=0;
        if(a[j]-'0'+b[j]-'0'+l>=10){
          k++;
          ab.push_back(a[j]-'0'+b[j]+l-10);
        }
        else{
          ab.push_back(a[j]-'0'+b[j]+l);
        }
        l=k;
      }
      for(;j<int(a.size());j++){
        k=0;
        if(a[j]-'0'+l>=10){
          k++;
          ab.push_back(a[j]+l-10);
        }
        else{
          ab.push_back(a[j]+l);
        }
        l=k;
      }
      for(;j<int(b.size());j++){
        k=0;
        if(b[j]-'0'+l>=10){
          k++;
          ab.push_back(b[j]+l-10);
        }
        else{
          ab.push_back(b[j]+l);
        }
        l=k;
      }
      if(l>0){
        ab.push_back(l+'0');
      }
      if(ab==c){
        f++;
        cout << i << endl;
        break;
      }
    }

    
    if(f==0){
      cout << "NA" << endl;
    }
    s="";
    cin >> s;
  }
}



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

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

	int n;
	cin >> n;

	vector<vector<int>> a(n, vector<int>(n, -1));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> a[i][j];

	int M = (1 << n);
	int mod = 1e9 + 7;
	vector<int> dp(M);
	dp[0] = 1;

	for(int i = 1; i < M; i++)
	{
		int x = __builtin_popcount(i) - 1;
		for(int j = 0; j < n; j++)
		{
			if((i & (1 << j)) && a[x][j])
			{
				dp[i] += dp[i - (1 << j)];
				if(dp[i] > mod) dp[i] -= mod;
			}
		}
	}

	cout << dp[M - 1] << "\n";
}

Measured memory_bytes: 8448
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))

#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))

#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321
#define IINF 987654321987654321
#define MAXV 200500

#define MOD 1000000007
int N,M,K,T;
char p[3000][3000]; int S[3000][3000]; int A[3000][3000];
int aa[3000][3000], bb[3000][3000];
int main(){
	geti(N,M,K);
	rep(i,N+2) rep(j,M+2) p[i][j] = '0';
	repp(i,N) scanf("%s",p[i]+1);

	repp(i,N){
		repp(j,M){
			if( p[i][j] == '1' && p[i][j+1] == '1' ) aa[i][j] = 1;
			if( p[i][j] == '1' && p[i+1][j] == '1' ) bb[i][j] = 1;
		}
	}

	repp(i,N){
		repp(j,M) aa[i][j] += aa[i-1][j];
	}
	repp(j,M){
		repp(i,N) bb[i][j] += bb[i][j-1];
	}


	repp(i,N){
		repp(j,M){
			S[i][j] = S[i-1][j] + S[i][j-1] - S[i-1][j-1];
			if( p[i][j] == '1' ) S[i][j]++;
			A[i][j] = A[i-1][j] + A[i][j-1] - A[i-1][j-1];
			if( p[i][j] == '1' && p[i-1][j] == '1'  ) A[i][j]++;
			if( p[i][j] == '1' && p[i][j-1] == '1' ) A[i][j]++;
		}
	}

	/*
	repp(i,N){
		repp(j,M) printf("%d ",A[i][j]);
		printf("\n");
	}
	*/
	repp(i,K){
		int a,b,c,d; geti(a,b,c,d);
		int x = S[c][d] - S[c][b-1] - S[a-1][d] + S[a-1][b-1];
		//printf("%d %d %d %d\n",S[c][d],S[c-1][b-1],S[a-1][d-1],S[a-1][b-1]);
		int y = A[c][d] - A[c][b-1] - A[a-1][d] + A[a-1][b-1];
		//printf("%d ",y);
		y -= (aa[c][b-1] - aa[a-1][b-1]);
		y -= (bb[a-1][d] - bb[a-1][b-1]);
		//printf("%d %d %d %d\n",aa[c][b-1],aa[a-1][b-1],bb[a-1][d],bb[a-1][b-1]);
		printf("%d\n",x-y);
	}

}

Measured memory_bytes: 108288