akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

void _main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    cin >> A >> B >> C;
    SORT(A);
    SORT(B);
    SORT(C);
    int ans = 0;
    REP(i, N) {
        int a = LBP(A, B[i]);
        int c = N - UBP(C, B[i]);
        ans += a * c;
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 2812
#include <stdio.h>

int main(){
  int i, j, N, v;
  int A[100];

  scanf("%d",&N);
  for(i = 0; i < N; i++)scanf("%d",&A[i]);

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

  for(i = 1; i < N; i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(j = 0; j < N; j++){
      printf("%d",A[j]);
      if(j < N-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}




Measured memory_bytes: 2068
#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 FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  if (n % 2 == 1) {
    int left = -1, right = inf;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      int cnt = 0;
      rep(i, n) {
        if (a[i] <= mid) cnt++;
      }
      if (cnt >= n / 2 + 1) right = mid;
      else left = mid;
    }
    int minv = right;
    rep(i, n) {
      a[i] = inf - a[i];
      b[i] = inf - b[i];
      swap(a[i], b[i]);
    }
    left = -1, right = inf;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      int cnt = 0;
      rep(i, n) {
        if (a[i] <= mid) cnt++;
      }
      if (cnt >= n / 2 + 1) right = mid;
      else left = mid;
    }
    int maxv = inf - right;
    cout << maxv - minv + 1 << '\n';
  }
  else {
    int left = -1, right = inf;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      int cnt = 0;
      rep(i, n) {
        if (a[i] <= mid) cnt++;
      }
      if (cnt >= n / 2) right = mid;
      else left = mid;
    }
    int minv1 = right;
    left = -1, right = inf;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      int cnt = 0;
      rep(i, n) {
        if (a[i] <= mid) cnt++;
      }
      if (cnt >= n / 2 + 1) right = mid;
      else left = mid;
    }
    int minv2 = right;
    rep(i, n) {
      a[i] = inf - a[i];
      b[i] = inf - b[i];
      swap(a[i], b[i]);
    }
    left = -1, right = inf;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      int cnt = 0;
      rep(i, n) {
        if (a[i] <= mid) cnt++;
      }
      if (cnt >= n / 2) right = mid;
      else left = mid;
    }
    int maxv2 = inf - right;
    left = -1, right = inf;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      int cnt = 0;
      rep(i, n) {
        if (a[i] <= mid) cnt++;
      }
      if (cnt >= n / 2 + 1) right = mid;
      else left = mid;
    }
    int maxv1 = inf - right;
    //cout << minv1 << ' ' << minv2 << ' ' << maxv1 << ' ' << maxv2 << '\n';
    int minv = minv1 + minv2;
    int maxv = maxv1 + maxv2;
    //cout << minv << ' ' << maxv << '\n';
    cout << maxv - minv + 1 << '\n';
  }







  
  return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(void){
    // Here your code !
    
    map<char,char> m;
    m['b'] = 'd';
    m['d'] = 'b';
    m['q'] = 'p';
    m['p'] = 'q';
    
    string str;
    cin >> str;
    
    for(int i = 0; i < str.size(); i++){
        if( str[str.size() - i - 1] != m[str[i]]){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    
}


Measured memory_bytes: 512
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        final int n = Integer.parseInt(line[0]);
        final int m = Integer.parseInt(line[1]);
        final int l = Integer.parseInt(line[2]);
        long[][] A = new long[n][m];
        long[][] B = new long[m][l];
        long[][] C = new long[n][l];
        
        for (int i=0; i<n; i++){
            String[] tmp= br.readLine().split(" ");
            for (int j=0; j<m; j++){
                long num = Long.parseLong(tmp[j]);
                A[i][j] = num;
            }
        }
        for (int i=0; i<m; i++){
            String[] tmp= br.readLine().split(" ");
            for (int j=0; j<l; j++){
                long num = Long.parseLong(tmp[j]);
                B[i][j] = num;
            }
        }
        for (int i=0; i<n; i++){
            for (int j=0; j<m; j++){
                for (int k=0; k<l; k++){
                    C[i][k] += A[i][j]*B[j][k]; 
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<n; i++){
            for (int j=0; j<l-1; j++){
                sb.append(C[i][j]+" ");
            }
            sb.append(C[i][l-1]+"\n");
        }
        System.out.print(sb.toString());
    }
}

Measured memory_bytes: 28764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

char tx[1006][1006];
char pt[106][106];
char qt[106][106];

int decode(char c){
	if(isupper(c)) return c-'A';
	if(islower(c)) return c-'a'+26;
	if(isdigit(c)) return c-'0'+52;
	return c=='+' ? 62 : 63;
}

void rotate(int p){
	memcpy(qt, pt, sizeof(pt));
	for(int i=0;i<p;i++)
		for(int j=0;j<p;j++)
			pt[i][j] = qt[p-j-1][i];
}

int main(){
	int w, h, p;
	while(cin >> w >> h >> p, w){
		for(int i=0;i<h;i++){
			string str; cin >> str;
			for(int j=0;j<(w+5)/6;j++){
				int tmp = decode(str[j]);
				for(int k=0;k<6;k++) tx[i][6*j+k] = ((tmp>>(5-k))&1)+'0';
			}
		}
		for(int i=0;i<p;i++){
			string str; cin >> str;
			for(int j=0;j<(p+5)/6;j++){
				int tmp = decode(str[j]);
				for(int k=0;k<6;k++) pt[i][6*j+k] = ((tmp>>(5-k))&1)+'0';
			}
		}
		if(p > w || p > h){
			cout << 0 << endl;
			continue;
		}
		vector< vector<unsigned int> > pat(8, vector<unsigned int>(p, 0));
		for(int i=0;i<4;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<p;k++){
					for(int l=0;l<p;l++){
						pat[2*i+j][k] = pat[2*i+j][k]*101+pt[k][j==0 ? l : p-1-l];
					}
				}
			}
			rotate(p);
		}
		sort(pat.begin(), pat.end());
		pat.erase(unique(pat.begin(), pat.end()), pat.end());
		unsigned int mul = 1;
		vector<int> hash(h, 0);
		for(int i=0;i<h;i++){
			for(int j=0;j<p;j++){
				hash[i] = (hash[i]*101+tx[i][j]);
				if(i==0) mul *= 101;
			}
		}
		int res = 0;
		for(int i=p;i<=w;i++){
			for(int j=0;j<pat.size();j++){
				for(int k=0;k+p-1<h;k++){
					bool flag = true;
					for(int l=0;l<p;l++){
						if(hash[k+l] != pat[j][l]){
							flag = false;
							break;
						}
					}
					if(flag) res++;
				}
			}
			if(i!=w)
				for(int j=0;j<h;j++){
					hash[j] = hash[j]*101-tx[j][i-p]*mul+tx[j][i];
				}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1944
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	int now = 1, ans = 0;
	for(int i = 0; i < n; i++) {
		if(a[i] == now) {
			now++;
		} else {
			ans++;
		}
	}
	
	if(now == 1) printf("-1\n");
	else printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 6LL * 1e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e5 + 100;



int cnt[10][10];
signed main() {
	speed;
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		string s = to_string(i);
		int x = s[0] - '0', y = s.back() - '0';
		ans += 2*cnt[x][y];
		cnt[y][x]++;
		if (x == y) {
			++ans;
		}
	}
	cout << ans;
	return 0;
}

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

int main() {
  int a,b;
  char x;
  while(1){
      cin >> a >> x >> b;
      if(x == '?') break;
      else if(x == '+') cout << a+b << endl;
      else if(x == '-') cout << a-b << endl;
      else if(x == '*') cout << a*b << endl;
      else cout << a/b << endl;
  }
}



Measured memory_bytes: 3084
#include<stdio.h>

int main(){
    int sum_alice = 0;
    int sum_bob = 0;
    int num = 0;
    int num_cards = 0;

    
    scanf("%d\n",&num_cards);

    int cards[num_cards];

    for(int i=0; i<num_cards; i++){
        scanf("%d",&cards[i]);
    }

    // bubble sort
    for(int j=0; j<num_cards;j++ ){
        for(int i=0; i<num_cards-(j+1); i++){
            if(cards[i] < cards[i+1]){
                num = cards[i];
                cards[i] = cards[i+1];
                cards[i+1] = num;
            }
        }
    }

    // for testing confirm bubble sort 
    // for(int c=0;c<num_cards;c++){
    //     printf("%d\n",cards[c]);
    // }

    for(int k=0; k<num_cards; k++ ){
        if(k%2 == 0){
            sum_alice = sum_alice + cards[k];
        }else{
            sum_bob = sum_bob + cards[k];
        }
    }

    printf("%d\n",sum_alice-sum_bob);

    return 0;
}

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

int main(){
    int a, b;
    char op;
    scanf("%d %c %d",&a, &op, &b);
    int res;
    if(op == '+') res = a + b;
    if(op == '-') res = a - b;
    printf("%d\n", res);
    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	char ss[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	for(int i=0;i<s.size();i++){
		int idx = s[i]-'A';
		cout << ss[(idx+n)%26];
	}
	cout << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  sort(all(a));
  reverse(all(a));
  // Here, a is decreasing order.

  auto check = [&](ll m) {
    // Here, max length is m. we caount all by m.
    ll now = 0;
    rep(i,n) {
      ll cnt = (a[i]+(m-1)) / m;
      now += cnt;
    }
    // Here, we cant make now or more.
    return now <= n+k;
  };

  ll l = 0;
  ll r = 1e9+1;
  // Here, we want minimum.
  while (r-l > 1) {
    ll m = (r+l)/2;
    if (check(m)) { // ok
      r = m;
    } else {
      l = m;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 4692
#include <algorithm>
#include <bits/stdc++.h>
#include <cctype>

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

using namespace std;

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

  bool ok = true;
  rep(i, s.size()) {
    if (i == a) {
      if (s[a] != '-') {
        ok = false;
        break;
      } else {
        continue;
      }
    }
    if (!isdigit(s[i])) {
      ok = false;
      break;
    }
  }

  std::cout << (ok ? "Yes" : "No") << std::endl;
  return 0;
}


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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpv(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) c.begin(), c.end()
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

signed main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b == c || b + c == a || c + a == b)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int64_t N;
cin >> N;
int ha = 0;
int ex = N;
while (ex > 0) {
  ha = ha + ex % 10;
  ex /= 10;
}
if (N % ha == 0) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}


Measured memory_bytes: 256
# ALDS1_4_B.
# バイナリサーチ。

def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def binary_search(S, k):
    a = 0; b = len(S) - 1
    if b == 0: return S[0] == k
    while b - a > 1:
        c = (a + b) // 2
        if k <= S[c]: b = c
        else: a = c
    return S[a] == k or S[b] == k
    
def main():
    n = int(input())
    S = intinput()
    q = int(input())
    T = intinput()
    count = 0
    for k in T:
        if binary_search(S, k): count += 1
    print(count)

    
if __name__ == "__main__":
    main()


Measured memory_bytes: 13504
#include <iostream>
#include <string>
using namespace std;
int main(){
	char buf[100];
	int len;
	scanf("%d", &len);
	scanf("%s", buf);
	string st = buf;
	int count = 0, pos = -1;
	while(1){
		pos = st.find("ABC", pos+1); 
		if(pos != string::npos)	count++;
		else break;
	}
	printf ("%d\n", count);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(ll n, ll r){
    if(n>=10){
        cout<<r<<endl;
    }else{
        cout<<r+100*(10-n)<<endl;
    }
}

int main(){
    ll n;
    scanf("%lld",&n);
    ll r;
    scanf("%lld",&r);
    solve(n, r);
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Msi = M<string, int>;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
    int n, k, q;
    cin >> n >> k >> q;
    Vi cnt(n+1, 0);
    REP(i, q) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    REP2(i, 1, n+1) {
        if (k + cnt[i] - q > 0) {
            std::cout << "Yes" << '\n';
        } else {
            std::cout << "No" << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define rep(i,s,n) for(int i=s;i<n;i++)

using namespace std;

int main() {
	int a[3][3], n, i, j, abs;

	rep(i,0,3) {
		rep(j,0, 3) {
			cin >> n;
			a[i][j] = n;
		}
	}

	rep(i,0, 3) {
		abs = a[i][0] - a[(i+1)%3][0];
		rep(j, 1, 3) {
			if (abs != a[i][j] - a[(i + 1) % 3][j]) {
				cout << "No";
				return 0;
			}
		}
		
	}
	rep(j, 0, 3) {
		abs = a[0][j] - a[0][(j + 1) % 3];
		rep(i, 1, 3) {
			if (abs != a[i][j] - a[i][(j + 1) % 3]) {
				cout << "No";
				return 0;
			}
		}
	}

	cout << "Yes";

	return 0;
}

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

vector<string> f;
void init(){
  f.clear();
}

int input(){
  int w,h;
  cin>>w>>h;
  if(w==0&&h==0)return false;
  string s;
  for(int i=0;i<h;i++){
    cin>>s;
    f.push_back(s);
  }
  return true;
}

int vx[] = {0,0,1,-1};
int vy[] = {1,-1,0,0};

int rec(int x,int y){
  if(x<0||f.size()<=x)return 0;
  if(y<0||f[x].size()<=y)return 0;
  if(f[x][y]!='.')return 0;
  f[x][y]='#';
  int res = 1;
  for(int i=0;i<4;i++){
    res += rec(x+vx[i],y+vy[i]);
  }
  return res;
}

int solve(){
  int x,y;
  for(int i=0;i<f.size();i++){
    for(int j=0;j<f[i].size();j++){
      if(f[i][j]=='@'){
        x = i;
        y = j;
        f[i][j] = '.';
      }
    }
  }
  return rec(x,y);
}

int main(){
  while(init(),input()){
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

//const int maxn = 2e5 + 7; 
//const int md = 1e9 + 7;

int main() {
	ll x,y; cin>>x>>y;
	cout<<((abs(x-y) <= 1)?"Brown":"Alice")<<endl;
}

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

const int MAXN = 100000;
int x[MAXN + 10], y[MAXN + 10], MOD = 1000 * 1000 * 1000 + 7;

int main() {
    //ios_base::sync_with_stdio(false)
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        scanf("%d", &x[i]);
    }
    for(int i = 0; i < m; i++) {
        scanf("%d", &y[i]);
    }
    sort(x, x + n);
    sort(y, y + m);
    ll sum1 = 0;
    ll sum2 = 0;
    for(int i = 1; i < n; i++) {
        sum1 += (((((ll)x[i] - x[i - 1]) * i) % MOD) * (n - i)) % MOD;
        if(sum1 >= MOD)
            sum1 -= MOD;
    }
    for(int i = 1; i < m; i++) {
        sum2 += (((((ll)y[i] - y[i - 1]) * i) % MOD) * (m - i)) % MOD;
        if(sum2 >= MOD)
            sum2 -= MOD;
    }
    //cout << sum1 << "\n";
    //cout << sum2 << "\n";
    cout << (sum1 * sum2) % MOD << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
 ll r,c,k;
  cin >> r >> c >> k;
 vvll p(r,vll(c,0));
  rep(i,0,k){
   ll x,y,v;
    cin >>x >>y >> v;
    x--;
    y--;
    p[x][y]=v;
  }
  
  vector<vvll> dp(r+1,vvll(c+1,vll(4,0)));
  
  rep(i,0,r){
   rep(j,0,c){
    repr(k,3,0) chmax(dp[i][j][k+1],dp[i][j][k]+p[i][j]);
    rep(k,0,4){
     chmax(dp[i+1][j][0],dp[i][j][k]);
     chmax(dp[i][j+1][k],dp[i][j][k]); 
    }
    }
   }
  
 cout << *max_element(all(dp[r-1][c-1])) << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
#define next asdnext
#define prev asdprev
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
signed main() {
    cin >> N;
    cout << N / 2 - 1 + N % 2 << endl;
}

Measured memory_bytes: 256
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

cnt=0
cnt2=0
for i in range(0,n):
	cnt+=b[i]	
	
for j in range(0,n-1):
	if a[j]+1==a[j+1]:
		cnt2+=c[a[j]-1]
	
print(cnt+cnt2) 

Measured memory_bytes: 3064
import sys
from bisect import bisect_left, bisect_right


def inputs(func=lambda x: x, sep=None, maxsplit=-1):
	return map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))

def input_2d_T(nrows : int, ncols : int, type=int, **kwargs):
	data = [[None] * nrows for _ in range(ncols)]
	for i in range(nrows):
		for j, v in enumerate(inputs(type)):
			data[j][i] = v
	return data

from collections import deque

N, M = inputs(int)
A, B, C = input_2d_T(N, 3)
D, E, F = input_2d_T(M, 3)
xs = sorted(set(C))
ys = sorted(set(D))

x_guard = [[False for _ in range(len(ys)+1)] for _ in range(len(xs)+1)]
y_guard = [[False for _ in range(len(ys)+1)] for _ in range(len(xs)+1)]

for a, b, c in zip(A, B, C):
	c = bisect_right(xs, c)
	a = bisect_left(ys, a) + 1
	b = bisect_right(ys, b)
	for i in range(a, b):
		x_guard[c][i] = True

for d, e, f in zip(D, E, F):
	d = bisect_right(ys, d)
	e = bisect_left(xs, e) + 1
	f = bisect_right(xs, f)
	for i in range(e, f):
		y_guard[i][d] = True

cow = (
	bisect_right(xs, 0),
	bisect_right(ys, 0)
)
nexts = deque([cow])
visited = [[0 for _ in range(len(ys)+1)] for _ in range(len(xs)+1)]
visited[cow[0]][cow[1]] = True

area = 0

while nexts:
	xi, yi = nexts.popleft()
	
	if 0 < xi < len(xs) and 0 < yi < len(ys):
		area += (xs[xi] - xs[xi-1]) * (ys[yi] - ys[yi-1])
		if not visited[xi-1][yi] and not x_guard[xi][yi]:
			visited[xi-1][yi] = True
			nexts.append((xi-1, yi))
		if not visited[xi+1][yi] and not x_guard[xi+1][yi]:
			visited[xi+1][yi] = True
			nexts.append((xi+1, yi))
		if not visited[xi][yi-1] and not y_guard[xi][yi]:
			visited[xi][yi-1] = True
			nexts.append((xi, yi-1))
		if not visited[xi][yi+1] and not y_guard[xi][yi+1]:
			visited[xi][yi+1] = True
			nexts.append((xi, yi+1))
	else:
		area = 'INF'
		break

print(area)



Measured memory_bytes: 36356
#include<bits/stdc++.h>
using namespace std;
int n,m;
char f[101][101]={0};
int check(int a,int i)
{
	int j;
	if(a==0)
	{
		for(j=0;j<m;j++)
		{
			if(f[i][j]=='#')
				return 0;
		}
		return 1;
	}
	else
	{
		for(j=0;j<n;j++)
		{
			if(f[j][i]=='#')
				return 0;
		}
		return 1;
	}
}
void remove(int a,int i)
{
	int j;
	if(a==0)
	{
		for(j=0;j<m;j++)
		{
			f[i][j]=' ';
		}
	}
	else
	{
		for(j=0;j<n;j++)
		{
			f[j][i]=' ';
		}
	}
}
int main()
{
	int i,j,t;
	scanf("%d %d",&n,&m);
	getchar();
	for(i=0;i<n;i++)
	{
		scanf("%s",f[i]);
	}
	for(i=0;i<n;i++)
	{
		if(check(0,i))
			remove(0,i);
	}
	for(j=0;j<m;j++)
	{
		if(check(1,j))
			remove(1,j);
	}
	for(i=0;i<n;i++)
	{
		t=0;
		for(j=0;j<m;j++)
		{
			if(f[i][j]!=' ')
			{
				printf("%c",f[i][j]);
				t=1;
			}
		}
		if(t)
			printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000000000000002
#define N 400003
#define endl "\n"
using namespace std;
 
int main()
{
 ll s[1000][2]={0};
  ll n,w;cin>>n>>w;
    for(ll i=0;i<n;i++)
    {
        cin>>s[i][0]>>s[i][1];
    }
      ll arr[n+1][w+1];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            if(i==0||j==0)
            {
                arr[i][j]=0;
            }
            else{
            if(s[i-1][0]<=j)
            {
                arr[i][j]=max(arr[i-1][j],s[i-1][1]+arr[i-1][j-s[i-1][0]]);
            }
            else

            {
                arr[i][j]=arr[i-1][j];
            }
            }
        }
    }
    cout<<arr[n][w]<<endl;;

    return 0;
}


Measured memory_bytes: 79104
s = input()
k = int(input())
def seqcnt(s):
    cnt=1
    ans=0
    bk=''
    for c in s+' ':
        if bk==c:
            cnt+=1
        else:
            ans+=(cnt)//2
            cnt=1
        bk=c
    return ans

cnt=seqcnt(s)
cnt2=seqcnt(s*2)    
if len(set(list(s)))==1:
    print(len(s)*k//2)
else:
    print(cnt+(cnt2-cnt)*(k-1))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vvi G(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;
    function<int(int, int)> dfs = [&](int i, int j) {
        int res = 0, rres = -1;
        for(int ne:G[i]) {
            if(ne == j) continue;
            int x = dfs(ne, i);
            if(x > res) {
                rres = res;
                res = x; 
            } else if(x > rres) {
                rres = x;
            }
        }
        chmax(ans, res+rres+1);
        return res+1;
    };
    dfs(0, -1);

    cout << (ans%3 == 2?"Second":"First") << endl;
}


Measured memory_bytes: 32100
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C;
    cin >> A >> B >> C;
    vector<int> temp;
    temp.push_back(A);
    temp.push_back(B);
    temp.push_back(C);
    sort(temp.begin(), temp.end());
    if(temp[0]==5 && temp[1]==5 && temp[2]==7){
        cout << "YES" << "\n";
    }else{
        cout << "NO" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    s = input()
    ls = len(s)
    t = input()
    if t[0] in s:
        idx = s.find(t[0])
    else:
        print(-1)
        exit()
    for i in t[1::]:
        nt = s.find(i,idx%ls+1)
        ntl = s.find(i)
        if ntl == -1:
            print(-1)
            exit()
        elif nt == -1:
            idx = (idx//ls)*ls+ls+ntl
        else:
            idx = (idx//ls)*ls+nt
    print(idx+1)
    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 9668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    int n, k;   cin >> n >>k;
    string s;   cin >> s;
    vector<ll> a;
    if(s[0]=='0') a.push_back(0);

    int cnt=1;
    REP(i, n){
        if(s[i]==s[i+1]){
            cnt += 1;
            if(i==n-1) a.push_back(cnt);
        }else{
            a.push_back(cnt);
            cnt = 1;
        }
    }
    if(s.back()=='0') a.push_back(0);
    vector<ll> sum((int)a.size()+1, 0);
    REP(i, a.size())    sum[i+1] = sum[i]+a[i];
    
    ll res=0;
    for(int left=0; left<sum.size(); left+=2){
        int right = left+2*k+1;
        if(sum.size()<=right) right = sum.size()-1;
        res = max(res, sum[right]-sum[left]);
    }
    cout << res << endl;
}

Measured memory_bytes: 2164
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (a, b, c) = InputLine.to_ia

  if c < (a + b) then
    puts 'No'
    return
  end

  s = (c ** 2) + ((a + b) ** 2)
  t = (2 * (a + b) * c) + (4 * a * b)

  if s > t then
    puts 'Yes'
  else
    puts 'No'
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner();

$n = $sc->nextInt();
$x = $sc->nextInt();
$cnt = 0 ;
$d = 0;

while ($d <= $x){
  $cnt ++ ;
  $d += $sc->nextInt();
  if ($cnt == $n + 1){break;}
}

out::println($cnt) ;



Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mod 1000000007
#define mod1 998244353
#define N 100003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
/*vbool isprime(N,true);
vll spf(N,0);
vll prime;
void sieve()
{
    isprime[0] = isprime[1] = false;
    for(ll i = 2 ; i<N ; i++)
    {
        if(isprime[i])
        {
            for(ll j=2*i ; j<N ; j+=i)
            {
                isprime[j] = false;
                if(spf[j]==0)
                {
                    spf[j] = i;
                }
            }
            prime.pb(i);
        }
    }
}*/
ll nck(ll n , ll k ,ll m=1e18+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}
long long power(long long k , long long n , long long m=mod)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v , ll a = 0)
{
    //ll a ;
    for(ll i=a ; i<v.size() ; i=i+1)
    {
        v[i] = max((ll)0,v[i]);
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
ll n,m,k;
bool ok = true;
int main()
{
    FastIO ;
    PRECISION ;
    ll a,b,c,d,e,i,j,t,x,y,z,x1,y1,z1,f;
    //double p,q,r,u,w ;
    char ch,chr ;
    //string str,st,str2,str3;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>n;
    vll v;
    READ(v,n-1);
    vll cnt(n+1,0);
    for(i=0 ; i<n-1 ; i++)
    {
        cnt[v[i]]++;
    }
    for(i=1 ; i<n+1 ; i++)
    {
        cout<<cnt[i]<<"\n";
    }
}

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

int main() {
	int n;
	cin >> n;
	vector<int> t(n+1), x(n+1), y(n+1);
	rep(i, n) cin >> t[i+1] >> x[i+1] >> y[i+1];
	t[0] = 0; x[0] = 0; y[0] = 0;
	string ans = "Yes";
	rep(i, n+1) {
		if(i==0) continue;
		int time = t[i] - t[i-1];
		int pre = x[i-1] + y[i-1];
		int now = x[i] + y[i];
		if(time < abs(pre - now)) {
			ans = "No";
			break;
		} 
		if(time%2 != abs(pre - now)%2) {
			ans = "No";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
 string S;
  cin >> S;
  if (S=="Sunny") cout << "Cloudy" <<endl;
  if (S=="Cloudy") cout << "Rainy" <<endl;
  if (S=="Rainy") cout << "Sunny" <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int A,B,C;
    int X;
    int i,j,k,count = 0;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&X);

    for (i = A;i >= 0;i--){
        for(j = B;j >= 0;j--){
            for(k = C;k >= 0;k--){
                /*printf("%d\n",500 * i + 100 * j + 50 * k);*/
                if(X == 500 * i + 100 * j + 50 * k) count++;
                
            }
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
//Name : Rupa Dey
  //Date : 17 September 2020 //Shuvo mohaloya..
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
#define n0 cout<<"No\n"<<endl
#define test cin>>t; while(t--)
#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gp ' ';
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b,i,j;
    string s,t,u;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s.compare(u)==0) a--;
    else b--;
    cout<<a<<" "<<b;

}
//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N, X, Y;
    cin >> N >> X >> Y;
    vector<long> dist(N);
    long d;
    long start = X-1;
    long end = Y-1;
    for(size_t i=0;i<N; i++)
    {
        for(size_t j=i+1;j<N; j++)
        {
            //cerr << i << "," << j << endl;
            //直接向かう
            // j - i 
            //ショートカット可能
            // |(X-1) - i| + |j - (Y-1)| + 1
            d = j - i;
            if(start >= i && j >= end)
                d = min(d, (long)(start - i + j - end + 1));
            if(i >= start && j >= end)
                d = min(d, (long)(i - start + j - end + 1));
            if(i >= start && end >= j)
                d = min(d, (long)(i - start + end - j + 1));
            if(start >= i && end >= j)
                d = min(d, (long)(start - i + end - j + 1));
            dist[d] ++;
        }
    }

    for(size_t k=1;k<N; k++)
    {
        cout << dist[k] << endl;
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main() {
    while (1) {
        int M, F, R;
        cin >> M >> F >> R;
        if (M == -1 && F == -1 && R == -1) break;

        if (M == -1 || F == -1) cout << "F" << endl;
        else if (M + F >= 80) cout << "A" << endl;
        else if (65 <= M + F && M + F < 80) cout << "B" << endl;
        else if (50 <= M + F && M + F < 65) cout << "C" << endl;
        else if (30 <= M + F && M + F < 50) {
            if (R >= 50) cout << "C" << endl;
            else cout << "D" << endl;
        }
        else cout << "F" << endl;
    }
}


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

int main() {
  int a,b,c, ab, bc, ca;
  cin >> a >> b >> c;
  ab=a+b;
  bc=b+c;
  ca=c+a;
  if (ab>=bc){
    if (bc>=ca){
    cout << ca << endl;
    }
    else{
     cout << bc << endl;
    }
  }
  else if(ab>=ca){
    cout << ca << endl;
  }
  else{
  cout << ab << endl;
  }
}

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

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if (a >=13) cout << b << endl;
    else if (a >=6 && a <= 12) cout << b/2 << endl;
    else cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		long[] r = new long[n];
		for (int i = 0; i < n; i++) {
			String s = in.next();
			int p = in.nextInt();
			r[i] = toLong(s, p, i + 1);
		}
		Arrays.sort(r);
		for (int i = 0; i < n; i++)
			System.out.println(r[i] % 101);
		in.close();
	}

	private static long toLong(String s, int p, int n) {
		long r = 0;
		for (int i = 0; i < 10; i++) {
			r *= 26;
			if (i < s.length())
				r += s.charAt(i) - 'a';
		}
		r *= 101;
		r += 101 - p;
		r *= 101;
		r += n;
		return r;
	}

}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+3;
int a[N],d[N];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t,i,j,n,m,l,r,k;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    d[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        int mn=INT_MAX;
        m=max(0,(i-k));
        for(j=i-1;j>=m;j--)
        {
            l=abs(a[i]-a[j])+d[j];
            mn=min(mn,l);
        }
        d[i]=mn;
    }
    cout<<d[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
const long long int mod = 1000000007;

int main(){
	long long int k, s,ans=0;
	cin >> k >> s;
	for (int x = 0; x <= k; x++){
		for (int y = 0; y <= k; y++){
			int z = s - x - y;
			if (0 <= z&&z <= k){
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
from bisect import bisect_left,bisect_right
s=list(input())
q=int(input())
D={chr(ord("a")+i):[] for i in range(26)}
for i ,j in enumerate(s):
    D[j].append(i)
ans=0
for i in range(q):
    x=list(input().split())
    if x[0]=="1":
        l=int(x[1])
        l-=1
        r=x[-1]
        if r==s[l]:
            continue
        rr=bisect_left(D[r],l)
        D[s[l]].remove(l)
        D[r].insert(rr,l)
        s[l]=r
    else:
        l=int(x[1])
        r=int(x[2])
        l-=1
        r-=1
        ans=0
        for i in range(26):
            W=chr(ord("a")+i)
            ll=bisect_left(D[W],l)
            rr=bisect_right(D[W],r)
            if rr-ll>0:
                ans+=1
        print(ans)



Measured memory_bytes: 98048