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

long long t,n,a,b,c,d,ans,dp[50000005],num[3]={2,3,5},co[3]={2,3,5},coeff[3]={15,9,6};
map<long long,long long> dp2;

void brute(){
	
	vector<pair<int,long long> > opz;
	
	opz.push_back({0,0});
	
	int cont=0;
	
	while(cont<opz.size()){
		//cout<<cont<<endl;
		
		pair<int,long long> curr=opz[cont];
		
		if(curr.first<0 || curr.first>50){
			cont++;
			continue;
		}
		
		if(dp[curr.first]==-1){
			
			dp[curr.first]=curr.second;
			
			if(curr.first<=15){
			opz.push_back({curr.first+1,curr.second+d});
			opz.push_back({curr.first-1,curr.second+d});
			opz.push_back({curr.first*2,curr.second+a});
			opz.push_back({curr.first*3,curr.second+b});
			opz.push_back({curr.first*5,curr.second+c});
			}
			else{
				opz.push_back({curr.first-1,curr.second+d});
			}
			
		}
		else{
		
			if(dp[curr.first]>curr.second){
				dp[curr.first]=curr.second;
				
				if(curr.first<=15){
					opz.push_back({curr.first+1,curr.second+d});
					opz.push_back({curr.first-1,curr.second+d});
					opz.push_back({curr.first*2,curr.second+a});
					opz.push_back({curr.first*3,curr.second+b});
					opz.push_back({curr.first*5,curr.second+c});
				}
				else{
					opz.push_back({curr.first-1,curr.second+d});
				}
			}
		}
		
		cont++;
	}
	
	for(int i=16;i<50;i++)dp[i]=-1;
}

long long f(long long x){
	
	
	//char fg;
	//cin>>fg;
	long long res=LLONG_MAX;
	
	if(x<=50000000){
		
		if(dp[x]!=-1)return dp[x];
		
		res=x*d;
		
		for(int i=0;i<3;i++){
			res=min({res,f((x-x%num[i])/num[i])+(x%num[i])*d+co[i],f((x+(num[i]-x%num[i]))/num[i])+(num[i]-x%num[i])*d+co[i]});
		}
		
		return dp[x]=res;
	}
	
	//cout<<x<<"ecco "<<endl;
	
	if(dp2[x]!=0)return dp2[x];
	
	long long tmp,ans=LLONG_MAX;
	
	for(int i=0;i<3;i++){
		
			//cout<<"divido "<<x<<" per "<<num[i]<<endl;
			if(x/num[i]<=1000000000)
			res=min(res,f((x-x%num[i])/num[i])+(x%num[i])*d+min(co[i],x/num[i]*(num[i]-1)*d));
			else
			res=min(res,f((x-x%num[i])/num[i])+(x%num[i])*d+min(co[i],co[i]));	
		
			if(x/num[i]<=1000000000)
			res=min(res,f((x+(num[i]-x%num[i]))/num[i])+(num[i]-x%num[i])*d+min(co[i],(x+(num[i]-x%num[i]))/num[i]*(num[i]-1)*d));
			else
			res=min(res,f((x+(num[i]-x%num[i]))/num[i])+(num[i]-x%num[i])*d+min(co[i],co[i]));
			//return res;
	}
		
	return dp2[x]=res;
}

int main(){

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

	cin>>t;
	
	while(t--){
		
		memset(dp,-1,sizeof(dp));
		dp2.clear();
		
		cin>>n>>a>>b>>c>>d;
		
		co[0]=a;
		co[1]=b;
		co[2]=c;
		brute();
		
		cout<<f(n)<<"\n";
	}

return 0;
}


Measured memory_bytes: 394604
n, k = map(int, input().split())
a = [int(n) for n in input().split()]
index = a.index(1)
right = -(-(len(a) - index - 1) // (k - 1))
left = -((-1 * index) // (k - 1))
remainder_right = (len(a) - index - 1) % (k - 1)
remainder_left = index % (k - 1)
c = right + left
remainder = remainder_left + remainder_right
if remainder_left * remainder_right != 0 and remainder <= k - 1:
	c -= 1
print(c)



Measured memory_bytes: 13880
function main()
	H,W,K=map(x->parse(Int,x),split(readline()))
	c=zeros(Int,H,W)
	for i=1:H
		j=0
		for d=chomp(readline())
			j+=1
			c[i,j]=Int(d)-48
		end
	end
	ans=10^9
	for z=0:2^H-1
		t=z
		sz=1
		for j=2:H
			sz+=t%2
			t>>=1
		end
		d=zeros(Int,sz,W)
		szi=1
		t=z
		for j=1:H
			d[szi,:]+=c[j,:]
			if t%2==1
				szi+=1
			end
			t>>=1
		end
		if any(x->any(x->x>K,x),d)
			continue
		end
		now=sz-1
		x=zeros(Int,sz)
		for j=1:W
			x+=d[:,j]
			if any(x->x>K,x)
				now+=1
				x=d[:,j]
			end
		end
		ans=min(ans,now)
	end
	println(ans)
end
main()

Measured memory_bytes: 158476
#include<bits/stdc++.h>
#define maxn 605
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
#define LL long long
using namespace std;

int n;
int mod;
int f[2][maxn];
int up[maxn],dn[maxn],d[maxn],c[maxn];
bool cmp(const int &u,const int &v){ return d[u] < d[v]; }

int main(){
	scanf("%d%d",&n,&mod);
	rep(i,0,2*n-1) up[i] = min((int)floor(sqrt(4 * n * n - i * i)),2*n-1) , dn[i] = (i <= n ? (int)ceil(sqrt(n * n - i * i)) : 0);
	rep(i,0,n-1) d[i] = dn[i] - 1;
	rep(i,n,2*n-1) d[i] = up[i];
	rep(i,0,2*n-1) c[i] = 2*n-i-1;
	stable_sort(c,c+2*n,cmp);int ans =0 ;
	rep(k,0,n){
		memset(f,0,sizeof f);
		int now = 1, pre = 0 , cntr = 0;
		f[now][0] = 1;
		rep(i,0,2*n-1){
			int u = c[i];
			swap(now,pre);
			rep(j,0,k) if(f[pre][j]){
				if(u >= n){	
					f[now][j] = (f[now][j] + 1ll * f[pre][j] * max(up[u] + 1 - i + (cntr - j), 0)) % mod;
				}
				else{
					f[now][j] = (f[now][j] + 1ll * f[pre][j] * max(up[u] + 1 - n - (k-j) - cntr , 0)) % mod;
					if(j < k) f[now][j+1] = (f[now][j+1] + 1ll * f[pre][j] * max(dn[u] - i + (cntr - j) , 0)) % mod;
				}
				f[pre][j] = 0;
			}
			if(u < n) cntr ++;
		}
		ans = (ans + (k&1?-1ll:1ll) * f[now][k]) % mod;
	}
	printf("%d\n",(ans+mod)%mod);
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
using namespace std;
 
 ll mod=1e9 +7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=200006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();
    // Sieve();
    
   ll tests=1;
  // cin>>tests;
    while(tests--)
    {
      ll k,a,b;
      cin>>k>>a>>b;
      if(a%k==0 || b%k==0 || a/k !=b/k) cout<<"OK";
      else cout<<"NG";
    }
    return 0;
   }

Measured memory_bytes: 14128
# coding: utf-8
import copy
import numpy as np

n, k = map(int, input().split())
v = list(map(int, input().split()))
rev = copy.copy(v)
rev.reverse()

lcs = [0]+np.cumsum(v)
rcs = [0]+np.cumsum(rev)
# print(lcs,rcs)

ans = -10**20
for l in range(n+1):
  for r in range(n+1-l):
    able = True
    d = k - ( l + r )
    if d < 0:
      able = False
      break
    # m = lcs[l] + rcs[r]
    t = v[0:l] + rev[0:r]
    m = sum(t)
    # print(t,l,r,m)
    t.sort()
    # print(t)
    d = min(d,l+r)
    for i in range(d):
      if 0 > t[i]:
        m -= t[i]
      else:
        break
    # print(m)
    ans = max(ans,m)

print(ans)
    

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

int main(){
  int N;
  cin >> N;
  vector<int> value(N);
  for(int i = 0; i < N; i++){
    cin >> value.at(i);
  }
  sort(value.begin(), value.end());
  
  double answer;
  for(int i = 0; i < N-1; i++){
    if(i == 0){
      answer = (value.at(0) + value.at(1))/2.0;
    }else{
      answer = (answer + value.at(i+1))/2.0;
    }
  }
  
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    multimap<ll, ll> work;

    int a, b;

    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;

        work.insert(P(b, a));
    }

    ll time = 0;

    for (auto x : work)
    {
        time += x.second;

        if (time > x.first)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

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

int main(){

	int* data;
	int* data_list;
	int n;
	int i;
	int tmp;
	int flag = 0;
	int sum = 1;

	scanf("%d",&n);
	data = (int*)calloc(n,sizeof(int));
	data_list = (int*)calloc(n,sizeof(int));

	for(i=0; i<n; i++){
		scanf("%d",data+i);
	}

	for(i=0; i<n; i++){
		tmp = data[i];
		data_list[tmp]++;
	}

	if( n%2 == 1 && data_list[0] != 1 ) flag = 1;

	if( flag == 0 ){
		if( n%2 == 1 ){
			i = 1;
		}else{
			i = 0;
		}
		while( i < n && flag == 0 ){
			if( data_list[i+1] != 2 ) flag = 1;
			i += 2;
		}
	}

	if( flag == 1 ){
		printf("0\n");
	}else{
		for(i=0; i<n/2; i++){
			sum *= 2;
			sum %= 1000000007;
		}
		printf("%d\n",sum);
	}

	return 0;
}

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


typedef long long LL;

const LL BASE = 1000000007;


LL pow2(LL M) {
	if (M == 0) return 1LL;

	LL a = M / 2;
	LL b = pow2(a);
	b = (b * b) % BASE;
	if (M % 2) b = (b * 2) % BASE;

	return b;
}


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

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

	sort(C.begin(), C.end());

	LL ans = 0;
	for (int i = 0; i < N; ++i) {
		LL cost = (C[i] * (N - i + 1)) % BASE;
		ans = (ans + cost) % BASE;
	}

	ans = (ans * pow2(2 * N - 2)) % BASE;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4368
function Main(input){
  var inputs = input.split("\n");
  var N = inputs[0].split(" ")[0];
  var D = inputs[0].split(" ")[1];
  var a = [];
  for(i=1;i<=N;i++){
    a[i-1] = inputs[i].split(" ");
  }
  var n = 0;
  for(j=0;j<=(N-1);j++){
    for(l=0;l<=(N-1);l++){
      var b=0;
      var k=0;
      var s;
      if(j<=l){
        continue;
      }
      for(m=0;m<=(D-1);m++){
        b = a[j][m] - a[l][m];
        k += Math.pow(b,2);
      }
      s = Number.isInteger(Math.pow(k,1/2));
      if(s==true){
        n += 1;
      }
    }
  }
  console.log(n);
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include "bits/stdc++.h"

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main() {
  int a;
  cin >> a;
  int cnt = 0;
  if (a == 4) {
    cout << 4;
    return 0;
  }
  if (a == 2) {
    cout << 4;
    return 0;
  }
  if (a == 1) {
    cout << 4;
    return 0;
  }
  while (a != 4) {
    if (a % 2 == 0) {
      a /= 2;
    } else {
      a*=3;
      a++;
    }
    cnt++;
  }
  cout << cnt+4;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
    //ここにパーテーションがくる
  } while (next_permutation(s.begin(), s.end()));

*/


Measured memory_bytes: 256
import heapq
import sys
hq = []
while True:
    a = sys.stdin.readline().split()
    if a[0] == 'end':
        break
    if a[0] == 'insert':
        heapq.heappush(hq, -int(a[1]))
    if a[0] == 'extract':
        print(-heapq.heappop(hq))
    
    
    


Measured memory_bytes: 45564
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int n;  cin >> n;
	V a(n + 1);
	for(int i = 1 ; i <= n ; i++)  cin >> a[i];

	V b;  b.push_back(-1);
  	int to, from;
  	if(n % 2)
      to = 1, from = 2;
  	else
      to = 2, from = 1;
  
	for(int i = n ; to <= i ; i -= 2)      b.push_back(a[i]);
	for(int i = from ; i <= n ; i += 2)  b.push_back(a[i]);

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

	return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main(){
	int S;
	cin >> S;
	int front, back;
	front = S/100;
	back = S - front*100;
	string SS;

	bool f = false, b = false;
	if(front <= 12 && 0 < front)
		f = true;
	if(back <= 12 && 0 < back)
		b = true;

	if(f && b)
		SS = "AMBIGUOUS";
	else if(f)
		SS = "MMYY";
	else if(b)
		SS = "YYMM";
	else
		SS = "NA";
	cout << SS << endl;
}

Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
p1=a*x+b*y
min=10**9
for i in range(10**5+1):
    p2=2*i*c+max(0,x-i)*a+max(0,y-i)*b
    if p2<min:
        min=p2
if min<p1:
    print(min)
else:
    print(p1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,q;
    cin>>n>>k>>q;
    ll a;
    /*ll score[n],ans[n];
    for(int i=0;i<n;i++){
        score[i]=0;
    }*/
    ll ans[n];
    for(int i=0;i<n;i++){
        ans[i]=k-q;
    }
    for(int i=0;i<q;i++){
        cin>>a;
        a--;
        ans[a]++;
    }
    for(int i=0;i<n;i++){
        if(ans[i]>0){
            cout<< "Yes"<<endl;
        }
        else{
            cout <<"No"<<endl;
        }
    }


    return 0;
}



Measured memory_bytes: 1408
#include<stdio.h>
int prev[200007]={},next[200007]={};
int main()
{
	int N,M,Q,i,a,r,p=0,j;
	scanf("%d %d %d",&N,&M,&Q);
	for(i=0;i<N;i++){
		prev[i]=(i+N-1)%N;
		next[i]=(i+1)%N;
	}
	for(i=0;i<M;i++){
		scanf("%d",&a);
		
		for ( j = 0; j < a; j++)p=a%2?prev[p]:next[p];
		next[prev[p]]=next[p],prev[next[p]]=prev[p];
		
		r=next[p];
		next[p]=-1;
		prev[p]=-1;
		p=r;
		
	}
	for(i=0;i<Q;i++){
		scanf("%d",&a);
		puts(prev[a] != -1 ? "1" : "0");
	}
	return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    string s; cin >> s;
    if(s=="ABC") out("ARC");
    else out("ABC");
}


Measured memory_bytes: 3620
#include <stdio.h>
int main(){
    int N;
    scanf("%d",&N);
    int a[101],b[101];
    int Alise,Bob,score,i,j,max,max_num;
    for(i = 0; i < N;i++){
        if(scanf("%d",&a[i]) == 1){
        }
    }

    for(j =0;j<N;j++){
        for(i=0;i<N-j;i++){
            if(max <= a[i]){
                max = a[i];
                max_num = i;
            }
        }
        b[j] = max;
        a[max_num] = a[N-j-1];
        max_num = 0;
        max = a[0];
    }
    Alise = 0;
    Bob = 0;
    for(j=0;j<N;j++){
        if(j%2 == 0){
            Alise = Alise + b[j];
        }else{
            Bob = Bob + b[j];
        }
    }
  
    score = Alise - Bob;
    printf("%d\n",score);
    return 0;
}



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

int main(){
    double a, b, x;
    cin>>a>>b>>x;
    if(x<=a*a*b/2){
        x = 2*x/(a*b);
        x = sqrt(x*x+b*b);
        cout<<setprecision(10)<<asin(b/x) * 180.0/M_PI;
    }
    else{
        cout<<setprecision(10)<<atan((2*a*a*b-2*x)/a/a/a)*180.0/M_PI;
    }
    return 0;
}

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x * y / GCD(x, y);
}


int main() {
	int n; cin >> n;
	vector<ll> a(n+1), b(n);
	rep(i, n+1)  cin >> a[i];
	rep(i, n) cin >> b[i];

	ll res = 0;
	rep(i, n) {
		ll tmp = min(a[i], b[i]);
		a[i] -= tmp;
		b[i] -= tmp;
		res += tmp;
		tmp = min(b[i], a[i+1]);
		a[i+1] -= tmp;
		res += tmp;
	}
	cout << res << endl;
}


Measured memory_bytes: 1792
def main():
    a, b, c = map(int, input().split())
    l = sorted([a, b, c])
    i, j, k = l[0], l[1], l[2]
    if k % 2 == 0:
        print(0)
    else:
        print(i * j)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main() {
  int n; cin >> n;
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    mp[s]++;
  }
  vector<pair<int, string>> v;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    v.push_back(make_pair(it->second, it->first));
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());

  int cnt = v[0].first;
  vector<string> ans;
  for (int i = 0; i < v.size(); i++) {
    if (v[i].first == cnt) {
      ans.push_back(v[i].second);
    }
  }
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 33516
#!/usr/bin/env python3
import sys

from functools import reduce

import math


from collections import defaultdict
from math import sqrt

def is_prime(n):
    for i in range(2, int(sqrt(n))):
        if n % i == 0:
            return False
    return True

def prime_factors(n):
    primes = defaultdict(int)
    i = 2
    mx = sqrt(n)
    while n != 1:
        if n % i == 0:
            n = n // i
            primes[i] += 1
        elif i >= mx:
            if is_prime(n):
                primes[i] += 1
            break
        else:
            i += 1
    return primes

def solve_n(x):
    return (-1 + sqrt(1 + 4 * 2* x)) / 2

def solve(N: int):
    fs = prime_factors(N)
    count = 0
    for key, value in fs.items():
        val = solve_n(value)
        count += math.floor(val)

    print(count)
    return



# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define LL long long
using namespace std;

string a,b;
const int maxn = 200005;
int xmin[maxn];
int xmax[maxn];
int ymin[maxn];
int ymax[maxn];

int main()
{
    int H,W,N;
    int sr,sc;
    scanf("%d %d %d",&H,&W,&N);
    scanf("%d %d",&sr,&sc);
    cin >> a >> b;

    xmax[N] = W;ymax[N] = H;
    xmin[N] = 1;ymin[N] = 1;

    int ok = 1;
    for(int i = N-1;i >= 0;i--){
        xmax[i] = xmax[i+1];
        xmin[i] = xmin[i+1];
        ymax[i] = ymax[i+1];
        ymin[i] = ymin[i+1];

        char ch1 = b[i];
        if(ch1 == 'R')  xmin[i]--;
        else if(ch1 == 'L') xmax[i]++;
        else if(ch1 == 'D') ymin[i]--;
        else  ymax[i]++;

        xmax[i] = min(W,xmax[i]);
        ymax[i] = min(H,ymax[i]);
        xmin[i] = max(1,xmin[i]);
        ymin[i] = max(1,ymin[i]);
        if(xmax[i] < xmin[i] || ymax[i] < ymin[i]) ok = 0;

        //printf("%d %d %d %d\n",xmin[i],xmax[i],ymin[i],ymax[i]);


        char ch2 = a[i];
        if(ch2 == 'R') xmax[i]--;
        else if(ch2 == 'L') xmin[i]++;
        else if(ch2 == 'D') ymax[i]--;
        else ymin[i]++;
        //printf("%d %d %d %d\n",xmin[i],xmax[i],ymin[i],ymax[i]);
        if(xmax[i] < xmin[i] || ymax[i] < ymin[i]) ok = 0;
    }


    if(sr < ymin[0] || sr > ymax[0])ok = 0;
    if(sc < xmin[0] || sc > xmax[0])ok = 0;

    if(ok) printf("YES\n");
    else printf("NO\n");
    return 0;
}


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

int main() 
{
    string s;
    cin>>s;
    int ans=0;
    int temp=0;
    if(s[0]=='R')
    {
        temp++;
        ans=max(ans,temp);
    }
    for(int i=1;i<3;i++)
    {
        if(s[i]=='S')
        {
            temp=0;
        }
        else
        {
            temp++;
            ans=max(ans,temp);
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
import itertools
N = int(input())
P = tuple(input().split())
Q = tuple(input().split())
p = list(itertools.permutations(P))
q = list(itertools.permutations(Q))
p.sort()
q.sort()
for i in range(len(p)):
    if p[i]==P:
        break
for j in range(len(q)):
    if q[j]==Q:
        break
print(abs(i-j))

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

ll gcd(ll a,ll b){
  while(a*b!=0){
    if(a>b){
      a=a%b;
    }else{
      b=b%a;
    }
  }
  return a+b;
}

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll l=c/gcd(c,d)*d;
  ll s=l-l/c-l/d+1;
  ll ta=((a-1)%l)-((a-1)%l)/c-((a-1)%l)/d;
  ll tb=(b%l)-(b%l)/c-(b%l)/d;
  cout << (b/l)*s+tb-((a-1)/l)*s-ta << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#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 show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n,cnt[maxn],q;

int main()
{
    fastio();
    cin>>n;
    ll tot = 0; int x;
    rep(i,1,n) {cin>>x;cnt[x]++;tot+=x;}
    cin>>q;
    while(q--){
        int b,c;
        cin>>b>>c;
        tot += (ll)cnt[b]*(c-b);
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout<<tot<<endl;
    }
    return 0;
}


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

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

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize,mut w: [usize; n]);

    let mut vec_f = Vec::new();
    let mut vec_b = Vec::new();

    vec_f.push(w[0]);
    for i in 0..n - 1 {
        vec_f.push(vec_f[i] + w[i + 1]);
    }

    vec_b.push(w[n - 1]);
    for i in 0..n - 1 {
        vec_b.push(vec_b[i] + w[n - i - 1 - 1]);
    }

    let mut min: usize = 1000000000usize;
    for i in 0..n - 1 {
        min = ch_min(
            min,
            (vec_f[i] as isize - vec_b[n - 2 - i] as isize).abs() as usize,
        );
    }

    println!("{}", min);
}
fn ch_min(a: usize, b: usize) -> usize {
    return if a < b { a } else { b };
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N, M;
  cin >> N >> M;
  vector <int> A(M);
  rep(i,M) cin >> A.at(i);

  int sum = accumulate(all(A), 0);
  int ans = max(-1, N - sum);
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main() {
   int n,a,b; 
   cin>>n>>a>>b;
   ll ans=0;
   rep(i,1,n+1){
      int sum=0;
      int t=i;
      while(t){
         sum+=t%10;
         t/=10;
      }
      if(sum>=a&&sum<=b) ans+=i;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans;
    int n;
    cin>>n;
    map<string,int>mp;
    for (int i = 0; i < n; ++i) {
        string s;
        cin>>s;
        mp[s] ++;
    }
    ans = mp.size();
    cout<<ans<<endl;
    return 0;
}

//
// Created on 2020/04/26.
//



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

int main()
{
  int64_t n,w;
  cin>>n>>w;
  
  vector<int64_t> weight(n);
  vector<int64_t> value(n);
  
  for(int i=0;i<n;i++)
    cin>>weight[i]>>value[i];
  
  vector<vector<int64_t>> value_sum(n,vector<int64_t>(w+1,0));
  int64_t result=0;
  
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<=w;j++)
    {
      if(i==0)
      {
        if(weight[i]>j)
          value_sum[i][j]=0;
        else
          value_sum[i][j]=value[i];
      }
      else
      {
        if(weight[i]>j)
        {
          value_sum[i][j]=value_sum[i-1][j];
        }
        else
        {
          value_sum[i][j]=max(value_sum[i-1][j-weight[i]]+value[i],value_sum[i-1][j]);
        }
      }
      result=max(result,value_sum[i][j]); 
    }
  }
  //for(int i=0;i<n;i++)
  //{
    //for(int j=0;j<=w;j++)
    //{
      //cout<<value_sum[i][j]<<" ";
      //if(j==w)
        //cout<<endl;
    //}
  //}
  
  cout<<value_sum[n-1][w]<<endl;
}
        
  

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int>data(m*2);
  for(int i = 0;i < m*2;i++){
    cin >> data.at(i);
  }
  for(int i = 1;i <= n;i++){
    int c = 0;
    for(int j = 0;j < data.size();j++){
      if(i == data.at(j)){
        c++;
      }
    }
    cout << c << endl;
  }
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s;
	std::cin >> s;
	std::string t = "";
	int normal = true;
	int q;
	std::cin >> q;
	rep(qq,q) {
		int qx;
		std::cin >> qx;
		if(qx==1) {
			normal^=1;
		} else {
			int qy;
			std::cin >> qy;
			qy--;
			char c;
			std::cin >> c;
			if(qy^normal) {
				t+=c;
			} else {
				s+=c;
			}
		}
	}
	if(normal) {
		rep(i,t.size()) std::cout << t[t.size()-i-1];
		std::cout << s << ENDL;
	} else {
		rep(i,s.size()) std::cout << s[s.size()-i-1];
		std::cout << t << ENDL;
	}

	return 0;
}


Measured memory_bytes: 960
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    map<ll, ll> mp;
    ll res = 0;
    mp[0]++;
    vector<ll> sum(n + 1);
    for (ll i = 0; i < n; i++) {
        ll a;
        cin >> a;
        sum[i + 1] = sum[i] + a;
        sum[i + 1] %= k;
        if (i + 1 >= k) {
            mp[(sum[(i + 1) - k] - (i + 1) % k + k) % k]--;
        }
        res += mp[(sum[i + 1] - (i + 1) % k + k) % k];
        mp[(sum[i + 1] - (i + 1) % k + k) % k]++;
    }
    cout << res << endl;
}

Measured memory_bytes: 14336
while s = gets
  (h,w)=s.split(/ /).map(&:to_i)

  break if h+w==0

  (f,g,x,y)=[[],[],0,0]
  h.times{ f.push(gets.chomp.split(//)) }

  loop do
    if f[y][x] == "."
      puts "#{x} #{y}"
      break
    end

    if g.include?([x,y])
      puts "LOOP"
      break
    end

    g.push([x,y])
    case f[y][x]
    when ">" then x+=1
    when "<" then x-=1
    when "v" then y+=1
    when "^" then y-=1
    end
  end
end

Measured memory_bytes: 8920
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;

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

    string s;
    cin >> s;

    int left_w = 0, right_r = n-1;
    int count = 0;

    while(true){
        if(left_w >= n) break;
        if(right_r < 0) break;
        if(left_w >= right_r)break;

        if((s[left_w] == 'W') && (s[right_r] == 'R')){
            s[right_r] = 'W';
            s[left_w] = 'R';
            left_w++;
            right_r--;
            count++;
        }else if(s[left_w] == 'W'){
            right_r--;
        }else{
            left_w++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int V, E;
int G[20][20];
int dp[1<<15][20];


signed main(){
    cin >> V >> E;
    rep(i, 0, V) rep(j, 0, V) G[i][j] = INF;
    rep(i, 0, E){
        int s, t, d;
        cin >> s >> t >> d;
        G[s][t] = d;
    }

    rep(i, 0, 1<<V) rep(j, 0, V) dp[i][j] = INF;
    dp[1][0] = 0;
    rep(i, 0, 1<<V) rep(j, 0, V){
        if(dp[i][j] == INF) continue;
        rep(k, 0, V) if(((i>>k)&1) == 0 and G[j][k] != INF) chmin(dp[i|(1<<k)][k], dp[i][j]+G[j][k]);
    }
    int ans = INF;
    rep(i, 1, V) if(G[i][0] != INF and dp[(1<<V)-1][i] != INF) chmin(ans, dp[(1<<V)-1][i]+G[i][0]);
    if(ans == INF) ans = -1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8212
/**
    @Author Monk78
    @Topic F:LCS
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second;
#define F first;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end));i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000009
#define MAX 100005
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define rf(i,a,b) for(int i=(a);i>=b;i--)
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
#define vpshVar() int main()

vpshVar(){
    string str1,str2;;
    cin>>str1>>str2;
    ll n1=str1.length();
    ll n2=str2.length();
    ll dp[n1+1][n2+1];
    for(ll i=0;i<=n1;i++){
     for(ll j=0;j<=n2;j++){
        if(i==0 || j==0)dp[i][j]=0;
        else{
            if(str1[i-1]==str2[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
     }
    }
    ll index=dp[n1][n2];
    char lcs[index+1];
    lcs[index]='\0';
    ll i=n1;
    ll j=n2;
    while(i>0 && j>0){
        if(str1[i-1]==str2[j-1]){
            lcs[index-1]=str1[i-1];
            index--;i--;j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }
        else{
            j--;
        }

    }
    cout<<lcs;

return 0;
}


Measured memory_bytes: 70656
fun main(args: Array<String>) {

    val mod = 1e9.toLong() + 7

    class Comb {

        val n = 1e5.toInt()

        val fact = LongArray(n + 1)
        val factInv = LongArray(n + 1)

        init {
            fact[1] = 1L
            for (i in 2 .. n) {
                fact[i] = fact[i - 1] * i % mod
            }
            factInv[n] = inv(fact[n])
            for (i in n downTo 1) {
                factInv[i - 1] = factInv[i] * i % mod
            }
        }

        private fun pow(base: Long, exp: Long): Long {
            if (exp == 0L) return 1L
            var a = pow(base, exp shr 1)
            a *= a
            a %= mod
            if (exp and 1L == 0L) return a
            return base * a % mod
        }

        private fun inv(x: Long): Long {
            return pow(x, mod - 2)
        }

        fun comb(n: Int, k: Int): Long {
            if (k !in 0..n) return 0L
            return fact[n] * factInv[k] % mod * factInv[n - k] % mod
        }

    }

    val cb = Comb()

    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    var a = readLine()!!.split(' ').map { it.toLong() }.sorted()

    val ans = LongArray(2)

    repeat(2) {
        for (i in 0 until n) {
            if (i + 1 < k) continue
            if (a[i] >= 0) {
                val b = a[i] * cb.comb(i, k - 1) % mod
                ans[it] = ans[it] + b % mod
            } else {
                val b = -a[i] * cb.comb(i, k - 1) % mod
                ans[it] = (ans[it] + mod - b) % mod
            }
        }
        a = a.reversed()
    }

    println((ans[0] + mod - ans[1]) % mod)
}


Measured memory_bytes: 76976
def main():
    n = int(input())
    k = int((2 * n) ** 0.5) - 1
    while k * (k + 1) // 2 < n:
        k += 1
    s = k * (k + 1) // 2 - n
    [print(i) for i in range(1, k + 1) if i != s]

if __name__ == '__main__':
    main()


Measured memory_bytes: 9412
#include<iostream>
#include<algorithm>
#include<vector>
int main() {
	std::vector<int> on ,tw ,th;
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		std::cin >> a >> b >> c;
		on.emplace_back(a);
		tw.emplace_back(b);
		th.emplace_back(c);
	}
	for (int i = 0; i < n; i++) {
		int x[3];
		x[0] = on[i];
		x[1] = tw[i];
		x[2] = th[i];
		std::sort(x, x + 3);
		if (x[0]* x[0] + x[1] * x[1] == x[2] * x[2]) {
			std::cout << "YES" << std::endl;
		}
		else {
			std::cout << "NO" << std::endl;
		}
	}
}

Measured memory_bytes: 2964
count = int(input())
num_list = list(map(int,input().split()))

#count  = 3
#num_list =[8,12,40]

output = 0
stop_flag = 0

while 1:
    for num in num_list:
        if((num % 2) == 1 ):
            stop_flag = 1
    if stop_flag == 0:
        output += 1
    
    num_list = list(map(lambda x: x/2,num_list))

    if stop_flag == 1:
        break
    
print(output)

Measured memory_bytes: 9156
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    vector< map<char,int> > p(n);
    rep(i,0,n)
    {
        string s;
        cin>>s;

        rep(j,0,s.length())
        {
            p[i][s[j]]++;
        }
    }
    // rep(i,0,p.size())
    // {
    //     fori(it,p[i])
    //     {
    //         out2(it->ft,it->sd);
    //     }
    // }
    map<map<char,int>,int> ans;
    int cnt = 0;
    rep(i,0,p.size())
    {
        ans[p[i]]++;
    }

    fori(it,ans)
    {
        cnt += it->sd*(it->sd-1)/2;
    }

    cout<<cnt<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 119808
n = int(input())
a = list(map(int,input().split()))
s1 = 0
s2 = 0
cnt1 = 0
cnt2 = 0
for i in range(n):
    s1 += a[i]
    s2 += a[i]
    if i % 2 == 0:
        if s1 <= 0:
            cnt1 += abs(s1) + 1
            s1 += abs(s1) + 1
        if s2 >= 0:
            cnt2 += s2 + 1
            s2 -= s2 + 1
    else:
        if s1 >= 0:
            cnt1 += s1 + 1
            s1 -= s1 + 1
        if s2 <= 0:
            cnt2 += abs(s2) + 1
            s2 += abs(s2) + 1
print(min(cnt1,cnt2))

Measured memory_bytes: 14332
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define all(aaa) (aaa).begin(),(aaa).end()
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
long long,
null_type,
less<long long>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
std::vector<std::vector<long long>> g;
std::vector<long long> dp,black;
std::vector<bool> vis;
long long dfs(long long node)
{
	if(vis[node]){return dp[node];}
	vis[node]=1;
	long long ans=1,ans2=1;
	for(auto it:g[node])
	{
		if(!vis[it])
		{
			dfs(it);
			ans=((ans*dp[it])%N);
			ans2=((ans2*(dp[it]-black[it]))%N);
		}
	}
	ans=(((ans%N)+N)%N);ans2=(((ans2%N)+N)%N);
	black[node]=ans2;dp[node]=(ans+ans2)%N;
	return dp[node];
}
long long solve()
{
	long long n;cin>>n;
	g.resize(n);
	dp.resize(n,0);
	black.resize(n,0);
	vis.resize(n,0);
	REP(i,0,n-2)
	{
		long long a,b;cin>>a>>b;--a;--b;
		g[a].pb(b);g[b].pb(a);
	}
	cout<<dfs(0)<<"\n";
}
signed main(){
	long long tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 14208
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <math.h>

int main(int argc, char *argv)
{
    int a, b, c;
    int ans;

    scanf("%d %d %d", &a, &b, &c);

    if (a == b && b == c) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int n, m, p, an, bn, ans;
int x[100000];
int y[100000];
int a[100000];
int b[100000];
long long eans[100000];
int root(int c) {
	int t = 0;
	while (x[c] >= 0) {
		y[t] = c;
		c = x[c];
		t++;
	}
	for (int i = 0; i < t - 1; i++) {
		x[y[i]] = c;
	}
	return c;
}
void merge(int c, int d) {
	if (c == d)return;
	if (x[c] < x[d]) {
		x[c] += x[d];
		x[d] = c;
	}
	else if (x[c] == x[d]) {
		x[c] += x[d];
		x[d] = c;
	}
	else{
		x[d] += x[c];
		x[c] = d;
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d", a + i, b + i, &p);
		a[i]--, b[i]--;
	}
	for (int i = 0; i < n; i++)x[i] = -1;
	ans = n;
	for (int i = 0; i < m; i++) {
		an = root(a[i]);
		bn = root(b[i]);
		if (an != bn) {
			ans--;
			merge(an, bn);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1280
#include <cstdio>
int main() {
	int n;
	while(scanf("%d",&n),n) {
		for(int k=0;k<n;k++) {
			int x[3]={0},y[3]={0},z[3]={0},w[3]={0};
			for(int i=0;i<2;i++) {
				scanf("%d %d %d %d",&x[i],&y[i],&z[i],&w[i]);
			}
			x[2]=x[0]*x[1]-y[0]*y[1]-z[0]*z[1]-w[0]*w[1];
			y[2]=x[0]*y[1]+y[0]*x[1]+z[0]*w[1]-w[0]*z[1];
			z[2]=x[0]*z[1]+z[0]*x[1]+w[0]*y[1]-y[0]*w[1];
			w[2]=w[0]*x[1]+y[0]*z[1]+x[0]*w[1]-z[0]*y[1];
			printf("%d %d %d %d\n",x[2],y[2],z[2],w[2]);
		}
	}
}

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

int dir[4][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} };

int dist (int s, int t, int h, int w, vector<string> &map)
{
  queue< pair<int, pair<int, int>> > q;
  q.push( make_pair(0, make_pair(s, t)) );
  
  int maxm = 0;
  vector<vector<int>> dist(h, vector<int>(w, INT_MAX));
  dist[s][t] = 0;
  while (!q.empty())
  {
    pair<int, pair<int, int>> p = q.front(); q.pop();
    int nextm = p.first + 1;
    for (int i = 0; i < 4; ++i)
    {
      int u = p.second.first + dir[i][0], v = p.second.second + dir[i][1];
      if (u < 0 || u >= h || v < 0 || v >= w) continue;
      
      if (map[u][v] == '.' && nextm < dist[u][v])
      {
        dist[u][v] = nextm;
        q.push( make_pair(nextm, make_pair(u, v)) );
        maxm = max(maxm, nextm);
      }
    } 
  }
  
  return maxm;
}

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> map(h);
  for (int i = 0; i < h; ++i)
    cin >> map[i];
  
  int maxd = 0;
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      if (map[i][j] == '.')
        maxd = max(maxd, dist(i, j, h, w, map));
  
  cout << maxd << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <cstdio>

using namespace std;
#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(cin>>n,n!=-1){
        complex<double> p(1,0);
        rep(i,n-1) p+=p*complex<double>(0,1)/abs(p);
        printf("%.4f\n%.4f\n",p.real(),p.imag());
    }
}

Measured memory_bytes: 1192
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

static size_t A[100000];

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) > *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

int main(void) {
	size_t N;
	size_t a[100];

	scanf("%zu\n", &N);
	for (size_t idx = 0; idx < N; idx++) {
		scanf("%zu", &a[idx]);
		if (idx < N - 1) {
			scanf(" ");
		}
	}

	qsort(a, N, sizeof(size_t), compare_f);

	size_t aliceP = 0;
	size_t bobP = 0;
	for (size_t idx = 0; idx < N; idx++) {
		if (idx % 2 == 0) {
			aliceP += a[idx];
		}
		else {
			bobP += a[idx];
		}
	}

	printf("%zu\n", aliceP - bobP);

	return 0;
}


Measured memory_bytes: 128