akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

int main(){
  int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
  string s; cin >> s;

  int count = 0;
  bool ok = true;

  for(int i=a-1;i<max(c,d);i++){
    if(s.at(i)=='#') count++;
    else count = 0;

    if(count==2) ok = false;
  }

  if(c>d){
    bool space = false;
    for(int i=b-1;i<d;i++){
      string tmp = "";
      rep(j,3){
        tmp.push_back(s.at(i+j-1));
      }
      if(tmp=="...") space = true;
    }
    if(!space) ok = false;
  }

  if(ok) puts("Yes");
  else puts("No");

}


Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  int n=s.size();
  int ans = 0;
  for(int i=0; i<(n+1)/2; i++){
    if(s[i]!=s[n-1-i])ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, K;
int A[200010];
int F[200010];
int D[200010];

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

	cin >> N >> K;
	rep(i, 0, N)
	{
		cin >> A[i];
	}
	rep(i, 0, N)
	{
		cin >> F[i];
	}

	sort(A, A + N);
	sort(F, F + N, greater<int>());

	rep(i, 0, N)
	{
		D[i] = A[i] * F[i];
	}

	int l = -1, r = 1e13;
	while (r - l > 1)
	{
		int mid = (l + r) / 2;
		int sum = 0;
		rep(i, 0, N)
		{
			if (D[i] > mid)
			{
				sum += (D[i] - mid + F[i] - 1) / F[i];
			}
		}
		if (sum <= K)
		{
			r = mid;
		}
		else
		{
			l = mid;
		}
	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 8308
#include <stdio.h>

int main(void)
{
	int a,b,d,r;
	double f;
	
	scanf("%d %d",&a,&b);
	d = a/b;
	r = a%b;
	f = 1.0*a/b;
	printf("%d %d %f",d,r,f);
	return 0;
}

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

int main()
{
    int n, m;

    cin >> n >> m;

    vector<int> ac(n), wa(n);
    int acc = 0, pen = 0;
    for(int i = 0; i < m; i++)
    {
        int tmp;
        string ju; 
        cin >> tmp;
        cin >> ju;

        if(ju == "AC" && ac[tmp - 1] != 1)
        {
            acc += 1;
            pen += wa[tmp - 1];
            ac[tmp - 1] = 1;
        }
        else if(ju == "WA")
        {
            wa[tmp - 1] += 1;
        }
    }
    cout << acc << " " << pen << endl; 
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define mp           make_pair
#define int          long long
#define uint         unsigned long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define vs           vector<string>
#define pi           pair<int,int>
#define di           deque<int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define noob         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}
const int mx=1e7+1;
int a[mx]={0};
double tick(){static clock_t oldt,newt=clock();double diff=1.0* (newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}

void sieve()
{
    rep(i,0,mx)
    {
        a[i]=1;
    }

    for(int i=2;i<mx;++i)
    {
        for(int j=i;j<mx;j+=i)
            a[j]+=1;
    }
    
}
void ram5564()
{
   int n;   
   cin>>n;
   int sum=0;
   rep(i,1,n+1)
   {
    sum+=i*a[i];
   }
   cout<<sum;
}

signed main()
{
        noob
        // #ifndef ONLINE_JUDGE
        //  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);
        //  #endif   
        sieve();
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
    cerr<<"\nExecution time: "<<tick()*1000<<" ms"<<endl;
        return 0;
}

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

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

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

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

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

int main(){
    lint h, w; cin >> h >> w;
    if(h == 1 || w == 1){
        out(1); return 0;
    }
    out((h * w + 1) / 2);
}

Measured memory_bytes: 256
def main():
  n,*t=map(int,open(0).read().split())
  (x,y),*t,(a,b)=sorted(zip(*[iter(t)]*2))
  r_min=[b]
  l_max=[a]
  for l,r in t[::-1]:
    r_min+=min(r_min[-1],r),
    l_max+=max(l_max[-1],l),
  m=max(0,y-x+1)+max(0,r_min.pop()-l_max.pop()+1)
  for l,r in t:
    i=r_min.pop()
    j=l_max.pop()
    v=min(y,r)
    w=max(x,l)
    m=max(m,max(0,i-j+1)+max(0,v-w+1),max(0,min(i,y)-max(j,x)+1)+max(0,r-l+1))
    y,x=v,w
  m=max(m,max(0,b-a+1)+max(0,y-x+1))
  print(m)
main()

Measured memory_bytes: 98892
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    long a = sc.nextLong();
    long b = sc.nextLong();
    long x = sc.nextLong();
    long ans = (b + x)/ x - (a + x - 1) / x;
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>

int main() {
    int N;
    std::vector<std::string> test_case = {"AC", "WA", "TLE", "RE"};
    std::vector<std::string> data;

    std::cin >> N;

    int AC = 0, WA = 0, TLE = 0, RE = 0;

    
    for(int i=0; i < N; i++) {
        data.emplace_back();
        std::cin >> data[i];
    }
    
    for(int i=0; i < N; i++) {
        for(int j=0; j < test_case.size(); j++) {
            if(data[i] == test_case[j]) {
                if(j == 0) {
                    AC++;
                }
                else if(j == 1) {
                    WA++;
                }
                else if(j == 2) {
                    TLE++;
                }
                else {
                    RE++;
                }
                break;
            }
        }
    }

    std::cout << "AC x " << AC << std::endl;
    std::cout << "WA x " << WA << std::endl;
    std::cout << "TLE x " << TLE << std::endl;
    std::cout << "RE x " << RE << std::endl;
}

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

int main() 
{
  char c;
  cin >> c;
  string S = "aiueo";
  bool b = false;
  
  for (int i=0;i<S.size();i++){
    if (c==S.at(i)) b=true;
  }
  
  if (b) cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
#define LL long long
#define PP std::pair<int,int>
#define TT std::tuple<int,int,int>
LL N, T;
LL A[100010];
LL m[100010];
int main() {
	std::cin >> N >> T;
	for (LL i = 1; i <= N; i++) {
		std::cin >> A[i];
	}
	m[1] = A[1];
	for (LL i = 2; i <= N; i++) {
		m[i] = std::min(m[i - 1], A[i]);
	}
	LL dif = 0;
	LL ans = 0;
	for (int i = 1; i <= N; i++) {
		if (dif == A[i] - m[i]) {
			ans++;
		}
		else if (dif < A[i] - m[i]) {
			ans = 1;
			dif = A[i] - m[i];
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main()
{
 int n;
 cin >> n;
 int a[n],tab[n];
 for(int i=1;i<n+1;i++) cin >> a[i];
 vector<int> ans;
 for(int i=n;i!=0;i--){
   vector<int> div;
   int j=1;
   while(i*j<=n){
     div.push_back(i*j);
     j++;
   }
   int tmp=0;
   for(int k=0;k!=div.size();++k){
     if(k!=0) tmp+=tab[div[k]];
   }
   tab[i]=(a[i]-tmp)%2;
 }
  for(int i=1;i<n+1;i++){
    if(tab[i]!=0) ans.push_back(i);
  }
      cout << ans.size() << endl;
  for(int i=0;i!=ans.size();++i) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 3448
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1);





int main() 
{
  ll N; cin>>N;
  if(N%1000==0) {cout<<0<<endl; return 0;}
  cout<<1000-N%1000<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
//________
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define show(x) cerr << #x << ':' << (x) << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef pair<int,int> Pii;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
inline int updiv(int a, int b){return((a+b-1) / b);}
const int INF = 1 << 29;
const int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
#define Size 1000011
#define NIL -1
//________


signed main()
{
    FAST();
    ll a, b;
    cin >> a >> b;
    ll i = a, cnt  = 0;
    while(i <= b){
        ++cnt;
        i *= 2;
    }
    outl(cnt);
}



Measured memory_bytes: 256
#include <cstdio>
#include <queue>
using namespace std;
#define ri register int
typedef long long ll;
#define rll register ll
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: putc;
using io :: print;
const int N=2e5+5,inf=2e9;
int f[N],v[N],cnt0[N],cnt1[N],fa[N];
struct node{
	int x,c0,c1;
	double r;
	inline bool operator <(const node &rhs)const{
		return r<rhs.r;
	}
};
priority_queue<node> q;
inline int find(ri x){
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main(){
	ri n,i,x1,x,t;
	rll ans;
	gi(n);
	for(i=1;i<=n;++i) fa[i]=i;
	for(i=2;i<=n;++i) gi(f[i]);
	gi(x1);
	if(x1)
		cnt0[1]=0,cnt1[1]=1;
	else
		cnt0[1]=1,cnt1[1]=0; 
	for(i=2;i<=n;++i){
		gi(x);
		if(x)
			cnt0[i]=0,cnt1[i]=1,
			q.push((node){i,0,1,0});
		else
			cnt0[i]=1,cnt1[i]=0,
			q.push((node){i,1,0,inf});
	}
	ans=0;
	while(!q.empty()){
		x=q.top().x;
		if(cnt0[x]!=q.top().c0||cnt1[x]!=q.top().c1){
			q.pop();
			continue;
		}
		q.pop();
		t=fa[x]=find(f[x]);
		ans+=(ll)cnt1[t]*cnt0[x];
		cnt0[t]+=cnt0[x];
		cnt1[t]+=cnt1[x];
		if(t!=1) q.push((node){t,cnt0[t],cnt1[t],!cnt1[t]?inf:(double)cnt0[t]/cnt1[t]});
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 15856
#include<stdio.h>

#define MAX 100005
#define NIL -1

struct Node{ int p, l, r, t;};
struct Node T[MAX];

int n, H, D[MAX],h[MAX];

void getDepth(int u);
int getheight(int u);
void print(int u);

int main(){
  int i,d, v, c, l,r;
  
  scanf("%d", &n);
  
  for (i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    if(l!=NIL){
      T[l].p=v;
    }
    if(r!=NIL){
      T[r].p=v;
    }
    T[v].l = l;
    T[v].r = r;
  }
  for ( i = 0; i < n; i++ ){
    if(T[i].l != -1){
      T[i].t++;
    }
    if(T[i].r != -1){
      T[i].t++;
    }
  }
  for ( i = 0; i < n; i++ ){
    if(T[i].p==NIL){D[i]=0; getDepth(i); break;}
  }
  for ( i = 0; i < n; i++ ){
    h[i]=getheight(i); 
  }
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

void getDepth(int u){
  int d=0;

  if(T[u].r!=NIL){
    D[T[u].r]=D[u]+1;
    getDepth(T[u].r);
  }
  if(T[u].l!=NIL){ 
    D[T[u].l]=D[u]+1;
    getDepth(T[u].l);
  }
}

int getheight(int u){
  int a,s;
  a=s=0;
  if(T[u].r==NIL && T[u].l==NIL) return 0;
  if(T[u].l!=NIL){
    a=getheight(T[u].l)+1;
  }
  if(T[u].r!=NIL){
    s=getheight(T[u].r)+1;
  }
  if(a>s) return a;
  else return s;
}

void print(int u){
  printf("node %d: parent = %d,",u,T[u].p);
if(T[u].p==NIL)printf(" sibling = -1, ");
  else if(T[T[u].p].r==u)  printf(" sibling = %d, ",T[T[u].p].l);
  else   if(T[T[u].p].l==u) printf(" sibling = %d, ",T[T[u].p].r);
  printf("degree = %d, ",T[u].t);
  printf("depth = %d, height = %d, ",D[u],h[u]);
  if(T[u].p==NIL) printf("root\n");
  else if(T[u].t==0) printf("leaf\n");
  else printf("internal node\n");
}

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


def solve(N: int):
    print(N  * 800 - N // 15 * 200)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double n = sc.nextInt();
    double sum = 0;
    double count = 0;
    for (int i = 1; i <= n; i++) {
      if (i % 2 != 0) {
        count++;
      }
    }
    System.out.println(String.format("%.10f", count / n));
  }
}


Measured memory_bytes: 21844
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef int ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll N,D[101],A[101];
map<vector<ll>,ll> dp[100];
ll arr[7];
ll brr[7];

ll taste[7];
ll res,ans;
ll K;
int main()
{{
	scanf("%d",&N);
	rep(i,N) scanf("%d",&D[i]);
	rep(i,N) scanf("%d",&A[i]);
	K=min(N,7);
	vector<ll> v(K);
	rep(i,K) v[i]=i;
	do{
		res=0;
		rep(i,7) taste[i]=0;
		rep(i,K){
			ll eat=K-1-v[i];
			res+=taste[eat];
			for(ll j=eat-D[eat];j<=eat+D[eat];j++){
				if(0<=j&&j<K) taste[j]+=A[eat];
			}
		}
		
		dp[K-1][v]=res;
		if(N<=7) ans=max(ans,res);
	}while(next_permutation(v.begin(),v.end()));
	if(N<=7){
		cout<<ans<<endl;
		return 0;
	}
	vector<ll> V(7);
	vector<ll> G(7);
	for(ll i=6;i<N-1;i++){
		rep(j,7){
			arr[j]=j;
		}
		do{
			ll yoso;
			for(ll nx=0;nx<8;nx++){
				yoso=0;
				res=0;
				for(ll now=0;now<7;now++){
					ll eat=arr[now];
					if(now==nx){
						brr[yoso]=0;
						yoso++;
					}
					if(now>=nx){
						if(D[i+1]>=eat+1) res+=A[i+1];
					}
					else{
						if(D[i-eat]>=eat+1) res+=A[i-eat];
					}
					if(eat<6){
						brr[yoso]=eat+1;
						yoso++;
					}
				}
				if(nx==7){
					brr[yoso]=0;
					yoso++;
				}
				rep(j,7){
					G[j]=arr[j];
					V[j]=brr[j];
				}
				dp[i+1][V]=max(dp[i+1][V],dp[i][G]+res);
			}
		}while(next_permutation(arr,arr+7));
	}
	ans=0;
	rep(i,7) arr[i]=i;
	do{
		rep(j,7) G[j]=arr[j];
		ans=max(dp[N-1][G],ans);
	}while(next_permutation(arr,arr+7));
	cout<<ans<<endl;}
	return 0;
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int A;
    cin >> A;
    N = N - A;
  }
  if (N < 0){
    cout << -1;
  } else {
    cout << N;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
char mp[1005][1005];
bool vis[1005][1005];
int h, w;
struct Node {
	int x, y, cnt;
	Node(){}
	Node(int xx, int yy, int cc):x(xx), y(yy), cnt(cc){}
};
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
int main() {
	scanf("%d%d", &h, &w);
	for (int i = 1; i <= h; i++) scanf("%s", mp[i] + 1);
	memset(vis, false, sizeof(vis));
	queue<Node> que;
	int tot = h * w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (mp[i][j] == '#') {
				que.push(Node(i, j, 0));
				vis[i][j] = true;
				tot--;
			}
		}
	}
	int ans = 0;
	while (!que.empty()) {
		Node t = que.front(); que.pop();
		if (!tot) break;
		for (int i = 0; i < 4; i++) {
			int tx = t.x + dx[i], ty = t.y + dy[i];
			if (tx < 1 || tx > h || ty < 1 || ty > w || vis[tx][ty]) continue;
			vis[tx][ty] = true;
			tot--;
			que.push(Node(tx, ty, t.cnt + 1));
			ans = max(ans, t.cnt + 1);
			if (!tot) break;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 14352
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N < M:
    X.sort()
    len = []
    for i in range(M-1):
        len.append(X[i+1] - X[i])

    len.sort()
    for i in range(N-1):
        len.pop()

    print(sum(len))

else:
    print(0)


Measured memory_bytes: 13968
#include <cstdio>
#include <algorithm>
using namespace std;

struct node {
    int v, i;
} x[200005];

int ans[200005];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &x[i].v);
        x[i].i = i;
    }
    sort(x, x + n, [](const node &a, const node &b) {
        return a.v < b.v;
    });
    int n2 = n >> 1;
    for (int i = 0; i < n2; ++i) {
        ans[x[i].i] = x[n2].v;
    }
    for (int i = n2; i < n; ++i) {
        ans[x[i].i] = x[n2 - 1].v;
    }
    for (int i = 0; i < n; ++i) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define taskname "test1"
#define int long long
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    string s;   getline(cin, s);
    for (char c : s)
        if (c == '9') cout << '1';
        else cout << '9';
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
from fractions import gcd

def f(a, x):
    # 1~a以下の数で、xで割り切れるものの数を返す
    return a//x


def lcm(a, b):
    """ aとbの最小公倍数を返す """
    return a*b // gcd(a, b)


def solve():
    A,B,C,D = list(map(int, input().split()))
    A -= 1
    ans = (B - (f(B,C)+f(B,D)-f(B,lcm(C,D)))) - (A - (f(A,C)+f(A,D)-f(A,lcm(C,D))))
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 5332
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)

typedef unsigned long long ull;

int main(){
	int n; cin>>n;
	FOR(i,n){
		printf("Case %d:\n",i+1);
		int x; cin>>x;
		FOR(j,10){
			x = (x*x)/100%10000;
			cout << x << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1192
n = int(input())
a_list = []
for _ in range(n):
    a_list.append(int(input()))
max_list = [0, 0]
for a in a_list:
    if a > max_list[0]:
        max_list[0] = a
    elif a > max_list[1]:
        max_list[1] = a
for a in a_list:
    if not a == max_list[0]:
        print(max_list[0])
    else:
        print(max_list[1])

Measured memory_bytes: 12520
#include<iostream>
using namespace std;
int main(){
	int a, b,c,d;
	while(cin>>a>>b>>c>>d)
	{
		int ans=0;
	
			for(int i=0; i<=100;i++)
			{
				if((i>=a&&i<=b) && (i>=c && i<=d) )
				ans++;
			}
			printf("%d\n" ,ans-1>=0? ans-1:0);
		}
	return 0;
	
}

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

int main() {
  string S;
  int k = 0;
  int countJ = 0;
  int countO = 0;
  int countI = 0;
  cin >> S;

  for(int i = 0; i < S.size(); i++) {
    if(S[i] == 'J' && countO == 0 && countI == 0)
      countJ+=1;
    else if(S[i] == 'O' && countJ > countO && countI == 0) {
      countO+=1;
    }   
    else if(countO > 0 && S[i] == 'I') {
      countI+=1;
      if(countO == countI)
        if(countI >= k) {
          k = countI;
        }
    }
    else {
      countJ = 0;
      countO = 0;
      countI = 0;
      if(S[i] == 'J')
	countJ = 1;
    }
  }
  cout << k << endl;

  return 0;
}



Measured memory_bytes: 3996
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
for i in range(n):
    t1 = min(a[i], b[i])
    a[i] -= t1
    b[i] -= t1
    res += t1
    t2 = min(a[i+1], b[i])
    a[i+1] -= t2
    b[i] -= t2
    res += t2
print(res)


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

int main(){
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double n = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
	printf ("%f\n", n);

	return 0;
}

Measured memory_bytes: 1228
N,M,X,Y = map(int, input().split(" "))
xList = input().split(" ")
yList = input().split(" ")

for i in range(len(xList)):
  xList[i] = int(xList[i])
for j in range(len(yList)):
  yList[j] = int(yList[j])

xList.sort()
yList.sort()

if yList[0] > xList[len(xList) - 1] and yList[0] > X and Y > xList[len(xList) - 1]:
  print("No War")
else:
  print("War")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int Combination(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int n,a,b,c,d,r1,r2;
  r1=1;
  r2=1;
  cin>>n>>a>>b>>c>>d;
  for(int i=c;i<a;i=i+c) {
    r1++;
  }
  for(int i=d;i<b;i=i+d) {
    r2++;
  }
  cout<<n-max(r1,r2)<<endl;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

string s[8];

int main(void){
  int h, w;
  cin >> h >> w;
  int c = 0;
  REP(i, 0, h) {
    cin >> s[i];
    REP(j, 0, w) {
      c += s[i][j] == '#';
    }
  }
  cout << (c == h + w - 1 ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] Array = Console.ReadLine().Split(' ');
            int a = int.Parse(Array[0]);
            int b = int.Parse(Array[1]);
            int c = int.Parse(Array[2]);
            int count = 0;

            for (int i = a; i <= b; ++i)
            {

                if (c % i == 0)
                {
                    ++count;
                }
            }
            Console.WriteLine(count);
            }
        }
    }

Measured memory_bytes: 5616
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
typedef pair<LL,LL> mp;
const int maxn = 105;
const int N = 90;
const int mod = 1e9+7;
vector<mp> vec[maxn];

#define pb push_back
#define fi first
#define se second

LL fib[maxn];int Q;
void dfs(int stp,LL a,LL b)
{
	vec[stp].pb(mp(a,b));
	if (stp>=86) return ;
	LL num=fib[stp+3]+fib[stp];
	if (a+b<=num) dfs(stp+1,b,a+b);
	if (a+2*b<=num) dfs(stp+1,b,a+2*b);
}
int main()
{
	#ifdef Amberframe
		freopen("agc015f.in","r",stdin);
		freopen("agc015f.out","w",stdout);
	#endif
	fib[0]=1;fib[1]=1;
	for (int i=2;i<=N;i++)
		fib[i]=fib[i-1]+fib[i-2];
	dfs(1,1,2);
	dfs(1,1,3);
	
	scanf("%d",&Q);
	for (int i=1;i<=Q;i++)
	{
		LL x,y;scanf("%lld %lld",&x,&y);LL ans=0;
		if (x>y) swap(x,y);
		int k=1;while (x>=fib[k+1]&&y>=fib[k+2]) ++k;
		for (unsigned j=0;j<vec[k-1].size();j++)
		{
			if (vec[k-1][j].se<=x)
				ans+=max(0ll,(y-vec[k-1][j].fi)/vec[k-1][j].se);
			if (vec[k-1][j].se<=y)
				ans+=max(0ll,(x-vec[k-1][j].fi)/vec[k-1][j].se);
		}
		printf("%d %d\n",k,k==1?(LL)x*y%mod:ans%mod);
	}
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
string c="CODEFESTIVAL2016";

int main(){ _;
  string s;cin>>s;
  int cnt=0;
  REP(i,16){
    if(c[i]!=s[i])cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char*s[]={	"0111111",
				"0000110",
				"1011011",
				"1001111",
				"1100110",
				"1101101",
				"1111101",
				"0100111",
				"1111111",
				"1101111",};
	int n,x,i;
	while(scanf("%d",&n),n>=0)
	{
		char l[10]="0000000";
		while(n--)
		{
			scanf("%d",&x);
			for(i=0;i<7;++i)
				printf("%d",l[i]!=s[x][i]),l[i]=s[x][i];
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 0
# include <iostream>
# include <string>
using namespace std;
int main()
{
	long long int t;
	cin>>t;
		long long int ac=0;
		long long int wa=0;
		long long int tle=0;
		long long int re=0;	
	for(long long int i=0;i<t;i++)
	{
		string s;
		cin>>s;
		if(s=="AC")
		{
			ac++;
		}
		else if(s=="WA")
		{
			wa++;
		}
		else if(s=="TLE")
		{
			tle++;
		}
		else
		{
			re++;
		}
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  cin>>n;
    vector<vector<ll>> count(10, vector<ll>(10));
  Loop(i,1,n+1){
    ll y=i;
    string s=to_string(y);
    ll fir=ctoi(s[0]);
    ll en=ctoi(s[s.size()-1]);
    loop(j,10){
      loop(k,10){
        if(j==fir&&k==en)count[j][k]++;
      }
    }
  }
  
  
  ll ans=0;
  loop(i,10){
    loop(j,10){
      loop(k,10){
        loop(l,10){
          if(i==l&&j==k)ans+=count[i][j]*count[k][l];
        }
      }
    }
  }

  putout(ans);
}


Measured memory_bytes: 256
N = int(input())
D = [[-1,1]]*N
ans = "No"

for n in range(N):
  D[n] = list(map(int, input().split()))
  if D[n][0] == D[n][1]:
    if D[n-1][0] == D[n-1][1]:
      if D[n-2][0] == D[n-2][1]:
        ans = "Yes"
        break
print(ans)

Measured memory_bytes: 8972
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 100001;

namespace centroid {
    int sz[MN], cpar[MN], vis[MN];
	void dfs(vector<ii> * G, int u, int p = 0) {
		sz[u] = 1;
		for (ii v : G[u]) if (v.s != p && !vis[v.s]) dfs(G, v.s, u), sz[u] += sz[v.s];
	}
	int centroid(vector<ii> * G, int u = 1) {
		dfs(G, u);
		int num = sz[u], p = 0;
		do {
			int nxt = 0;
			for (ii v : G[u]) if (v.s != p && !vis[v.s] && 2*sz[v.s] > num) nxt = v.s;
			p = u, u = nxt;
		} while (u);
		return p;
	}
	void centroid_decomp(vector<ii> * G, int u = 1, int p = 0) {
		int c = centroid(G, u);
		vis[c] = 1,	cpar[c] = p;
		for (ii v : G[c]) if (!vis[v.s]) centroid_decomp(G, v.s, c);
	}
}

int N; ll sz[MN];
vector<ii> G[MN];

void dfs(int u, int p = 0) {
	sz[u] = 1;
	for (ii v : G[u]) if (v.s != p) dfs(v.s, u), sz[u] += sz[v.s];
}

ll solve(int u, int p = 0) {
	ll ret = 0;
	for (ii v : G[u]) if (v.s != p) ret += solve(v.s, u)+2*min(sz[v.s], N-sz[v.s])*v.f;
	return ret;
}

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    cin >> N;
    for (int i = 1; i < N; ++i) {
        int A, B, C; cin >> A >> B >> C;
        G[A].emplace_back(C, B), G[B].emplace_back(C, A);
    }

    int c = centroid::centroid(G);
	dfs(c);
	int d = 0; ll w;
	for (ii v : G[c]) if (N%2 == 0 && sz[v.s] == N/2) d = v.s, w = v.f;
	if (d) {
		cout << solve(c, d)+solve(d, c)+(N-1)*w;
	}
	else {
		int ans = 1e9;
		for (ii v : G[c]) ans = min(v.f, ans);
		cout << solve(c)-ans;
	}
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numDays = sc.nextInt();
		int[] activityCost = new int[3];
		for(int day = 0; day < numDays; day++) {
			int[] newActivityCost = new int[3];
			int[] activityHappiness = new int[3];
			for(int i = 0; i < 3; i++) {
				activityHappiness[i] = sc.nextInt();
			}
			
			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < 3; k++) {
					if(j != k) {
						newActivityCost[k] = Math.max(newActivityCost[k], activityCost[j] + activityHappiness[k]);
					}
				}
			}
			System.arraycopy(newActivityCost, 0, activityCost, 0, 3);
		}
		System.out.println(Math.max(activityCost[0], Math.max(activityCost[1], activityCost[2])));
	}
}

Measured memory_bytes: 60080
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m,y;
    cin>>n>>m>>y;
    if(m-n==y-m)
    {
    	cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
     
    public void solve(){
        Scanner sc =new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b && b < c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
     
    public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17276
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    ll a,b,n,x,rta;
    cin >> a >> b >> n;
    if(b==1) rta=0;
    else if(b<=n){
        x=b-1;
        rta=floor((a*x)/b)-a*floor(x/b);
    }
    else{
        x=n;
        rta=floor((a*x)/b)-a*floor(x/b);
    }
    cout << rta << endl;
    return 0;
}


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

int main()
{
	int n, k;
	long double p = 0;
	
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		if (i + 1 >= k)
			p += 1 / (long double)n;
		else {
			int j = 0;

			while ((i + 1) * (1 << j) < k)
				j++;

			p += 1 / ((long double)n * (long double)(1 << j));
		}
	}

	cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(12)
		<< p << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    char s[ 128 ], *p;
    int a = 0, b = 0;

    scanf ( "%s", s );
    if ( *s == '0' ) break ;

    for ( p = s + 1; *p != '\0'; ++p )
    {
      a += !!( *p == 'A' );
      b += !!( *p == 'B' );
    }

    printf ( "%d %d\n", a + !!( a > b ), b + !!( b > a ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
      	int n = sc.nextInt();
        int max = sc.nextInt();
      	int count = 1;
      	int istack;
      
      	for(int i = 1;i < n;i++){
          istack = sc.nextInt();
          if(istack >= max){
            count++;
            max = istack;
          }
        }
          
      	System.out.print(count);
      
	}
}

Measured memory_bytes: 35788
#include<cstdio>
using namespace std;
const int MAXN = 100005;
int a[MAXN], b[MAXN], fa[MAXN];
long long ans[MAXN], s[MAXN];
inline int findset(int x){
	return fa[x]==x?x:fa[x]=findset(fa[x]);
}
int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=1; i<=m; i++){
		scanf("%d%d", a+i, b+i);
	}
	long long sum = 1LL*n*(n-1)/2;
	for(int i=1; i<=n; i++) fa[i]=i, s[i]=1LL;
	for(int i=m; i; i--){
		ans[i]=sum;
		int x = findset(a[i]);
		int y = findset(b[i]);
		if(x!=y){
			fa[y]=x;
			sum-=s[x]*s[y];
			s[x]+=s[y];
		}
	}
	for(int i=1; i<=m; i++) printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using i64 = long long;

i64 c[51][51];

i64 rec(int n, int k) {
    if (c[n][k]) return c[n][k];
    if (k == 0) return c[n][k] = 1;
    if (n == k) return c[n][k] = 1;
    return c[n][k] = rec(n - 1, k - 1) + rec(n - 1, k);
}

int main() {
    int n, p, cnt[] { 0, 0 };
    std::cin >> n >> p;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        cnt[a & 1]++;
    }

    i64 e = 1, o = 0;
    for (int i = 0; i < cnt[0]; i++) e *= 2;
    for (int i = p; i <= cnt[1]; i += 2) o += rec(cnt[1], i);

    std::cout << o * e << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX_LENGTH 200000

int index(char dir) {
	switch (dir) {
	case 'L':
		return 0;
	case 'R':
		return 1;
	case 'U':
		return 2;
	case 'D':
		return 3;
	}
}

int main(void) {
	int H, W, N;
	int y, x;
	char S[MAX_LENGTH + 1];
	char T[MAX_LENGTH + 1];
	scanf("%d%d%d", &H, &W, &N);
	scanf("%d%d", &y, &x);
	scanf("%s", S);
	scanf("%s", T);

	//'L','R','U','D'
	int out[] = { 0,W + 1,0,H + 1 };
	int lim[] = { x,x,y,y };
	int move[] = { -1,1 };
	int i,dir,moveDir;
	for (i = 0; i < N; i++) {
		dir = index(S[i]);
		lim[dir] += move[dir % 2];
		if (lim[dir] == out[dir]) {
			printf("NO\n");
			break;
		}
		moveDir = index(T[i]);
		dir = moveDir / 2 * 2 + (moveDir + 1) % 2;
		lim[dir] -= lim[dir] - move[dir % 2] == out[moveDir] ? 0 : move[dir % 2];
	}
	if (i == N)
		printf("YES\n");
	return 0;
}

Measured memory_bytes: 512
# 3 個の整数 A1, A2, A3 が与えられます。
# A1 + A2 + A3 が 22 以上なら bust、
# 21 以下なら win を出力してください。

# 3個の整数を取得
input = gets.chomp.split
a1 = input[0].to_i
a2 = input[1].to_i
a3 = input[2].to_i

# 結果を格納する変数を宣言
result = String.new

# 3個の整数の和を計算
if a1 + a2 + a3 >= 22
  result = "bust"
else
  result = "win"
end

# 結果を出力
puts result

Measured memory_bytes: 1788
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

ll S;

int main() {
    cin >> S;
    ll x0 = 0;
    ll y0 = 0;

    ll x1 = 1e9;
    ll y1 = 1;

    ll x2 = (x1 - S % x1) % x1;
    ll y2 = (S + x2) / x1;

    // S = |x1y2 - x2y1|

    cout << x0 << " " << y0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
    return 0;
}


Measured memory_bytes: 256
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
a = []
ok = False
for i in range(N):
    inp = int(input())
    a.append(inp)
    if inp % 2 != 0:
        ok = True
if ok:
    print("first")
else:
    print("second")


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

int main() {
  int a,b,c,d,i,s;
  cin>>a;
  d=a%10;
  c=a/10%10;
  b=a/100%10;
  a=a/1000%10;
  for(i=0;;i++){
    s=a;
    if(i/4==0)s+=b;
    else s-=b;
    if(i%4==0||i%4==1)s+=c;
    else s-=c;
    if(i%2==0)s+=d;
    else s-=d;
    if(s==7)break;
  }
  cout<<a;
  if(i/4==0) cout<<'+';
  else cout<<'-';
  cout<<b;
  if(i%4==0||i%4==1)cout<<'+';
  else cout<<'-';
  cout<<c;
  if(i%2==0)cout<<'+';
  else cout<<'-';
  cout<<d<<'='<<7<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <iterator>
#include <queue>
#include <utility>

using namespace std;
#define whole(xs) xs.begin(), xs.end()
#define MOD 1000000007

string A, B, C;
bool input() {
    cin >> A; 
    if (A == "0") return false;
    cin >> B >> C;
    return true;
}

int Cache[51][2];
int dfs(int index, int x) {
    int Ans = 0;
    if (index == A.size()) return x == 0;
    if (Cache[index][x] >= 0) return Cache[index][x];
    for (int a = 0; a <= 9; a++) {
        if (index == A.size() - 1 && a == 0) continue;
        if (A[index] != '?' && A[index] != a + '0') continue;
        for (int b = 0; b <= 9; b++) {
            if (index == A.size() - 1 && b == 0) continue;
            if (B[index] != '?' && B[index] != b + '0') continue;
            int c1 = a + b + x;
            int x1 = c1 >= 10;
            int c = c1 % 10;
            if (index == A.size() - 1 && c == 0) continue;
            if (C[index] != '?' && C[index] != c + '0') continue;
            Ans = (Ans + dfs(index + 1, x1)) % MOD;
        }
    }
    return Cache[index][x] = Ans;
}

void solve() {
    memset(Cache, -1, sizeof(Cache));
    reverse(whole(A));
    reverse(whole(B));
    reverse(whole(C));
    cout << dfs(0, 0) << endl;
}

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

Measured memory_bytes: 1188
import java.io.*;
import java.util.*;
public class Main {


    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[]a = new  int[n];
        int sum=0;
        for (int i =0;i<n;i++){
            a[i]=sc.nextInt();
            sum+=a[i];
        }
        Arrays.sort(a);
        boolean is =true;
        int x=m;
        for (int i =n-1;m-->0;i--){
//            System.err.println(a[i]*4+" "+sum);
            if (a[i]*4*x<sum){
                is=false;
                break;
            }
        }
        if (is){
            pw.println("Yes");
        }else pw.println("No");
        pw.flush();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

}

Measured memory_bytes: 21460
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);

	int n,m;
	cin >> n >> m;
	cout << ((n == m) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n,m,a,b;
  vi x[200001];
  
  cin>>n>>m;
  rep(i,m){
    cin>>a>>b;
    x[a].pb(b);x[b].pb(a);
  }
  rep(i,x[1].size()){
    int tmp=x[1][i];
    rep(j,x[tmp].size()){
      if(x[tmp][j]==n){
	cout<<"POSSIBLE"<<endl;
	return 0;
      }
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 12016
#include <stdio.h>
#include <string.h>

int main() {
  char s[10]; scanf("%s", s);
  for (int i = 0; i < strlen(s) - 1; i++) {
    if (s[i] == 'A' && s[i+1] == 'C') {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
}

Measured memory_bytes: 128