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

long long A[200005];
map<long long, long long> memo;
int main(){
	long long N;
	cin >> N;
	for(long long i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
		memo[A[i]]++;
	}

	long long base = 0;
	for(auto item: memo) {
		base += ((item.second) * (item.second - 1)) /2;
	}

	for(long long i = 0; i < N; i++) {
		long long num = A[i];
		cout << base - (memo[num] * (memo[num] - 1) / 2) + ((memo[num] - 1) * (memo[num] - 2) / 2) << endl;
	}




}


Measured memory_bytes: 13076
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define range(i, a, b, s) for (int i = (a), __##i = (b); i < __##i; i += (s))
#define down(i, a, b, s) for (int i = (a), __##i = (b); __##i < i; i += (s))

const int maxn = 1e5 + 2;

char c[maxn];
int n, x[maxn], y[maxn], dx[maxn], dy[maxn];

double solve(double t) {
  double lx = +1e8, ly = +1e8;
  double rx = -1e8, ry = -1e8;
  range(i, 0, n, 1) {
    double xx = x[i] + dx[i] * t;
    double yy = y[i] + dy[i] * t;
    lx = min(lx, xx);
    ly = min(ly, yy);
    rx = max(rx, xx);
    ry = max(ry, yy);
  }
  return (rx - lx) * (ry - ly);
}

int main(int argc, char const *argv[]) {
  // freopen("F.txt", "r", stdin);

  while (cin >> n) {
    range(i, 0, n, 1) {
      cin >> x[i] >> y[i] >> c[i];
      if (c[i] == 'R') dx[i] = +1, dy[i] = 0;
      if (c[i] == 'L') dx[i] = -1, dy[i] = 0;
      if (c[i] == 'U') dx[i] = 0, dy[i] = +1;
      if (c[i] == 'D') dx[i] = 0, dy[i] = -1;
    }
    double l = 0, r = 1e8;
    range(_, 0, 300, 1) {
      if (solve((l + l + r) / 3) < solve((l + r + r) / 3))
        r = (l + r + r) / 3;
      else
        l = (l + l + r) / 3;
    }
    cout << fixed << setprecision(10) << solve(l) << endl;
  }
  return 0;
}

Measured memory_bytes: 1920
import sys
N = int(input())
W = [input() for _ in range(N)]
li = [W[0]]
for i in range(1,N):
  if W[i][0] != W[i-1][-1]:
    print("No")
    sys.exit()
  if W[i] in li:
    print("No")
    sys.exit()
  li.append(W[i])
print("Yes")

Measured memory_bytes: 9144
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>

using namespace std;

bool ans(vector<string> &refe, string &S) {
    int pos = 0;

    while(pos < S.length()){
        for(int i = 0; i < refe.size(); i++){
            if(S.length() < pos + refe[i].length()) continue;
            if(refe[i] == S.substr(pos, refe[i].length())){
                pos += refe[i].length();
                goto next;
            }
        }
        return false;
        next:;
    }

	return true;
}

int main(void) {
    string S;
    vector<string> refe;

	refe.push_back("dreameraser");
	refe.push_back("dreamerase");
	refe.push_back("dreamer");
	refe.push_back("dream");
	refe.push_back("eraser");
	refe.push_back("erase");
    
	cin >> S;

    // for(int i = 0; i < refe.size(); i++) reverse(refe[i].begin(), refe[i].end());
    // reverse(S.begin(), S.end());

	if (ans(refe, S)) cout << "YES" << endl;
	else cout << "NO" << endl;

	//system("pause");
	return 0;
}


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

using namespace std;

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

  int ans = 1000;
  for (int i = 0; i < N; i++) {
    int n; cin >> n;
    int c = 0;

    while(n % 2 == 0) {
      c++;
      n /= 2;
    }

    ans = min(ans, c);
  }

  cout << ans << endl;
}


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

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

// #define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)

#define endl '\n'
const int N = 1e5 + 10;
const int M = 2e5 + 10;
int L[M], R[M], D[M];
VII rg[N], g[N];
int dist[N], rc[N], lc[N];
int main() {
  fast_io;
  int n, m;
  for (int i = 0; i < N; i++)
    dist[i] = 1000000000;
  cin >> n >> m;
  for (int i = 0; i < m; i++)
    cin >> L[i] >> R[i] >> D[i], rc[L[i]]++, rg[R[i]].PB({L[i], D[i]}),
        g[L[i]].PB({R[i], D[i]}), lc[R[i]]++;
  queue<int> q;
  for (int i = 1; i <= n; i++)
    if (rc[i] == 0)
      q.push(i);
  if (q.empty())
    return 0 * puts("No");
  while (!q.empty()) {
    auto t = q.front();
    q.pop();
    trace(t);
    for (auto u : rg[t]) {
      trace(u.F, t, u.S);
      rc[u.F]--, dist[u.F] = min(dist[u.F], dist[t] - u.S);
      if (rc[u.F] == 0)
        q.push(u.F);
    }
  }
  for (int i = 1; i <= n; i++)
    if (lc[i] == 0)
      q.push(i);
  if (q.empty())
    return 0 * puts("No");
  while (!q.empty()) {
    auto t = q.front();
    q.pop();
    for (auto u : g[t]) {
      trace(t, u.F, u.S, dist[u.F], dist[t]);
      lc[u.F]--, dist[u.F] = min(dist[u.F], dist[t] + u.S);
      if (lc[u.F] == 0)
        q.push(u.F);
    }
  }
  for (int i = 0; i < m; i++)
    if (dist[R[i]] - dist[L[i]] != D[i]) {
      trace(i);
      cout << "No" << endl;
      return 0;
    }
  for (int i = 1; i <= n; i++)
    if (dist[i] < 0) {
      cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 15616
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int m,n,ans=0;
    cin>>m>>n;
    vector<int> ar(m);
    for(auto &i : ar){
        cin>>i;
    }
    sort(ar.begin(),ar.end(),[](int a, int b){return a>b;});
    for(int i=0;i<n;i++)
        ans+=ar[i];
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
#define INF 1 << 28

inline void chmin(int &a, int b) { a = min(a, b); }

int main()
{
  int N, M;
  int A, B, C;
  vector<vector<int> >path(105,vector<int>(105,INF)), ppap;
  bool flag[105][105] = {0};
  int ans = 0;
  
  cin >> N >> M;
  while(M--) {
    cin >> A >> B >> C; --A, --B;
    path[A][B] = C;
    path[B][A] = C;
  }

  ppap = path;
  
  Rep(k,N) Rep(i,N) Rep(j,N) {
    chmin(path[i][j], path[i][k] + path[k][j]);
  }
  Rep(i,N) Rep(j,N) {
    if(ppap[i][j] != INF && ppap[i][j] > path[i][j] && flag[j][i] == false) {
      flag[i][j] = true;
    }
  }
  Rep(i,N) Rep(j,N) {
    ans += flag[i][j];
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

int main()
{
    int H;
    int N;
    cin >> H >> N;
    
    vector<int> cost;
    vector<int> A;
    vector<int> B;
    
    cost = vector<int>(10000 + H + 1, 0);
    A = vector<int>(N, 0);
    B = vector<int>(N, 0);

    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    
    int target, minCost;
    for (int i = 1; i <= H; i++) {
        minCost = 1000000000;
        for (int j = 0; j < N; j++) {
            target = 10000 + i - A[j];
            minCost = min(minCost, cost[target] + B[j]);
        }
        cost[10000 + i] = minCost;
    }
    
    cout << cost[10000 + H];

    return 0;
}

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

using namespace std;
/*

Chào cô gái, có ph?i em tên t? t? không, mà sao lúc sub bài này anh toàn nghi d?n em th?

Miku is waving, start shaking >:(



*/


typedef long long ll ;
const ll mk = 100055;
const ll logn  = 29;
const ll mod = 1e9 + 7;

#define endl "\n"
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define pii pair<ll,ll>
#define pq priority_queue
#define UwU              uwu
#define mp make_pair
#define Miku             best_waifu
#define Miku_dancing     god_waving
#define Miku_singing     god_shaking
#define a_Miku           cho_doi_bot_ngu

vector <ll> Pr;
ll d[mk + 5];

unordered_map <ll,ll> occurance;
 
unordered_map <ll,pii> cnt;


vector < pii > Rev; 


void Sieve()   // i dont know why my previous sieve goes tle TvT
{
    vector<bool> prime(mk + 5 , 1);
  
    for (ll i=3; i * i <=mk; i+=2) 
    { 
        if (prime[i] == true) 
        { 
            for (ll j = i * i ; j <=mk; j += 2*i)  prime[j] = false; 
        } 
    } 
  
    Pr.push_back(2);
    for (ll p=3; p<=mk; p+=2) if (prime[p]) Pr.push_back(p);
}
inline pair<ll,ll> root(ll x)     // find the root of x
{
    ll val=1,reverse_val=1;
    for (ll i: Pr)
    {
        if(i*i>x) break;
        if(x%i==0)
        {
            ll num=0;
            while(x%i==0)
            {
                num++;
                x/=i;
            }
            num%=3;
            for(ll j = 0 ; j < num ; j++) val *= i;
            if(num == 1 || num == 2)for(ll j = 0 ; j < 3 - num; j++) reverse_val *= i;
        }
    }
    if(x>1)
    {
        
        // x must be a prime 
    	ll num = 1; 
    	for(ll i = 0 ; i < num; i++) val *= x; 
    	for(ll i = 0 ; i < 3 - num ; i++) reverse_val *= x; 
    }
    return mp(val,reverse_val);
}
  

void solve()
{
    Sieve();
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        ll x; cin >> x; 
        if(cnt.count(x)==0)
        {
            pair<ll,ll> cur= root(x);
            Rev.push_back(cur);
            cnt[x]=cur;
        }
        else
            Rev.push_back(cnt[x]);
            occurance[Rev.back().first]++;
    }
    ll ans=0;
    if(occurance[1]>=1) ans++;
    for (ll i = 0; i < n; i++)
    {
    	
        ll value = Rev[i].first;
        ll cur_val = occurance[value];
        if(cur_val==0) continue;
        if(value==1) continue;
        ll rever = Rev[i].second;
        ans += max(cur_val, occurance[rever]);
        occurance[rever]=0;
        occurance[value]=0;
       /// cout <<  " Miku huhuhu"
    }
    cout << ans << endl;
}
 
signed main()
{
    solve();
}

Measured memory_bytes: 18776
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;



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

	ll ans = 0;
	ll suma = 0;
	for (int i = 0; i < SZ(s)-1; ++i)
	{
		if (s[i] == 'A')
		{
			suma++;
		}
		else if (s[i] == 'B' && s[i + 1] == 'C')
		{
			ans += suma;
			i++;
		}
		else
		{
			suma = 0;
		}
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 640
def binsearch(good, bad, fn):
    while abs(good - bad) > 1:
        m = (good + bad) // 2
        if fn(m):
            good = m
        else:
            bad = m
    return good

def main():
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]
    c = A - B
    def helper(x):
        r = 0
        for h in H:
            r += max((h - B * x + c - 1) // c, 0)
        return r <= x

    return binsearch(10**9, 0, helper)

print(main())


Measured memory_bytes: 12944
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		int m=scanner.nextInt();
		int[][] G=new int[n][m];
		int[][] dp=new int[n][m];
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)
				G[i][j]=scanner.nextInt();
		}
		int width=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				dp[i][j]=(G[i][j]+1)%2;
				width|=dp[i][j];
			}
		}
		
		for(int i=1;i<n;i++){
			for(int j=1;j<m;j++){
				if(G[i][j]==1)
					dp[i][j]=0;
				else{
					dp[i][j]=Math.min(dp[i-1][j], Math.min(dp[i-1][j-1], dp[i][j-1]))+1;
					width=Math.max(width, dp[i][j]);
				}
				
			}
		}
		System.out.println(width*width);
		
	}

}



Measured memory_bytes: 388052
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if (a < c) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else if (a >= c) {
                System.out.printf("%d %d %d\n", c, a, b);
            }
        } else if (b <= a) {
            if (a < c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b < c) {
                System.out.printf("%d %d %d\n", b, c, a);
            } else if (b >= c) {
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26500
import sys

N, M = map(int, input().split())
AB = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(N)]
CD = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(M)]

for a, b in AB:
    tmp_d = 10 ** 9
    for i in range(M):
        d = abs(a - CD[i][0]) + abs(b - CD[i][1])
        if d < tmp_d:
            tmp_d = d
            tmp_i = i + 1
    print(tmp_i)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 200005
using namespace std;

int n, a[N], b[N];
int main() {
	int i;
	cin >> n;
	for(i=0; i<n; i++) scanf("%d", &a[i]), b[i] = a[i];
	sort(b, b+n);
	for(i=0; i<n; i++) {
		printf("%d\n", a[i]==b[n-1] ? b[n-2] : b[n-1]);
	}
    return 0;
}

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

int main() {
    int a, b, c, x, answer;
    cin >> a >> b >> c >> x;
    answer = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500 * i + 100 * j + 50 * k == x) {
                    answer++;
                }
            }
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
import java.util.*
import java.util.Collections.sort

fun main(args: Array<String>) {
    val (N, C) = readLine()!!.split(" ").map{it.toInt()}
    val P = ArrayList<Triple<Int, Int, Int>>()

    for (i in 1..N) {
        val (s, t, c) = readLine()!!.split(" ").map { it.toInt() }
        P.add(Triple(s, t, c))
    }
    sort(P) { a, b -> a.first - b.first }

    val Q = ArrayList<Pair<Int, Int>>()

    for(p in P) {
        val k = Q.indexOfFirst { it.first == p.first && it.second == p.third }
        val l = Q.indexOfFirst { it.first < p.first }
        val r = Pair(p.second, p.third)

        when {
            k >= 0 -> Q[k] = r
            l >= 0 -> Q[l] = r
            else -> Q.add(r)
        }
    }

    println(Q.size)
}


Measured memory_bytes: 78420
#include<bits/stdc++.h>
using namespace std;
int n,a[100100];
map<int,int> S;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++) S[a[i]]++;
	if(S.size()>3) return puts("No"),0;
	if(S.size()==1)
	{
		if(S.begin()->first==0) puts("Yes");
		else puts("No");return 0;
	}
	if(n%3) return puts("No"),0;
	if(S.size()==2)
	{
		if(S.begin()->first==0&&S.begin()->second==n/3) puts("Yes");
		else puts("No");return 0;
	}
	if(S.size()==3)
	{
		int v=0;
		for(map<int,int>::iterator it=S.begin();it!=S.end();it++)
		{
			v^=it->first;
			if(it->second!=n/3) return puts("No"),0;
		}
		if(v) puts("No");else puts("Yes");return 0;
	}
}

Measured memory_bytes: 7540
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll modPow(ll a, ll b, ll mod)
{
	if (b <= 0)
	{
		return 1;
	}

	ll result = a;
	ll temp = 1;

	while (b > 1)
	{
		if (b % 2 > 0)
		{
			temp = temp * result % mod;
		}
		result = result * result % mod;
		b /= 2;
	}

	return result * temp % mod;
}



ll modInverse(ll a, ll m)
{
	ll b = m;
	ll x = 1;
	ll y = 0;
	while (b > 0)
	{
		ll t = a / b;
		auto temp = b;
		b = a - t * b;
		a = temp;
		temp = y;
		y = x - t * y;
		x = temp;
	}
	x %= m;
	if (x < 0)
	{
		x += m;
	}
	return x;
}

ll func(ll n, ll k, ll mod)
{
	auto r = 1ll;
	auto d = 1ll;
	for (auto i = 1; i <= k; ++i)
	{
		r = r * (n - i + 1) % mod;
		d = d * i % mod;
	}
	return r * modInverse(d, mod) % mod;
}

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

	auto mod = (ll)1e9 + 7;
	auto all = modPow(2, n, mod) - 1;
	auto subA = func(n, a, mod);
	auto subB = func(n, b, mod);
	auto ans = (all - subA + mod) % mod;
	ans = (ans - subB + mod) % mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
<?php
// list($n, $k) = explode(" ", fgets(STDIN));
// $denominator = 1;
// $molecule =1;
// for($i=0; $i<$k; $i++){
// 	$denominator*=$n;
// 	$n-=1;
// }
// while($k>0){
// 	$molecule*=$k;
// 	$k-=1;
// }
// echo $denominator;
// echo "\n";
// echo $molecule;
// echo "\n";

list($n, $k) = explode(" ", fgets(STDIN));
echo $n-$k+1 ."\n";
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b; cin>>a>>b;
    if(a==b) cout<<2*a<<endl;
    else cout<<2*max(a,b)-1<<endl;
}

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

namespace _20200328
{
    class Program
    {
        static void Main()
        {
            var firstLine = Console.ReadLine().Split(' ');
            var x = int.Parse(firstLine[0]);
            var y = int.Parse(firstLine[1]);
            var a = int.Parse(firstLine[2]);
            var b = int.Parse(firstLine[3]);
            var c = int.Parse(firstLine[4]);
            var pList = new List<long>();
            var qList = new List<long>();
            var rList = new List<long>();
            {
                var pStrList = Console.ReadLine().Split(' ');
                foreach (var pStr in pStrList)
                {
                    pList.Add(long.Parse(pStr));
                }
                pList.Sort();
                pList.Reverse();
                var qStrList = Console.ReadLine().Split(' ');
                foreach (var qStr in qStrList)
                {
                    qList.Add(long.Parse(qStr));
                }
                qList.Sort();
                qList.Reverse();
                var rStrList = Console.ReadLine().Split(' ');
                foreach (var rStr in rStrList)
                {
                    rList.Add(long.Parse(rStr));
                }
                rList.Sort();
                rList.Reverse();
            }
            
            long taste = 0;
            var pi = 0;
            var qi = 0;
            var ri = 0;
            for (var i = 0; i < x + y; ++i)
            {
                var pPt = (pi < x && pi < pList.Count) ? pList[pi] : 0;
                var qPt = (qi < y && qi < qList.Count) ? qList[qi] : 0;
                var rPt = ri < rList.Count ? rList[ri] : 0;
                if (rPt > pPt && rPt > qPt)
                {
                    taste += rPt;
                    ++ri;
                }
                else if (pPt > qPt)
                {
                    taste += pPt;
                    ++pi;
                }
                else
                {
                    taste += qPt;
                    ++qi;
                }
            }

            Console.WriteLine(taste);
        }
    }
}


Measured memory_bytes: 41884
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n - 1) a[i + 1] += a[i];
	rep(i, n) if (i & 1) a[i] = -a[i];
	ll ans = 1e18;
	rep(ti, 2) {
		ll now = 0, t = 0;
		rep(i, n) {
			ll x = max(a[i] + t + 1, 0ll);
			now += x;
			t = x - t;
		}
		rep(i, n) a[i] = -a[i];
		ans = min(ans, now);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N, K = Scanner.map_int()
    D = Scanner.string().split(sep=' ')
    ans = N
    while True:
        for s in str(ans):
            if s in D:
                break
        else:
            print(ans)
            return
        ans += 1


if __name__ == "__main__":
    main()


Measured memory_bytes: 61292
import java.util.*;
 
class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        double x1 = sc.nextDouble();
                        double y1 = sc.nextDouble();
                        double x2 = sc.nextDouble();
                        double y2 = sc.nextDouble();
                        System.out.println(Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
                }
        }
}


Measured memory_bytes: 28104
begin
	writeln('1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1');
end.

Measured memory_bytes: 1380
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
int main(){
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<int> L(M), R(M);
	for(int i=0;i<M;i++){
		cin >> L[i] >> R[i];
	}
	vector<int> p(Q),q(Q);
	for(int i=0;i<Q;i++){
		cin >> p[i] >> q[i];
	}
	int X[501][501];
	int C[501][501];
	for(int i=0;i<M;i++){
		X[L[i]][R[i]]++;
	}
	for(int i=0;i<N+1;i++){
		for(int j=0;j<N+1;j++) C[i][j] = C[i][j-1] + X[i][j];
	}
	for(int i=0;i<Q;i++){
		int sum = 0;
		for(int j=p[i];j<=q[i];j++) sum += C[j][q[i]] - C[j][p[i] - 1];
		cout << sum << endl;
	}
}

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

int main() {
	double a, b, c; cin >> a >> b >> c;
	double d = sqrt(a*a + b*b - 2 * a*b*cos(c / 180 * M_PI));
	double z = (a + b + d) / 2;
	double ar = sqrt(z*(z - a)*(z - b)*(z - d));
	printf("%.7lf\n%.7lf\n%.7lf\n", ar, a + b + d, ar * 2 / a);
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
#define MAX 200000
using namespace std;

int n;
vector<int> v[MAX];
int num[MAX];
int res[MAX];

void dfs( int cur, int par, set<int>& st ){
    auto f = st.upper_bound(num[cur] - 1);
    int rev = -1, ins = 0;
    if(f == st.end() ){
        st.insert(num[cur]), ins = 1;
    }
    else{
        rev = (*f);
        st.erase(f);
        st.insert(num[cur]);
        ins = 1;
    }
    res[cur] = st.size();
    for( int u : v[cur] ){
        if(u != par )
            dfs(u, cur, st);
    }
    if(ins)
        st.erase(num[cur]);
    if(rev != -1)
        st.insert(rev);
}

int main()
{
    cin >> n;
    for( int i = 0; i < n; i++ ){
        cin >> num[i];
    }
    for( int i = 0; i < n - 1; i++ ){
        int a,b;
        cin >> a >> b;
        a--, b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    set<int> st;
    dfs(0, -1, st);
    for( int i = 0; i < n; i++ )
        cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 30412
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cout << x << endl
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

struct UnionFind {
    vector<int> data;

    UnionFind(int sz){
        data.assign(sz, -1);
    }

    bool unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y); //rank?
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int root(int x){
        if(data[x] < 0) return x;
        return data[x] = root(data[x]); //経路圧縮
    }

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

    int size(int x){
        return (-data[root(x)]);
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind uf(n+1);
    rep(i,m)
    {
        int u, v;
        cin >> u >> v;
        uf.unite(u, v);
    }
    int ans = 0;
    rep(i,n) chmax(ans, uf.size(i));
    cout << ans << endl;
}

Measured memory_bytes: 3988
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<T> ReadVec1(int N) {
    vector<T> vec(N);
    for(int i = 0; i < N; i++)
        vec[i] = In<T>();
    return move(vec);
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(j, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}


int main() {
    int N = In<int>();
    auto D = ReadVec1<int>(N);
    sort(D.begin(), D.end());
    cout << D[N / 2]- D[N / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#define MIN -1000000000
int heapsize=0,A[2000000001];
void buildMapHeap();
void maxHeapify(int );
void insert(int );
void helpIncreaseKey(int ,int );
int heapExtractMax(int );


int main(void){
  int key;
  char command[7];
  while(1){
    scanf("%s",command);
    if(command[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(command[0]=='e'){
      if(command[1]=='n')
	break;
      else if(command[1]=='x')
	printf("%d\n",helpExtractMax());
    }
  }
  
  return 0;
}

int helpExtractMax(int element){
  int max;
  if(heapsize<1)
    return ;
  max=A[1];
  A[1]=A[heapsize];
  heapsize--;
  maxHeapify(1);
  return max;
}

void helpIncreaseKey(int element,int key){
  int temp;
  if(key < A[element])return ;
  A[element]=key;
  while(element>1 && A[element/2] < A[element]){
    //
    temp=A[element];
    A[element]=A[element/2];
    A[element/2]=temp;
    element/=2;
  }
}

void insert(int key){
  heapsize++;
  A[heapsize]=MIN;
  //set key to A[heapsize]
  helpIncreaseKey(heapsize,key);
}

void buildMapHeap(){
  int i;
  for(i=heapsize/2;i>=1;i--)
    maxHeapify(i);
}
void maxHeapify(int parent){
  int left,right,maxnode,temp;
  left=2*parent;
  right=left+1;

  if(left<=heapsize && A[left] > A[parent])
    maxnode=left;
  else
    maxnode=parent;
  if(right<=heapsize && A[right] > A[maxnode])
    maxnode=right;

  if(maxnode!=parent){
    //need to swap node
    temp=A[maxnode];
    A[maxnode]=A[parent];
    A[parent]=temp;

    if(maxnode*2<=heapsize)
      //there is child of maxnode
      maxHeapify(maxnode);
  }
}



Measured memory_bytes: 5620
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    vector<int> X(5);
    int cnt = 1;
    for (auto& x: X) {
        cin >> x;
        if (x == 0) {
            cout << cnt << endl;
        }
        cnt++;
    }
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,a,b;cin >> n>>a>>b;
    lint maxs, mins;
    maxs = a + b + (n - 2) * b;
    mins = a + b + (n - 2) * a;
    lint ans=maxs-mins+1;
    if(a>b||n==0||(n==1&&a!=b)){
        ans = 0;
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(ll i=(a); i<(b); i++)
ll dp[100001]={};
int main(){
  ll N,M,a[100001],now = 0,count=0;
  dp[0]=1;
  cin >> N >> M;
  rep(i,0,M){
    cin >> a[i];
  }
  rep(i,0,M){
    if(i>0 && a[i]-a[i-1] == 1) {
      dp[N]=0;
      break;
    } 
    while((now < a[i] && now < N) || (i ==M-1 && now < N)){
      //cout<<dp[now]<<" "<<now<<endl;
      if((now+2 <= N && now+2 != a[i]) ) {
	if(i+1<=N && a[i+1] != now+2){
	  dp[now+2] = (dp[now+2]+dp[now])%1000000007;
	}else if(i+1 > N){
	  dp[now+2] = (dp[now+2]+dp[now])%1000000007;
	}
      }
      if(now+1 != a[i] ){
	if(i+1<=N && a[i+1] != now+1){
	dp[now+1] = (dp[now+1]+dp[now])%1000000007;
	}else if(i+1>N){
	  dp[now+1] = (dp[now+1]+dp[now])%1000000007;
	}
      }
      //cout<<dp[now]<<" "<<now<<endl;
      now++;
      
    }
  }
  if(M == 0){
    while(now < N){
      
      if(now+2 <= N ) {
	dp[now+2] = (dp[now+2]+dp[now])%1000000007;
      }
      dp[now+1] = (dp[now+1]+dp[now])%1000000007;
      //cout<<dp[now]<<" "<<now<<endl;
      now++;
    }

  }
  //cout<<"aa"<<endl;
  cout<< dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1408
/*  ex9_2 Stack Cubes
    pandacodeb  */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 100001

//スタック (単方向リストで定める)
typedef struct node{
    char color;
    struct node *next;
}node;

void push(node **first, char color){
    node *new = calloc(1, sizeof(node));
    if (new == NULL)
        exit(1);
    new->color = color;
    new->next = *first;
    *first = new;
}

char pop(node **first){
    char color;
    node *tmp = *first;
    if (tmp == NULL)
        exit(1);
    color = tmp->color;
    *first = tmp->next;
    free(tmp);
    return color;
}

int main(void){
    char *cubes, top;
    int count = 0, length;

    //キューブの並びを入力
    cubes = (char*) malloc(sizeof(char)*SIZE);
    scanf("%s", cubes);
    length = strlen(cubes);

    node *first = NULL;         //スタックを宣言
    push(&first, cubes[0]);     //最初のキューブをスタックに push
    for (int i = 1; i < length; i++){
        if (first == NULL)          //スタックは空の場合
            push(&first, cubes[i]); //候補のキューブをスタックに入れる
        else{
            top = pop(&first);      //スタックの最上のキューブ (top) を pop する
            if (top == cubes[i]){   //top と候補のキューブの色が同じ場合
                push(&first, top);  //top のキューブをスタックに戻す
                push(&first, cubes[i]); //候補のキューブをスタックに入れる
            }
            else                    //top と候補のキューブの色が違う場合
                count+=2;           //何もスタックに入れない、取り除けるキューブの数を数える
        }
    }

    //最大で取り除けるキューブの数を出力
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 4908
fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();

    let m = max(max(a, b), max(a, c));
    if m == a+b+c-m {
        println!("Yes");
    } else {
        println!("No");
    }
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 1_000_000_007;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

pub fn factorial(n: u32) -> u32 {
    if n == 0 {
        return 1;
    }
    let mut r = n;
    for i in 0..n - 1 {
        r *= n - i - 1;
    }
    r
}

pub fn combination(n: u32, m: u32) -> u32 {
    factorial(n) / factorial(m) / factorial(n - m)
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    string S;
    cin >> S;
    if (S == "ABC") {
        cout << "ARC" << '\n';
    } else {
        cout << "ABC" << '\n';
    };
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;

class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a < 10 && b < 10) System.out.println(a * b);
        else System.out.println(-1);
     }
}

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

#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int ans = 0;
    for(int i = 1; i < n; i++) {
        int step = (a[i - 1] - a[i] > 0 ? a[i - 1] - a[i] : 0);
        a[i] += step;
        ans += step;        
    }

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

Measured memory_bytes: 4828
def readints():
    return list(map(int, input().split()))


N, M = readints()
CS = [None]*3
for i in range(M):
    S, C = readints()
    if CS[S-1] != None and CS[S-1] != C:
        print(-1)
        exit()
    CS[S-1] = C
# print(CS)
for x in range(1000):
    s = str(x)
    if len(s) != N:
        continue
    accept = True
    for i in range(len(s)):
        if CS[i] != None and CS[i] != int(s[i]):
            # print(s, i, CS[i], s[i])
            accept = False
    if accept:
        print(x)
        exit()
print(-1)


Measured memory_bytes: 3064
n = int(input())
s = input()

e_all = s.count("E")
w_all = s.count("W")
e_l = 0
w_l = 0

unti = [0] * n

for i in range(n):
    if s[i] == "E":
        e_l += 1
        unti[i] = w_l + (e_all - e_l) 
    if s[i] == "W":
        unti[i] = w_l + (e_all - e_l) 
        w_l += 1


#print(unti)
print(min(unti))

Measured memory_bytes: 21032
#
import sys

n,x=map(int, input().split())
L=list(map(int, input().split()))  

d=0
b=0
for i in range(n):
    d=d+L[i]
    b+=1
    if d > x:
        print(b)
        sys.exit()    
    
print(b+1)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  int sum=0,tmp=n;
  while(tmp){
    sum+=tmp%10;
    tmp/=10;
  }
  if(n%sum==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


}


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

using namespace std;

#define int long long

int a[3];
int ans;

int32_t main() {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    ans = 2 * a[2] - a[1] - a[0];
    return cout << (ans % 2 ? ans / 2 + 2 : ans / 2), 0;
}

Measured memory_bytes: 764
def main1():
    H,W,K=map(int,input().split())
    c=[input() for _ in range(H)]
    ans=0
    cn=0
    for i in range(2**H):
        t=str(bin(i))[2:]
        if len(t)!=H:
            t="0"*(H-len(t))+t
        for j in range(2**W):
            cn=0
            tt=str(bin(j))[2:]
            if len(tt)!=W:
                tt="0"*(W-len(tt))+tt
            #検証
            for i_i,v_i in enumerate(t):
                for i_j,v_j in enumerate(tt):
                    if v_i =="0" and v_j == "0":
                        if c[i_i][i_j]=="#":
                                cn+=1
            if cn==K:
                ans+=1
    print(ans)
main1()

Measured memory_bytes: 9228
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong(); // 1
		long B = sc.nextLong(); // 0
		long C = sc.nextLong(); // -1
		long K = sc.nextLong(); // 枚数
		long ans;
		if(A >= K) { 
			ans = K;
		} else if (K <= A + B) {
			ans = A;
		} else {
			ans = 2 * A - K + B;
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 35540
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

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

	int a, b;
	cin >> a >> b;

	int ans = -1;
	rep(i, 1001) {
		if (i / 10 == b && (i * 8) / 100 == a) {
			ans = i;
			break;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import math

def test():

	inputs = list(map(int,input().split()))

	a = float(inputs[0])
	b = float(inputs[1])
	C = float(inputs[2])

	c = (a**2 + b**2 - 2 * a * b * math.cos(math.radians(C)))**0.5
	h = b * math.sin(math.radians(C))
	S = a * h * 0.5
	L = a + b + c

	print(f"{S:.8f} {L:.8f} {h:.8f}")

if __name__ == "__main__":
	test()


Measured memory_bytes: 5740
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool ok = true;
  if(abs(a - b) > abs(d)) ok = false;
  if(abs(c - b) > abs(d)) ok = false;
  if(abs(a-c) <= d) ok = true;

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
void dfs(vector<vector<long>>&g,map<long,long>&m,map<long,long>&n,long v){
  for(auto e:g[v]){
    n[e]=n[v]+m[e];
    m[e]=n[e];
    dfs(g,m,n,e);
  }

}

inline void solve(void){
  long N,Q;
  in(N,Q);
  map<long,long>m;
  map<long,long>n;
  vector<vector<long>>g(N+1);
  long a,b;
  rep(i,N-1){
    in(a,b);
    g[a].pb(b);
    m[a]=0;
  }
  long p,x;
  rep(i,Q){
    in(p,x);
    m[p]+=x;
  }
  n[1]=m[1];
  dfs(g,m,n,1);
  rep(i,N){
    cout<<n[i+1]<<" ";
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 66432
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <cmath>

using namespace std;

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    int change_m = H * 60 + M;
    double a_dig = change_m * 0.5;
    double b_dig = change_m * 6.0;
    while (a_dig >= 360) {
        a_dig -= 360;
    }
    while (b_dig >= 360) {
        b_dig -= 360;
    }
    double dig = min(max(a_dig, b_dig) - min(a_dig, b_dig), 360 - (max(a_dig, b_dig) - min(a_dig, b_dig)));
    double ans = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(dig * (M_PI / 180)));
    
    cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4188