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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  rep(j,s.size()-1){
    if(s[j] == s[j+1]){
      cout << j+1 << ' ' << j+2 << endl;
      return 0;
    }
    else if(s[j] == s[j+2]){
      cout << j+1 << ' ' << j+3 << endl;
      return 0;
    }
  }
  cout << -1 << ' '  << -1 << endl;
  return 0;
}



Measured memory_bytes: 512
#include <iostream>

using namespace std;

#define rep(i,n) for(int i=0; i<(int)(n); i++)

int d[10];

int ok(int r) {
	for(int i=r; i; i/=10) if(d[i%10]) return false;
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, k;
	cin >> n >> k;
	rep(i,k) {
		int e;
		cin >> e;
		d[e]++;
	}

	int r = n;
	for(;! ok(r); r++);	
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 384
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

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

   int flag = 0;
  
   if(n[0]!='A'){
     
     //cout << "WA" << endl;
     
      flag = 1;
     
   }else{
     
     int cou = 0;
     
     for(int i = 2;i < n.size()-1;i++){
     
          if(n[i]=='C'){
            
            cou++;
            
          }
       

     }
     
     if(cou!=1){
        flag = 1;
     }
     
     
     
     for(int i = 0;i < 2;i++){
     
          if(n[i]=='C'){
            
            flag=1;
          }
       
     }
     
    
     
          if(n[n.size()]=='C'){
            
            flag=1;
            
          }
       
     
     
   }
   
  if(flag==1){
    
    
    cout << "WA"<< endl;
    
    
  }else{
    
    
  
    
     for(int i = 0;i < n.size();i++){
       
       if(n[i]=='A'||n[i]=='C'){
         
       }else{
         
          if(isupper(n[i])) { 
            
            flag = 1;
          }
         
       }
       
     }
    
    if(flag==1){
      cout << "WA"<< endl;
    }else{
    cout << "AC"<< endl;
    }
  }
   

  
  return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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

fn main() {
  let n: usize = read();

  let mut s: Vec<(u64, u64)> = Vec::new();
  for _ in 0..n {
    let v: Vec<u64> = read_vec();
    s.push((v[0], v[1]));
  }

  let mut t: Vec<(u64, u64)> = Vec::new();
  for _ in 0..n {
    let v: Vec<u64> = read_vec();
    t.push((v[0], v[1]));
  }

  t.sort_by(|a, b| a.0.cmp(&b.0));
  let mut pair: Vec<bool> = vec![true; n];
  let mut count = 0;
  for &(x, y) in &t {
    let v: Vec<(usize, &(u64, u64))> = s.iter().enumerate().filter(|&(i, e)| e.0 <= x && e.1 <= y && pair[i]).collect();

    match v.into_iter().max_by_key(|x| (x.1).1) {
      None => continue,
      Some((i, &(_, _))) => {
        pair[i] = false;
        count += 1;
      },
    };
  }

  println!("{}", count);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int a = sc.nextInt();
			int b = sc.nextInt();
			
			int result = a - 2*b;
			
			if (result < 0 ) 
				result = 0;
			
			System.out.println(result);
			
		}
	}
}


Measured memory_bytes: 21972
#include<iostream>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int main() {
  int n;
  cin >> n;
  int a[n][3], s[n];
  rep (i, n) rep (j, 3) cin >> a[i][j];
  rep (i, n) s[i] = 0;
  rep (i, 3) rep (j, n) {
    bool ok = true;
    rep (k, n) if (j != k && a[j][i] == a[k][i]) ok = false;
    if (ok) s[j] += a[j][i];
  }
  rep (i, n) cout << s[i] << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    int ninzuu1 = a+b, ninzuu2 = b;
    char c;
    while (cin >> c)
    {
        if (c=='a')
        {
            if(ninzuu1 > 0)
            {
                ninzuu1--;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
            
        }
        else if (c=='b')
        {
            if (ninzuu1 > 0 and ninzuu2 > 0)
            {
                ninzuu1--;
                ninzuu2--;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
            
        }
        else
        {
            cout << "No" << endl;
        }
        
    }
    
}


Measured memory_bytes: 3556
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	int N, K;
	cin >> N >> K;
	char S;
	for (int i = 0; i < N; i++) {
		cin >> S;
		if (i + 1 == K) {
			if (S == 'A')S = 'a';
			if (S == 'B')S = 'b';
			if (S == 'C')S = 'c';

		}
		cout << S;
	}
	cout << endl;
	return 0;
}


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

int main(int argc, const char * argv[]) {
    int N;
    int A[MAX_N];
    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    
    int ans = 0;
    bool isdouble = true;
    while (isdouble) {
        for (int i=0; i<N; i++) {
            if (A[i] % 2 != 0) {
                isdouble = false;
                break;
            }
            A[i] = A[i] / 2;
        }
        if (isdouble) ans += 1;
    }
    
    cout << ans << endl;
    return 0;
}

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

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

    int x = 1;
    for (int i = 0; i < N; i++)
    {
        if ((2 * x) >= (x + K))
        {
            x += K;
        }
        else
        {
            x *= 2;
        }
    }

    cout << x << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int n,i,d1,d2,p,max,ans;

    while(scanf("%d",&n),n){
        max=0;
        ans=0;
        for(i=0;i<n;i++){
            scanf("%d%d%d",&p,&d1,&d2);
            max<d1+d2?(max=d1+d2,ans=p):(0);
        }
        printf("%d %d\n",ans,max);
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
ll h,a[200010],S=0;

void solve(){
    cin >> h >> n;
    rep(i,n){
        cin >> a[i];
        S+=a[i];
    }
    if (S>=h) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

Measured memory_bytes: 1024
N,W = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]

supremum = 10**5

dp = [float("inf") for i in range(supremum+1)]
dp[0] = 0

for i in range(N) :
    weight_i,value_i = L[i]    
    for j in range(supremum,value_i-1,-1) :
        if dp[j-value_i] < float("inf") :
            dp[j] = min(dp[j], dp[j-value_i] + weight_i)

for i in range(supremum,-1,-1) :
    if dp[i] <= W :
        ans = i
        break

print(ans)


Measured memory_bytes: 87808
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int A, B, C;
  	cin >> A >> B >> C;
  	cout << max(C - (A - B), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define int long long 
using namespace std; 
int n, m; 
const int N = 1e5 + 10; 
int num[N]; 
int dis; 
inline int ksm(int x, int y) {
	int tmp = 1; 
	while (y) {
		if (y & 1)
			tmp = x * tmp; 
		y >>= 1; 
		x = x * x; 
	}
	return tmp; 
}
priority_queue < int > qu; 
signed main(void) {
	ios::sync_with_stdio(false); 
	cin >> n >> m; 
	for (int i = 1; i <= n; i++) {
		cin >> num[i]; 
		qu.push(num[i]); 
	}
	if (n == 1) {
		if (log2 (num[1]) + 1 <= m)
			puts ("0"); 
		else
			printf ("%lld\n", num[1] / ksm (2, m)); 
		
		return 0; 
	}
	while (m) {
		int now = qu.top(); 
		if (now == 0)
			break; 
		qu.pop(); 
		int cost = 0; 
		if (qu.top() == 0) {
			if (log2 (now) + 1 <= m)
				qu.push(0); 
			else 
				qu.push(now/ksm(2, m)); 
			break; 
		}
		while (now/ksm(2, cost) - now/ksm(2, cost + 1) >= qu.top() - qu.top()/2 && cost + 1 <= m)
			cost++; 
		m -= cost; 
		qu.push(now/ksm(2, cost)); 
	}
	while ( ! qu.empty()) {
		dis += qu.top(); 
		qu.pop(); 
	}
	printf("%lld\n", dis); 
	return 0; 
}


Measured memory_bytes: 1912
#include<iostream>
#include<string>
#include <cstdlib>
using namespace std;
int main(){
    string S;
    cin>>S;
    int min=10000000;
    for(int i=0;i<S.size()-2;i++){
        int X=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
        int diff = abs(X-753);
        if(diff<min)min=diff;
    }
    cout<<min<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 200010
const int p=1e9+7;
const int inv2=500000004;
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
struct Edge
{
	int v;
	Edge *next;
	Edge(int a=0,Edge *b=NULL)
	{
		v=a;
		next=b;
	}
}*head[maxn];
int n,ans,f[maxn];
int add(int x,int y)
{
	return (x+y)%p;
}
int sub(int x,int y)
{
	return (x-y+p)%p;
}
int mul(int x,int y)
{
	return 1ll*x*y%p;
}
int fpow(int x,int y)
{
	int res=1;
	while(y)
	{
		if(y&1)
			res=mul(res,x);
		x=mul(x,x);
		y>>=1;
	}
	return res;
}
void dfs1(int k,int fa)
{
	f[k]=inv2;
	for(Edge *i=head[k];i!=NULL;i=i->next)
	{
		if(i->v==fa)
			continue;
		dfs1(i->v,k);
		f[k]=mul(f[k],f[i->v]);
	}
}
void dfs2(int k,int fa,int F)
{
	f[k]=mul(f[k],F);
	int s=mul(f[k],2);
	int t=sub(1,s);
	for(Edge *i=head[k];i!=NULL;i=i->next)
	{
		if(i->v==fa)
			continue;
		t=sub(t,mul(sub(1,f[i->v]),mul(s,fpow(f[i->v],p-2))));
	}
	if(fa)
		t=sub(t,mul(sub(1,F),mul(s,fpow(F,p-2))));
	ans=add(ans,mul(t,inv2));
	for(Edge *i=head[k];i!=NULL;i=i->next)
	{
		if(i->v==fa)
			continue;
		dfs2(i->v,k,mul(f[k],fpow(f[i->v],p-2)));
	}
}
int main()
{
	read(n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		read(x,y);
		head[x]=new Edge(y,head[x]);
		head[y]=new Edge(x,head[y]);
	}
	dfs1(1,0);
	dfs2(1,0,1);
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

ll nCr(int n, int r) {
  if (r * 2 > n) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  FOR(i, 1, r+1) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main() {
    int n, p; cin >> n >> p;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int k = 0;
    rep(i, n) {
        if (a[i]%2) k++;
    }

    ll cnt = 0;
    rep(i, n+1) {
        if (p==1 && k>=i && i%2!=0) cnt += nCr(k, i);
        if (p==0 && k>=i && i%2==0) cnt += nCr(k, i);
    }
    
    cout << cnt * (1ll<<(n-k)) << endl;
}

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

using namespace std;

typedef vector<int> vi;

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

	int n;
	while(cin >> n)
	{
		int add = (n%2 == 0);
		cout << n*(n-2)/2 + (1-add) << '\n';
		for(int i=1; i<=n; i++)
		{
			for(int j=i+1; j<=n; j++)
			{
				if(j != n-i+add)
					cout << i << ' ' << j << '\n';
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
import sys
import math

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

d = [ y - x for x, y in zip(A, B)]

q = [ x // 2 for x in d if x > 0]
r = [ -x for x in d if x < 0]

if sum(q) >= sum(r):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4852
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

/*
 * 重み無し無向グラフで、辺表現から隣接集合表現へ変換
 */
template<typename N>
std::vector<std::unordered_set<N>> edges2neighs(const std::vector<std::pair<N, N>>& edges, N n)
{
	std::vector<std::unordered_set<N>> neighs(n);
	for (const auto& edge : edges) {
		neighs[edge.first].insert(edge.second);
		neighs[edge.second].insert(edge.first);
	}
	return neighs;
}


/*
 * 重み無し無向グラフの隣接集合表現を受け取り、深さ優先探索してノードをポストオーダーで列挙して関数を呼ぶ
 */
template<typename N, typename F>
void graph_depthfirst_postorder_call(const std::vector<std::unordered_set<N>>& neighs, N n, const F& fn, N start = 0);

template<typename N, typename F>
void graph_depthfirst_postorder_call_impl(std::vector<char>& arrived, const std::vector<std::unordered_set<N>>& neighs, N cur, const F& fn)
{
	for (auto neigh : neighs[cur]) {
		if (arrived[neigh])
			continue;
		arrived[neigh] = 1;
		graph_depthfirst_postorder_call_impl(arrived, neighs, neigh, fn);
	}
	fn(cur);
}

template<typename N, typename F>
void graph_depthfirst_postorder_call(const std::vector<std::unordered_set<N>>& neighs, N n, const F& fn, N start /* = 0 */)
{
	std::vector<char> arrived(n);
	arrived[start] = 1;
	graph_depthfirst_postorder_call_impl(arrived, neighs, start, fn);
}


/*
 * 重み無し無向グラフの隣接集合表現を受け取り、深さ優先探索してノードをポストオーダーで列挙して返す
 */
template<typename N>
std::vector<N> graph_depthfirst_postorder_enum(const std::vector<std::unordered_set<N>>& neighs, N n, N start = 0)
{
	std::vector<N> nodes(n);
	size_t num = 0;
	graph_depthfirst_postorder_call(neighs, n, [&nodes, &num](N node){
		nodes[num++] = node;
	}, start);
	return nodes;
}


int main()
{
	int N, M;
	std::vector<std::pair<int, int>> E;

	std::cin >> N >> M;
	E.resize(M);
	for (auto& e : E) {
		std::cin >> e.first >> e.second;
		--e.first;
		--e.second;
	}

	if (M % 2 == 1) {
		std::cout << "-1\n";
		return 0;
	}

	auto neighs = edges2neighs(E, N);
	auto nodes = graph_depthfirst_postorder_enum(neighs, N);

	std::vector<char> parity(N);
	for (auto node : nodes) {
		for (auto neigh : neighs[node]) {
			if (parity[node]) {
				std::cout << (node + 1) << " " << (neigh + 1) << "\n";
				parity[node] = 0;
			} else {
				std::cout << (neigh + 1) << " " << (node + 1) << "\n";
				parity[neigh] ^= 1;
			}
			neighs[neigh].erase(node);
		}
	}
}


Measured memory_bytes: 23808
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

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

    string S = "";
    repp(i, 0, (int)s.size()) {
        if (s[i] == 'A') S += "A";
        else if (i < (int)s.size() - 1 && s[i] == 'B' && s[i+1] == 'C') {
            S += "D";
            ++i;
        }
        else S += s[i];
    }

    ll res = 0;
    ll countA = 0;
    repp(i, 0, (int)S.size()) {
        if (S[i] == 'B' || S[i] == 'C') {
            countA = 0;
        } else if (S[i] == 'A') {
            ++countA;
        } else if (S[i] == 'D'){
            res += countA;
        }
    }
    cout << res << endl;
}


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

int main(){
  int n;
  cin >>n;
  int f[n];
  for(int i=0;i<n;i++) cin >>f[i];
  bool s=true;
  for(int i=0;i<n;i++){
    if(f[i]%2==0){
      if(f[i]%3!=0 and f[i]%5!=0)  {
        s=false;
        break;
      }
    }
    
  }
  
  while(s) {
    cout <<"APPROVED" <<endl;
    break;
  }
  while(!s) {
    cout <<"DENIED" <<endl;
    break;
  }
}


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

const double PI = acos(-1);

int main() {
    int a, b, c; cin >> a >> b >> c;
    double rad_c = double(c) * PI / 180.0; // convert to rad
    
    double h = double(b) * sin(rad_c);
    double S = double(a) * h / 2.0;
    double side = sqrt(double(a * a) + double(b * b) - 2.0 * a * b * cos(rad_c)); // 余弦定理
    double L = a + b + side;
    
    printf("%.8f\n%.8f\n%.8f\n", S, L, h);
    
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)	cin >> a[i];
  vector<int> b = a;
  sort(b.rbegin(), b.rend());
  for(int i = 0; i < n; i++)	cout << (a[i]==b[0] ? b[1] : b[0]) << " \n"[i+1==n];
  return 0;
}


Measured memory_bytes: 3200
# -*- coding: utf-8 -*-

sx,sy,tx,ty = map(int, input().split())

x = tx - sx
y = ty - sy

ans = ""
if x > 0 and y > 0:
    ans += "U"*y + "R"*x + "D"*y + "L"*x
    ans += "L" + "U"*(y+1) + "R"*(x+1) + "D" + "R" + "D"*(y+1) + "L"*(x+1) + "U"
elif x < 0 and y < 0:
    ans += "D"*y + "L"*x + "U"*y + "R"*x
    ans += "R" + "D"*(y+1) + "L"*(x+1) + "U" + "L" + "U"*(y+1) + "R"*(x+1) + "D"
elif x > 0 and y < 0:
    ans += "R"*x + "D"*y + "L"*x + "U"*y
    ans += "U" + "R"*(x+1) + "D"*(y+1) + "L" + "D" + "L"*(x+1) + "U"*(y+1) + "R"
elif x < 0 and y > 0:
    ans += "L"*x + "U"*y + "R"*x + "D"*y
    ans += "D" + "L"*(x+1) + "U"*(y+1) + "R" + "U" + "R"*(x+1) + "D"*(y+1) + "L"

elif x == 0 and y > 0:
    ans += "U"*y + "R" + "D"*y + "L"
    ans += "L" + "U"*y + "R" + "U" + "R"*2 + "D"*(y+2) + "L"*2 + "U"
elif x == 0 and y < 0:
    ans += "D"*y + "L" + "U"*y + "R"
    ans += "R" + "D"*y + "L" + "D" + "L"*2 + "U"*(y+2) + "R"*2 + "D"
elif x > 0 and y == 0:
    ans += "R"*x + "D" + "L"*x + "U"
    ans += "U" + "R"*x + "D" + "R" + "D"*2 + "L"*(x+2) + "U"*2 + "R"
elif x < 0 and y == 0:
    ans += "L"*x + "U" + "R"*x + "D"
    ans += "D" + "L"*x + "U" + "L" + "U"*2 + "R"*(x+2) + "D"*2 + "L"

print(ans)

Measured memory_bytes: 3188
input = STDIN.gets.to_i

def seek_max_int_sqrt(target)
  target.step(1, -1) do |t|
    result = Math.sqrt(t)
    result_int = result.to_i

    if result == result_int
      return result_int
    end
  end
end

puts seek_max_int_sqrt(input)**2


Measured memory_bytes: 1788
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>
#include <map>

using namespace std;
 
int main() {
	long long power = 1;
	int n;
	int inf = 1e09 + 7;
	cin >> n;
	for(int i = 1; i <= n;i++){
	    power = power * i % inf;
	}
    
	cout << power << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i=0; i<n; i++) cin >> l[i];
  sort(l.begin(),l.end());
  int ans=0;
  for(int i=0; i<n-2; i++){
    for(int j=i+1; j<n-1; j++){
      int sum = l[i] + l[j];
      int oldmax = n-1;
      int oldmin = j+1;
      int target=0;
      if(sum <= l[j+1]) target=j;
      if(l[n-1] < sum) target=n-1;
      while(target==0){
        int now = (oldmax + oldmin)/2;
        if(l[now] < sum) oldmin = now;
        else if(sum <= l[now]) oldmax = now;
        if(l[now] < sum && sum <= l[now+1]) target = now;
      }
      ans += target-j;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<ctime>
#include<map>
#define For(i,a,b) for(register int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(register int i=(a);i>=(b);i--)
#define Formylove return 0
const int N=2e5+7;
typedef long long LL;
typedef double db;
using namespace std;
int n,c[N];

template<typename T> void read(T &x) {
    char ch=getchar(); T f=1; x=0;
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f;
}

int ecnt,fir[N],nxt[N<<1],to[N<<1];
void add(int u,int v) {
	nxt[++ecnt]=fir[u]; fir[u]=ecnt; to[ecnt]=v;
	nxt[++ecnt]=fir[v]; fir[v]=ecnt; to[ecnt]=u;
}

map<int,int>Q[N];
int qry(int x,int fa,int v) {
	if(Q[x][v]) {
		return Q[x][v];
	}
	int rs=1;
	for(int i=fir[x];i;i=nxt[i]) if(to[i]!=fa&&to[i]<=v) 
		rs+=qry(to[i],x,v);
	Q[x][v]=rs;
	return rs;
}

void dfs(int x,int fa,int mx) {
	for(int i=fir[x];i;i=nxt[i]) if(to[i]!=fa) {
		c[to[i]]=c[x]+qry(to[i],x,max(mx,x));
		if(to[i]<=mx) c[to[i]]-=qry(to[i],x,mx); 
		dfs(to[i],x,max(mx,x));
	}
}

int main() {
	//freopen("rand.txt","r",stdin);
	read(n);
	For(i,2,n) {
		int x,y;
		read(x); read(y);
		add(x,y);
	}
	dfs(1,0,1);
	For(i,2,n) printf("%d ",c[i]); printf("\n");
	//printf("%d\n",c[n]);
   	Formylove;
}

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

int main(void){
  int N,M,a[50],b[50],c[50],d[50],i,j,min[50]={},flag[50];

for(i=0;i<50;i++){
  flag[i]=1;
}

  scanf("%d %d",&N,&M);

  for(i=0;i<N;i++){
    scanf("%d %d",&a[i],&b[i]);
  }

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

  for(i=0;i<N;i++){
    min[i]=abs(a[i]-c[0])+abs(b[i]-d[0]);
  }

  for(i=0;i<N;i++){
    for(j=1;j<M;j++){
      if(min[i]>abs(a[i]-c[j])+abs(b[i]-d[j])){
        min[i]=abs(a[i]-c[j])+abs(b[i]-d[j]);
        flag[i]=j+1;
      }else if(min[i]==abs(a[i]-c[j])+abs(b[i]-d[j])){
        flag[i]=j;
      }
    }
  }

  for(i=0;i<N;i++){
    printf("%d\n",flag[i]);
  }

  return 0;
}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  ll a, b, k; cin >> a >> b >> k;
  ll t = max(0LL, a - k);
  ll ao = (a >= k ? b: max(0LL, b - (k - a)));
  cout << t << " " << ao << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    char s[4];
    for(int i=0; i<4; i++)
    cin>>s[i];
    int temp=0;
    for(int i=0; i<4; i++)
    {
        if(s[i]=='+')
            temp+=1;
        else if (s[i]=='-')
            temp-=1;
    }
    cout<<temp<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

int main(){
  int INF=1000000007;
  int N,a,ans=0,tmp;cin>>N;
  REP(i,0,N){
    cin>>a;
    tmp=0;
    while(a){
      if(a%2==0){tmp++;}
      else {break;}
      a/=2;
    }
    ans+=tmp;
  }
  print(ans)
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(int i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


class runtime_modint {
  using u64 = std::uint_fast64_t;

  static u64 &mod() {
    static u64 mod_ = 0;
    return mod_;
  }

public:
  u64 a;

  runtime_modint(const u64 x = 0) : a(x % get_mod()) {}
  u64 &value() noexcept { return a; }
  const u64 &value() const noexcept { return a; }
  runtime_modint operator+(const runtime_modint rhs) const {
    return runtime_modint(*this) += rhs;
  }
  runtime_modint operator-(const runtime_modint rhs) const {
    return runtime_modint(*this) -= rhs;
  }
  runtime_modint operator*(const runtime_modint rhs) const {
    return runtime_modint(*this) *= rhs;
  }
  runtime_modint operator/(const runtime_modint rhs) const {
    return runtime_modint(*this) /= rhs;
  }
  runtime_modint &operator+=(const runtime_modint rhs) {
    a += rhs.a;
    if (a >= get_mod()) {
      a -= get_mod();
    }
    return *this;
  }
  runtime_modint &operator-=(const runtime_modint rhs) {
    if (a < rhs.a) {
      a += get_mod();
    }
    a -= rhs.a;
    return *this;
  }
  runtime_modint &operator*=(const runtime_modint rhs) {
    a = a * rhs.a % get_mod();
    return *this;
  }
  runtime_modint &operator/=(runtime_modint rhs) {
    u64 exp = get_mod() - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }

  static void set_mod(const u64 x) { mod() = x; }
  static u64 get_mod() { return mod(); }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll p;cin>>p;
  runtime_modint::set_mod(p);
  using mint=runtime_modint ;
  vector<mint>fact(p),inv(p);
  fact[0]=(mint)1;
  rep(i,p-1)fact[i+1]=fact[i]*(i+1);
  inv[p-1]=(mint)1/fact[p-1];
  rrep(i,p-1){
    inv[i]=inv[i+1]*(i+1);
  }
  auto comb=[&](int a,int b){
    return fact[a]*inv[b]*inv[a-b];
  };
  
  vector<mint>res(p);
  rep(i,p){
    mint w;
    cin>>w.value();
    res[0]+=w;
    mint tj(1);
    rrep(j,p){
      res[j]-=(comb(p-1,j)*tj)*w;
      tj=tj*(mint)(p-i);
    }

  }
  rep(i,p){
    cout<<res[i].value()<<" ";
  }
  cout<<endl;


  return 0;

}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  
  
  
  
  if(a>=b&&b>=c){printf("%d",a*10+b+c); return 0;}//a>b>c
  if(a>=c&&c>=b){printf("%d",a*10+b+c);return 0;}//a>c>b
   if(b>=a&&a>=c){printf("%d",b*10+a+c);return 0;}//b>a>c
  if(b>=c&&c>=a){printf("%d",b*10+a+c);return 0;}//b>c>a
   if(c>=b&&b>=a){printf("%d",c*10+b+a);return 0;}//c>b>a
  if(c>=a&&a>=b){printf("%d",c*10+b+a);return 0;}//c>a>b
return 0;
}

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

int n, k;
int a[500];
bool ok(int d) {
  vector<long> v;
  for (int i = 0; i < n; ++i) {
    if (a[i] % d == 0) continue;
    v.push_back(a[i] % d);
  }
  sort(v.begin(), v.end());
  
  vector<long> p(v.size() + 1);
  vector<long> q(v.size() + 1);
  for (int i = 0; i < v.size(); ++i) p[i + 1] = p[i] + v[i];
  for (int i = v.size(); i > 0; --i) q[i - 1] = q[i] + d - v[i - 1];
  for (int i = 0; i <= v.size(); ++i) {
    if (p[i] == q[i]) {
      int ans = p[i];
      return ans <= k;
    }
  }
  assert(0);
}

vector<int> divisors(int n) {
  vector<int> ret;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      ret.push_back(n / i);
    }
  }
  return ret;
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int sum = accumulate(a, a + n, 0);
  
  int mx = 1;
  for (int d : divisors(sum)) {
    if (ok(d)) mx = max(mx, d);
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,t,t1,h=0;
	int *g;
	scanf("%d",&n);
	g = (int*)malloc(sizeof(int)*n);
	for(t=0;t<n;t++)
	{
		scanf("%d",&g[t]);
		h += g[t];
	}
	for(t=0;t<n;t++)
	{
		for(t1=t+1;t1<n;t1++)
		{
			if(g[t]>g[t1])
			{
				int a;
				a = g[t];
				g[t] = g[t1];
				g[t1] = a;
			}
		}
	}
	if(h%10 != 0) goto z;
	for(t=0;t<n;t++)
	{
		for(t1=t;t1<n;t1++)
		{
			h -= g[t1];
			if(h%10 != 0) goto z;
			else		h+=g[t1];
		}
		h -= g[t];
	}
z:	printf("%d\n",h);
	return 0;
}

Measured memory_bytes: 128
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int a, int b) {
    if (a > b) return calc(b, a);
    assert(a <= b);

    int d = b - a;
    if (d % 2 == 1) {
        writeln("IMPOSSIBLE");
        return;
    }
    writeln(a + d / 2);
}

void main() {
    int a, b; scan(a, b);
    calc(a, b);
}


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

int main(){
  int N, T, min=10001;
  cin >> N >> T;
  vector<int> c(N), t(N);
  for(int i=0; i<N; i++){
  	cin >> c[i] >> t[i];
	if(t[i]<=T) min=min>c[i]?c[i]:min;
  }
  if(min==10001) cout << "TLE" << endl;
  else cout << min << endl;
 return 0;
}

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


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

    int a=0,b=0,c=0,d=0;

    while(n--){
        string s;
        cin>>s;

        if(s=="AC")
            a++;

        else if(s=="WA")
            b++;

        else if(s=="TLE")
            c++;

        else
            d++;
    }


    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;



}


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

int main()
{int N;
 vector<vector<int>> X(2,vector<int>(N));
 
 cin >> N;
 
 for(int i = 0; i < 2; i++)
 { for(int j = 0; j < N; j++)
 {cin >> X.at(i).at(j);}}
 //X入力
 
 int sum = 0;
 
 for(int j = 0;j < N; j++)
 {
 if( X.at(0).at(j)-X.at(1).at(j) > 0)
 { sum += X.at(0).at(j) - X.at(1).at(j);}}
 
 cout <<sum<<endl;
return 0;}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    int n,m;
    cin >> n >> m;
    int a[m],b[m];
    int f[n],s[n];
    for(int i = 0; i < n; i++){
        f[i] = 0;
        s[i] = 0; 
    }
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        if(a[i] == 1) f[b[i]-1] = 1;
        if(b[i] == n) s[a[i]-1] = 1;
    }
    for(int i = 0; i < n; i++){
        if(f[i] == 1 && s[i] == 1){
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
}


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

int main() {
    ll N,K;
    cin >> N >> K;
    vec<ll> A(N);
    rep(i, N) cin >> A[i];
    
    int first1 = 0;
    rep(i,60) if((K>>i)&1) first1=i;
    ll msk = 0;
    ll msk2 = 0;
    for(int i=40;i>=0;--i){
        ll cnt = 0;
        rep(j,N) if((A[j]>>i)&1) ++cnt;
        if(cnt*2<=N && msk+(1LL<<i)<=K) msk^=(1LL<<i);
        if(cnt*2<=N && i<first1) msk2^=(1LL<<i);
    }
    
    ll ans = 0;
    ll ans2 = 0;
    rep(i,N){
        ans += (A[i]^msk);
        ans2 += (A[i]^msk2);
    }
    cout << max(ans,ans2) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll arr[4] = {0};
  for (auto &e : arr) {
    cin >> e;
  }
  ll mx = arr[0] * arr[2];
  for (int i = 0; i <= 1; ++i) {
    for (int j = 2; j <= 3; ++j) {
      mx = max(mx, arr[i] * arr[j]);
    }
  }
  cout << mx << '\n';
  return 0;
}


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

int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < 4; i++) {
        cout << s[i];
    }
    cout << " ";
    for(int i = 4; i < 12; i++) {
        cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3536
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		List<List<Hen>> list = new ArrayList<List<Hen>>();
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<Hen>());
		}
		for (int i = 0; i < n - 1; i++) {
			sa = br.readLine().split(" ");
			Hen h = new Hen();
			h.u = Integer.parseInt(sa[0]) - 1;
			h.v = Integer.parseInt(sa[1]) - 1;
			h.w = Integer.parseInt(sa[2]);
			list.get(h.u).add(h);
			list.get(h.v).add(h);
		}
		br.close();

		boolean[] flg = new boolean[n];
		int[] ans = new int[n];
		Queue<Integer> que = new ArrayDeque<Integer>();
		que.add(0);
		flg[0] = true;
		while (!que.isEmpty()) {
			int cur = que.poll();
			List<Hen> list2 = list.get(cur);
			for (int i = 0; i < list2.size(); i++) {
				Hen h = list2.get(i);
				int next = h.u;
				if (next == cur) {
					next = h.v;
				}
				if (!flg[next]) {
					que.add(next);
					flg[next] = true;
					if (h.w % 2 == 0) {
						ans[next] = ans[cur];
					} else {
						ans[next] = ans[cur]^ 1;
					}
				}
			}
		}

		for (int i = 0; i < ans.length; i++) {
			System.out.println(ans[i]);
		}
	}

	static class Hen {
		int u, v, w;
	}
}


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

int main(){

  int x;
  cin>>x;

  int h = x / 3600;
  int m = (x / 60) % 60;
  int s = x % 60;
  cout<<h<<":"<<m<<":"<<s<<endl;

  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, P;
    cin >> N >> P;
    string S;
    cin >> S;
    if (P == 2 || P == 5) {
        ll k = 0;
        for (int i = 0; i < N; i++) {
            int c = S[N - i - 1] - '0';
            if (c % P == 0) {
                k += N - i;
            }
        }
        cout << k << "\n";
        return 0;
    }
    ll dp[N + 1]{};
    int k = 1;
    ll a[P + 1]{};
    a[0] = 1;
    for (int i = 0; i < N; i++) {
        int j = N - i - 1;
        int c = S[j] - '0';
        dp[i + 1] = (dp[i] + c * k) % P;
        k = (k * 10) % P;
        a[dp[i + 1]]++;
    }
    ll ans = 0;
    for (int i = 0; i < P; i++) {
        ans += (a[i] * (a[i] - 1)) / 2;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5364
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;


int main()
{
    long long  a, b, k;


    cin >> a >> b >> k;
    if (a >= k) {

        a -= k;
    }
    else {
        k -= a;
        a = 0;


        if (b >= k) {
            b -= k;
        }
        else {
            b = 0;
        }
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        int k=sc.nextInt();
        char[][] c=new char[h][w];

        for(int i=0;i<h;i++) {
            String s=sc.next();
            c[i]=s.toCharArray();
        }

        int ans=0;
        for(int i=0;i<(Math.pow(2, h));i++) {
            for(int j=0;j<(Math.pow(2, w));j++) {
                int count=0;
                for(int row=0;row<h;row++) {
                    for(int col=0;col<w;col++) {
                        if(((i>>row & 1)==1) && ((j>>col & 1)==1)) {
                            if (c[row][col] == '#')count++;
                        }
                    }
                }
                if(count==k)ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 35768
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<ll,int> P;

int a[100001]={};
int b[100001]={};

int main() {
	int n,h;

	cin>>n>>h;
	for(int i=0;i<n;++i)cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	int t=0;
	int c=0;
	int k=n-1;
	while(t<h){
		if(b[k]>a[n-1]&&(k>=0)){
			t+=b[k];
			k--;
			c++;
		}else{
			c+=((h-t)/a[n-1]);
			if((h-t)%a[n-1]>0)c++;
			t=h+1;
		}
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 1024
N = int(input())

def num_to_str(num):
    return chr(num + 97)

ans = []
while N > 0:
    N -= 1
    q, r = divmod(N, 26)
    ans.append(r)
    N = q
ans_alpha = list(reversed([num_to_str(i) for i in ans]))
print(''.join(ans_alpha))

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
using Graph = vector<vector<int>>;

double kitai[200100];

int main() {
  ll n, k; cin >> n >> k;
  Vl p(n);
  rep(i, 0, n) cin >> p[i];

  double bunsi = 0, bunbo;
  Rep(i, 1, 200000){
    bunsi += i;
    bunbo = i;
    kitai[i] = bunsi/bunbo;
  }

  double sum = 0.0;
  rep(i, 0, k) sum += kitai[p[i]];
  double ans = sum;
  rep(i, 0, n-k){
    sum -= kitai[p[i]];
    sum += kitai[p[i+k]];
    ans = max(ans, sum);
  }
  cout << fixed << setprecision(7) << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
H,W,N = map(int,input().split())
ah,aw = map(int,input().split())
d = [aw,W-aw+1,ah,H-ah+1]
S = list(input())
T = list(input())

C = []
for i,LRUD in enumerate([["L","R"],["R","L"],["U","D"],["D","U"]]):
  if d[i] <= S.count(LRUD[0]):
    if d[i] <= S.count(LRUD[0])-T.count(LRUD[1]):
      print("NO")
      exit()
    else:
      C.append([i,LRUD])
for x in C:
  count = d[x[0]]
  if S[0] == x[1][0]:count -= 1
  for i in range(len(S)-1):
    if T[i] == x[1][1]:
      if (x[1][1] == "R" or x[1][1]== "L") and count < W:count += 1
      elif (x[1][1] == "U" or x[1][1]== "D") and count < H:count += 1
    if S[i+1] == x[1][0]:count -= 1
    if count <= 0:
      print("NO")
      exit()

print("YES")

Measured memory_bytes: 6832
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int Longitudinal = scanner.nextInt();
        int side = scanner.nextInt();

        int area = Longitudinal * side;
        int length = (Longitudinal + side) * 2;
        
        System.out.println(area + " " + length);
    }
}

Measured memory_bytes: 26044
#include<stdio.h>
int main(void)
{
	int A, B, C, K,max=0,wa;
	scanf("%d%d%d%d", &A, &B, &C, &K);
	if (A >= B && A >= C) {
		max = A;
		wa = B + C;
	}
	else if (B >= A && B >= C) {
		max = B;
		wa = A + C;
	}
	else if (C >= A && C >= B) {
		max = C;
		wa = A + B;
	}
	for (int i = 0; i < K; i++) {
		max *= 2;
	}
	printf("%d", max + wa);
	return 0;
}

Measured memory_bytes: 128
A, B, C, D, E, F = map(int, input().split())
a = 100 * A
b = 100 * B
waters = set()
sugers = set()
for i in range(F // a + 1):
    ai = a * i
    f = F - ai
    for j in range(f // b + 1):
        g = ai + b * j
        if g <= F:
            waters.add(g)
for i in range(F // C + 1):
    ci = C * i
    f = F - ci
    for j in range(f // D + 1):
        g = ci + D * j
        if g <= F:
            sugers.add(g)

waters = sorted(waters)
sugers = sorted(sugers)

ans_sum = 100 * A
ans_sg = 0
concetration = 0
for w in waters:
    for s in sugers:
        g = w + s
        if g == 0 or g > F:
            break
        if s > w // 100 * E:
            break
        c = s / g
        if concetration < c:
            concetration = c
            ans_sum = g
            ans_sg = s
print(ans_sum, ans_sg)


Measured memory_bytes: 3188
function Main(input){
var inputs = input.split("\n");
var arra = inputs[1].split("");
var x = 0;
var a = [0];
for(i=0;i<=(arra.length - 1);i++){
  if(arra[i] == "I"){
    x += 1;
    a[i+1] = x;
  }else{
    x -= 1;
    a[i+1] = x;
  }
}
var answer = Math.max.apply(null,a);
console.log(answer);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int main(void) {
	int N, K;
	scanf("%d %d", &N, &K);
	int h[100100];
	for (int i = 0; i < N; i++) {
		scanf("%d", &h[i]);
	}
	sort(h, h + N);
	int ans = 2000000000;
	for (int i = K - 1; i < N; i++) {
		ans = min(ans, h[i] - h[i - K + 1]);
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 4100
<?php
$s=trim(fgets(STDIN));
$a=$s[0].$s[1];
$b=$s[2].$s[3];
if($a!=0&&$a<13){
  if($b!=0&&$b<13){
    echo "AMBIGUOUS";
  }else{
    echo "MMYY";
  }
}else{
  if($b!=0&&$b<13){
    echo "YYMM";
  }else{
    echo "NA";
  }
}


Measured memory_bytes: 4732
/** author: __nishad__ **/
#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(ll i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    int count=0, k, s, z;

    cin>>k>>s;


    loop(i, 0, k){
        loop(j, 0, k){
            z = 0;
            z = s - (i+j);

            if((i+j+abs(z)) == s && z <= k)
                count++;

        }
    }

    cout<<count;



}






























Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <functional>
using namespace std;

int main()
{
	string pass = "";

	cin >> pass;

	for(int i=1; i<4; i++){
		if(pass[i-1] == pass[i]){
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;

	return 0;
}


Measured memory_bytes: 256