akhauriyash/Code-Regression huggingface dataset:
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_c
 
import sys
# sys.setrecursionlimit(100000)
 
 
def input():
    return sys.stdin.readline().strip()
 
 
def input_int():
    return int(input())
 
 
def input_int_list():
    return [int(i) for i in input().split()]
 
 
def main():
    n = int(input())
    A = []
    B = []
    for _ in range(n):
        a, b = input_int_list()
        A.append(a)
        B.append(b)
 
    cnt = 0
    for a, b in zip(A[::-1], B[::-1]):
        tmp = (a + cnt) % b
        if tmp != 0:
            cnt += b - tmp
    print(cnt)
 
 
if __name__ == "__main__":
    main()

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

#define ll long long
#define pi pair<int,int>
#define ppi pair<pi,pi>
#define mp make_pair
#define fr first
#define sc second

using namespace std;

const int nax = 4e5 + 100;
int dp1[nax];
int dp2[nax];
string s;
int c , n , k;
int solve1(int i){
    if(i > n)return 0;
    int &ret = dp1[i];
    if(ret + 1)return ret;
    ret = 0;
    if(s[i] == 'o')
        ret = max(ret,solve1(i + 1)),
        ret = max(ret , solve1(i + c + 1) + 1);
    else
        ret = max(ret , solve1(i + 1));
    return ret;
}
int solve2(int i){
    if(i < 1)return 0;
    int &ret = dp2[i];
    if(ret + 1)return ret;
    ret = 0;
    if(s[i] == 'o')
        ret = max(ret,solve2(i - 1)),
        ret = max(ret , solve2(i - c - 1) + 1);
    else
        ret = max(ret , solve2(i - 1));
    return ret;
}
int pre[nax];
int main(){
//    ios::sync_with_stdio(0);
//    cin.tie(0) , cout.tie(0);
    memset(dp1, -1, sizeof dp1);
    memset(dp2, -1, sizeof dp2);
    cin >> n >> k >> c;
    cin >> s;
    s = "#" + s;
    if(!c){
        int cnt=0;for(int i=1;i<=n;i++)cnt+=s[i]=='o';
        if(cnt == k){
            for(int i=1;i<=n;i++)if(s[i] == 'o')
                cout << i << '\n';
        }
        return 0;
    }
    for(int i = 1 - c + 1;i <= n ;i++){
        if(solve2(i - 1) + solve1(i +  c) < k){
            //cout << i << ' ' << solve1(i - 1) << ' ' << solve2(i + c) << '\n';
            pre[max(1 , i)]++;
            pre[i + c]--;
        }
    }
    for(int i = 1;i <= n;i++){
        pre[i] += pre[i - 1];
        if(s[i] == 'o' && pre[i] >= c && pre[i])
            cout << i << '\n';
    }

    return 0;
}


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

int main() {
int A,B,C;
  cin >>A>>B>>C;
  if(A==max({A,B,C})){
    cout<<10*A+B+C;
  }
  else if(B==max({A,B,C})){
    cout <<10*B+A+C;
  }
  else if(C==max({A,B,C})){
    cout <<10*C+A+B;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
pair<int,int> arr[100005],pre[100005],suf[100005];
pair<int,int> isect(pair<int,int> a,pair<int,int> b)
{
	return {max(a.first,b.first),min(a.second,b.second)};
}
int main()
{
	int n,ans=0;
	scanf("%d",&n);
	pre[0]={1,1e9};
	suf[n+1]={1,1e9};
	for (int i=1;i<=n;i++)
	scanf("%d%d",&arr[i].first,&arr[i].second);
	sort(arr+1,arr+n+1);
	for (int i=1;i<=n;i++)
	pre[i]=isect(pre[i-1],arr[i]);
	vector<pair<int,int> > v;
	for (int i=n;i>0;i--)
	{
		if (v.empty() || arr[i].second<v.back().second)
		v.push_back(arr[i]);
		suf[i]=isect(suf[i+1],arr[i]);
	}
	reverse(v.begin(),v.end());
	for (int i=0;i<v.size()-1;i++)
	ans=max(ans,max(v[0].second-v[i].first+1,0)+max(v[i+1].second-v.back().first+1,0));
	for (int i=1;i<=n;i++)
	{
		auto tmp=isect(pre[i-1],suf[i+1]);
		ans=max(ans,max(tmp.second-tmp.first+1,0)+arr[i].second-arr[i].first+1);
	}
	printf("%d",ans);
}

Measured memory_bytes: 3448
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

int main() {
    

    string s,t;
    int k;
    cin >> s >> k;
    t = s;
    sort(t.begin(),t.end());
    set <string> ans;
    int p = 0;
    while (ans.size() < k) {
        char alp1 = t[p];
        for (int i = 0; i < s.length(); i++) {
            if (s[i] == alp1) {
                int j = 1;
                while (i + j <= s.length() and j <= 5) {
                    ans.insert(s.substr(i, j));
                    j++;
                }
            }
        }
        p++;
    }
    vector <string> ansv;
    set <string>::iterator q;
    for (q = ans.begin();q!=ans.end();q++){
        ansv.push_back(*q);
    }

    sort(ansv.begin(),ansv.end());
    vector <string>::iterator vit;
    vit = ansv.begin();
    cout << ansv[k-1] << endl;

}

Measured memory_bytes: 384
using System;
using System.Linq;

namespace _0025
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				string s1 = Console.ReadLine();
				if (string.IsNullOrEmpty(s1)) break;
				int[] x = s1.Trim().Split().Select(int.Parse).ToArray();
				string s2 = Console.ReadLine();
				if (string.IsNullOrEmpty(s2)) break;
				int[] y = s2.Trim().Split().Select(int.Parse).ToArray();
				int hit = 0; int blow = 0;
				for (int i = 0; i < 4; i++)
				{
					for (int j = 0; j < 4; j++)
					{
						if (x[i] == y[j])
						{
							if (i == j) hit++;
							else blow++;
						}
					}
				}
				Console.WriteLine(hit + " " + blow);
			}
		}
	}
}


Measured memory_bytes: 8308
S=input()
T=input()
le=len(S)
s=[]
t=[]
sr=[]
for i in range(le):
  s.append(S[i])
  t.append(T[i])
  sr.append(S[i])

def rotate():
  for j in range(le):

    for i in range(le):
      sr[i]=s[(i+j)%le]
    if sr==t :
      return("Yes")
  return("No")

print(rotate())


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M * 2);
  for (int i = 0; i < M * 2; i++) cin >> a[i];

  for (int i = 1; i <= N; i++) {
    int ans = 0;
    for (int j = 0; j < M * 2; j++) {
      if (a[j] == i) ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n, m, s = 0; cin >> n >> m;
  v1i h(n); rep(i, n) cin >> h[i];
  v2i v(n);
  rep(i, m){
    int a, b; cin >> a >> b; --a; --b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  rep(i, n){
    bool d = 1;
    for(int c: v[i]){
      if(h[c] >= h[i]){
        d = 0;
        break;
      }
    }
    if(d) ++s;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 8800
#include <stdio.h>
#include <math.h>
int main(void)
{
	double x1, y1, x2, y2, x, y, s, d;
	scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
    x = x1-x2;
    y = y1-y2;
	s = x*x + y*y;
	d = sqrt(s);
	printf("%f\n", d);
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll dy[4] = {1, 0, -1, 0};
const ll dx[4] = {0, 1, 0, -1};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int sum = 0;
	rep(i, m) {
		int a;
		cin >> a;
		sum += a;
	}
	if (sum <= n)
		cout << n - sum << endl;
	else
		cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3652
//AOJ ALDS1_12_B dijkstra法 2018/9/20

#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;  //firstは最短距離,secondは頂点番号

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

struct edge{
	int to,cost;
	edge(){to=0;cost=0;}
};

class dijkstra{
public:
	vector<vector<edge> > E;
	vector<int> dist;
	int start;
	dijkstra(int n): E(n),dist(n){}

	void add_edge(int x,int y,int c){
		edge e;
		e.to = y,e.cost = c;
		E[x].push_back(e);
	}

	void shortest_path(){
		priority_queue<P,vector<P>,greater<P> > que;
		dist.assign(dist.size(),INF);

		dist[start] = 0;
		que.push(P(0,start));

		while(!que.empty()){
			 P p = que.top();
			 que.pop();
			 int v = p.second;
			 if(dist[v] < p.first) continue;

			 for(int i = 0; i < E[v].size(); i++){
			 	edge e = E[v][i];
			 	if(dist[v] +  e.cost < dist[e.to]){
			 		dist[e.to] = dist[v] +  e.cost;
			 		que.push(P(dist[e.to],e.to));
			 	}
			 }
		}
	}


};

int main()
{
	int n;
	cin >> n;
	dijkstra dij(n);
	for(int i = 0; i < n; i++){
		int u,k;
		cin >> u >> k;
		for(int j = 0; j < k; j++){
			int v,c;
			cin >> v >> c;
			dij.add_edge(u,v,c);
		}
	}

	dij.start = 0;
	dij.shortest_path();

	for(int i = 0; i < n; i++){
		cout << i << " " <<  dij.dist[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 7856
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#include<fstream>

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

using namespace std;

const int MOD = 1000000007;

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

    fstream text;
    text.open("text.txt", ios::out);

    ll H, W, K;
    cin >> H >> W >> K;

    vector<ll> to(W);
    Rep (i, W) to[i] = i;
    vector<vector<ll>> single(W, vector<ll>(W, 0));
    Rep (i, 1<<(W-1)) {
        text << "i=" << i << "\n";
        bool ok = true;
        Rep (j, W-2) {
            ll mask = 0;
            mask |= (1<<j);
            mask |= (1<<(j+1));
            if ((i & mask) == mask) {
                ok = false;
                text << "neighbor error" << "\n";
            }
        }
        if (!ok) continue;

        vector<ll> to(W);
        Rep (j, W) to[j] = j;

        Rep (j, W-1) {
            if (i & (1<<j)) {
                swap(to[j], to[j+1]);
            }
        }        
        Rep (j, W) {
            text << to[j] << " ";
        }
        text << "\n";

        Rep (j, W) {
            single[to[j]][j]++;
        }
    }

    Rep (i, W) {
        Rep (j, W) {
            text << single[i][j] << " ";
        }
        text << "\n";
    }

    text << "\ndp\n";

    vector<vector<ll>> dp(H+1, vector<ll>(W, 0));
    dp[0][0] = 1;
    Rep (i, H) {
        Rep (j, W) {
            Rep (k, W) {
                dp[i+1][j] += dp[i][k] * single[k][j] % MOD;
                dp[i+1][j] %= MOD;
            }
        }
    }

    Rep (i, H+1) {
        Rep (j, W) {
            text << dp[i][j] << " ";
        }
        text << "\n";
    }

    cout << dp[H][K-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	scanf("%d",&N);

	const string pattern = "E869120";

	int ans = 0;
	string tmp;

	for(int loop = 0; loop < N; loop++){

		cin >> tmp;

		if(tmp == pattern){

			ans += 1;
		}
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
vector<vector<double> >dp(610,vector<double>(2,-1.0));
vector<vector<ll> >G(610);
signed main(){
    ll n,m;cin>>n>>m;
    vector<ll>dim(n);
    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        dim[b]++;
    }/* 
    vector<ll>idx(n);
    //トポソ
    queue<ll>q;
    rep(i,n){
        if(dim[i]==0)q.push(i);
    }
    ll now=0;
    while(!q.empty()){
        ll k=q.front();
        q.pop();
        idx[now]=k;
        now++;
        for(auto e:G[k]){
            dim[e]--;
            if(dim[e]==0)q.push(e);
        }
    }
    rep(i,n){
        cout<<idx[i]<<endl;
    }*/
    //DP
    vector<vector<double> >dp(n,vector<double>(2,-1.0));
    dp[n-1][0]=0.0;
    dp[n-1][1]=-1.0;
    for(int i=n-2;i>=0;i--){
        ll from=i;
        double sum=0.0;
        ll cnt=G[from].size();
        for(auto to:G[from]){
            sum+=(dp[to][0]+1.0);
        }
        dp[from][0]=sum/(cnt*1.0);
    }
    ll x=-1;
    rep(i,n){
        if(G[i].size()>1){
            x=i;
            break;
        }
    }
    double ans=dp[0][0];
    if(x!=-1){
        rep(j,n-1){
            if(G[j].size()==1)continue;
            rep(k,n){
                dp[k][1]=-1.0;
            }
            for(int i=j;i>=0;i--){
                ll from=i;
                double sum=0.0;
                double ma=0.0;
                ll cnt=G[from].size();
                for(auto to:G[from]){
                    if(dp[to][1]>=0)sum+=dp[to][1]+1.0;
                    else sum+=(dp[to][0]+1.0);
                    ma=max(ma,dp[to][0]+1.0);
                }
                //cout<<sum<<' '<<ma<<endl;
                if(i==j){
                    dp[from][1]=(sum-ma)/((cnt-1.0)*1.0);
                }else{
                    dp[from][1]=sum/(cnt*1.0);
                }
                //cout<<i<<' '<<dp[i][0]<<' '<<dp[i][1]<<endl;
            }
            ans=min(ans,dp[0][1]);
        }
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

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

int main() {
  int s;
  cin >> s;
  int s1 = s / 100, s2 = (s - s1 * 100) / 10, s3 = s - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;
 
#define REP(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define RREP(i, a, n) for(ll i = n-1; i >= (ll)(a); i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007
#define _SPLIT " "
 
template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T,class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << setprecision(24) << a << endl;}
template<class T,class ...Args> void write(T a, Args... args){cout << setprecision(24) << a << _SPLIT; write(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    Hash<int,int> h;
    rep(i,3){
        h[read<int>()]++;
    }
    write(h.size());
    return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Data.Tuple
import Data.Char
import Data.IORef

inter it a b
    | a == 1 = VUM.write it b True
    | b == 1 = VUM.write it a True
    | otherwise = return ()

dest it ds a b n
    | a == n = VUM.write ds b True
    | b == n = VUM.write ds a True
    | otherwise = return ()

main = do
    [n, m] <- Prelude.map read . Prelude.words <$> Prelude.getLine :: IO [Int]
    it <- VUM.replicate (n+1) False
    ds <- VUM.replicate (n+1) False
    res <- newIORef False
    forM_ [1..m] $ \_ -> do
        bs <- B.getLine
        let Just (a, bs') = B.readInt bs
            Just (b, _) = B.readInt $ B.dropWhile isSpace bs'
        inter it a b
        dest it ds a b n
    forM_ [1..n] $ \i -> do
        r <- VUM.read it i
        when r $ do
            r' <- VUM.read ds i 
            when r' $ modifyIORef' res (||True)
    
    readIORef res >>= \r -> putStrLn $ if r then "POSSIBLE" else "IMPOSSIBLE"

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  vector<pair<int, int>> B(0);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  B.push_back(make_pair(1, A.at(0)));
  for(int i = 1; i < N ; i++){
    if(A.at(i) == A.at(i-1)){
      for(int j = 0; j < B.size(); j++){
        if(B.at(j).second == A.at(i)) B.at(j).first++;
      }
    }
    else{
      B.push_back(make_pair(1, A.at(i)));
    }
  }
  sort(B.begin(), B.end());
  if(K >= B.size()) cout << 0 << endl;
  else{
    int counter = 0;
    int n = B.size() - K;
    for(int i = 0; i < n; i++){
      counter += B.at(i).first;
    }
    cout << counter << endl;
  }
}

Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510;
const int MOD = 1000000007;

int d[MAX][MAX];
int V;
int a[MAX][MAX];

void warshall_floyd() {
    for(int k = 0; k < V; k++) {
        for(int i = 0; i < V; i++) {
            for(int j = 0; j < V; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main(){
  V = 10;
  ll H,W;cin>>H>>W;

  rep(i,10){
    rep(j,10){
      cin>>d[i][j];
    }
  }

  rep(i,H){
    rep(j,W){
      cin>>a[i][j];
    }
  }

  warshall_floyd();

  int ans=0;
  rep(i,H){
    rep(j,W){
      if(a[i][j] == -1) continue;
      else{
        ans += d[a[i][j]][1];
      }
    }
  }
  cout<<ans<<endl;
}


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

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



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


int get(int x){
    int v = (x*x*x*x*x);
    return v;
}

void solve(){
    int x; cin>>x;
    for(int b=-2000; b<=2000; b++){
        for(int a=-2000; a<=2000; a++){
            if(get(a)-get(b)==x){
                cout<<a<<" "<<b;
                return;
            }
        }
    }
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}





Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(void){
    int A,B;
    cin >> A >> B;
    int need;
    if(B==1){
        need = 0;
    }else{
        need = 1;
        while(need*(A-1)+1<B){
            need += 1;
        }
    }
    cout << need << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
/*
    time : 6:26:43 PM
    date : 3/12/2020
*/    
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5;  
const double pie = 3.14159265358979323846 ;
double dist(double Ax,double X,double Ay, double Y){
  double best = (Ax-Ay)*(Ax-Ay) + (X-Y)*(X-Y) ;
  best = sqrt(best) ;
  return best ;
} 
int tests(){
  int n ;  
  cin >> n ; 
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
  cout << a[n-1] ;     
  return 0 ;
}
int main(){
    I__O ;  
    int cases = 1 ; 
    // cin >> cases ; 
    while(cases--)
      tests(); 
    return 0 ; 
}

Measured memory_bytes: 256
times = int(input())
values = [int(input()) for _ in range(times)]
min_v = values[0]
max_v = values[1] - values[0]
for j in range(1, times):
    if values[j] - min_v > max_v: max_v = values[j] - min_v
    if min_v > values[j]: min_v = values[j]
print(max_v)


Measured memory_bytes: 13600
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long   
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;    
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    ld a,b;
    cin>>a>>b;
    cout<<(int)(a*b);


    printclock;
    return 0;
}


Measured memory_bytes: 3804
R, C, K = map(int, input().split())
rcv = [list(map(int, input().split())) for _ in range(K)]

board = [[0] * (C + 1) for _ in range(R + 1)]
for r, c, v in rcv:
    board[r][c] = v

dp = [[[0] * (C + 1) for _ in range(R + 1)] for _ in range(4)]

for r in range(1, R + 1):
    for c in range(1, C + 1):
        v = board[r][c]
        for i in range(4):
            dp[0][r][c] = max(dp[0][r][c], dp[i][r-1][c])
            dp[1][r][c] = max(dp[1][r][c], dp[i][r-1][c] + v)

            dp[i][r][c] = max(dp[i][r][c], dp[i][r][c-1])
            if i > 0:
                dp[i][r][c] = max(dp[i][r][c], dp[i-1][r][c-1] + v)

ans = 0
for i in range(4):
    ans = max(ans, dp[i][R][C])

print(ans)


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

#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define all(v) (v.begin(),v.end())
#define ll long long

const int N=105;
const int inf=2e9;


int main(){
    ios::sync_with_stdio(0);
    //freopen("in.txt","r",stdin);
    int a,b,c,ans=0;
    cin>>a>>b>>c;
    if(a<b) swap(a,b);
    if(a<c) swap(a,c);
    if(b<c) swap(b,c);
    if((a-b)%2){
        ++b;
        ++c;
        ++ans;
        ans+=(a-b)/2;
        b=a;
        ans+=(a-c)/2;
        if((a-c)%2){
            ans+=2;
        }
    }
    else{
        ans+=(a-b)/2;
        b=a;
        ans+=(a-c)/2;
        if((a-c)%2){
            ans+=2;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
A,B,C,D,E,F=map(int,input().split())
#100*A*i + 200*B*j == x
#C*i + D*j == y
xs = []
ys = []
def dens(x,y):
    if x+y==0:
        return(-1)
    else:
        return(y/(x+y))
for i in range(31):
    for j in range(16):
        if 100*A*i + 200*B*j <= F:
            xs.append(100*A*i + 200*B*j)
for i in range(3001):
    for j in range(1501):
        if C*i + D*j <= F:
            ys.append(C*i + D*j)
density = 0
water = 100*A
sugar = 0
for x in xs:
    for y in ys:
        if x+y > F or 100*y > E*x:
            continue
        nd = dens(x,y)
        if nd > density:
            density = nd
            sugar = y
            water = x
print(str(water+sugar) + " " + str(sugar))

Measured memory_bytes: 12456
N = int(input())
brick_nums = list(map(int , input().split()))

X = 1
broken = 0

if  1 not in brick_nums:
    print(-1)

else:
    for i in range(N):
        if X == brick_nums[i]:
            X += 1
        else:
            broken += 1
        
    print(broken)

Measured memory_bytes: 26268
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int line = Integer.parseInt(sc.nextLine());
		long[] numline = Stream.of(sc.nextLine().split(" ", 0)).mapToLong(Long::parseLong).toArray();
		int ans = 0;
		for (int i = 0; i < line; i++) {
			while (true) {
				if (numline[i] % 2L == 0) {
					numline[i] = numline[i] / 2L;
					ans++;
				} else {
					break;
				}
			}
		}
		sc.close();
		System.out.println(ans);
	}


}

Measured memory_bytes: 29236
import sys

inf = sys.maxsize
N, K = map(int, input().split())
heights = list(map(int, input().split()))

dp = [inf]*N
dp[0] = 0


def chmin(a, b, diff):
    if dp[a] > dp[b] + diff:
        dp[a] = dp[b] + diff
    return


for i in range(N):
    for j in range(1, K+1):
        if i-j >= 0:
            chmin(i, i-j, abs(heights[i]-heights[i-j]))

print(dp[N-1])

Measured memory_bytes: 52592
#include <iostream>
#include <cstring>
#include <cctype>

using namespace std;

int dist(int a, int b) {
	int d = b-a;
	if (d >= 26)
		return d-26;
	if (d < 0)
		return d+26;
	return d;
}

int main() {
	char s[81];
	while (cin.getline(s, 81)) {
		int len = strlen(s);
		int shift;
		for (int i = 0; i <= len-4; i++) {
			if (dist(s[i],s[i+1]) != dist('t','h'))
				continue;
			if (
					(dist(s[i+1], s[i+2]) == dist('h','a') && dist(s[i+2],s[i+3]) == dist('a','t')) ||
					(dist(s[i+1], s[i+2]) == dist('h','i') && dist(s[i+2],s[i+3]) == dist('i','s')) ||
					dist(s[i+1], s[i+2]) == dist('h','e'))
				shift = dist(s[i],'t');
		}
		if (
				dist(s[len-3],s[len-2]) == dist('t','h') &&
				dist(s[len-2],s[len-1]) == dist('h','e'))
			shift = dist(s[len-3], 't');
		for (int i = 0; i < len; i++) {
			if (isalpha(s[i]))
				s[i] = (s[i]-'a'+shift)%26+'a';
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <cmath>

const double EPSILON = 1e-10;

inline bool equals(double a, double b) {
    return std::fabs(a - b) < EPSILON;
}

struct Point {
    double x;
    double y;

    bool operator < (const Point& p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point& p) const {
        return equals(x, p.x) && equals(y, p.y);
    }
};

Point operator + (const Point& p1, const Point& p2) {
    return Point{p1.x + p2.x, p1.y + p2.y};
}

Point operator - (const Point& p1, const Point& p2) {
    return Point{p1.x - p2.x, p1.y - p2.y};
}

Point operator * (const Point& p1, double k) {
    return Point{p1.x * k, p1.y * k};
}

struct Segment {
    Point p1, p2;
};

struct Circle {
    Point center;
    double radius;
};

using Vector = Point;
using Line = Segment;
using Polygon = std::vector<Point>;


double norm(const Vector& p) {
    return p.x * p.x + p.y + p.y;
}

double abs(const Vector& p) {
    return std::sqrt(norm(p));
}

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}


Vector projection(const Segment& s, const Point& p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

Vector reflection(const Segment& s, const Point& p) {
    auto proj = projection(s, p);
    return p + (projection(s, p) - p) * 2.0;
}

bool is_orthogonal(const Vector& a, const Vector& b) {
    return equals(dot(a, b), 0.0);
}

bool is_orthogonal(const Segment& s1, const Segment& s2) {
    return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool is_parallel(const Vector& a, const Vector& b) {
    return equals(cross(a, b), 0.0);
}

bool is_parallel(const Segment& s1, const Segment& s2) {
    return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}


#include <iostream>
#include <iomanip>
#include <array>

using namespace std;

int main() {
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        array<Point, 4> points;
        for (auto& p : points) {
            cin >> p.x >> p.y;
        }
        Segment s1{points[0], points[1]};
        Segment s2{points[2], points[3]};
        if (is_orthogonal(s1, s2)) {
            cout << 1;
        } else if (is_parallel(s1, s2)) {
            cout << 2;
        } else {
            cout << 0;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3220
def main():
    NM = input()
    N = int(NM.split(" ")[0])
    M = int(NM.split(" ")[1])
    strA = input()
    listA = strA.split(" ")

    X = 0
    for i in range(0, M):
        X += int(listA[i])

    Y = N - X
    if(Y < 0):
        Y = -1
    print(Y)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  int n; 
  cin >> n; 
  vector<int> a(n); 
  rep(i,n){
    cin >> a[i];
  }
  int count; 
  int max = INF; 
  rep(i,n){
    if(max>a[i]){
      count++; 
      max=a[i]; 
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
void func(int);
int cnt[10],flg,ka[9],p,pp;
int main(void)
{
	int i,j,k;
	char a[14];
	while(scanf("%s",a)!=EOF)	{
		for(i=1;i<=9;i++)	cnt[i]=0;
		for(i=0;i<13;i++)	cnt[a[i]-'0']++;
		p=0;
		for(i=1;i<=9;i++)	{
//			printf("i=%d\n",i);
			if(cnt[i]<4)	{
				cnt[i]++;
				flg=0;
				func(14);
				if(flg==1)	{
					ka[p]=i;
					p++;
				}
				cnt[i]--;
			}
		}
		if(p==0)	{
			printf("0\n");
		}
		else {
			printf("%d",ka[0]);
			for(i=1;i<p;i++)	{
				printf(" %d",ka[i]);
			}
			printf("\n");
		}
	}
	return 0;
}
void func(int nn)
{
	int f2,i,j;
	if(nn==2)	{
		f2=0;
		for(i=1;i<=9;i++)	{
			if(cnt[i]==2)	{
				f2=1;
				break;
			}
		}
//		for(i=1;i<=9;i++)	printf(" %d",cnt[i]);printf("\n");
		if(f2==1)	flg=1;
	}
	else if(flg!=1)	{
		for(i=1;i<=9;i++)	{
			if(cnt[i]>=3)	{
				cnt[i]-=3;
				func(nn-3);
				cnt[i]+=3;
			}
		}
		for(i=1;i<=7;i++)	{
			if(cnt[i]>=1 && cnt[i+1]>=1 && cnt[i+2]>=1)	{
				cnt[i]--;	cnt[i+1]--;	cnt[i+2]--;
				func(nn-3);
				cnt[i]++;	cnt[i+1]++;	cnt[i+2]++;
			}
		}
	}
}


Measured memory_bytes: 984
//test copy file

#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;
 
int number(string &S, int &i);
int term(string &S, int &i);
int expr(string &S, int &i);
 
int number(string &S, int &i){
    int ret = 0;
    while(isdigit(S[i])){
        ret*=10;
        ret+=S[i]-'0';
        i++;
    }
    return ret;
}
 
int term(string &S, int &i){
    const int64_t mod=1000000007;
    if(S[i]=='S'){
        i+=2;//"S<"
        int64_t x = expr(S,i);
        i++;//'>'
        x=x*x%mod;
        return x;
    }else{
        return number(S,i);
    }
}
 
int expr(string &S, int &i){
    int ret = term(S,i);
    while(i<S.size()){
        int cnt=0;
        for(int j=i;j<S.size();j++){
            if(S[j]=='>')cnt++;
            else break;
        }
        if(cnt==2&&i+2<S.size()){
            i+=2;//">>"
            int y = term(S,i);
            if(y>=31){
                ret=0;
            }else{
                ret>>=y;
            }
            continue;
        }else{
            return ret;
        }
    }
    return ret;
}
 
int main(){
    string S;
    while(getline(cin,S)){
        if(S[0]=='#') break;
        int i=0;
        string ss;
        for(auto c:S){
            if(c!=' ') ss.push_back(c);
        }
        // cout<<ss<<endl;
        cout<<expr(ss,i)<<endl;
    }
 
    return 0;
}

Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,Z,W;
ll memo[2001][2];
ll a[2001];

// 人turnはa[card,N)で何枚か選ぶ
ll dfs(int card,int turn,ll x, ll y){
    if(memo[card][turn]) return memo[card][turn];

    if(card == N) return abs(x-y);

    if(turn == 0){
        ll mx = 0;
        for(int i=card;i<N;i++){
            ll d = dfs(i+1,1,a[i],y);
            mx = max(mx,d);
        }
        return memo[card][turn] = mx;
    }else{
        ll mn = LINF;
        for(int i=card;i<N;i++){
            ll d = dfs(i+1,0,x,a[i]);
            mn = min(mn,d);
        }
        return memo[card][turn] = mn;
    }
}


int main(){
    cin >> N >> Z >> W;
    rep(i,N){
        cin >> a[i];
    }

    cout << dfs(0,0,Z,W) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    if (N % 10 == 0){
        cout << 10 << endl;
    }
    else {
        int a, b, c, d, e, f;
        a = N / 100000;
        b = (N - a * 100000) / 10000;
        c = (N - a * 100000 - b * 10000) / 1000;
        d = (N - a * 100000 - b * 10000 - c * 1000) / 100;
        e = (N - a * 100000 - b * 10000 - c * 1000 - d * 100) / 10;
        f = (N - a * 100000 - b * 10000 - c * 1000 - d * 100) % 10;
        cout << a + b + c + d + e + f << endl;
    }
}

Measured memory_bytes: 256
h,w=gets.split.map(&:to_i)
a,t=[],Array.new(w,0)
h.times{|i|
  aa=gets.split('')
  if aa.include?('#') then
    aa.each_with_index{|at,j|
      t[j]+=1 if at=='#'
    }
    a.push(aa)
  end  
}
a.size.times{|i|
  w.times{|j|
    print a[i][j] if t[j]!=0
  }
  puts ''
}

Measured memory_bytes: 2556
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    n <- fst . fromJust . B.readInt <$> B.getLine
    as <- V.fromList . (\s -> 0 : s) . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    if even $ V.length as
        then do
            forM_ [n, (n - 2) .. 1] $ \i -> do
                putStr $ show $ as V.! i
                putChar ' '
            forM_ [2, 4 .. n] $ \i -> do
                putStr $ show $ as V.! i
                putChar ' '
        else do
            forM_ [n, (n - 2) .. 1] $ \i -> do
                putStr $ show $ as V.! i
                putChar ' '
            forM_ [1, 3 .. n] $ \i -> do
                putStr $ show $ as V.! i
                putChar ' '


Measured memory_bytes: 12540
#include <iostream> 
#include <algorithm>
#include <map>

using namespace std;

int main(){
	long long m=0,n=0,i=0;
	string s;
	map<string,long long>ma;
	map<string,long long>::iterator iter;
	
	cin>>m;
	
	for(i=0;i<m;i++){
		cin>>s;
		sort(s.begin(),s.end());
		ma[s]++;
	}
	
	for(iter=ma.begin();iter!=ma.end();iter++){
		n += (iter->second*(iter->second-1))/2;
	}
	
	cout<<n<<endl;
	
	return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int X, A;
    std::cin >> X >> A;

    int res;
    
    if(X < A){
        res = 0;
    }else{
        res = 10;
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
int main() {
	while(cin >> n >> m, n) {
		vector<vector<int> > G(n);
		for(int i = 0; i < m; i++) {
			cin >> a >> b; a--, b--;
			G[a].push_back(b);
			G[b].push_back(a);
		}
		vector<int> d(n, -1); d[0] = 0;
		queue<int> que; que.push(0);
		while(!que.empty()) {
			int u = que.front(); que.pop();
			for(int i : G[u]) {
				if(d[i] == -1) {
					d[i] = d[u] + 1;
					que.push(i);
				}
			}
		}
		int cnt = -1;
		for(int i = 0; i < n; i++) {
			if(d[i] <= 2) cnt++;
		}
		cout << cnt << endl;
	}
}

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

int main() {
	int a, b, c,d;
	cin>>a>>b>>c>>d;
	
	while(a >0 && c > 0){
		if(c-b<=0){
		cout<<"Yes"<<endl;
		return 0;
		}
		else if(a-d<=0){
		cout<<"No"<<endl;
		return 0;	
		}
		else{
			a = a-d;
			c= c-b;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N, K;
	cin >> N >> K;
	VL x(N), y(N), ox(N), oy(N);
	REP(i, N) {
		cin >> x[i] >> y[i];
		ox[i] = x[i];
		oy[i] = y[i];
	}
	SORT(ox);
	SORT(oy);
	ll mins = (ox[N - 1] - ox[0])*(oy[N - 1] - oy[0]);
	REP(xi, N - 1) {
		FOR(xj, xi + 1, N) {
			REP(yi, N - 1) {
				FOR(yj, yi + 1, N) {
					ll xl = ox[xi];
					ll xr = ox[xj];
					ll yb = oy[yi];
					ll yt = oy[yj];
					int c = 0;
					REP(i, N) {
						if ((xl <= x[i]) && (x[i] <= xr) && (yb <= y[i]) && (y[i] <= yt)) c++;
						if (c >= K) mins = min(mins, (xr - xl)*(yt - yb));
					}
				}
			}
		}
	}
	cout << mins << endl;
	return 0;
}

Measured memory_bytes: 256
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

g = {i:'A' for i in A}
g.update({i:'B' for i in B})
g.update({i:'C' for i in C})

x,y = map(int,input().split())
print('Yes' if g[x] == g[y] else 'No')

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    int n,m;
    cin>>n>>m;


    int i1=1;
    int i2=m+2;

    for(int i=m;i>=1;i--){
        cout<<i1<<" "<<i1+i<<endl;
        i1++;
        swap(i1,i2);
    }
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7816
a= [[[0]*10 for i in range(3)] for j in range(4)]

n = int(input())

for i in range(n):
    b,f,r,v = map(int,input().split())
    a[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(a[i][j][k]),end='')
        print()
    if i != 3:
        print("#"*20)


Measured memory_bytes: 5620