akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;


int main() {
	LL N;
	cin >> N;
	vector<LL> v(N);
	vector<LL> m(100000);

	REP(i, N) {
		cin >> v[i];
		m[v[i]]++;
	}

	LL max = -1;
	for (LL i = 1; i <= 99998; ++i) {
		LL score = m[i - 1] + m[i] + m[i + 1];
		if (score > max) {
			max = score;
		}
	}

	cout << max << endl;
}

Measured memory_bytes: 1792
/* 
 * Project: Panasonic programing Contest B - Bishop
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/12
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include<cstdio>
using namespace std;

long h, w;

void solve() {

    if (h^1 && w^1)
        printf("%ld\n", ((h*w)+1)/2);
    else
        printf("%d\n",1);

}

int main() {

    scanf("%ld", &h);
    scanf("%ld", &w);

    solve();

}


Measured memory_bytes: 3184
#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;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int curMin = 1e8;
  int ans = 0;
  rep(i,n){
    curMin = min(curMin,p[i]);
    if(curMin == p[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    int l[51];
    REP(i, N) cin >> l[i];
    sort(l, l + N, greater<int>());
    cout << accumulate(l, l + K, 0) << endl;
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    set<int> st;
    int n;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        if (st.count(a) == 1) {
            cout << "NO" << endl;
            return 0;
        }
        st.insert(a);
    }
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 9600
#include<cstdio>
#include<vector>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

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


	int N = getint(), M = getint();

	int E[200010], ne[200010], H[100010] = {};
	int k = 1;
	rep(i, M) {
		int a = getint(), b = getint();
		E[k] = b;
		ne[k] = H[a];
		H[a] = k++;
		E[k] = a;
		ne[k] = H[b];
		H[b] = k++;
	}

	bool S[100010] = {};
	S[1] = 1; 
	S[E[H[1]]] = 1;
	vector<int> kotae1, kotae2;
	kotae1.pb(1);
	kotae2.pb(E[H[1]]);

	int ima = 1;
	while (true) {
		int nakatta = 1;
		for (int i = H[ima]; i; i = ne[i]) {
			int to = E[i];
			if (!S[to]) {
				kotae1.pb(to);
				ima = to;
				S[to] = 1;
				nakatta = 0;
				break;
			}
		}
		if (nakatta) break;
	}
	ima = E[H[1]];
	while (true) {
		int nakatta = 1;
		for (int i = H[ima]; i; i = ne[i]) {
			int to = E[i];
			if (!S[to]) {
				kotae2.pb(to);
				ima = to;
				S[to] = 1;
				nakatta = 0;
				break;
			}
		}
		if (nakatta) break;
	}

	putint(kotae1.size() + kotae2.size());
	rep(i, kotae1.size()) {
		putint(kotae1[kotae1.size() - i - 1]);
	}
	rep(i, kotae2.size()) {
		putint(kotae2[i]);
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define p 1000000007
long long fact(long long n)
{
  long long ans = 1;
  while(n != 1)
  {
    ans = (ans*n)%p;
    --n;
  }
  
  return ans;
}

int main(void)
{
  using namespace std;
  long long N, M;
  cin >> N >> M;
  if(N < M)
    swap(N, M);
  if(N == M)
  {
    cout << (2LL*fact(N)*fact(M))%p << '\n';
  }
  else if(N-M == 1)
  {
    cout << (fact(N)*fact(M))%p << '\n';
  }
  else
  {
    cout << "0\n";
  }
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

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

  int n = s.size();
  map<char, char> r1, r2;
  rep(i, n) {
    if(r1.find(s[i]) == r1.end()) r1[s[i]] = t[i];
    if(r2.find(t[i]) == r2.end()) r2[t[i]] = s[i];

    if(r1[s[i]] != t[i] || r2[t[i]] != s[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3904
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int Nmax = 100000;
int N;
ll A[Nmax];

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

	vector<ll> step;
	ll cur = 0;;
	step.push_back(0);
	for(int i=0; i<N; i++){
		if(A[i] > cur){
			step.push_back(A[i]);
			cur = A[i];
		}
	}

	vector<vector<int> > stepidx(step.size(), vector<int>());
	for(int i=0; i<N; i++){
		vector<ll>::iterator k = lower_bound(step.begin(), step.end(), A[i]);
		stepidx[k-step.begin()].push_back(i);
	}

	/*
	for(int i=0; i<stepidx.size(); i++){
		cout << step[i] << " ";
		for(int j=0; j<stepidx[i].size(); j++){
			cout << stepidx[i][j] << " ";
		}
		cout << endl;
	}
	*/

	int cnt=0;
	vector<ll> ans(N);
	for(int i=stepidx.size()-1; i>=0; i--){
		for(int j=0; j<stepidx[i].size(); j++){
			ans[stepidx[i][0]] += A[stepidx[i][j]] - A[stepidx[i][0]];
			cnt += 1;
		}
		if(i>0){
			ans[stepidx[i][0]] += cnt * (step[i] - step[i-1]);
		}
	}

	for(int i=0; i<N; i++){
		cout << ans[i] << endl;
	}

	return 0;
}


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

int dp[3][112345];
int mat[3][112345];

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

    for(int i = 0; i < n; ++i)
        cin >> mat[0][i] >> mat[1][i] >> mat[2][i];

    for(int i = 0; i < 3; ++i)
        dp[i][n] = 0;

    for(int i = n-1; i >= 0; --i)
    {
        dp[0][i] = max(mat[0][i] + dp[1][i+1],
                       mat[0][i] + dp[2][i+1]);

        dp[1][i] = max(mat[1][i] + dp[0][i+1],
                       mat[1][i] + dp[2][i+1]);

        dp[2][i] = max(mat[2][i] + dp[0][i+1],
                       mat[2][i] + dp[1][i+1]);
    }

    cout << max({dp[0][0], dp[1][0], dp[2][0]}) << endl;
}


Measured memory_bytes: 2560
while True:
  n = int(input().rstrip())
  if n == 0:
    break
  A = 0
  B = 0
  while n > 0:
    line = input().rstrip()
    a,b = map(int,line.split())
    if a == b:
      A += a
      B += b
    elif a > b:
      A += (a+b)
    else:
      B += (a+b)
    n -= 1
  print(A,B)

Measured memory_bytes: 7520
N = int(input())
list = [''] * N
judge = [0] *4

#print(list)

#'''''''''
for i in range(0, N):
    list[i] = input()
    if list[i] == 'AC':
        judge[0] += 1
    elif list[i] == 'WA':
        judge[1] += 1
    elif list[i] == 'TLE':
        judge[2] += 1
    else:
        judge[3] += 1

print('AC x ' + str(judge[0]))
print('WA x ' + str(judge[1]))
print('TLE x ' + str(judge[2]))
print('RE x ' + str(judge[3]))
#'''''''''

Measured memory_bytes: 16180
#include<iostream>
using namespace std;
int main(){
    int a,b,x;
    char op;
    cin >> a >> op >> b;
    while(op!='?'){
        if ( op == '+' ){x=a+b;}
        else if ( op == '-' ){x=a-b;} 
        else if ( op == '*' ){x=a*b;}
        else if ( op == '/' ){x=a/b;}
        cout << x << endl;
        cin >> a >> op >> b;
    }return 0;
}


Measured memory_bytes: 3088
import java.io.*;

public class Main {

	private static int count;

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while (null != (str = in.readLine())) {// 入力の終わりまで
			doit(Integer.parseInt(str));
		}
	}

	private static void doit(int n) {
		count = 0;
		
		for (int i = 1; i <= n; i++)
			if (isPrime(i))count++;
		
		System.out.println(count);
	}

	private static boolean isPrime(int n) {// 素数判定メソッド
		if (n < 2)
			return false;
		else if (n == 2)
			return true;

		if (n % 2 == 0)
			return false;

		for (int i = 3; i <= n / i; i += 2)
			if (n % i == 0)
				return false;
		return true;
	}
}

Measured memory_bytes: 18720
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

int n, m;
int a, b;

int pos[200000];

signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--; b--;
		if (a > b) swap(a, b);
		if (a == 0) pos[b]++;
		if (b == n - 1) pos[a]++;
	}
	
	for (int i = 0; i < n; i++) {
		if (pos[i] == 2) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 1024
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion


int main()
{
	int k; cin >> k;
	int res = 0;
	for (int a = 1; a <= k; ++a)
	{
		for (int b = 1; b <= k; ++b)
		{
			for (int c = 1; c <= k; ++c)
			{
				int tmp = gcd(a, b);
				res += gcd(tmp, c);
			}
		}
	}
	cout << res << endl;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

map<int, map<int, set<pii>>> memo;
bool used[400][400];
vector<pii> ds = {{1,0},{0,1},{-1,0},{0,-1}};
int h,w;
ll black, white;
vector<string> vs;

void rec(int x, int y) {
    if (used[y][x]) return;
    used[y][x] = true;

    if (vs[y][x] == '#') black++;
    else white++;

    for(auto& p: ds) {
        int nx = x + p.first;
        int ny = y + p.second;
        if (0 <= nx and nx < w and 0 <= ny and ny < h) {
            if (vs[y][x] != vs[ny][nx]) rec(nx, ny);
        }
    }
}


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

    cin >> h >> w;
    rep(i, h) {
        string s;
        cin >> s;
        vs.emplace_back(s);
    }

    ll ans = 0;
    rep(y, h) rep(x, w) {
        if (vs[y][x] != '#' or used[y][x]) continue;
        black = white = 0;
        rec(x, y);
        ans += black * white;
        // cout << x << " " << y << " " << black << " " << white << endl;
    }

    cout << ans << endl;    

    return 0;
}


Measured memory_bytes: 18048
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int x, n;
  cin >> x >> n;
  vector<int> vc(n);
  unordered_map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> vc[i];
  }
  for (auto i: vc) {
    mp[i] = 1;
  }
  int diff = INT_MAX, ans;
  for (int i = -200; i <= 200; i++) {
    if (abs(x - i) < diff and mp.find(i) == mp.end()) {
      diff = abs(x - i);
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct node{
  int a,b;
} node;

int cmp(const void *a,const void *b){
  node *p=(node *)a;
  node *q=(node *)b;
  return (p->a+p->b)-(q->a+q->b);
}

void run(void){
  int n;
  scanf("%d",&n);
  node *p=(node *)calloc(n,sizeof(node));
  int i;
  for(i=0;i<n;i++) scanf("%d%d",&p[i].a,&p[i].b);
  qsort(p,n,sizeof(node),cmp);
  int64 ans=0;
  for(i=n-1;i-1>=0;i-=2){
    ans+=p[i].a-p[i-1].b;
  }
  if(i>=0) ans+=p[i].a;
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1788
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> p;
  tools::read(p, N);

  if (std::is_sorted(p.begin(), p.end())) goto SUCCEEDED;
  for (i64 i = 0; i < N - 1; ++i) {
    for (i64 j = i + 1; j < N; ++j) {
      std::swap(p[i], p[j]);
      if (std::is_sorted(p.begin(), p.end())) goto SUCCEEDED;
      std::swap(p[i], p[j]);
    }
  }

  std::cout << "NO" << std::endl;
  return 0;

SUCCEEDED:
  std::cout << "YES" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int sum=0;
  int a,i;
  int m=INF;
  rep(i,4){
    cin>>a;
    sum+=a;
    m=min(m,a);
  }
  sum-=m;
  m=INF;
  rep(i,2){
    cin>>a;
    sum+=a;
    m=min(m,a);
  }
  sum-=m;
  cout<<sum<<endl;
}

Measured memory_bytes: 3052
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
using namespace std;
 
#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
 
typedef long long ll;

int main() {
    
    string s;
	cin >> s;
	if (s[5] == '1' || s[6] >= '5') {
		cout << "TBD" << endl;
	} else {
		cout << "Heisei" << endl;
	}
    return 0;
}


Measured memory_bytes: 256
using System;

namespace abc122A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string b = Console.ReadLine();
            switch (b)
            {
                case "A":
                    Console.WriteLine("T");
                    break;
                case "C":
                    Console.WriteLine("G");
                    break;
                case "T":
                    Console.WriteLine("A");
                    break;
                case "G":
                    Console.WriteLine("C");
                    break;
            }
        }
    }
}


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

namespace Atc_0035
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var Ps = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int result = 0;

            for (int i = 0; i < Ps.Length - 2; i++)
            {
                if ((Ps[i] < Ps[i + 1] && Ps[i + 1] < Ps[i + 2]) ||
                    (Ps[i + 2] < Ps[i + 1] && Ps[i + 1] < Ps[i]))
                {
                    result++;
                }
            }

            Console.WriteLine(result);
        }
    }
}


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

namespace Contest
{


    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long[] nums = new long[200001];
            long ans = 0;

            foreach(var temp in a)
            {
                nums[temp]++;
                ans += temp;
            }

            var q = int.Parse(Console.ReadLine());

            while(q > 0)
            {
                q--;

                var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var b = input[0];
                var c = input[1];
                
                ans -= nums[b] * b;
                ans += nums[b] * c;
                
                nums[input[1]] += nums[input[0]];
                nums[input[0]] = 0L;

                Console.WriteLine(ans);
            }

        }
    }
}

Measured memory_bytes: 51428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int x = sc.nextInt();
		int res = 0;
		int[] d = new int[n+1];

		for (int i = 0; i < n; i++) {
			int ls = sc.nextInt();
			d[i+1] = ls + d[i];
			if (d[i+1] <= x) {
				res++;
			}
		}
		// System.out.println(Arrays.toString(d));
		System.out.println(res+1);
		
	}
	
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22484
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	int ans = 0;
	vector<int> p(30);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p.at(i);
	}
	for (int i = 1; i < n-1; i++) {
		if (p.at(i-1) > p.at(i) && p.at(i) > p.at(i + 1)) {
			ans++;
		}
		if (p.at(i - 1) < p.at(i) && p.at(i) < p.at(i + 1)) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  // ここにプログラムを追記
  long X;
  cin>> X ;
  long x=100;
  for(int i=1; ;i++){
    x+=x/100;
    if(x>=X){
      cout<< i <<endl;
      break;
  }
}
}


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

using ll = long long;

vector<int> operator*(const vector<int>& a, const vector<int>& b)
{
    const auto N = int(a.size());
    auto c = vector<int>(N);
    for (auto i = 0; i < N; i++)
        c[i] = a[b[i]];
    return c;
}

template <typename T>
T power(const T x, const ll K)
{
    if (K == 1) return x;
    else if (K % 2 == 0) return power(x*x, K/2);
    else return x * power(x*x, K/2);
}

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;

    auto initial = vector<int>(N);
    for (auto& x : initial) cin >> x;

    auto delta = vector<int>(N-1);
    for (auto i = 0; i < N-1; i++)
        delta[i] = initial[i+1]-initial[i];

    int M; ll K; cin >> M >> K;

    auto pi = vector<int>(N-1);
    iota(begin(pi), end(pi), 0);

    for (auto i = 0; i < M; i++)
    {
        int a; cin >> a;
        a--;
        swap(pi[a], pi[a-1]);
    }

    pi = power(pi, K);

    auto x = ll(initial[0]);
    for (auto i = 0; i < N; i++)
    {
        cout << x << "\n";
        if (i != N-1) x += delta[pi[i]];
    }
}


Measured memory_bytes: 25728
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		long n = sc.nextLong();
		long s = sc.nextLong();

		out:
		if (n == s) {
			pr.println(n + 1);
		} else if (n < s) {
			pr.println(-1);
		} else {
			for (long b = 2; b < 1_000_000; b++) {
				long ret = 0;
				long tmp = n;
				while (tmp > 0) {
					ret += tmp % b;
					tmp /= b;
				}

				if (ret == s) {
					pr.println(b);

					break out;
				}
			}

			for (long p = Math.min(1_000_000, s); p >= 1; p--) {
				if ((n - s) % p == 0) {
					long b = (n - s) / p + 1;

					if (s - p < b) {
						pr.println(b);

						break out;
					}
				}
			}

			pr.println(-1);
		}

		pr.close();
		sc.close();
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
//					it = Arrays.asList(br.readLine().split(" ")).iterator();
					it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 9684
#include <iostream>
#include <cctype>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cstring>
#include <fstream>
#include <cmath>
#include <stack>
#include <algorithm>
#include <queue>
#include <iterator>
#include <limits>
#define PI 3.1415926535
#include <sstream>
#define MAX 100
#define swap(a,b,t) (t=a,a=b,b=t)
using namespace std;
string getstring(char a)
{
       string s(1,a);
       return s;
}

int main()
        { 
        char a;
        cin>>a;
        
        switch(a)
        {
        case 'A':
             cout<<"T";
             break;
        case 'C':
             cout<<"G";
             break;
        case 'G':
             cout<<"C";
             break;
        case 'T':
             cout<<"A";
             break;
        }
        //system("pause");
        return 0;
        } 
        
        





Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	if(!(n & (n - 1))) {puts("No"); return 0;}
	puts("Yes"); puts("1 2"); puts("2 3");
	printf("%d %d\n", 3, n + 1); printf("%d %d\n", n + 1, n + 2); printf("%d %d\n", n + 2, n + 3);
	for(int i = 4; i + 1 <= n; i += 2)
	{
		int j = i + 1;
		printf("%d %d\n", 1, i);
		printf("%d %d\n", 1, j);
		printf("%d %d\n", i, j + n);
		printf("%d %d\n", j, i + n);
	}
	if(n % 2 == 0)
	{
		for(int i = 4; i <= n; i ++)
		{
			int j = n ^ i ^ 1;
			if(j != 3 && j < n)
			{
				printf("%d %d\n", i, n);
				printf("%d %d\n", j, 2 * n);
				return 0;
			}
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <bitset>
#include <math.h>

using namespace std;

typedef long long ll;

const int MAX_N = 60;

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

ll dp[MAX_N][MAX_N][MAX_N*MAX_N] = {0};

int main(int argc, char const *argv[]) {
  ll n, a, x[MAX_N]={0};
  cin >> n >> a;
  ll maxX = a;
  for (int i = 0; i < n; ++i) {
    cin >> x[i+1];
    maxX = max(maxX, x[i]);
  }

  EREP(j,n){
    EREP(k,j){
      EREP(s, n*maxX){
        if (j==0&&k==0&&s==0) dp[j][k][s] = 1;
        if (j >= 1 && s < x[j]) dp[j][k][s] = dp[j-1][k][s];
        if (j >= 1 && k >= 1 && s>=x[j]) dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
      }
    }
  }

  ll ans = 0;
  for (int i = 1; i <= n; ++i) ans += dp[n][i][i*a];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 84224
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()
l = [400, 600, 800, 1000, 1200, 1400, 1600, 1800]
print(9-bisect(l, X))


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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   string S, T;
   cin >> S >> T;
   int N = S.size();
   int M = T.size();
   vector<int> prefS(N + 1);
   vector<int> prefT(M + 1);
   for (int i = 0; i < N; ++i) {
      prefS[i + 1] = prefS[i] + (S[i] == 'A' ? 1 : 2);
   }
   for (int i = 0; i < M; ++i) {
      prefT[i + 1] = prefT[i] + (T[i] == 'A' ? 1 : 2);
   }
   int Q;
   cin >> Q;
   while (Q--) {
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      --a, --b, --c, --d;
      int vs = (prefS[b + 1] - prefS[a]) % 3;
      int vt = (prefT[d + 1] - prefT[c]) % 3;
      if (vs == vt) {
         cout << "YES\n";
      } else {
         cout << "NO\n";
      }
   }
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;

struct dat {
    int a,b;
    bool operator<(const dat& o) const {
	return b<o.b;
    }
};

int n;
dat s[maxn];
int a[maxn];
int p[maxn];
int viz[maxn];

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

    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>s[i].a;
	a[i]=s[i].a;
    }
    for (int i=0; i<n; i++) {
	cin>>s[i].b;
    }
    sort(s,s+n);
    sort(a,a+n);
    for (int i=0; i<n; i++) {
	if (a[i] > s[i].b) out("No");
    }
    
    for (int i=0; i<n-1; i++) {
	if (a[i] <= s[i+1].b && a[i+1] <= s[i].b) out("Yes");
    }

    for (int i=0; i<n; i++) {
	p[i] = lower_bound(a,a+n,s[i].a)-a;
    }

    for (int i=0, at=0; i<n; i++) {
	viz[at]=1;
	at=p[at];
    }
    

    if (count(viz,viz+n,1)==n) out("No");
    out("Yes");
    
    
    return 0;
}


Measured memory_bytes: 5564
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int D = int.Parse(input[0]);
		int[] c = new int[26];
		input = Console.ReadLine().Split(' ');
		for(int i=0; i<26; i++) c[i] = int.Parse(input[i]);
		int[][] s = new int[D][];
		for(int i=0; i<D; i++)
		{
			input = Console.ReadLine().Split(' ');
			s[i] = new int[26];
			for(int j=0; j<26; j++) s[i][j] = int.Parse(input[j]);
		}
		int[] t = new int[D];
		int[] last = new int[26];
		for(int i=0; i<26; i++) last[i] = -1;
		int satisfy = 0;
		for(int i=0; i<D; i++)
		{
			input = Console.ReadLine().Split(' ');
			t[i] = int.Parse(input[0]) - 1;
			satisfy += s[i][t[i]];
			last[t[i]] = i;
			for(int j=0; j<26; j++)
			{
				satisfy -= c[j] * (i - last[j]);
			}
			Console.WriteLine(satisfy);
		}
	}
}

Measured memory_bytes: 28052
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var x = int.Parse(line[1]);
        var t = int.Parse(line[2]);
        Console.WriteLine(((n + x - 1) / x) * t);
    }
}


Measured memory_bytes: 27524
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 28)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n,m;
	for (int i = 0; i < 4; ++i)
	{
		cin>>n>>m;

		if(n==1){
			cout << m*6000 <<endl;
		}
		if(n==2){
			cout << m*4000 <<endl;
		}
		if(n==3){
			cout << m*3000 <<endl;
		}
		if(n==4){
			cout << m*2000 <<endl;
		}
	}
	


	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1168
#include <stdio.h>
        int main()
        {
        	int N, a, b, c, total, S,ans = -1,ans1 = -1,ans2 = -1;
        	scanf("%d", &N);
        	scanf("%d", &S);
        	for (a = 0; a <= N; a++) {
        		for (b = 0; a + b <= N; b++) {
        			c = N - a - b;
        			total = a * 10000 + b * 5000 + c * 1000;
        			if (total == S) {
                      ans = a;
                      ans1 = b; 
                      ans2 = c;
        			}
        		}
        	}
          printf("%d %d %d",ans,ans1,ans2);
        }

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
string s;
int ans,cnt;
int main()
{
    cin>>s;
    ans=s.size();
    for (int i=0;i<s.size();i++){
        if (s[i]=='S') cnt++;
        if (s[i]=='T'&&cnt) cnt--,ans-=2;
    }
    cout<<ans<<endl;
    return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

class bipartite_matching {
public:
	int n;
	vector<vector<int>> g;
	vector<int> match;
	bipartite_matching(int n_) : n(n_), g(n_), match(n_), used(n_) {}
	void add_edge(int u, int v) {
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int maximum_matching(void) {
		int res = 0;
		fill(begin(match), end(match), -1);
		for (int v = 0; v < n; ++v) {
			if (match[v] == -1) {
				fill(begin(used), end(used), false);
				if (dfs(v)) res++;
			}
		}
		return res;
	}

private:
	vector<int> used;
	bool dfs(int v) {
		used[v] = true;
		for (int u : g[v]) {
			int w = match[u];
			if (w == -1 || (!used[w] && dfs(w))) {
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}
};

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<VI> ab(n, VI(2));
	bipartite_matching bm(2*n);
	rep(i, n) cin >>ab[i][0] >>ab[i][1];
	rep(j, n){
		int c, d; cin >>c >>d;
		rep(i, n) if( c > ab[i][0] && d > ab[i][1]) bm.add_edge(i, j+n);
	}
	int ans = bm.maximum_matching();
	
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
require 'prime'
class Array
  def lcm
    inject(:lcm)
  end

  def gcd
    inject(:gcd)
  end
end

N, M = gets.split(' ').map(&:to_i)
nums = gets.split(' ').map(&:to_i).uniq
# p nums

prm = Prime.prime_division(nums[0])[0][1]
nums.each do |num|
  if prm != Prime.prime_division(num)[0][1]
    puts 0
    exit
  end
end

lcm = nums.lcm
# puts lcm
puts (M-lcm.div(2)).div(lcm)+1

Measured memory_bytes: 11428
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

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


void Calc() {
  int n = in;
  struct Data {
    int i, a;
    void In() {
      in, a;
    }
    bool operator<(const Data&d)const {
      return a < d.a;
    }
  };
  vector<Data> d(n);
  rep(i, n) {
    d[i].In();
    d[i].i = i;
  }
  sort(all(d));

  int cnt = 0;
  auto solve = [&](int mid) {
    ll now = d[mid].a;
    rep(i, n) {
      if (i == mid)continue;
      if (d[i].a <= now * 2) {
        now += d[i].a;
      } else {
        return false;
      }
    }
    return true;
  };
  int l = 0, r = n;
  while (r - l > 0) {
    int mid = (r + l) / 2;
    if (solve(mid)) r = mid;
    else l = mid + 1;
  }
  err(l, r, n);
  cout << (n-l) << endl;

}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 200005;
vector<int> g[N];
int st[N], en[N], f[N];
int ptr;

void dfs(int v, int p){
	st[v] = ptr; ptr++;
	for(auto u : g[v]){
		if(u != p)dfs(u, v);
	}
	en[v] = ptr;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, q; cin>>n>>q;
	for(int i = 1; i < n; i++){
		int u, v; cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	ptr = 1; dfs(1, -1);
	memset(f, 0, sizeof(f));
	while(q--){
		int p, x; cin>>p>>x;
		f[st[p]] += x;
		f[en[p]] -= x;
	}
	for(int i = 1; i <= n; i++){
		f[i] += f[i - 1];
	}
	for(int i = 1; i <= n; i++){
		cout<<f[st[i]]<<" ";
	}

	return 0;
}

Measured memory_bytes: 25088
using System;

namespace AOJ
{
    class Program
    {
        static void Main()
        {
            string l;
            char b = 'A';
            while ((l = Console.ReadLine()) != null)
            {
                if (l[0] == b) b = l[2];
                else if (l[2] == b) b = l[0];
            }
            Console.WriteLine(b);
        }
    }
}

Measured memory_bytes: 5260
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

ll dp[401][401], sum[401][401];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, i, s, j, k;
    cin>>n;
    vector<ll> a(n);
    for(i = 0; i < n; i++) {
    	cin>>a[i];
    }
    for(i = 0; i < n; i++) {
    	for(j = 0; j < n; j++) {
    		dp[i][j] = 2e18;
    	}
    }
    for(i = 0; i < n; i++) {
    	ll temp = 0;
    	for(j = i; j < n; j++) {
    		temp += a[j];
    		sum[i][j] = temp;
    	}
    }
    for(s = 0; s < n; s++) {
    	for(i = 0; i < n - s; i++) {
    		j = i + s;
    		if(i == j) {
    			dp[i][j] = 0;
    		} else {
    			for(k = 0; k < j; k++) {
					dp[i][j] = min(dp[i][j], sum[i][j] + dp[i][k] + dp[k + 1][j]);
    			}
    		}
    	}
    }
    cout<<dp[0][n-1]<<"\n";
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define inf 1000000000

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <ll, ll> ii;
typedef vector <ii> vii;
typedef vector <vii> graph;

bool comp(ll a, ll b) {
	return a > b;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
 
    int n, k;
    cin >> n >> k;
    bitset <110> vis;
    vis.reset();
    int m;
    int in;
    for (int i = 0; i < k; i++) {
        cin >> m;
        for (int j = 0; j < m; j++) {
            cin >> in;
            vis[in] = 1;
        }
    }
    int cont = 0;
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) cont++;
    }
    cout << cont << "\n";
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
	return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, 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> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

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

void solver() {
    int n = input(), m = input(), q = input();
    vector< int > as(q), bs(q), cs(q), ds(q);
    range(i, 0, q) {
        cin >> as[i] >> bs[i] >> cs[i] >> ds[i];
    }

    auto calc = [&](vector< int > A) {
        i64 res = 0;
        range(i, 0, q) {
            if (A[bs[i] - 1] - A[as[i] - 1] == cs[i]) res += ds[i];
        }
        return res;
    };

    int ans = 0;
    vector< int > A(n);
    function<void(int, int)> dfs = [&](int idx, int pre) {
        if (idx == n) {
            chmax(ans, calc(A));
            return;
        }
        range(i, pre, m + 1) {
            A[idx] = i;
            dfs(idx + 1, i);
        }
    };

    dfs(0, 1);
    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>

using namespace std;
 
using ll = long long;
using vll = vector<ll>;
 
int main(){
  ll N;
  cin >> N;
  vll H(N);
  for(auto& h : H) cin >> h;
  ll ans = 0;
  ll cur = 0;
  for(int i = 0; i < N - 1; ++i){
    if(H[i] >= H[i + 1]){
      cur++;
      ans = max(ans, cur);
    }
    else
    {
      cur = 0;
    }
  }
  cout << ans << endl;
}

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

int main() {
    int n,ans=0;
    cin>>n;
    vector<int> a;
    for(int i=0;i<n;i++) {
        int x;
        cin>>x;
        a.push_back(x);
    }
    sort(a.rbegin(),a.rend());
    ans=a[0]-a[n-1];
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256