akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(ll 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() {
    string S;
    cin >> S;
    int N = S.size();

    int ans = 0;
    int before = 0;
    for(auto e:S){
        if(e == 'A'||e=='T'||e=='C'||e=='G'){
            ++before;
            ans = max(ans,before);
        } else {
            before = 0;
        }
    }
    ans = max(ans,before);
    cout << ans << endl;
    
}

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

int main() {

int N,X;
cin >> N >> X;

vector<int> D(N + 2),L(N + 1);
for(int i = 1; i <= N; i++) {
  cin >> L.at(i);
}

D.at(1) = 0;
for(int i = 2; i <= N + 1;i++) {
  D.at(i) = D.at(i - 1) + L.at(i - 1);
}

int ans = 0;
for(int i = 1; i <= N + 1; i++) {
  if(D.at(i) <= X) ans++;
}

cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, k;
	cin>>a>>b>>c>>k;
	if(a<b) swap(a,b);
	if(a<c) swap(a,c);
	for(int i=0;i<k;i++)
		a*=2;
	cout<<a+b+c;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int isprime(int);
int main()
{
  int n,i,j,count=0;
  int x;

  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&x);
    if(!isprime(x)) count++;
  }
  
  printf("%d\n",count);
    
  return 0;
}

int isprime(int x) 
{
  int i=3;
  if(x==2) return 0;
  else if(x<2 || x%2==0) return	1;
  else {
    while(i<=sqrt(x)){
      if(x%i==0) return 1;
      i += 2;
    }
  }
  return 0;
}
  

Measured memory_bytes: 596
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    int base[3] = {0};
    char happend[50];
    int score, counts, n, i, j;
 
    scanf("%d\n", &n);
     
 
    for (i = 0; i < n; i++)
    {
        counts = 0;
        score = 0;
 
        while (counts != 3)
        {
            gets(happend);
 
            if (strcmp(happend, "HIT") == 0)
            {
                if (base[2] == 1)
                {
                    score++;
                    base[2] = 0;
                }
                if (base[1] == 1)
                {
                    base[2]++;
                    base[1] = 0;
                }
                if (base[0] == 1)
                {
                    base[1]++;
                    base[0] = 0;
                }
                base[0]++;
            }
            else if (strcmp(happend, "HOMERUN") == 0)
            {
                for (j = 0; j < 3; j++)
                    if (base[j] == 1)
                    {
                        base[j] = 0;
                        score++;
                    }
                score++;
            }
            else if (strcmp(happend, "OUT") == 0)
                counts++;
        }
 
        base[0] = 0;
        base[1] = 0;
        base[2] = 0;
 
        printf("%d\n", score);
    }
 
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define ALL(c) (c).begin(),(c).end()
int parent[17][100000],depth[100000];
vector<int> G[100000];
void dfs(int v,int p,int d){
	parent[0][v]=p;
	depth[v]=d;
	rep(i,G[v].size()) dfs(G[v][i],v,d+1);
}
void init(int n){
	dfs(0,-1,0);
	rep(i,16){
		rep(j,n){
			if(parent[i][j]<0) parent[i+1][j]=-1;
			else parent[i+1][j]=parent[i][parent[i][j]];
		}
	}
}
int lca(int u,int v){
	if(depth[u]>depth[v]) swap(u,v);
	rep(i,17) if(((depth[v]-depth[u])>>i) & 1) v=parent[i][v];
	if(u==v) return u;
	for(int i=16;i>=0;i--){
		if(parent[i][u]!=parent[i][v]){
			u=parent[i][u];
			v=parent[i][v];
		}
	}
	return parent[0][u];
}
int main(){
	int n,cnt=0,prev=0;
	long long ans=0;
	cin >> n;
	rep1(i,n-1){
		int p;
		cin >> p;
		G[p-1].push_back(i);
	}
	init(n);
	queue<int> q;
	q.push(0);
	while(!q.empty()){
		int p=q.front();
		q.pop();
		ans+=(depth[p]+depth[prev]-2*depth[lca(p,prev)]);
		rep(i,G[p].size()) q.push(G[p][i]);
		prev=p;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<int64_t> table(n + 1, 1ll);
	for (int i{2}; i <= n; i++)
		table[i] = table[i - 1] + table[i - 2];
	printf("%lld\n", table[n]);

	return 0;
}


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

int main(){
    ll int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a>0&&c>>0){
        c-=b;
        if(c<=0){
            cout << "Yes";
            return 0;
        }
        a-=d;
        if(a<=0){
            cout << "No";
            return 0;
        }
    }
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <stack>
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
const int MAX=1e5+5;
const int INF=1e9+5;
const double M=4e18;
using namespace std;
const int MOD=1e9+7;
typedef pair<int,int> pii;
const double eps=0.000000001;
struct node
{
    ll num,zhi;
};
bool cmp(node x,node y)
{
    if(x.zhi!=y.zhi)
        return x.zhi<y.zhi;
    else
        return x.num<y.num;
}
ll he[MAX];
node a[MAX];
ll n,k;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    he[0]=0LL;
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i].zhi>>a[i].num;
    }
    sort(a+1,a+1+n,cmp);
    for(ll i=1;i<=n;i++)
    {
        he[i]=he[i-1]+a[i].num;
        if(he[i]>=k)
        {
            cout<<a[i].zhi<<"\n";return 0;
        }
    }
    return 0;
}


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

string a,b;

inline int read(void){
    int x=0,f=1;
    char ch=getchar();
    for(;!isdigit(ch);ch=getchar())
        if(ch=='-')
            f=-f;
    for(;isdigit(ch);ch=getchar())
        x=(x<<3)+(x<<1)+(ch&15);
    return x*f;
}

int main(void){
    cin>>a;
    b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();++i){
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  lint N,check=0;
  cin >> N;
  int A[N];
  rep(i,N) cin >> A[i];
  sort(A,A+N);
  if(N%2==0){
    if(A[0]==0) check=1;
    for(int i=0;i<N;i+=2) if(A[i]!=A[i+1]) check=1;
  }
  else{
    if(A[0]!=0) check=1;
    for(int i=1;i<N;i+=2) if(A[i]!=A[i+1]) check=1;
  }
  if(check==1) cout << "0" << endl;
  else{
    lint ans=1;
    lint count=N/2;
    rep(i,count) ans=(ans*2)%MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define vpll vector <pll>
#define pb push_back

int main()
{
    int i=0;
  string s;
  cin>>s;
  if((s[i]=='A' && s[i+1]=='A' && s[i+2]=='A') || (s[i]=='B' && s[i+1]=='B' && s[i+2]=='B'))
    cout<<"No";
  else cout<<"Yes";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    //#include <ext/pb_ds/assoc_container.hpp>
    //using namespace __gnu_pbds;
    //typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
    // #include <ext/rope>
    // using namespace __gnu_cxx;
    typedef long long int ll;
    typedef long double ld;
    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define rep(g, i, n) for (ll g = i; g < n; g++)
    #define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
    #define all(v) v.begin(), v.end()
    #define pb push_back
    #define mxe(v) *max_element(v.begin(),v.end())
    #define mne(v) *min_element(v.begin(),v.end())
    #define ve vector
    #define lb lower_bound
    #define ub upper_bound
    #define bb break
    #define cc continue
    #define rem 1000000007
    #define PI 3.141592653589793238462643383279502
    ll power(ll x, ll y, ll p) 
    { 
        ll res = 1;      // Initialize result 
        x = x % p;  // Update x if it is more than or 
        while (y > 0) 
        { 
            if (y & 1) 
                res = (res*x) % p; 
            y = y>>1; // y = y/2 
            x = (x*x) % p; 
        } 
        return res; 
    } 
    ll modInverse(ll n, ll p) 
    { 
        return power(n, p-2, p); 
    } 
    struct point
    {
        ll x,y;
    };
    int main()
    {
        FAST
        // freopen("input1.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        /*ll tests;
        cin>>tests;
        rep (gg,0,tests)
        {}*/
        string s;
        cin>>s;
        if (s=="ABC")
        {
            cout<<"ARC";
        }
        else
        {
            cout<<"ABC";
        }
        
    }


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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>void __f(const char* name, Arg1&& arg1){cout<<name<<" : "<<arg1<<"\n";}
template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args)
{const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);} 
#define traceloop(x,a) { cerr<<#a<<": "; for(ll ix=0;ix<x;ix++) cerr<<a[ix]<<" "; cerr<<endl; }

int main()
{
	ios::sync_with_stdio(0);

	int n, i, j, m;
	cin>>n>>m;
	vector<pii> v;
	for(i=0;i<n;++i)
	{
		int u, v1;
		cin>>u>>v1;
		v.pb({u, v1});
	}

	sort(v.begin(), v.end());
	priority_queue<int> pq;

	i = j = 0;
	ll ans = 0;
	for(i=1;i<=m;++i)
	{
		while(j < n and v[j].first <= i)
		{
			pq.push(v[j].second);
			j++;
		}

		if(!pq.empty())
		{
			ans += pq.top();
			pq.pop();
		}
	}

	cout << ans << "\n";

	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (i < b){
				if (j < a)
					cout << '0';
				else
					cout << '1';
			}
			else{
				if (j < a)
					cout << '1';
				else
					cout << '0';
			}
		}
		cout << '\n';
	}
}


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

using namespace std;

typedef long long int ll;


void solve(){
	
	ll n; cin>>n;
	
	ll a[n],b[n];
	
	for(int i=0; i<n; i++){
		cin>>a[i]>>b[i];
	}
	
	ll ans=0,curr=0;
	
	for(int i=0; i<n; i++){
		if(a[i]==b[i]){
			curr++;
		}
		else{
			ans=max(ans,curr);
			curr=0;
		}
	}
	
	ans=max(ans,curr);
	
	if(ans>=3){
		cout<<"Yes"<<"\n";
	}
	else{
		cout<<"No"<<"\n";
	}
	
	return;
}




int main() {
	
	
	

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

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

int main(){
    int N, M;
    cin >> N >> M;
    int LL, LR, RL, RR;
    LL = 1;
    LR = N / 2;
    RL = LR + 1;
    RR = N;
    if(N % 2 == 0) LR--;
    int count = 0;
    while(true){
        cout << RL << " " << RR << endl;
        count++;
        if(count == M) break;
        RL++;
        RR--;
        cout << LL << " " << LR << endl;
        count++;
        if(count == M) break;
        LL++;
        LR--;
    }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
ll num[12];
int main()
{
    //IOS;
    string s,t;
    while(cin>>s>>t)
    {
        ll sum=0;
        rep(i,s.size())
        {
            if(s[i]==t[i]) sum++;
        }
        cout<<sum<<"\n";
    }

    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  // scanf("%d",&A[1]);
  //for(i=1;i<=n;i++){
    
    //  printf("%d %d %d\n",i,A[i],n);
  // }
  // for(i=1;i<=n;i++){
  // if(i-1)printf(" ");
  //  printf("%d",A[i]);
  // }
  // printf("\n");
  
  for(i=0;i<=VMAX;i++)C[i] = 0;

  for(j=1;j<=n;j++){
    scanf("%u",&A[j]);
    C[A[j]]++;
    
  }
 
  for(i=1;i<=VMAX;i++)C[i]+=C[i-1];
  //printf("aaaaaaaa\n");
  for(j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
    // printf("aaaaaaaa\n");
    // printf("aaa:%d  ",A[j]);
  }
  //printf("B:");
  for(i=1;i<=n;i++){
    if(i-1)printf(" ");
    printf("%u",B[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 9560
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] input = sc.next().toCharArray();
        Stack<Character> stack = new Stack<>();
        for(char c: input){
            if(!stack.empty()){
                if(stack.peek() == 'S' && c == 'T')
                    stack.pop();
                else
                    stack.push(c);
            }else{
                stack.push(c);
            }
        }
        StringBuilder result = new StringBuilder("");
        while(!stack.empty()){
            result.append(stack.pop());
        }
        System.out.println(result.length());
    }
}

Measured memory_bytes: 44476
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int k;
  string s;
  cin >> k >> s;
  mint ans = 0;
  int n = s.size();
  combination comb(n + k);

  // 使う数をi
  rep(i, k + 1) {
    mint cur = mint(26).pow(k - i);
    cur *= mint(25).pow(i);
    cur *= comb(n - 1 + i, n - 1);
    ans += cur;
  }

  cout << ans << endl;
}

Measured memory_bytes: 35564
#include <bits/stdc++.h>    
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
const int inf = 2e9;
using namespace std;
ll MOD = 1000000007;
typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;



ll ans = 0, sum = 0;
int n,k,a,b,minimo;
int A[1000], B[1000];
map<ii,bool> M;
set<ii> S;



void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}
void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

bool ord(ii a, ii b){
	return b.second<a.second;
}

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

	for(int i=1; i<=n; i++){
		for(int j=i+1; j<=n; j++){
			S.insert({i,j});
		}
	}

	if(n%2==0){
		for(int i=1; i<=n/2; i++){
			S.erase({i,n-i+1});
		}
	} else {
		for(int i=1; i<=(n-1)/2; i++){
			S.erase({i,n-i});
		}
	}

	printf("%d\n", int(S.size()));
	for(auto a:S) printf("%d %d\n",a.first,a.second);

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0

signed main() {
	int x, y;
	cin >> x;
	y = x / 11;
	x %= 11;
	if (x == 0)cout << y * 2 << endl;
	else if (x <= 6)cout << y * 2 + 1 << endl;
	else cout << y * 2 + 2 << endl;

	END;
}

Measured memory_bytes: 764
using System;

class Program
{
    static void Main()
    {
    	var s = Console.ReadLine().Split(' ');
    	var x1 = double.Parse(s[0]);
    	var y1 = double.Parse(s[1]);
    	var x2 = double.Parse(s[2]);
    	var y2 = double.Parse(s[3]);
    	
    	Console.WriteLine( Math.Sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) );
    }
}

Measured memory_bytes: 9240
// luogu-judger-enable-o2
#include<cstdio>
using namespace std;
int n,m,a[105],ans;
int main(){
	scanf("%d",&n);
	for (register int i=1;i<=n;++i) scanf("%d",&a[i]),ans+=a[i];
	scanf("%d",&m);
	for (register int i=1,x,y;i<=m;++i) scanf("%d%d",&x,&y),printf("%d\n",ans-a[x]+y);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
int N,L;
struct Point{long long x;double y;}Q[500010];
int main(){
	scanf("%d%d",&N,&L);
	Point*H=Q,*T=Q;
	for(int i=N;i--;){
		int t,v;
		scanf("%d%d",&t,&v);
		while(H->x-T->x>L-v){
			if(H[1].x-T->x>L-v)++H;
			else H->y=H[1].y+(H->y-H[1].y)*(T->x+L-v-H[1].x)/(H->x-H[1].x),H->x=T->x+L-v;
		}
		Point p=(Point){T->x-v,T->y-1ll*t*v};
		while(H<T&&(p.y-T->y)*(T->x-T[-1].x)<=(T->y-T[-1].y)*(p.x-T->x))--T;
		*++T=p;
		printf("%.12lf\n",(H->y-T->y)/L);
	}
} 

Measured memory_bytes: 19200
import collections

N = int(input())
As = list(map(int, input().split()))

cnt = collections.Counter(As)
sm = 0 
#print(cnt)

for k in cnt:
  sm += cnt[k]*(cnt[k]-1)//2
  
for i in range(N):
  print(sm -(cnt[As[i]]-1))

Measured memory_bytes: 87756
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int n;
vi adj[100001];
ll a[100001];
ll dp[100001];
ll sumleaf[100001];

ll solve(vector<ll>& vec)
{
	if(vec.empty()) return 0;
	ll mx = 0;
	ll sum = 0;
	int k = vec.size();
	for(int i = 0; i < k; i++)
	{
		mx=max(mx,vec[i]);
		sum+=vec[i];
	}
	if(mx*2>sum)
	{
		return (sum-mx);
	}
	else
	{
		return sum/2;
	}
}

void prep(int u, int p)
{
	bool leaf=1;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		if(v==p) continue;
		leaf=0;
		prep(v,u);
		sumleaf[u]+=sumleaf[v];
	}
	if(leaf)
	{
		sumleaf[u]=a[u];
	}
}

ll dfs1(int u, int p)
{
	ll sum = 0;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		if(v==p) continue;
		ll val = dfs1(v,u);
		sum+=val;
		a[u] -= val*2;
	}
	sum+=a[u];
	return sum;
}
bool pos;
ll dfs2(int u, int p)
{
	ll sum = 0;
	vector<ll> vec;
	bool leaf=1;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		if(v==p) continue;
		leaf=0;
		ll val = dfs2(v,u);
		sum+=val;
		vec.pb(val);
	}
	if(leaf)
	{
		if(a[u]>0)
		{
			pos=0;
			return 0;
		}
		return sumleaf[u];
	}
	ll cnt = solve(vec);
	if(cnt<a[u])
	{
		pos=0;
		return 0;
	}
	//apply a[u] times;
	return (sum - ll(a[u])*2LL);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	pos=1;
	int n; cin>>n;
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
	}
	for(int i = 0; i + 1 < n; i++)
	{
		int u, v; cin>>u>>v;
		u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	if(n==2)
	{
		if(a[0]==a[1])
		{
			cout<<"YES\n";
		}
		else
		{
			cout<<"NO\n";
		}
		return 0;
	}
	int rt = 0;
	for(int i = 0; i < n; i++)
	{
		if(adj[i].size()!=1)
		{
			rt=i;
			break;
		}
	}
	prep(rt,-1);
	//cerr<<rt<<'\n';
	for(int i = 0; i < n; i++)
	{
		ll newa = (sumleaf[i] - a[i]);
		//cerr<<i<<' '<<sumleaf[i]<<' '<<a[i]<<' '<<newa<<'\n';
		/*
		if(newa&1)
		{
			cout<<"NO\n";
			return 0;
		}
		*/
		if(newa<0)
		{
			cout<<"NO\n";
			return 0;
		}
		//a[i]=newa/2;
		a[i]=newa;
	}
	dfs1(rt,-1);
	for(int i = 0; i < n; i++)
	{
		if(a[i]<0)
		{
			cout<<"NO\n";
			return 0;
		}
	}
	ll val = dfs2(rt,-1);
	if(pos&&val==0) cout<<"YES\n";
	else cout<<"NO\n";
}


Measured memory_bytes: 17920
#include<stdio.h>
#include<string.h>
int main()
{
int q,w;
char a[1000],b[1000],c[1000];
scanf("%s",a);
scanf("%s",b);
scanf("%s",c);
q=strlen(a);
w=strlen(b);
if(a[q-1]==b[0] && b[w-1]==c[0])
{printf("YES\n");}
else
{
printf("NO\n");}
return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll k;
  cin >> k;
  queue<ll> q;
  for (int i = 1; i <= 9; ++i) {
    q.push(i);
  }

  rep(i, k) {
    ll x = q.front(); q.pop();
    if (i == k-1) {
      cout << x << endl;
      return 0;
    }

    ll y = x * 10 + (x % 10);
    if (x % 10 != 0) { // e.g. 10 -> 100, 101
      q.push(y-1);
    }
    q.push(y);
    if (x % 10 != 9) { // e.g. 9 -> 98, 99
      q.push(y+1);
    }
  }
}


Measured memory_bytes: 1792
def main():
    import sys
    input = sys.stdin.readline
    
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    mod = 10**9+7
    
    fact = [1]
    fact_inv = [1]
    for i in range(10**5+5):
        fact.append(fact[-1]*(i+1)%mod)
        fact_inv.append(pow(fact[-1],mod-2,mod))
        
    def mod_comb_k(n,k,mod):
        return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod
    
    a.sort()
    
    res = 0
    for i in range(n-k+1):
        res = (res + (a[n-1-i]- a[i])*mod_comb_k(n-i-1,k-1,mod)%mod)%mod

    print(res)
if __name__ == '__main__':
    main()


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

bool isPrime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            return false;
        }
    }

    return true;
}

int main() {
    int N;
    cin >> N;
    vector<int> ans;
    for (int i = 6; i <= 55555; i += 5) {
        if (isPrime(i)) {
            ans.push_back(i);
        }
    }

    for (int i = 0; i < N; i++) {
        printf("%d%c", ans[i], i == N - 1 ? '\n' : ' ');
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);



    int n, t;
    cin >> n >> t;
    pair<int, int> a[n];
    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;

    ll dp[t][n][2];
    memset(dp, 0, sizeof dp);
    for (int time = a[0].first; time < t; time++) {
        dp[time][0][0] = a[0].second;
    }

    int maxi = 0;
    for (int i = 0; i < n; i++) {
        maxi = max(maxi, a[i].second);
        dp[0][i][1] = maxi;
    }

    for (int i = 1; i < n; i++) {
        for (int time = 1; time < t; time++) {
            dp[time][i][0] = max(dp[time][i - 1][0], dp[time - 1][i][0]);
            if (time - a[i].first >= 0) dp[time][i][0] = max(dp[time][i][0], dp[time - a[i].first][i - 1][0] + a[i].second);

            dp[time][i][1] = max({dp[time][i - 1][1], dp[time - 1][i][1], dp[time][i - 1][0] + a[i].second});
            if (time - a[i].first >= 0) dp[time][i][1] = max(dp[time][i][1], dp[time - a[i].first][i - 1][1] + a[i].second);
        }
    }

    cout << dp[t - 1][n - 1][1];

}


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

const int maxn = 200010;
int n, p[maxn], w[maxn], fa[maxn], col[maxn][2];
long long ans;

int find(int x) {
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}

struct node {
    int id;
    friend bool operator < (node x, node y) {
        int x0 = col[x.id][0], x1 = col[x.id][1];
        int y0 = col[y.id][0], y1 = col[y.id][1];
        return make_pair(1LL * x0 * y1, x.id) > make_pair(1LL * x1 * y0, y.id);
    }
};

int main() {
    scanf("%d", &n);
    for (int i = 2; i <= n; i++) {
        scanf("%d", &p[i]);
    }
    set<node> q;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &w[i]);
        col[fa[i] = i][w[i]]++;
    }
    for (int i = 2; i <= n; i++) {
        if (i ^ 1) q.insert((node){i});
    }
    while (!q.empty()) {
        int v = find(q.begin()->id); q.erase(q.begin());
        int u = find(p[v]); q.erase((node){u});
        ans += 1LL * col[v][0] * col[u][1];
        fa[v] = u, col[u][0] += col[v][0], col[u][1] += col[v][1];
        if (u ^ 1) q.insert((node){u});
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 13568
#include<stdio.h>
int main(void){
	int i,j,k,null;
	int y=0;
	int n=0;
	char s[27];
	scanf("%s",s);
	
	for(k=0;k<27;k++){
		if(s[k]=='\0'){
			null=k;
			break;
		}
	}
	for(i=0;i<null-1;i++){
		for(j=i+1;j<null;j++){
			if(s[i]==s[j]){
				n=n+1;
			}else if(s[i]!=s[j]){
				y=y+1;
			}		
		}

	}
	
	if(y-n == y){
		printf("yes\n");
	}else if(y-n != y){
		printf("no\n");
	}
}

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


int h[1<<17], dp[1<<17];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  cin >> h[0];
  for (int i = 1; i < n; ++i) {
    cin >> h[i];
    dp[i] = INT_MAX;
    for (int j = max(0, i - 2); j < i; ++j) {
      dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
    }
  }
  cout << dp[n - 1] << '\n';
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
a = [[1, 0] for _ in range(n)]
a[0][1] = 1
for i in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    a[x][0] -= 1
    a[y][0] += 1
    a[y][1] += a[x][1]
    if a[x][0] == 0:
        a[x][1] = 0
cnt = 0
for i in range(n):
    if a[i][1] > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 13172
import std.stdio, std.algorithm, core.bitop;

void main(){
	int A, B, K, ans;
	scanf("%d%d%d", &A, &B, &K);
	foreach(bit; 0..1<<10)if(popcnt(bit) <= K){
		ans = max(ans, test(A, B, bit));
	}
	writeln(ans);
}

int test(int A, int B, int bit){
	int carry = 0, ten = 1, C = 0;
	for(;A;A/=10, B/=10, ten*=10, bit>>=1){
		int x = A%10, y = B%10;
		if(x - carry >= y){
			C += ten * (x - carry - y);
			carry = 0;
		}
		else{
			C += ten * (x - carry + 10 - y);
			carry = (bit&1) ? 0 : 1;
		}
	}
	return C;
}

Measured memory_bytes: 1008
/*
AUTHOR : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com
*/

#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 100050

#define ll long long
#define ld long double
#define lli long long int

#define pb emplace_back
#define INF 1000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define loop(i,n) for (lli i = 0; i < n; i++)
#define loopitr(xt,vec) for (auto xt : vec)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)
#define loop_rev(i,n) for (lli i = n-1; i >= 0; i--)
#define FOR_REV(i,a,b) for (lli i = a; i >= b; i--)
#define itr :: iterator it
#define WL(t) while(t --)

#define all(v) v.begin(),v.end()
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>
#define vi vector<lli>
#define seti set<lli>
#define pii pair<lli,lli>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

template <typename T>
void print(T x){cout<<x<<endl;}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<endl;}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<endl;}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvector(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvector(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";
#define printset(st) for(auto xt : st) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define endl '\n'

#define deb(x) cout<<#x<<" "<<x<<endl;

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}

ll modmul(ll a, ll b) {
    return ((a%mod) * (b%mod)) % mod;
}

ll modadd(ll a , ll b){
    return((a%mod)+(b%mod)+mod)%mod;
}

ll modsub(ll a , ll b){
    return((a%mod) - (b%mod) + mod)%mod;
}

lli fastexpo(lli a,lli b ,lli MOD = mod){
    a = a%MOD;
    //b = b%(mod-1); // if mod is prime then only
    lli ans=1;
    while(b){
        if(b&1)
            ans=(ans*1ll*a)%MOD;
        a=(a*1ll*a)%MOD;
        b=b/2;
        }
    return ans;
 }
 

int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
    lli n,a,b,c;
    string s;
    cin>>a>>b>>c;
    lli cnt=0;
    FOR(i,a,b+1)
        if(i%c==0)
            cnt++;
    print(cnt);
    
  }
return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

constexpr ll lim = 1e6;

ll tb[lim + 1];

void init(){
  for(int i=2; i<=lim; i++) {
    tb[i] = i;
  }

  for(int i=2; i<=lim; i++){
    if(tb[i] == i){
      for(int j=1; i*j <= lim; j++){
        (tb[i*j] /= i) *= (i-1);
      }
    }
  }

  tb[1] = 2;
  for(int i=1; i<=lim; i++){
    tb[i] += tb[i-1];
  }
}

int main(){
  init();

  int t; cin >> t;
  for(int i=0; i<t; i++) {  
    int n; cin >> n;
    cout << tb[n] << endl;
  }

  return 0;
}



Measured memory_bytes: 10892
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		
		
		Scanner scan = new Scanner(System.in);
		
		
		String S = scan.next();
		
		
		char[] moji = new char[S.length()];
		
		moji = S.toCharArray();
		
		Arrays.sort(moji);
		
		
		int okcount = 1;
		
		
		
		for(int i = 0;i<S.length()-1;i++){
			
			if(moji[i]==moji[i+1]){
				okcount=0;
				break;
			}
			
			
			//System.out.println(moji[i]);
			
		}
		
		
		System.out.println(okcount==1?"yes":"no");
		
		
	
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to, cost, rev; bool used; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

template<typename T1, typename T2> ostream& operator << (ostream& s, const P<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}

void add_edge(V<V<edge>>& G, int l, int r, int d) {
   G[l].PB((edge){ l, r,  d, SZ(G[r]),   false });
   G[r].PB((edge){ r, l, -d, SZ(G[l])-1, false });
}

bool dfs(vector< vector<edge> >& G, V<int>& d, int s) {
   if (d[s] != INF) return true;
   stack<int> st;
   st.push(s);
   d[s] = 0;
   while (!st.empty()) {
      int i = st.top(); st.pop();
      for(int j = 0; j < G[i].size(); j++) {
         edge e = G[i][j];
         if (e.used) continue;
         e.used = true; G[e.to][e.rev].used = true;
         if (d[e.to] == INF) {
            d[e.to] = d[i] + e.cost;
            st.push(e.to);
         } else {
            if (d[e.to] != d[i] + e.cost) return false;
         }
      }
   }
   return true;
}

signed main()
{
   int N, M; cin >> N >> M;
   V<int> L(M), R(M), D(M);
   REP(i, M) {
      cin >> L[i] >> R[i] >> D[i];
      L[i]--; R[i]--;
   }

   V<V<edge>> G(N);
   REP(i, M) {
      add_edge(G, L[i], R[i], D[i]);
   }
   V<int> d(N, INF);
   bool ans = true;
   REP(i, N) {
      if (!dfs(G, d, i)) {
         ans = false;
      }
   }
   cout << (ans ? "Yes" : "No") << endl;

   return 0;
}


Measured memory_bytes: 31232
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	a, _ := strconv.Atoi(Scanner())
	b, _ := strconv.Atoi(Scanner())
	q, _ := strconv.Atoi(Scanner())
	s := make([]int, a)
	t := make([]int, b)
	for i := 0; i < a; i++ {
		s[i], _ = strconv.Atoi(Scanner())
	}
	for i := 0; i < b; i++ {
		t[i], _ = strconv.Atoi(Scanner())
	}
	for i := 0; i < q; i++ {
		x, _ := strconv.Atoi(Scanner())
		sidx := sort.SearchInts(s, x)
		tidx := sort.SearchInts(t, x)
		ans := 1000000000000
		if sidx > 0 && tidx > 0 {
			ans = smaller(larger(x-s[sidx-1], x-t[tidx-1]), ans)
		}
		if sidx < a && tidx > 0 {
			ans = smaller(larger(s[sidx]-x, x-t[tidx-1])+smaller(s[sidx]-x, x-t[tidx-1])*2, ans)
		}
		if sidx > 0 && tidx < b {
			ans = smaller(larger(x-s[sidx-1], t[tidx]-x)+smaller(x-s[sidx-1], t[tidx]-x)*2, ans)
		}
		if sidx < a && tidx < b {
			ans = smaller(larger(s[sidx]-x, t[tidx]-x), ans)
		}
		fmt.Println(ans)
	}
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}
func larger(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <iostream>
#include <cctype>
using namespace std;
int main(){
    char ch;
    for(;;){
        scanf("%c",&ch);
        if(ch == '\n'){
            break;
        }
        if (isalpha(ch)){
            if(islower(ch)){
                char ch1 = toupper(ch);
                cout << ch1;
            }else if (isupper(ch)){
                char ch2 = tolower(ch);
                cout << ch2;
            }
        }else{
            cout << ch;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner num = new Scanner(System.in);
		int a = num.nextInt();
		int b = num.nextInt();
		int c = num.nextInt();
		if (a == b & b == c) {
			System.out.println("1");
		} else if ((a == b & b != c) | (a == c & c != b) | (b == c & c != a)) {
			System.out.println("2");
		} else {
			System.out.println("3");
		}
		num.close();
	}
}


Measured memory_bytes: 9680
#include <stdio.h>

int main(void){
int a,b,c,d,e,k;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);
scanf("%d",&e);
scanf("%d",&k);

if(b-a>k){
printf(":(");
return 0;
}
if(c-a>k){
printf(":(");
return 0;
}
if(d-a>k){
printf(":(");
return 0;}
if(e-a>k){
printf(":(");
return 0;}

printf("Yay!");

return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

int main(void){
	int N;
	ll a[100100];
	int odd_n = 0;
	cin >> N;
	REP(i, N){
		cin >> a[i];
		if(a[i] % 2 == 1)
			odd_n++;
	}
	if(odd_n%2==0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 1532
// あみだくじ
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();  // 縦線の数
	    int m = kbd.nextInt();  // 横線の数
	    int a = kbd.nextInt();  // 調べたい縦線始点の番号
	    if(n!=0){
		solve(n, m, a);
	    }
	}
    }

    static void solve(int n, int m, int a){
	int[][] amida = new int[n+1][1010];
	int maxH = 0;
	// あみだくじセットここから
	while(m > 0){
	    int h = kbd.nextInt();
	    int p = kbd.nextInt();
	    int q = kbd.nextInt();
	    amida[p][h] = q;
	    amida[q][h] = p;
	    if(maxH < h) maxH = h;
	    m--;
	}
	
	// あみだくじ探索ここから
	int dep = maxH+1;
	int num = a;	
	a = amida[num][dep];
	//System.out.println(maxH);
	while(dep > 0){
	    //System.out.println(num+" "+dep);
	    if(a == 0){
		dep--;
		a = amida[num][dep];
	    }
	    else{
		num = a;
		dep--;
		a = amida[num][dep];
	    }
	}

	System.out.println(num);
    }
}

Measured memory_bytes: 64672
import java.util.Scanner;

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

		String w = sc.next();
		int count = 1;
		int i = 0;
		while (w.length() >= 2) {
			for (int j = i + 1; j < w.length(); j++) {
				if (w.substring(i, 1).equals(w.substring(j, j + 1))) {
					count++;
				}
			}
			if (count % 2 == 1) {
				System.out.println("No");
				break;
			}
			count = 1;
			w = w.replaceAll(w.substring(0, 1), "");
		}
		if (w.length() == 0) {
			System.out.println("Yes");
		} else if (w.length() == 1) {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, m;
    cin>>n>>m;
    ll ans = 0;
    if(n == 1 and m == 1){
        ans = 1;
    }else if(n == 1){
        ans = m - 2;
    }else if(m == 1){
        ans = n - 2;
    }else{
        ans = (n - 2) * (m - 2);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

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

	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;

	if(m1 != m2) {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}
			
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, x = map(int, input().split())
an = list(map(int, input().split()))
an_s = list(an)

if an_s[0] > x:
    an_s[0] = x
for i in range(1,N):
    if an_s[i-1] + an_s[i] > x:
        an_s[i] = x - an_s[i-1]

ans = 0
for org,aft in zip(an,an_s):
    ans += abs(org - aft)

# print(an_s)
print(ans)



Measured memory_bytes: 14132
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M,H[100000],B[100000],l,m,i,S;
  cin >> N >> M;
  i=0;
  while(i < N){
    B[i]=0;
    i++;
  }
  i=0;
  while(i < N){
    cin >> l;
    H[i]=l;
    i++;
  }
  i=0;
  while(i < M){
    cin >> l >> m;
    if(H[l-1]<=H[m-1]){
      B[l-1]++;
    }
    if(H[l-1]>=H[m-1]){
      B[m-1]++;
    }
    i++;
  }
  S=0;
  i=0;
  while(i < N){
    if(B[i]==0){
      S++;
    }
    i++;
  }
  cout << S <<endl;
}

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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x, y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x, y, z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define db4(x, y, z, w) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<","<<#w<<"="<<w<<'\n'
#define sz(a) int((a).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define PR(a, n) {cout<<#a<<"="; for(int __=0;__<n;__++)cout<<a[__]<<' '; cout<<"\n"; }
using namespace std;
using ll =  long long;
#define int ll

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n ;

    vector<int> v(n);
    for (int &i: v)cin >> i;
    vector<vector<int>> dp(n,vector<int> (n));
    for(int i= 0; i< n; ++i){
        dp[i][i] = v[i];
    }
    for(int i= 0; i< n-1; ++i){
        dp[i][i+1] = max(v[i],v[i+1])-min(v[i],v[i+1]);
    }
    int len = 3;
    while(len<=n){
        for(int i= 0; i<n-(len-1); ++i){
            int j = i+len-1;
            int a = dp[i+1][j];
            int b = dp[i][j-1];

            dp[i][j] = max(v[i] - a, v[j] -b);
        }
        ++len;
    }
    cout << dp[0][n-1];
}

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

signed main()
{
  int k,s;
  cin >> k>>s;
  int res=0;
  for(int x=0; x<= k ; ++x)for(int y=0; y<= k ;++y){
  	res+= int(s-x-y >=0 && s-x-y <= k);
  } 
  cout<< res << endl;
 return 0; 
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

var S string

func main() {
	fmt.Scan(&S)
	fmt.Println(min(count("0"), count("1")) * 2)
}

func count(s string) int {
	var ret int
	for i := 1; i <= len(S); i++ {
		if S[i-1:i] == s {
			ret++
		}
	}
	return ret
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 2492
import copy

def fact(n,s):
    return len(list(filter(lambda x:x>=n-1,s)))


n=int(input())
s=[0]*(n+1)
for i in range(2,n+1):
    a=copy.deepcopy(i)
    for j in range(2,a+1):
        while a%j==0:
            s[j]+=1
            a//=j
#print(s)
b=fact(5,s)
print(max(0,fact(75,s)+fact(25,s)*(fact(3,s)-1)+fact(15,s)*(fact(5,s)-1)+b*(b-1)*(fact(3,s)-2)//2))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

vector<double> dp(55, 0);

ull binomial(ull N, ull K) {
	if (K < 0 || N < K) return 0;
	ull ret = 1;
	for (ull i = 1; i <= K; ++i) {
		ret *= N--;
		ret /= i;
	}
	return ret;
}

void solve_abc_d() {
	ll n, m;
	ll a, b;
	//ll x, y;
	ll k;
	ll l_ans = 0;

	cin >> n >> a >> b;
	V v(n);
	rep(i, n) {
		cin >> v[i];
	}

	sort(v.rbegin(), v.rend());
	map<ll, ll> d;
	rep(i, a) {
		dp[i + 1] = (i * dp[i] + v[i])/(i + 1);
		++d[v[i]];
	}

	ll value = d.begin()->first;
	ll size = d.begin()->second;
	ll add = 0;
	for (ll i = a; i < n; i++) {
		if (v[i] == value) {
			add++;
		}
	}
	ull ans = 0;
	if (size == a) {
		for (ll i = a; i <= min(b, size+add); i++) {
			ans += binomial((ull)size + add, (ull)i);
		}
	}
	else {
		ans = binomial((ull)size + add, (ull)size);
	}

	cout << dp[a] << "\n";
	cout << ans << "\n";
	return;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(15);

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 3772
/*
	*	Created By: 'Present_Sir'
	*	Created On: Sunday 13 September 2020 05:25:20 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define lgt(s) ((int)s.length())
#define int long long
using namespace std;

class Solver{
    public:
        void test(){
            //int t; cin>>t; for(int i=1; i<=t; ++i)
            {
                //cout<<"Case #"<<i<<": ";
                this->solve();
            }
        }
        void solve(){
           int x;
           cin>>x;
           cout<<1-x<<endl;
        }
};


int32_t main(){
    IOS;
    Solver S;
    S.test();
    return 0;
}



Measured memory_bytes: 3612