akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**7)

# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())

def solve():
    l_list = []
    r_list = []
    n, m = map(int, input().split())
    for i in range(m):
        l, r = map(int, input().split())
        l_list.append(l)
        r_list.append(r)

    max_l = max(l_list)
    min_r = min(r_list)
    print(max(0, min_r - max_l + 1))

solve()

Measured memory_bytes: 11036
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<40;
const ll LINF=1LL<<62;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template<typename T>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);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    string s;cin>>s;
    bool f=false;
    if(s[5]=='1'||s[6]-'0'>=5){
        f=true;
    }
    if(!f){
        cout<<"Heisei"<<endl;
    }else{
        cout<<"TBD"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define int long long
set < ll> primes;
 
int n,m;

bool isvalid(int x,int y)
{
    return (x>=0 && x<n && y>=0 && y<m);
}
int dx[]={0,0,1,-1,-1,1,1,-1};
int dy[]={1,-1,0,0,-1,1,-1,1};
void Sieve(ll n) 
{ 
    bool prime[n+1];
	for(ll i=0;i<n+1;++i)
		prime[i]=true;
    for (ll p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (ll i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(ll p=2; p<=n; p++) 
       if (prime[p]) 
		primes.insert(p);  
}

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
        return gcd(b % a, a); 
} 
ll powermod(ll x, ll y){
    if(y==0)
    return 1;
        
    if(y%2==0)
    return (powermod(x,y/2)*powermod(x,y/2))%mod;
    else
    return (((powermod(x,y/2)*powermod(x,y/2))%mod)*x)%mod;
}

void solve()
{
    int n,m;
    cin>>n>>m;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int f=0,cnt=0;
    
    for(int i=0;i<n;i++)
    {
        double d= (1.0/(4.0 * m) )*(sum);
        double d1=(double)a[i];
        
        if(d1>=d)cnt++;
    }
    if(cnt>=m)cout<<"Yes";
    else cout<<"No";
}



 
 

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t=1;
    //cin>>t;
    for(int ind=1;ind<=t;ind++)
    {
        // cout<<"Case #"<<ind<<": "<<" ";
        
        solve();
    }
    
    
    
    
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    int n;
    cin >> n;
    vector<ll> d(n);
    int mx = 0;
    rep(i,n) {
        int di;
        cin >> di;
        d[di]++;
        chmax(mx, di);

        if (i == 0 && di != 0){
            cout << 0 << endl;
            return 0;
        }
    }

    if (d[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    mint ans = d[0];
    for(int i = 1; i <= mx; i++){
        rep(j, d[i]) ans *= d[i-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4012
from math import degrees, atan

a, b, x = map(int, input().split())
if 2 * x > a * a * b:
    ans = degrees(atan(2 * ((b / a) - (x / (a ** 3)))))
else:
    ans = degrees(atan(a * b * b / (2 * x)))
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i, l, n) for(int i=(l); i<(int)(n); i++)
#define REP(i, n) for(int i=1; i<=(int)(n); i++)

using namespace std;
const long long MOD = 1000000000 + 7;

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> s(H+1);
    vector<vector<int> > dp(H, vector<int> (W, 0));

    dp[0][0] = 1;

    rep(i, 0, H) {
        cin >> s[i];
    }

    rep(i, 0, H) rep(j, 0, W) {
        if (!(i==0&&j==0)) {
            if (s[i][j] == '.') {
                int pre1 = (i-1 < 0) ? 0 : dp[i-1][j];
                int pre2 = (j-1 < 0) ? 0 : dp[i][j-1];
//                printf("i=%d, j=%d, pre1=%d, pre2=%d\n", i, j, pre1, pre2);
                dp[i][j] = (pre1 + pre2) % MOD;
            } else {
                dp[i][j] = 0;
            }
        }
   }

    cout << dp[H-1][W-1] << endl;

    return 0;
}



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

//構造体
typedef struct {
  char name[10];
  int t;
}Process;


//プロトタイプ宣言
void enqueue(Process);
Process dequeue(void);

//グローバル変数
Process Q[100000];
int n,q;
int ttime;
int i,j;

int main(void){

  int count=0;
  Process stack[1000];

  scanf("%d %d", &n, &q);

  //スケジュールの入力
  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  for(i=0;i<n+j;i++){
  stack[count] = dequeue();
  if(stack[count].t != -1)
  enqueue(stack[count++]);
  }

  return 0;
}


//終了したプロセスを表示する
void enqueue(Process x){

  printf("%s %d\n",x.name,x.t);
}

Process dequeue(void){

  int flag=0;

    if(Q[i].t <= q){
      ttime += Q[i].t;
      Q[i].t = ttime;
      flag=1;
    } 
    else{
      ttime += q;
      Q[n+j].t = Q[i].t - q;
      strcpy(Q[n+j].name,Q[i].name);
      j++;
    }

    if(flag==0)
      Q[i].t = -1;

      return Q[i];
      
}

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

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];

    long long ans = t;
    for (int i = 1; i < n; i++)
        ans += t - max(0, t-(v[i]-v[i-1]));
    cout << ans << endl;

}

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

int main(){
    int K;
    string S;
    cin >> K >> S;
    std::string str = S;
    size_t size = str.length();
    if (size <= K)
    {
        cout << S;
    }else
    {
        cout << S.erase(K) << "...";
    }
}

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

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,lessl<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define double long double

#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()

#define ff first
#define ss second
#define mp make_pair

#define pb push_back
#define endl "\n"

#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)

#define bp __builtin_popcountll
#define inf 1e18

const int N=2e3+5;
const int M=1e9+7;
void solve()
{
	int n,x,tt;
	cin>>n>>x>>tt;
	int ans=((n+x-1)/x)*tt;
	cout<<ans<<endl;
}

signed main()
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


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


int main() {
	int N;
	cin >> N;
	set<int> d;
	for(int i = 0; i < N; i++){
		int s;
		cin >> s;
		d.insert(s);
	}
	cout << d.size() << endl;
	return 0;
}

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

int main(){

int num = 0;
int *data;
int i;
int k;
int count = 0;
int finalans = 0;

while(1){
  scanf("%d",&num);
  if(1 <= num && num <=10000){
    break;
  }
}

data = (int *)malloc(sizeof(int)*num);

for(i = 0;i < num;i++){
  scanf("%d",&data[i]);
  for(k = 1;k <= sqrt(data[i]);k++){
   if(data[i] % k == 0){
    count++;
   }
}
if(count == 1){
  finalans++;
}
count = 0;
}

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



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

using namespace std;

int main() {
	char s[212345];
	int ini=-1,fim=0;
	scanf("%s", s);
	int tam = strlen(s);
	for (int i = 0;i < tam;i++) {
		if (s[i] == 'A' && ini == -1)
			ini = i;
		if (s[i] == 'Z')
			fim = i;
	}	
	printf("%d\n", fim-ini+1);
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<long long>h(n);
    vector<long long>d(n-1);
    for(int i=0; i<n; ++i){
        cin >> h[i];
    }
    for(int i=0; i<n-1; ++i){
        d[i]=h[i]-h[i+1];
    }
    vector<long long>b;
    int a;
    a=0;
    for(int i=0; i<n-1; ++i){
        if(d[i]>=0){
            a +=1;
        }
        else{
            b.push_back(a);
            a=0;
        }
    }
    b.push_back(a);
    int ans;
    ans =b[0];
    for(int i=0; i<b.size();++i){
        if(ans<b[i]){
            ans = b[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2936
let read_int_array n = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x))

let () =
  let n = read_int() in
  let a = read_int_array n in

  let rec solve i count =
    if i = n then count
    else
      let flag = i mod 2 = 0 && a.(i) mod 2 = 1 in
      let x = if flag then 1 else 0 in
      solve (i + 1) (count + x) in

  let ans = solve 0 0 in
  Printf.printf "%d\n" ans


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

int c[26][2],p[26];

int pr(int now){
  cout<<" "<<now;
  if(c[now][0]!=-1)pr(c[now][0]);
  if(c[now][1]!=-1)pr(c[now][1]);
  return 0;
}
int in(int now){
  if(c[now][0]!=-1)in(c[now][0]);
  cout<<" "<<now;
  if(c[now][1]!=-1)in(c[now][1]);
  return 0;
}
int po(int now){
  if(c[now][0]!=-1)po(c[now][0]);
  if(c[now][1]!=-1)po(c[now][1]);
  cout<<" "<<now;
  return 0;
}

int main(){
  int a,b,e,d,now;
  cin>>a;
  for(int i=0;i<=a;i++)p[i]=-1;
  for(int i=0;i<a;i++){
    cin>>b>>e>>d;
    p[d]=b;
    p[e]=b;
    c[b][0]=e;
    c[b][1]=d;
  }
  for(int i=0;i<a;i++)if(p[i]==-1)now=i;
  //cout<<now<<"<---"<<endl;//////
  cout<<"Preorder"<<endl;
  pr(now);
  cout<<endl;
  cout<<"Inorder"<<endl;
  in(now);
  cout<<endl;
  cout<<"Postorder"<<endl;
  po(now);
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1168
from collections import defaultdict, deque
N, Q = map(int, input().split())

neighbor = defaultdict(list)
counter = [0] * N

for i in range(N-1):
    a, b = map(int, input().split())
    neighbor[a-1].append(b-1)
    neighbor[b-1].append(a-1)

for i in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

def propagate():
    stack = deque([(0, None)])
    while stack:
        (node, parent) = stack.pop()
        if parent is not None:
            counter[node] += counter[parent]
        for c in neighbor[node]:
            if c != parent:
                stack.append((c, node))

propagate()
print(*counter)


Measured memory_bytes: 74048
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
const ll INF=1000000000;

signed main(){
	ll n,s,k; cin>>n>>k>>s;
	vl ans(n);
	bool t=true;
	if(n==k){
		rep(i,0,n)ans[i]=s;
	}
	else if(s==1){
		ll cnt=0;
		rep(i,0,n){
			if(i<k)ans[i]=1;
			else ans[i]=INF;
		}
	}
	else if(s==INF){
		ll cnt=0;
		rep(i,0,n){
			if(i<=k){
				if(t)ans[i]=1;
				else ans[i]=INF-(ll)1;
				t=!t;
			}
			else ans[i]=2;
		}
	}
	else{
		rep(i,0,n){
			if(i<=k){
				if(t)ans[i]=1;
				else ans[i]=s-1;
				t=!t;
			}
			else ans[i]=INF;
		}
	}
	rep(i,0,n){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 3936
#include<stdio.h>
#include<string.h>
int main()
{char a[101];
scanf("%s",a);
int l=strlen(a);
int i,j;
for(i=0;i<l;i++)
{if(a[i]=='C'){

	for(j=i+1;j<l;j++)
{
	if(a[j]=='F'){
		printf("Yes");
	return 0;
	}
	}

}
}

	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> int inf<int> = 1e9;
template <> ll inf<ll> = 1e18;
 
int main() {
    int N;
    cin >> N;
    vector<pair<ll, ll>> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i].second >> v[i].first;
    }
    sort(begin(v), end(v), [](auto const& p1, auto const& p2) {
        return p1.first + p1.second < p2.first + p2.second;
    });
    vector<ll> H(N), P(N);
    for(int i = 0; i < N; ++i) {
        H[i] = v[i].second;
        P[i] = v[i].first;
    }
 
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, -1));
    dp[0][0] = 0;
    for(int i = 1; i <= N; ++i) {
        for(int j = 1; j <= N; ++j) {
            if(dp[i - 1][j] != -1) {
                dp[i][j] = dp[i - 1][j];
            }
            if(dp[i - 1][j - 1] == -1 || dp[i - 1][j - 1] > H[i - 1]) {
                continue;
            }
            if(dp[i][j] == -1) {
                dp[i][j] = dp[i - 1][j - 1] + P[i - 1];
            } else {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + P[i - 1]);
            }
        }
    }
 
    int res = 0;
    for(int i = 1; i <= N; ++i) {
        if(dp[N][i] != -1) {
            res = i;
        }
    }
    cout << res << endl;
}


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

using namespace std;

int Index;
int PostOrderStr[40];

void getOrderInfo(int *p, int n) {

	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
}

void solve(int *preOrder, int *inOrder, int len) {
	int curRootPos;

	if (len == 0) {
		return;
	}
	curRootPos = find(inOrder, inOrder + 40, *preOrder) - inOrder;
	//left
	solve(preOrder + 1, inOrder, curRootPos);
	//right
	solve(preOrder + curRootPos + 1, inOrder + curRootPos + 1, len - curRootPos - 1);
	
	PostOrderStr[Index++] = *preOrder;
}

int main() {
	int n;
	int preorderStr[40], inorderStr[40];

	Index = 0;
	memset(preorderStr, 0, sizeof(preorderStr));
	memset(inorderStr, 0, sizeof(inorderStr));
	memset(PostOrderStr, 0, sizeof(PostOrderStr));
	cin >> n;
	getOrderInfo(preorderStr, n);
	getOrderInfo(inorderStr, n);
	solve(preorderStr, inorderStr, n);

	cout << PostOrderStr[0];
	for (int i = 1; i < n; ++i) {
		cout << " " << PostOrderStr[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3100
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    string s; cin >> s;
    vector<int> accs(s.size() + 1);
    for(int i = 0; i < (int)s.size() - 1; i++){
        accs[i + 1] = accs[i];
        if(s[i] == 'A' && s[i + 1] == 'C'){
            accs[i + 1]++;
        }
    }
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << accs[r - 1] - accs[l - 1] << '\n';
    }
}


Measured memory_bytes: 1472
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

ll n;

int main() {
    cin >> n;
    V t(5);
    rep(i, 5) cin >> t[i];
    ll minel = t[0];
    FOR(i, 1, 5) minel = min(minel, t[i]);
    ll ret = n / minel + (n % minel != 0) + 4;
    cout << ret << endl;
    return 0;
}


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

int main() {
  string a;
  cin>>a;
  if (a=="Sunny")
  {
      cout<<"Cloudy"<<endl;
  }
  else if  (a=="Cloudy")
  {
      cout<<"Rainy"<<endl;
  }
  else
  {
      cout<<"Sunny"<<endl;
  }
  return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

int main(){

  char s[10];
  scanf("%s", s);
  REP(i, strlen(s) - 1){
    if(s[i] == 'A' && s[i + 1] == 'C'){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
  long long MOD=1000000007;
  #define IOS() ios_base::sync_with_stdio(0); cin.tie(0);
  typedef long long ll;
  #define pb push_back
  typedef pair<ll,ll> pi;

int main()
{
  IOS();
  ll n,w;
  cin>>n>>w;
  ll a[n+1ll];
  ll value[n+1ll];
  a[0ll]=0ll;
  value[0ll]=0ll;

  for(ll i=1ll;i<=n;i++)
  {
  	cin>>a[i]>>value[i];
  }
 ll  dp[n+1ll][w+1ll];
  
 
  		for(ll j=0ll;j<=w;j++)
  			dp[0][j]=0ll;
  		// cout<<endl;
  	

  	for(ll i=1ll;i<=n;i++)
  	{
  		for(ll j=0ll;j<=w;j++)
  		{
  			if(a[i]>j)
  				dp[i][j]=dp[i-1][j];
  			else 
  				dp[i][j]=std::max(dp[i-1ll][j],value[i]+dp[i-1ll][j-a[i]]);
  		}
  	}
  	
  	cout<<dp[n][w]<<endl;


  return 0;
}

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

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define SHOW(a) cout << #a << " = " << a << endl;

void solve(){
	int a, b;
	cin >> a >> b;
	if(a * b % 2 == 0){
		cout << "Even";
	}else{
		cout << "Odd";
	}
	cout << endl;
}

int main(){
	solve();
	return 0;
}

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

int n;
double p[Nmax][Nmax][Nmax], exV[Nmax][Nmax][Nmax];
long long cnt[4];

void read()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        ++cnt[x];
    }
}

void solve()
{
    p[cnt[1]][cnt[2]][cnt[3]] = 1;

    for (int c = cnt[3]; c >= 0; --c) {
        for (int b = cnt[3] + cnt[2]; b >= 0; --b) {
            for (int a = n; a >= 0; --a) {
                if (a == 0 && b == 0 && c == 0) {
                    continue;
                }
                if (a + b + c > n) {
                    continue;
                }

                double p_waste = (double) (n - (a + b + c)) / n;
                exV[a][b][c] += (p_waste / (1 - p_waste)) * p[a][b][c];
                //cout << a << " " << b << " " << c << " " << exV[a][b][c] << "\n";

                ///remove from 1
                double p_go;
                if (a != 0) {
                    p_go = (double) a / (a + b + c);
                    p[a - 1][b][c] += p[a][b][c] * p_go;
                    exV[a - 1][b][c] += exV[a][b][c] * p_go;
                }

                ///remove from 2
                if (b != 0) {
                    p_go = (double) b / (a + b + c);
                    p[a + 1][b - 1][c] += p[a][b][c] * p_go;
                    exV[a + 1][b - 1][c] += exV[a][b][c] * p_go;
                }
                ///remove from 3
                if (c != 0) {
                    p_go = (double) c / (a + b + c);
                    p[a][b + 1][c - 1] += (double) p[a][b][c] * p_go;
                    exV[a][b + 1][c - 1] += (double) exV[a][b][c] * p_go;
                }
            }
        }
    }
    cout << setprecision(10) << exV[0][0][0] + cnt[1] + 2 * cnt[2] + 3 * cnt[3];
}

int main()
{
    read();
    solve();
    return 0;
}


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

string s;
int cnt[2] = {0};

int main() {
  cin >> s;
  for(int i = 0; i < s.size(); ++i) ++cnt[s[i] - '0'];
  cout << min(cnt[0], cnt[1]) * 2 << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<int> (a)((n))
using namespace std;
signed main(){
	int n,x,ans=0;
	cin >> n >> x;
	vec(a,n);
	REP(i,n){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	REP(i,n){
		if(x >= a[i]){
			x -= a[i];
			ans++;
		}else break;
	}
	if(ans == n && x > 0){
		ans--;
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/* 
* code by: imasnegi
**/

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define nl "\n"
#define spc " "
#define fr(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define deb(a) cout << #a << " " << a << nl;

template<typename T>
void printArray(vector<T>& v) {
	for(auto& i : v)
		cout << i << spc;
	cout << nl;
}
const int MaxN = 2e5 + 5;
const int MOD = 1e9 + 7;

void solve_cases() {
	int n;
	cin >> n;
	if(n >= 30) cout << "Yes" << nl;
	else cout << "No" << nl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cout << setprecision(10) << fixed;
	int t = 1;
	//cin >> t;
	FOR(tt, 1, t) {
		//cout << "Case #" << tt << ": ";
		solve_cases();
	}
}

Measured memory_bytes: 3668
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

######
# URL: https://atcoder.jp/contests/abc095/tasks/arc096_a
######

def main():
    a, b, c, x, y = l_inpl()
    ans = INF
    for i in range(max(x, y)*2+2):
        j = max(0, x-i//2)
        k = max(0, y-i//2)
        ans = min(ans, i*c+j*a+k*b)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 39536
#include<iostream>
using namespace std;
int N,A,B,C;
long mod=1e9+7;
long F[5050],I[5050];
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long comb(long a,long b){return F[a]*I[b]%mod*I[a-b]%mod;}
long H(long a,long b){return a==0?b==0:comb(a-1+b,b);}
main()
{
	cin>>N>>A>>B>>C;
	F[0]=1;
	for(int i=1;i<=N;i++)F[i]=F[i-1]*i%mod;
	I[N]=power(F[N],mod-2);
	for(int i=N;i--;)I[i]=I[i+1]*(i+1)%mod;
	if(B%2)
	{
		cout<<0<<endl;
		return 0;
	}
	long ans=0;
	for(int i=0;i<=C;i++)
	{
		for(int j=0;j<=A&&j+i<=C;j++)
		{
			if((C-i-j)%3)continue;
			(ans+=F[(C-i-j)/3+j+A-j+B/2]*I[(C-i-j)/3]%mod*I[j]%mod*I[A-j]%mod*I[B/2]%mod*H(B/2,i)%mod)%=mod;
			//(C-i-j)/3,j,A-j,B/2 naraberu
			//i B/2 furiwakeru
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
local a = tonumber(io.read())
local b = tonumber(io.read())
local c = tonumber(io.read())
local d = tonumber(io.read())

local aa = 0
local bb = 0

if a < b then
    aa = a
elseif a == b then
    aa = a
else
    aa = b
end

if c < d then
    bb = c
elseif c == d then
    bb = c
else
    bb = d
end
print(aa+bb)

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def left(N, S, a, i):
    a[i + 1] = 0
    v = 0
    while True:
        if i == 0:
            a[i] = v + 1
            break
        if S[i - 1] == ">":
            v += 1
            a[i] = v
            i -= 1
        else:
            a[i] = max(a[i], v + 1)
            break


def right(N, S, a, i):
    a[i] = 0
    v = 0
    while True:
        if i == N - 1:
            a[i + 1] = v + 1
            break
        if S[i + 1] == "<":
            i += 1
            v += 1
            a[i] = v
        else:
            a[i + 1] = max(a[i + 1], v + 1)
            break


def main():
    S = input().rstrip()
    N = len(S)

    a = [0] * (N + 1)
    if S[0] == "<":
        right(N, S, a, 0)
    if S[-1] == ">":
        left(N, S, a, N - 1)
    for i in range(N - 1):
        if S[i:i + 2] == "><":
            left(N, S, a, i)
            right(N, S, a, i + 1)
    
    ans = sum(a)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 29128
#include <bits/stdc++.h>
// #include<iostream>
// #include<vector>
// #include<cmath>
// #include<iomanip>
using namespace std;

const double PI= acos(-1.0);

int gcd_func(int a, int b){
    return b? gcd_func(b, a%b) : a;
} 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    long long n; cin >> n;
    string name = "";
    while(n){
        n--;
        name = (char)('a'+n%26) + name;
        n/=26;
    }
    cout << name;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long long
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int32_t main()
{
  BOOST;
	pii tab[5];
	for (int i=0;i<5;i++)cin>>tab[i].st,tab[i].nd=i+1;
	sort(tab,tab+5);
	cout<<tab[0].nd;
  return 0;
}


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

static const int N = 4;
static const int N2 = 16;
static const int LIMIT = 100;

static const int dx[4] = { 0, -1,  0, 1};
static const int dy[4] = { 1,  0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle {
  int f[N2], space, MD;
};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz) {
  int sum = 0;
  for (int i = 0; i < N2; i++) {
    if (pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
}

bool isSolved() {
  for (int i = 0; i < N2; i++) {
    if (state.f[i] != i+1) return false;
  }
  return true;
}

bool dfs(int depth, int prev) {
  if (state.MD == 0) return true;
  if (depth + state.MD > limit) return false;

  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;

  for (int r = 0; r < 4; r++) {
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
    if ((max(prev, r) - min(prev, r)) == 2) continue;

    tmp = state;
    state.MD -= MDT[tx*N+ty][state.f[tx*N+ty]-1];
    state.MD += MDT[sx*N+sy][state.f[tx*N+ty]-1];
    swap(state.f[tx*N+ty], state.f[sx*N+sy]);
    state.space = tx*N+ty;
    if (dfs(depth+1, r)) {
      path[depth] = r;
      return true;
    }
    state = tmp;
  }
  return false;
}

string iterative_deepening(Puzzle in) {
  in.MD = getAllMD(in);

  for (limit = in.MD; limit <= LIMIT; limit++) {
    state = in;
    if (dfs(0, -100)) {
      string ans = "";
      for (int i = 0; i < limit; i++) ans += dir[path[i]];
      return ans;
    }
  }
  return "Unsolvable";
}

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

    for (int i = 0; i < N2; i++) {
      for (int j = 0; j < N2; j++) {
        MDT[i][j] = abs(i/N - j/N) + abs(i%N - j%N);
      }
    }

    Puzzle in;
    for (int i = 0; i < N2; i++) {
      cin >> in.f[i];
      if (in.f[i] == 0) {
        in.f[i] = N2;
        in.space = i;
      }
    }

    string ans = iterative_deepening(in);
    cout << ans.size() << endl;

    return 0;
}

Measured memory_bytes: 3240
import sys
input=sys.stdin.readline

def main():
    H,W = map(int, input().split())
    
    S = []
    for _ in range(H):
        S.append(input().strip())
 
    u = [[0]*W for _ in range(H)]
    d = [[0]*W for _ in range(H)]
    l = [[0]*W for _ in range(H)]
    r = [[0]*W for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if S[y][x] == "#":
                u[y][x] = l[y][x] = 0
            else:
                u[y][x] = 1 if y == 0 else u[y-1][x] + 1
                l[y][x] = 1 if x == 0 else l[y][x-1] + 1
    for y in range(H-1,-1,-1):
        for x in range(W-1,-1,-1):
            if S[y][x] == "#":
                d[y][x] = r[y][x] = 0
            else:
                d[y][x] = 1 if y == H-1 else d[y+1][x] + 1
                r[y][x] = 1 if x == W-1 else r[y][x+1] + 1
 
    ans = 0
    for y in range(H):
        for x in range(W):
            ans = max(ans, u[y][x] + d[y][x] + l[y][x] + r[y][x] - 3)
            
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 176008
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

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

int main()
{
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans;
    if(A + B > 2 * C)
    {
        if(X > Y)
        {
            ans = min( 2*C * max(X,Y), 2 * C * Y + A * (X - Y));
        }
        else
        {
            ans = min( 2*C * max(X,Y), 2 * C * X + B * (Y - X));
        }
    }
    else
    {
        ans = A * X + B * Y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int a[10];
int n;
 
bool dfs(int i,int left,int right){
    if(i==10) return true;
    if(a[i]>left){
        return dfs(i+1,a[i],right);
    }
    if(a[i]>right){
        return dfs(i+1,left,a[i]);
    }
    return false;
}
 
void solve(){
    for(int i=0;i<10;i++) cin >> a[i];
    if(dfs(0,0,0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return;
}
 
int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        solve();
    }
    return 0;
}

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


int main(){
  int n;
  cin >> n;
  vector<int> v0(n/2), v1(n/2);
  for(int i = 0; i<n/2;i++){
    cin >> v0.at(i) >> v1.at(i);
  }

  vector<pair<int, int>> v0c(100001),  v1c(100001);

  for(int i = 0; i<n/2;i++){
    v0c[v0.at(i)].first += 1;
    v0c[v0.at(i)].second =v0.at(i);
    v1c[v1.at(i)].first += 1;
    v1c[v1.at(i)].second =v1.at(i);
  }
  sort(v0c.rbegin(), v0c.rend());
  sort(v1c.rbegin(), v1c.rend());

  if(v0c[0].second != v1c[0].second){
    cout << n - v0c[0].first - v1c[0].first << endl;
  }else{
    int ans = min(n-v0c[0].first - v1c[1].first, n-v0c[1].first - v1c[0].first);
    cout << ans << endl;
  }



}


Measured memory_bytes: 2176
VALUES = [500, 100, 50]

a = int(input())
b = int(input())
c = int(input())
x = int(input())

ways = 0
for ia in range(a + 1):
  for ib in range(b + 1):
    for ic in range(c + 1):
      s = ia * VALUES[0] + ib * VALUES[1] + ic * VALUES[2]
      ways += (1 if s == x else 0)
      
print(ways)

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

int main() {
	char s[11];
	char r[11];
	//char buf[64];
	int i,j,k;
	scanf("%s", s);

	for (i = 0, j=0; s[i] != '\0'; i++) {
		//fgets(buf, 64, stdin);
		if (s[i] == 'B') {
			j--;
			if (j < 0) j = 0;
		}
		else {
			r[j] = s[i];
			j++;
		}
	}
	for (k = 0, r[j] = '\0'; k < j; k++) printf("%c", r[k]);
	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	int n, m;
	cin >> n >> m;
	V<ll> d(n), dp(n, 0);
	V<V<ll>> e(n);
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		e[a].push_back(b);
		d[b]++;
	}
	queue<int>q;
	REP(i, n)if (d[i] == 0)q.push(i);
	while (q.size()) {
		int p = q.front();
		q.pop();
		for(auto j: e[p]){
			dp[j] = max(dp[p] + 1, dp[j]);
			d[j]--;
			if(d[j]==0)	q.push(j);
		}
	}
	cout << *max_element(ALL(dp)) << endl;
	
	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
//-------head-------
const int N = 1e5 + 7;
int n, x, a[N];
ll solve() {
	ll ret = 0;
	if (a[0] > x) {
		int tmp = a[0] - x;
		ret += tmp, a[0] -= tmp;
	}
	rep(i, 1, n) 
		if (a[i - 1] + a[i] > x) {
			int tmp = a[i - 1] + a[i] - x;
			ret += tmp, a[i] -= tmp;
		}
	return ret;
}
int main() {
	scanf("%d%d", &n, &x);
	rep(i, 0, n)
		scanf("%d", &a[i]);
	printf("%lld", solve());
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
using namespace std;
#define ll long long
ll H,W,N,ans[10],y,x,dy[9]={-1,-1,-1,0,0,0,1,1,1},dx[9]={0,1,2,0,1,2,0,1,2};
map<ll,ll> chk;
int main()
{
	cin >> H >> W >> N;
	ans[0]=(H-2)*(W-2);
	
	for(int i=0; i<N; i++)
	{
		cin >> y >> x;
		map<ll,ll> c;	
	
		for(int j=0; j<9; j++)
		{
			ll py=y+dy[j],px=x+dx[j],p=(py-2)*(W-2)+(px-3);
			if(py<=H&&py>=2&&px<=W&&px>=3&&p<(H-2)*(W-2)&&!c[p])
			{
				c[p]=1;
				if(!chk[p])
				{
					chk[p]=1;
					ans[0]--,ans[1]++;
				}
				else if(chk[p]<=9)
				{
					ans[chk[p]]--;
					chk[p]++;
					ans[chk[p]]++;
				}
			}
		}
	}
	for(int i=0; i<10; i++)
	cout << ans[i] << "\n";
}

Measured memory_bytes: 56448
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 3007;

long long dp[N][N];

string s, t;

int abs(int val) {
    return max(val, -val);
}

int main()
{
    int n, tw, val, cst;
    cin >> s >> t;
    for (int i = 1; i <= s.size(); ++i)
        for (int j = 1; j <= t.size(); ++j)
            dp[i][j] = max(max(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1] + (s[i - 1] == t[j - 1]));
    int ci(s.size()), cj(t.size());
    string ans;
    while (ci && cj) {
        if (dp[ci][cj] == dp[ci - 1][cj]){
            --ci;}
        else if (dp[ci][cj] == dp[ci][cj - 1]) {
            --cj;}
        else {
            --ci;
            --cj;
            ans = ans + s[ci];
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int a[MAX_N],b[MAX_N],c[MAX_N];

int main(){
  int N; cin >> N;
  rep(i,N) scanf("%d",a+i);
  copy(a,a+N,b);
  sort(b,b+N);
  int ans = 0;
  rep(i,N){
    int ind = int(lower_bound(b,b+N,a[i])-b);
    if(i%2==0 && ind%2==1) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define int long long
#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) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
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 long double PI = 3.1415926535897932384626433832795028L;
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 T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &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, A[110000];
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i]; }
    bool flag = true;
    rep(i, N) {
        if (~A[i] & 1) { flag &= A[i] % 3 == 0 || A[i] % 5 == 0; }
    }
    if (flag) { cout << "APPROVED" << endl; }
    else { cout << "DENIED" << endl; }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] arr = new int[3];
        for(int i=0;i<3;++i)
            arr[i] = Integer.parseInt(st.nextToken());
        Arrays.sort(arr);
        bw.write((arr[0]+arr[1])+"");
        bw.close();
    }

}


Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
 
using vd=vector<double>;
using vvd=vector<vd>;
 
 
int main(){
    int h,w;
    cin>>h>>w;
    vvi f(h+2,vi(w+2,1));
    vvi walk(h+2,vi(w+2,0));
    int gy,gx,y=0,x=0,v=0;
    range(i,1,h+1)range(j,1,w+1){
        char c;
        cin>>c;
        switch(c){
            case 'G': gy=i,gx=j,f[i][j]=0; break;
            case '.': f[i][j]=0;break;
            case '#': break;
            case '^': y=i,x=j,v=0,f[i][j]=0; break;
            case '>': y=i,x=j,v=1,f[i][j]=0; break;
            case 'v': y=i,x=j,v=2,f[i][j]=0; break;
            case '<': y=i,x=j,v=3,f[i][j]=0; break;
        }
    }
    walk[y][x]=1;
    rep(loop,(2650+2660)/2){
        vvi vec={{-1,0},{0,1},{1,0},{0,-1}};
        if(f[y+vec[(v+1)%4][0]][x+vec[(v+1)%4][1]]==0){ //右手が道なら右に曲がって前に進む
            //cout<<"hoge";
            v=(v+1)%4;
            y+=vec[v][0], x+=vec[v][1];
            walk[y][x]=1;
        }else if(f[y+vec[v][0]][x+vec[v][1]]==1){ //（右が壁で、）正面が壁なら左に回る
            //cout<<"fuga";
            v=(v+3)%4;
        }else{ //そうでないならまえに進む
            //cout<<"zako";
            y+=vec[v][0],x+=vec[v][1];
            walk[y][x]=1;
        }
        if(y==gy&&x==gx){
            break;
        }
        // cout<<y<<","<<x<<","<<v<<endl;
        // rep(i,h+2){
        //     rep(j,w+2){
        //         if(i==y&&j==x){
        //             cout<<"^>v<"[v];
        //         }else{
        //             cout<<".#"[f[i][j]];
        //         }
        //     }
        //     cout<<endl;
        // }
    }
    if(y==gy&&x==gx){
        int ans=0;
        rep(i,h+2)rep(j,w+2)ans+=walk[i][j];
        cout<<ans<<endl;
    }else cout<<-1<<endl;
    return 0;
}


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

int main () {
  char n[20];
  scanf("%s", n);
  int len_ = strlen(n);
  int sum1 = 0, sum2 = 0;
  for (int i = 0;i < len_; ++i) sum1 += n[i] - '0';
  sum2 += n[0] - '0' - 1, sum2 += (len_ - 1) * 9;

  printf("%d\n", max(sum1, sum2));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
const int MAXN = 100000;
const int P = 1e9 + 7;
using namespace std;

int n;

namespace tree {

const int MAXM = 2 * MAXN;

int rt, tot, head[MAXN + 5];

struct Edge {
  int to, nxt;
  Edge() {}
  Edge(int _to, int _nxt) : to(_to), nxt(_nxt) {}
} edge[MAXM + 5];

void init() {
  tot = 0, memset(head, -1, sizeof(head));
  rt = 1;
}

inline void addEdge(int u, int v) {
  edge[tot] = Edge(v, head[u]), head[u] = tot++;
  edge[tot] = Edge(u, head[v]), head[v] = tot++;
}

LL dp[MAXN + 5][2];

void dfs(int u, int fa) {
  dp[u][0] = dp[u][1] = 1;
  for (int i = head[u]; ~i; i = edge[i].nxt) {
    int v = edge[i].to;
    if (v == fa) continue;
    dfs(v, u);
    dp[u][0] = dp[u][0] * ((dp[v][0] + dp[v][1]) % P) % P;
    dp[u][1] = dp[u][1] * dp[v][0] % P;
  }
}

void solve() {
  dfs(rt, -1);
  cout << (dp[rt][0] + dp[rt][1]) % P << endl;
}

}

void init() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  tree::init();

  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v; cin >> u >> v;
    tree::addEdge(u, v);
  }
}

int main() {
#ifdef forever23
  freopen("test.in", "r", stdin);
#endif
  init();

  tree::solve();
  return 0;
}

Measured memory_bytes: 9344
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
#define MAX 100100
//#define NIL -1

int main() {
    int n;
    int t;
    vector<pair<int, int>> ct;
    int tmp_c;
    int tmp_t;
    int ans=MAX;

    cin >> n >> t;
    for(int i=0; i<n; i++){
        cin >> tmp_c >> tmp_t;
        ct.push_back(make_pair(tmp_c, tmp_t));
    }
    for(int i=0; i<n; i++){
        if(ct[i].second<=t){
            if(ct[i].first<ans){
                ans=ct[i].first;
            }
        }
    }
    if(ans==MAX){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256