akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

void go(const vector<vector<int> >& g, int cur, ll val, vector<ll>& cnt,
        vector<bool>& used)
{
    used[cur] = true;

    for(int to: g[cur]) {
        if(used[to])
            continue;

        go(g, to, val + cnt[cur], cnt, used);
    }

    cnt[cur] += val;
}

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

    vector<vector<int> > g(n);

    for(int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<ll> cnt(n);

    for(int i = 0; i < q; ++i) {
        int p, x;
        cin >> p >> x;
        --p;
        cnt[p] += x;
    }

    vector<bool> used(n);
    go(g, 0, 0LL, cnt, used);

    copy(cnt.begin(), cnt.end(), ostream_iterator<ll>(cout, " "));
    cout << endl;

    return 0;
}


Measured memory_bytes: 30592
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	vector<ll> s(n + 1);
	s[0] = 0;
	REP(i, n) {
		s[i + 1] = s[i] + a[i];
	}
	vector<ll> b;
	REP(i, n) {
		FOR(j, i+1, n+1) {
			b.push_back(s[j] - s[i]);
		}
	}
	ll res = 0;
	RREP(i, 40) {
		int cnt = 0;
		bool flag = false;
		ll ba = 1ll << i;
		for (auto v : b) {
			ll t1 = res + ba;
			ll t2 = t1 & v;
			if (t1 == t2) {
				cnt++;
			}
		}
		if (cnt >= k) {
			res += ba;
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int sum=0;
  for(int i=0;i<N;i++){
    for(int j=N-1;j>0;j--){
      if(A[j]<A[j-1]){
        swap(A[j],A[j-1]);
        sum++;
      }
    }
    if(i==N-1){
      for(int k=0;k<N;k++){
        if(k<N-1){
        cout << A[k] << " ";
      }
      else if(k==N-1){
        cout << A[k];
      }
      }
      cout << endl << sum << endl;
    }
  }
}


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <stdio.h>
using namespace std;
int main()
{
    char a [10];
    scanf("%s",a);
    if(a[1]==a[2]&&(a[1]==a[0]||a[1]==a[3])) 
    printf("Yes");
    else 
    printf("No");
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;

struct V {
    double x, y;

    V(double x = 0, double y = 0) : x(x), y(y) {

    }

    V &operator+=(const V &v) {
        x += v.x;
        y += v.y;
        return *this;
    }

    double dot(const V &v) const {
        return x * v.x + y * v.x;
    }

    double cross(const V &v) const {
        return x * v.y - v.x * y;
    }

    int ort() const {
        if (y > 0) return x > 0 ? 1 : 2;
        else return x > 0 ? 4 : 3;
    }

    bool operator<(const V &v) const {
        int o = ort(), vo = v.ort();
        if (o != vo)return o < vo;
        return cross(v) > 0;
    }

    double norm2() const { return x * x + y * y; }

    double norm() const { return sqrt(norm2()); }

    V &operator+(const V &v) const { return V(*this) += v; }
};

istream &operator>>(istream &i, V &v) {
    i >> v.x >> v.y;
    return i;
}

ostream &operator>>(ostream &o, const V &v) {
    o << "(" << v.x << "," << v.y << ")";
    return o;
}

int main() {

    int n;
    cin >> n;
    vector<V> v(n);

    rep(i, n) {
        cin >> v[i];
    }

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

    double ans = 0;
    rep(l, n) {
        int r = l;
        V now;
        rep(i, n) {
            now += v[r];
            ans = max(ans, now.norm());
            r = (r + 1) % n;
        }

    }
    printf("%.12f\n", ans);


}


Measured memory_bytes: 384
while True :
    n, m = map(int, input().split())
    if n == 0 and m == 0 :
        break
    
    ans = [0] * m
    for i in range(n) :
        tmp = list(map(int, input().split()))
        for j in range(m) :
            ans[j] += tmp[j]
    
    sort_ans = sorted(ans, reverse=True)
    index_ans = []
    for i in range(m) :
        index_ans.append(ans.index(sort_ans[i])+1)
        ans[ans.index(sort_ans[i])]=-1
    print(*index_ans)


Measured memory_bytes: 5628
N = int(input())
digit =[[0] * 10 for i in range(10)]

def CheckDigit():
    ans = 0
    for i in range(10):
        for j in range(10):
            ans += digit[i][j] * digit[j][i]
    return ans

def ArrayRotation(n):
    for i in range(1, n+1):
        tmp = str(i)
        digit[int(tmp[0])][int(tmp[-1])] += 1

if N <= 11:
    print(N)
else:
    ArrayRotation(N)
    print(CheckDigit())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 65;
const ll LINF = 1e18 + 5;
const int mod = 1e9 + 7;
ll dp[N][2][2][2], L, R;
ll dfs(int pos, int limx, int limy, int lead, ll x, ll y) 
{
	if(pos==-1) return 1;
	if(dp[pos][limx][limy][lead]!=-1) return dp[pos][limx][limy][lead];
	int upx = limx ? (x>>pos)&1 : 1;
	int upy = limy ? (y>>pos)&1 : 1;
	ll ans = 0;
	for(int i=0; i<=upx; i++)
		for(int j=0; j<=upy; j++)
		{
			if(lead && i==j) (ans += dfs(pos-1, limx&&i==upx, limy&&j==upy, lead&&i==0, x, y)) %= mod;
			else if(!lead && j>=i) (ans += dfs(pos-1, limx&&i==upx, limy&&j==upy, lead, x, y)) %= mod;
		}
	return dp[pos][limx][limy][lead] = ans;	
}
ll solve(ll l, ll r)
{
	memset(dp, -1, sizeof(dp));
	int len = 0;
	ll x = max(l, r);
	for(int i=0; i<63; i++)
		if((x>>i)&1) len = i;
	ll ans = dfs(len, 1, 1, 1, l, r);
	return ans;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> L >> R;
 	ll ans = (solve(R, R) - solve(L-1, R) -solve(R, L-1) + solve(L-1, L-1))%mod;
 	ans = (ans + mod)%mod;
 	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
signed main(){
	cin>>s;
	int x,y;
	for(int i=0;i+1<s.size();i++){
		if(s[i]=='A'){
			x=i;
			break;
		}
	}
	for(int i=s.size()-1;i>0;i--){
		if(s[i]=='Z'){
			y=i;
			break;
		}
	}
	cout<<y-x+1;
	return 0;
}

Measured memory_bytes: 3716
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
	char ch;
	int alpha[26] = {};

	while(cin >> ch){
		ch = tolower(ch);
		if(isalpha(ch)){
			alpha[ch-'a']++;
		}
	}

	for(int i=0; i<26; i++){
		printf("%c : %d\n",'a'+i,alpha[i]);
	}

	return 0;
}

Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

string s;
lli k;

int main(void){
    cin >> s >> k;
    rep(i, s.size()){
        if(s[i] == 'a') continue;
        lli d = 'z'-s[i]+1;
        if(k >= d){
            k-=d;
            s[i] = 'a';
        }
    }
    lli u = s[s.size()-1]-'a';
    u += k%26;
    u%=26;
    s[s.size()-1] = char('a'+u);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n,k,x,y; cin>>n>>k>>x>>y;
    if(n<=k)cout<<n*x<<endl;
    else cout<< (n-k)*y+k*x<<endl;return 0;
}

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

typedef long long ll;

int main() {
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    vector<vector<int>> min_a(N, vector<int>(N, 2e9));
    rep(i, N) {
        min_a[i][i] = a[i];
        rep(j, N - 1) {
            min_a[i][(i + j + 1) % N] = min(min_a[i][(i + j) % N], a[(i + j + 1) % N]);
        }
    }
    ll ans = 1e18;
    rep(i, N) {
        ll ans0 = 1LL * x * i;
        rep(j, N) {
            ans0 += min_a[j][(i + j) % N];
        }
        if (ans0 < ans) ans = ans0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 16000
n = int(input())

import math
def factorize(n):
    d = {}
    temp = int(math.sqrt(n))+1
    for i in range(2, temp):
        while n%i== 0:
            n //= i
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    if d == {}:
        d[n] = 1
    else:
        if n in d:
            d[n] += 1
        elif n != 1:
            d[n] =1
    return d

D = {}
for i in range(1, n+1):
    d = factorize(i)
    for k, v in d.items():
        if k in D:
            D[k] += v
        else:
            D[k] = v
#print(D)
p74 = 0
p24 = 0
p14 = 0
p4 = 0
p2 = 0
for k, v in D.items():
    if v >= 74:
        p74 += 1
        p24 += 1
        p14 += 1
        p4 +=1
        p2 +=1
    elif v >= 24:
        p24 += 1
        p14 += 1
        p4 +=1
        p2 +=1
    elif v >= 14:
        p14 += 1
        p4 +=1
        p2 +=1
    elif v >= 4:
        p4 +=1
        p2 +=1
    elif v >= 2:
        p2 +=1
    else:
        pass

ans = 0
# 3*5*5
ans += (p4*(p4-1)//2)*(p2-2)
# 3*25
ans += p24*(p2-1)
# 5*15
ans += p14*(p4-1)
# 75
ans += p74
print(ans)


Measured memory_bytes: 62424
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
	int num,cap,price;

	while(std::cin >> num >> cap){

		if(num == 0 && cap == 0){
			break;
		}

		std::vector<int> vegetables;

		for(int i=0; i<num; ++i){
			std::cin >> price;
			vegetables.push_back(price);
		}

		sort(vegetables.begin(), vegetables.end(), std::greater<int>());

		int sum = 0;
		int i = 0;

		while(i < num){

			if((i+1) % cap != 0){
				sum += vegetables.at(i);
			}

			++i;
		}

		std::cout << sum << std::endl;
	}

}

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

int main() {
  int x,y;
  cin >> x >> y ;
  
  if ( (x*y)%2 == 0 ) {
    
    cout << "Even" << endl;
  }
  
  else if ( (x*y)%2 == 1 ) {
    
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <set>
#include <vector>

using namespace std;

using ll = long long;

ll cnt_digits(ll x) {
    int ret = 0;
    while (x > 0) {
        ret++;
        x /= 10;
    }
    return ret;
}

int main() {
    ll n;
    cin >> n;
    ll ans = 1e10 + 10;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ll x = max(cnt_digits(i), cnt_digits(n / i));
            ans = min(ans, x);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    int x = s.find('A');
    int y = s.rfind('Z');
    cout << y - x + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 720
#include <stdio.h>

int main(void)
{
  const int N;
  scanf("%d", &N);
  int ord[N];
  for(int i = 0; i < N; i++){
    int a;
    scanf("%d", &a);
    ord[a-1] = i+1;
  }
  for(int i = 0; i < N; i++){
    printf("%d ", ord[i]);
  }
  return 0;
}


Measured memory_bytes: 1152
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	int cnt = 0;
		int N = sc.nextInt();
      	int M = sc.nextInt();
      	boolean menu[][] = new boolean[N][M];
      	for(int i=0;i<N;i++){
        	for(int j=0;j<M;j++){
            	menu[i][j]= false;
            }
        }
      	for(int i=0;i<N;i++){
        	int K = sc.nextInt();
          	for(int j=0;j<K;j++){
            	int A = sc.nextInt();
              	menu[i][A-1] = true;
            }
        }
      	
      	for(int i=0;i<M;i++){
          	boolean flg = true;
        	for(int j=0;j<N;j++){
            	if(menu[j][i] ==false){
                  	flg = false;
                }
            }
          	if(flg){
            	cnt++;
            }
        }
      	
      	System.out.println(cnt);
    }
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

bool possible(string a, string b){
    for(int i=0; i<a.size(); i++){
        if(a.at(i) == '?') continue;
        else{
            if(a.at(i) != b.at(i)) return false;
        }
    }
    return true;
}

int main(){
    string s;
    string t;
    cin >> s >> t;
    for(int i=s.size()-t.size();i>=0;i--){
        string a;
        a = s.substr(i, t.size());
        if(possible(a,t)){
            for(int k=0; k<s.size(); k++){
                if(k>=i && k<i+t.size()){
                    cout << t.at(k-i);
                }
                else{
                    if(s.at(k)=='?') cout << 'a';
                    else cout << s.at(k);
                }
            }
            cout << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 3532
N = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(N)]#玉を収納していくリスト

def check(i):
#Nには箱の番号（aのindex+1)を大きい順に入れる
    n = i
    cnt = 0
    #aaの倍数の箱に入っている玉の数をカウント
    while n <= N:
        cnt += b[n-1]
        n += i
        #aaを2倍、3倍、、、としていく
    return cnt

for i in range(N-1, -1, -1):
    if (a[i]+check(i+1))%2 == 1:
        b[i] = 1
    
ans = sum(b)
ll = []
for i in range(N):
    if b[i] == 1:
        ll.append(i+1)

lll = [str(i) for i in ll]
if ans == 0:
    print(ans)
else:
    print(ans)
    print(" ".join(lll))

Measured memory_bytes: 22324
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        mut ss: [usize; n]
    };
    let sum: usize = ss.iter().sum();
    if sum % 10 != 0 {
        println!("{}", sum);
    } else {
        ss.sort();
        if let Some(s) = ss.iter().find(|&s| s % 10 != 0) {
            println!("{}", sum - s);
        } else {
            println!("0");
        }
    }
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int gcd(int a,int b)
{
	return (b==0?a:gcd(b,a%b));
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	int t; cin>>t;
	int now=t;
	REP(i,1,n-1)
	{
		cin>>t;
		now=gcd(now,t);
	}
	cout<<now<<"\n";
	return 0;
}







Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

bool par(int x) {
   string s = to_string(x);
   bool flag = true;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] != s[s.size() - i - 1]) {
            flag = false;
            break;
        }
    }
    return flag;
}
int main() {
    int a,b;
    cin >> a >> b;
    int cnt = 0;
    for (int i = a; i <=b ; ++i) {
        if(par(i)) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
    ]

count = int(input())
for c in range(count):
    b, f, r, v = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v

for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()
    if bi < 3:
        print('#' * 20)

Measured memory_bytes: 7640
# K個の独立した問題として考える

N, K = map(int, input().split())
RSP = list(map(int, input().split()))
T = input()

def is_win(me, other):
    if me == 0 and other == 1:
        return True
    elif me == 1 and other == 2:
        return True
    elif me == 2 and other == 0:
        return True
    return False

def char_to_num(s):
    if s == "r":
        return 0
    elif s == "s":
        return 1
    else:
        return 2

# dp[i][j] = i回目のじゃんけんでjを出して取れる最大の点数([i%K]ごとに独立)
dp = [[-1 for j in range(3)] for i in range(N+1)]
dp[0] = [0, 0, 0]
for i in range(1, N+1):
    t = char_to_num(T[i-1])
    if i <= K:
        for j in range(3):
            dp[i][j] = is_win(j, t)*RSP[j]
    else:    
        for j in range(3):
            dp[i][j] = max(
                [dp[i-K][k] + is_win(j, t)*RSP[j] for k in range(3) if j != k]
            )

# print(dp)

r = sum(map(max, dp[-K:]))
print(r)

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

typedef long long ll;
typedef unsigned long long ull;
typedef long l;
typedef unsigned long ul;
typedef pair<ll,ll> pll;
typedef pair<l,l> pl;
typedef pair<int,int> pi;
typedef vector<ll> vll;
typedef vector<l> vl;
typedef vector<int> vi;

#define pb push_back
#define mp make_pair
#define eb emplace_back

#define fi first
#define se second

int main(){
	ll N, A;
	cin >> N >> A;
	cout << N*N - A << endl;
	return 0;
}

Measured memory_bytes: 256
h, w = list(map(int, input().split()))
A = [input() for i in range(h)]

B = [[0]*w for i in range(h)]

d = [-1, 0, 1]

for i in range(h):
    for j in range(w):
        if A[i][j] == "#":
            B[i][j] = "#"
            for k in d:
                for l in d:
                    if 0 <= i+k < h and 0 <= j+l < w:
                        if B[i+k][j+l] != "#":
                            B[i+k][j+l] += 1


B_str = [map(str, B[i]) for i in range(h)]
for i in range(h):
    print("".join(B_str[i]))


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;
 
int H, W, N;
set<pair<int, int> > F;
set<pair<int, int> > cand;
 
i64 ans[10];
 
void add_cand(int y, int x)
{
	if (y >= 0 && y < H - 2 && x >= 0 && x < W - 2) cand.insert({ y, x });
}
 
int main()
{
	scanf("%d%d%d", &H, &W, &N);
	for (int i = 0; i < N; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a; --b;
		F.insert({ a, b });
 
		for (int dy = 0; dy <= 2; ++dy) for (int dx = 0; dx <= 2; ++dx) add_cand(a - dy, b - dx);
	}
 
	for (int i = 0; i <= 9; ++i) ans[i] = 0;
	ans[0] = (i64)(H - 2) * (W - 2);
	for (auto aa : cand) {
		int y = aa.first, x = aa.second;
		int num = 0;
		for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) {
			if (F.count({ y + i, x + j })) ++num;
		}
		--ans[0];
		++ans[num];
	}
	for (int i = 0; i <= 9; ++i) printf("%lld\n", ans[i]);
 
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N;
string S;

int b[222222];

signed main(){
    cin>>S;
    N=S.size();
    rep(i,N){
        b[i+1]=b[i]^(1<<(S[i]-'a'));
    }

    map<int,int>dp;
    dp[0]=0;
    rep(i,N-1){
        int hoge=INF;
        rep(j,26){
            int tmp=b[i+1]^(1<<j);
            if(dp.find(tmp)!=dp.end()){
                chmin(hoge,dp[tmp]+1);
            }
        }

        if(dp.find(b[i+1])!=dp.end())chmin(dp[b[i+1]],hoge);
        else dp[b[i+1]]=hoge;
    }

    int ans=INF;

    rep(i,26){
        int tmp=b[N]^(1<<i);
        if(dp.find(tmp)!=dp.end())chmin(ans,dp[tmp]+1);
    }
    if(b[N]==0)ans=1;
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	int n,m;
	while(cin >> n >> m){
		if(!n && !m)
			break;
		int DP[16][16];
		for(int i=0;i<16;i++){
			for(int j=0;j<16;j++){
				DP[i][j] = 1;
			}
		}
		int k;
		cin >> k;
		for(int l=0;l<k;l++){
			int a,b;
			cin >> a >> b;
			DP[b-1][a-1] = 0;
		}
		
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(i == 0 && j == 0)
					continue;
				if(DP[i][j] != 0){
					if(i == 0)
						DP[i][j] = DP[i][j-1];
					else if(j == 0)
						DP[i][j] = DP[i-1][j];
					else
						DP[i][j] = DP[i-1][j] + DP[i][j-1];
				}
			}
		}
		cout << DP[m-1][n-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int a, b;
	cin >> a >> b;
	if (b % a)
		cout << b - a << endl;
	else
		cout << a + b << endl;
}

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

	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
   int a,b,d,r;
       float f;
   cin>>a>>b;
   d=a/b;
   r=a%b;
   cout<<d<<" "<<r<<" ";
   printf("%.5lf\n",1.0*a/b);
}


Measured memory_bytes: 3216
#include <stdio.h>
#include <string.h>
int main(){
int n;
scanf("%d",&n);
char arr[n];
scanf("%s",arr);
int z=strlen(arr);
if(z%2){
	printf("No");
	return 0;
}
else{
	for (int i=0;i<z/2;i++){
		if(arr[i]!=arr[i+(z/2)]){
			printf("No");
			return 0;
		}
		else{
			continue;
		}
	}
}
printf("Yes");
return 0;
}

Measured memory_bytes: 1688
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep0(i,n) for(i=0;i<(n);i++)
#define repn(i,m,n) for(int i=(m);i<=(n);i++)
#define all(n) n.begin(),n.end()
#define mp make_pair
#define PUTLINE cout<<__LINE__<<endl;

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

int k[100100];

int main() {
	int n=in();
	rep(i,n){
		++k[in()-1];
		--k[in()];
	}
	int res,t=0;
	rep(i,100100){
		t+=k[i];
		if(i<=t)res=i;
	}
	cout<<res<<endl;
	return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
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;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if ((num%2) == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) if (num % i == 0) return false;
    return true;
}

void solve(long long x){
    while(1){
        if(IsPrime(x)) break;
        x++;
    }
    cout<<x<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

using namespace std;

const int MAXN = 1000 * 1000 + 10;

int bomb_h[MAXN], bomb_w[MAXN];

set <pair <int,int>> check;

vector <int> max_h, max_w;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //cout << fixed << setprecision(10);

    int h, w, m;
    cin >> h >> w >> m;
    for(int i = 0; i < m; i++){
        int hi, wi;
        cin >> hi >> wi;
        bomb_h[hi]++;
        bomb_w[wi]++;
        check.insert( make_pair(hi,wi) );
    }
    int _max=0;
    for(int i=0; i<= h ;i++){
        if(bomb_h[i]>_max){
            max_h.clear();
            _max=bomb_h[i];
        }
        if(bomb_h[i]==_max) max_h.push_back(i);
    }
    _max=0;
    for(int i=0; i<= w ;i++){
        if(bomb_w[i]>_max){
            max_w.clear();
            _max=bomb_w[i];
        }
        if(bomb_w[i]==_max) max_w.push_back(i);
    }

    for(int i=0 ; i< max_h.size(); i++){
        for(int j=0; j< max_w.size(); j++){
            int add =0;
            if(*check.lower_bound(make_pair(max_h[i],max_w[j])) == make_pair(max_h[i],max_w[j])){
                add = -1;
            }
            if((i==max_h.size()-1 and j==max_w.size()-1)or add == 0){
                cout << bomb_h[max_h[i]] + bomb_w[max_w[j]] + add <<endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 23748
#include<iostream>

using namespace std;

int main() {
	long a, b, k;

	cin >> a >> b >> k;

	if (b - a < 2 * k) {
		for (int i = a; i <= b; i++) {
			cout << i << endl;
		}
	}

	else {
		for (int i = 0; i < k; i++) {
			cout << a + i << endl;
		}
		for (int i = -k + 1; i <= 0; i++) {
			cout << b + i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		long extrac;
		long n=sc.nextLong();
		long m=sc.nextLong();
		if(m<2*n) System.out.println(m/2); 
		else
		{
			extrac=m-2*n;
			n+=(extrac/4);
			System.out.println(n);
			
		}
	
	}
}


Measured memory_bytes: 35444
N,M = map(int,input().split())

L = [list(map(int,input().split())) for i in range(M)]

for i in range(M):
  L[i].append(i + 1)

sortL = sorted(L)

ID = ""

order = 0

for i in range(0,len(L)):
  if sortL[i][0] > sortL[i-1][0]:
    order = 0
  order += 1
  pref = str(sortL[i][0])
  ID = "0" *  (6 - len(pref))
  ID += pref
  ID += "0" * (6 - len(str(order)))
  ID += str(order)
  sortL[i].append(ID)

sortL.sort(key=lambda x: x[2])

for i in range(0,len(L)):
  print(sortL[i][-1])

Measured memory_bytes: 39628
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main2():
    numbers=[]
    n,m = map(int,input().split())
    numbers=[list(map(int,input().split())) for _ in range(m)]
    dp=[0]*n
    for number in numbers:
        for n in number:
            dp[n-1]+=1
    for ans in dp:
        print(ans)

def main():
    numbers=[]
    n,m = map(int,input().split())
    numbers=[list(map(int,input().split())) for _ in range(m)]
    dp={}
    for number in numbers:
        for n in number:
            if n not in dp:
                dp[n]=1
            else:
                dp[n]+=1
    print(dp)
    for i in range(1,len(dp)+1):
        print(dp[i])

if __name__=="__main__":
    main2()

Measured memory_bytes: 9232
require 'matrix'

class Vector
    include Comparable

    def <=>(other)
        if self[0] == other[0]
            self[1] <=> other[1]
        else
            self[0] <=> other[0]
        end
    end

    def det(other)
        self[0] * other[1] - self[1] * other[0]
    end
end

def convex_hull(ps)
    n = ps.length
    vs = ps.sort
    k = 0
    qs = []
    n.times do |i|
        while qs.length > 1 && (qs[-1] - qs[-2]).det(vs[i] - qs[-1]) <= 0 do
            qs.pop
        end
        qs.push(vs[i])
    end
    t = qs.length
    (n - 2).downto(0) do |i|
        while qs.length > t && (qs[-1] - qs[-2]).det(vs[i] - qs[-1]) <= 0 do
            qs.pop
        end
        qs.push(vs[i])
    end
    return qs
end

N = gets.to_i
vs = []
N.times do |i|
    x, y = gets.split.map(&:to_i)
    vs[i] = Vector[x, y]
end

ch = convex_hull(vs)
ch.pop
N.times do |i|
    if ch.include?(vs[i])
        now = ch.index(vs[i])
        nex = (now + 1) % ch.length
        pre = (now - 1) % ch.length
        begin
            angle = (ch[now] - ch[pre]).angle_with(ch[nex] - ch[now])
        rescue
            angle = Math::PI
        end
        puts angle / 2 / Math::PI
    else
        puts 0
    end
end

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, ans = 0;
	string A, B, C;

	cin >> N >> A >> B >> C;

	rep(i, N) {
		if (A[i] == B[i] && B[i] == C[i]) continue;
		else if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) ans++;
		else ans += 2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(void){
  int n;
  if (!scanf("%d", &n))
    return 0;
  float ans;
  if (n%2 == 0){
    ans = 0.5;
  }
  else{
    ans = (float)(n/2+1)/n;
  }
  printf("%f", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

ll N, M, Q;
vector<vector<ll>> pattern(vector<vector<ll>> A)
{
  vector<vector<ll>> res;
  if (A.at(0).size() == N) {
    return A;
  }
  for (ll j = 0; j < A.size(); ++j) {
    ll last = A.at(j).at(A.at(j).size() - 1);
    for (ll k = last; k <= M; ++k) {
      vector<ll> temp = A.at(j);
      temp.push_back(k);
      res.push_back(temp);
    }
  }
  return pattern(res);
}

int main()
{
  cin >> N >> M >> Q;
  vector<vector<ll>> A;
  for (ll i = 1; i <= M; ++i) {
    A.push_back({i});
  }
  vector<vector<ll>> abcd(Q);
  for (ll i = 0; i < Q; ++i) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    a -= 1;
    b -= 1;
    abcd.at(i) = {a, b, c, d};
  }

  vector<vector<ll>> all = pattern(A);
  // for (ll i = 0; i < all.size(); ++i) {
  //   for (ll j = 0; j < all.at(i).size(); ++j) {
  //     cout << all.at(i).at(j) << ' ';
  //   }
  //   cout << endl;
  // }
  ll ans = 0;
  for (ll i = 0; i < all.size(); ++i) {
    vector<ll> check = all.at(i);
    ll score = 0;
    for (ll j = 0; j < Q; ++j) {
      vector<ll> now = abcd.at(j);
      ll a = now.at(0), b = now.at(1), c = now.at(2), d = now.at(3);
      if (check.at(b) - check.at(a) == c) {
        score += d;
      }
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
}


Measured memory_bytes: 42824
#include<stdio.h>
#include<stdlib.h>
int comp(const void *a,const void *b){
  int p=*(int*)a;
  int q=*(int*)b;
  return q-p;
}

int main(){
  int a[2][10];
  for(int i=0;i<2;i++){
    for(int j=0;j<10;j++)scanf("%d",&a[i][j]);
    qsort(a[i],10,sizeof(int),comp);
  }
  printf("%d %d\n",a[0][0]+a[0][1]+a[0][2],a[1][0]+a[1][1]+a[1][2]);
  return 0;
}

Measured memory_bytes: 1028
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroint-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define pi 3.14159265359
#define mp make_pair
#define ff first
#define ss second
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%intd",&a)
#define pf printf
#define sz(a) (int)(a.size())
#define psf push_front
#define ppf pop_front
#define ppb pop_back
#define pb push_back
#define pq priority_queue
#define all(s) s.begin(),s.end()
#define sp(a) setprecision(a)
#define rz resize
#define ld long double
#define inf 1e18
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define eb emplace_back
#define vvlli vector<vector<ll> >
#define vlli vector<ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vstr vector<string>
#define vvstr vector<vector<string> >
ll binpow(ll a, ll b){ll res=1;while(b!=0){if(b&1)res*=a;a*=a;b>>=1;}return res;}

using namespace std;

ll d,dp[10001][2][2][100];
string l,r;

ll fn(int level, int tlo, int thi, int rem)
{
    if(level>=sz(l))
    {
        if(rem==0)
            return 1;
        return 0;
    }
    if(dp[level][tlo][thi][rem]==-1)
    {
        ll ans=0;
        int blo = 0,bhi = 9;
        if(tlo)
            blo = l[level]-'0';
        if(thi)
            bhi = r[level]-'0';
        f(i,blo,bhi+1)
        {
            int ntlo = tlo, nthi = thi;
            if(i > (l[level]-'0'))
                ntlo = 0;
            if(i < r[level]-'0')
                nthi = 0;
            ans += fn(level+1,ntlo,nthi,(rem+i)%d);
            ans%=mod;
        }
        dp[level][tlo][thi][rem] = ans;
    }
    return dp[level][tlo][thi][rem];
}

void solve()
{
    memset(dp,-1,sizeof(dp));
    cin>>r>>d;
    l="1";
    while(sz(l)<sz(r))
        l+='0';
    reverse(all(l));
    cout<<fn(0,1,1,0)<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    solve();
}

Measured memory_bytes: 35844
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
    ll a,b,x;
    cin >> a>>b >>x;
 	
  	ll a1 = (a-1)/x;
  	
  	ll b1 = b/x;
  
  
  	if (a==0)a1=0;
	if (a==0)b1=b/x+1;
  
	cout << (b1-a1);

    return 0;
}


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

int getNextWord(int added, char* src, char* word)
{
	int i;
	for( i = 0; src[i] != ' ' && src[i] != '.' && src[i] != ',' && src[i] != '\0'; i++ )
	{
		word[i] = src[i];
	}
	word[i] = '\0';
	
	for(; src[i] == ' ' || src[i] == '.' || src[i] == ',' || src[i] == '\0'; i++ )
	{
	}
	
	return (i + added);
}

int main(void)
{
	char string[2048] = {0};
	char word[2048] = {0};
	int i;
	int len;
	int isFirst = 1;
	
	fgets( string, 2048, stdin );
	
	string[ strlen( string ) ] = '\0';
	
	for( i = 0; i < 2048; )
	{
		i = getNextWord( i, string + i, word );
		len = strlen( word );
		if( len >= 3 && len <= 6 )
		{
			printf("%s%s", isFirst == 1 ? "" : " ", word);
			isFirst = 0;
		}
	}
	puts("");
	
	return (0);
}

Measured memory_bytes: 528
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    double otoshidama = 0, x;
    string u;
    for(int i=0; i<N; i++){
        cin >> x >> u;
        if(u == "JPY"){
            otoshidama += x;
        }else{
            otoshidama += x * 380000;
        }
    }
    cout << otoshidama << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int c[10000],a[10000];
int main(){

	int n;
		cin >> n;
		int x = n;
		for (int b=0; b < n; b++){
			cin >> c[b];
			a[x] = c[b];
			x--;
		}
		x = 1;
		for (int z=0; z < n; z++){
			if (z < n - 1){
				cout << a[x] << ' ';
				x++;
			}
			else{
				cout << a[x] << endl;
			}
		}
	return 0;
}



Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

signed main() { 
        int n;
        cin >> n;
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        int ans = 0;
        rep(i, n) {
                if (a[i] >= 3200) {
                        a[i] = -400;
                        ans ++;
                }
        }
        rep(i, n) a[i] /= 400;
        int cnt[8] = { 0 };
        rep(i, n) if (a[i] != -1) cnt[a[i]] ++;
        int c = 0;
        rep(i, 8) if (cnt[i] > 0) c ++;
        if (c == 0) cout << 1 << ' ' << ans << endl;
        else cout << c << ' ' << c + ans << endl;
        return 0;
}               



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <iomanip>
#include <bits/stdc++.h>
#include <fstream>
#include <map>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll a;
    ll ans;
    cin >> a;
    cout << a+(a*a)+(a*a*a) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    string s, c, p;
    int q, a, b;

    cin >> s >> q;

    while (q-- && cin >> c) {
        cin >> a >> b;
        int size = b - a + 1;
        if (c == "print")
            cout << s.substr(a, size) << endl;
        else if (c == "reverse") {
            string st = s.substr(a, size);
            reverse(st.begin(), st.end());
            s = s.replace(a, size, st);
        } else {
            cin >> p;
            s = s.replace(a, size, p);
        }
    }

    return 0;
}


Measured memory_bytes: 3228
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for (ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VLL               vector<vector<ll>>
#define VLLL              vector<vector<vector<ll>>>
#define INF               2e9;
#define INF_LL            1LL<<60;
#define MOD               1000000007;

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 処理
void Solve()
{
	ll N;
	cin >> N;

	string ans = "hon";
	ll amari = N % 10;
	if (amari == 3) ans = "bon";
	if (amari == 0 || amari == 1 || amari == 6 || amari == 8) ans = "pon";
	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;
const long double pi = 3.14159265;
const long long mod =1e9+7;


int main(){
    int X,x,sum=0;
    
    cin >> X;
    x = X;
    while(x>0){
        sum += x%10;
        x = x/10;
    }

    if(X%sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}
 

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

int main(){
    int n,h,i;
    string s,s1,s2;
    while(1){
        cin >> s;
        if (s == "-") break;
        else{
            cin >> n;
            for (i = 0; i < n; i++){
                cin >> h;
                s1 = s.substr(0,h);
                s2 = s.substr(h,s.size() - h);
                s = s2 + s1;
            }
            cout << s << '\n';
        }    
    }

    return 0;
}


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

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  const Int n = 30;
  vector<Int> po(n,1);
  for(Int i=0;i+1<n;i++) po[i+1]=po[i]*3;

  auto solve=[&](Int a,Int b,Int c,Int d)->Int{
    for(Int k=n-1;k>=0;k--){
      Int A=a/po[k];
      Int B=b/po[k];
      Int C=c/po[k];
      Int D=d/po[k];
      if(A==C and A%3==1 and abs(B-D)>=2){
        Int x1=a%po[k];
        Int x2=c%po[k];
        return abs(b-d)+min(x1+1+1+x2,(po[k]-(x1+1))+1+1+(po[k]-(x2+1)));
      }
      if(B==D and B%3==1 and abs(A-C)>=2){
        Int y1=b%po[k];
        Int y2=d%po[k];
        return abs(a-c)+min(y1+1+1+y2,(po[k]-(y1+1))+1+1+(po[k]-(y2+1)));
      }
    }
    return abs(a-c)+abs(b-d);
  };

  Int q;
  cin>>q;

  for(Int i=0;i<q;i++){
    Int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;c--;d--;
    cout<<solve(a,b,c,d)<<newl;
  }
  return 0;
}


Measured memory_bytes: 384
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

def calc(x, y):
    cnt = sum((x[i] - y[i]) ** 2 for i in range(D))
    return cnt ** 0.5 == int(cnt ** 0.5)

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans += 1 if calc(X[i], X[j]) else 0
print(ans)



Measured memory_bytes: 38384
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.datetime;

void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;

    auto W = new int[](N+1);
    auto E = new int[](N+1);
    foreach (i; 0..N) W[i+1] = W[i] + (S[i] == 'W');
    foreach (i; 0..N) E[i+1] = E[i] + (S[i] == 'E');


    int ans = 1 << 29;

    foreach (i; 0..N) {
        int tmp = 0;
        if (i > 0) {
            tmp += W[i];
        }
        if (i < N-1) {
            tmp += E[N] - E[i+1];
        }
        ans = min(ans, tmp);
    }

    ans.writeln;
}


Measured memory_bytes: 4440
#include <stdio.h>
#define ll long long

int main(void) {
	int N, K;
	scanf("%d%d", &N, &K);
	int A[101] = {0};

	for (int i = 0; i < K; i++) {
		int d;
		scanf("%d", &d);
		for (int j = 0; j < d; j++) {
			int a;
			scanf("%d", &a);
			A[a] = 1;
		}
	}

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (!A[i]) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1732
n,a,b = map(int,input().split())
x = [int(i) for i in input().split()]
ans = 0
for i in range(n-1):
    if (x[i+1] - x[i])*a >= b:
        ans += b
    else:
        ans += (x[i+1] - x[i])*a
print(ans)

Measured memory_bytes: 14252
rank = ["AAA","AA","A","B","C","D","E"]
ref1 = [35.5,37.5,40.0,43.0,50.0,55.0,70.0]
ref2 = [71.0,77.0,83.0,89.0,105.0,116.0,148.0]
while True:
	try:
		time = map(float, raw_input().split())
		for i in range(7):
			if time[0]<ref1[i] and time[1]<ref2[i]:
				print rank[i]
				break
		else:
			print "NA"
	except:
		break

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

int main()
{
    string s;
    cin >> s;
    vector<int> ans;

    for(int i=0;i<s.size();i++){
        switch(s[i]){
            case '0':
                ans.push_back(0);
                break;
            case '1':
                ans.push_back(1);
                break;
            case 'B':
                if(ans.size() != 0){
                    ans.pop_back();
                    break;
                }
                else{
                    break;
                }
            default:
                break;
        }
        
    }
    for(int j=0;j<ans.size();j++){
    cout << ans[j];
    }
    cout << endl;
    return 0;

}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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


Measured memory_bytes: 256