akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int parent(int);
int left(int);
int right(int);

int main()
{
  int n,i;
  int A[250];

  scanf("%d",&n);
  for(i = 1;i <= n;i++){
    scanf("%d",&A[i]);
  }

  for(i = 1;i <= n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) > 0) printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= n) printf("left key = %d, ",A[left(i)]);
    if(right(i) <= n) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;
}

int parent(int i)
{
  return i/2;
}

int left(int i)
{
  return 2*i;
}

int right(int i)
{
  return 2*i+1;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	int p[100000]={};
	rep(i,0,n){
		cin >> p[i];
		p[i]--;
	}

	int cnt=0;
	
	if(p[0] == 0 ){
		swap(p[0],p[1]);
		cnt++;
	}

	rep(i,0,n-1){
		if(	p[i+1] == i+1 ){
			swap(p[i] , p[i+1] );
			cnt++;
			i++;
		}
	}
	
	cout << cnt << endl;

	ret 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#define M 100
#define W 0
#define G 1
#define B 2

int n,A[M][M];
int clr[M],k[M],t[M],s;

void dfs(int u){
    int x;
    clr[u]=G;
    k[u]=++s;
    for(x=0;x<n;x++){
        if(A[u][x] == 0)continue;
        if(clr[x] == W){
            dfs(x);
        }
    }
    clr[u]==B;
    t[u]=++s;
}

void dfs2(){
    int y;

    for(y=0;y<n;y++){
        clr[y]=W;
        s=0;
    }
    for(y=0;y<n;y++){
        if(clr[y] == W)dfs(y);
    }

    for(y=0;y<n;y++){
        printf("%d %d %d\n",y+1,k[y],t[y]);
    }
}

int main(){
    int i,j,x,y,z;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            A[i][j]=0;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        x--;
        for(j=0;j<y;j++){
            scanf("%d",&z);
            z--;
            A[x][z]=1;
        }
    }
    dfs2();

    return 0;
}



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

int main() {
    int N, K, sum;
    cin >> N >> K;

    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;

        sum += min(x, K - x);
    }
    
    cout << sum * 2 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(input.readLine());
        int m = 1000000007;
        long sum = 1;

        for (int i = 1; i <= n; i++) {
            sum *= i;
            sum %= m;
        }

        out.write(String.valueOf(sum));
        out.write("\n");
        out.close();
        

    }
}


Measured memory_bytes: 20692
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    int n;
    cin >> n;
    unordered_map<int, int> m;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        m[x]++;
    } 
    int ans = 0;
    for (auto p : m) if (p.se & 1) ans++;
    cout << ans;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 4388
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

const int mod = 1e9 + 7;

vector<long long> powers2(64,0);

void init() {
	powers2[0] = 1;
	for (int i = 1; i < 62; ++i) {
		powers2[i] = (powers2[i - 1] * 2LL) % mod;
	}
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	init();
	int n; cin >> n;

	vector<long long> arr(n);
	for (int i = 0; i < n; ++i) cin >> arr[i];

	vector<vector<long long> > ones(n, vector<long long>(62, 0));
	vector<vector<long long> > zeros(n, vector<long long>(62, 0));

	int max_bit_set = 0;
	for (int i = n-1; i >= 0; --i) {
		for (int j = 0; j < 62; ++j) {
			long long tmp = arr[i];
			tmp = tmp >> j;
			if (i < n - 1) {
				ones[i][j] = ones[i + 1][j];
				zeros[i][j] = zeros[i + 1][j];
			}

			if ((tmp % 2)==1) {
				++ones[i][j];
				max_bit_set = max(max_bit_set,j);
			}
			else {
				++zeros[i][j];
			}
		}
	}

	long long ans = 0;
	for (int i = 0; i < n - 1; ++i) {
		for (int j = 0; j <= max_bit_set; ++j) {
			long long tmp = arr[i];
			tmp = tmp >> j;
			if ((tmp % 2) == 1 ) {
				ans = (ans + (zeros[i + 1][j] * powers2[j]) % mod ) % mod;
			}
			else {
				ans = (ans + ( ones[i + 1][j] * powers2[j]) % mod ) % mod;
			}
		}
	}

	cout << ans << "\n";
	
	return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  string s;
  cin >> s;
  if(s.size()!=(n+m+1)){cout << "No" << endl;return 0;}
  for(int i=0; i<n; i++){
    if(48>s.at(i)||s.at(i)>57){cout << "No" << endl;return 0;}
  }
  if(s.at(n)!='-'){cout << "No" << endl;return 0;}
  for(int i=n+1;i<n+m;i++){
    if(48>s.at(i)||s.at(i)>57){cout << "No" << endl;return 0;}
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

// #define DEBUG 100

using namespace std;
using ll = unsigned long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7,maxn = 100010;
const double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0); 
    int n, m, ans = 0;
    cin >> n >> m;

    ans += ((n)*(n-1))/2;
    ans += (m*(m-1))/2;

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

Measured memory_bytes: 3608
def main():
    import collections
    import sys
    sys.setrecursionlimit(5000000)
    input = sys.stdin.readline
    N=int(input())
    S=input()
    if N<=3:
        print(0)
    else:
        str_list=list(S[:N])
        result=0
        c=collections.Counter(str_list)
        RGB_list=c.most_common()

        if len(c)<3:
            print(0)

        else:

            list1=[i for i, x in enumerate(str_list) if x == RGB_list[0][0]]
            list2=[i for i, x in enumerate(str_list) if x == RGB_list[1][0]]
            list3=[i for i, x in enumerate(str_list) if x == RGB_list[2][0]]
            list23=[]

        
            for i in list3:
                for j in list2:
                    list23+=[2*i-j,2*j-i,(i+j)/2]
            c1=collections.Counter(list23)
            for k in list1:
                for l in c1.keys():
                    if k==l:
                        result+=c1[l]
            print(int(RGB_list[0][1]*RGB_list[1][1]*RGB_list[2][1]-result))

if __name__ == '__main__':
    main()


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

int main(){
  ll n, k;
  cin >> n >> k;
  ll sum = 0;
  ll tmp;
  vector<ll> hs(n);
  for(ll i=0; i<n; i++){
  	cin >> hs[i];
  }
  sort(hs.begin(), hs.end());
  for(ll i=0; i<n-k; i++){
  	sum += hs[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int n, x, a[100];
    cin >> n >> x;
    for (int i = 0; i < n; i++)cin >> a[i];
    sort(a, a+n);
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        if (i == n) {
            if (x > 0)ans--;
            break;
        }
        if (a[i] <= x) {
            ans++;
            x -= a[i];
        }
        else break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func diviedbyTwo(a int) int {
	// return 0 when % 2 == 1
	if a%2 == 0 {
		return a / 2
	} else {
		return 0
	}
}

func main() {
	var (
		n int
		counter = 0
	)
	fmt.Scan(&n)
	blackboard := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&blackboard[i])
	}
	condition := true
	for condition {
		for i := 0; i < n; i++ {
			returnN := diviedbyTwo(blackboard[i])
			blackboard[i] = returnN
			if returnN == 0 {
				condition = false
			}
		}
		//fmt.Println(blackboard)
		counter++
	}
	fmt.Println(counter-1)
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100;
int a[MAXN + 5];
int main() {
	int N, x;
	scanf("%d%d", &N, &x);
	for(int i=1;i<=N;i++)
		scanf("%d", &a[i]);
	sort(a+1, a+N+1);
	for(int i=1;i<=N;i++) {
		if( x < a[i] ) {
			printf("%d\n", i-1);
			return 0;
		}
		x -= a[i];
	}
	if( x == 0 ) printf("%d\n", N);
	else printf("%d\n", N-1);
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef pair<ll, ll> pint;


#define rep(i,n) for(ll i=0;i<n;i++)

class Dice
{
public:
  vint pos;


  Dice();
  void roll(char d);
  ll face();
  ll right(ll top, ll front);

private:
  map<pint, ll> m;



};

Dice::Dice(){
  pos.resize(6);
  rep(i,6) pos[i] = i;

  // vint v = vint({1, 2, 4, 3});
  ll v[] = {1, 2, 4, 3};

  ll top = 0;
  rep(i, 4){
    // vint u = vint({top, v[i%4], v[(i+1)%4]});
    ll u[] = {top, v[i%4], v[(i+1)%4]};
    rep(j, 3){
      m[make_pair(u[j%3], u[(j+1)%3])] = u[(j+2)%3];
    }
  }

  reverse(v , v + 4);
  top = 5;
  rep(i, 4){
    ll u[] = {top, v[i%4], v[(i+1)%4]};
    rep(j, 3){
      m[make_pair(u[j%3], u[(j+1)%3])] = u[(j+2)%3];
    }
  }

  // m[make_pair(0, 1)] = 3;
  // m[make_pair(0, 2)] = 4;
  // m[make_pair(0, 4)] = 3;
  // m[make_pair(0, 3)] = 4;
  // m[make_pair(1, 5)] = 2;
  // m[make_pair(1, 2)] = 0;
  // m[make_pair(1, 3)] = 5;
  // m[make_pair(2, 5)] = 4;
  // m[make_pair(2, 4)] = 0;
  // m[make_pair(3, 5)] = 2;
  // m[make_pair(3, 4)] = 5;
  // m[make_pair(4, 5)] = 3;
}

void Dice::roll(char d){
  vint tmp_pos = pos;

  if(d == 'E'){
    pos[2] = tmp_pos[0];
    pos[0] = tmp_pos[3];
    pos[3] = tmp_pos[5];
    pos[5] = tmp_pos[2];
  }else if(d == 'N'){
    pos[0] = tmp_pos[1];
    pos[1] = tmp_pos[5];
    pos[5] = tmp_pos[4];
    pos[4] = tmp_pos[0];
  }else if(d == 'S'){
    pos[0] = tmp_pos[4];
    pos[4] = tmp_pos[5];
    pos[5] = tmp_pos[1];
    pos[1] = tmp_pos[0];
  }else if(d == 'W'){
    pos[0] = tmp_pos[2];
    pos[2] = tmp_pos[5];
    pos[5] = tmp_pos[3];
    pos[3] = tmp_pos[0];
  }else{
    assert(false);
  }
  // rep(i,6) cout<<pos[i]<<" ";
  // cout<<endl;

}

ll Dice::face(){
  return pos[0];
}

ll Dice::right(ll top, ll front){
  ll rtn;

  rtn = m[make_pair(top, front)];
  return rtn;

}


int main() {


  cout<<fixed<<setprecision(10);

  vint v(6);
  rep(i,6)cin>>v[i];

  map<ll,ll> m;
  rep(i,6){
    m[v[i]] = i;
  }

  Dice d = Dice();

  ll n; cin>>n;
  rep(i,n){
    ll f,t; cin>>f>>t;
    cout<<v[d.right(m[f], m[t])]<<endl;
  }
}





//



Measured memory_bytes: 3096
while True:
    (H, W) = tuple([int(i) for i in input().split(' ')])
    if (H == W == 0):
        break
    for i in range(H):
        if (i == 0):
            # first element
            print('#' * W)
        elif (i == (H - 1)):
            # last element
            print('#' * W)
        else:
            # middle element
            print('#', end='')
            print('.' * (W - 2), end='')
            print('#')
    print()

Measured memory_bytes: 7692
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll n;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  for(auto&& e: b) 
  {
    cin>>e;
  }
  for(auto&& e: c) 
  {
    cin>>e;
  }
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  ll ans=0;
  for (int i = 0; i < n; ++i)
  {
    ans+=(lower_bound(a.begin(), a.end(),b[i])
      - a.begin()) *
    (c.end() - upper_bound(c.begin(),
      c.end(),b[i]));
  }
  cout<<ans<<endl;
}

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

int main()
{
  int n;
  cin>>n;
  vector<int> p(n),q(n),t;
  for(int &i:p) cin>>i;
  for(int &i:q) cin>>i;
  for(int i=0;i<n;i++)
  {if(q[i]<p[i])
    {t=p;p=q;q=t;break;}
  	else
  	  break;
  }
  int c=0;
  do{
    if(p==q)
      break;
    c++;
  }while(next_permutation(p.begin(),p.end()));
  cout<<c<<"\n"; 
  
  
  return 0;
}

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


int main() {
	
	int N, T;
	cin >> N >> T;
	vector<int> c(N,10000);
	for(int i=0; i<N; i++){
		int a, t;
		cin >> a >> t;
		if(t<=T) c.at(i) = a;
	}
	sort(c.begin(), c.end());
	if(c.front() != 10000) cout << c.front() << endl;
	else cout << "TLE" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main (void){

	char str[1024] = "";
	int length = 0;

	int i=0;
	while(true){
		scanf("%c",str+i);
		//printf("%c",*(str+i));
		if(str[i] == '\n'){
			length = i;
			break;
		}
		if(str[i] != ' ')i++;
	}
	//printf("###dbg :%d\n",length);
	for(int i=0;i<length;i++){
		str[i] = (((str[i] - 0x41) + 23) % 26) + 0x41;
	}
	printf("%s",str);
	/*for(int i=0;i<length;i++){
		printf("%c%c",str[i],(i==length-1?'\n':' '));
	}*/

	return 0;
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "Yes";
const string NO  = "No";

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

    int n, m;

    cin >> n >> m;

    cout << (n == m ? YES : NO) << endl;

    return 0;
}



Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    for (ss <- io.Source.stdin.getLines()) { rec(ss) }
  }

  def rec(s: String): Unit = {
    if (check(s)) {
      println(s)
      return
    }

    rec(next(s))

    def check(s: String): Boolean = {
      val list = List("the", "this", "that")
      list.foreach { ss =>
        if (s.contains(ss)) {
          return true
        }
      }
      return false
    }

    def next(s: String): String = {
      val sss = s.map({
        case cc if 'a' to 'z' contains cc => (((cc - 'a' + 1) % 26) + 'a').toChar
        case ch => ch
      })
      sss.toString
    }
  }
}

Measured memory_bytes: 46100
#094c
import copy
N = int(input()) #N<200000=2 * 10**5
X_list = [int(e) for e in input().split()]

sort_X_list = copy.copy(X_list)
sort_X_list.sort(reverse=False)
Bi_smaller = sort_X_list[int(len(X_list)/2-1)]
Bi_bigger = sort_X_list[int(len(X_list)/2)]

for i in range(N):
    if X_list[i]>=Bi_bigger:
        print(Bi_smaller)
    else:
        print(Bi_bigger)

Measured memory_bytes: 25732
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll GCD(ll A, ll B){
  if (A < B) swap(A, B);
  while (A % B != 0){
    A = A % B;
    swap(A, B);
  }
  return B;
}

int main(){
  ll A, B; cin >> A >> B;
  ll G = GCD(A, B);
  cout << A / G * B << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> l(n); rep (i, n) cin >> l[i];
    sort(all(l));
    ll ans = 0;
    rep (i, n) {
        rep (j, i + 1, n) {
            auto it = lower_bound(l.begin() + j + 1, l.end(), l[i] + l[j]);
            int pos = (int)distance(l.begin(), it);
            eprintf("%d %d: %d\n", i, j, pos);
            ans += pos - (j + 1);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll N;
    ll A;
    ll count=1;
    cin>>N;
    bool ok=true;
    rep(i, N){
        cin>>A;
        
        //cout<<A<<sp;
        if(A==0){cout<<0<<endl; return 0;}
        if(A>1000000000000000000/count){ok=false; count=1;}
        count*=A;
    }
    if(ok) cout<<count<<endl;
    else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;


int main()
{
	int N, A;
	cin >> N >> A;
	int tmp = N % 500;
	if (tmp <= A)
		puts("Yes");
	else
		puts("No");
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll arr[100] ;

int main()
{
    ll n, total = 1000, piece = 0, val ;
    cin >> n ;
    for (int i = 0; i < n; i++) {
        cin >> arr[i] ;
    }
    for (int i = 1; i < n; i++) {
        if (arr[i] > arr[i - 1]) {
            piece = (total / arr[i - 1]) ;
            total -= (piece * arr[i - 1]) ;

            total += (piece * arr[i]) ;
            piece = 0 ;
        }
    }
    cout << total ;

    return 0 ;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int n, a, x, y, z;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 4 == 0) x++;
        else if (a % 2 == 0) y++;
        else z++;
    }
    if (x + 1 == z && y == 0) cout << "Yes" << endl; 
    else if (x + 1 > z) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;

class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int[] num = new int[5];
		
		for(int i = 0; i < 5; i++)
		{
			num[i] = sc.nextInt();
		}
		
		for(int i = 0; i < 5; i++)
		{
			if(num[i] == 0)
			{
				System.out.println(i + 1);
				break;
			}
		}
	}
}


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

using namespace std;

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

  int n, a;
  cin >> n;
  map<int, int> hash;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    a = min(a/400, 8);
    hash[a]++;
  }
  bool eight = (hash.find(8) != hash.end());
  int normal = hash.size()-eight;
  if (normal == 0) {
    cout << 1 << " " << hash[8] << endl;
  } else {
    cout << normal << " " << normal + (eight > 0 ? hash[8] : 0) << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int f(int n) {
  int ret = 0;
  while (n >= 1) {
    ret += n % 10;
    n /= 10;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  if (n % f(n) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int R,C,x,y,MAX=0;cin>>R>>C;
  int N[R][C];char M[R][C];
  queue<pair<int,int>>X;
  for(int i=0;i<R;i++)for(int j=0;j<C;j++){
    N[i][j]=R*C;cin>>M[i][j];
    if(M[i][j]=='#'){
      X.push(make_pair(i,j));
      N[i][j]=0;
    }
  }
  while(X.size()){
    x=X.front().first;y=X.front().second;
    if(x<R-1&&M[x+1][y]=='.'&&N[x+1][y]==R*C){X.push(make_pair(x+1,y));N[x+1][y]=N[x][y]+1;}
    if(x>0&&M[x-1][y]=='.'&&N[x-1][y]==R*C){X.push(make_pair(x-1,y));N[x-1][y]=N[x][y]+1;}
    if(y<C-1&&M[x][y+1]=='.'&&N[x][y+1]==R*C){X.push(make_pair(x,y+1));N[x][y+1]=N[x][y]+1;}
    if(y>0&&M[x][y-1]=='.'&&N[x][y-1]==R*C){X.push(make_pair(x,y-1));N[x][y-1]=N[x][y]+1;}
    X.pop();
  }
  for(int i=0;i<R;i++)for(int j=0;j<C;j++)
    MAX=max(MAX,N[i][j]);
  cout<<MAX<<endl;
}

Measured memory_bytes: 13328
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    string s;
    cin >> s;
    string tmp = "";
    string prv = "";
    int res = 0;
    int p = 0;
    while (p < s.size()) {
        tmp += s[p];
        p++;
        if (tmp != prv) {
            prv = tmp;
            tmp = "";
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

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

    ll a = A * B;
    ll b = C * D;

    if(a > b) {
        cout << a << endl;
    } else if(a < b) {
        cout << b << endl;
    } else {
        cout << a << endl;
    }
}

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

inline 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*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge
{
	int v,next;
}vs[2010];
int st[2010],ee,n,val[2010],Fs[2010];
int wss[2010][6010],tmp[6010],fg;
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}
inline void dfs(int rt)
{
	memset(wss[rt],-1,sizeof wss[rt]);
	wss[rt][0]=0;
	for(int i=st[rt];i;i=vs[i].next)
	{
		dfs(vs[i].v); 
		if(fg==1) return ;
		int v=vs[i].v;
		memset(tmp,-1,sizeof tmp);
		for(int i=5000;i>=val[v];i--) if(wss[rt][i-val[v]]!=-1)
		{
			if(tmp[i]==-1) tmp[i]=wss[rt][i-val[v]]+Fs[v];
			else tmp[i]=min(tmp[i],wss[rt][i-val[v]]+Fs[v]);
		}
		for(int i=5000;i>=Fs[v];i--) if(wss[rt][i-Fs[v]]!=-1)
		{
			if(tmp[i]==-1) tmp[i]=wss[rt][i-Fs[v]]+val[v];
			else tmp[i]=min(tmp[i],wss[rt][i-Fs[v]]+val[v]);
		}
		for(int i=0;i<=5000;i++) wss[rt][i]=tmp[i];
	}
	//for(int i=0;i<=10;i++) printf("%d ",wss[rt][i]); printf("\n");
	Fs[rt]=0x3fffffff;
	for(int i=0;i<=min(val[rt],1ll*5000);i++) if(wss[rt][i]!=-1)
		Fs[rt]=min(Fs[rt],wss[rt][i]);
	if(Fs[rt]==0x3fffffff) fg=1;
}
signed main()
{
	n=read(); for(int i=2;i<=n;i++)
	{
		int k=read(); addedge(k,i);
	}
	for(int i=1;i<=n;i++) val[i]=read();
	dfs(1);
	if(fg) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 47360
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int n,a;
    cin>>n>>a;
    cout<<n*n-a<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

int main(){
    int N; cin>>N;
    ll x[N],y[N];
    REP(i,N){
        cin >> x[i] >> y[i];
    }
    int same = 0;
    map<pll, int> mp;
    REP(i,N){
        for(int j=i+1;j<N;++j){
            pll temp = MP(x[i]-x[j],y[i]-y[j]);
            pll semp = MP(x[j]-x[i],y[j]-y[i]);
            chmax(same,++mp[temp]);
            chmax(same,++mp[semp]);
        }
    }
    cout << N - same << "\n";
}

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

#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vll vector<ll>
#define vvll vector<vll>
template<typename T, typename U> 
static inline void amin(T &x, U y){
    if(x>y)
        x = y;
}
template<typename T, typename U> 
static inline void amax(T &x, U y){
    if(x<y)
        x = y;
}
#define rep(i,n) for(int i = 0; i < n; ++i)
#define irep(i,k,n) for(int i = k; i <= n; ++i)
#define irepr(i,k,n) for(int i = k; i >= n; --i)

const ll mod = 1e9+7;
const int N = 1e5+5;

vi tree[N];
int a, t, dist;
vi depth1(N, 0);
vi depth2(N, 0);
void dfs1(int u, int par){
    depth1[u] = 1 + depth1[par];
    for(auto ch : tree[u]){
        if(ch != par){
            dfs1(ch, u);
        }
    }
}
void dfs2(int u, int par){
    depth2[u] = 1 + depth2[par];
    for(auto ch : tree[u]){
        if(ch != par){
            dfs2(ch, u);
        }
    }
}
int main(){
    depth1[0] = depth2[0] = -1;
    int n;
    cin>> n>> t>> a;
    int u, v;
    rep(i, n-1){
        cin>> u>> v;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    dfs1(a, 0);
    dfs2(t, 0);
    int ans = 0;
    irep(i, 1, n){
        if(depth1[i] > depth2[i]){
            amax(ans, depth1[i]-1);
        }
    }
    cout << ans << "\n";
    return 0;
}

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

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

    int ans = 0;
    rep(i, n) {
        int h;
        cin >> h;
        if (h >= k) ans++;
    }

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


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

int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin>>s;
  int ans=0,k=0;
  for(int i=0; i<s.size(); i++){
    if(s[i]=='R'){
        if(i-1>=0&&s[i-1]=='S'){ans=max(ans,k); k=1;}
        else{k++;}
    }
  }
  cout<<max(ans,k);

  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, k, i, j;
	ll ans = 0, buf, a = 0, x;
	cin >> num >> k;
	vector<pair<int, int>> d(num);
	vector<int> s(num + 1, 0);
	for (i = 0; i < num; i++)
		cin >> d[i].second >> d[i].first;
	sort(d.begin(), d.end(), greater<pair<int, int>>());
	for (i = 0; i < k; i++) {
		ans += d[i].first;
		if (s[d[i].second] == 0)
			a++;
		s[d[i].second]++;
	}
	buf = ans;
	ans += a * a;
	for (i = k, j = k - 1 ; i < num; i++) {
		if (s[d[i].second] == 0) {
			for (; j >= 0; j--) {
				if (s[d[j].second] > 1)
					break;
			}
			if (j < 0)
				break;
			buf += d[i].first - d[j].first;
			a++;
			ans = max(ans, buf + a * a);
			s[d[i].second]++;
			s[d[j].second]--;
			j--;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int min = Integer.MAX_VALUE;

		int count = 0;

		for (int i = 0; i < n; i++) {
			int p = sc.nextInt();
			if (p < min) {
				min = p;
				count++;
			}
		}

		print(count);
		sc.close();
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


Measured memory_bytes: 63044
#include<stdio.h>
#include<time.h>
#include<string.h>
int main(void) {
	time_t tim1,tim2;
	struct tm d;
	double diff;
	int year1, year2, month1, month2, day1, day2;
	while (1) {
		scanf("%d %d %d %d %d %d",&year1,&month1,&day1,&year2,&month2,&day2);
		if (month1 == -1 || year1 == -1 || day1 == -1 ||month2 == -1 || year2 == -1 || day2 == -1) break;
		memset(&d,0,sizeof(d));
		d.tm_year = year1 - 1900;
		d.tm_mon = month1 - 1;
		d.tm_mday = day1;
		tim1 = mktime(&d);
		d.tm_year = year2 - 1900;
		d.tm_mon = month2 - 1;
		d.tm_mday = day2;
		tim2 = mktime(&d);

		diff = difftime(tim2, tim1);

		printf("%d\n",(int)(diff/60/60/24+0.5));
	}
	return 0;
}

Measured memory_bytes: 660
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

vector<int> make(const string& str){
	int n=str.size();
	vector<int> ret(n+1);
	ret[0]=-1;
	int j=-1;
	for(int i=0;i<n;i++){
		while(j>=0 && str[i]!=str[j]){
			j=ret[j];
		}
		ret[i+1]=++j;
	}
	return ret;
}

vector<int> kmp(const string& str,const string& word){
	vector<int> table=make(word),ret;
	int m=0,i=0,n=str.size();
	while(m+i<n){
		if(word[i]==str[m+i]){
			if(++i==(int)(word.size())){
				ret.push_back(m);
				m=m+i-table[i];
				i=table[i];
			}
		}else{
			m=m+i-table[i];
			if(i>0)i=table[i];
		}
	}
	return ret;
}

struct graph_scc{
	int V;
	static const int MAX=2000005;
	vector<int> G[MAX];
	vector<int> rG[MAX];
	vector<int> ci[MAX];
	vector<int> vs;
	bool used[MAX];
	int cmp[MAX];
	void init(int n){
		V=n;
		for(int i=0;i<V;i++){
			G[i].clear();
			rG[i].clear();
		}
		vs.clear();
		memset(cmp,0,sizeof(cmp));
	}
	void add_edge(int from,int to){
		G[from].push_back(to);
		rG[to].push_back(from);
	}

	void dfs(int v){
		used[v]=true;
		for(int i=0;i<G[v].size();i++){
			if(!used[G[v][i]])dfs(G[v][i]);
		}
		vs.push_back(v);
	}
	void rdfs(int v,int k){
		used[v]=true;
		cmp[v]=k;
		ci[cmp[v]].push_back(v);
		for(int i=0;i<rG[v].size();i++){
			if(!used[rG[v][i]])rdfs(rG[v][i],k);
		}
	}

	int scc(int n){
		V=n;
		memset(used,0,sizeof(used));
		vs.clear();
		for(int v=0;v<V;v++){
			if(!used[v])dfs(v);
		}
		memset(used,0,sizeof(used));
		int k=0;
		for(int i=vs.size()-1;i>=0;i--){
			if(!used[vs[i]]){
				rdfs(vs[i],k++);
			}
		}
		return k;
	}
};

string s,t;
graph_scc sc;
int maxi[1500005];

int main(void){
	cin >> s;
	cin >> t;
	string ns="";
	while(ns.size()<(int)t.size()+s.size()){
		ns+=s;
	}
	vector<int> edges=kmp(ns,t);

	for(int i=0;i<edges.size();i++){
		if(edges[i]>=s.size())continue;
		//printf("%d\n",edges[i]);
		sc.add_edge(edges[i],(edges[i]+t.size())%s.size());
	}
	int sz=sc.scc(s.size());
	int ans=0;
	for(int i=0;i<s.size();i++){
		//printf("%d %d\n",i,sc.cmp[i]);
	}
	for(int i=sz-1;i>=0;i--){
		if(sc.ci[i].size()>=2){
			printf("%d\n",-1);
			return 0;
		}
		for(int j=0;j<sc.ci[i].size();j++){
			int v=sc.ci[i][j];
			//printf("%d\n",v);
			for(int k=0;k<sc.G[v].size();k++){
				int nv=sc.G[v][k];
				if(v==nv){
					printf("-1\n");
					return 0;
				}
				if(sc.cmp[v]<sc.cmp[nv]){
					maxi[v]=max(maxi[v],maxi[nv]+1);
					ans=max(maxi[v],ans);
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 211596
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef pair<string, int> P;

void solve()
{
	int n, m;
	while(cin >> n >> m, n || m)
	{
		vector<P> lottery(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> lottery[i].first >> lottery[i].second;
		}
		int sum = 0;
		for(int i = 0; i < m; ++i)
		{
			string ticket;
			cin >> ticket;
			for(int j = 0; j < n; ++j)
			{
				bool flag = true;
				for(int k = 0; k < ticket.size(); ++k)
				{
					if(lottery[j].first[k] == '*')
					{
						continue;
					}	
					else if(ticket[k] != lottery[j].first[k])
					{
						flag = false;
						break;
					}
				}
				if(flag)
				{
					sum += lottery[j].second;
					break;
				}
			}
		}
		cout << sum << endl;
	}
}

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

Measured memory_bytes: 1216
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())

answer = 0
for _ in range(N):
    x,u = input().split()
    if u == "JPY":
        money = float(x) 
    else:
        money = float(x)*380000.0
    answer += money
print(answer)



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

using namespace std;
typedef long long ll;
const int N = 1e5+5;
const ll oo = 1e18;
const ll mod = 1e9+7;
const int INF = 1 << 30;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
    
    ll n, k;
    cin >> n >> k;
    if (n % k == 0) {
        cout << 0 << endl;
    } else {
        cout << min(n%k, abs((n%k) - k)) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e5+10;

ll a;
int main() {
	int n;
	cin>>n;
	ll tmp = 1e18;
	ll ans = 1;
	rep(i, 0, n) {
		scanf("%lld", &a);
		if(a == 0) {
			ans = 0;
			continue;
		}
		tmp = tmp / a;//cout<<tmp<<"\n";
		if(tmp != 0)
		ans *= a;
	}
	//cout<<99999900000 / 999999000001<<"\n";
	if(tmp == 0&&ans != 0) {
		cout<<-1;
	} else {
		cout<<ans;
	}
	return 0;
} 

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

int main() {
    while(1){
	    int n; cin >> n;
        if(n==0) return 0;
        vector<int> a(n);
	    int sum=0;
        for(int i=0; i < n; i++){
            cin >> a[i];
            sum += a[i];
        }
        sum /= n;
        int cnt=0;
        for(int i=0; i < n; i++){
            if(a[i] <= sum) cnt++;
        }
        cout << cnt << endl;
    }
}
//./test < in > out


Measured memory_bytes: 3112
#include<iostream>
using namespace std;
int main()
{
	int n;
	float sum=0.0,sum1=0.0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		
	}
	for(int i=0;i<n;i++)
	{
	
	sum=sum+((float)1/a[i]);
}

	 sum1=1/sum;
	cout<<sum1<<endl;
	

}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False


def main():
    N = I()
    A = LI()
    A = sorted(A)
    acc = list(accumulate(A))
    mag = []

    for i in range(N-1):
        mag.append(A[i+1] / acc[i])

    # print(A)
    # print(acc)
    # print(mag)

    ans = 0
    for i in range(len(mag)):
        if mag[i] > 2.0:
            ans = 0
        else:
            ans += 1

    print(ans + 1)


if __name__ == '__main__':
    main()


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 200005;

void solve(){
 	ll a;
 	float b;
	cin >> a >> b;
	b *= 100.0;
	cout << (ll)((a*(ll)round(b))/100) << endl;
}

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


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

#include <vector>
int main(){
    int n; cin >> n;
    vector<int> high(n),dp(n);
    for(int i=0; i<n; i++) cin >> high.at(i);
    dp.at(0)=0;
    dp.at(1)=abs(high.at(0)-high.at(1));
    for(int i=2; i<n; i++) {
        dp.at(i)=min(dp.at(i-1)+abs(high.at(i-1)-high.at(i)),dp.at(i-2)+abs(high.at(i-2)-high.at(i)));
    }
    printf("%d\n",dp[n-1]);
}

Measured memory_bytes: 3904
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
    ll n ,m;
    cin >> n >> m;
    int odd[n+m+10],j=0;
    for(int i=0;i<n;i++)odd[j++]=2;
    for(int i=0;i<m;i++)odd[j++]=3;
    int ans = 0;
    //for(int i=0;i<n+m;i++)cout<<odd[i]<<' ';cout<<endl;
    for(int i=0;i<n+m;i++)
    {
        for(int j=i+1;j<n+m;j++)
            if((odd[i]+odd[j])%2==0)ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
#define ll long long int
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
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;}
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    while (cin >> s, s[0] != '#')
    {
        int m, d, y;
        cin >> y >> m >> d;
        if(y>31){
            cout << "? " << y-30 << " " << m << " " << d << endl;
        }
        else if (y==31)
        {
            if(m>=5)    
                cout << "? " << y - 30 << " " << m << " " << d << endl;
            else
                cout << s << " " << y << " " << m << " " << d << endl;
        }
        else{
            cout <<s<< " " << y << " " << m << " " << d << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MAXN = 212345;
int n, m, k;
ll ft[MAXN];
ll get(int x) {
    ll ans = 0;
    for (; x; x-=x&-x) {
        ans = max(ans, ft[x]);
    }
    return ans;
}

void update(int x, ll v) {
    for (; x<=n; x+=x&-x) {
        ft[x] = max(v, ft[x]);
    }
}

int h[MAXN], v[MAXN];
int main() {
    scanf("%d", &n);
    for (int i = 1; i<=n; ++i) {
        scanf("%d", h+i);
    }
    for (int i = 1; i<=n; ++i) {
        scanf("%d", v+i);
    }
    ll ans = 0, sum;
    for (int i = 1; i<=n; ++i) {
        sum = get(h[i])+v[i];
        ans = max(ans, sum);
        update(h[i], sum);
    }
    printf("%lld\n", ans);
}


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

using namespace std;

int main(){
	int n,v[111];
	scanf("%d",&n);
	
	for(int w = 0;w < n;w++){
		scanf("%d",&v[w]);
	}
	sort(v, v + n);

	int resp = 0;
	for(int i = 0;i < n;i++){
		for(int j = i+1;j < n;j++){
			for(int k = j+1;k < n;k++){
				if(abs(v[j] - v[k]) < v[i] && v[i] < v[j] + v[k]){
					if(abs(v[i] - v[k]) < v[j] && v[j] < v[k] + v[i]){
						if(abs(v[j] - v[i]) < v[k] && v[k] < v[j] + v[i]){
							if(v[i] != v[j] && v[i] != v[k] && v[j] != v[k]){
								resp++;
							}
						}
					}
				}
			}
		}
	}
	printf("%d\n",resp);
}

Measured memory_bytes: 3740
#include <stdio.h>

int main()
{
    int n, i;
    long money = 1000;
    int a[80];

    scanf("%d", &n);

    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    
    for (i = 0; i < n-1; i++) {
        if (a[i] < a[i+1]) {
            money += money / a[i] * (a[i+1] - a[i]);
        }
    }

    printf("%ld\n", money);

    return 0;
}

Measured memory_bytes: 1736
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9


def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
from collections import deque


n, m = map(int, input().split())
path = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    path[a-1].append(b-1)
    path[b-1].append(a-1)



from collections import deque


def dfs(path, start):
    que = deque([(start, 0)])
    dist = [float('inf')] * n
    while que:
        cur, c = que.popleft()
        c += 1
        for nxt in path[cur]:
            if c < dist[nxt]:
                dist[nxt] = c
                que.append((nxt, c))
    return dist



dist = dfs(path, 0)
if dist[-1] == 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 90828
#include <bits/stdc++.h>
using namespace std;
long long n , x[300000] , previx[300000] , ans;
map<long long , int>pos; 
int main(){
	cin >> n;
	pos[0]++;
	for(int i = 1 ; i <= n ; i++){
		cin >> x[i];
		previx[i] = x[i] + previx[i - 1];
		pos[previx[i]]++;
		if(pos[previx[i]] > 1){
			ans += pos[previx[i]] - 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 19128
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    a = Intl()
    all = 1
    cnt = 1
    for i in range(n):
        all *= 3
        if a[i]%2 == 0:cnt *= 2
    print(all-cnt)

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

int main(){
	ll k,n;
	cin >> k >> n;
	vector<ll> a(n+1);
	rep(i,n){
		cin >> a[i];
	}
	a[n] = a[0] + k;
	ll temp = 0;
	rep(i,n){
		temp = max(temp, a[i+1] - a[i]);
	}
	ll ans = k - temp;
	cout << ans << endl;
	
    return 0;
}



Measured memory_bytes: 1792