akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count4=0;
		int count2=0;
		for(int i=0; i<N; i++) {
			int a = sc.nextInt();
			if(a%4==0) {
				count4++;
			} else if(a%2==0) {
				count2++;
			}
		}
		if((N/2<=count4) || (N-2*count4 <= count2)) {
			print("Yes");
		} else {
			print("No");
		}
		
	}
	
	// print
	static void print(String s) {
		System.out.println(s);
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 47236
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n,k; cin >>n>>k;

    double p = 0;

    for (int i = 1; i <= n; i++) {
        if(i < k) {
            double j = i;
            int count = 0;
            while (j < k) {
                j *= 2;
                count += 1;
            }
            j = (int)pow(2,count);
            double this_p = (double)1/j;
            this_p *= (double)1/n;
            p += this_p;
        } else {
            p += (double)1/n;
        }
    }

    cout << setprecision(12) << p << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = input().split()
# a = list(map(int, input().split()))
ans = ''
# t1, t2 = [], []
t1, t2 = Counter(), Counter()
for i in range(n):
    t1.update(a[i])
    t2.update(a[n-1-i])
    t3 = t1 & t2
    t1 -= t3
    t2 -= t3
    if t1 == t2:
        ans += str(i+1) + ' '
print(ans[:-1])


Measured memory_bytes: 14688
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int t;
ll a,b,c,d;

ll gcd(ll a,ll b) {
    return b==0?a:gcd(b,a%b);
}

bool solve() {
    if (a<b||b>d) return false;
    if (b<=c+1) return true;
    a%=b;
    if (a>c) return false;
    ll e=gcd(d,b);
    ll k=(c-a)/e+1;
    if (a+k*e<b) return false;
    return true;
}

int main()
{
    scanf("%d",&t);
    for (int i=1;i<=t;i++) {
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
        if (solve()) printf("Yes\n");
        else printf("No\n");
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
static const int MAX=100;
static const long long int INFTY=1LL<<32;

int n;
long long int M[MAX][MAX];

void floyd()
{
	for(int k=0;k<n;k++)
	{
		for(int i=0;i<n;i++)
		{
			if(M[i][k]==INFTY)continue;
			for(int j=0;j<n;j++)
			{
				if(M[k][j]==INFTY)continue;
				M[i][j]=min(M[i][j],M[i][k]+M[k][j]);
			}
		}
	}
	return;
}

int main() {
	cin>>n;int e,u,v,d;cin>>e;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)M[i][j]=i==j?0:INFTY;
	for(int i=0;i<e;i++)
	{
		cin>>u>>v>>d;
		M[u][v]=d;
	}
	floyd();
	bool flag=false;
	for(int i=0;i<n;i++)if(M[i][i]<0){flag=true;break;}
	if(flag)cout<<"NEGATIVE CYCLE"<<endl;
	else
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(j)cout<<" ";
				if(M[i][j]==INFTY)cout<<"INF";
				else cout<<M[i][j];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;


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




int main() {
    int n, m;
    cin >> n >> m;
    vector<int> k(n);
    vector<vector<int>> A;
    REP(i, n) {
        cin >> k[i];
        vector<int> A_i(k[i]);
        REP(j, k[i]) {
            cin >> A_i[j];
        }
        A.push_back(A_i);
    }
    vector<int> all_like(m+1, 0);
    REP(i, n) {
        for(int food:A[i]){
            all_like[food] += 1;
        }
    }
    int ans = 0;
    FOR(i, 1, m + 1) {
        if(all_like[i] == n) {
            ans += 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}
namespace IO{
    char nc(){ static char bf[100000],*p1=bf,*p2=bf; return p1==p2&&(p2=(p1=bf)+ fread(bf,1,100000,stdin),p1==p2)?EOF:*p1++; }
    int rd(){ int res=0; char c=getchar(); while(!isdigit(c))c=getchar(); while(isdigit(c))res=res*10+c-'0',c=getchar(); return res; }
}/*}}}*/
/******************heading******************/
const int N=1e5+5;

int n,k,ans;
char s[N];
int sig,c[2];

int main(){
    scanf("%d%d",&n,&k);
    scanf("%s",s+1);
    FOR(i,1,n){
        if(s[i]!=s[i-1])sig=!sig,c[sig]++;
        else ans++;
    }
    //printf("%d %d\n",c[0],c[1]);
    if(c[0]>c[1])swap(c[0],c[1]);
    if(k<c[0])ans+=k*2;
    else ans=n-1;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long n,c,x[100010],v[100010],ans,a[100010],b[100010];
int main(){
	cin>>n>>c;
	for (long long i=1;i<=n;i++) cin>>x[i]>>v[i];
	x[n+1]=c;
	for (long long i=1;i<=n;i++) a[i]=a[i-1]+(-x[i]+x[i-1]+v[i]);
	for (long long i=1;i<=n;i++) a[i]=max(a[i],a[i-1]);
	for (long long i=n;i>=1;i--) b[i]=b[i+1]+(-x[i+1]+x[i]+v[i]);
	for (long long i=n;i>=1;i--) b[i]=max(b[i],b[i+1]);
	for (long long i=1;i<=n;i++) ans=max(ans,max(a[i],max(b[i],max(a[i]+b[i+1]-x[i],b[i]+a[i-1]-c+x[i]))));
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
ll dp[51][51][2600];
int n,a;
int x[51];
int main() {
  cin >> n >> a;

  for(int i = 0; i < n; i++)  cin >> x[i];
   

  dp[0][0][0] = 1;

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      for(int k = 0; k <= 2500; k++) {
	
	  dp[i+1][j][k] += dp[i][j][k];
	  dp[i+1][j+1][k+x[i]] += dp[i][j][k];
	
	
      }
    }
  }
  
  ll ans = 0;

  for(int i = 1; i <= n; i++) ans += dp[n][i][i*a];

  cout << ans << endl;
}
	
  


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

const int N = 1e5 + 7;

int l[N], r[N];
set<pair<int, int> > L, R;

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

	int n;
	cin >> n;
	for (int i=0; i<n; i++)
	{
		cin >> l[i] >> r[i];
	}
	ll ans = 0;
	for (int x=0; x<2; x++)
	{
		for (int i=0; i<n; i++)
		{
			L.insert({l[i], i});
			R.insert({r[i], i});
		}
		int pos = 0;
		ll res = 0;
		for (int i=0; i<n; i++)
		{
			int turn = (i + x) % 2;
			int ind = 0;
			if (turn)
				ind = L.rbegin()->second;
			else
				ind = R.begin()->second;
			if (pos < l[ind])
				res += l[ind] - pos, pos = l[ind];
			else if (pos > r[ind])
				res += pos - r[ind], pos = r[ind];
			L.erase({l[ind], ind});
			R.erase({r[ind], ind});
		}
		ans = max(ans, res + abs(pos - 0));
	}
	cout << ans << "\n";
	return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;

    double theta;
    if(2*x <= a*a*b) theta = atan2(a*b*b, 2*x);
    else theta = atan2(2*(a*a*b-x), a*a*a);
    cout << setprecision(12) << theta / PI * 180.0 << endl;

    return 0;
}

/*



*/

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}
char s[20];

int main(){
  scanf("%s",s);
  printf("2018");
  for(int i=4;s[i]!='\0';i++){
    printf("%c",s[i]);
  }
  printf("\n");
}


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

using namespace std;

int main()
{
  string n;
  cin >> n;
  for (int i = 0; i < 3; i++)
    cout << (n[i] == '1' ? '9' : '1');
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  string c(a.size() + b.size(), 'a');
  for (int i = 0; i < c.size(); i++) {
    if (i % 2 == 0) c[i] = a[i / 2];
    else c[i] = b[(i - 1) / 2];
  }
  cout << c << endl;
}

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

typedef long long ll;
const int MOD = 1e+9 + 7;
const int MAX = 1e+5;
int n, m;
ll x[MAX+1], y[MAX+1];

int main() {
  // 入力
  cin >> n >> m;
  for (int i=1; i<=n; i++) cin >> x[i];
  for (int i=1; i<=m; i++) cin >> y[i];
  ll sum_x, sum_y;
  sum_x = sum_y = 0;
  for (int k=1; k<=n; k++) {
    sum_x += ((k - 1)*x[k] - (n - k)*x[k]) % MOD;
    sum_x %= MOD;
  }
  for (int k=1; k<=m; k++) {
    sum_y += ((k - 1)*y[k] - (m - k)*y[k]) % MOD;
    sum_y %= MOD;
  }
  cout << (sum_x * sum_y) % MOD << endl;
  return 0;
}


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

using namespace std;

int main () {
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
    	int sum = 0, tmp = i;
    	while (1) {
    		sum += tmp % 10;
        	tmp /= 10;
        	if (tmp == 0)
				break;
		}
    	if (sum >= a && sum <= b)
        	ans += i;
	}
	printf("%d\n", ans);
	return 0;
}


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

int main(void)
{
  while (true)
  {
    int n;
    cin >> n;
    if ( n == 0 ) break;
    int max = 0;
    int min = 500;
    for (int i = 0; i < n; i++)
    {
      int sum = 0;
      for (int j = 0; j < 5; j++)
      {
        int score;
        cin >> score;
        sum += score;
      }
      if ( min > sum )
      {
        min = sum;
      }
      if ( max < sum )
      {
        max = sum;
      }
    }
    cout << max << ' ' << min << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

i64 n, m;
vector<i64> p;
vector<bool> s;
int main() {
    cin >> n >> m;
    vector<bool> ac(n + 1);
    vector<int> pen(n + 1);
    for (int i = 0; i < m; ++i) {
        int p;
        string s;
        cin >> p >> s;
        bool t = s == "AC";
        if (!t && !ac[p]) pen[p]++;
        ac[p] = ac[p] | t;
    }

    int a = 0, b = 0;
    for (int i = 1; i <= n; ++i) {
        if (ac[i]) {
            ++a;
            b += pen[i];
        }
    }
    cout << a << ' ' << b << endl;
    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
int main(void)
{
	int i,x,y;
	for(i=0;;i++)
	{
		scanf("%d %d",&x,&y);
	if(x==0 && y==0)
		break;
	else if(x<y)
		printf("%d %d\n",x,y);
	else
		printf("%d %d\n",y,x);
	}
	return 0;
}
		

Measured memory_bytes: 600
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int c = sc.nextInt();
        
        int[][] array = new int[r + 1][c + 1];
        for(int i = 0; i < r; i++){
            for(int j = 0; j < c; j++){
                array[i][j] = sc.nextInt();
                array[i][c] += array[i][j];
                array[r][j] += array[i][j];
            }
            array[r][c] += array[i][c];
        }
        
        for(int i = 0; i < r + 1; i++){
            System.out.print(array[i][0]);
            for(int j = 1; j < c + 1; j++){
                System.out.print(" " + array[i][j]);
            }
            System.out.println();
        }
    }
}


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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    string S;
    int cnt = 0, s = 0;

    cin >> S;
    for(int i = 0; i < S.length(); i++) {
        if(S[i] == '0') {
            if(s > 0) {
                cnt++;
            }
            s--;
        } else {
            if(s < 0) {
                cnt++;
            }
            s++;
        }
    }
    cout << cnt * 2 << endl;

    return 0;
}


Measured memory_bytes: 512
from collections import deque


def main():
    h, w = map(int, input().split())
    c = list(map(lambda x: int(x) - 1, input().split()))
    d = list(map(lambda x: int(x) - 1, input().split()))
    grid = [list(input()) for _ in range(h)]
    q = deque([c])
    max_val = 10 ** 10
    dist = [[max_val for _ in range(w)] for _ in range(h)]
    dist[c[0]][c[1]] = 0
    next_d = [[0, 1], [1, 0], [0, -1], [-1, 0]]
    while q:
        now_x, now_y = q.popleft()
        for dx, dy in next_d:
            nx = now_x + dx
            ny = now_y + dy
            if not (0 <= nx < h and 0 <= ny < w):
                continue
            elif grid[nx][ny] == "#":
                continue
            if dist[nx][ny] > dist[now_x][now_y]:
                dist[nx][ny] = dist[now_x][now_y]
                if [nx, ny] == d:
                    continue
                q.appendleft([nx, ny])
        for dx, dy in [[0, 2], [1, 2], [1, 1], [2, 2], [2, 0], [2, 1]]:
            for cx, cy in [[1, 1], [1, -1], [-1, -1], [-1, 1]]:
                nx = now_x + dx * cx
                ny = now_y + dy * cy
                if not (0 <= nx < h and 0 <= ny < w):
                    continue
                elif grid[nx][ny] == "#":
                    continue
                if dist[nx][ny] > dist[now_x][now_y] + 1:
                    dist[nx][ny] = dist[now_x][now_y] + 1
                    if [nx, ny] == d:
                        continue
                    q.append([nx, ny])
    print(dist[d[0]][d[1]] if dist[d[0]][d[1]] != max_val else -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 161464
a,b,c = map(int,input().split())

fcount = 0
scount = 0

if a == 5 :
  fcount += 1
elif a == 7:
  scount += 1

if b == 5 :
  fcount += 1
elif b == 7:
  scount += 1

if c == 5 :
  fcount += 1
elif c == 7:
  scount += 1

if fcount == 2 and scount == 1:
  print("YES")
else :
  print("NO")


  

Measured memory_bytes: 3060
import numpy as np

N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))

max_len = max(len(bin(K)[2:]), len(bin(A.max())[2:]))
bit_cnt = [((A>>k)&1).sum() for k in range(max_len)]

x = 0
for i in range(max_len-1, -1, -1):
    if x+2**i <= K and bit_cnt[i] < (N+1)//2:
        x += 2**i

answer = 0
for a in A:
    answer += a^x
print(answer)


Measured memory_bytes: 23600
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    fast;
    ll n,k;
    cin >> n >> k;
    if(n % k == 0)
        cout << "0\n";
    else if(n > k){
        while(n > k){
            n -= (n / k) * k;
        }
        cout << min(n,abs(n - k)) << "\n";
    }else{
        cout << min(n,abs(n - k)) << '\n';
    }
    return 0;   
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			String np = "";
			int w = scanner.nextInt();
			int h = scanner.nextInt();
			Map<String, Page> pages = new HashMap<String, Main.Page>();
			while (n-- > 0) {
				Page p = new Page();
				String name = scanner.next();
				if (np.equals(""))
					np = name;
				int b = scanner.nextInt();
				while (b-- > 0) {
					int sx = scanner.nextInt();
					int sy = scanner.nextInt();
					int ex = scanner.nextInt();
					int ey = scanner.nextInt();
					String to = scanner.next();
					Button bn = new Button(sx, sy, ex, ey, to);
					p.buttons.add(bn);
				}
				pages.put(name, p);
			}
			int m = scanner.nextInt();
			List<String> buff = new ArrayList<String>();
			buff.add(np);
			int pi = 0;
			int br = 1;
			while (m-- > 0) {
				String op = scanner.next();
				if (op.equals("click")) {
					int x = scanner.nextInt();
					int y = scanner.nextInt();
					String to = pages.get(buff.get(pi)).click(x, y);
					if (!to.equals("") && pages.containsKey(to)) {
						pi++;
						if (pi == buff.size())
							buff.add(to);
						else
							buff.set(pi, to);
						br = pi + 1;
					}
				} else if (op.equals("back")) {
					if (pi != 0)
						pi--;
				} else if (op.equals("forward")) {
					if (pi + 1 != br)
						pi++;
				} else
					System.out.println(buff.get(pi));
			}
		}
	}

	class Button {
		int sx, sy, ex, ey;
		String to;

		public Button(int sx, int sy, int ex, int ey, String to) {
			super();
			this.sx = sx;
			this.sy = sy;
			this.ex = ex;
			this.ey = ey;
			this.to = to;
		}

		@Override
		public String toString() {
			return "Button [sx=" + sx + ", sy=" + sy + ", ex=" + ex + ", ey="
					+ ey + ", to=" + to + "]";
		}

		boolean isHit(int x, int y) {
			return sx <= x && x <= ex && sy <= y && y <= ey;
		}
	}

	class Page {
		List<Button> buttons = new ArrayList<Main.Button>();

		String click(int x, int y) {
			for (int i = 0; i < buttons.size(); i++) {
				if (buttons.get(i).isHit(x, y))
					return buttons.get(i).to;
			}
			return "";
		}

		@Override
		public String toString() {
			return "Page [buttons=" + buttons + "]";
		}
	}
}

Measured memory_bytes: 26332
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vll;
typedef vector<vector<long long>> vvll;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const double eps9 = 1e-9;


int main() {
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n, x;
	cin >> n >> x;
	int cur = 0;
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		if (cur <= x)
			res++;
		int t;
		cin >> t;
		cur += t;
	}
	if (cur <= x)
		res++;
	cout << res;
	return 0;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 05:50:12 2020

@author: baddude
"""


S = str(input())

count = 0
for text in S:
    if text == 'o':
        count = count + 1
print(700 + 100 * count)

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

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

    vector<pair<int, int>> work(n);
    for(int i=0; i<n; i++){
        cin >> work[i].first >> work[i].second;
    }
    sort(work.begin(),work.end());

    int salary = 0;
    priority_queue<int> pq;
    int j = 0;// for corner cases
    for(int i=1; i<=m; i++){
        while(j < n && work[j].first <= i){
            pq.push(work[j].second);
            j += 1;
        }
        if(!pq.empty()){
            salary += pq.top();
            pq.pop();
        }
    }
    cout << salary << endl;
    return 0;
}

Measured memory_bytes: 1660
module Main where
--import Debug.Trace
import Data.List
import Data.Maybe
import Data.Ord
import Control.Monad

data Suits = Spades Int| Hearts Int| Clubs Int| Diamonds Int deriving (Eq, Ord)
instance Show Suits where
    show (Spades   r) = "S " ++ show r
    show (Hearts   r) = "H " ++ show r
    show (Clubs    r) = "C " ++ show r
    show (Diamonds r) = "D " ++ show r


solve :: [Suits] -> [String]
solve l = map show ([s r| s<-[Spades,Hearts,Clubs,Diamonds], r<-[1..13]] \\ l)

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [Suits]
readLines 0 = return []
readLines n = readLine >>= (\a -> fmap (a:) (readLines (pred n))) where
    readLine = do 
            [suit, rank] <- fmap words getLine
            return $ select suit (read rank)
    select "S" r = Spades   r
    select "H" r = Hearts   r 
    select "C" r = Clubs    r
    select "D" r = Diamonds r


main :: IO() 
main = do
    [n] <- readLine
    l   <- readLines n
    mapM_ putStrLn (solve l)



Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int A,P;
  cin>>A>>P;
  cout << (3*A+P)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
ll N, K;
vll A;

bool C(ll X){
    ll cnt = 0; //* count <= X
    REP(i, N){
        ll tgt = A[i];
        if(tgt == 0){
            if(X >= 0) cnt+= N-1;
            continue;
        }
        if(X ==0){
            if(tgt > 0) cnt += upper_bound(ALL(A), 0) - A.begin();
            if(tgt < 0) cnt += A.end() - lower_bound(ALL(A), 0);
            if(tgt*tgt <= X) cnt --;  
            continue;
        }
        if(X >0 && tgt > 0) {
            cnt += upper_bound(ALL(A), X/tgt) - A.begin();
            if(tgt*tgt <= X) cnt --; 
            continue;
        }
        if(X < 0 && tgt <0) {
            ll Xtmp = -X, tgttmp = -tgt;
            cnt += A.end() - lower_bound(ALL(A), (Xtmp+tgttmp-1)/tgttmp);
            continue;
        }
        if(X >0 && tgt < 0){
            cnt += A.end() - lower_bound(ALL(A), -(X/(-tgt)));
            if(tgt*tgt <= X) cnt --; 
            continue;
        }
        if(X < 0 && tgt >0){
            cnt += upper_bound(ALL(A), -((-X+tgt-1)/tgt)) - A.begin();
            continue;
        }
    }
    if(cnt >=(2*K)) return true;
    else return false;
}

int main(){
    cin >> N>>K;
    A.resize(N); REP(i, N) cin >> A[i];
    sort(ALL(A));

    ll lo = -INF, hi = INF; //* hi is good
    while(hi - lo > 1){
        ll mid = (hi + lo )/2;
        if(C(mid)) hi = mid;
        else lo = mid;
    }
    cout<<hi<<endl;
    return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	vint A(N); cin >> A;
	map<int, int> mp;
	set<int> st;
	for (auto &v : A) { mp[v]++; st.insert(v); }
	if (st.size() > 3) { cout << "No" << endl; return; }
	if (mp[0] == N) { cout << "Yes" << endl; return; }
	if (N % 3) { cout << "No" << endl; return; }
	if (st.size() == 3) {
		bool flag = true;
		int xd = 0;
		for (auto &v : mp) {
			if (st.count(v.first)) {
				flag &= v.second == N / 3;
				xd ^= v.first;
			}
		}
		cout << (flag && xd == 0 ? "Yes" : "No") << endl;
		return;
	}
	if (st.size() == 2) {
		int a = *st.begin(), b = *st.rbegin();
		if (mp[a] == N/3 && a == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
		return;
	}
	cout << "No" << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 7808
#include<iostream>
#include<cstdio>
#include<string>
#include<cstdlib>

using namespace std;

struct node{
    int key;
    node *right,*left,*parent;
};

node *root,*NIL;

void insert(int k)
{
    node *y=NIL;
    node *x=root;
    node *z;
    
    z=(node*)malloc(sizeof(node));
    z->key=k;
    z->left=NULL;
    z->right=NULL;
    
    while(x!=NULL){
        y=x;
        if(z->key<x->key){
            x=x->left;
        }else{
            x=x->right;
        }
    }
    
    z->parent=y;
    
    if(y==NIL){
        root=z;
    }else{
        if(z->key<y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}

void inorder(node *u)
{
    if(u==NULL){
        return ;
    }
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(node *u)
{
    if(u==NULL){
        return ;
    }
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n,k;
    string com;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&k);
            insert(k);
        }else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}
/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print
*/



Measured memory_bytes: 26736
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    map<long long,int> mp;
    long long Count = 0;
    for(int i = 0; i < N; i++){
       if(mp.count(A[i])) mp[A[i]]*=-1;
       else mp[A[i]]=1;
    }
    for(auto p : mp){
       if(p.second == 1) Count += p.second;
    }
    cout << Count << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
struct tree
{
    int key, left, right, parent;
};
int main()
{
    int n;
    cin >> n;
    tree mytree[n + 1];
    for (int i = 1; i <= n; ++i)
        cin >> mytree[i].key;
    for (int i = 1; i <= n; ++i)
    {
        if (i / 2)
            mytree[i].parent = mytree[i / 2].key;
        if (i * 2 <= n)
            mytree[i].left = mytree[i * 2].key;
        if (i * 2 < n)
            mytree[i].right = mytree[i * 2 + 1].key;
    }
    for (int i = 1; i <= n; ++i)
    {
        printf("node %d: key = %d, ", i, mytree[i].key);
        if (i / 2)
            printf("parent key = %d, ", mytree[i].parent);
        if (i * 2 <= n)
            printf("left key = %d, ", mytree[i].left);
        if (i * 2 < n)
            printf("right key = %d, ", mytree[i].right);
        putchar('\n');
    }
}


Measured memory_bytes: 3148
import sys
input = sys.stdin.readline
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
#import numpy as np

from collections import deque

def main():
	l=int(input())
	print((l/3)**3)




if __name__ == "__main__":
	main()

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


def solve(s: str):
    print(max(0, (len(s)-2*s.count('p'))//2))
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll h, n;
	cin >> h >> n;
	Array a(n), b(n);
	REP(i, n) cin >> a[i] >> b[i];

	Matrix dp(n+1, Array(10101, INF));

	dp[0][0] = 0;
	REP(i, n) {
		REP(j, 10101) {
			chmin(dp[i + 1][j], dp[i][j]);
			if (j - a[i] >= 0) {
				chmin(dp[i + 1][j], dp[i + 1][j - a[i]] + b[i]);
			}
		}
	}

	ll ans = INF;
	rep(i, h, 10101) {
		chmin(ans, dp[n][i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 79360
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,{chars :$base :expr } ) =>{read_value !($iter ,String ) .chars () .map (|c |(c as u8 -$base as u8 ) as usize ) .collect ::<Vec <usize >>() } ;($iter :expr ,{char :$base :expr } ) =>{read_value !($iter ,{chars :$base } ) [0 ] } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,char ) =>{read_value !($iter ,chars ) [0 ] } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .unwrap () } ;}
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,mut $var :ident :$t :tt $($r :tt ) *) =>{let mut $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,mut $var :ident $($r :tt ) *) =>{input_inner !{$iter ,mut $var :usize $($r ) *} } ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,$var :ident $($r :tt ) *) =>{input_inner !{$iter ,$var :usize $($r ) *} } ;}
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;(iter =$iter :ident ,$($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut $iter =s .split_whitespace () ;input_inner !{$iter ,$($r ) *} } ;($($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
fn main() {
    input! { n, k, a: [usize1; n] };
    let mut v = vec![vec![0; n]; 60];
    v[0] = a.clone();
    for i in 0..59 {
        for j in 0..n {
            let x = v[i][v[i][j]];
            v[i + 1][j] = x;
        }
    }
    let mut res = 0;
    for i in 0..60 {
        if k & 1 << i != 0 {
            res = v[i][res];
        }
    }
    println!("{}", res + 1);
}


Measured memory_bytes: 98780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  printf("%lf %d\n", double(W) * double(H) / 2, x + x == W && y + y == H);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    const ll con = mod_fact(n - 1, MOD);
    ll fact[n];
    fact[0] = 1;
    for(int i = 1; i < n; i++){
        fact[i] = fact[i - 1] * i % MOD;
    }
    for(int i = 0; i <= k; i++){
        const ll bino = fact[n - 1] * mod_inv(fact[i], MOD) % MOD * mod_inv(fact[n - i - 1], MOD) % MOD;
        ans = (ans + bino * m % MOD * mod_pow(m - 1, n - i - 1, MOD)) % MOD;
    }
    cout << ans << "\n";
}

/*⠀⠀⠀⠀⠀⢀⣀⣀⣀    
⠀⠀⠀⠰⡿⠿⠛⠛⠻⠿⣷
⠀⠀⠀⠀⠀⠀⣀⣄⡀⠀⠀⠀⠀⢀⣀⣀⣤⣄⣀⡀
⠀⠀⠀⠀⠀⢸⣿⣿⣷⠀⠀⠀⠀⠛⠛⣿⣿⣿⡛⠿⠷
⠀⠀⠀⠀⠀⠘⠿⠿⠋⠀⠀⠀⠀⠀⠀⣿⣿⣿⠇
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠁

⠀⠀⠀⠀⣿⣷⣄⠀⢶⣶⣷⣶⣶⣤⣀
⠀⠀⠀⠀⣿⣿⣿⠀⠀⠀⠀⠀⠈⠙⠻⠗
⠀⠀⠀⣰⣿⣿⣿⠀⠀⠀⠀⢀⣀⣠⣤⣴⣶⡄
⠀⣠⣾⣿⣿⣿⣥⣶⣶⣿⣿⣿⣿⣿⠿⠿⠛⠃
⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄
⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡁
⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁
⠀⠀⠛⢿⣿⣿⣿⣿⣿⣿⡿⠟
⠀⠀⠀⠀⠀⠉⠉⠉
*/

//library//
ll mod_fact(ll a, ll mod){
    ll ans = 1;
    while(a > 1){
        ans = ans * a % mod;
        a--;
    }
    return ans; 
}
ll mod_pow(ll a, ll b, ll mod){
    ll ans = 1;
    while(b > 0){
        if(b & 1) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
ll mod_inv(ll a, ll mod){
    return mod_pow(a, mod - 2, mod);
}

Measured memory_bytes: 5192
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int n;
vector<vector<int>> saying;

void show() {
	for (int i = 0; i < n; i++) {
		printf("%2d: ", i);
		for (auto x: saying[i]) {
			printf("%3d ", x);
		}
		printf("\n");
	}
}

int calc(int maxi, int bits) {
	vector<int> person(n, 0);
	// printf("-------bits %d\n", bits);

	int n_true = 0;
	for (int i = 0; i < n; i++) {
		if ((bits >> i) & 1) {
			person[i] = 1;
			n_true++;
			// printf("true %d\n", i);
		}
	}


	if (n_true <= maxi) {
		return 0;
	}


	for (int i = 0; i < n; i++) {
		if (person[i]) {
			for (int j = 0; j < n; j++) {
				int tmp = saying[i][j];
				if (tmp == -1) {
					continue;
				}

				if (person[j] != tmp) {
					// printf("  x %d %d, %d\n", i, j, saying[i][j]);
					return 0;
				}
			}
		}
	}
	return n_true;
}

int main() {
	int a, x, y;
	cin >> n;

	saying.assign(n, vector<int>(n, -1));
	for (int i = 0; i < n; i++) {
		cin >> a;
		for (int j = 0; j < a; j++) {
			cin >> x >> y;
			saying[i][x-1] = y;
		}
	}

	// show();


	int ans = 0;
	int limit = 1 << n;
	for (int i = 0; i < limit; i++) {
		int tmp = calc(ans, i);
		ans = max(ans, tmp);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
N=int(stdin.readline().rstrip())
data=[int(x) for x in stdin.readline().rstrip().split()]
from statistics import mean
data_mean=mean(data)
def calc_(n):
    return abs(n-data_mean)
 
data2 = list(map(calc_, data))
data3=list(data2)
result=data3.index(min(data3))
print(result)

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

using namespace std;

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

int visited[200005];
vector<int>v[200005];
int man[200005];

void dfs(int node, int taka)
{
	man[node] += taka;
	visited[node] = 1;
	int len = v[node].size();
	
	for(int i = 0; i < len; i++)
	{
		int nodd = v[node][i];
		if(visited[nodd] == 0)
		{
			dfs(nodd,man[node]);
		}
	}
	return;
}

int main()
{
    int n,q,a,b,p,x;
    
    scanf("%d %d", &n, &q);
    
    for(int i = 1; i <= n-1; i++)
    {
		scanf("%d %d", &a, &b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i = 1; i <= q; i++)
	{
		scanf("%d %d",&p,&x);
		man[p] += x;
	}
    
    for(int i = 1; i <= n; i++)
    {
		if(visited[i] == 0)
		{
			dfs(i,0);
		}
	}
	cout << man[1];
	for(int i = 2; i <= n; i++)
	{
		cout << " " << man[i];
	}	
	cout << endl;
	return 0;
}


Measured memory_bytes: 24320
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut vs = vec![0; n];
    for i in 0..n {
        vs[i] = read::<i64>();
    }
    vs.sort();
    let mut sum = vs[0] as f64;
    for i in 1..n {
        sum = (sum + vs[i] as f64) / 2.0;
    }
    println!("{:.8}", sum);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
	long long int r,d,x[11],i;
	scanf("%lld %lld %lld",&r,&d,&x[0]);
	for(i=0;i<10;i++)
	{
		x[i+1]=r*x[i]-d;
		printf("%lld\n",x[i+1]);
	}
	return 0;
}


Measured memory_bytes: 128
n = int(input())

def d(k):
    s = 0
    while k > 0:
        k //= 10
        s += 1
    return s

dn = d(n)
a = 0
for i in range(1, dn + 1):
    if i % 2 == 1:
        if n < 10 ** i:
            a += n - 10**(i- 1) + 1
        else:
            a += 10 ** i - 10 ** (i - 1)
print(a)

Measured memory_bytes: 61916
#include <iostream>
using namespace std;
int n;
double a[105];

int main()

{
	ios::sync_with_stdio(false);
	cin>>n;
	double ans=0.0;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		ans+=1.0/a[i];
	}
	ans=1.0/ans;
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){

    int n;
    cin >> n;
	int aux = 0;
    while(n > 0){
    	aux = n%10;
    	if(aux == 7){
    		cout << "Yes\n";
    		return 0;
    	}
    	n/=10;
    }
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;
vector<string>S;
int dp[55][10];

int main(void)
{
	cin >> N;
	S.resize(2);
	cin >> S[0];
	cin >> S[1];
	vector<int>A;
	{
		int i = 0;
		while (i < N)
		{
			if (S[0][i] == S[1][i])
			{
				A.push_back(1);
				++i;
			}
			else
			{
				A.push_back(0);
				i += 2;
			}
		}
	}
	if (A[0])
	{
		dp[0][0] = dp[0][4] = dp[0][8] = 1;
	}
	else
	{
		dp[0][1] = dp[0][2] = dp[0][3] = dp[0][5] = dp[0][6] = dp[0][7] = 1;
	}
	N = A.size();
	for (int i = 1; i < N; ++i)
	{
		for (int j = 0; j < 9; ++j)
		{
			int c1 = j % 3;
			int c2 = j / 3;
			bool p = (c1 == c2);
			if (p != A[i])continue;
			for (int k = 0; k < 9; ++k)
			{
				int cc1 = k % 3;
				int cc2 = k / 3;
				if (c1 != cc1 && c2 != cc2)
				{
					dp[i][j] += dp[i - 1][k];
					dp[i][j] %= 1000000007;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 9; ++i)
	{
		ans += dp[N - 1][i];
		ans %= 1000000007;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

onesum=0
twosum=0
for i in range(n):
    if(a[i]>b[i]):
        onesum+=a[i]-b[i]
    elif(a[i]<b[i]):
        twosum+=(b[i]-a[i])//2

if(onesum<=twosum):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4596
A = int(input())
B = int(input())
C = int(input())
X = int(input())

K = 0

for a in range(0, A + 1):
   for b in range(0, B+1):
      for c in range(0, C+1):
         if (500*a + 100*b + 50*c) == X:
            K = K+1

print(K)


Measured memory_bytes: 3060
s = input()

p_point = 0
point = 0

for j in s:
  if j == 'g':
    if p_point > 0:
      point += 1
      p_point -= 1
    else:
      p_point += 1
  else:
    if p_point > 0:
      p_point -= 1
    else:
      point -= 1
      p_point += 1

print(point)



Measured memory_bytes: 3316
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#define ll long long int
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
using namespace std;
int main()
{
    l d,t,s;
    cin>>d>>t>>s;
    l res=d/s;
    if(res<=t)
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main(void){
  int n;
  cin>>n;
  int ans=n/25;
  n-=n/25*25;
  ans+=n/10;
  n-=n/10*10;
  ans+=n/5;
  n-=n/5*5;
  ans+=n;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3120