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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long Y = sc.nextLong();
		sc.close();
		int A = 0;int B = 0;int C = 0;
		for(int i = 0;i <= N;i++) {
			A = i * 10000;
			for(int j = 0;j <= N;j++) {
				B = j * 5000;
				C = (N - i - j) * 1000;
				if(A + B + C == Y && C >= 0) {
					System.out.println(i + " " + j + " " + (N - i - j));
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}
}

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

using namespace std;
int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };

int main() {
  ios::sync_with_stdio( false );
  cin.tie( 0 );
  int H, W;
  cin >> H >> W;
  vector<vector<int> > info( H, vector<int>(W) );
  for ( int i = 0; i < H; i++ ) {
    string c;
    cin >> c;
    for ( int j = 0; j < W; j++ ) {
      if ( c[j] == '.' ) info[ i ][ j ] = 0;
      else info[ i ][ j ] = c[j] - '0';
    }
  }
  queue<pair<int, pair<int, int> > > q;
  vector<vector<int> > cnt( H, vector<int>( W, 0 ) );
  for ( int i = 1; i + 1 < H; i++ ) {
    for ( int j = 1; j + 1 < W; j++ ) {
      if ( info[ i ][ j ] ) {
        for ( int k = 0; k < 8; k++ ) {
          cnt[ i ][ j ] += !info[ i + dx[ k ] ][ j + dy[ k ] ];
        }
        if ( cnt[ i ][ j ] >= info[ i ][ j ] ) {
          q.push( make_pair( 1, make_pair( i, j ) ) );
        }
      }
    }
  }
  int ans = 0;
  while ( q.size() )
  {
    int num = q.front().first;
    pair<int, int> pos = q.front().second;
    q.pop();
    int x = pos.first, y = pos.second;
    ans = max( ans, num );
    for ( int i = 0; i < 8; i++ ) {
      cnt[ x + dx[ i ] ][ y + dy[ i ] ]++;
      if ( cnt[ x + dx[ i ] ][ y + dy[ i ] ] == info[ x + dx[ i ] ][ y + dy[ i ] ] )
      {
        q.push( make_pair( num + 1, make_pair( x + dx[ i ], y + dy[ i ] ) ) );
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define fcout cout << fixed << setprecision(15)
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 2; i * i <= n; i++) {
		int now = i;
		while(n % now == 0) {
			n /= now;
			now *= i;
			ans++;
		}
		while(n % i == 0) n /= i;
	}
	if(n != 1) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3648
// --------------
// Tejas Pandey  |
// 08 - 12 - 19  |
// KGP MIRROR'19 |
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int a,b,c;
      cin >> a >> b >> c;
		if(a + b + c < 22)
			cout << "win";
		else
			cout << "bust";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 2e5;
int N;
ll A[Nmax], B[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> A[i] >> B[i];

	ll sum = 0;
	bool same = true;
	for(int i=0; i<N; i++){
		sum += A[i];
		same = same && (A[i]==B[i]);
	}
	if(same){
		cout << 0 << endl;
		return 0;
	}

	ll m=1e10;
	for(int i=0; i<N; i++){
		if(A[i]>B[i] && B[i] < m) m = B[i];
	}
	cout << sum-m << endl;

	return 0;
}


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

    string a, b, c;
    cin >> a >> b >> c;

    /*
    if(a + b == c || a + c == b || b + c == a){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    */
    
    cout << a.at(0) << b.at(0) << c.at(0) << endl;

    return 0; 
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    
    int H, W;
    cin >> H >> W;

    vector<string> data(H);
    for (int i = 0; i < H; i++) {
        cin >> data.at(i);
    }
    
    for (int i = 0; i < W + 2; i++) {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < H; i++) {
        cout << "#" << data.at(i) << "#" << endl;
    }
    for (int i = 0; i < W + 2; i++) {
        cout << "#";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<cctype>


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


Measured memory_bytes: 2520
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define lli long long int
#define d double
#define mod 1000000007
#define mx 100001
using namespace std;
int main() {
	FIO;
	int n;
	cin>>n;
	vector<int> vec(n);
	lli total=0;
	for(int i=0;i<n;i++){
		cin>>vec[i];
		total+=vec[i];
	}
	vector<vector<lli>> dp(n,vector<lli>(n));//dp[l][r]->max score I can get from range l to r....
	for(int i=0;i<n;i++){
		dp[i][i]=vec[i];
		if(i!=n-1) dp[i][i+1]=max(vec[i],vec[i+1]);
	}
	for(int i=n-1;i>=0;i--){
		for(int j=i+2;j<n;j++){
			dp[i][j]=max(vec[i]+min(dp[i+2][j],dp[i+1][j-1]), vec[j]+min(dp[i+1][j-1],dp[i][j-2]));
		}
	}
	cout<<2*dp[0][n-1]-total<<endl;
}

Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a, b;
    char c;

    cin >> a >> c >> b;

    if (c == '+') {
        cout << a + b << endl;
    }
    else {
        cout << a - b << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=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;}

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

int main(){
    int A,B,X;
    cin>>X>>A>>B;
    cout<<(X-A)%B<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int q;
	long long n,i,k,j,sum=0,count=0,ans=0,m,w,mx=0;
	cin>>n>>w;
	long long a[n],b[n];
	for(i=0;i<n;i++)
	{cin>>a[i]>>b[i]; sum+=b[i];
	}
	
  long long	dp[n+1][sum+1];

    for(i=0;i<n+1;i++)
    {
        for(j=0;j<=sum;j++)
        dp[i][j]=1000000000000000;
    }
    dp[0][0]=0;
	for(i=1;i<=n;i++)
	{
	    for(j=0;j<=sum;j++)
	    {
	         if(j-(b[i-1])<0)
	        {
	            dp[i][j]=min(dp[i-1][j],dp[i][j]);
	        }
	        else
	        {
	            dp[i][j]=min(dp[i-1][j],dp[i-1][j-b[i-1]]+a[i-1]);
	        }
	    }
	    
	    
	}
	for(j=0;j<=sum;j++)
	{
	   if(dp[n][j]<=w)
	   mx=max(mx,j);
	}
	cout<<mx;
	
	return 0;
}

Measured memory_bytes: 79104
from collections import Counter as counter
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(li() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,s):
    res = 0
    for i in counter(s).values():
        if 1 < i :
            res += int(i*(i-1)/2)
    print(res)

n = ii()
s = list("".join(sorted(input())) for _ in range(n))
main(n,s)

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

#define ll long long 

void max_self(ll& a, ll b) {
    a = max(a, b);
}

int main() {
    int n,w;
    cin>>n>>w;
    vector<ll> dp(100005, INT_MAX);
    dp[0] = 0;
    for(int i = 0; i<n; i++){
		int weight, value;
		cin>>weight>>value;
		for(int j= dp.size() - value - 1; j >=0; j--){
				dp[j+value] = min(dp[j+value], dp[j] + weight);
			}
		}
	int ans=0;
	for(unsigned int i = 1; i<dp.size(); i++){
		if(dp[i] <= w)
			ans = i;
		}
	cout<<ans<<endl;
    
    
    }


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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long

int main(){
	string S1;
	string T;
	string kouho;
	string ans="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*";
	int S_len,T_len;
	bool flag;

	cin>>S1;
	cin>>T;
	S_len=S1.size();
	T_len=T.size();

	REP(i,S_len-T_len+1){
		//cerr<<i<<"\n";
		flag=true;
		REP(j,T_len){
			if(S1.at(i+j)!='?'){
				if(S1.at(i+j)!=T.at(j)){
					flag=false;
				}
			}
		}
		kouho=S1;
		kouho.replace(i,T_len,T);
		replace(kouho.begin(), kouho.end(), '?', 'a');
		if(flag){
			if(ans>kouho){
				ans=kouho;
			}
		}
	}
	if(ans=="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*"){
		cout<<"UNRESTORABLE\n";
	}else{
		cout<<ans<<"\n";
	}
	return 0;
}


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

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

int dp[114514];

int main(){
	int n;
	cin>>n;
	vector<int>h(n);
	for(int i=0;i<n;i++){
		cin>>h[i];
		dp[i]=1145141919;
	}
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=2;j++){
			if(i>=j){
				dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;	
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k;
  cin>>n>>k;
  int x[k],y[k];
  for(int i=0;i<k;i++) cin>>x[i]>>y[i];
  for(int i=0;i<k;i++){
    int tmp=min(x[i]-1,y[i]-1);
    tmp=min(tmp,min(n-x[i],n-y[i]));
    cout<<tmp%3+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
int cntodd[100005];
int cnteven[100005];
void add(int x,int k,int *s){
    x++;
    for(int i = x;i<100005;i+=i&-i){
        s[i]+=k;
    }
}
int query(int x,int *s){
    x++;
    int res=0;
    for(int i =x;i>0;i-=i&-i){
        res+=s[i];
    }
    return res;
}
int main(){
    int n;
    scanf("%d",&n);
    int a[3][100005];
    for(int i = 0;i<3;i++){
        for(int j=0;j<n;j++){
            scanf("%d",&a[i][j]);
        }
    }
    vector<pii> v;
    for(int i = 0;i<n;i++){
        int Min=min(a[0][i],min(a[1][i],a[2][i]));
        int x=(Min-1)/3;
        if((x-i)&1){
            printf("No\n");
            return 0;
        }
        if(Min==a[0][i]){
            if(a[1][i]==a[0][i]+1&&a[2][i]==a[1][i]+1){
                v.pb(mp(Min/3,0));
            }
            else{
                printf("No\n");
                return 0;
            }
        }
        else if(Min==a[2][i]){
            if(a[1][i]==a[0][i]-1&&a[2][i]==a[1][i]-1){
                v.pb(mp(Min/3,1));
            }
            else{
                printf("No\n");
                return 0;
            }
        }
        else{
            printf("No\n");
            return 0;
        }
    }
    reverse(v.begin(),v.end());
    LL co=0,ce=0;
    for(auto it:v){
        if(it.x&1){
            co+=query(it.x,cntodd);
            add(it.x,1,cntodd);
            ce^=it.y;
        }
        else{
            ce+=query(it.x,cnteven);
            add(it.x,1,cnteven);
            co^=it.y;
        }
    }
    if((co&1)||(ce&1)){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }

}
/*

b[i]*K!/(i)!*(K-i)!
*/

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
"""
D - Triangles
https://atcoder.jp/contests/abc143/tasks/abc143_d

"""
import sys

from itertools import combinations
from bisect import bisect_left, bisect_right

def solve(N, lines):
    ans = 0
    for c in range(N-1, -1, -1):
        for b in range(c-1, -1, -1):
            i = bisect_right(lines[:b], lines[c] - lines[b])
            ans += max(0, (b-i))
    return ans


def main(args):
    N = int(input())
    lines = map(int, input().split())
    ans = solve(N, sorted(lines))
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 51676
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x " = " << (x) << '\n';
#define P(x) cout << #x << '\n';    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;

const int maxn = 1e5 + 10;
int a[maxn], b[maxn], dp[maxn];
const int inf = 1e15;
const int till = 3e4;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	for(int i = 0; i < maxn; ++ i)
		dp[i] = inf;
	int h, n;
	cin >> h >> n;
	for(int i = 1; i <= n; ++ i)
		cin >> a[i] >> b[i];
	dp[0] = 0;
	for(int i = 0; i <= till; ++ i)
	{
		for(int j = 1; j <= n; ++ j)
		{
			if(i - a[j] >= 0)
				dp[i] = min(dp[i], dp[i - a[j]] + b[j]);
		}
	}
	
	int ans = inf;
	for(int i = h; i <= till; ++ i)
		ans = min(ans, dp[i]);
	
	cout << ans << '\n';
	
	return 0;
}






Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	double T, X;
	cin >> T >> X;
	
	printf("%.10f\n", T / X);
	
	return 0;
}


Measured memory_bytes: 256
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
print(alphabet[int(alphabet.index(input()) + 1)])

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

using namespace std;

int n;
int a[200100];
int val[200100];
unordered_set<int> same;
long long int ans;

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>a[i]; val[a[i]]++;
        if(val[a[i]]>1) same.insert(a[i]);
    }
    for(auto e:same) {
        long long int temp=1LL*val[e];
        ans+=temp*(temp-1)/2;
    }
    
    for(int i=0;i<n;i++) {
        if(val[a[i]]>1) {
            cout<<ans-1LL*(val[a[i]]-1)<<endl;
        }
        else cout<<ans<<endl;
    }
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

struct Melody{
    int low, high, point;
};

int dp[400];

signed main(){
    int N; cin >> N;
    vector<Melody> melody( N );
    REP( i, N ){
        cin >> melody[i].low >> melody[i].high >> melody[i].point;
    }

    REP( i, N ){
        REP( j, 400 ){
            FOR( k, melody[i].low, melody[i].high + 1 ){
                if( j >= k ){
                    dp[j] = max( dp[j], dp[j - k] + melody[i].point );
                }
            }
        }
    }

    int M; cin >> M;
    vector<int> ans;
    REP( i, M ){
        int w; cin >> w;
        if( !dp[w] ) {
            cout << -1 << endl;
            return 0;
        }
        ans.push_back( dp[w] );
    }

    for( auto v : ans ){
        cout << v << endl;
    }

}


Measured memory_bytes: 3160
N, K, Q = [int(v) for v in input().split(' ')]

count = [0] * N

for i in range(0, Q):
    v = int(input())
    count[v-1] += 1

for c in count:
    s = K - (Q - c)
    if s > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4680
N = int(input())
a = list(map(int, input().rstrip().split()))
even = [i for i in a if i%2 == 0]
count = 0
for i in even:
    c = 0
    for j in range(100):
        rem = i % 2
        i //= 2
        if rem == 1:
            break
        c += 1
    count += c
print(count)

Measured memory_bytes: 4148
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf = 1e18;

int N;
ll A,B, ans, cnt;
int main(){
    cin>>N;
    ll mn=inf;
    bool flag=true;
    REP(i,0,N){
        cin>>A>>B;
        cnt+=A;
        if(A>B)mn=min(mn,B);
        if(B!=A) {
            flag=false;
        }
    }
    if(!flag){
        ans=cnt-mn;
    }
    p(ans);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var res = 0;
            for (int i = 0; i < N; i += 2)
            {
                if (As[i] % 2 == 1)
                    res++;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 28308
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;

int main()
{
    char a[16];
    while(scanf("%s",a)==1)
    {
        int n=strlen(a);
        int i;
        int O=0,X=0;
        for(i=0;i<n;i++)
        {
            if(a[i]=='o')
                O++;
            else
                X++;
        }
        if(O>=X)
            cout<<"YES"<<endl;
        else if(X<=7)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}

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

#define MAX_N 2020

int main(){
  ll N;
  cin >> N;

  string tmp;
  set<string> ss;
  for(ll i=0; i<N; i++){
    cin >> tmp;
    ss.insert(tmp);
  }
  cout << ss.size() << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    int cnt = 0;
    long long sumM = 0;
    for (int i = 0; i < N; i++) {
        int B;
        cin >> B;
        A[i] -= B;
        if (A[i] < 0) {
            sumM += -A[i];
            cnt++;
        }
    }

    if (cnt == 0) {
        cout << 0 << endl;
        return 0;
    }

    sort(A.begin(), A.end(), greater<int>());

    long long sumP = 0;
    int ans = cnt;
    for (int i = 0; i < N - cnt; i++) {
        sumP += A[i];
        ans++;
        if (sumP >= sumM) break;
    }

    if (sumP >= sumM) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3708
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Good Integer
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  string s;
  cin >> s;

  if (s[1] == s[2] && (s[0] == s[1] || s[2] == s[3])) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int p(int i){
  return i * (i + 1) * (i + 2) / 6;
}

int main(void){
  int n = 1000000;
  /* ???????¨??????? */
  int ans1[n+1];
  int ans2[n+1];
  for(int i = 1 ; i < n + 1 ; i++){
    ans1[i+1] = -1;
    ans2[i+1] = -1;
  }

  for(int i = 1 ; p(i) < n + 1 ; i++){
    ans1[p(i)] = 1;
    if(p(i) % 2 == 1){ ans2[p(i)] = 1; }
  }

  for(int i = 2 ; i <= n ; i++){
    if(ans1[i] == 1){
    }else{
      int min = 10000;
      for(int j = 1 ; p(j) < i ; j++){
        if(min > 2 && ans1[i - p(j)] + 1 < min){
          min = ans1[i - p(j)] + 1;
        }
      }
      ans1[i] = min;
    }
  }

  for(int i = 2 ; i <= n ; i++){
    if(ans2[i] == 1){
    }else{
      int min = 10000;
      for(int j = 1 ; p(j) < i ; j++){
        if(min > 2 && p(j) % 2 == 1 && ans2[i - p(j)] + 1 < min){
          min = ans2[i - p(j)] + 1;
        }
      }
      ans2[i] = min;
    }
  }

  while(1){
    cin >> n;
    if(n == 0){return 0;}
    cout << ans1[n] << " " << ans2[n] << endl;
  }
}

Measured memory_bytes: 10768
#include <stdio.h>
 
int main(){
    int n,m,l;
    scanf("%d %d %d",&n,&m,&l);
    int A[n][m],B[m][l];
    long long int C[n][l];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            C[i][j] = 0;
        }
    }
 
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            scanf("%d",&B[i][j]);
        }
    }
 
    for(int i = 0; i < n; i++){
        for(int k = 0; k < l; k++){
            for(int j = 0; j < m; j++){
                C[i][k] += A[i][j]*B[j][k];
            }
        }
    }
 
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l-1; j++){
            printf("%lld ",C[i][j]);
        }
        printf("%lld\n",C[i][l-1]);
    }
}


Measured memory_bytes: 2108
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    string S;
    cin >> S;
    int N = S.size();

    bool isOk = true;
    rep(i, N / 2) {  // condition 1
        if (S.at(i) != S.at(N - 1 - i)) isOk = false;
    }

    int limit2 = (N - 1) / 2;
    for (int i = 0; i < limit2; i++) {  //condition 2
        if (S.at(i) != S.at(limit2 - 1 - i)) isOk = false;
    }

    int limit3 = (N + 3) / 2;
    int j = 0;
    for (int i = limit3 - 1; i < N; i++) {
        if (S.at(i) != S.at(N - 1 - j)) isOk = false;
        j++;
    }

    string ans = isOk ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define inf 1000000000000
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK";
            return;
        }
    }
    cout<<"NG";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3584
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#define INF 0x3f3f3f3f
#define NO 1005
#define MO 100005
typedef long long ll;
//by Oliver
using namespace std;
inline ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

ll n, m, g[NO][NO], ans, cnt[2];
const int go[4][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} };
bool book[NO][NO];
struct node
{
	ll now, i, j;
};
//variable

void init()
{
	memset(g, -1, sizeof(g));
	n = read(), m = read();
	for(int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
		{
			char a;
			cin >> a;
			g[i][j] = a == '#';
		}
}
//functions

int main()
{
	init();
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if (!book[i][j])
			{
				queue<node>q;
				q.push(node{g[i][j], i, j});
				cnt[0] = cnt[1] = 0;
				while (!q.empty())
				{
					node now = q.front();
					q.pop();
					if (!now.i || !now.j || now.i > n || now.j > m || book[now.i][now.j])
						continue;
					cnt[now.now]++;
					book[now.i][now.j] = true;
					for (int k = 0; k < 4; k++)
						if (g[now.i + go[k][0]][now.j + go[k][1]] != now.now)
							q.push(node{!now.now, now.i + go[k][0], now.j + go[k][1] });
				}
				//printf("now at (%d, %d), tot = %d * %d = %d\n", i, j, cnt[0], cnt[1], cnt[1] * cnt[0]);
				ans += (ll)cnt[1] * cnt[0];
			}
	cout << ans << endl;
	return 0;
}
//main


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

# define    ll            long long 
# define    vi             std::vector<ll>
# define    int            long long 
# define    setbits(x)     __builtin_popcountll(x)
# define    zrobits(x)     __builtin_ctzll(x)
# define    fast           ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
# define    pb             push_back
# define    fn             for(int i=0;i<n;i++)
# define    fo(i,a,b)      for(ll i=a;i<b;i++)
# define    all(x)         x.begin(), x.end()
# define    allr(a)        a.rbegin(), a.rend()
# define    PI             3.14159265358979323846
# define    mod            1000000007
# define    endl           "\n"
# define    pii            pair<ll,ll>
# define    deb1(x)        cout<<#x<<" "<<x<<endl;
# define    deb2(x,y)      cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
# define    deb3(x,y,z)    cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
 
void getio()
{
    fast
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}


void solve()
{
	ll n;
	cin>>n;
	if(n%1000==0) cout<<0<<endl;
		else
	cout<<1000-n%1000<<endl;
}



int32_t main()
{
	getio();
    // int t; cin>>t; while(t--)
    solve();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

bool comp(pair<ll,ll> p1,pair<ll,ll> p2){
    return p1.first<p2.first;
}

int main() {
    fastio
    
    ll N,W;
    cin>>N>>W;
    vector<pair<ll,ll>> w(N);
    for(ll i=0;i<N;i++){
        ll x,y;
        cin>>x>>y;
        w[i]={x,y};
    }
    sort(w.begin(),w.end(),comp);
    vector<vector<ll>> dp(N+1,vector<ll>(W+1));
    for(ll i=0;i<=N;i++){
        for(ll j=0;j<=W;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }else{
                auto p = w[i-1];
                if(j>=p.first){
                    dp[i][j]=max(dp[i-1][j],p.second+dp[i-1][j-p.first]);
                }else{
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
    }
    cout<<dp[N][W]<<"\n";
    return 0;
}

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  ll ans = 1;
  vector<ll> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  if(a[0]==0){
    cout << 0 << endl;
    return 0;
  }
  for(int i=0; i<n; i++){
    if(ans<=1000000000000000000/a[i]){
      ans *= a[i];
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4040
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int n;
  string s;
  cin>>n>>s;
  int i=0;
  int ans=1;
  while(i<n-1)
  {
    if(s[i]!=s[i+1])
    {
      ans++;
    }
    i++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	int N;cin>>N;
	int B[N+1];B[0]=INF;B[N]=INF;
	rep(i,1,N) cin>>B[i];
	int sum=0;
	rep(i,0,N){
		sum+=min(B[i],B[i+1]);
	}cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
signed main()
{
    speed
    int n,k;cin>>n>>k;
    vector<int> inp(n);
    map<int,vector<int>> mp;
    for(int i=0;i<n;++i){cin>>inp[i];mp[inp[i]].pb(i);}
    vector<bool> status(n+1,0);
    status[n]=1;
    map<int,int> next;
    next[-1]=-1;
    for(auto it:mp)
    {
        int len=(it.y).size();
        for(int i=0;i<len-1;++i)
        {
            next[(it.y)[i]]=(it.y)[i+1];
        }
        next[(it.y)[len-1]]=(it.y)[0];
        status[(it.y)[len-1]]=1;
    }
    int pres=-1;
    vector<int> fin;
    do
    {
        pres=(next[pres]+1);
        while(!status[pres])
        {
            pres=(next[pres]+1);
        }
        fin.pb(pres);
    }while(pres!=n);
    int dis=fin.size();
    int r=(k%dis);
    if(r==0){return 0;}
    r=inp[fin[r-1]];
    int six=mp[r].back();
    stack<int> st;
    map<int,bool> done;
    for(int i=six;i<n;++i)
    {
        if(!done[inp[i]])
        {
            st.push(inp[i]);
            done[inp[i]]=1;
        }
        else
        {
            while(st.top()!=inp[i])
            {
                done[st.top()]=0;
                st.pop();
            }
            done[inp[i]]=0;
            st.pop();
        }
    }
    vector<int> sol;
    while(!st.empty())
    {
        sol.pb(st.top());st.pop();
    }
    reverse(sol.begin(),sol.end());
    for(auto it:sol){cout<<it<<" ";}
}

Measured memory_bytes: 55024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
double n;
struct Cup{
	double cupp;
	int val;
	bool operator < (const Cup &rhs) const {
		return double(rhs.val)/rhs.cupp>double(val)/cupp;
	} 
}a[5];
ll ans=0;
int main() {
	a[1].cupp=0.25;a[2].cupp=0.5;a[3].cupp=1;a[4].cupp=2;
	scanf("%d%d%d%d%lf",&a[1].val,&a[2].val,&a[3].val,&a[4].val,&n);
	sort(a+1,a+1+4);
		for(int i=1;i<=4;i++){
			if(n>=a[i].cupp) {
				ll tmp=floor(n/a[i].cupp);
				ans+=ll(a[i].val)*tmp;
				n-=a[i].cupp*tmp;
			}
	}
	cout<<ans<<endl;
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 101;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m,sx,sy;

char st[maxn][maxn];

short line[maxn][maxn],row[maxn][maxn];

short dp[maxn][maxn][maxn][maxn];

void Work(){
	memset(dp,-1,sizeof(dp));dp[0][0][0][0]=0;
	REP(i,0,sx-1)
		REP(j,0,n-sx)
			REP(k,0,sy-1)
				REP(l,0,m-sy)if(dp[i][j][k][l]!=-1){
					int U=max(sx-i,j+1),D=min(sx+j,n-i),L=max(sy-k,l+1),R=min(sy+l,m-k);
					if(sx-i-1>=j+1)dp[i+1][j][k][l]=max((int)dp[i+1][j][k][l],dp[i][j][k][l]+line[sx-i-1][R]-line[sx-i-1][L-1]);
					if(sx+j+1<=n-i)dp[i][j+1][k][l]=max((int)dp[i][j+1][k][l],dp[i][j][k][l]+line[sx+j+1][R]-line[sx+j+1][L-1]);
					if(sy-k-1>=l+1)dp[i][j][k+1][l]=max((int)dp[i][j][k+1][l],dp[i][j][k][l]+row[D][sy-k-1]-row[U-1][sy-k-1]);
					if(sy+l+1<=m-k)dp[i][j][k][l+1]=max((int)dp[i][j][k][l+1],dp[i][j][k][l]+row[D][sy+l+1]-row[U-1][sy+l+1]);
				}
	int ans=0;
	REP(i,0,n)REP(j,0,n)REP(k,0,m)REP(l,0,m)ans=max(ans,(int)dp[i][j][k][l]);
	iout(ans);
}

void Init(){
	read(n,m);
	REP(i,1,n)scanf("%s",st[i]+1);
	REP(i,1,n)REP(j,1,m){
		if(st[i][j]=='E')sx=i,sy=j;
		line[i][j]=line[i][j-1]+(st[i][j]=='o');
		row[i][j]=row[i-1][j]+(st[i][j]=='o');
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 203520
def main():
    N = input()
    nlen = len(N)
    if int(N[nlen-1]) == 2 or int(N[nlen-1]) == 4 or int(N[nlen-1]) == 5 or int(N[nlen-1]) == 7 or int(N[nlen-1]) == 9:
        print("hon")
    elif int(N[nlen-1]) == 0 or int(N[nlen-1]) == 1 or int(N[nlen-1]) == 6 or int(N[nlen-1]) == 8:
        print("pon")
    elif int(N[nlen-1]) == 3:
        print("bon")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9240
def main():
    N = int(input())
    L, R = [0] * N, [0] * N
    for i in range(N):
        L[i], R[i] = map(int, input().split())

    max_l = max(L)
    min_r = min(R)

    ab = [(max(0, r - max_l + 1), -max(0, min_r - l + 1)) for l, r in zip(L, R)]
    ab.sort()

    mi = float("inf")
    ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, min_r - max_l + 1)
    for i in range(N - 1):
        mi = min(mi, -ab[i][1])
        ma = max(ma, mi + ab[i + 1][0])

    print(ma)

main()


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

using namespace std;

int main() {
  string abcd;
  cin >> abcd;

  vector<string> pattern {
      "+++",
      "++-",
      "+-+",
      "+--",
      "-++",
      "-+-",
      "--+",
      "---" };

  for (auto p : pattern) {
    int ans = abcd[0] - '0';
	for (int i = 0 ; i < 3; i++) {
	  if (p[i] == '+') {
	    ans += (abcd[i+1] - '0');
	  } else if (p[i] == '-') {
	    ans -= (abcd[i+1] - '0');
      }
	}
	if (ans == 7) {
	  cout << abcd[0] << p[0] << abcd[1] << p[1] << abcd[2] << p[2] << abcd[3]
	      << "=7" << endl;
	  break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;
const int inf = 1e17+21;



int32_t main(){
    FAST;

    int n;  cin >> n;
    int ans = 0;
    int val[n] , cost[n];
    for(int x=0;x<n;x++)    cin>> val[x];
    for(int x=0;x<n;x++) {
        cin >> cost[x];
        ans += max(0LL , val[x] - cost[x]);
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

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;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / (b))
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))
//#define int long long int //dont forget to change int to signed

int main() {
	int N;
	scanf("%d", &N);
	if (N%2)N*=2;
	printf("%d\n", N);
}


Measured memory_bytes: 256
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main(args: Array<String>) {
    val n = readInt()
    val a = readIntList()

    val result = Array(n) { 0 }
    for (i in a.indices) {
        result[a[i] - 1] += 1
    }

    println(result.joinToString(separator = "\n"))
}


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

int main()
{
	int n;
	cin>>n;
	vector<int>a(n),b(n),c(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		c[i] = a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}

	sort(c.begin(),c.end());

	int apos,bpos,cnt = 0;

	do{
		if(a == c) apos = cnt;
		if(b == c) bpos = cnt;
		cnt++;
	}while(next_permutation(c.begin(), c.end()));

	cout<<abs(apos-bpos)<<endl;	
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d:\n",ca)
int ca=1;
using namespace std;
int main(){

   //  #ifndef HEY_LETS_CODE
   // freopen("Input.txt", "r", stdin);
   // freopen("Output.txt", "w", stdout);
   // #endif
   fast;
   int a;
   cin>>a;
   set<int>s;
   for(int i = 0;i<a;i++){
    int x;
    cin>>x;
    s.insert(x);
   }
   if(s.size()==a){
    cout<<"YES"<<nl;
   }else{

       cout<<"NO"<<nl;
   }

}



Measured memory_bytes: 12956
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
//vector.assign (n,value)... for global vectors
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll h,w;
    cin>>h>>w;
    if (h==1||w==1)
    {
        cout<<"1\n";
        return 0;   
    }
    ll ans=(h*w)/2;
    if ((h*w)%2!=0)
    {
        ans++;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
import sys 
input = sys.stdin.readline
MOD = 10**9 +7
INF = 10**9

def main():
    n = int(input())
    a = list(map(int,input().split()))
    
    dp = [[0] * (n + 2)  for _ in range(n + 2)]
    
    for l in range(1,n + 1):
        for i in range(n - l + 1):
            j = i + l
            if (n - l)%2 == 0:
                dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1])
            else:
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1])
    
    print(dp[0][n])

if __name__=='__main__':
    main()

Measured memory_bytes: 112348
n = gets.to_i
result = nil
3500.times do |i|
  h  = i+1
  3500.times do |j|
    w = j+1
    p = w*h
    s = w+h
    bunshi = n * p
    bunbo = 4 * p - n * s
    if bunshi >= bunbo && bunbo > 0 && bunshi % bunbo == 0
      result = [h, w, bunshi/bunbo]
    end
    break unless result.nil?
  end
  break unless result.nil?
end
puts result.join(" ")


Measured memory_bytes: 1916
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int M, N;
int p[100][100];
bool used[100][100] = {};
int ans;

int dx[4] = {0, 1, 0, -1};
int dy[4] = { 1, 0, -1, 0 };

void solve(int x, int y, int s) {
	ans = max(ans, s);
	used[x][y] = true;

	for (int i = 0; i < 4; i++) {
		int ax = x + dx[i];
		int ay = y + dy[i];

		if (0 <= ax && ax < N && 0 <= ay && ay < M && used[ax][ay] == false && p[ax][ay] == 1) {
			solve(ax, ay, s + 1);
		}
	}

	used[x][y] = false;
}

int main() {
	while (cin >> M >> N, M)
	{
		ans = 0;

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				cin >> p[i][j];
			}
		}

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				if (p[i][j] == 1) {
					solve(i, j, 1);
				}
			}
		}

		cout << ans << endl;

	}


	return 0;
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */

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

	LL N; cin >> N;
	vector<vector<LL>> a(N, vector<LL>(10));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> a[i][j];
		}
	}
	vector<vector<LL>> P(N, vector<LL>(11));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 11; ++j) {
			cin >> P[i][j];
		}
	}



	LL ans = -LINF;
	FOR(state, 1, 1 << 10) {
		LL ret = 0;
		FOR(i, 0, N) {
			LL cnt = 0;
			FOR(j, 0, 10) {
				if ((state & 1 << j) && (a[i][j])) {
					cnt++;
				}
			}
			ret += P[i][cnt];
		}

		ans = max(ans, ret);
	}


	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

class B {
	int N;
public:
	void solve()
	{

		if (!(N & 0b11))
		{
			cout << "Yes" << endl;
			return;
		}

		while (N >= 7)
		{
			N -= 7;
			if (!(N & 0b11))
			{
				cout << "Yes" << endl;
				return;
			}
		}
		
		cout << "No" << endl;
	}

	B() { cin >> N; }
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define MOD 1000000007
int main()
{
  int h,w;
  ll dp[1005][1005];
  char mas[1005][1005];

  for(int i=0; i<1001; i++){
    for(int j=0; j<1001; j++){
      dp[i][j] = 0;
    }
  }
  
  cin >> h >> w;
  
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      cin >> mas[i][j] ;
    }
  }
  
  dp[1][1] = 1;
  
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(mas[i][j] != '#'){
	dp[i][j] += (dp[i-1][j] % MOD) + (dp[i][j-1] % MOD);
      }
    }
  }
  
  cout << dp[h][w] % MOD << endl;
  
  return 0;
}


Measured memory_bytes: 9088
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

int dist(int[] a, int[] b) {
    int d;
    foreach (i,j ; zip(a,b)) d += (i-j) * (i-j);
    return d;
}

bool can(int x) {
    for (int i=1;i*i<=x;i++)
        if (i * i == x) return true;
    return false;
}

void main() {
    int n, d; scan(n,d);
    auto xs = new int[][](n);
    foreach (i; 0..n)
        xs[i] = reads();

    int ans;
    foreach (i; 0..n) foreach (j; i+1..n) {
        if (can(dist(xs[i], xs[j]))) ans++;
    }
    writeln(ans);
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
ll f(ll n){
    if(n<0)return 0;
    switch(n%4){
        case 0:return n;
        case 1:return 1;
        case 2:return n+1;
        case 3:return 0;
    }
}
int main(void){
    ll a,b;cin>>a>>b;
    cout<<(f(a-1)^f(b))<<"\n";
}

Measured memory_bytes: 256