akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt {
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};
using mint = ModInt<MOD>;

mint dp[2010];
int main() {
	int s; cin >> s;
	dp[0] = 1;
	for(int i = 0; i <= s; ++i) {
		for(int j = 3; j <= s; ++j) {
			if(i + j > s) continue;
			dp[i + j] += dp[i];
		}
	}
	cout << dp[s] << '\n';
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
    int h,w;
    cin>>h>>w;

    vector<vector<char>>s(52,vector<char>(52));

    for (int i = 0; i < 52; i++){
            for (int j = 0; j < 52; j++){
                s[i][j] = '.';
            }
    }

    for (int i=1;i<h+1;i++) {
        for (int j=1;j<w+1;j++) {
            cin>>s[i][j];
        }
    }

    for (int i=1;i<h+1;i++) {
        for (int j=1;j<w+1;j++) {
            if(s[i][j]=='#'){
                cout<<s[i][j];
            }
            else {
                int count=0;
                for (int k=-1;k<=1;k++) {
                    for(int l=-1;l<=1;l++){
                        if(s[i+k][j+l]=='#'){
                            count++;
                        }
                    }
                }
                cout<<count;
            }
        }
        cout<<endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    ll now=100;
    ll x;
    cin >> x;
  	int n=100000000;
    rep(i,n){
        if(now>=x){
            cout << i;
            return 0;
        }
        now*=1.01;
    }


    
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

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

typedef struct node {
    int value, size;
    struct node *lch, *rch;
} node_t;

typedef node_t* segtree_t;

void combine_segtree(segtree_t root) {
    root->size = root->lch->size + root->rch->size;
    root->value = min(root->lch->value, root->rch->value);
}

segtree_t make_segtree(int size) {
    segtree_t root = (segtree_t)malloc(sizeof(node_t));
    root->size = size;
    root->value = INT_MAX;
    root->lch = root->rch = NULL;
    if (size == 1) return root;
    root->lch = make_segtree(size / 2);
    root->rch = make_segtree(size - size / 2);
    combine_segtree(root);
    return root;
}

void free_segtree(segtree_t root) {
    if (root->lch) free(root->lch);
    if (root->rch) free(root->rch);
    free(root);
}

void update_segtree(segtree_t root, int k, int x) {
    if (root->lch == NULL && root->rch == NULL) {
        free_segtree(root);
        root = make_segtree(1);
        if (k == 0) root->value = x;
    }
    else if (k < root->lch->size) {
        update_segtree(root->lch, k, x);
        combine_segtree(root);
    }
    else {
        int lsize = root->lch->size;
        update_segtree(root->rch, k - lsize, x);
        combine_segtree(root);
    }
}

int min_query(segtree_t root, int a, int b) {
    if (root->lch == NULL)
        return (a <= 0 && b > 0)
            ? root->value
            : INT_MAX;
    if (a <= 0 && root->size <= b) return root->value;
    if (b <= 0 || root->size <= a) return INT_MAX;
    int lsize = root->lch->size,
        left = min_query(root->lch, a, b),
        right = min_query(root->rch, a - lsize, b - lsize);
    return min(left, right);
}

enum command { Update, Find, };

int main(void) {
    int n, q, i;
    scanf("%d%d", &n, &q);
    segtree_t rmq = make_segtree(n);
    for (i = 0; i < q; i++) {
        int com, x, y;
        scanf("%d%d%d", &com, &x, &y);
        switch (com) {
            case Update:
                update_segtree(rmq, x, y);
                break;
            case Find:
                printf("%d\n", min_query(rmq, x, y + 1));
        }
    }
    free_segtree(rmq);
    return 0;
}

Measured memory_bytes: 6848
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N, K = (int(_) for _ in input().split())
    if N%K == 0:
        print(0)
    else:
        print(1)
if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
  string s;
  int q;
  int a,b;
  
  cin >> s;

  cin >> q;

  string order,str;
  
  for(int i=0;i < q;i++)
    {
      cin >> order;
      if(order == "replace")
	{
	  cin >> a >> b >> str;
	  s.replace(a,str.size(),str);
	}
      else if(order == "reverse")
	{
	  cin >> a >> b;
	  reverse(s.begin()+a, s.begin()+b+1);
	}
      else if(order == "print")
	{
	  cin >> a >> b;
	  for(int i=a;i <= b;i++)
	    {
	      printf("%c",s[i]);
	    }
	  printf("\n");
	}
    }
  return 0;
}

  



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

using namespace std;

int main()
{
  int n, x;
  cin >> n;
  x=n%10;
  if(x==2 || x==4 || x==5 || x==7 || x==9)cout << "hon";
  else if(x==3)cout << "bon";
  else cout << "pon";
}

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


void rotate(char in[][9], char out[][9])
{
    int x, y, j;
    
    for (x = 0; x < 8; x++){
        for (y = 0; y < 8; y++){
            out[x][7 - y] = in[y][x];
        }
        out[x][8] = '\0';
    }
}

int main(void)
{
    char in[8][9];
    char out[8][9];
    char tmp[8][9];
    int i, j;
    
    for (i = 0; i < 8; i++){
        scanf("%s", in[i]);
    }
    
    for (i = 1; i <= 3; i++){
        memcpy(tmp, in, sizeof(in));
        for (j = 1; j <= i; j++){
            rotate(tmp, out);
            memcpy(tmp, out, sizeof(out));
        }
        printf("%d\n", i * 90);
        for (j = 0; j < 8; j++){
            printf("%s\n", tmp[j]);
        }
    }
    
    return (0);
}

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


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

    for(int i=0; i<=n; i++){
        for(int j=0; j<=m; j++){
            int tmp = i*(m-j) + j*(n-i);
            if(tmp == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3552
#include <stdio.h>

int main(void)
{
    int a, b;
    char op[2];
    
    
    while (1){
        scanf("%d%s%d", &a, op, &b);
        if (op[0] == '?'){
            break;
        }
        
        switch (op[0]){
          case '+':
            printf("%d\n", a + b);
            break;
            
          case '-':
            printf("%d\n", a - b);
            break;

          case '*':
            printf("%d\n", a * b);
            break;

          case '/':
            printf("%d\n", a / b);
            break;
        }
    }

    return (0);
}



Measured memory_bytes: 2104
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int a[100010];

bool isprime(int n){
    if(n<=1) return false;
	for(int i=2;i*i<=n;i++){
        if(n%i==0) return false;
	}
	   return true;
}

int main(void){
	          int i,j;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);

	      	  for(i=3;i<=100000;i+=2){
	      		  if(isprime(i) && isprime((i+1)/2)) a[i]=1;
	      	  }

	      	  for(i=1;i<=100000;i++) a[i]+=a[i-1];

	      	  int Q;
	      	  cin >> Q;
	      	  for(i=1;i<=Q;i++){
	      		  int L,R;
	      		  cin >> L >> R;
	      		  cout << a[R]-a[L-1] << endl;
	      	  }

	          return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int gx,gy;
  cin>>gx>>gy;

  int y=0,x=0,sz=1,pr=0,color=0,dir=0;
  while(1){
    if(y<=gy&&gy<y+sz&&x<=gx&&gx<x+sz){
      cout<<(color%3)+1<<endl;
      break;
    }
    int nx=sz+pr;
    if(dir==0){
      x+=sz;
    }
    if(dir==1){
      x-=pr;
      y+=sz;
    }
    if(dir==2){
      x-=nx;
      y-=pr;
    }
    if(dir==3){
      y-=nx;
    }
    pr=sz;
    sz=nx;
    color++;
    dir=(dir+1)%4;
  }
  return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
ll n,m,k; 
int main()
{
	cin>>n;
	if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
	{
		cout<<"hon";
	}
	else
	{
		if(n%10==0||n%10==1||n%10==6||n%10==8)
		{
			cout<<"pon";
		}
		else
		{
			cout<<"bon";
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int gcd(int a,int b){
   if(a%b==0) return b;
   return gcd(b,a%b);
}
int digit(long long num){
   int cnt=0;
   while(num!=0){
      cnt+=num%10;
      num=num/10;
   }
   return cnt;
}
int main(void){
   string S;
   cin>>S;
   int N=S.size();
   vector<vector<int>> dp(N+1,vector<int>(3,-1));
   dp[0][0]=0;
   for(int i=0;i<N;i++){
      for(int j=0;j<=2;j++){
         if(dp[i][j]==-1) continue;
         for(int k=1;k<=2&&i+k<=N;k++){
            if(j!=k||S.substr(i-j,j)!=S.substr(i,k)){
               dp[i+k][k]=max(dp[i+k][k],dp[i][j]+1);
            }
         }
      }
   }
   int ans=0;
   for(int i=0;i<=2;i++){
      ans=max(ans,dp[N][i]);
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 14396
#include <iostream>
#include <set>

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::multiset<int> S;
    while(1){
        std::string Command;
        std::cin >> Command;
        if(Command[0] == 'i'){
            int Value;
            std::cin >> Value;
            S.insert(Value);
        }else
        if(Command[1] == 'x'){
            std::set<int>::reverse_iterator It = S.rbegin();
            std::cout << *It << std::endl;
            S.erase(--(It.base()));
        }else{
            break;
        }
    }
    return 0;
}

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

#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)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N; cin >> N;
    if (N % 2 == 0) cout << N / 2 - 1 << endl;
    else cout << N / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long int dp[n][3];
  int arr[n][3],i,j;
  for(i=0;i<n;i++)
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  dp[0][0]=arr[0][0];dp[0][1]=arr[0][1];dp[0][2]=arr[0][2];
  for(i=1;i<n;i++)
  {
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
    dp[i][1]=max(dp[i-1][2],dp[i-1][0])+arr[i][1];
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  return 0;
            }
    

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double

#define int long long

typedef pair<int, int> II;
typedef pair<int, II> III;

const int INF = (1 << 30) - 1;
const long long oo = (1ll << 62) - 1;
const long double PI = 3.1415926535898;
///BEGIN CODE
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const int A = 4000 + 5;

int n;
II a[N];
int gt[2 * A], m[A];
int f[A][A];

void giaithua()
{
    gt[0] = 1;;
    for(int i = 1; i < 2 * A; i++)
        gt[i] = (gt[i - 1] * i) % MOD;
}

int power(int a, int b)
{
    if(b == 0) return 1;
    if(b == 1) return a;
    int ans = power(a, b / 2);
    ans = (ans * ans) % MOD;
    if(b & 1) ans = (ans * a) % MOD;
    return ans;
}

void modulo()
{
    for(int i = 1; i < A; i++)
    {
        m[i] = power(gt[i], MOD - 2);
    }
}

int tinh(int x, int y)
{
    int ans = 1;
    int val = gt[x + y];
    int m1 = m[x];
    int m2 = m[y];
    ans = (ans * val) % MOD;
    ans = (ans * m2) % MOD;
    ans = (ans * m1) % MOD;
    return ans;
}


void xuly()
{
    for(int i = 1; i <= n; i++)
    {
        int x = a[i].fi, y = a[i].se;
        f[2001 - x][2001 - y] += 1;
    }
    for(int i = 1; i < A; i++)
    {
        for(int j = 1; j < A; j++)
        {
            f[i][j] = (f[i - 1][j] + f[i][j - 1] + f[i][j]) % MOD;
        }
    }
    int res = 0;
    for(int i = 1; i <= n; i++)
    {
        int x = a[i].fi, y = a[i].se;
        res = (res + f[2001 + x][2001 + y]) % MOD;
        res = (res - tinh(x * 2, y * 2) + MOD * MOD) % MOD;
    }
    res = (res + MOD * MOD) % MOD;
    res = (res * power(2, MOD - 2)) % MOD;
    cout << res;

}

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("BARECUE.inp", "r", stdin);
    //freopen("BARECUE.out", "w", stdout);
    cin >> n;
    for(int i = 1; i <= n ;i++)
        cin >> a[i].fi >> a[i].se;
    giaithua();
    modulo();
    xuly();
}

/**
    Code by: Best_Nakroth 12TH.


*/


Measured memory_bytes: 128768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n+1, 0);
    rep(i, m) {
        int x, y; cin >> x >> y;
        a[x]++; a[y]--;
    }
    bool ok = true;
    for(const auto& v: a) {
        if (v%2!=0) ok = false;
    }
    if (ok) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-


#----------
N,K = list(map(int, input().rstrip().split()))
A_list = list(map(int, input().rstrip().split()))
#----------
balls={}

for num in A_list:
    if str(num) not in balls:
        balls[str(num)] = 1
    else:
        balls[str(num)] += 1

# 辞書ballsを昇順にソート
balls_list = sorted(balls.items(),key=lambda x:x[1])

result = 0
if len(balls) > K:
    for i in range(len(balls) - K):
        result += balls_list[i][1]

print(result)


Measured memory_bytes: 50076
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;
    Graph G(N);
    G[X].push_back(Y);
    G[Y].push_back(X);
    rep(i, N-1){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }

    vector<int> dist_sum(N, 0);

    for(int v0 = 0; v0 < N; v0++){
        vector<int> dist(N, -1);
        queue<int> que;
        que.push(v0);
        dist[v0] = 0;
        
        while(!que.empty()){
            int v1 = que.front();
            que.pop();
            for(int v2 : G[v1]){
                if(dist[v2] != -1) continue;
                dist[v2] = dist[v1] + 1;
                dist_sum[dist[v2]]++;
                que.push(v2);
            }
        }
    }

    for(int i = 1; i< N; i++){
        cout << dist_sum[i] / 2 << endl;
    }

}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long n;
    cin>>n;
    long long i=0,x=0,y=0,r=n;
    while (i<=pow(n,0.5))
    {
    i++;
    if (n%i==0)
    {
        x=n/i;
        y=i;
        r=min(x+y-2,r);
    }
    }
    cout<<r;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define N 100100
using namespace std;
template<typename T>inline void read(T &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-48);c=getchar();}
	x*=p;
}
int n,m;
int a[N];
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
//	freopen("mnth.in","r",stdin);
//	freopen("mnth.out","w",stdout);
	read(n);
	for(int i=1;i<=n;i++)
		read(a[i]);
	sort(a+1,a+n+1,cmp);
	int stx=1,sty=1;
	while(sty+1<=a[stx+1])sty++,stx++;
	int now=stx+1;
	while(a[now]==sty)now++;
	if((now-stx)%2==1&&(a[stx]+1-sty)%2==1)
		puts("Second");
	else puts("First");
	return 0;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define eb emplace_back
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e18;
  const int N=3e5+35;
  const int M=1005;
 

 void doit()         
 {
   int a,b,n; cin>>a>>b>>n;

   int t=n; if(n>=b) t=b-1;

   int ans1=(t*a)/b,ans2=t/b; ans2*=a;

   cout<<ans1-ans2;
   
 }

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
   int tc=1;                         
 //   cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
    
   doit();
   if(i<tc)
   cout<<nl;
  }
 
 return 0; 
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include<algorithm>
#include<vector>


using namespace std;

int main()
{
    bool rev = false;

    string S;
    vector<char> b, e;
    cin >> S;

    int Q;
    cin >> Q;


    for (int q = 0; q < Q; q++){
        int T;
        cin >> T;
        if(T == 1){
            rev = (!rev);
        }else{
            int F;
            char C;
            cin >> F >> C;
            if(F == 1){
                if(rev){
                    e.push_back(C);
                }else{
                    b.push_back(C);
                }
            }else{
                if(rev){
                    b.push_back(C);
                }else{
                    e.push_back(C);
                }
            }
        }

    }
    
    if(rev){
        reverse(e.begin(), e.end());
        reverse(S.begin(), S.end());
        for (auto itr = e.begin(); itr != e.end(); itr++){
            cout << *itr;
        }
        cout << S;
        for (auto itr = b.begin(); itr != b.end(); itr++){
            cout << *itr;
        }
        cout << '\n';
    }else{
        reverse(b.begin(), b.end());
        for (auto itr = b.begin(); itr != b.end(); itr++)
        {
            cout << *itr;
        }
        cout << S;
        for (auto itr = e.begin(); itr != e.end(); itr++)
        {
            cout << *itr;
        }
        cout << '\n';
    }
}

Measured memory_bytes: 3872
s = input()
while len(s) > 4:
    if s[:5] == "dream":
        if s[5:7] == "er":
            if s[7:10] == "ase":
                s = s[5:]
            else:
                s = s[7:]
        else:
            s = s[5:]
    elif s[:5] == "erase":
        if s[5:6] == "r":
            s = s[6:]
        else:
            s = s[5:]
    else:
        break
if s == "":
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
    int work[10];
    int temp;
    for(int i = 0; i < 10; i++){
        cin >> work[i];
    }
    for(int i = 0; i < 9; i++){
        for(int j = i + 1; j <= 9; j++){
            if(work[i] < work[j]){
                temp = work[i];
                work[i] = work[j];
                work[j] = temp;
            }
        }
    }
    for(int i = 0; i < 3; i++){
        cout << work[i] << endl;
    }
    return 0;
}

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

int main() {
    int cnt[101]{};
    int n;
    int mx=0;
    while (cin>>n) {
        cnt[n]++;
        mx=max(mx,cnt[n]);
    }
    for (int i=1;i<=100;i++)
        if (cnt[i]==mx)
            cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 3080
from queue import PriorityQueue
X,Y,Z,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
A.append(-float('inf'))
B.sort(reverse=True)
B.append(-float('inf'))
C.sort(reverse=True)
C.append(-float('inf'))

pq = PriorityQueue()
pq.put((-(A[0]+B[0]+C[0]),0,0,0))
count = 0
queued = set([(0,0,0)])
while True:
  d,i,j,k = pq.get()
  #print(-d,i,j,k)
  print(-d)
  count += 1
  if count >= K:
    break
  for l in [i,i+1]:
    for m in [j,j+1]:
      for n in [k,k+1]:
        if (l,m,n) in queued:
          continue
        else:
          pq.put((-(A[l]+B[m]+C[n]),l,m,n))
          queued.add((l,m,n))

Measured memory_bytes: 5996
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;

int main(void){
    int n;
    cin>>n;
    vector<int> A(n);
    rep(i,n) cin>>A[i];
    vector<int> ans(n,-1);
    int m=0;
    for(int i=n;i>0;--i){//上から決めていく
        int count=0;//i以外のiの倍数のうちボールが入ってる個数
        for(int j=2;j<=n;++j){
            if(i*j>n) break;
            if(ans[i*j-1]==-1){
                puts("error");
                return 0;
            }
            count+=ans[i*j-1];
        }
        if(count%2==A[i-1])
            ans[i-1]=0;
        else{
            ans[i-1]=1;
            m++;
        }
    }
    cout<<m<<endl;
    rep(i,n) if(ans[i]==1) cout<<i+1<<" ";
    cout<<endl;
    return 0;
}

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


int main(){
    ios::sync_with_stdio(0);
    int n ,k;
    cin >> n >> k;
    double s[n], sums[n], ans = 0;
    for (int i = 0 ; i < n ; ++i){
        int a;
        cin >> a;
        s[i] = (a+1)/2.0;
    }
    sums[0] = s[0];
    int j = 1;
    while(j < k){
        sums[j] = sums[j-1] + s[j];
        ++j;
    }
    while(j < n){
        sums[j] = sums[j-1] + s[j] - s[j-k];
        ++j;
    }
    for (int i = 0 ; i < n ; ++i)
        ans = max(ans, sums[i]);
    cout.precision(9);
    cout << ans;
    return 0;
}


Measured memory_bytes: 3456
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;

int main(){
 
	ll n,ans=1;
	cin>>n;
	rep(i,n){
		ans *= i+1;
	}
	cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3092
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
for i in txy:
    if i[1] + i[2] > i[0] or i[0] % 2 != (i[1] + i[2]) % 2:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 27300
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    boolean[][] cards=new boolean[4][14];
     
    public int StoI(String s){
        if("S".equals(s)){
            return 0;
        }else if("H".equals(s)){
            return 1;
        }else if("C".equals(s)){
            return 2;
        }else{
            return 3;
        }
    }
    public String ItoS(int i){
        switch(i){
        case 0:return "S";
        case 1:return "H";
        case 2:return "C";
        case 3:return "D";
        default:return null;
        }
    }
     
    public void run() {
        int N = sc.nextInt();
        for(int i=0;i<N;i++){
            String type=sc.next();
            int num=sc.nextInt();
            cards[StoI(type)][num]=true;
        }
         
        for(int c=0;c<4;c++)for(int i=1;i<=13;i++){
            if(!cards[c][i]){
                ln(ItoS(c)+" "+i);
            }
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}


Measured memory_bytes: 26376
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, m) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]

    return (n, m, a)


def solve(n, m, a):


    total = sum(a)

    cnt = 0
    for i in range(n):
        if a[i] * 4 * m >= total:
            cnt = cnt + 1

    if cnt >= m:
        result = 'Yes'
    else:
        result = 'No'

    
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
bitset<50005> st[50005];
const int Q=1<<20;
int X[Q],Y[Q];
int had[Q];
char ans[Q];
int si[Q],bel[Q];
int main()
{
    int n,m,ty;
    scanf("%d%d%d",&n,&m,&ty);
    for(int i=1;i<=m;i++)
            scanf("%d%d",&X[i],&Y[i]);
    if(ty==1){
        for(int i=1;i<=n;i++)
            st[i][i]=1;
        for(int i=1;i<=m;i++)
            st[X[i]]=st[Y[i]]=st[X[i]]|st[Y[i]];
        int beg=-1;
        for(int i=1;i<=n;i++)
            if(st[i].count()==n){
                beg=i;
                break;
            }
        if(beg<0)return 0&puts("-1");
        had[beg]=1;
        for(int i=m;i;--i)
            if(!had[X[i]])ans[i]='v',had[X[i]]|=had[Y[i]];
            else ans[i]='^',had[Y[i]]|=had[X[i]];
        ans[m+1]='\n';
        printf("%s",ans+1);
        return 0;
    }
    if(n==2)return 0&puts("-1");
    for(int i=1;i<=n;i++)
        bel[i]=i,si[i]=1;
    for(int j=m;j;--j){
        int tx=bel[X[j]],ty=bel[Y[j]];
        if(tx==ty)ans[j]='^';
        else if(si[tx]>=2)ans[j]='v',--si[tx],++si[ty],bel[X[j]]=ty;
        else ans[j]='^',++si[tx],--si[ty],bel[Y[j]]=tx;
    }
    ans[m+1]='\n';
    printf("%s",ans+1);
    return 0;
}

Measured memory_bytes: 312960
n,k = map(int,input().split())
a = list(map(int,input().split()))

leq,high = 0,1e10
while high-leq > 1:
  l = int((leq+high)/2)
  cnt = 0
  for ai in a:
    cnt += int((ai-1)/l)
  if cnt>k:
    leq = l
  else:
    high = l

print(high)

Measured memory_bytes: 30624
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 100 * 1000 + 7;
const int MOD = 1000 * 1000 * 1000 + 7;

vector<int> g[MX];
int f[MX][2];

void dfs(int v, int p) {
    f[v][0] = f[v][1] = 1;
    for (int to : g[v]) {
        if (to != p) {
            dfs(to, v);
            f[v][0] = (1ll * f[v][0] * (f[to][0] + f[to][1])) % MOD;
            f[v][1] = (1ll * f[v][1] * f[to][0]) % MOD;
        }
    }
}
int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs(1, -1);

    cout << (f[1][0] + f[1][1]) % MOD << "\n";
    return 0;
}



Measured memory_bytes: 9472
n,a,b,c,d=map(int,input().split())
a,b,c,d=a-1,b-1,c-1,d-1
s=input()
if c==d:
  print('No')
elif c<d:
  for i in range(a,d+1):
    if s[i]=='#' and s[i+1]=='#':
      print('No')
      break
  else:
    print('Yes')
elif c>d:
  for i in range(a,c+1):
    if s[i]=='#' and s[i+1]=='#':
      print('No')
      break
  else:
    for i in range(b,d+1):
      if s[i]=='.':
        if s[i-1]=='.' and s[i+1]=='.':
          print('Yes')
          break
    else:
      print('No')

Measured memory_bytes: 3572
s = input()
n = int(input())
for _ in range(n):
    r, a, b, *p = input().split()
    a = int(a)
    b = int(b) + 1 
    if r == "replace":
        s = s[:a] + p[0] + s[b:]
    elif r == "reverse":
        s = s[:a] + s[a:b][::-1] + s[b:]
    elif r == "print":
        print(s[a:b])
    else:
        print("unknown")



Measured memory_bytes: 5612
#include<stdio.h>
int main(void)
{
    int A,B;
    scanf("%d%d",&A,&B);
    if(A<10)
    {
        if(B<10)
        {
            printf("%d\n",A*B);
        }
        else
        {
            printf("%d\n",-1);
        }
    }
    else
    {
        printf("%d\n",-1);
    }
    return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	b1, b2, b4 := 0, 0, 0

	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)

		b := 0
		for ; a%2 == 0; b++ {
			a /= 2
		}
		if b == 0 {
			b1++
		} else if b == 1 {
			b2++
		} else {
			b4++
		}
	}

	if b2 == 0 {
		if b1 <= b4+1 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else {
		if b1 <= b4 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}

}


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


class dice {
public:
	dice(int* a) {
		set(a[0], a[1], a[2], a[3], a[4], a[5]);
	}
	dice(int& a, int& b, int& c, int& d, int &e, int& f) {
		set(a, b, c, d, e, f);
	}
	void turn(int n) {
		if (n < 4)
		{
			turndice(n);
			return;
		}
		switch (n)
		{
		case 'N':
			turndice(0);
			break;
		case 'E':
			turndice(1);
			break;
		case 'S':
			turndice(2);
			break;
		case 'W':
			turndice(3);
			break;
		}

	}

	int getcurrent(void) { return label[0]; }

private:

	int label[6];

	void set(int& a, int& b, int& c, int& d, int &e, int& f) {
		label[0] = a; 
		label[1] = b; 
		label[2] = c; 
		label[3] = d; 
		label[4] = e; 
		label[5] = f; 
	}
	void turndice(int n)
	{
		int m = (n > 1) ? n - 2 : n + 2;
		int f[] = { 1, 3, 4, 2 };
		int tmp;

		tmp = label[0];
		label[0] = label[f[n]];
		label[f[n]] = label[5];
		label[5] = label[f[m]];
		label[f[m]] = tmp;
	}

};

#define A

#ifdef A
int main(void)
{
	int in[6];
	for (auto &a :in)
	{
		cin >> a;
	}
	dice d(in);
	string oder;
	cin >> oder;
	for (size_t i = 0; i < oder.size(); i++)
	{
		d.turn(oder[i]);
	}

	cout << d.getcurrent() << endl;


	return 0;
}
#endif // A

Measured memory_bytes: 3200
#include <iostream>

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;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w,n;cin>>h>>w>>n;
    ll ans = 0;
    cout<<(n+max(h,w)-1)/max(h,w);

    return 0;
}

Measured memory_bytes: 256
// Problem : D - Redistribution
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
 
#define endl "\n"
#define int long long
#define FAST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define rep(n) for(int i=0;i<(n);i++)
#define rrep(n) for(int i=(n)-1;i>=0;i--)
#define mem(a,b) memset((a),(b),sizeof (a))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define INF (long long) 1e18
#define MOD 1000000007


void solve(){
      int s;
      cin>>s;
      int dp[2001];
      dp[0]=dp[1]=dp[2]=0;
      for(int i=3;i<=s;i++){
            dp[i] = 1;
            for(int j=i-3;j>2;j--){
                  dp[i] = (dp[j] + dp[i])%MOD;
            }
      }
      cout<<dp[s]<<endl;
}

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




Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	
	}
	int b[n]={0};
	int x=1;
	for(int i=0;i<n-1;i++){
		if(a[i+1]<=a[i]){
			x++;
		}
		else{
			
			b[i]=x;
			x=1;
		}
	}
	b[n-1]=x;
	sort(b,b+n);
	
	cout<<b[n-1]-1;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	int ans, x;
	rep(i, 5) {
		cin >> x;
		if (x == 0)ans = i + 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3592
L, R = map(int, input().split())
min_mod = 2019

if R - L >= 2019:
    for i in range(2018):
        for j in range(i+1, 2019):
            min_mod = min(min_mod, (i*j) % 2019)

else:
    for i in range(L, R):
        for j in range(i+1, R+1):
            min_mod = min(min_mod, (i*j) % 2019)

print(min_mod)


Measured memory_bytes: 65480
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Runtime.InteropServices.ComTypes;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Security.Cryptography.X509Certificates;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            int N = cin.nextInt();
            List<int> buka = new List<int>();
            for (int i = 0; i < N; i++)
            {
                buka.Add(0);
            }
            for (int i = 0; i < N - 1; i++)
            {
                buka[cin.nextInt() - 1]++;
            }

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(buka[i]);
            }
        }

    }
}


Measured memory_bytes: 42328
//超时 
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,max=0,Max=0,cnt=0;
	int a[200020]={};
	int b[200020]={};
	while(~scanf("%d",&n)){
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
			max=max>a[i]?max:a[i];
		}
		for(i=0;i<n;i++){
			if(a[i]==max){
				cnt++;
			}if(a[i]!=max){
				Max=Max>a[i]?Max:a[i];
			}
		}if(cnt>1){
			while(n--){
				printf("%d\n",max);
			}
		}else if(n>1){
			i=0;
			while(n--){
				if(a[i]==max){
					printf("%d\n",Max);
				}else{
					printf("%d\n",max);
				}i++;
			}
		}else{
			printf("%d\n",a[0]);
		}
		max=0;Max=0;cnt=0;
	}
}

Measured memory_bytes: 2432
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<sstream>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF=0x3f3f3f3f;
const int MAX_N = 10;
const int MAX_H = 1005;
const int dx[] = {0, 0, -1, 1};
const int dy[] = {1, -1, 0, 0};
struct T{
    int x,y;
};//坐?
char G[MAX_H][MAX_H];
T aim[MAX_N];
int vis[MAX_H][MAX_H]; // ???数
int H, W, N;
T s, t; //起点，?点

int bfs(){
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            vis[i][j] = -1;
    queue<T> q;
    q.push(s);
    vis[s.x][s.y] = 0;
    while(!q.empty()){
        T cur = q.front();
        q.pop();
        if(cur.x == t.x && cur.y == t.y)break;
        for(int i = 0; i < 4; i++){
            T nxt;
            nxt.x = cur.x + dx[i];
            nxt.y = cur.y + dy[i];
            if(nxt.x >= 0 && nxt.x < H && nxt.y >= 0 && nxt.y < W && vis[nxt.x][nxt.y] == -1 && G[nxt.x][nxt.y] != 'X'){
                q.push(nxt);
                vis[nxt.x][nxt.y] = vis[cur.x][cur.y] + 1;
            }
        }
    }
    return vis[t.x][t.y];
}

void solve(){
    int ans = 0;
	for(int i = 0; i < N; i++){
        t = aim[i]; //?个?酪??点
        ans += bfs();
        s = t; //?次?点??下次起点
        G[s.x][s.y] = '.';
	}
	cout << ans << endl;
}
int main()
{
	#ifdef LOCAL
		freopen("in.txt","r",stdin);
	//	freopen("out.txt","w",stdout);
	#endif
	//ios::sync_with_stdio(false);
	cin >> H >> W >> N;
	int p = 0;
	for(int i = 0; i < H; i++){
        scanf("%s", G[i]);
        for(int j = 0; j < W; j++){
            if(G[i][j] == 'S'){
                s.x = i;s.y =j;
                G[i][j] = '.';
            }
            else if(G[i][j] <= '9' && G[i][j] >= 0){
                int num = G[i][j] - '0' - 1;
                aim[num].x = i;aim[num].y = j;
            }
        }
	}
	solve();
	return 0;
}

Measured memory_bytes: 6172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  ll a[N];
  ll no, n4;
  no = 0; n4 = 0;
  for (ll i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i]%2==1) {no++;}
    if (a[i]%4==0) {n4++;}
  }
  if (no > n4+1) {cout << "No" << endl; return 0;}
  if (no == n4+1 && 2*no-1 < N) {cout << "No" << endl; return 0;}
  cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
const int MASDFGHJKLXCVBNMNM=4000000;
const int NM=2020;
const int MOPDFGHJKL=1000000007;
int nm,kl;
long long fghjkl[NM][NM],fghjklasdfghjklcvbnm[MASDFGHJKLXCVBNMNM+5],iopnmvbnm_fghjklasdfghjklcvbnm[MASDFGHJKLXCVBNMNM+5];
inline long long C(int nm,int m){
	return (((fghjklasdfghjklcvbnm[m]*iopnmvbnm_fghjklasdfghjklcvbnm[nm])%MOPDFGHJKL)*iopnmvbnm_fghjklasdfghjklcvbnm[m-nm])%MOPDFGHJKL;
}
long long power(long long xcvbnm,int P){
    long long asdfghjklnmsdfghjkl=1,m=xcvbnm;
    while(P){
        if(P&1) (asdfghjklnmsdfghjkl*=m)%=MOPDFGHJKL;
        P>>=1;(m*=m)%=MOPDFGHJKL;
    }
    return asdfghjklnmsdfghjkl;
}
int main(){
	ios::sync_with_stdio(false);
    cin>>nm>>kl;
    if(kl==1) return cout<<1<<endl,0;
    fghjklasdfghjklcvbnm[0]=1;
	for(int iop=1;iop<=MASDFGHJKLXCVBNMNM;++iop)
		fghjklasdfghjklcvbnm[iop]=(fghjklasdfghjklcvbnm[iop-1]*iop)%MOPDFGHJKL;
    iopnmvbnm_fghjklasdfghjklcvbnm[MASDFGHJKLXCVBNMNM]=power(fghjklasdfghjklcvbnm[MASDFGHJKLXCVBNMNM],MOPDFGHJKL-2);
	for(int iop=MASDFGHJKLXCVBNMNM-1;iop>=0;--iop)
		iopnmvbnm_fghjklasdfghjklcvbnm[iop]=(iopnmvbnm_fghjklasdfghjklcvbnm[iop+1]*(iop+1))%MOPDFGHJKL;
    fghjkl[0][0]=1;
    for(int iop=1;iop<=nm;++iop){
        for(int jkl=0;jkl<=iop;++jkl){
            fghjkl[iop][jkl]=fghjkl[iop-1][jkl];
            if(!jkl) continue;
            (fghjkl[iop][jkl]+=fghjkl[iop][jkl-1]*(nm-jkl+1)%MOPDFGHJKL*C(kl-2,nm-iop+(nm-jkl+1)*(kl-1)-1)%MOPDFGHJKL)%=MOPDFGHJKL;
        }
    }
    cout<<fghjkl[nm][nm]<<endl;
    return 0;
}

Measured memory_bytes: 94464