akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.1415926535

int main() {
    ll n;
    cin >> n;
    vector<tuple<string, ll, ll>> res(n);
    for(ll i = 0; i < n; i++){
        string s;
        ll p;
        cin >> s >> p;
        res[i] = make_tuple(s, -p, i + 1);
    }
    sort(res.begin(), res.end());
    for(ll i = 0; i < n; i++){
        cout << get<2>(res[i]) << endl;
    }
    
}


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

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n){
        int num = i+1;
        if(to_string(num).size()%2 == 1) ++cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int p[n];
    rep(i,n)cin >> p[i];
    int max=0,ans=0;
    
    rep(i,n){
        ans+=p[i];
        if(p[i]>max)max=p[i];
    }
    
    cout << ans - max/2;
    
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int dp[100][100];

int main() {
    ll x, y;
    cin >> x >> y;

    cout << (abs(x-y) <= 1 ? "Brown" : "Alice") << endl;

    REP(s,100) REP(x,s+1) REP(y,s+1-x){
        int i = x, j = y;
        if (i + j >= 99) continue;
        if (i <= 1 && j <= 1) continue;
        bool f = false;
        for (int p = 2; p <= i; p += 2) if (dp[i-p][j+p/2] == 0) f = true;
        for (int p = 2; p <= j; p += 2) if (dp[i+p/2][j-p] == 0) f = true;
        dp[i][j] = f;
    }

    // REP(i,30){
    //     REP(j,30){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <map>
using namespace std;

typedef pair<int,int> P;
// massÌîñ
bool isRead[21];
int n;
map<pair<P,P>,int > idxs;

const int INF=100000000;

int resSize=0;
int res[100];

// R}ðÄAIÉÇñÅ¢­
void readComma(vector<pair<P,P> > mass){
    sort(mass.begin(),mass.end());
    // EãÌ¨©çTõµÄ¢­
    for(int i = 0; i < mass.size(); i++){
        int s=idxs[mass[i]];
        if(isRead[s-1])
            continue;
        isRead[s-1]=true;
        // Ü¾ÇñÅ¢È¢àÌÌê
        //cout<<s<<endl;
        res[s-1]=resSize+1;resSize++;

        // »ÝÌ}XÌEºÌ¸_
        P p = P(mass[i].first.first,mass[i].second.second);
        // ÕË·éxÀW
        int crashX=INF;
        // ðð½·}XðTõ
        for(int j = 0; j < mass.size(); j++){
            int ss=idxs[mass[j]];
            if(isRead[ss-1])
                continue;
            // ºüð¶ÉLÎµÄ¢ÁÄAÔÂ©éÀWðTõ
            if(mass[j].first.second<p.second&&mass[j].second.second>p.second)
                crashX=min(crashX,-mass[j].first.first);
        }
        vector<pair<P,P> > nmass;
        if(i==1){
  //          cout<<endl;
        }
        // crashXæèEÉSÌªûÜèA©ÂÜ¾ÇÜêÄ¢È¢àÌðXgAbv
        for(int j = 0; j < mass.size(); j++){
            int ss=idxs[mass[j]];
            if(isRead[ss-1])
                continue;
            if(mass[j].second.second<=p.second&&mass[j].second.first<=crashX)
                nmass.push_back(mass[j]);
        }
        readComma(nmass);
    }
}

int main(){

    bool first=true;
    while(cin>>n&&n!=0){
        if(first)
            first=false;
        else
            cout<<endl;
        vector<pair<P,P> > mass;
        idxs.clear();
        fill(isRead,isRead+21,false);
        for(int i = 0; i < n; i++){
            pair<P,P> p;
            int x1,x2,y1,y2;
            cin>>x1>>y1>>x2>>y2;
            p.first=P(x1,y1);p.second=P(x2,y2);
            mass.push_back(p);
            idxs[p]=i+1;
        }
        // ¶ãÌÀWÅ\[g
        sort(mass.begin(),mass.end());
        // ðð½·}X©çÔÉÄAIÉÇñÅ¢­
        readComma(mass);
        for(int i = 0; i < resSize; i++)
            cout<<res[i]<<endl;
        resSize=0;
    }

    return 0;
}

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

int main()
{
	int H, W;

	while (1) {
		cin >> H >> W;

		if (H == 0 && W == 0) {
			break;
		}

		for (int i = 0; i < W; i++) {
			cout << "#";
		}

		cout << endl;

		for (int i = 0; i < H - 2; i++) {
			cout << "#";
			for (int j = 0; j < W - 2; j++) {
				cout << ".";
			}
			cout << "#" << endl;
		}

		for (int i = 0; i < W; i++) {
			cout << "#";
		}
		cout << endl << endl;
	}

	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,n,k,a[102],s=0;
cin>>n;
for(i=0;i<n;i++){
  cin>>a[i];
 }
 sort(a,a+n);
    for(i=0;i<n;i++){s+=a[i];}
    if(s%10==0){
        
  for(i=0;i<n;i++){
        s=0;
 for(j=0;j<n;j++){if(i!=j){s+=a[j];}}
            if(s%10!=0){break;}
 }
     if(i==n) {s=0;}

  }
    cout<<s<<endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int h,n;
    cin>>h>>n;
    int a=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a+=x;
    }
    if(a>=h)cout<<"Yes";
    else cout<<"No";
}


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

#define INF (1 << 30)

inline int min(int a, int b)
{
    return (b > a ? a : b);
}

int main(void)
{
    int i, j, k;
    int n;
    int div[10001];
    static int dp[2][5001][2];
    
    scanf("%d", &n);
    
    for (i = 1; i <= n - 1; i++){
        scanf("%d", &div[i]);
    }
    
    for (i = 0; i < 2; i++){
        for (j = 0; j <= n / 2; j++){
            dp[i][j][0] = dp[i][j][1] = INF;
        }
    }
    dp[0][0][0] = dp[0][0][1] = 0;
    
    for (i = 0; i <= n / 2; i++){
        for (j = 0; j <= n / 2; j++){
            if (i > 0){
                dp[i & 1][j][0] = dp[(i - 1) & 1][j][0];
                dp[i & 1][j][1] = dp[(i - 1) & 1][j][0] + div[i + j];
            }
            if (j > 0){
                dp[i & 1][j][0] = min(dp[i & 1][j][0], dp[i & 1][j - 1][1] + div[i + j]);
                dp[i & 1][j][1] = min(dp[i & 1][j][1], dp[i & 1][j - 1][1]);
            }
        }
    }
    
    printf("%d\n", min(dp[0][n / 2][0], dp[0][n / 2][1]));
    
    return (0);
}

Measured memory_bytes: 480
from collections import deque

H, W, K = map(int, input().split())
sx, sy, tx, ty = map(lambda a: int(a) - 1, input().split())
INF = 10**18

A = [input() for _ in range(H)]

minDist = [[INF] * W for _ in range(H)]
minDist[sx][sy] = 0
que = deque([(0, sx, sy)])

while que:
    dist, nx, ny = que.popleft()

    for i in range(1, K + 1):
        if nx + i >= H:
            break
        if minDist[nx + i][ny] <= dist or A[nx + i][ny] == '@':
            break
        if minDist[nx + i][ny] > dist + 1:
            minDist[nx + i][ny] = dist + 1
            que.append((dist + 1, nx + i, ny))
    for i in range(1, K + 1):
        if nx - i < 0:
            break
        if minDist[nx - i][ny] <= dist or A[nx - i][ny] == '@':
            break
        if minDist[nx - i][ny] > dist + 1:
            minDist[nx - i][ny] = dist + 1
            que.append((dist + 1, nx - i, ny))
    for i in range(1, K + 1):
        if ny + i >= W:
            break
        if minDist[nx][ny + i] <= dist or A[nx][ny + i] == '@':
            break
        if minDist[nx][ny + i] > dist + 1:
            minDist[nx][ny + i] = dist + 1
            que.append((dist + 1, nx, ny + i))
    for i in range(1, K + 1):
        if ny - i < 0:
            break
        if minDist[nx][ny - i] <= dist or A[nx][ny - i] == '@':
            break
        if minDist[nx][ny - i] > dist + 1:
            minDist[nx][ny - i] = dist + 1
            que.append((dist + 1, nx, ny - i))

ans = minDist[tx][ty]
print(ans if ans < INF else -1)


Measured memory_bytes: 131768
#!/usr/bin/env python
# coding: utf-8


def main():
    n = int(input())
    t, a = list(map(int, input().split()))
    hs = list(map(int, input().split()))
    best_t, best_i = None, None
    for i, h in enumerate(hs):
        temp = t - h * 0.006
        if best_t is None or abs(temp - a) < best_t:
            best_t = abs(temp - a)
            best_i = i+1
    print(best_i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define H ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
using namespace std;
const ll  mod = 998244353;

    int frq[200001];

int main()
{
    H
    int h, w, n;
    cin >> h >> w >> n;
    int x, i = 0, j = 0, arr[h][w];
    for (int q = 0; q < n; q++){
        cin >> x;
        while (x--){
           arr[i][j] = q + 1;
           i % 2 == 0 ? j++ : j--;
           if (j == w){
               i++;
               j--;
           }
           else if (j == -1){
               i++;
               j++;
           }
        }
    }
    for (int k = 0; k < h; k++){
        for (int l = 0; l < w; l++){
            cout << arr[k][l];
            if (l < w - 1) cout << ' ';
        }
        cout << '\n';
    }
    return 0 ;
}


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

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    int count = 0;
    for(int n = A;n<=B;n++){
        string ns = to_string(n);
        bool kaibun = true;
        for(int i=0;i<ns.size()/2;i++){
            if(ns[i] != ns[ns.size()-1-i]){
                kaibun = false;
                break;
            }
        }
        if(kaibun){
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0;
    cin>>n;
    int arr[n-1];
    for(int i=0;i<n-1;i++)
    {
        cin>>arr[i];
        if(i!=0)
        {
            if(arr[i]>=arr[i-1])
                sum+=arr[i-1];
            else sum+=arr[i];
        }
    }
    sum+=(arr[0]+arr[n-2]);
    cout<<sum;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
using namespace std;
int H,W;

int tkj(int h,int w){
	return (h*h+w*w);
}

int main(void){
  
  while(cin>>H>>W&&H>0){
    const pair<int,int> given(tkj(H,W),H);
  pair<int,int>best(tkj(150,150),150),ans;
  for(int h=1;h<=150;h++){
    for(int w=1;w<=150;w++){
      if(w<=h)continue;
      pair<int,int>x(tkj(h,w),h);
      if(given<x&&x<best){
	best=x;
	ans=make_pair(h,w);
      }
    }
  }
  cout<<ans.first<<" "<<ans.second<<endl;
}
}

Measured memory_bytes: 1160
n = int(input())
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

f = list(set(prime_factors(n)))
ans = 0
for i in f:
    e = 1
    while n % i**e == 0:
        n = n//(i**e)
        ans += 1
        e+=1

print(ans)  

Measured memory_bytes: 9100
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int dp[100005][13];

void solve(){
   string s;
   cin >> s;

   int n = s.size();

   dp[0][0] = 1;

   for(int i = 0;i<n;i++){
        for(int j = 0;j<13;j++){
            //for(int k = 0;k<10;k++){

                if(s[i]=='?'){
                    for(int k= 0;k<10;k++)
                    (dp[i+1][(j*10+k)%13]+=dp[i][j])%=mod;
                }
                else{
                    (dp[i+1][(j*10 + s[i]-'0')%13]+=dp[i][j])%=mod;
                }
            
        }
   }

   cout << dp[n][5]<<endl;

} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 10704
#include <iostream>
#include <string>

int main(){
	const int topping = 100;
	const int ramen = 700;
	int price = ramen;
	std::string s;

	std::cin >> s;

	for(int i = 0; i < 3; ++i){
		if(s[i] == 'o'){
			price += topping;
		}
	}

	std::cout << price << std::endl;

	return 0;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, k, a[MAXN];

bool check(int u) {
    ll cnt = 0;
    FOR(i,1,n) {
        int pieces = a[i] / u + (a[i] % u > 0);
        cnt += pieces - 1;
    }
    return cnt <= k;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    FOR(i,1,n) cin >> a[i];
    int dau = 1, cuoi = 1000000000;
    while (dau <= cuoi) {
        int mid = (dau + cuoi) >> 1;
        if (check(mid)) cuoi = mid-1;
        else dau = mid+1;
    }
    cout << dau;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int t[n + 1], x[n + 1], y[n + 1];
    t[0] = x[0] = y[0] = 0;
    for (int i = 0; i < n; i++)
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];

    bool ans = true;
    for (int i = 0; i < n; i++) {
        int dt = t[i + 1] - t[i];
        int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        if (dt < dist || dt % 2 != dist % 2)
            ans = false;
    }

    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1408
//	-*- mode: C++ -*-
//	Search III
//		Your task is to write a program of a simple dictionary which implements the following instructions:
//
//		insert str: insert a string str in to the dictionary
//		find str: if the distionary contains str, then print 'yes', otherwise print 'no'
//	Input
//		In the first line n, the number of instructions is given. In the following n lines, n instructions are given in the above mentioned format.
//
//	Output
//		Print yes or no for each find instruction in a line.
//
//	Constraints
//		A string consists of 'A', 'C', 'G', or 'T'
//		1 ≤ length of a string ≤ 12
//		n ≤ 1000000
//	Sample Input 1
//		5
//		insert A
//		insert T
//		insert C
//		find G
//		find A
//	Sample Output 1
//		no
//		yes
//	Sample Input 2
//		13
//		insert AAA
//		insert AAC
//		insert AGA
//		insert AGG
//		insert TTT
//		find AAA
//		find CCC
//		find CCC
//		insert CCC
//		find CCC
//		insert T
//		find TTT
//		find T
//	Sample Output 2
//		yes
//		no
//		no
//		yes
//		yes
//		yes

#include <iostream>
#include <vector>
#include <string>

struct HashList{
	std::string	keyWord;
	HashList*	Next;

	HashList();
};

HashList::HashList(): Next(nullptr)
{
}

class HashTable{
private:
	static const unsigned int	hashSize	= 1024 * 1024;
	const unsigned int	maxKeySize	= 12;
	HashList*			hashList[hashSize]	{nullptr};
	std::vector<std::string>	result;

	unsigned int	getChar(const char	ch);
	unsigned int	getKey(const std::string	str);
public:
	HashTable();
	~HashTable();

	void	insert(const std::string	str);
	void	find(const std::string	str);
	void	print(void);
};

unsigned int	HashTable::getChar(const char	ch)
{
	if(ch == 'A'){
		return	1;
	}
	else if(ch == 'C'){
		return	2;
	}
	else if(ch == 'G'){
		return	3;
	}
	else{
		return	4;
	}
}

unsigned int	HashTable::getKey(const std::string	str)
{
	unsigned long long	sum	{0};
	unsigned long long	p	{1};

	for(unsigned int i = 0; i < str.length(); i++){
		sum	+= p * (getChar(str[i]));
		p *= 5;
	}

	return	static_cast<unsigned int>(sum % hashSize);
}

HashTable::HashTable()
{
}

HashTable::~HashTable()
{
}

void	HashTable::insert(const std::string	str)
{
	unsigned int	key	= getKey(str);
	HashList**		pp	= &hashList[key];
	HashList*		p	= hashList[key];

	while(p != nullptr){
		if(p->keyWord == str){
			return;
		}
		pp	= &(p->Next);
		p	= p->Next;
	}

	*pp	= new	HashList;
	p	= *pp;
	p->keyWord	= str;
}

void	HashTable::find(const std::string	str)
{
	unsigned int	key	= getKey(str);
	HashList*		p	= hashList[key];

	while(p != nullptr){
		if(p->keyWord == str){
			result.push_back("yes");
			return;
		}

		p	= p->Next;
	}

	result.push_back("no");
}

void	HashTable::print(void){
	for(auto res : result){
		std::cout << res << '\n';
	}
}

HashTable	h;

int	main(int	argc,
		 char*	argv[])
{
	unsigned int	count	{0};

	std::cin >> count;

	for(auto i = 0; i < count; i++){
		std::string	command	{};
		std::string	str	{};

		std::cin >> command >> str;

		if(command[0] == 'i'){
			h.insert(str);
		}
		else{
			h.find(str);
		}
	}

	h.print();

	return	0;
}



Measured memory_bytes: 59176
def read_int():
    return int(input())


def read_ints():
    return map(int, input().split(' '))


r, c = read_ints()
s = []
for i in range(r):
    s.append(input())
inf = int(1e9)
dp = [[inf for j in range(c)] for i in range(r)]
dp[0][0] = 1 if s[0][0] == '#' else 0
for i in range(r):
    for j in range(c):
        if i > 0:
            dp[i][j] = dp[i - 1][j]
            if s[i][j] == '#' and s[i - 1][j] == '.':
                dp[i][j] += 1
        if j > 0:
            another = dp[i][j - 1]
            if s[i][j] == '#' and s[i][j - 1] == '.':
                another += 1
            dp[i][j] = min(dp[i][j], another)
print(dp[r - 1][c - 1])


Measured memory_bytes: 42352
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var T = cin.ReadInt;

            var ctList = new List<KeyValuePair<int, int>>();
            for(var i=0; i<N; i++)
            {
                ctList.Add(new KeyValuePair<int, int>(cin.ReadInt, cin.ReadInt));
            }
            var sortedctList = ctList.OrderBy((x) => x.Key);
            foreach(var ct in sortedctList)
            {
                if(ct.Value <= T)
                {
                    WriteLine(ct.Key);
                    return;
                }
            }
            WriteLine("TLE");
        }

        static long GcdArray(long[] array)
        {
            var ans = array[0];
            for(var i=1; i<array.Length; i++)
            {
                ans = Gcd(ans, array[i]);
            }
            return ans;
        }

        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

const int mx = 1000005;
int prime[mx], ps[mx];

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    rep(i, 2, mx) prime[i] = true;
    rep(i, 2, mx) for (ll j = 1ll * i * i; j < mx; j += i) prime[j] = false;

    while (true) {
        int a, d, n; cin >> a >> d >> n;
        if (!a) break;
        int i, j;
        for (i = 0, j = a; i < n; j += d) {
            if (prime[j]) i++;
        }
        cout << j - d << endl;
    }
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
	int N;
	cin >> N;
	if((N/10)%111==0 || (N%1000)%111==0){
	    cout << "Yes" << endl;
	}else{
	    cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  ll Q, H, S, D, N; cin >> Q >> H >> S >> D >> N;

  ll l2 = N/2 * min({Q*8, H*4, S*2, D});
  ll l1 = N%2 * min({Q*4, H*2, S});

  cout << l2+l1 << endl;
}

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

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int n, l;
    cin>>n>>l;
    int a[n+1];
    int sum = 0;
    for(int i = 1;i <= n;i++) {a[i] = i+l-1; sum += a[i];}

    int mind = INT_MAX;
    int ans = -1;
    for(int i = 1;i <= n;i++) {
        int diff = sum - a[i];
        if(abs(sum - (sum - a[i])) < mind) {
            mind = abs(sum - (sum - a[i]));
            ans = sum - a[i];
        }
        
    }

    // cout<<sum<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
   О НЕТ! ОНИ ДОГОНЯЮТ!!!
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
*/

#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ll n, x;
    cin >> n >> x;
    cout << 3 * (n - __gcd(n, x)) << '\n';
}


Measured memory_bytes: 384
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    while 1:
        n = I()
        if n == 0:
            quit()
        a = LI()
        m = sum(a)/n
        c = 0
        for i in range(n):
            if a[i] <= m:
                c += 1
        print(c)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    A()



Measured memory_bytes: 9140
using System;

namespace Atcoder2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            double N = int.Parse(input[0]);
             double D = int.Parse(input[1]);
            double n = N/( 2 * D + 1);
            double x = Math.Ceiling(n);
            Console.Write(x);
            
        }
    }
}

Measured memory_bytes: 13140
use v5.26;
my @cards = glob <>;
my $k = <>;
my $cnt = 0;
for my $i (0 .. $#cards - 1) {
  while ($cards[$i] >= $cards[$i + 1]) {
    $cards[$i + 1] *= 2;
    $cnt++;
  }
}
say $k - $cnt >= 0 ? 'Yes' : 'No';


Measured memory_bytes: 5272
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n%2 == 0) return false;
    if(n%3 == 0) return false;
    // 2と3の倍数でないので6の倍数ではないことが保証された

    if(n%6 != 1 && n%6 != 5) return false;
    // 6の倍数前後の数(素数かもしれない数)であることが保証された

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i=5;i*i<=n;i+=6){
        if(n%i     == 0) return false; // 6n-1
        if(n%(i+2) == 0) return false; // 6n+1
    }

    return true;
}
int main(){
    CIN(N);
    int now = 2;
    I vec;
    for(int a = 0;a < N;a++){
        for(;now < 55556;now++){
            if(is_prime(now)&&now%10==1){
                vec.pb(now);
                now++;
                break;
            }
        }
    }
    REP(a,N-1){
        cout<<vec.at(a)<<" ";
    }
    cout<<vec.at(N-1)<<endl;
    return 0;
}


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

#include<cstdio>

int main(){
  char ch;
  while(1){
    scanf("%c", &ch);
    if (islower(ch)) printf("%c",toupper(ch));
    if (isupper(ch)) printf("%c",tolower(ch));
    if (!isalpha(ch)) printf("%c",ch);
    if (ch=='\n') break;
  }

  return 0;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	string ans;
	int size=s.size();
	for(int i=0;i<size;i++){
		if(s[i]=='0'){
			ans+=s[i];
		}else if(s[i]=='1'){
			ans+=s[i];
		}else{
			if(ans.size()>0){
				ans.erase(ans.size()-1);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

ll pow5(ll x){
  return x*x*x*x*x;
}

int main(){
  ll X;cin >> X;
  //(i) A^5 + B^5 = X
  for(ll A=0;true;A++){
    ll Y = X - pow5(A);
    for(ll B=0;pow5(B)<=abs(Y);B++){
      if(pow5(B)==abs(Y)){
        if(Y>0){
          cout << A << " -" << B << endl;
        }else{
          cout << A << " " << B << endl;
        }
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll int
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cout<<"Case #"<<v1+1<<": ";



int main()
{
    fastio
    ll t,i,j,x,f;
    //cin>>t;
    
    
    ll n;
    string s;
    cin>>n>>s;
    ll res=0;
    ll start=n,end=-1;
    
    for(i=0;i<n;i++)
    {
        if(s[i]=='W')
        {
            start=i;
            break;
        }
    }
    
    for(i=n-1;i>=0;i--)
    {
        if(s[i]=='R')
        {
            end=i;
            break;
        }
    }
    if(start>end)
    cout<<'0';
    else
    {
        ll re=0,rw=0;
        for(i=start;i<=end;i++)
        {
            if(s[i]=='W')
            ++re;
            else
            ++rw;
        }
        ll cnt=0;
        
        for(i=0;i<n;i++)
        {
            if(s[i]=='R')
            ++cnt;
        }
        ll r2=0;
        
        for(i=0;i<cnt;i++)
        {
            if(s[i]=='W')
            ++r2;
        }
        
        cout<<min(r2,min(re,rw));
    }
}


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

const int N = 200000;
const ll INF = 1e18;

int n, a[N], f[N];
ll k;
P af[N];

bool isOK(ll key) {
  ll tr = 0;
  rep(i, n) {
    if (af[i].first <= key) continue;
    tr += (af[i].first - key + af[i].second - 1) / af[i].second;
  }
  return tr <= k;
}

ll binary_search(ll ok, ll ng) {
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (isOK(mid)) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> f[i];
  sort(a, a + n);
  sort(f, f + n, greater<int>());
  rep(i, n) af[i] = make_pair((ll)a[i] * f[i], f[i]);
  ll ans = binary_search(INF, -1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8292
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n-1);
	for (int i = 0; i < n-1; i++){
		cin >> b[i]; 
	}
	a[0] = b[0];
	a[n-1] = b[n-2];
	for (int i = 1; i < n-1; i++){
		a[i] = min(b[i-1], b[i]);
	}

	for (int i = 0; i < n; i++){
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//chiragjn
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define gibe_de_fast_io_b0ss ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 0x7FFFFFFFFFFFFFFF/2;
int main(){
    gibe_de_fast_io_b0ss;
    int n, k;
    cin>>n>>k;
    vector<int> arr(n);
    vector<bool> cache(k + 1, false);
    for(int i = 0; i < n; i++) {
    	cin>>arr[i];
    }
    sort(arr.begin(), arr.end());
    for(int i = arr[0]; i <= k; i++) {
    	bool all_wins = true;
    	for(int j = 0; j < arr.size() && arr[j] <= i; j++) {
    		all_wins &= cache[i - arr[j]];
    	}
    	cache[i] = !all_wins;
    }
    cout<<((cache[k]) ? "First" : "Second"); 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

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

	if (A > 8 || B > 8) cout << ":(" << endl;
	else cout << "Yay!" << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

const int maxT = 17*50;
// dp[i][a][b] = テ・ツ青暗ィツィツ暗ヲツ卍づゥツ鳴禿」ツ?古」ツ?敕」ツつ古」ツ?榲」ツつ径, b, sum(hoge)-a-bテ」ツ?ァテ」ツつケテ」ツつュテ」ツδ」テ」ツδウテ」ツ?ァテ」ツ?催」ツつ?
bool dp[51][maxT+1][maxT+1];
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int N; cin >> N;
    vector<int> T(N); cin >> T;
    fill(dp[0][0], dp[0][maxT+1], false);
    dp[0][0][0] = true;
    REP(i, N) REP(a, maxT+1) REP(b, maxT+1) {
        if (!dp[i][a][b]) continue;
        if (a+T[i] <= maxT) {
            dp[i+1][a+T[i]][b] = true;
        }
        if (b+T[i] <= maxT) {
            dp[i+1][a][b+T[i]] = true;
        }
        dp[i+1][a][b] = true;
    }
    int st = 0;
    REP(i, N) st += T[i];
    ll ans = inf;
    REP(a, maxT+1) REP(b, maxT+1) {
        if (dp[N][a][b]) {
            ll c = st - a - b;
            ans = min(ans, max(max(a, b), c));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 28900
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

#define ALL(a) (a).begin(), (a).end()

using ll = long long;
map<int, vector<int>> recorder;

int h, w, n;

bool inside(int row, int col) {
    return 0 <= row && row < h && 0 <= col && col < w;
}

ll ans[10];

bool find_black(int row, int col) {
    auto& vec = recorder[row];
    auto it = lower_bound(vec.begin(), vec.end(), col);
    return it != vec.end() && *it == col;
}

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

    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        recorder[a - 1].push_back(b - 1);
    }

    for (auto it = recorder.begin(); it != recorder.end(); it++) {
        auto& cols = it->second;
        sort(cols.begin(), cols.end());
    }

    for (auto row_it = recorder.begin(); row_it != recorder.end(); row_it++) {
        int row = row_it->first, col;
        for (auto& elt : row_it->second) {
            col = elt;

            for (int dtop = -2; dtop <= 0; dtop++) {
                for (int dleft = -2; dleft <= 0; dleft++) {
                    int ntop = row + dtop,
                        nbottom = row + dtop + 2,
                        nleft = col + dleft,
                        nright = col + dleft + 2;
                    if (!inside(ntop, nleft) || !inside(nbottom, nright)) continue;

                    // 今見ている領域内で辞書順で自分より小さいものが存在したらそこに任せる
                    int num = 0;
                    bool exists = false;
                    for (int r = ntop; r <= nbottom; r++) {
                        for (int c = nleft; c <= nright; c++) {
                            if (find_black(r, c)) {
                                // 辞書順で小さいのなら
                                if (make_pair(r, c) < make_pair(row, col)) {
                                    exists = true;
                                }
                                num++;
                            }
                        }
                    }
                    if (exists) continue;
                    ans[num]++;
                }
            }
        }
    }

    ans[0] = (ll)(h - 2) * (ll)(w - 2);
    for (int i = 1; i < 10; i++) ans[0] -= ans[i];

    for (int i = 0; i < 10; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 42368
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI x(N), y(N), h(N);
	bool P = true;

	REP(i, N) {
		cin >> x[i] >> y[i] >> h[i];
		//if (h[i])P = false;
	}
	

	eFOR(i,0, 100) {
		eFOR(j,0, 100) {
			bool F = true;
			int tmp = INF;

			REP(k, N) {				
				
				if (h[k]>0 && tmp==INF){

					tmp = abs(x[k] - i) + abs(y[k] - j);
					tmp += h[k];

				}
				else if (h[k] > 0) {
					if (tmp - abs(x[k] - i) - abs(y[k] - j)!=h[k]) {
						F = false;
						break;
					}
				}
				else if (tmp == INF)continue;
				else {
					if (tmp - abs(x[k] - i) - abs(y[k] - j)>0) {
						F = false;
						break;
					}
				}
			}
			REP(k, N) {

				if (h[k] > 0) {
					if (tmp - abs(x[k] - i) - abs(y[k] - j) != h[k]) {
						F = false;
						break;
					}
				}
				else {
					if (tmp - abs(x[k] - i) - abs(y[k] - j) > 0) {
						F = false;
						break;
					}
				}
			}
			if (F) {
				cout << i << " " << j << " " << tmp << endl;
				return 0;
			}
		}
	}

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL INF=1e18;

int main(){
    LL N,A,B;
    cin >> N >> A >> B;
    N-=2;
    LL t=0;
    cout << max((B-A)*N+1,t) << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 10000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
const int INF=1e9;
bool com(P l,P r){
      if(l.first!=r.first)return l.first>r.first;
      return l.second<r.second;
}
int main(){
      int n,m,cnt[100];
      while(cin>>n>>m&&n&&m){
            memset(cnt,0,sizeof(cnt));
            REP(i,n)REP(j,m){
                  int a;
                  cin>>a;
                  cnt[j]+=a;
            }
            vector<P>V;
            REP(i,m)V.PB(P(cnt[i],i+1));
            sort(V.begin(),V.end(),com);
            REP(i,V.size()){
                  cout<<V[i].second;
                  if(i==m-1)cout<<endl;
                  else cout<<" ";
            }
      }
}

Measured memory_bytes: 1200
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Array;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		long count = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				int ok = j;
				int ng = n;
				while (ng - ok > 1) {
					int mid = (ok + ng) / 2;
					if (l[mid] < l[i] + l[j]) {
						ok = mid;
					} else {
						ng = mid;
					}
				}
				count += ok - j;
			}
		}
		System.out.println(count);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22228
import math 

def gcd(x,y,z):
  return math.gcd(x, math.gcd(y,z))

k = int(input())
ans = 0
for x in range(1,k + 1):
  for y in range(1, k + 1):
    for z in range(1, k + 1):
    	ans += gcd(x,y,z)
print(ans)

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

int main(){

  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
  
    cout << "vowel" << endl;
  
  }else{
  
    cout << "consonant" << endl;
  
  }

  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=1010;
const int inf=2147483647;
const int mod=1000000007;
int read()
{
	int 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<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int n,m,a[Maxn],b[Maxn],cx[Maxn*Maxn],cy[Maxn*Maxn],px[Maxn*Maxn],py[Maxn*Maxn];
int main()
{
//	freopen("1.txt","r",stdin);
	memset(px,-1,sizeof(px));
	memset(py,-1,sizeof(py));
	n=read(),m=read();
	for(int i=1;i<=n;i++)cx[a[i]=read()]++,px[a[i]]=i;
	for(int i=1;i<=m;i++)cy[b[i]=read()]++,py[b[i]]=i;
	for(int i=1;i<=n*m;i++)if(cx[i]>2||cy[i]>2)return puts("0"),0;
	int N=0,M=0,ans=1,cnt=0;
	for(int i=n;i;i--)
	for(int j=m;j;j--)
	{
		int x=(i-1)*m+j;
		if(px[x]!=-1&&py[x]!=-1)N++,M++,cnt++;
		else if(px[x]!=-1)
		{
			if(!M)return puts("0"),0;
			N++,cnt++;
			ans=(LL)ans*M%mod;
		}
		else if(py[x]!=-1)
		{
			if(!N)return puts("0"),0;
			M++,cnt++;
			ans=(LL)ans*N%mod;
		}
		else
		{
			if(N*M-cnt==0)return puts("0"),0;
			ans=(LL)ans*(N*M-cnt)%mod;cnt++;
		}
		if(N>n||M>m)return puts("0"),0;
//		printf("%d %d %d %d\n",x,N,M,cnt);
	}
	printf("%d",ans);
}

Measured memory_bytes: 10624
from collections import defaultdict
n=int(input())
sosu_list=[2]
for i in range(3, 101, 2):
    flag=0
    for j in range(2, int(i**0.5)+2):
        if i%j==0:
            flag=1
    if flag==0:
        sosu_list.append(i)
soinsu=defaultdict(int)
for i in sosu_list:
    temp=n
    while temp>=i:
        temp//=i
        soinsu[i]+=temp
kouho=soinsu.values()
cnt3=0
cnt5=0
cnt15=0
cnt25=0
cnt75=0
for a in kouho:
    if a>=2:
        cnt3+=1
    if a>=4:
        cnt5+=1
    if a>=14:
        cnt15+=1
    if a>=24:
        cnt25+=1
    if a>=74:
        cnt75+=1
ans=0
ans+=cnt75
ans+=cnt15*(cnt5-1)
ans+=cnt25*(cnt3-1)
if cnt3>=2:
    ans+=cnt5*(cnt5-1)*(cnt3-2)//2
        
print(ans)

Measured memory_bytes: 3444