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

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

int root;
int arr[100010];
int parent[100010];
vector<int>nodes[100010];

void maketree(int x){
    for(int y:nodes[x]){
        if(y==parent[x])continue;
        parent[y]=x;
        maketree(y);
    }
}

bool f(int x){
    if(nodes[x].size()==1)return true;
    ll sum=0;
    ll maxi=0;
    for(int y:nodes[x]){
        if(y==parent[x])continue;
        if(!f(y))return false;
        sum+=arr[y];
        maxi=max(maxi,(ll)arr[y]);
    }
    if(arr[x]>sum)return false;
    arr[x]-=sum-arr[x];
    if(arr[x]<0)return false;
    if(arr[x]<maxi-(sum-maxi))return false;
    //printf("%d:%d\n",x,arr[x]);
    return true;
}

int main() {
    //freopen("hi.txt", "r", stdin);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&arr[i]);
    }
    if(n==2){
        if(arr[1]==arr[2])printf("YES");
        else printf("NO");
        return 0;
    }
    int a,b;
    for(int i=0;i<n-1;i++){
        scanf("%d%d",&a,&b);
        nodes[a].push_back(b);
        nodes[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        if(nodes[i].size()>1){
            root=i;
            break;
        }
    }
    maketree(root);
    if(!f(root) || arr[root]!=0){
        printf("NO");
    }
    else{
        printf("YES");
    }
}


Measured memory_bytes: 11776
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n,m;
	cin>>n>>m;

	if(n+m==4)
	{
		cout<<2<<endl;
	}
	else if(n+m==5)
	{
		cout<<1<<endl;
	}
	else
	{
		cout<<3<<endl;
	}

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int N;
  cin>>N;
  vector<int>P(N);
  vector<int>Q(N);
  for(int i=0;i<N;i++){
    cin>>P[i];
  }
  for(int i=0;i<N;i++){
    cin>>Q[i];
  }
  vector<int>A(N);
  for(int i=0;i<N;i++){
    A[i]=i+1;
  }
  int a=0,b=0,i=0;
  do{
   if(P==A){a=i;}
   if(Q==A){b=i;}
   i++;
  }while(next_permutation(A.begin(),A.end()));
  cout<<abs(a-b)<<endl;
  return 0;
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    ll a, b, k;
    cin >> a >> b >> k;
    set<int> x;
    int roop = min(b - a + 1, 2 * k);
    rep(i, roop)
    {
        if (i < k)
            x.insert(a + i);
        if (roop - i > k)
            x.insert(b - i);
    }
    for (int q : x)
    {
        c(q);
    }
    return 0;
}

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

int main(){
	int a,b;
	float f;
	scanf("%d%d",&a,&b);
	f=(a+b)/2;
	if((a+b)%2==0){
		printf("%.0f\n",f);
	}
	else{
		printf("%.0f\n",f+1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int n, m, a, b, s, t, dist[300005];
vector<vi> adjList;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    cin >> n >> m;
    adjList.resize(3*n);

    for (int i = 0; i < 3*n; i++)
        dist[i] = INF;

    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        adjList[a].push_back(b+n);
        adjList[a+n].push_back(b+2*n);
        adjList[a+2*n].push_back(b);
    }

    cin >> s >> t;
    s--; t--;

    queue<int> q;
    q.push(s);
    dist[s] = 0;

    bool reached = 0;
    while (!q.empty() && !reached) {
        int u = q.front(); q.pop();
        for (int i = 0; i < adjList[u].size() && !reached; i++) {
            int v = adjList[u][i];
            if (dist[v] == INF) {
                dist[v] = dist[u]+1;
                if (v == t) reached = 1;
                q.push(v);
            }
        }
    }

    if (dist[t] == INF) cout << "-1\n";
    else cout << dist[t]/3 << '\n';
 
    return 0;
}

Measured memory_bytes: 17792
#include<iostream>
#include<cstring>
using namespace std;
typedef struct{
  int p,r,l;
}node;
node tree[100001];
int n,d[100001];

//出力する関数
int print(int u){
  int i,c;
  cout<<"node "<<u<<": ";
  cout<<"parent = "<<tree[u].p<<", ";
  cout<<"depth = "<<d[u]<<", ";
  if(tree[u].p==-1) cout<<"root, ";
    else if(tree[u].l==-1) cout<<"leaf, ";
    else cout<<"internal node, ";
  cout<<"[";
  for(i=0,c=tree[u].l;c!=-1;++i,c=tree[c].r){
    if(i) cout<<", ";
    cout<<c;
  }
  cout<<"]"<<endl;
}

//深さを求める
int rec(int u,int p){
  d[u]=p;
  if(tree[u].r!=-1) rec(tree[u].r,p);
  if(tree[u].l!=-1) rec(tree[u].l,p+1);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int i,j,d,v,c,l,r;
  cin>>n;
  memset(tree,-1,sizeof(tree));

  //ノードの情報を入力
  for(int i=0;i<n;++i){
    cin>>v>>d;    //v=ノードの番号(親ではない),d=次数
    for(int j=0;j<d;++j){
      cin>>c;
      if(j==0) tree[v].l=c;
      else tree[l].r=c;
      l=c;
      tree[c].p=v;
    }
  }

  //
  for(int i=0;i<n;++i){
    if(tree[i].p==-1) r=i;
  }
  //
  rec(r,0);
  
  //出力
  for(i=0;i<n;++i) print(i);
  
  return 0;
}

Measured memory_bytes: 7824
#include <stdio.h>
#include <string.h>
int solve(int, int, int);
int A[2000];
int main(){
  int n,i;
  int M[2000];
  int q;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&M[i]);
  for(i=0;i<q;i++){
    if(solve(0,M[i],n)==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m,int n){
  int res;
  if(m==0)
    return 1;
  if(i>=n)
    return 0;
  res=solve(i+1,m,n)||solve(i+1,m-A[i],n);
  return res;
}



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

int main(){
	int A[3];
	cin >> A[0] >> A[1] >> A[2];

	sort(A,A+3);

	int ans = A[2]*2 - A[0] - A[1];
	if (ans%2){
		ans = ans/2 + 2;
		cout << ans << endl;
	} else {
		cout << ans/2 << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long[] a=new long[n];
		long[] two=new long[n/2];
		long[] ans=new long[n];
		SegTree st=new SegTree(n/2);
		for(int i=0; i<n; i++){
			a[i]=sc.nextLong();
		}
		int count=0;
		for(int i=0; i<n; i+=2){
			two[i/2]=(a[i]^a[i+1]);
			st.set(count++,a[i]^a[i+1]);
		}
		for(int i=0; i<n; i++){
			long tmpb=0;
			long tmpf=0;
			if(i/2>0){
				tmpb=st.query(0,i/2);
			}
			if(i/2+1<n/2){
				tmpf=st.query(1+i/2,1+n/2);
			}
			if(i%2==0){
				System.out.println(a[i+1]^tmpb^tmpf);
			}else{
				System.out.println(a[i-1]^tmpb^tmpf);
			}
		}
	}
	static class SegTree{
		int n=1;
		long[] v;
		
		public SegTree(int n) {
			while(this.n<n)this.n*=2;
			v=new long[2*this.n-1];
		}
		
		void set(int k,long val) {
			k+=n-1;
			v[k]=val;
			while(k>0) {
				k=(k-1)/2;
				v[k]=v[2*k+1]^v[2*k+2];
			}
		}
		//bをプラス1
		long query(int a,int b) {
			return query(0,n,a,b,0);
		}
		
		long query(int l,int r,int a,int b,int k) {
			if(r<=a||b<=l)return 0;
			else if(a<=l&&r<=b)return v[k];
			else {
				long vl=query(l,(l+r)/2,a,b,2*k+1);
				long vr=query((l+r)/2,r,a,b,2*k+2);
				return vl^vr;
			}
		}
	}
}


Measured memory_bytes: 67080
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(a.begin(), a.end());
    int res = 0;
    rep(i, N)
    {
        if (x >= a[i])
        {
            x -= a[i];
            if (i == N - 1 && x > 0)
                break;
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(ll, N);
	bool ok = false;
	ll t = 0, nn = 0;
	for (ll i = 1; t <= N; ++i){
		++nn;
		if (t == N) {
			ok = true;
			break;
		}
		t += i;
	}
	YesNo(ok);
	//std::cerr << "nn = " << nn << std::endl;
	if (!ok) return 0;
	t = 1;
	vector<vector<ll>> ans(nn);
	for (int i = 1; i < nn; ++i) {
		//std::cerr << "-------" << std::endl;
		//std::cerr << "i = " << i << ", nn = " << nn << endl;
		for (int e = 0; e < i; ++e) {
			//cerr << "node ( " << e + 1 << " ) <- " << t << endl;
			//cerr << "node ( " << i + 1 << " ) <- " << t << endl;
			ans[e].push_back(t);
			ans[i].push_back(t);
			++t;
			//std::cerr << std::endl;
		}
	}
	out(nn);
	for (int i = 0; i < nn; ++i) {
		std::cout << ans[i].size();
		for (auto a : ans[i]) {
			std::cout << " " << a;
		}
		std::cout << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 10000;
#define INF 0x3f3f3f3f

int main() {
    int n,tep;
    cin>>n;
    int a[n];
    cin>>tep;
    ll sum = 0;
    for(int i = 1;i < n;i++) {
        cin>>a[i];
        if(a[i]<tep) {
            sum += 1LL*(tep - a[i]);
        }
        tep = max(a[i],tep);
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
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;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

constexpr array<int, 6> goods = {100, 101, 102, 103, 104, 105};

static bool can = false;
void dfs(int x)
{
    static map<int, int> mp;
    if (can)
        return;
    if (x == 0)
        can = true;
    else if (x < 0)
        return;
    if (mp[x] > 0)
        return;
    mp[x]++;

    for (auto &&gi : goods)
        dfs(x - gi);
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int x;
    cin >> x;

    dfs(x);
    cout << (can ? 1 : 0) << endl;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline

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

S_A = [0]*(N+1)
S_B = [0]*(N+1)
for i in range(N):
    S_A[i+1] = S_A[i] + A[i]
    S_B[i+1] = S_B[i] + B[i]
X = [0]*N
X[0] = A[0]+B[0]
for i in range(N-1):
    X[i+1] = max(X[i]+B[i+1],S_A[i+2]+B[i+1])
    
print(X[N-1])

Measured memory_bytes: 62160
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
		
		long long int x,y;
		double ans=0;
		cin>>x>>y;
		for(int n=1;n<10000;n++)ans+=(n*(1900*y+100*(x-y))*pow((pow(2,y)-1)/pow(2,y),n-1)*(1/pow(2,y)));
		cout<<ans<<"\n";
		return 0;
}

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

int main() {
  
  int n,k;
  int ans = 0;
  cin >> n >> k;
  vector<int> p(n);
  for(int i = 0;i<n;i++){
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  for(int i  = 0;i<k;i++){
    ans = ans + p.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  int ans;
  for(int i=1;i<=N;i++){
    if(i*i <= N){
      ans = i*i;
    }
    else{
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1e9+7;
ll mod_pow(ll a,ll b) {
    if(b==0){return 1;}
    ll res=mod_pow(a*a%MOD,b/2);
    if(b&1)res=res*a%MOD;
    return res;
}
int main(){
  ll N,ans=0,x=1;
  cin>>N;
  vector<ll> vec(61);
  for(ll i=0;i<N;++i){
    ll a,j=0;
    cin>>a;
    while(a>0){
      if(a&1){++vec.at(j);}
      a/=2;
      ++j;
    }
  }
  for(int i=0;i<61;++i){
    ans+=((((N-vec.at(i))*vec.at(i))%MOD)*(x%MOD))%MOD;
    x*=2;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
#define Hare printf("here\n")
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define x first
#define y second
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))

//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
using namespace std;

int main(){
    int i,j,k,n,m,val,t=0,cnt,test;
    //freopen("000input.txt","r",stdin);
    cin>>n;
    int arr[n+5];
    for(i=n-1;i>=0;i--)scanf("%d",&arr[i]);
    int ans[n+5];
    ans[0]=0,ans[1]=abs(arr[0]-arr[1]);
    for(i=2;i<n;i++){
        ans[i]=min(ans[i-1]+abs(arr[i-1]-arr[i]),ans[i-2]+abs(arr[i-2]-arr[i]));
    }
    printf("%d\n",ans[n-1]);

    //free();   //if pointer array
    return 0;
}


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

typedef long long ll;
ll n, m, ans;

ll fact(ll x) {
    if (x == 0)
        return 1;
    return x * fact(x - 1) % ((int)1e9 + 7);
}

int main(void) {
    cin >> n >> m;
    if (abs(n-m) >= 2)
        ans = 0;
    else if (abs(n-m) == 1)
        ans = fact(n) * fact(m);
    else if (abs(n-m) == 0)
        ans = 2 * fact(n) * fact(m);

    ans = ans % ((int)1e9+7);
    cout << ans << endl;
    return 0;
}

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

int main()
{
  	string s,t;
  	cin>>s>>t;
  
  	int l1=s.size(),l2=t.size();
  	
  	int mi_cnt=l2;
  
  	for(int i=0;i+l2-1<l1;i++)
    {
      	int cnt=0;
      	for(int j=0;j<l2;j++)
        {
          	if(t[j] != s[i+j])
              	cnt++;
        }
      	mi_cnt=min(mi_cnt,cnt);
    }
  	cout<<mi_cnt<<endl;
  	return 0;
}

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

#define ll long long int
ll mod=1e9+7;
#define loop() for(ll i=0;i<n;i++) 


int main()
{ 
      std::ios_base::sync_with_stdio(false);
     // int t;cin>>t;
     /* while(t--)
      {
           
           
      }*/
      
      int a,b;cin>>a>>b;
      (a-(2*b))>0?(cout<<a-(2*b)):(cout<<0);
      return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n, i, a, b, c, judge[1000] = {0};

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%d %d %d", &a, &b, &c);
		if((a*a == b*b + c*c) || (b*b == a*a + c*c) || (c*c == a*a + b*b)){
			judge[i] = 1;
		}
	}

	for(i = 0; i < n; i++){
		if(judge[i] == 1){
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}

	return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  string c[3];

  REP(i, 3) { cin >> c[i]; }

  cout << c[0][0] << c[1][1] << c[2][2] << "\n";
}

Measured memory_bytes: 256
//  Created by conan1024hao on 2019/11/26.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //------------------------------
    int n;
    cin>>n;
    vector<int>h(n);
    for(int i=0;i<n;i++)
        cin>>h[i];
    //cout<<75+96+100-50<<endl;
    int sum=0;
    for(int i=0;i<n-1;i++){
        if(h[i]>h[i+1]){
            sum+=h[i];
            sum-=h[i+1];
        }
    }
   
        sum+=h[n-1];
    cout<<sum<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

int main(){
    int X,ok[3]={3,5,7},i;
    cin >> X;
    for(i=0;i<3;i++){
        if(X==ok[i]){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final long A = Integer.parseInt(sc.next());
        final long B = Integer.parseInt(sc.next());
        long ans = 0;
        
        for (int i = 1; i <= B; i++) {
            if (A * i % B == 0) {
                ans = A * i;
                break;
            }
        }
        
        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 22608
import sys
input = sys.stdin.readline
from collections import deque
n = int(input())
stone = [0]+list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
deg = [0]*(n+1)
for a,b in ab:
  if stone[a] < stone[b]:
    graph[a].append(b)
    deg[b] += 1
  elif stone[a] > stone[b]:
    graph[b].append(a)
    deg[a] += 1
que = deque()
dp = [[] for i in range(n+1)]
wl = [0]*(n+1)
ans = []
for i in range(1,n+1):
  if deg[i] == 0:
    que.append(i)
    wl[i] = 0
while que:
  x = que.popleft()
  if dp[x]:
    if dp[x].count(0) >= 1:
      ans.append(x)
      wl[x] = 1
  for y in graph[x]:
    if deg[y]:
      dp[y].append(wl[x])
      deg[y] -= 1
    if deg[y] == 0:
      que.append(y)
ans.sort()
print(*ans)

Measured memory_bytes: 5100
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

int dp[100][4][2];

string N;
int K;

int process(int idx, int count, int limit)
{
	if (idx == N.size())
	{
		if (count == K) return 1;
		else return 0;
	}
	else if (count > K) return 0;
	
	int& ret = dp[idx][count][limit];
	if (ret != -1) return ret;
	ret = 0;

	int digit_max = 9;
	if (limit == 1)
	{
		digit_max = N[idx] - '0';
	}


	for (int i = 0; i <= digit_max; i++)
	{
		int next_count = count;
		if (i != 0)
		{
			next_count++;
		}

		int next_limit = 0;
		if (i == digit_max)
		{
			next_limit = 1;
		}

		ret += process(idx + 1, next_count, limit && next_limit);
	}

	return ret;
}

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

	fill_n(&dp[0][0][0], sizeof(dp) / sizeof(int), -1);

	cin >> N;
	cin >> K;

	cout << process(0, 0, 1);

	return 0;
}

Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<ll> a(n-1), b(n-1);
    vector<vector<pair<ll, ll>>> g(n);
    vector<ll> deg(n, 0);
    REP(i, n-1) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        deg[a[i]]++; deg[b[i]]++;
        g[a[i]].emplace_back(b[i], i);
        g[b[i]].emplace_back(a[i], i);
    }

    ll k = *max_element(ALL_OF(deg));


    vector<ll> ans(n-1, -1);
    vector<ll> vst(n, false), toc(n, -1);
    deque<ll> q = {0};
    vst[0] = true;
    while (q.size()) {
        ll u = q.front(); q.pop_front();
        ll c = 0;
        for (pair<ll, ll> &p : g[u]) {
            ll v, e; tie(v, e) = p;
            if (!vst[v]) {
                vst[v] = true;
                q.push_back(v);
                if (c == toc[u]) c++;
                ans[e] = toc[v] = c;
                c++;
            }
        }
    }

    cout << k << endl;
    REP(i, n-1) {
        cout << ans[i]+1 << endl;
    }


}

Measured memory_bytes: 12800
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    N -= 1
    N //= 999
    s = ord('C') + N
    print('AB' + chr(s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9980
#include<stdio.h>
#include<math.h>
int main(){
    double n,k;
    scanf("%lf %lf",&n,&k);
    double i;
    double sum;
    double no;
    for(i=1;i<=n;i++){
        no = ceil(log2(k/i));
        if(i>=k){
            sum += 1/n;
        }
        else{
        //printf("確率 = %lf ",1/n * pow(0.5,no));
        sum += 1/n * pow(0.5,no);

        }
    }
    printf("%.20f\n",sum);
    return 0;
}

Measured memory_bytes: 128
def check_prime(num):
    if num == 2:
        return True

    if num < 2 or num % 2 == 0:
        return False

    return pow(2,num-1,num) == 1

cnt_num = int(input())
dataset = [int(input()) for i in range(cnt_num)]

count = 0
for i in dataset:
    if check_prime(i):
        count += 1

print(count)

Measured memory_bytes: 7984
#include<iostream>
#include<algorithm>

int main(){
  int a, b, c;
  std::cin >> a >> b >> c;
  int A[3];
  A[0] = a;
  A[1] = b;
  A[2] = c;
  std::sort(A, A + 3);
  std::cout << A[0] + A[1] << std::endl;
}


Measured memory_bytes: 256
/*  ex4_3 Stone Monument
    pandacodeb  */

#include <stdio.h>

int findDepth(int west, int east);

int main(void){
    int west, east;
    scanf("%d %d", &west, &east);
    printf("%d\n", findDepth(west, east));      //雪の厚さの計算
    return 0;
}

int findDepth(int west, int east){
    int n = east - west;                        //西側と東側の残り部分の高さの差 n で、西側の高さが得られる
    int sum = 0;
    for (int i = 1; i < n; i++){
        sum += i;                               // 1+2+3+...+(n-1) の計算
    }
    int depth = sum - west;                     // depth = 西側の本当の高さ - 残り部分の高さ
    return depth;
}

Measured memory_bytes: 128
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int min = Integer.MAX_VALUE;
    int cnt = 0;
    for(int i=0; i<N; i++){
      int tmp = sc.nextInt();
      if( tmp < min ){
        min = Math.min(min, tmp);
        cnt++;
      }
    }
    System.out.print(cnt);
  }
}


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

int main() {
    int64_t n, a, b;
    cin >> n >> a >> b;
    int64_t r = n%(a+b);
    int64_t k = n/(a+b);
    int64_t ans = k*a+min(r,a);
    cout << ans << endl;
}


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

int main()
{ 
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a[3];
		int max = 0;
		for (int j = 0; j < 3; j++) {
			cin >> a[j];
			if (a[max] < a[j]) {
				max = j;
			}
		}
		if (a[max] * a[max] == a[0] * a[0] + a[1] * a[1] + a[2] * a[2] - a[max] * a[max])cout << "YES" << endl;
		else cout << "NO" << endl;
	}
    return 0;
}


Measured memory_bytes: 3096
<?php
fscanf(STDIN,"%d %d",$a,$b);

$a_arr=yakusu($a);
$b_arr=yakusu($b);

$arr=array_intersect($a_arr,$b_arr);
$val=array_unique($arr);
asort($val);
$n_val=array_values($val);
//print_r($val);
$cnt=0;
for($i=0;$i<count($n_val);$i++){
	if(is_prime($n_val[$i])){
		$cnt++;
	}
}
echo $cnt+1;

function yakusu($target) {
	$limit = ceil(sqrt($target));
	for($i=1;$i<=$limit;$i++) {
		if($target%$i == 0) {
			$divisor_array[] = $i;
			$j = $target/$i;
			if ($i!=$j) {
				$divisor_array[] = $j;
			}
		}
	}
	return $divisor_array;
}

function is_prime($n){
    if($n < 2) {
        return false;
    } else if ($n == 2) {
        return true;
    }
    if($n % 2 == 0) {
        return false;
    }
    for ($i = 3; $i * $i <= $n; $i += 2) {
        if ($n % $i == 0) {
            return false;
        }
    }
    return true;
}
?>

Measured memory_bytes: 7412
# -*- coding: utf-8 -*-
s = list(input())

n = len(s)
ans = "Yes"
for i in range(n // 2):
    if s[i] != s[n-i-1]:
        ans = "No"
        #print("A")

m = (n - 1) // 2
#print(m)
for i in range(m // 2):
    if s[i] != s[m-i-1]:
        #print(i, m-i)
        ans = "No"
        #print("B")

k = (n + 3) // 2
for i in range(k, (n-k-1)//2):
    if s[i] != s[n+k-1-i]:
        ans = "No"
        #print("C")

print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        //String s = sc.next();
        
        int tmp=0;
        if(a<b){
            tmp = b;
            b=a;
            a=tmp;
        }
        //a>bになった
        while(a%b>0){
            tmp=a%b;
            a=b;
            b=tmp;
        }
        
        int k = Integer.parseInt(sc.next());
        tmp=0;
        int i=b+1;
        while(tmp<k){
            i--;
            if(b%i==0) tmp++;
        }
        
        System.out.println(i);
    }
}

Measured memory_bytes: 23764
package main

import (
	"bufio"
	"fmt"
	"os"
)

const INF int = int(1e9) + 1

func FroydWarshall(edge [][]int) [][]int {
	n := len(edge)
	dist := make([][]int, n)
	for i := 0; i < n; i++ {
		dist[i] = make([]int, n)
		for j := 0; j < n; j++ {
			dist[i][j] = edge[i][j]
		}
		dist[i][i] = 0
	}

	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				if dist[i][j] > dist[i][k]+dist[k][j] {
					dist[i][j] = dist[i][k] + dist[k][j]
				}
			}
		}
	}

	return dist
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n, m, l int
	fmt.Fscan(r, &n, &m, &l)
	e := make([][]int, n)
	for i := 0; i < n; i++ {
		e[i] = make([]int, n)
		for j := 0; j < n; j++ {
			e[i][j] = INF
		}
	}

	for i := 0; i < m; i++ {
		var a, b, c int
		fmt.Fscan(r, &a, &b, &c)
		a--
		b--
		e[a][b] = c
		e[b][a] = c
	}

	var q int
	fmt.Fscan(r, &q)
	s := make([]int, q)
	t := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Fscan(r, &s[i], &t[i])
		s[i]--
		t[i]--
	}

	dist := FroydWarshall(e)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if dist[i][j] <= l {
				e[i][j] = 1
			} else {
				e[i][j] = INF
			}
		}
	}
	dist = FroydWarshall(e)

	for i := 0; i < q; i++ {
		ans := dist[s[i]][t[i]]
		if ans == INF {
			fmt.Fprintln(w, -1)
		} else {
			fmt.Fprintln(w, ans-1)
		}
	}
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=2e3,INF=1e9+8;

int N,K,Q,A[MAX_N];

int main(){
	cin>>N>>K>>Q;
	REP(i,N){
		cin>>A[i];
	}
	int ans=INF;
	set<int> inte{0};
	REP(s,N){
		multiset<int> st;
		for(auto ite=inte.begin();ite!=inte.end();ite++){
			auto ite2=ite;
			ite2++;
			int t;
			if (ite2==inte.end()){
				t=N+1;
			}else{
				t=*ite2;
			}
			if (t-*ite-1>=K){
				multiset<int> temp;
				FOR(i,*ite,t-1){
					temp.insert(A[i]);
				}
				{
					auto i=temp.begin();
					REP(j,t-*ite-K){
						st.insert(*i);
						i++;
					}
				}
			}
		}
		if (st.size()>=Q){
			int mn,mx;
			auto ite=st.begin();
			mn=*ite;
			REP(i,Q-1){
				ite++;
			}
			mx=*ite;
			ans=min(ans,mx-mn);
			REP(i,N){
				if (A[i]==mn){
					inte.insert(i+1);
				}
			}
		}else{
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.Math;
public class Main{
	public static void main(String [] args){
		Scanner in = new Scanner(System.in);
		double a = in.nextInt();
		double b = in.nextInt();
		for(int i=0;i<=1000;i++){
			double x = Math.floor(i*0.08);
			double y = Math.floor(i*0.1);
			if(x==a && y==b){
				System.out.print(i);
				break;
			}
			else if(i==1000){
				System.out.print("-1");
			}
			
		}
	}
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
#define PB push_back
int n,s[100005],ans;
char x[100005];
bool o=false;
int main(void){
	scanf(" %s",x);
	n=strlen(x);
	ans=n;
	x[n]='0';
	for(int i=1;i<=n+1;i++){
		if(x[i-1]=='1')s[i]=1,o=true;
		if(s[i-1]!=s[i]){
			ans=min(ans,max(i-1,n-i+1));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;

int main() {
	static long long N, A[100010], B[100000], ANS = 0;
	cin >> N;
	for (int i = 0; i <= N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N; i++) {
		if (A[i] >= B[i]) {
			A[i] -= B[i];
			ANS += B[i];
		}
		else if (A[i] + A[i + 1] >= B[i]) {
			A[i + 1] -= B[i] - A[i];
			A[i] = 0;
			ANS += B[i];
		}
		else {
			ANS += A[i] + A[i + 1];
			A[i] = 0;
			A[i + 1] = 0;
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 1792
def main():
    N, K = map(int, input().split())
    *A, = map(int, input().split())

    def bit60(x):
        *bit, = map(int, bin(x)[2:])
        zfill = 60 - len(bit)
        ret = [0] * zfill
        ret += bit
        return ret

    # print(*map(bit60, A))

    ctr = [0] * 60
    for bit in map(bit60, A):
        for j in range(60):
            ctr[j] += bit[j]

    ans = 0
    d = 1 << (60 - 1)
    x = 0
    for j in range(60):
        if (ctr[j] < N - ctr[j]) and (x + d <= K):  # フラグを立てた方が得する
            x += d
            ans += (N - ctr[j]) * d
        else:
            ans += ctr[j] * d
        d >>= 1
    print(ans)


if __name__ == '__main__':
    main()


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

#define ll long long

int main() {
	// your code goes here
	ll a, b, c, n;
	cin >> n;
	vector<pair<string, ll>> s(n);
	for(ll i = 0; i < n; i++){
		string ss;
		ll p;
		cin >> ss >> p;
		if(p > 90 && p != 100){
			ss += "0";
			ss += to_string(10 - (p % 10));
		}else if (p < 10 && p != 0){
			ss += "9";
			ss += to_string(10 - (p % 10));
		}else if(p == 100){
			ss+= "000";
		}else if(p == 0){
			ss += "9999";
		}else{
			ss += to_string(100 - p);
		}
		s[i] = make_pair(ss ,i + 1);
	}
	sort(s.begin(), s.end());
	for(int i = 0 ; i < n; i++){
		cout <<s[i].second << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)
#define srt(vec) sort(vec_all(vec))

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

// --- notice ---
// intの和はllにしろ

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

    vector<pair<int, bool>> colors;
    colors.push_back(make_pair(400, false));
    colors.push_back(make_pair(800, false));
    colors.push_back(make_pair(1200, false));
    colors.push_back(make_pair(1600, false));
    colors.push_back(make_pair(2000, false));
    colors.push_back(make_pair(2400, false));
    colors.push_back(make_pair(2800, false));
    colors.push_back(make_pair(3200, false));
    int ext = 0;

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

    rep(i, n) {
        rep(j, colors.size()) {
            if (a[i] < colors[j].first) {
                colors[j].second = true;
                break;
            }
        }

        if (a[i] >= 3200) {
            ext++;
        }
    }

    int norm = 0;
    for (auto c : colors) {
        if (c.second) {
            norm++;
        }
    }

    int min;
    if (norm == 0) {
        min = 1;
    } else {
        min = norm;
    }

    cout << min << " " << norm + ext << endl;
    return 0;
}

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

int main(){
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	
	double M = 6*m;
	double H = 30*h+m/2;
	double ans;
/*	if (M == H) {
		if (a > b) {
			ans = a - b;
		} else {
			ans = b - a;
		}
		cout << ans << endl;
		return 0;
	}
*/	
	double pi = acos(-1);
//	if (M > H) {
		ans = a*a + b*b - 2*a*b*cos(pi*(M-H)/180.0);
//      cout << (M-H)/180 << cos(pi*(M-H)/180.0) << endl;
/*	} else if (M < H) {
		ans = a*a + b*b - 2*a*b*cos(pi*(H-M)/180.0);
//      cout << H-M << cos(pi*(H-M)/180.0) << endl;
	}
    */
	cout << fixed << setprecision(20) << sqrt(ans) << endl;
}


Measured memory_bytes: 4228
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <map>

using namespace std;

void solve()
{
	int N;
	cin >> N;
	vector<int> T(N);
	int sum = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> T[i];
		sum += T[i];
	}
	int M;
	cin >> M;
	for (int i = 0; i < M; ++i)
	{
		int P, X;
		cin >> P >> X;
		cout << sum - T[P - 1] + X << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
import Control.Applicative

import Data.List
    (intercalate)
    
type Problem = [String]

type Result = [String]

runlength :: String -> String -> String

runlength text ""
    = text
    
runlength text ('@':n:x:xs)
    = runlength (text ++ open) xs where
        time = read [n]
        open = replicate time x
        
runlength text (x:xs)
    = runlength (text ++ [x]) xs
    
solve :: Problem -> Result

solve list
    = map (runlength "") list
        
main :: IO ()

main
    = do
        list <- lines <$> getContents
        putStrLn $ intercalate "\n" $ solve list

Measured memory_bytes: 3744
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll check(ll A, ll C){
    ll B = A / C - 1;
    if(B == 0)return 0;
    if((A / B) == (A % B))return B;
    return 0;
}

int main(){

    ll N;
    cin >> N;
    ll ans = 0; 
    for(ll i = 1; i * i <= N; i++){
        if(N % i)continue;
        ans += check(N, i);
        if(N / i > i)ans += check(N, N / i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

class UnionFind():
    def __init__(self, X):
        self.n = len(X)
        self.parents = [-x for x in X]

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
n, m = map(int, input().split())
X = [0] + list(map(int, input().split()))
edge = []
for _ in range(m):
  a, b, y = map(int, input().split())
  edge.append((y, a, b))
edge.sort()
G = [[] for _ in range(n+1)]
for y, a, b in edge:
  G[a].append((b, y))
  G[b].append((a, y))
uf = UnionFind(X)
T = []
for y, a, b in edge:
  uf.unite(a, b)
  if uf.size(a) >= y:
    T.append(1)
  else:
    T.append(0)
seen = [False]*(n+1)
used = set()
cnt = 0

def dfs(e):
  y, a, b = edge[e]
  res = 0
  seen[a] = True
  stack = [a]
  while stack:
    v = stack.pop()
    for nv, cost in G[v]:
      if cost > y:
        continue
      if (v, nv) in used:
        continue
      res += 1
      used.add((v, nv))
      used.add((nv, v))
      if seen[nv]:
        continue
      stack.append(nv)
      seen[nv] = True
  return res
for i in range(m-1, -1, -1):
  if T[i] and not seen[edge[i][1]]:
    cnt += dfs(i)
ans = m - cnt
print(ans)

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

int main(){
	int W,H,x,y,r;

	cin >> W >> H >> x >> y >> r;


	if( x-r>=0 && W>=x+r && y-r>=0 &&  H>=y+r){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	
	return 0;
}

Measured memory_bytes: 1128
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

int main() {
	
	ll N, A, B;
	string S;
	cin >> N >> A >> B >> S;

	ll p = 0;
	ll f = 0;

	rep(i, N) {
		if (S[i] == 'a') {
			if (p < A + B) {
				cout << "Yes" << endl;
				p++;
			}
			else { cout << "No" << endl; }
		}

		else if (S[i] == 'b') {
			if (p < A + B && f < B) {
				cout << "Yes" << endl;
				p++;
				f++;
			}
			else { cout << "No" << endl; }
		}
		else { cout << "No" << endl; }
	}

	system("PAUSE");
}


Measured memory_bytes: 1144
using System;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        StringBuilder S = new StringBuilder(Console.ReadLine());
        int q = int.Parse(Console.ReadLine());

        bool isOdd = false;

        StringBuilder front = new StringBuilder("");
        StringBuilder last = new StringBuilder("");

        for (int i = 0; i < q; i++)
        {
            string[] inputs = Console.ReadLine().Split(' ');

            if (inputs[0] == "1")
            {
                isOdd = !isOdd;
            }
            else
            {
                if (isOdd)
                {
                    if (inputs[1] == "2") front.Append(inputs[2]);
                    else last.Append(inputs[2]);
                }
                else
                {
                    if (inputs[1] == "1") front.Append(inputs[2]);
                    else last.Append(inputs[2]);
                }
            }
        }

        string answer = string.Join("",front.ToString().Reverse().ToArray()) + S + last;

        if (isOdd) Console.WriteLine(answer.Reverse().ToArray());
        else Console.WriteLine(answer);
    }
}

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

int main()
{
  string s;
  int k=0;
  cin >> s;
  for(int i=0; i < s.size() ;i++){
    if(s[i] == 'C')
      k = 1;
    if(s[i] == 'F' && k == 1){
      k = 2;
      cout << "Yes" << endl;
    }
  }
  if(k != 2 ) cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 384