akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n, m;
    cin >> n >> m;
    vector<vector<char> > gg(n, vector<char> (m));
    cin >> gg;
    int dp[n][m];
    for (int i = 0;i < n;i++) {
        for (int j = 0;j < m;j++) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    for (int i = 1;i < n;i++) {
        if (gg[i][0] == '.') {
            chkmax(dp[i][0], dp[i - 1][0]);
        }
    }
    for (int i = 1;i < m;i++) {
        if (gg[0][i] == '.') {
            chkmax(dp[0][i], dp[0][i - 1]);
        }
    }
    for (int i = 1;i < n;i++) {
        for (int j = 1;j < m;j++) {
            if (gg[i][j] == '.') {
                (dp[i][j] = dp[i - 1][j] + dp[i][j - 1]) %= mod;
            }
        }
    }

    cout << dp[n - 1][m - 1];

    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64
#define uint u64

template<class T>
inline bool chmin(T &a, T b) { if(a > b) {a = b; return true;} return false; }
template <class T>
inline bool chmax(T &a, T b) { if(a < b) {a = b; return true;} return false; }
const int INF = 1LL << 60;

inline bool isOdd(char x) {
	if(x == '1' || x == '3' || x == '5' || x == '7' || x == '9') return true;
	return false;
}

signed main() {
	uint n;
	cin >> n;

	uint res = 0;

	if(n % 2 == 0) {
		uint denom = 10;
		while(n / denom) {
			res += n / denom;
			denom *= 5;
		}
	}

	cout << res << endl;

	return 0;
}


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

flag = True

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            if i-1 >= 0 and s[i-1][j] == '#':
                continue
            elif i+1 < h and s[i+1][j] == '#':
                continue
            elif j-1 >= 0 and s[i][j-1] == '#':
                continue
            elif j+1 < w and s[i][j+1] == '#':
                continue
            else:
                flag = False
                break
    if flag == False:
        break

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n, k, a[1005], sum=0;
int main() {
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a, a+n);
    while (k>=0) {
        if (k!=0) sum+=a[k-1];
        k--;
    }
    cout << sum;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int dif = (a / 15) * 200;

        long sum = a * 800l;

        sum -= dif;
        System.out.println(sum);
    }
}


Measured memory_bytes: 21716
//abc113_d.cpp
//Thu May  9 21:46:16 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll h,w,k;
	cin >> h >> w >> k;

	ll mod = 1000000007;

//	if (w==1){
//		cout << 1 << endl;
//		return 0;
//	}else if (w==2){
//		lldiv_t temp = lldiv(pow(2,h),mod);
//		cout << temp.rem << endl;
//		return 0;
//	}

	ll dp[h+1][w];
	for (int i=0;i<h+1;i++){
		for (int j=0;j<w;j++){
			dp[i][j] = 0;
		}
	}

	dp[0][0] = 1;

	for (int i=1;i<h+1;i++){
		for (int j=0;j<w;j++){
			for (int k=0;k<1<<w-1;k++){
				int flag = 1;
				for (int l=0;l<w-2;l++){
					if ((k>>l & 1) && (k>>(l+1) & 1)){
						flag = 0;
						break;
					}
				}
				if (flag){
					if (j>=1 && (k>>(j-1) & 1)){
						dp[i][j-1] += dp[i-1][j];
						dp[i][j-1] %= mod;
					}else if (j<w-1 && ((k>>j) & 1)){
						dp[i][j+1] += dp[i-1][j];
						dp[i][j+1] %= mod;
					}else {
						dp[i][j] += dp[i-1][j];
						dp[i][j] %= mod;
					}
				}
			}
		}
	}


	cout << dp[h][k-1] << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;
 
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };
 
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
 
bool solve(int x) {
	int cnt = 0;
	for (int i = 1; i <= x; i++) {
		if (i % 2 == 0) {
			continue;
		}
 
		if (x % i == 0) {
			cnt++;
		}
 
		if (cnt == 8) {
			return true;
		}
	}
 
	return false;
}
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	int n;
	cin >> n;
 
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += solve(i);
	}
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint N, a, b;
	cin >> N >> a >> b;
    
    if(b > a) swap(a, b);

	if ((a - b) % 2 == 0) {
		cout << (a - b) / 2 << "\n";
	}
	else {
		cout << min({ a - 1, N - b,
			 (a - b) / 2 + b, (a - b) / 2 + N - a + 1 }) << "\n";
	}

	return 0;
}


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

int main(){
  int64_t a,b;
  cin >> a >> b;
  int k;
  cin >> k;
  for(int64_t i=a;i<=b;i++){
    if(i<a+k||i>b-k) cout << i << endl;
  }
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int k;
    string s;
    cin>>k>>s;
    if(s.size()>k)s=s.substr(0,k)+"...";
    cout<<s<<endl;
return 0;
}

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

int a[100005];

int main(){
	int n,i,j,win=0;cin>>n;
	for(i=1;i<=n;++i) cin>>a[i];
	sort(a+1,a+n+1,greater<int>());
	for(i=1;i<=n;++i){
		if(a[i+1]<i+1 && a[i]>=i){
			j=i+1;
			while(a[j]==i) j++,win^=1;
			win|=((a[i]-i)&1);
			if(win) puts("First");
			else puts("Second");
		}
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
vector<bool> ps(1000+1, true);

void sieve() {
  for(int i = 2; i*i <= 1000; i++) {
    if (ps.at(i)) {
      int c = i*2;
      while(c <= 1000) {
        ps.at(c) = false;
        c += i;
      }
    }
  }
}

int main()
{
  int n;
  cin >> n;
  sieve();
  map<int, int> mp;
  ll r = 1e9 + 7;
  reps(i, 2, n+1) {
    int t = i;
    reps(j, 2, 1000+1) {
      if (ps[j]) {
        while(t % j == 0) {
          mp[j]++;
          t /= j;
        }        
      }
    }
  }  
  ll ans = 1;
  for(auto it = mp.begin(); it != mp.end(); it++) {
    ans *= it->second + 1;
    ans %= r;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N, M;
    while(cin >> N >> M && N > 0){
        vector<int> h(N);
        vector<int> w(M);
        for(int i = 0; i < N; i++)
		{
            cin >> h[i];
		}
        for(int i = 0; i < M; i++)
		{
            cin >> w[i];
		}
        int count = 0;
        int H,W;
        for(int i = 0; i < N; i++){
            for(int j = 0; j < M; j++){
                int p = i;
                int q = j;
                H = 0;
                W = 0;
                while(1){
                    if(H >= W){
                        W += w[q];
                        q++;
                        if(q > M) break;
                    }else{
                        H += h[p];
                        p++;
                        if(p > N) break;
                    }

                    if(H == W){
                        
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 2964
x,k,d = map(int,input().split())
x=abs(x)

if(x//d>k):
    print(x-d*k)

else:
    tempx=x-(x//d)*d
    nokorik=k-(x//d)

    migi=tempx+d
    hidari=abs(tempx-d)

    ans1=tempx
    ans2=min(migi,hidari)

    if(nokorik %2 ==0):
        print(ans1)
    else:
        print(ans2)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

int x[8];

int main()
{
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vector<int> a(n);
    rep(i, n) a[i] = i + 1;
    int c = 0;
    int b = 0;
    int cnt = 0;
    do {
        if(p == a) c = cnt; 
        if(q == a) b = cnt;
        cnt++;
    } while(next_permutation(a.begin(), a.end()));
    cout << abs(b - c) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int r;
  cin>>r;
  if(r<1200)cout<<"ABC"<<endl;
  else if(r<2800)cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
  return 0;
}


Measured memory_bytes: 768
mod=10**9+7
class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv
comb = Combination(100005)
n,k = map(int,input().split())
As = list(map(int,input().split()))
As.sort()
ans = 0
for i in range(n-k+1):
  ans -= comb(n-i-1,k-1) * As[i]
  ans %= mod
As = As[::-1]
for i in range(n-k+1):
  ans += comb(n-i-1,k-1) * As[i]
  ans %= mod
print(ans)

Measured memory_bytes: 26776
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int main () {
        int x;
        cin >> x;
        long long l = 1, r = x;
        while (l <= r) {
                long long mid = (l + r) / 2;
                if ((1 + mid) * mid / 2>= x) {
                        r = mid - 1;
                } else {
                        l = mid + 1;
                }
        }
        for (int i = l - 1; ; i++) {
                if (1ll * (1 + i) * i / 2 >= x) {
                        cout << i << endl;
                        return 0;
                }
        }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b, d, ans;
  while (scanf("%d%d", &a, &b) != EOF) {
    d = a + b;
    ans = 1;
    while (d /= 10) ans++;
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 1916
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

ll gcd(ll(a), ll(b)) {
	ll k = a;
	ll l = b;
	ll j = 0;
	while (l != 0) {
		j = k % l;
		k = l;
		l = j;
	}
	return k;
}



int main() {

	ll N;
	cin >> N;
	vector<ll> vec(N);
	vector<ll> su(N);
	ll an = 0;
	for (ll i = 0; i < N; i++) {
		cin >> vec.at(i);
		an += vec.at(i);
		su.at(i) = an;

	}
	ll s = 9999999999999999;
	
	for (ll i = 0; i < N-1; i++) {
		s = min(s, abs(2 * su.at(i) - su.at(N - 1)));
	}
	cout <<s<< endl;
	
	
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 500005
const long double PI = acos(-1);

int n,v[Nmax];
ll sum = 0;
string s;

int get(int x){
    if (v[x]) return v[x];
    if (x==0){
        if (s[0] == '<') v[x] = 1;
        else{
            v[x] = get(x+1) + 1;
        }
        return v[x];
    }
    if (x==n){
        if (s[n-1] == '>') v[x] = 1;
        else{
            v[x] = get(x-1) + 1;
        }
        return v[x];
    }

    // dbg(x,s[x-1],s[x+1]);
    if (s[x-1] == '<' && s[x] == '>'){
        v[x] = max(get(x-1), get(x+1)) + 1;
    }
    else if (s[x-1] == '>' && s[x] == '<'){
        v[x] = 1;
    }
    else if (s[x-1] == '<'){
        v[x] = get(x-1) + 1;
    }
    else{
        v[x] = get(x+1) + 1;
    }
    return v[x];
}

int main(){
    ios::sync_with_stdio(false);
    cin >> s;
    n = s.size();
    for (int i=0;i<=n;i++){
        if (!v[i]) get(i);
    }
    for (int i=0;i<=n;i++){
        sum += v[i];
    }
    // dbg_v(v,n);
    cout << sum - n - 1 << '\n';
    return 0;
}

Measured memory_bytes: 26268
n=int(input())
s=[]
p=[]
for i in range(n):
    si,pi=input().split()
    s.append(si)
    p.append(int(pi))
ans=[0]*n
for i in range(n-1):
    for j in range(i+1,n):
        if s[i]>s[j]:
            ans[i]+=1
        elif s[i]<s[j]:
            ans[j]+=1
        else:
            if p[i]<p[j]:
                ans[i]+=1
            else:
                ans[j]+=1
z=[0]*n
for i in range(n):
    z[ans[i]]=(i+1)
for i in range(n):
    print(z[i])

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

int h, w, vis[20][20];
string gr[20];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> h >> w;
	for(int i = 0; i < h; i++) cin >> gr[i];
	int mx = 0;
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++){
			if(gr[i][j] == '#') continue;
			for(int k = 0; k < h; k++)
				for(int l = 0; l < w; l++) vis[k][l] = -1;
			queue<tuple<int, int, int>> que;
			que.push(make_tuple(i, j, 0));
			while(!que.empty()){
				int a, b, c;
				tie(a, b, c) = que.front();
				que.pop();
				if(vis[a][b] != -1) continue;
				vis[a][b] = c;
				int ii[] = {-1, 0, 1, 0}, jj[] = {0, -1, 0, 1};
				for(int k = 0; k < 4; k++)
					if(a + ii[k] >= 0 && a + ii[k] < h && b + jj[k] >= 0 && b + jj[k] < w && vis[a + ii[k]][b + jj[k]] == -1 && gr[a + ii[k]][b + jj[k]] == '.') que.push(make_tuple(a + ii[k], b + jj[k], c + 1));
			}
			for(int k = 0; k < h; k++)
				for(int l = 0; l < w; l++) mx = max(mx, vis[k][l]);
		}
	cout << mx << "\n";
	return 0;
}

Measured memory_bytes: 256
char m[20][21],s[101];
char direc[5]="^v<>";

solve(h,w,n){
  int i,j,x,y,d;
  char *p;
  for(i=0;i<h;i++)
    for(j=0;j<w;j++)
      if(p=strchr(direc,m[i][j])){
        y=i;x=j;
        d=p-direc;
        m[i][j]='.';
        break;
      }
  for(j=0;j<n;j++)
    switch(s[j]){
      case 'U':
        d=0;if(y>0  &&m[y-1][x]=='.')y--;break;
      case 'D':
        d=1;if(y<h-1&&m[y+1][x]=='.')y++;break;
      case 'L':
        d=2;if(x>0  &&m[y][x-1]=='.')x--;break;
      case 'R':
        d=3;if(x<w-1&&m[y][x+1]=='.')x++;break;
      case 'S':
        switch(d){
          case 0:
            for(i=y-1;~i;i--){
              if(m[i][x]=='#')break;
              if(m[i][x]=='*'){m[i][x]='.';break;}
            }break;
          case 1:
            for(i=y+1;i<h;i++){
              if(m[i][x]=='#')break;
              if(m[i][x]=='*'){m[i][x]='.';break;}
            }break;
          case 2:
            for(i=x-1;~i;i--){
              if(m[y][i]=='#')break;
              if(m[y][i]=='*'){m[y][i]='.';break;}
            }break;
          case 3:
            for(i=x+1;i<w;i++){
              if(m[y][i]=='#')break;
              if(m[y][i]=='*'){m[y][i]='.';break;}
            }break;
        }
        break;
    }
  m[y][x]=direc[d];
  for(i=0;i<h;i++)
    printf("%s\n",m[i]);
}

main(){
  int c,h,w,n,i;
  scanf("%d",&c);
  for(;c;c--){
    scanf("%d%d",&h,&w);
    for(i=0;i<h;i++)
      scanf("%s",m[i]);
    scanf("%d%s",&n,s);
    solve(h,w,n);
    if(c>1)puts("");
  }
}

Measured memory_bytes: 588
N = int(input())
L = list(map(int, input().split()))

check = 0

for i in range(N):
    L_tmp = L[i]
    L_sum_tmp = sum(L) - L_tmp
    if L_sum_tmp <= L_tmp:
        check = 1

if check == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
/*#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")*/
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define rrep(i, n) for (i32 i = (i32)(n) - 1; 0 <= (i32)(i); i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64, i64>;

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string s;
    cin >> s;
    i64 n = s.size();
    vector<i32> a(n + 1, 0);
    rep(i, n) {
        if (s[i] == '<')a[i + 1] = max(a[i + 1], a[i] + 1);
    }
    rrep(i, n) {
        if (s[i] == '>')a[i] = max(a[i], a[i + 1] + 1);
    }
    i64 ans = 0;
    rep(i, n + 1) {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 7332
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

vector<int> g[100000];
map<int, P> mp;
map<P, int> ans;

void dfs(int v, int p, int c) {
  int color = 1;
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (to == p) continue;
    if (color == c) color++;
    ans[P(v, to)] = color;
    dfs(to, v, color);
    color++;
  }
}

int main() {
  int n;
  cin >> 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);
    mp[i] = P(a, b);
  }
  dfs(0, -1, 0);
  int mx = 0;
  for (int i = 0; i < n - 1; ++i) {
    mx = max(mx, ans[mp[i]]);
  }
  cout << mx << endl;
  for (int i = 0; i < n - 1; ++i) {
    cout << ans[mp[i]] << endl;
  }
  return 0;
}

Measured memory_bytes: 18560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

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

    long long li1 = 1;
    long long li2 = 2;
    long long li = 3;
    for (long long i = 0; i < N-1; i++)
    {
        li = li1 + li2;
//        cout << li1<< "+" << li2 << "=" <<li << endl;
        li2 = li1;
        li1 = li;
    }
    if(N == 1) li = 1;
    cout << li << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
 
using namespace std;
int main()
{
 
 int a,b,c;
 cin>>a>>b>>c;
 int z=a+b+c;
 if(z>21){
    cout<<"bust"<<endl;
 }
 else cout<<"win"<<endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  long h, w;
  scanf("%ld %ld", &h, &w);
  
  if (h == 1 || w == 1)
  {
    printf("1");
    return 0;
  }
  
  long ans;
  ans = h * w / 2;
  if (h % 2 == 1 && w % 2 == 1)
  {
    ans++;
  }
  printf("%ld", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    vector<int> ans(n);
    rep(sv, n){
        vector<int> dist(n, -1);
        queue<int> q;
        auto push = [&](int v, int d){
            if(dist[v] != -1) return;
            dist[v] = d;
            q.push(v);
        };
        push(sv, 0);
        while(!q.empty()){
            int v = q.front(); q.pop();
            int d = dist[v];
            if(v+1 < n) push(v+1, d+1);
            if(v-1 >= 0) push(v-1, d+1);
            if(v == x) push(y, d+1);
            if(v == y) push(x, d+1);
        }
        rep(i, n) ans[dist[i]]++;
    }
    rep(i, n) ans[i] /= 2;
    for (int i = 1; i <= n-1; i++)
    {
        cout << ans[i] << endl;
    }
    

    return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999


int main(void){
    int N,H,W;
    scanf("%d %d %d", &N, &H, &W);

    int ans;

    ans=(N-W+1)*(N-H+1);

    printf("%d\n",ans);
    
    return 0;
    
}


Measured memory_bytes: 128
#include<stdio.h>
int n[300000];
int main(void){
    int i;
    int tim;
    int nin;
    int ans;
    int d;
    for(i=0;i<300000;i++){
        n[i]=-1;
    }
    scanf("%d %d",&nin,&tim);
    for(i=0;i<nin;i++){
        scanf("%d",&n[i]);
    }
    ans=n[nin-1]+tim;
    for(i=1;i<nin;i++){
        d=n[i]-n[i-1];
        if(d>tim){
            ans-=d-tim;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=998244353;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n;cin>>n;
    vi x(n),y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
        if(x[i]>y[i])swap(x[i],y[i]);
    }
    vp s;
    P a=P(inf,inf),b=P(-inf,inf);
    rep(i,n)chmin(a,P(x[i],i));
    rep(i,n)chmax(b,P(y[i],i));
    ll rmi=a.fi,rma=b.fi,bmi=min(y[a.se],x[b.se]),bma=max(y[a.se],x[b.se]);
    rep(i,n)if(i!=a.se&&i!=b.se)s.eb(x[i],y[i]);
    sort(all(s));
    sort(all(x));sort(all(y));
    ll ans=(x[n-1]-x[0])*(y[n-1]-y[0]);
    ll ma=-inf,mi=inf;
    rep(i,s.size()){
        ll maa=max(bma,max(s[s.size()-1].fi,ma)),mii=min(bmi,min(s[i].fi,mi));
        chmin(ans,(maa-mii)*(rma-rmi));
        chmax(ma,s[i].se);
        chmin(mi,s[i].se);
    }
    out(min(ans,(rma-rmi)*(max(ma,bma)-min(mi,bmi))));
}

Measured memory_bytes: 9584
//120 C - Christmas Eve
#include <bits/stdc++.h>
using namespace std;
int n,k,h[123456],v=999999999,a;
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>h[i];
	sort(h,h+n);
	
	for(int i=0;i<n-k+1;i++){
		a=h[i+k-1]-h[i];
		if(v>a)v=a;
	}
	cout<<v<<endl;
}


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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll A, B, C, X, Y;

ll cost(ll p, ll q, ll r) {
  return A * p + B * q + C * 2 * r;
}

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> A >> B >> C >> X >> Y;
  
  if (X < Y) {
    swap(X, Y);
    swap(A, B);
  }
  ll ans = cost(0, 0, X);
  ans = min(ans, cost(X, Y, 0));
  ans = min(ans, cost(X-Y, 0, Y));
  cout << ans << endl;
  return 0;
}



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

int main() {
int X;
cin >> X;

int maisuu_500 = X/500;

if(X%500==0){
cout<<maisuu_500*1000<<endl;
}else{
int goukei_500 = maisuu_500*500;
int janai_500 = X-goukei_500;
int goukei_5 =  janai_500/5;
cout<<maisuu_500*1000+goukei_5*5<<endl;
}


	
	return 0;
}

Measured memory_bytes: 256
import sys 
from collections import Counter
input = sys.stdin.readline
n = int(input())
m = int(n**0.5)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
            
    if n != 1:
        a.append(n)
    return a

if n == 1:
    ans = 0
else:
    ans = 0
    a = prime_factorize(n)
    c = Counter(a)
    for val in c.values():
        j = 1
        while j*(j+1)//2 <= val:
            j += 1
        ans += j-1
print(ans)

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

int main() {
  int n,ans = 0,preans = 0;
  cin >> n;
  vector<long long>data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  for(int i = 0;i < n-1;i++){
    if(data.at(i) >= data.at(i+1)){
      preans++;
    }
    else{
      if(preans > ans){
        ans = preans;
      }
      preans = 0;
    }
    if(i == n-2 && preans > ans){
      ans = preans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var dp []int64

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}
func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)
	aList := make([]int, n)
	hList := make([]int, n)
	h := strings.Split(getNextLine(scanner), " ")
	a := strings.Split(getNextLine(scanner), " ")
	for i := 0; i < n; i++ {
		fmt.Sscan(h[i], &hList[i])
	}
	for i := 0; i < n; i++ {
		fmt.Sscan(a[i], &aList[i])
	}

	segSize := 1
	for segSize < n {
		segSize = segSize << 1
	}
	dp = make([]int64, segSize*2)
	for i := 0; i < n; i++ {
		dp[segSize-1+hList[i]-1] = int64(aList[i]) + query(0, hList[i]-1, 0, 0, segSize)
		update(segSize - 1 + hList[i] - 1)
	}
	fmt.Println(query(0, n, 0, 0, n))
}

func query(a int, b int, k int, l int, r int) int64 {
	if b <= l || r <= a {
		return int64(0)
	}
	if a <= l && r <= b {
		return dp[k]
	}
	vl := query(a, b, k*2+1, l, (l+r)/2)
	vr := query(a, b, k*2+2, (l+r)/2, r)
	if vl < vr {
		return vr
	}
	return vl
}

func update(i int) {
	for i > 0 {
		i = (i - 1) / 2
		dp[i] = dp[i*2+1]
		if dp[i] < dp[i*2+2] {
			dp[i] = dp[i*2+2]
		}
	}
}


Measured memory_bytes: 32128
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    a, b, c, d = LI()
    while a > 0 and c > 0:
        c -= b
        if c <= 0:
            print('Yes')
            break
        a -= d
        if a <= 0:
            print('No')
    return


# Solve
if __name__ == "__main__":
    solve()


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

int main() {
	// vector<int> vec;
	int n;
	cin >> n;
	int maxNum = 0;
	int sum = 0;
	for(int i = 0; i < n; i++) {
		int curr;
		cin >> curr;
		maxNum = max(maxNum, curr);
		sum += curr;
		// vec.push_back(curr);
	}
	sum -= (maxNum/2);
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define xy          exit(0);
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll gc(ll a,ll b,ll c)
{
	ll x=__gcd(a,b);
	return __gcd(x,c);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,m,b,d,x,a,h,l,r,n,p,q,c,ans;
    	cin>>n;
    	b=0;
    	repi(i,1,n)
    	{
    		repi(j,1,n)
    		{
    			repi(k,1,n)
    			b+=gc(i,j,k);
			}
		}
    	cout<<b;
    	
    	
    	
    }
	return 0;
}

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

int main() {
	int n;
	scanf("%d", &n);
	int a[n];
	int ans = 1;
	scanf("%d", &a[0]);
	for(int i = 1; i < n; i++) {
		scanf("%d", &a[i]);
		int j = 0;
		for(j = 0; j < i; j++) {
			if(a[j] > a[i]) break;
		} if(i == j) ans++;
	} cout << ans;
	return 0;
}

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

int main()
{
 	int n; cin >> n;set<int> s;
  for(int i = 0; i < n; ++i) 
  {
    int num; cin >> num; s.insert(num);
  }
  int m = s.size();
  if(m == n) cout << "YES";
  else cout << "NO";
  return 0;
}

Measured memory_bytes: 12948
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int p,q;
  while(cin>>p>>q&&p+q){
    vector<int> a,b,c,d;
    for(i=1;i<(int)sqrt(p)+1;i++){
      if(p%i==0){
	a.push_back(i);
	b.push_back(p/i);
      }
    }
    for(i=1;i<(int)sqrt(q)+1;i++){
      if(q%i==0){
	c.push_back(i);
	d.push_back(q/i);
      }
    }
    int e[4];
    unsigned mn=-1;
    for(i=0;i<(int)a.size();i++){
      for(j=0;j<(int)c.size();j++){
	e[0]=a[i];
	e[1]=b[i];
	e[2]=c[j];
	e[3]=d[j];
	sort(e,e+4);
	mn=min(mn,(unsigned)pow(e[1]-e[0],2)+(unsigned)pow(e[2]-e[1],2)+(unsigned)pow(e[3]-e[2],2));
      }
    }
    cout<<mn<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
/* Properties of modulo:Fermat's little theorem
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define ll long long
#define pb push_back
#define gcd __gcd
#define nl cout<<"\n"
#define endl "\n"
#define rep(i,n) for(ll i = 0 ; i < n ; i++)
#define fo(i,a,b) for(ll i = a ; i <= b ; i++)
#define foi(i,a,b) for(ll i = a ; i >= b ; i--)
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define lb lower_bound
#define ub upper_bound
//sorting in reverse order
bool compare(ll x, ll y){
    return x>y;
}
// checking whether a number is prime or not
ll isprime(ll n){
    if(n==1) return 0;
    else if(n==2) return 1;
    else{
        for(ll i=2;i<=sqrt(n);i++){
            if(n%i==0) return 0;
        }
    return 1;   
    }
}
// returning vector containing all prime numbers less than a given number
vector<ll> get_prime_factors_less_than(ll n){
    vector<ll> factor;
    vector<ll> prime(n,1);
    prime[0]=0,prime[1]=0;
    for(ll i = 2 ; i <= n ; i++){
        if(prime[i]==1){
            for(ll j=i*i;j<=n;j=j+i) prime[j]=0; 
            factor.push_back(i);
        }
    }
    return factor;
}
//returns x^y in order logn 
ll power(ll x, ll y) { 
    if (y == 0) return 1; 
    ll a = power(x,y/2);
    if (y % 2 == 0) return a * a; 
    else return x * a * a; 
} 
int main(){
    IOS;
    ll test,i;
    test = 1;
    //cin>>test;
    while(test--){
        ll n;
        cin>>n;
        map<ll ,ll >m;
        rep(i , n - 1){
            ll a;
            cin>>a;
            m[a]++;
        }  
        fo(i , 1 , n){
            cout<<m[i]<<endl;
        }
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    if(m == 1) {
        cout << 1 << " " << 2 << endl;
        return 0;
    }
    ll now = n;
    if(n % 2 == 1) {
        for(i = 0; i < m; i++) {
            if(now - (i + 1) - 1 == n - now + i) now--;
            cout << i + 1 << " " << now << endl;
            now--;
        }
    }else{
        ll f=0;
        for(i=0;i<m;i++){
            if(f==0 && now-i-2<n/2)now--,f=1;
            cout << i + 1 << " " << now << endl;
            now--;
        }
    }
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;

long int a,b,v,w,t;
long long int xa,xb;

int main(){
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    if( b > a){
        xa = v*t + a;
        xb =  w*t + b;
        if(xa >= xb ) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    else{
        xa = -v*t + a;
        xb = -w*t + b;
        if(xb >= xa) cout << "YES" << endl;
        else cout << "NO" << endl;
    }



return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a>=k) cout << k << endl;
  else if (a+b>=k)  cout << a << endl;
  else  cout << a-(k-a-b) << endl;
  return 0;
}


Measured memory_bytes: 3596
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int a[1024];
	int b[10];
	int c[10];
	bool used[10];
	int n, k;
	int x, y, z;
	int ans, s;
	ans = 1000000000;
	scanf("%d %d", &n, &k);
	f(i, n){
		scanf("%d %d", &c[i],&x);
		b[i] = (c[i] * (i + 1) * 100) + x;
	}
	s = 1 << n;
	f(kk, s ){
		x = kk;
		y = 0;
		z = 0;
		f(i, n){
			f(j, 10)used[i] = false;
			if (x % 2 == 1){
				y += c[i];
				z += b[i];
				used[i] = true;
			}
			x = x / 2;
		}
		if (z < k){
			f(i, n){
				if (!used[n - i - 1]){
					f(j, c[n - i - 1]){
						z += 100 * (n - i);
						y++;
						if (z >= k){
							ans = min(ans, y);
							break;
						}
					}
					if (z >= k){
						ans = min(ans, y);
						break;
					}
				}
			}
		}
		if (z >= k){
			ans = min(ans, y);
		}
	}

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


	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (n, p) = readLine()!!.split(' ').map { it.toInt() }
    val s = readLine()!!
    var ans = 0L
    when(p) {
        2,5 -> {
            for (i in s.indices) {
                val d = s[i] - '0'
                if (d % p == 0) {
                    ans += i + 1
                }
            }
        }
        else -> {
            var pow = 1
            var div = 0
            val m = LongArray(p)
            m[0] = 1
            for (i in s.length - 1 downTo 0) {
                val d = s[i] - '0'
                div = (div + pow * d) % p
                pow = (pow * 10) % p
                m[div]++
            }
            repeat(p) {
                if (m[it] > 1) {
                    ans += m[it] * (m[it] - 1) / 2
                }
            }
        }
    }
    println(ans)
}


Measured memory_bytes: 39664
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define mp(x,y) 	     make_pair(x,y)
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto& i: a)
#define loop(n,i,a)      for(int i=a;i<n;i++)
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        loop(n,i,0){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i;
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define pp               pop_back
#define endl              "\n"
#define copy(a,b)         copy(all(a),back_inserter(b));
#define intersect(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
//int m=10000009;
//int arr[100000];
#define M 					1000000007 
int isprime(int n)
{
        if(n<=1) return 0;
        if(n<=3) return 1;
        if(n%2==0 ||n%3==0)
        return 0;
    for(int i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)
        return 0;
    }
    return 1;
}
signed main(){
				fast
				//	freopen("input.txt","r",stdin);
				//	freopen("output.txt","w",stdout);
				int n;
				cin>>n;
				int ans=10000000000000;
				for (int i=1; i<=sqrt(n); i++) 
   				{ 
        		if (n%i == 0) 
        		{ 
                if (n/i == i) 
                {
                	if(abs(n/i-1)+abs(i-1) < ans)
                		ans = abs(i-1) + abs(i-1);
                }
  				else 
                {
                	if(abs(n/i-1)+abs(i-1) < ans)
                		ans = abs(n/i-1) + abs(i-1);
                }
        		} 
    			}
    			cout<<ans;
			}
			
				
		
		 
		 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j;
	string str;
	cin>>str;
	for(i=0;i<str.size();i++)
		if(str[i]=='C')
			for(j=i+1;j<str.size();j++)
				if(str[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int H1,H2,M1,M2,K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int pre,aft;
  pre = 60*H1 + M1;
  aft = 60*H2 + M2;
  int ans = aft - pre - K;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636