akhauriyash/Code-Regression huggingface dataset:
n,m=map(int,input().split())

g=[[] for i in range(1+n)]
v=[0]*(1+n)
e=[]
for i in range(m):
    a,b=map(int,input().split())
    e.append((a,b))
    g[a].append(b)
    g[b].append(a)

def dfs(st,ed):
    q=[]
    q.append(st)

    while q:
        cur=q.pop()
        v[cur]=1
        if cur==ed:
            return True

        for nb in g[cur]:
            #if v[nb]!=1:
            if v[nb]!=1 and (cur,nb)!=(st,ed):
                q.append(nb)
    #print(st,ed,v)
    return False

ans=0
for a,b in e:
    v=[0]*(1+n)
    #v[b]=1
    if not dfs(a,b):
        ans+=1
#print(g)
print(ans)


Measured memory_bytes: 39280
// <------------- Template -----------------------> //


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll t=1;
ll n,x;
string s;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	ll ans = 0;
	ans += n/11;
	ans*=2;
	n%=11;
	if(n <= 6 && n) ans++;
	else if(n>6) ans+=2;
	cout<<ans;	
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(t--) {
		MAIN();
	}
	return 0;
}


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

int Partition(int A[],int l,int r){
    int x=A[r];
    int i=l-1,j=l;
    int k;
    for(j=l;j<r;j++){
        if(A[j]<=x){
            i+=1;
            k=A[i]; A[i]=A[j]; A[j]=k;
        }
    }
    k=A[i+1]; A[i+1]=x; A[r]=k;
    return i+1;
}

int main(){
    int n,i;
    int loc=0;
    int A[100001];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    loc=Partition(A,0,n-1);
    for(int i=0;i<loc;i++){
        cout<<A[i]<<' ';
    }
    cout<<'['<<A[loc]<<']';
    for(int i=loc+1;i<n;i++){
        cout<<' '<<A[i];
    }
    cout<<endl;

}



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

int N, M;
vector<int> l, r;

int main()
{
    cin >> N >> M;
    l.resize(N);
    r.resize(N);
    for (int i=0; i<N; i++) cin >> l[i] >> r[i];

    vector<int> ans(M+1, 0);

    for (int i=0; i<N; i++)
    {
        int l_ = l[i], r_ = r[i];
        int l__ = r_ + 1;
        for (int j=1; j * j<=M; j++)
        {
            if ((l_ + j - 1) / j <= r_ / j)
            {
                ans[(l_ + j - 1)/ j]++;
                ans[min(r_ / j + 1, l__)]--;
                l__ = (l_+j-1)/j;
            }
        }
        for (int m=1; m<l__; m++)
        {
            if ((l_ - 1) / m < r_ / m)
            {
                ans[m]++; ans[m+1]--;
            }
        }
    }
    int ans_ = 0;
    for (int i=1; i<=M; i++)
    {
        ans_ += ans[i];
        cout << ans_ << endl;
    }
}


Measured memory_bytes: 3712
import java.util.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int H = sc.nextInt();
		int W = sc.nextInt();
		BitSet[] table = new BitSet[H];
		for (int i = 0; i < H; i++) {
			BitSet bits = table[i] = new BitSet(W);
			String S = sc.next();
			char[] chars = S.toCharArray();
			for (int j = 0; j < chars.length; j++) {
				bits.set(j, chars[j] == '.');
			}
		}

		PriorityQueue<Weighted> waiting = new PriorityQueue<>();
		waiting.add(new Weighted(new Vector(0, 0), 0));
		int[] ud = {0, 1};
		int[] lr = {1, 0};
		int[][] cost = new int[H][W];
		int[] infs = new int[W];
		Arrays.fill(infs, Integer.MAX_VALUE / 2);
		for (int[] ints : cost) {
			System.arraycopy(infs, 0, ints, 0, W);
		}
		cost[0][0] = 0;
		while (!waiting.isEmpty()) {
			Weighted weighted = waiting.remove();
			if (weighted.cost > cost[weighted.vector.y][weighted.vector.x]) continue;
			boolean white = table[weighted.vector.y].get(weighted.vector.x);
			for (int i = 0; i < 2; i++) {
				Vector next = new Vector(weighted.vector.x + lr[i], weighted.vector.y + ud[i]);
				if (next.x == W || next.y == H) continue;
				int temp = cost[weighted.vector.y][weighted.vector.x] + (white && !table[next.y].get(next.x) ? 1 : 0);
				if (cost[next.y][next.x] > temp) {
					cost[next.y][next.x] = temp;
					waiting.add(new Weighted(next, cost[next.y][next.x]));
				}
			}
		}
		System.out.println(cost[H - 1][W - 1] + (table[0].get(0) ? 0 : 1));
	}
}

class Weighted implements Comparable<Weighted>{
	final Vector vector;
	final int cost;

	Weighted(Vector vector, int cost){
		this.vector = vector;
		this.cost = cost;
	}
	
	@Override
	public int compareTo(Weighted o) {
		return Comparator.comparingInt((Weighted w) -> w.cost).compare(o, this);
	}
}

class Vector {
	int x;
	int y;

	Vector(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

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

int n, m;

void merge(int *u, int *net, int oldnet, int newnet);

int main(int argc, char *argv[])
{
  int i, s, t, p, q;
  int *u;
  int *net;

  scanf("%d", &n);
  scanf("%d", &m);
  u = (int *)malloc(sizeof(int) * n);
  net = (int *)malloc(sizeof(int) * (m + 1));
  for (i = 0; i < n; i++) u[i] = -1;
  for (i = 0; i <= m; i++) net[i] = 0;

  p = 1;

  for (i = 0; i < m; i++) {
    scanf("%d", &s);
    scanf("%d", &t);
    if (s != t) {
      if (u[s] == -1 && u[t] == -1) {
    u[s] = p;
    u[t] = p;
    net[p] += 2;
    p++;
      } else {
    if (u[s] != -1 && u[t] == -1) {
      u[t] = u[s];
      net[u[s]]++;
    } else if (u[s] == -1 && u[t] != -1) {
      u[s] = u[t];
      net[u[t]]++;
    } else {
      if (u[s] != u[t]) {
        if (net[u[s]] > net[u[t]]) merge(u, net, u[t], u[s]);
        else merge(u, net, u[s], u[t]);
      }
    }
      }
    }
  }

  scanf("%d", &q);

  for (i = 0; i < q; i++) {
    scanf("%d", &s);
    scanf("%d", &t);

    if (s == t) printf("yes\n");
    else {
      if (u[s] == u[t] && u[s] != -1 && u[t] != -1) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}

void merge(int *u, int *net, int oldnet, int newnet)
{
  int i;

  for (i = 0; i < n; i++) {
    if (u[i] == oldnet) u[i] = newnet;
  }

  net[newnet] += net[oldnet];
  net[oldnet] = 0;
}

Measured memory_bytes: 3404
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 400005;
const int K = 26;
int cnt[N][K], u, f[N], sz[N];
pair < int, int > p[N];
pair < int, int > g[N][K];
string s[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    u = 1;
    for (int i = 1; i <= n; i++){
        cin >> s[i];
        int j = 0;
        int v = 1;
        while(j < s[i].length()){
            int x = s[i][j] - 'a';
            if (g[v][x].F == 0){
                u++;
                g[v][x] = {u, 1};
                sz[v]++;
                p[u] = {v, x};
            }
            cnt[v][x]++;
            v = g[v][x].F;
            j++;
            if (j == s[i].length()){
                f[v] = i;
              //  cout << "v = " << v << " i = " << i << endl;
            }
        }
    }
    for (int i = u; i >= 2; i--){
        if (sz[i] == 1 && f[i] == 0){
            int c;
            for (int j = 0; j < 26; j++){
                if (g[i][j].F != 0){
                    c = j;
                    break;
                }
            }
            auto x = p[i];
            auto y = g[i][c];
            g[x.F][x.S] = {y.F, y.S + g[x.F][x.S].S};
        }
    }
    int q;
    cin >> q;
    while(q--){
        int k;
        string t;
        cin >> k;
        cin >> t;
        int v = 1;
        int p = 0;
        int ans = 0;
        int z = n;
        while(p <= s[k].length()){
          //  cout << v << " -- " << p << " " << z << " " << f[v] << endl;
            if (z == 1){
                ans++;
                break;
            }
            if (f[v] != 0 && p == s[k].length()){
                ans++;
                break;
            }
            if (f[v] != 0) ans++;
            for (int j = 0; j < 26; j++){
                int l = t[j] - 'a';
                if (t[j] == s[k][p]){
                    z = cnt[v][l];
                    p += g[v][l].S;
                    v = g[v][l].F;
                    break;
                }
                ans += cnt[v][l];
            }
        }
        cout << ans << endl;
    }
}


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

int main(){
  int x[4],y[4];cin >> x[0] >> y[0] >> x[1] >> y[1];
  x[2]=x[1]-(y[1]-y[0]);
  y[2]=y[1]+(x[1]-x[0]);
  x[3]=x[2]-(x[1]-x[0]);
  y[3]=y[2]-(y[1]-y[0]);
  loop(i,2,4)
    cout << x[i] << " " << y[i] << " ";
  cout << endl;

  

  return 0;
}


Measured memory_bytes: 256
def myAnswer(A:int,B:int,C:int) -> int:
   l = sorted([A,B,C])
   red = l[2] // 2
   blue = l[2] // 2
   if(l[2] % 2 == 1):
      red += 1
   return abs(l[0]*l[1]*red - l[0]*l[1]*blue)
      

def modelAnswer():
   tmp=1
def main():
   A,B,C = map(int,input().split())
   print(myAnswer(A,B,C))
if __name__ == '__main__':
   main()

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

int main(){
	string s,t;
	cin >> s >> t;
	int cnt = 0;
	for(int i=0;i < s.length();i++){
		if(s.at(i) != t.at(i)){
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3472
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MOD (ll)1000000007

char a[1050][1050];
int dp[1001][1001];
bool v[1001][1001];
pii d;

struct point
{
    int x, y, time;
};

point go[4] = { {0,-1}, {0,1}, {1,0}, {-1,0} };

int main(void)
{
    int h, w;
    int cx, cy;
    scanf("%d %d", &h, &w);
    scanf("%d %d %d %d", &cx, &cy, &d.first, &d.second);
    for (int i = 1; i <= h; i++)
        scanf("%s", a[i] + 1);

    for (int i = 0; i <= h; i++)
        for (int j = 0; j <= w; j++)
            dp[i][j] = 1e9;

    queue<point> q, q2;
    point t, temp;
    q.push({ cx,cy,0 });
    q2.push({ cx,cy,0 });
    dp[cx][cy] = 0;
    while (!q.empty() || !q2.empty())
    {
        while (!q.empty())
        {
            t = q.front();
            q.pop();
            q2.push(t);
            for (int i = 0; i < 4; i++)
            {
                temp = { t.x + go[i].x,t.y + go[i].y, t.time };
                if (temp.x >= 1 && temp.x <= h && temp.y >= 1 && temp.y <= w && dp[temp.x][temp.y] == 1e9 && a[temp.x][temp.y] == '.')
                {
                    dp[temp.x][temp.y] = min(dp[temp.x][temp.y], t.time);
                    q.push({ temp.x,temp.y, dp[t.x][t.y] });
                    q2.push({ temp.x,temp.y, dp[t.x][t.y] });
                }
            }
        }
        while (!q2.empty())
        {
            t = q2.front();
            q2.pop();
            for (int x = t.x - 2; x <= t.x + 2; x++)
                for (int y = t.y - 2; y <= t.y + 2; y++)
                {
                    if (x >= 1 && x <= h && y >= 1 && y <= w && dp[x][y] == 1e9 && a[x][y] == '.')
                    {
                        dp[x][y] = t.time + 1;
                        q.push({ x,y,t.time + 1 });
                    }
                }
        }
    }

    /*for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
            printf("%d ", dp[i][j]);
        printf("\n");
    }*/
    printf("%d", dp[d.first][d.second] != 1e9 ? dp[d.first][d.second] : -1);
    return 0;
}

Measured memory_bytes: 8220
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=2e5+5;
int n,m,p[maxn],cnt[maxn];
int find(int u)
{
	if(p[u]!=u) p[u]=find(p[u]);
	return p[u];
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) p[i]=i;
    for(int i=0,x,y;i<m;i++){
		scanf("%d%d",&x,&y);
		int root1=find(x),root2=find(y);
		if(root1!=root2){
			p[root2]=root1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		int root=find(i);
		ans=max(ans,++cnt[root]);
	}
	printf("%d",ans);
}

Measured memory_bytes: 4588
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            for (var i = 1; i <= n; i++)
            {
                Console.WriteLine(F(i));
            }
        }

        static int F(int n)
        {
            var result = 0;
            var end = Math.Sqrt(n);
            // Console.WriteLine(string.Format("n: {0}, end: {1}", n, end));

            for (var i = 1; i < end; i++)
            {
                var ii = i * i;
                for (var j = 1; j < end; j++)
                {
                    var jj = j * j;
                    var ij = i * j;
                    for (var k = 1; k < end; k++)
                    {
                        var kk = k * k;
                        var r = ii + jj + kk + ij + i * k + j * k;

                        if (r == n)
                        {
                            result++;
                        }
                        if (r >= n)
                        {
                            break;
                        }
                    }
                }
            }
            return result;
        }
    }
}


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

int main(void){
    long long N, K; cin >> N >> K;
    N = N % K;
    // N < K    
    // -(N-K) - K = -N
    long long N_ = -(N - K);
    //cout << "N=" << N << ", N_ = " << N_ << endl;
    long long ans = min(N, N_);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ALL(V) (V).begin(),(V).end()
 
int main()
{
    int a,b,c;
    cin >> a >>b>>c;
    vector<int> v {a,b,c};
    sort(ALL(v));
    int fir = v[2];
    int sec = v[1];
    int thi = v[0];
    cout << (fir - sec) + (sec - thi);
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		boolean jdg =true;
		int a = c.length()-1;
		if(c.length()%2==0)a-=1;
		for(int i =  a;i >=2;i-=2) {
			for(int k = 0;k < i/2;k++) {
				if(c.charAt(k) != c.charAt(k+(i/2))) {
					jdg = false;
					break;
				}
			}
			if(jdg == true) {
				System.out.println(i);
				break;
			}
			jdg = true;
		}
	}

}


Measured memory_bytes: 21844
#AGC039-B
"""
二部グラフで無いなら分割はできない。
二部グラフの場合、頂点間の最も長い距離＋１
が答え。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
g = [[float("inf")]*n for i in range(n)]
g2 = [[] for i in range(n)] #g[i]:点iに隣接している点のリスト
for i in range(n):
    s = readline().rstrip().decode('utf-8')
    for j in range(n):
        if s[j] == "1":
            g[i][j] = 1
            g2[i].append(j)
            g2[j].append(i)
for i in range(n):
    g[i][i] = 0 #自分自身への距離は0とする

def warshall_floyd(d): #隣接行列を入れる
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

FW = warshall_floyd(g)

color = [0] * n #color[i]:点iの色(1 or -1)。但し塗られていないときは0とする

def f(v,c,g):
    #頂点vに隣接する頂点全てを塗るあるいは判定する
    color[v] = c
    for i in range(len(g[v])):
        if color[ g[v][i] ] == c:
            return False
        elif color[ g[v][i] ] == 0 and not f(g[v][i],-c,g2):
            #(g[v][i]がまだ塗られていない　かつ　そこを-cで塗っても問題ない) ではないなら
            return False
    return True

k = 1 #判定　1ならYes -1ならNo
for i in range(n):
    if color[i] == 0:
        if not f(i,1,g2):
            k = -1

if k != 1:
    print(-1)
else:
    ans = 0
    for i in FW:
        for j in i:
            if j != float("inf"):
                ans = max(ans,j)
    print(ans+1)

Measured memory_bytes: 74992
#include<bits/stdc++.h>
using namespace std;
__int128 read(){
    __int128 x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    return x*f;
}
void write(__int128 x){
    if(x<0){putchar('-');x=-x;}
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
__int128 X,K,D;
int main(){
	X=read();K=read();D=read();
	if(X>0 && X-K*D>=0) {write(X-K*D);return 0;}
	if(X<0 && X+K*D<=0) {write(-X-K*D);return 0;}
	__int128 pos_min,neg_min,foot_to_pos,foot_to_neg;
	pos_min=(X%D+D)%D;neg_min=pos_min-D;
	foot_to_pos=(X-pos_min)/D;
	foot_to_neg=(X-neg_min)/D;
	if((K-foot_to_pos)%2==0) write(pos_min);
	else write(-neg_min);
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;

string lltostr(ll n) {
  // cout << "lltostr " << n << endl;
  stringstream ss;
  ss << n;
  return ss.str();
}

ll calc(string str) {
  // ©Á±ª êÎêÔOÌ©Á±ðÍ¸·
  int p = 0, s = 0;
  // cout << "before " << str << endl;
  REP(i,str.length()) {
    if (str[i] == '(') {
      p++;
      if (p==1)
        s = i;
    }
    if (str[i] == ')') {
      if (p==1) {
        string tmp = lltostr(calc(str.substr(s+1,i-s-1)));
        str = str.substr(0,s) + tmp + str.substr(i+1);
        i = s + tmp.length()-1;
      }
      p--;
    }
  }
  p = -1;
   // cout << "remove () " << str << endl;
  REP(i,str.length()) {
    char c = str[i];
    if (c=='*' || c=='/') {
      string a = str.substr(p+1,i-p-1);
      int q = i;
      string b;
      for(i++;i<str.length();i++) {
        if (i!=q+1 && !isdigit(str[i])) {
          b = str.substr(q+1,i-q-1);
          break;
        }
      }
      if (i == str.length())
        b = str.substr(q+1);
      string tmp;
      if (c=='*')
        tmp = lltostr(atoll(a.c_str()) * atoll(b.c_str()));
      else if (c=='/')
        tmp = lltostr(atoll(a.c_str()) / atoll(b.c_str()));
      str = str.substr(0,p+1) + tmp + str.substr(i);
      i = p + tmp.length();
    }
    if (!isdigit(str[i])) {
      p = i;
    }
  }
  // cout << "cal *|/ " << str << endl;
  p = -1;
  REP(i,str.length()) {
    char c = str[i];
    if (c=='+' || c=='-') {
      string a = str.substr(p+1,i-p-1);
      int q = i;
      string b;
      for(i++;i<str.length();i++) {
        if (i!=q+1 && !isdigit(str[i])) {
          b = str.substr(q+1,i-q-1);
          break;
        }
      }
      if (i == str.length())
        b = str.substr(q+1);
      string tmp;
      if (c=='+')
        tmp = lltostr(atoll(a.c_str()) + atoll(b.c_str()));
      else if (c=='-')
        tmp = lltostr(atoll(a.c_str()) - atoll(b.c_str()));
      str = str.substr(0,p+1) + tmp + str.substr(i);
      i = p + tmp.length();
    }
    if (!isdigit(str[i])) {
      p = i;
    }
  }
  // cout << "cal +|- " << str << endl;
  return atoll(str.c_str());
}

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while(n--) {
    string s;
    getline(cin,s);
    s = s.substr(0,s.length()-1);
    cout << calc(s) << endl;
  }
}

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

using namespace std;

const int maxn = 1005;

bool a[maxn][maxn],one[maxn],ex[maxn];
int n,zero[maxn];

int main()
{
	scanf("%d", &n);
	bool ap = 0;
	for(int i = 1;i <= n;i ++) one[i] = 1;
	for(int i = 1;i <= n;i ++)
		for(int j = 1;j <= n;j ++)
		{
			char c;
			while (c = getchar(),c != '#' && c != '.');
			a[i][j] = (c == '#');
			one[j] &= (c == '#');
			ex[j] |= (c == '#');
			zero[i] += (c == '.');
			ap |= (c == '#');
		}
	if (!ap) {printf("-1\n");return 0;}
	int ans = 0,mi = (1 << 30);
	for(int i = 1;i <= n;i ++) if (!one[i]) ++ ans;
	for(int k = 1;k <= n;k ++)
	{
		if (!zero[k]) {mi = 0;break;}
		if (ex[k]) mi = min(mi,zero[k]); else mi = min(mi,zero[k] + 1);
	}
	printf("%d\n", ans + mi);
	return 0;
}


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

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

using namespace std;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	long long total = 0;
	long long ans = 0;
	if (K <= A)cout << K;
	else if (K <= (A + B))cout << A;
	else cout << A - (K-A-B);
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,S=0,T=0,x;cin>>N;
  for(int i=0;i<N;i++){cin>>x;S+=x;T+=x*x;}
  x=(2*S+N)/(2*N);
  cout<<N*x*x-2*S*x+T;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//FUNCTION

void solve(void)
{
  int N,K; cin>>N; cin>>K;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  int L,R;
  for (int i = 0; i < N; i++)
  {
    if(vec[i] == 1)
    {
      L = i;
      R =N - i -1;
      break;
    }
  }
  int ANS = 1;
  int X = N - K;
  while(X>0)
  {
    X -= (K-1);
    ANS++;
  }

  cout<< ANS <<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 1024
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int dp1[10];
int dp2[100];
int dp3[1000];

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;

  rep(i, N){
    int d = S[i] - '0';
    int d2 = -1;
    int d3 = -1;
    rep(j, 100) if(dp2[j]) {
      d3 = j * 10 + d;
      dp3[d3] = 1;
    }
    rep(j, 10) if(dp1[j]) {
      d2 = j * 10 + d;
      dp2[d2] = 1;
    }
    dp1[d] = 1;
  }
  int ans = 0;
  rep(i, 1000){
    if(dp3[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;
int main(void){

  int a,b,k;
  bool flag = true;

  cin >> a >> b >> k;

  for(int i=0; i < k; i++){

    if(flag){
      if(a % 2 == 1){
        a -= 1;
      }

      a /= 2;
      b += a;

      flag = false;

    }
    else{
      if(b % 2 == 1){
        b -= 1;
      }

      b /= 2;
      a += b;

      flag = true;

    }

  }

  printf("%d %d", a, b);


}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    static long count = 0;
     
    static void mergeSort(int[] A, int left, int right) {
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            mergeSort(A, left, mid);
            mergeSort(A, mid, right);
            merge(A, left, mid, right);
        }
    }
     
    static void merge(int[] A, int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;
        int[] L = new int[n1 + 1];
        int[] R = new int[n2 + 1];
         
        for (int i = 0; i < n1; i++) {
            L[i] = A[left + i];
        }
 
        for (int i = 0; i < n2; i++) {
            R[i] = A[mid + i];
        }
         
        L[n1] = Integer.MAX_VALUE;
        R[n2] = Integer.MAX_VALUE;
         
        int i = 0, j = 0;
 
        for (int k = left; k < right; k++) {
            if (L[i] <= R[j]) {
                A[k] = L[i++];
            }
            else {
            	// バブルソートで交換が発生する場合。
            	// 回数は、今回ソートする範囲が(right -left)の長さで、
            	// 交換される値R[j]からL[i]までの交換回数になる
            	count += mid - (left + i);
                A[k] = R[j++];
            }
        }
    }
     
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
 
        int n = scan.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = scan.nextInt();
        }
         
        mergeSort(S, 0, n);
 
        System.out.println(count);
         
        scan.close();
    }
}

Measured memory_bytes: 96448
N,A,B = list(map(int,input().split()))
ans = []
if N >= A + B - 1 and N <= A *B:
    for i in range(A):
        ans.append(str(N - A +1 + i))
        for j in range(B-1):
            if i * (B -1 ) + (B -1 -j) > N - A + B:
              break
            elif i * (B-1) + (B -1 - j ) >= N - A + 1:
                continue
            #print(i * (B-1) + (B-1 -j))
            ans.append(str(i * (B-1) + (B-1 - j )))
else:
    ans = ["-1"] 
print(" ".join(ans))

Measured memory_bytes: 27928
#include <bits/stdc++.h>
using namespace std;
int main(){
  string O,E;cin>>O>>E;
  for(int i=0;i<O.size();i++){
    cout << O.at(i);
    if(i<E.size()){
      cout << E.at(i);
    }
  }
  cout<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n, a, b, c, d;
    scan(n, a, b, c, d);
    auto s = readln.chomp;

    a--, b--, c--, d--;

    bool ac, bd;
    ac = bd = true;

    foreach (i ; a .. c) {
        if (s[i] == '#' && s[i + 1] == '#') {
            ac = false;
            break;
        }
    }

    foreach (i ; b .. d) {
        if (s[i] == '#' && s[i + 1] == '#') {
            bd = false;
            break;
        }
    }

    bool dc;

    if (c < d) {
        dc = true;
    }
    else {
        foreach (i ; b - 1 .. d) {
            if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
                dc = true;
                break;
            }
        }
    }

    yes(ac && bd && dc);
}























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 636
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int min = N + 1;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int p = in.i();
            if (p < min) {
                min = p;
                ans++;
            }
        }
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 35660
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := nextInt(), nextInt(), nextInt()
	if (a < c && c < b) || (a > c && c > b) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;

const int inf = (int)1e9; 

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


int main(void){
	int n;
	cin>>n;
	vector<ll>a(n),seq1,seq2;
	for(ll i=0;i<n;i++)cin>>a[i];
	seq1.push_back(a[0]);
	for(ll i=0;i<n;){
		int j = i;
		while(true){
			if(i==n-1){
				if(a[i-1]!=a[i])seq1.push_back(a[i]);
				i++;
				break;
			}
			if(a[j]==a[i])i++;
			else{
				seq1.push_back(a[i]);
				break;
			}
		}
	}
	if(seq1.size()==1){
		cout<<1000<<endl;
		return 0;
	}
	seq2.push_back(seq1[0]);
	for(ll i=0;i<seq1.size();){
		if(seq1[i]<seq1[i+1]){
			while(true){
				if(i==seq1.size()-1){
					seq2.push_back(seq1[i]);
					i++;
					break;
				}
				if(seq1[i]<seq1[i+1])i++;
				else{
					seq2.push_back(seq1[i]);
					break;
				}
			}
		}
		else{
			while(true){
				if(i==seq1.size()-1){
					seq2.push_back(seq1[i]);
					i++;
					break;
				}
				if(seq1[i]>seq1[i+1])i++;
				else{
					seq2.push_back(seq1[i]);
					break;
				}
			}
		}
	}
	ll ans = 1000;
	if(seq2[0]<seq2[1]){
		for(ll i=0;i<seq2.size();){
			if(i==seq2.size()-1)break;
			if(seq2[i]<seq2[i+1]){
				ll t = ans/seq2[i];
				ans -= t*seq2[i];
				ans += t*seq2[i+1];
				i+=2;
			}
		}
	}
	else{
		for(ll i=1;seq2.size();){
			if(i==seq2.size()-1)break;
			if(seq2[i]<seq2[i+1]){
				ll t = ans/seq2[i];
				ans -= t*seq2[i];
				ans += t*seq2[i+1];
				i+=2;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll A, B;
  cin >> A >> B;
  if(A>=13)cout << B;
  else if(A>=6) cout << B/2;
  else cout << 0;
  return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ll N;
    cin >> N;

    ll d = N%10;

    if(d==0 || d==1 || d==6 || d==8) cout << "pon" << endl;
    else if(d==3) cout << "bon" << endl;
    else cout << "hon" << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

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

int main(){

	while(true){
		int n;
		cin >> n;
		if(n == 0)break;
		vector<int> A(n);
		int sum = 0;
		for(int i = 0; i < n; i ++){
			cin >> A[i];
			sum += A[i];
		}
		int ans = 0;
		for(int i = 0; i < n; i ++){
			if(A[i] * n <= sum)ans ++;
		}
		cout << ans << endl;
	}

	return 0;
}


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

long long gcd(long long a, long long b) {
  return b ? gcd(b,a%b) : a;
}

int pf_count(long long n) { //素数の約数の個数
  int c=1;
  for(int i=2;i<=sqrt(n);i++) {
    if(n%i==0) {
      while(n%i==0) {
        n /= i;
      }
      c++;
    }
  }
  if(n>1) c++;
  return c;
}

int main() {
  long long a,b;
  long long gcdab;
  int res;

  cin >> a >> b;

  gcdab = gcd(a,b);

  res = pf_count(gcdab);

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
import itertools

n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

"""Aの組み合わせ毎の合計を集合Bに追加"""
B = {sum(v) for i in range(n) for v in itertools.combinations(A, i+1)}

for m in M:
    print('yes' if m in B else 'no')


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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0;i<n;i++)cin >> a[i];
	ll ans = 0;
	for(int i = 0;i<n;i++)
	{
		while(a[i]%2==0)
		{
			ans ++;
			a[i]/=2;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{

    int n,s=0,k,i,h=0;
    cin>>k>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    s=a[n-1]-a[0];
    for(i=1;i<n-1;i++)
    {
        h=a[i]+(k-a[(i+1)]);
        if(h<s)
            s=h;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
int64 A[200000];
int64 H[200000];
int main() {
	memset(A, 0, sizeof(A));
	memset(H, 0xFF, sizeof(H));
	int64 N, K, tmp;
	cin >> N >> K;
	rep(i, N) {
		cin >> tmp;
		tmp--;
		A[i] = tmp;
	}
	int now = 0, loop;
	H[0] = 0;
	for (int64 i = 1; i <= K; ++i) {
		now = A[now];
		if (H[now] == -1) H[now] = i;
		else {
			loop = i - H[now];
			int64 a = (K-i) / loop;
			i += a * loop;
		}
	}
	
	cout << (now+1) << "\n";

	return 0;
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll INF = 1e14+7;
    ll MOD = 998244353;
    typedef pair<ll,ll> ii;
    #define f(i,a,b) for(long long i = a;i < b;i++)
    #define rf(i,a,b) for(long long i=a;i>=b;i--)
    #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define w(t) while(t--)
    #define c(n); cin>>n;
    #define p(n) cout<<n;
    #define pl(n) cout<<n<<endl;
    #define ps(n); cout<<n<<" ";
    #define F first
    #define S second
    #define pb(a) push_back(a)
    ///I hope I will get uprating and don't make mistakes
    ///I will never stop programming
    ///sqrt(-1) Love C++
    /// @TheofanisOrfanou Theo830
    ///AtCoder Beginner Contest 151
    int main(void){
        fastio;
        ll h,w;
        c(h);
        c(w);
        char arr[h][w];
        ll s1=-1,s2=1;
        ll dist[21][21][21][21];
        f(i,0,21){
            f(j,0,21){
                f(ki,0,21){
                    f(kj,0,21){
                        dist[i][j][i][j] = 0;
                        dist[i][j][ki][kj] = INF;
                    }
                }
            }
        }
        f(i,0,h){
            f(j,0,w){
                c(arr[i][j]);
                if(arr[i][j] == '.'){
                    if(j+1 < 21)
                    dist[i][j][i][j+1] = 1;
                    if(j > 0)
                    dist[i][j][i][j-1] = 1;
                    if(i > 0)
                    dist[i][j][i-1][j] = 1;
                    if(i+1<21)
                    dist[i][j][i+1][j] = 1;
                    dist[i][j][i][j] = 0;
                }
                else{
                    f(ki,0,21){
                        f(kj,0,21){
                            dist[i][j][ki][kj] = INF;
                        }
                    }
                }
            }
        }
        f(ki,0,h){
            f(kj,0,w){
                f(i,0,h){
                    f(j,0,w){
                        f(ii,0,h){
                            f(jj,0,w){
                                if(arr[i][j] == '.' && (arr[ii][jj] == '.' && arr[ki][kj] == '.') )
                                dist[i][j][ii][jj] = min(dist[i][j][ii][jj],dist[i][j][ki][kj] + dist[ki][kj][ii][jj]);
                            }
                        }
                    }
                }
            }
        }
        ll ans = -INF;
        f(i,0,h){
            f(j,0,w){
                f(ki,0,h){
                    f(kj,0,w){
                        if(dist[i][j][ki][kj] < INF)
                        ans = max(ans,dist[i][j][ki][kj]);
                        //cout<<"("<<i<<","<<j<<") ("<<ki<<","<<kj<<")"<<" = "<<dist[i][j][ki][kj]<<endl;
                    }
                }
            }
        }
        pl(max(ans,0LL));
    }


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const double delta=acos(-1)*5-20;
const double E=acos(-1)*10-20;
const int inf=1e8;

const int N=200005;
int n,X1,Y1,X2,Y2,m;
double s;
bool rev;
pi v[N];
map<int,int> fx,fy;

int ABS(int x){return x<0?-x:x;}
int solve(){
	static int st[N],mx;
	mx=0;memset(st,0,sizeof(st));
	for(int i=1;i<=m;i++){
		int now=upper_bound(st,st+mx+1,v[i].se)-st;
		if(now>mx)mx=now,st[mx]=v[i].se;else st[now]=min(v[i].se,st[now]);
	}
	return mx;
}

int main(){
	scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
	s=ABS(X1-X2)+ABS(Y1-Y2);s*=100;
	if(X1>X2)swap(X1,X2),swap(Y1,Y2);
	scanf("%d",&n);
	if(Y1>Y2)rev=true,Y1=inf-Y1,Y2=inf-Y2;
	for(int i=1,x,y;i<=n;i++){
		scanf("%d%d",&x,&y);
		if(rev)y=inf-y;
		if(X1<=x&&x<=X2&&Y1<=y&&y<=Y2)fx[x]=y,fy[y]=x,v[++m]={x,y};
	}
	sort(v+1,v+m+1);
	int t=solve();
	if(fx.count(X1)&&fx.count(X2)&&fx[X1]<=fx[X2]&&t==X2-X1+1)s+=(X2-X1)*delta+E;
	else if(fy.count(Y1)&&fy.count(Y2)&&fy[Y1]<=fy[Y2]&&t==Y2-Y1+1)s+=(Y2-Y1)*delta+E;
	else s+=t*delta;
	printf("%.13lf\n",s);
	return 0;
}

Measured memory_bytes: 21376