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

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	
	double s, p;
	double ans;
	if(x > a * a * b / 2){
	    s = (a * a * b - x) / a;
	    p = 2 * s / a;
	    ans = (atan2(p, a)/2/M_PI)*360;
	}else{
	    s = x / a;
	    p = 2 * s / b;
	    ans = (atan2(b, p)/2/M_PI)*360;
	}
	
	printf("%.8lf",ans);
	
	return 0;
}

Measured memory_bytes: 256
import math
a,b,deg = map(float,input().split())
rad = math.radians(deg)
S = a * b * math.sin(rad) / 2
L = (a**2 + b**2 - 2*a*b*math.cos(rad))**0.5 + a + b
h = abs(b * math.sin(rad))
print(S)
print(L)
print(h)




Measured memory_bytes: 5700
import java.util.*;
import java.util.Map.Entry;
 
 
 
public class Main{
	
	public int num;
	public int vol;
 
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 long N=sc.nextLong(),M=sc.nextLong();
	 long result=0;
	 if(N*2<=M) {
		 result+=N;
		 M-=N*2;
		 result+=M/4;
		 
	 }else {
		 result+=M/2;
	 }
	 System.out.println(result);
	 
 }
	
 
 
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <functional>
#include <tuple>

#ifdef USE_PYTHON_LIKE_PRINT
#include "print.h"
#else
template<char SEP = ' ', char END = '\n'> inline void print(...){}
template<char SEP = ' ', char END = '\n'> inline void printe(...){}
template<char SEP = ' ', char END = '\n'> inline void printo(...){}
#define define_print(...)
#define define_print_with_names(...)
#define define_to_tuple(...)
#endif

using namespace std;

inline int pow2(int n){
	int x = 1;
	for(int i = 0; i < n; i ++){
		x *= 2;
	}
	return x;
}

inline int pow3(int n){
	int x = 1;
	for(int i = 0; i < n; i ++){
		x *= 3;
	}
	return x;
}

void combi(const int N, vector<int>& towns, const int K, const int l, const int n, function<void(void)> f){
	if(l == K){
		f();
	}else{
		for(int i = n; i <= N - K + l; i ++){
			towns[l] = i;
			combi(N, towns, K, l + 1, i + 1, f);
		}
	}
}

int main(void){
	int N;
	cin >> N;
	
	vector<tuple<int, int, int>> data;
	
	unsigned long min_value_0 = 0;
	for(int i = 0; i < N; i ++){
		int X, Y, P;
		cin >> X;
		cin >> Y;
		cin >> P;
		data.push_back(make_tuple(X, Y, P));
		min_value_0 += (unsigned long)min(abs(X), abs(Y)) * (unsigned long)P;
	}
	
	cout << min_value_0 << endl;
	
	const int B = pow2(N);
	
	vector<vector<int>> table_dists_h(B + 1);
	vector<vector<int>> table_dists_v(B + 1);
	
	for(int b = 0; b < B; b ++){
		auto& dists_h = table_dists_h[b];
		auto& dists_v = table_dists_v[b];
		
		dists_h.reserve(N);
		dists_h.reserve(N);
		for(int i = 0; i < N; i ++){
			const int X0 = get<0>(data[i]);
			const int Y0 = get<1>(data[i]);
			int x = b;
			int j = 0;
			int d_h = abs(X0);
			int d_v = abs(Y0);
			while(x > 0){
				if(x % 2 == 1){
					const int X1 = get<0>(data[j]);
					const int Y1 = get<1>(data[j]);
					d_h = min(d_h, abs(X1 - X0));
					d_v = min(d_v, abs(Y1 - Y0));
				}
				x /= 2;
				j += 1;
			}
			dists_h.push_back(d_h);
			dists_v.push_back(d_v);
		}
	}
	
	const int T = pow3(N);
	vector<unsigned long> table(N + 1, min_value_0);
	for(int t = 0; t < T; t ++){
		int b0 = 0;
		int b1 = 0;
		int b = 1;
		int x = t;
		int c = 0;
		while(x > 0){
			switch(x % 3){
			case 1:
				b0 += b;
				c ++;
				break;
			case 2:
				b1 += b;
				c ++;
				break;
			}
			x /= 3;
			b *= 2;
		}
		unsigned long value = 0;
		const auto& t0 = table_dists_h[b0];
		const auto& t1 = table_dists_v[b1];
		for(int i = 0; i < N; i ++){
			const int P0 = get<2>(data[i]);
			value += (unsigned long)min(t0[i], t1[i]) * (unsigned long)P0;
		}
		if(table[c] > value){
			table[c] = value;
		}
	}
	
	for(int K = 1; K <= N; K ++){
		cout << table[K] << endl;
	}
	
	return 0;
}



Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
     long int h,n;
   scanf("%ld%ld",&h,&n);
   long int a[n],i,sum=0;
   for(i=0;i<n;++i)
   {
     scanf("%ld",&a[i]);
     sum+=a[i];
   }
     if(sum>=h)
         printf("Yes");
   
    else
       printf("No");
 
	return 0;
}

Measured memory_bytes: 1024
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>
using namespace std;
	typedef long long ll;
	const int maxn=200050;
	ll po[maxn];
	ll a[maxn],b[maxn];
	map<ll,ll>m;
	int main() {
		IOS
		int n;
		cin>>n;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			b[i]=a[i]-i;
			m[-b[i]]+=1;
		}
		ll ans=0;
		for(int i=1;i<=n;i++){
			ll t=b[i]+2*i;
			if(m[t])
				ans+=m[t];
		}
		cout<<ans<<endl;
		return 0;
	}

Measured memory_bytes: 29424
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<functional>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  long long sum = 0;
  vector<int> A(N);
  int b;
  int i;
  priority_queue<pair<int,int>,vector<pair<int,int>>,function<bool(pair<int,int>,pair<int,int>)>> q([](const pair<int,int>& lh, const pair<int,int>& rh) {
    return ((long long)lh.first*rh.second==(long long)rh.first*lh.second?lh.first>rh.first:(long long)lh.first*rh.second<(long long)rh.first*lh.second);
  });
  for(i=0;i<N;i++) {
    cin >> A[i];
    sum += A[i];
  }
  int cnt = 0;
  for(i=0;i<N;i++) {
    b = ((long long)A[i]*(K+1)-1)/sum+1;
    q.push(pair<int,int>(A[i],b));
    cnt += (b-1);
  }
  while(cnt < K) {
    pair<int,int> p = q.top();
    q.pop();
    p.second++;
    q.push(p);
    cnt++;
  }
  printf("%d\n",(q.top().first-1)/q.top().second+1);
}

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

#define endl '\n'
#define rep(i,n)       for(int i=0; i<n; i++)
#define clr(arr)       memset(arr, 0, sizeof arr)
#define all(x)         x.begin(), x.end()
const int MOD = 1e9 + 7;
template<class F, class S> ostream& operator<<(ostream &out, const pair<F, S> &p)
{
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out)
{
	out << '{';
	for (auto i = x.begin(); i != x.end(); i++)
		out << *i << (i == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dmp() {}
template<class T, class... Args> void dmp(T &&x, Args... args)
{
	cerr << x << ";  "; dmp(args...);
}
#ifdef SMIT
struct Nl {~Nl() {cerr << '\n';}};
#define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dmp(x), Nl(), cerr << ""
#else
#define debug(...) {}
#endif
// Yes you CAN

const int N = 1e5 + 1;
int dp[N], h[N], n;
int cost(int n, int h[])
{
	if (n == 0)
		return  0;
	if (dp[n] != -1)
		return dp[n];
	int cost1 = INT_MAX, cost2 = INT_MAX;
	if (n - 1 >= 0)
		cost1 = abs(h[n] - h[n - 1]) + cost(n - 1, h);
	if (n - 2 >= 0)
		cost2 = abs(h[n] - h[n - 2]) + cost(n - 2, h);
	return dp[n] = min(cost1, cost2);
}

void solve()
{
// #define TEST
	memset(dp, -1, sizeof dp);
	cin >> n;
	rep(i, n) cin >> h[i];
	cout << cost(n - 1, h) << endl;
}

int32_t main()
{
#ifdef SMIT
	freopen("/home/smit/Desktop/in.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);

	int t = 1;
#ifdef TEST
	cin >> t;
#endif
	while (t--)
		solve();
}

Measured memory_bytes: 10628
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	int nx = 0 , ny = 0 , nt = 0;
	rep(i,0,n){
		int t,y,x;
		C3(t,y,x);
		int cost = t - nt;
		if( abs(x-nx) <= cost ){
			cost -= abs(x-nx);
		}
		else{
			No;
			ret 0;
		}

		if( abs(y-ny) <= cost ){
			cost -= abs(y-ny);
		}
		else{
			No;
			ret 0;
		}
		
		if(cost % 2 != 0 ){
			No;
			ret 0;
		}

		ny = y;
		nx = x;
		nt = t;
	}
	Yes;
	ret 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
#define Inf 1000000000
using namespace std;
int H,W;


ll A[111111];
int main() {
    int K;
    cin>>K;
    
    
    for(int i=1;i<=K;i++)
        cin>>A[i];
    
    
    // X -> X%A[i]
    
    
    // (X%A[K])=X-2
    // X-(X%A[K])=2
    // X=A[K]*M+X-2
    
    // A[K]*M1=2
    
    ll high=2;
    ll low=2;
    
    bool can=true;
    
    for(int i=K;i>=1;i--) {
        
        
        // (A[i]+1)/A[i]
        
        high=(high/A[i])*A[i];
        
        high += A[i]-1;
        
        low = ((low+A[i]-1)/A[i])*A[i];
        
        

    }
    
    
    
    if (high>=low)
        printf("%lld %lld\n",low,high);
    else
        printf("-1\n");
    
    
}

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

#define forn(l, r) for(int i = l; i < (r); ++i)
#define forj(l, r) for(int j = l; j < (r); ++j)
#define TAM 1000100
#define SYNC ios::sync_with_stdio(0);
#define $ << ' ' <<
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const ll mod = 1000000007;


int main() {
    //SYNC
    int a, b, t, ans;
    cin >> a >> b >> t;
    cout << t/a*b << endl;

    return 0;
}


Measured memory_bytes: 384
#include <cassert>
#include <iostream>
#include <vector>

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> flower(n);
  for (int i = 0; i < n; i++) {
    std::cin >> flower.at(i);
  }
  int first = 0;
  int cnt = 0;
  while (first < n) {
    assert(0 <= flower.at(first));
    if (flower.at(first) == 0) {
      first++;
      continue;
    }
    int last = first;
    cnt++;
    while (last < n && 0 < flower.at(last)) {
      flower.at(last)--;
      last++;
    }
  }
  std::cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
#donut29
n=int(input())
lst=[]
for i in range(n):
    a=int(input())
    b=[]
    for j in range(a):
        x,y=map(int,input().split())
        x-=1
        b.append([x,y])
    lst.append(b)
ans=0
for i in range(2**n):
    on=[]
    switch=0
    for j in range(n):
        if ((i>>j)&1):
            on.append(j)
    for j in on:
        judge=lst[j]
        for k in judge:
            if k[1]==1:
                if not k[0] in on:
                    switch=1
            else:
                if k[0] in on:
                    switch=1
    if switch==0:
        ans=max(ans,len(on))

print(ans)

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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

int main(int argc, char const* argv[])
{
  ll h;
  cin>>h;

  ll ans=0;
  int pos=0;
  while(h) {
    ans |= 1ll<<pos;
    h>>=1;
    pos++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import math

n,m = map(int, input().split())

a = []
b = []
c = []
d = []

for _ in range(n):
	ta, tb = map(int, input().split())
	a.append(ta)
	b.append(tb)

for _ in range(m):
	tc, td = map(int, input().split())
	c.append(tc)
	d.append(td)

index = [0]*n

for sti in range(len(a)):
	di = abs(a[sti]-c[0])+abs(b[sti]-d[0])
	index[sti] = 1
	for chi in range(len(c)):
		if di > abs(a[sti]-c[chi])+abs(b[sti]-d[chi]):
			di = abs(a[sti]-c[chi])+abs(b[sti]-d[chi])
			index[sti] = chi+1

for num in index:
	print(num)
		

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
	int x, y;
	cin >> x;
	cin >> y;

	string ans = "No";

	for (int a = 0; a < x + 1; a++) {
		int b = x - a;
		if (2 * a + 4 * b == y) {
			ans = "Yes";
		}	
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include <vector>
#include <map> 
#include <algorithm>    // std::sort
using namespace std;
int main()
{
  int a;
  cin >> a;
  int cnt=0,strcnt=0,maxnum=0;
  string tmp;
  std::map<std::string, int> mp;
  std::map<std::string, int>::iterator itr;
  while (cin >> tmp) {
    itr = mp.find(tmp);
    if( itr != mp.end() ) {
      mp[tmp]++;
      if (maxnum < mp[tmp]) {
        maxnum++;
      }
    } else {
      mp[tmp] = 1;
      if (maxnum < 1) {
        maxnum++;
      }
    }
  }
  
  std::vector<std::string> vec;
  for ( itr = mp.begin(); itr != mp.end(); itr++ ) {
    if (itr->second == maxnum) {
      	vec.push_back(itr->first);
    }
  }
  
  sort(vec.begin(), vec.end()); 
  
  for (auto str : vec){
    cout << str << endl;
  }
  
  return 0;
}

Measured memory_bytes: 27760
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;

inline int read(){
	int x = 0, ch = getchar(), f = 1;
	while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

int n;
LL a[100005];

int chk(int x){
	LL tmp = 0;
	REP(i, 1, x) tmp += a[i];
	REP(i, x + 1, n)
		if (a[i] > 2 * tmp) return 0;
		else tmp += a[i];
	return 1;
}

int main(){
	n = read();
	REP(i, 1, n) a[i] = read();
	sort(a + 1, a + n + 1);
	int l = 1, r = n, res = -1;
	while (l <= r){
		int mid = l + r >> 1;
		if (chk(mid)) res = mid, r = mid - 1;
		else l = mid + 1;
	}
	if (res == -1) cout << 0 << endl;
	else cout << n - res + 1 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 100006
using namespace std;
int n,a[N],Min,numMin,Max,numMax;
inline int read()
{
	int x=0,c=getchar();while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+c-48,c=getchar();return x;
}
int main()
{
	n=read();
	Max=Min=a[1]=read();
	for(int i=2;i<=n;i++){
		a[i]=read();
		Max=max(Max,a[i]);
		Min=min(Min,a[i]);
	}
	if(Max-Min>1)return puts("No"),0;
	for(int i=1;i<=n;i++){
		if(a[i]==Max)numMax++;
		else numMin++;
	}
	if(Max==Min){
		if(Max+1==numMax||Max<=numMax/2)puts("Yes");else puts("No");
	}else{
		if(1<=Max-numMin&&Max-numMin<=numMax/2)puts("Yes");else puts("No");
	}
}

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

int N, K;
vector<int> d;
vector<vector<int>> A;

int main()
{
    cin >> N >> K;
    d.resize(K);
    A.resize(K, vector<int>());
    for (int i = 0; i < K; i++)
    {
        cin >> d[i];
        A[i].resize(d[i]);
        for (int j = 0; j < d[i]; j++)
        {
            cin >> A[i][j];
        }
    }

    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        bool have = false;
        for (auto v : A)
        {
            for (auto p : v)
            {
                if (p == i)
                    have = true;
            }
        }
        if (!have)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main() 
{
	int n,l;
	string s;
	cin>>n>>l;
	vector<string> v;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		v.push_back(s);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++)
	cout<<v[i];
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

K, N = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
diffs = []
prev = 0
for a in A:
    diffs.append(a - prev)
    prev = a
last = K - A[-1] + A[0]
diffs.append(last)

print(K - max(diffs))


Measured memory_bytes: 28472
import sys
sys.setrecursionlimit(3000)
def rec(x,y,c):
    if   A[y][x] == ".": A[y][x] = c
    elif A[y][x] != c  : A[y][x] = "x"
    for dx,dy in zip([1,0,-1,0],[0,1,0,-1]):
        nx,ny = x+dx,y+dy
        if 0 <= nx < w and 0 <= ny < h and A[ny][nx] in [".","b" if c == "w" else "w"]:
            rec(nx,ny,c)

while 1:
    w,h = map(int,raw_input().split())
    if w == 0: break
    A = [list(raw_input()) for _ in range(h)]
    for y in range(h):
        for x in range(w):
            if A[y][x] == "W": rec(x,y,"w")
            if A[y][x] == "B": rec(x,y,"b")
    print sum(Ai.count("b") for Ai in A),sum(Ai.count("w") for Ai in A)

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

int n,b = 0,c = 0;
int main() {
    scanf("%d",&n);
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    rep(i,0,n){
        if(i%2 == 0) b += a[i];
        else c += a[i];
    }
    pout(b-c);
    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.to!(int[]);
}

int calc(int[][] xs) {
    int n = cast(int) xs[0].length;

    auto dp = new int[][](2, n);
    dp[0][0] = xs[0][0];
    for (int i = 1; i < n; i++) {
        dp[0][i] = xs[0][i] + dp[0][i - 1];
    }

    dp[1][0] = xs[1][0] + dp[0][0];
    for (int i = 1; i < n; i++) {
        dp[1][i] = xs[1][i] + max(dp[0][i], dp[1][i - 1]);
    }

    return dp[1][n - 1];
}

void main() {
    readint;

    int[][] xs;
    xs ~= readints;
    xs ~= readints;

    int ans = calc(xs);
    writeln(ans);

}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include<cmath>
#define pb push_back
#define nax (int)2e5+2
#define ll long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
using namespace std;
 

bool palindrome(string s){
	int n = s.size();
	int l = 0;
	int r = n-1;
	bool ok = true;
	while(l < r){
		if(s[l] != s[r]){
			ok = false;
			break;
		}
		l++;
		r--;
	}	
	return ok;
}

int main() 
{ 
	string s;
	cin>>s;
	if(palindrome(s)){
		int n = s.size();
		int k = s.size();
		string t = s.substr(0,((n-1)/2));
		string p = s.substr((n-1)/2+1,k-1);
		deb(t);
		deb(p);
		if(palindrome(t) && palindrome(p)){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	
	
	return 0; 
} 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
vector<vector<ll> > memo(51,vector<ll>(51,-INF));
ll pascal(ll n, ll k){
    if(memo[n][k]!=-INF) return memo[n][k];
    if(n<k) return memo[n][k]=0;
    if(n<0 || k<0) return memo[n][k]=0;
    if(k==0) return memo[n][k]=1;
    return memo[n][k]=pascal(n-1,k)+pascal(n-1,k-1);
}

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,P; cin>>N>>P;
    ll ans=0;
    ll odd=0,even=0;
    rep(i,N){
        ll tmp; cin>>tmp;
        if(tmp%2==0) even++;
        else odd++;
    }
    if(P%2==0){
        ll tmp=0;
        for(ll i=0;i<=odd;i+=2){
            tmp+=pascal(odd,i);
        }
        cout<<pw2[even]*tmp<<endl;
    }
    else{
        ll tmp=0;
        for(ll i=1;i<=odd;i+=2){
            tmp+=pascal(odd,i);
        }
        cout<<pw2[even]*tmp<<endl;
    }
}



Measured memory_bytes: 3608
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main()
{
    int n,in;
    vector<int> p;
    
    cin >> n;

    REP(i,n){
        cin >> in;
        p.push_back(in);
    }

    int cnt = 0;
    REP(i,n){
        if(p[i] == i+1){
            swap(p[i],p[i+1]);
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

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

    int n, d, x;
    cin >> n >> d >> x;

    int res = 0;
    rep(i, n){
        int a;
        cin >> a;
        res += 1 + d/a - (d%a==0);
    }
    
    cout << res+x << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const auto last=--cend(v);
  for(auto i=cbegin(v); i<last; ++i) os<<*i<<' ';
  os<<*last<<'\n';
  return os;
}
template<typename Itr>
auto merge(const Itr first, const Itr mid, const Itr last, const Itr result){
  auto ret=0u;
  auto out=result;
  for(auto in1=first,in2=mid; ; ++out,++ret){
    if(in1==mid){
      ret+=last-in2;
      for(; in2!=last; ++in2,++out) *out=*in2;
      break;
    }
    if(in2==last){
      ret+=mid-in1;
      for(; in1!=mid; ++in1,++out) *out=*in1;
      break;
    }
    if(*in1<*in2){
      *out=*in1;
      ++in1;
    } else{
      *out=*in2;
      ++in2;
    }
  }
  copy(result, out, first);
  return ret;
}
template<typename Itr>
size_t merge_sort(Itr first, Itr last, Itr result){
  if(last-first>1){
    auto mid=first+(last-first)/2;
    auto ret=0u;
    ret+=merge_sort(first, mid, result);
    ret+=merge_sort(mid, last, result);
    return ret+merge(first, mid, last, result);
  } else return 0u;
}
int32_t main(){
  size_t n; cin>>n;
  vector<uint32_t> s(n),t(n); for(auto&& e:s) cin>>e;
  const auto c=merge_sort(begin(s), end(s), begin(t));
  cout<<t<<c<<'\n';
}


Measured memory_bytes: 6704
import itertools
n = int(input())
p_list = list(map(int, input().split()))
q_list = list(map(int, input().split()))
p_list_perm_sorted = sorted(list(itertools.permutations(p_list)))
q_list_perm_sorted = sorted(itertools.permutations(q_list))
print(abs(p_list_perm_sorted.index(tuple(p_list)) - q_list_perm_sorted.index(tuple(q_list))))

Measured memory_bytes: 12856
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define ulli unsigned lli
#define ld long double
#define pb push_back
#define mp make_pair
#define bp pop_back
#define vi vector<int>
#define vvi vector< vector<int> >
#define vli vector<lli>
#define vvli vector< vector<lli> >
#define pii pair <int, int>
#define pli pair <lli, lli>
#define forn(i,n) for(i=0;i<n;i++)
#define rof(i,k,n) for(i=k;i>=n;i--)
#define wh(k) while(k--)
#define mod 1000000007
#define set(a,s) memset(a,s,sizeof(a))

int main()
{
    fast;
    lli n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2)
    	cout<<min(a,n-b+1)+(b-a-1)/2<<'\n';
    else
    	cout<<(b-a)/2<<'\n';
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

int main(void){
    int H,N; cin >> H >> N;
    int n = 0;
    REP(i,N){
        int a; cin >> a;
        n += a;
    }
    cout << (H>n ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

void sort(int a[],int n)
{
	int i = 0,j = n-1;
	int pivot = a[(i+j)/2];

	while(true)
	{
		while(a[i] > pivot)i++;
		while(a[j] < pivot)j--;

		if( i >= j )break;

		int hold = a[i];
		a[i] = a[j];
		a[j] = hold;

		i++;
		j--;
	}

	if( i > 1 )sort(a,i);
	if( n-j-1 > 1 )sort(a+j+1,n-j-1);
}

int main()
{
	int N;
	int *a;
	long ans = 0;

	cin >> N;
	a = new int[N*3];

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

	sort(a,N*3);

	for(int i=1;i<N*2;i+=2)
	{
		ans += a[i];
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll n, m;
  cin >> n >> m;

  vector<ll> a(n);
  vector<ll> b(m);

  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (ll i = 0; i < m; ++i) {
    cin >> b[i];
  }

  map<ll, ll> c;
  for (ll i = 0; i < n; ++i) {
    c[a[i]] = 1;
  }
  for (ll i = 0; i < m; ++i) {
    auto itr = c.find(b[i]);
    if (itr == c.end()) c[b[i]] = 1;
    else itr->second++;
  }

  vector<ll> ansa;
  vector<ll> ansb;
  for (auto itr = c.begin(); itr != c.end(); ++itr) {
    ansb.push_back(itr->first);
    if (itr->second == 2) {
      ansa.push_back(itr->first);
    }
  }
  sort(ansa.begin(), ansa.end());
  sort(ansb.begin(), ansb.end());

  cout << ansa.size() << " " << ansb.size() << endl;
  for (ll i = 0; i < ansa.size(); ++i) {
    cout << ansa[i] << endl;
  }
  for (ll i = 0; i < ansb.size(); ++i) {
    cout << ansb[i] << endl;
  }

  return 0;
}


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

#define mod 1000000007
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define deb(x) cout<<"\n"<<#x<<"="<<x<<"\n";
#define deb2(x,y) cout<<"\n"<<#x<<"="<<x<<"\n"<<#y<<"="<<y<<"\n";
#define ideb int _p_;cin>>_p_;
typedef long long int ll;
typedef unsigned long long int ull;
long long power(long long x,long long n){long long result=1;while(n>0){if(n % 2 ==1)result=(result * x);x=(x*x);n=n/2;}return result;}

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

for(int i=1;i<=9;i++)
{
    if(n%i==0 && n/i<=9)
    {
        cout<<"Yes";
        return 0;
    }
}
cout<<"No";
return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
was = []
tf = [False] * N
place = 1
cnt = 0

while tf[place-1] == False:
  if cnt < K:
    tf[place-1] = True
    was.append(place)
    place = A[place-1]
    cnt += 1
  else:
    print(place)
    break;
else:
  loop = cnt - was.index(place)
  num = (K-cnt) % loop + was.index(place)
  print(was[num])

Measured memory_bytes: 32376
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 1<<30;
typedef pair<int, int> P;

ll gcd(ll m, ll n) {
  if(m < n) swap(m, n);
  if(n == 0) return abs(m);
  else return gcd(n, m % n);
}

int main() {
  ll a, b; cin >> a >> b;
  ll x = gcd(a, b);
  ll ans = 0;
  for(int i = 2; i <= sqrt(x); i++) {
    if(x % i == 0) {
      while(x % i == 0) {
        x /= i;
      }
      ans++;
    }
  }
  if(x != 1) ans++;
  cout << ans + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]

ans = 0
for row in range(2 ** H - 1):
    for col in range(2 ** W - 1):
        count = 0
        for i in range(H):
            for j in range(W):
                if not ((row >> i) & 1) and not ((col >> j) & 1) and C[i][j] == '#':
                    count += 1
        if count == K:
            ans += 1

print(ans)

Measured memory_bytes: 9156
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

snake ('>':'\'':s) = snakeA 0 s
  where
    snakeA r ('=':ss) = snakeA (r+1) ss
    snakeA 0 ('#':ss) = Nothing
    snakeA r ('#':ss) = snakeA' r ss
    snakeA _ _ = Nothing
    snakeA' 0 "~" = Just "A"
    snakeA' r ('=':ss) = snakeA' (r-1) ss
    snakeA' _ _ = Nothing
snake ('>':'^':'Q':'=':s) = snakeB s
  where
    snakeB ('Q':'=':ss) = snakeB ss
    snakeB "~~" = Just "B"
    snakeB _ = Nothing
snake _ = Nothing



main = getInt >>= flip replicateM getLine >>= mapM_ (putStrLn . fromMaybe "NA" . snake)

Measured memory_bytes: 9172
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	char a=s[0],b=s[1],c=s[2],d=s[3];
	if((a==b && c==d) || (a==c && b==d) || (a==d && b==c) ){
		if(a==b && b==c && c==d && d==a){
			cout<<"No\n";
		}else{
			cout<<"Yes\n";
		}
	}else{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		
		// 計算
		String result = "NO";
		if(a <= x && x <= a+b) result = "YES";
		
		// 出力
		System.out.println(result);
		
	}
}




Measured memory_bytes: 21972
#include<set>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<iostream>
using namespace std;

typedef long long ll;
int mod=1e9+7;

ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
            ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    int ac;
    cin>>ac;
    cout<<ac*ac*ac;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	string S;
	cin >> S;
	int ans = 0;
	int len = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') {
			len++;
		}
		else {
			ans = max(ans, len);
			len = 0;
		}
	}
	ans = max(ans, len);
	cout << ans << endl;
}


Measured memory_bytes: 256
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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;
}

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, C;
  cin >> A >> B >> C;
  int sum = A + B + C;
  if (sum >= 22)
    out("bust");
  else
    out("win");
  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_int_tuple() -> (i32, i32) {
    let v: Vec<i32> = read_vec();
    (v[0], v[1])
}

fn main() {
    let (N, K) = read_int_tuple();
    let K = K as f64;
    let mut ans = 0.0;
    for i in 1..N+1 {
        let prob = 0.5_f64.powf(((K/i as f64).ln() / 2.0_f64.ln()).ceil());
        ans += if prob > 1.0 {1.0} else {prob};
    }
    println!("{}", ans / N as f64);
}


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

int main()
{
  int N;
  cin >> N;
  string S, T, a;
  cin >> S >> T;
  for (int i = 0; i < N; i++)
  {
    a += S.at(i);
    a += T.at(i);
  }
  cout << a << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int num[] = {a + b, a - b, a * b};
        Arrays.sort(num);
        System.out.println(num[2]);
        
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>
#define y1 y11
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define NAME ""

using namespace std;
	
typedef long long ll;
typedef long double ld;

const ld PI = acos(-1.0);

const int MAXN = 4001;

vector <int> e[MAXN];
int a[MAXN];

bool dfs(int v)
{
	for (int i = 0; i < e[v].size(); i++)
	{
		int u = e[v][i];
		if ((a[u] < a[v]) && (!dfs(u))) return true;
	}
	return false;
}

int main()
{
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);	
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i < n; i++)
	{
		int v1, v2;
		cin >> v1 >> v2;
		e[v1].push_back(v2);
		e[v2].push_back(v1);
	}
	for (int i = 1; i <= n; i++)
	{
		if (dfs(i)) cout << i << " ";
	}
	cout << endl;
	return 0;
}




Measured memory_bytes: 640
N = int(input())
res = 0
for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        res += i
print(res)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;

    reverse(ALL(s));

    vector<int> amari(2019,0);
    int now = 0, x = 1;
    ll ans = 0;
    amari[0]++;
    REP(i,SIZE(s))
    {
        int tmp = s[i] - '0';
        now = (now + tmp * x) % 2019;
        ans += amari[now];
        amari[now]++;
        x = 10*x%2019;
    }

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


Measured memory_bytes: 3668
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll INF=1e16;
int n, w;
ll p[110];
vector<P> g[110];
bool used[110];
int par[110];
void dfs0(int x){
    used[x]=1;
    for(auto pr:g[x]){
        int y=pr.first;
        if(used[y]) par[x]=y;
        else dfs0(y);
    }
}
ll ans;
void dfs(int x, vector<ll>& v){
    for(auto pr:g[x]){
        int y=pr.first, c=pr.second;
        if(y==par[x] || c>w) continue;
        vector<ll> vc(w+1, -INF);
        for(int i=0; i<w-c+1; i++) vc[i+c]=v[i];
        dfs(y, vc);
        for(int i=0; i<=w; i++) v[i]=max(v[i], vc[i]);
    }
    for(int i=0; i<=w; i++) v[i]+=p[x];
}
int main()
{
    cin>>n>>w;
    for(int i=0; i<n; i++) cin>>p[i];
    for(int i=0; i<n-1; i++){
        int u, v, c; cin>>u>>v>>c;
        u--; v--;
        g[u].push_back({v, c});
        g[v].push_back({u, c});
    }
    par[0]=-1;
    dfs0(0);
    for(int i=0; i<n; i++){
        vector<ll> v(w+1, -INF);
        v[0]=0;
        dfs(i, v);
        ans=max(ans, *max_element(v.begin(), v.end()));
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int a,b,c;
  string result;
  cin >> a >> b >> c;


  if(a<c && c<b){
    result = "Yes";
  }else if(b<c && c<a){
    result = "Yes";
  }else{
    result = "No";
  }

  cout << result << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N;
    cin >> N;

    if (N&1) {
        print(0);
        return 0;
    }

    ll c2, c5;

    ll b = 2;
    while(N / b != 0) {
        c2 += N / b;
        b <<= 1;
    }

    b = 5;
    while(N / b != 0) {
        c5 += N / b / 2;
        b *= 5;
    }
    
    print(min(c2, c5));

}


Measured memory_bytes: 3660
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
#define INF 1e18
#define PI 3.14159265359

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    ll n, w;
    cin >> n >> w;
    ll memo[100010];
    for (ll i = 0; i < 100010; i++) memo[i] = 1000000000000000000LL;
    memo[0] = 0;
    for (ll i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        for (ll j = 100000 - b; j >= 0; j--) {
            memo[j + b] = min(memo[j + b], memo[j] + a);
        }
    }
    for (ll i = 100010; i >= 0; i--) {
        if (memo[i] <= w) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
PII arr[MAXN];
int main(){
    //~ freopen("file.in", "r", stdin);
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
		scanf("%d%d",&arr[i].ff,&arr[i].ss);
	sort(arr,arr+m);
	int ans=0,mn=INF;
	for(int i=0;i<m;i++){
		umin(mn,arr[i].ss);
		if(arr[i].ff>=mn){
			ans++;
			mn=arr[i].ss;
		}
		else
			umin(mn,arr[i].ss);
	}	
	printf("%d\n",ans+1);
	return 0;
}


Measured memory_bytes: 1024
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto d=readln.split.to!(int[]);
  int m; rd(m);
  auto t=readln.split.to!(int[]);
  
  sort(d); sort(t);
  int j=0;
  foreach(e; t){
    while(j<n && d[j]<e) j++;
    if(j>=n){writeln("NO"); return;}
    if(d[j]>e){writeln("NO"); return;}
    j++;
  }

  writeln("YES");
}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long int 
#define mp make_pair
#define pb push_back
#define f first
#define s second



int32_t main()
{
     IOS; 
     
     int n,x;
     
     cin>>n>>x;
     
     int a;
     cin>>a;
     int ans=abs(a-x);
     
     for(int i=2;i<=n;i++)
     {
          int a;
          cin>>a;
          if(a==x)
               continue;
          if(ans==0)
               ans=abs(a-x);
          else     
          ans=__gcd(ans,abs(a-x));
     }
     cout<<ans;
     return 0;
}

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



int main() {
  int N, K, h, result;
  int i;
  scanf ("%d %d", &N, &K);
  
  result = 0;
  for (i=0;i<N;i++) {
      scanf ("%d", &h);
      if (h>=K) result++;
  }
  
  
  printf("%d", result);
  return 0;
}




Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <string.h>

#define REP(i, n) for (int i = 0; i < n; ++i)
#define INF 9999999999999999


#define ll long long

int n, c = 0;

void dfs(ll i,int t,int f,int s) {
	if (i > n) return;
	if (t && f && s) ++c; // three,five,seven are present
	dfs(i*10+3,t+1,f,s),
	dfs(i*10+5,t,f+1,s),
	dfs(i*10+7,t,f,s+1);
}

int main() {
	scanf("%d", &n);
	dfs(0,0,0,0),

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



Measured memory_bytes: 128