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

//long long
using ll = long long;

// pair<int, int>
using PII = pair<int, int>;

//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;

//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

// a = max(a, b), a = min(a, b)
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; }

// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}



// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う

// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    vector<ll> ans;
    vector<int>d[200010];
void dfs(int v, int p) {
  for (int u : d[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}

int main(){
    int N, Q;
    cin >> N >> Q;
    REP(i, N - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        d[a].push_back(b);
        d[b].push_back(a);
    }
    ans.resize(N);
    // vector<pair<int, int>> pa(Q);
    REP(i, Q){
        int p, x;
        cin >> p >> x;
        p--;
        // pa.at(i).first = p;
        // pa.at(i).second = x;
        ans.at(p) += x;
}
        // sort(all(pa));

        // REP(i, Q){
        //     int cnt = pa.at(i).first;
        //     ans.at(cnt) += pa.at(i).second;
        // }
        // REP(i, N){
        //     REP(j, d[i].size()){
        //         ans.at(d[i].at(j)) += ans.at(i);
        //     }
        // }
    dfs(0, -1);
        REP(i, N){
            cout << ans.at(i);
            if(i < N - 1) cout << ' ';
        } 
 
    cout << endl;
    return 0;
}

Measured memory_bytes: 25728
#include <stdio.h>
 
int main(void)
{
	char s[5];
	int i,n=0;
	scanf("%s",s);
	for(i=0; i<4; i++){
		if(s[i]=='+'){
			n=n+1;
		}else{
			n=n-1;
		}
	}
	printf("%d\n",n);
}

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

int main() {
	// your code goes here
	long long int n, m;
	long long int tot=0;
	cin>>n>>m;
	for(int i=0;i<m;i++){
	    int x;
	    cin>>x;
	    tot+=x;
	}
	if(n-tot>=0){
	    cout<<n-tot;
	}
	else{
	    cout<<-1;
	}
	return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main(){
	int N, K;
	int A[200000];
	cin >> N >> K;
	fill(A, A + N, 0);
	for(int i = 0; i < N; i++){
		int input;
		cin >> input;
		input--;
		A[input]++;
	}
	sort(A, A + N);
	int ans = 0;
	for(int i = 0; i < N - K; i++){
		ans += A[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

dp=[-1]*100100
G=[[] for _ in range(100100)]

def dfs(v):
  if dp[v]!=-1:
    return dp[v]

  x=0
  for w in G[v]:
    r=dfs(w)+1
    x=max(x,r)

  dp[v]=x
  return x

def main():
  n,k=LI()
  for _ in range(k):
    a,b=LI()
    a-=1
    b-=1
    G[a].append(b)

  ans=0
  for i in range(n):
    ans=max(ans,dfs(i))

  return ans

# main()
print(main())


Measured memory_bytes: 61052
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

int main()
{
    string S;
    cin >> S;
    ll N = S.size();
    if (N <= 7) {
        cout << "YES" << endl;
    } else {
        ll cnt = 0;
        rep(i, N) {
            if (S[i] == 'x') {
                cnt++;
            }
        }
        if (cnt >= 8) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
using namespace std;
bool check(int *a,int n,int p){
	for(int i = 0; i < n; i++){
		if(a[i] == p){
			printf("%d\n",i);
			return true;
		}
	}
	return false;
}
int main(){
	int n,p;
	while(scanf("%d%d",&n,&p),n){
		int koisi[55]={0};
		int index = 0;
		int cha = p;
		while(!check(koisi,n,p)){
			if(cha > 0){
				koisi[index]++;
				cha--;
			}
			else if(cha == 0){
				cha = koisi[index];
				koisi[index] = 0;
			}
			++index%=n;
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n, m;

struct PP {
	int l, r;
} p[maxx];

int main() {
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++) scanf("%d %d", &p[i].l, &p[i].r);
	int L = p[1].l, R = p[1].r;
	for(int i = 2; i <= m; i++) {
		L = max(L, p[i].l);
		R = min(R, p[i].r);
	}
	if(L > R) puts("0");
	else printf("%d\n", R - L + 1);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pair<int, int>, int> ppi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef bitset<60> Bitset;
const ll INFL = 1LL << 60;
const int INF = 1000000005;
const int MAX = 300000;
const int MOD = 1000000007;
struct Graph{int to,coin; ll cost;};
struct Edge{int from,to,coin; ll cost;};
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int h,w,K;cin>>h>>w>>K;
    string s[6];
    for(int i = 0; i < h; i++) cin>>s[i];
    int ans = 0;
    for(int i = 0; i < (1<<h); i++) {
        for(int j = 0; j < (1<<w); j++) {
            string c[6];
            for(int k = 0; k < h; k++) c[k] = s[k];
            for(int k = 0; k < h; k++) {
                if(i&(1<<k)){
                    for(int l = 0; l < w; l++) {
                        c[k][l] = '.';
                    }
                }
            }
            for(int k = 0; k < w; k++) {
                if(j&(1<<k)){
                    for(int l = 0; l < h; l++) {
                        c[l][k] = '.';
                    }
                }
            }
            int cnt = 0;
            for(int k = 0; k < h; k++) {
                for(int l = 0; l < w; l++) {
                    if(c[k][l]=='#') cnt++;
                }
            }
            if(cnt==K) ans++;
        }
    }
    cout<<ans<<endl;
}


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

int main(void){
    int i, j, H, W;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0) break;
        for(i=0; i<H; i++){
            for(j=0; j<W; j++){
                if(i%2==0 && j%2==0) cout << "#";
                if(i%2==0 && j%2==1) cout << ".";
                if(i%2==1 && j%2==0) cout << ".";
                if(i%2==1 && j%2==1) cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
n = int(input())
cnt = 0
a = 0
b = 0
f = 0
for i in range(n):
  s = input()
  cnt += s.count('AB')
  if s[0] == 'B' and s[-1] == 'A':
    f += 1
  elif s[0] == 'B':
    b += 1
  elif s[-1] == 'A':
    a += 1

if n == 1:
  print(cnt)
  exit()

if f >= 1:
  if a >= 1:
    cnt += 1
    a -= 1
  if b >= 1:
    cnt += 1
    b -= 1
print(cnt + max(0, f - 1) + min(a, b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl ("\n")
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define fr(i,n) for(i=0;i<n;i++)
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
 
ll expo (ll x, ll y) {ll res = 1; while (y) {if (y & 1)res = res * x; res %= MOD; y = y >> 1; x = x * x; x %= MOD;} return res;}


ll dp[3001][3001];
void solve()
{   
   ll i,j;
   string s,t;
   cin>>s>>t;
   vector<char> ans;
   ll n=s.size();
   ll m=t.size();
 
    ms(dp,0,sizeof(dp));
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    i=n;j=m;
    while((i>=1) && (j>=1))
    {
        if(s[i-1]==t[j-1])
        {
            ans.pb(s[i-1]);
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
            i--;
            else
            j--;
        }
        
    }
    //cout<<dp[n][m]<<endl;
   for(i=ans.size()-1;i>=0;i--)
   cout<<ans[i];
}
int main() 
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);
#endif
    fast;
    // Fuck Ratings, I'm in Love with Experience. 
    int t = 1;
    
    //cin >> t;
    while(t--) {
      solve();
    }
    return 0;
}


Measured memory_bytes: 73932
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 200005
#define fr first
#define se second
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main()
{
   fast;
   unordered_map <string,int> mp;
   mp["SAT"] = 6;
   mp["SUN"] = 7;
   mp["MON"] = 13;
   mp["TUE"] = 12;
   mp["WED"] = 11;
   mp["THU"] = 10;
   mp["FRI"] = 9;
   string s1;
   cin >> s1;
   int k = abs(mp[s1]-mp["SUN"]);
   k == 0 ? cout << 7 << "\n" : cout << k << "\n";

   return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"
const int MOD = 1e9+7;

int A[100];
ll dp[101][100005];
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  IN(N); IN(K);
  REP(i, 101) REP(j, 100005) dp[i][j] = 0LL;
  dp[0][0] = 1LL;

  REP(i, N) {
    cin >> A[i];
  }
  REP(i, N) {
    REP(j, K+1) {
      dp[i+1][j] = dp[i][j];
      if (j - 1 >= 0)
        dp[i+1][j] += dp[i+1][j-1];
      if (j - A[i] - 1 >= 0)
        dp[i+1][j] -= dp[i][j-1-A[i]];
      dp[i+1][j] = (dp[i+1][j] + MOD) % MOD;
    }
  }
  OUT(dp[N][K] % MOD);

  return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define ll long long
#define N 1010
#define M 10000010
using namespace std;

struct block{ ll w,s,v; };

int n;
ll ans,dp[M];
block bs[N];

bool cmp(block a, block b) { return (a.w+a.s<b.w+b.s); }

int main()
{
    cin>>n; FOR(i,0,n) cin>>bs[i].w>>bs[i].s>>bs[i].v;
    sort(bs,bs+n,cmp);
    FOR(i,0,n)
    {
        for(int j=bs[i].s;j>=0;j--)
        {
            dp[j+bs[i].w]=max(dp[j+bs[i].w],dp[j]+bs[i].v);
        }
    }
    FOR(i,0,M) ans=max(ans,dp[i]);    
    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 384
using System;
namespace question1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] inp = Console.ReadLine().Split(' ');
                int sx = int.Parse(inp[1]);
                if (sx == 0)
                    break;
                int sy = int.Parse(inp[0]);
                char[,] ma = new char[sy, sx];
                char[,] l = new char[sy, sx];
                for (int i = 0; i < sy; i++)
                {
                    char[] a = Console.ReadLine().ToCharArray();
                    for (int j = 0; j < sx; j++)
                        ma[i, j] = a[j];
                }

                int x = 0, y = 0;
                while (true)
                {
                    bool end = false;
                    switch (ma[y, x])
                    {
                        case '^':
                            y -= 1;
                            break;
                        case 'v':
                            y += 1;
                            break;
                        case '<':
                            x -= 1;
                            break;
                        case '>':
                            x += 1;
                            break;
                        default:
                            end = true;
                            break;
                    }
                    if (end)
                    {
                        Console.WriteLine(x.ToString() + " " + y.ToString());
                        break;
                    }
                    if (l[y, x] == '1')
                    {
                        Console.WriteLine("LOOP");
                        break;
                    }
                    l[y, x] = '1';
                }
            }
            return;
        }
    }
}

Measured memory_bytes: 9320
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
long long int mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////

int main(){
    int n, l; cin >> n >> l;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    int p = -1;
    for(int i=0; i<n-1; i++) {
        if(a[i] + a[i+1] >= l) {
            p = i+1;
            break;
        }
    }
    if(p == -1) {
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;
    for(int i=1; i<p; i++) {
        cout << i << endl;
    }
    for(int i=n-1; i>p; i--) {
        cout << i << endl;
    }
    cout << p << endl;

    return 0;
}

// EOF



Measured memory_bytes: 1152
A,B,K=map(int,input().split(' '))
l=[A,B]
for i in range(K):
	p=l[i%2]
	l[i%2] = (p-(p%2))/2
	l[(i+1)%2] += (p-(p%2))/2
print(' '.join([str(int(x)) for x in l]))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;

const ll mod=1e9+7;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}

int n;
vector<int> g[200200];
ll p[200200];
ll d[202020];

ll q[202020];
ll qq[202020];

void dfs(int s,int pp){
	d[s]=1;
	for(int t:g[s]){
		if(t==pp)continue;
		p[t]=s;
		dfs(t,s);
		d[s]+=d[t];
		(q[s]*=q[t])%=mod;
	}
	(q[s]*=mod_pow(d[s],mod-2))%=mod;
}

void dfs2(int s,int p){
	ll re=1;
	for(int t:g[s]){
		if(t==p)continue;
		(re*=q[t])%=mod;
	}
	for(int t:g[s]){
		if(t==p)continue;
		(qq[t]*=qq[s]*re%mod*mod_pow(q[t],mod-2)%mod*mod_pow((n-d[t]),mod-2)%mod)%=mod;
		dfs2(t,s);
	}
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1;i<n;i++){
		int a,b; cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(int i=0;i<n;i++){
		q[i]=1;
		qq[i]=1;
	}
	p[0]=-1;
	dfs(0,-1);
	dfs2(0,-1);
	ll res=1;
	for(int i=1;i<n;i++){
		(res*=i)%=mod;
	}
	for(int i=0;i<n;i++){
		ll ans=res;
		for(int t:g[i]){
			if(p[t]==i){
				(ans*=q[t])%=mod;
			}else{
				(ans*=mod_pow(n-d[i],mod-2))%=mod;
				ll re=q[t];
				(re*=d[t])%=mod;
				(re*=mod_pow(q[i],mod-2))%=mod;
				(ans*=re)%=mod;
				(ans*=qq[t])%=mod;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 20212
using System;
using System.Collections.Generic;
using System.Linq;
public class Permutation
{
    public IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items)
    {
        return _GetPermutations<T>(new List<T>(), items.ToList());
    }

    private IEnumerable<T[]> _GetPermutations<T>(IEnumerable<T> perm, IEnumerable<T> items)
    {
        if (items.Count() == 0)
        {
            yield return perm.ToArray();
        }
        else
        {
            foreach (var item in items)
            {
                var result = _GetPermutations<T>(perm.Concat(new T[] { item }),
                                                    items.Where(x => x.Equals(item) == false)
                                );
                foreach (var xs in result)
                    yield return xs.ToArray();
            }
        }
    }
}

class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split();
        string[] input2 = Console.ReadLine().Split();
        int[] A = new int[N];
        int[] B = new int[N];
        int[] temp = new int[N];
        int pattern = 1;
        for (var i = 0; i < N; i++)
        {
            A[i] = int.Parse(input[i]);
            B[i] = int.Parse(input2[i]);
            pattern *= (i + 1);
            temp[i] = i+1;
        }
        int[,] xx = new int[pattern, N];
        // 確認用コード
        var perm = new Permutation();
        int count = 0,a_num=0,b_num=0;
        bool A_flag = true;
        bool B_flag = true;
        foreach (var n in perm.Enumerate(temp))
        {
            A_flag = true;B_flag = true;
            for (int i = 0; i < N; i++)
            {
                xx[count, i] = n[i];
                if (A[i] != n[i]) A_flag = false;
                if (B[i] != n[i]) B_flag = false;
            }
            count++;
            if (A_flag == true) { a_num = count; }
            if (B_flag == true) { b_num = count; }
        }
        Console.WriteLine(Math.Abs(a_num - b_num));
    }
}

Measured memory_bytes: 19692
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

#define ALL(V) (V).begin(),(V).end()

using namespace std;

typedef pair<int,int> ii_t;

#define cerr if(false)cerr

int r[4010]={0};
int g[4010]={0};
int b[4010]={0};

const char *rgb = "RGB";

int main() {
    int n;
    string buf;
    cin >> n >> buf;

    for (int i=n-1;i>=0;i--) {
            r[i] = r[i+1];
            g[i] = g[i+1];
            b[i] = b[i+1];

        if (buf[i]=='R') {
            r[i]++;
        } else if (buf[i]=='G') {
            g[i]++;
        } else {
            b[i]++;
        }
    }
    long long answer = 0;
    for (int i=0;i<n;i++) {
        for (int j=i+1;j<n;j++){
            if (buf[i] != buf[j]) {
                for (int k=0;k<3;k++) {
                    if (buf[i] == rgb[k] || buf[j] == rgb[k]) continue;
                    if (rgb[k] == 'R') {
                        answer += r[j+1];
                        if (buf[2*j-i] == 'R') answer--;
                        cerr << "i=" << i << " " << buf[i];
                        cerr << " j=" << j << " " << buf[j];
                        cerr << " a=" << answer << endl;
                    } else if (rgb[k] == 'G') {
                        answer += g[j+1];
                        if (buf[2*j-i] == 'G') answer--;
                        cerr << "i=" << i << " " << buf[i];
                        cerr << " j=" << j << " " << buf[j];
                        cerr << " a=" << answer << endl;
                    } else {
                        answer += b[j+1];
                        if (buf[2*j-i] == 'B') answer--;
                        cerr << "i=" << i << " " << buf[i];
                        cerr << " j=" << j << " " << buf[j];
                        cerr << " a=" << answer << endl;
                    }
                }
            }
        }
    }
    cout << answer << endl;
    return 0;
}


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

int main(void){
  int n;
  cin >> n;
  
  vector<int> p(n + 2);
  
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  
  int count = 0;
  
  for (int i = 1; i < n - 1; i++) {
    if((p.at(i-1) < p.at(i) && p.at(i) < p.at(i+1)) || (p.at(i+1) < p.at(i) && p.at(i) < p.at(i-1))){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  vector<Int> b(n*3);
  for(Int i=0;i<n;i++) b[i]=b[n+i]=b[n*2+i]=a[i];
  b.emplace(b.begin(),0);
  partial_sum(b.begin(),b.end(),b.begin());
  
  auto calc=[&](Int x){
    for(Int i=0;i<n;i++){
      Int p=i;
      p=lower_bound(b.begin()+p,b.end(),b[p]+x)-b.begin();
      p=lower_bound(b.begin()+p,b.end(),b[p]+x)-b.begin();
      p=lower_bound(b.begin()+p,b.end(),b[p]+x)-b.begin();
      if(p-i<=n) return 1;
    }
    return 0;
  };
  
  Int l=0,r=accumulate(a.begin(),a.end(),(Int)0);
  while(l+1<r){
    Int m=(l+r)>>1;
    if(calc(m)) l=m;
    else r=m;
  }
  cout<<l<<endl;
  return 0;
}



Measured memory_bytes: 8404
local k, x = string.match(io.read(), "(%d+) (%d+)")
k, x = tonumber(k), tonumber(x)
local min = math.max(x - (k - 1), -1000000)
local max = math.min(x + (k - 1), 1000000)

local result = {}
for i = min, max, 1 do
  table.insert(result, tostring(i))
end

print(table.concat(result, " "));

Measured memory_bytes: 760
#include <iostream>
#include <cstring>
int main() {
    int N; std::cin >> N;
    double ans = 0;
    for (int i = 0; i < N; ++i) {
        double x; char buf[4]; std::cin >> x >> buf;
        ans += (strcmp(buf, "BTC") ? x : (x * 380000.0));
    }
    std::cout << std::fixed;
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
char a[201];
int c;
int main(int argc, char const *argv[])
{
	scanf("%s",a);
	for(int i = 0; i < strlen(a); i++){
		if(a[i] == 'C') c++;
		if(a[i] == 'F' && c){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())                                                                                                                         
B = list(map(int, input().split()))
 
S = [[0]*M for i in range(N)]
for i in range(N):
    S[i] = list(map(int, input().split()))
  
b = 0
  
for i in range(N):
    a = 0
    for ii in range(M):
        a += S[i][ii] * B[ii]
    a += C
    if a > 0:
        b += 1
print(str(b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
    int N, M; cin >> N >> M;
    vector<int> G(N+1, 0);
    for (int i = 0; i < M; ++i) {
        int l, r; cin >> l >> r; r++;
        G[l]++;
        G[r]--;
    }

    for (int i = 1; i <= N; ++i) G[i+1] += G[i];
    int res = 0;
    for (int i = 1; i <= N; ++i) if (G[i] == M) ++res;
    cout << res << endl;
}

Measured memory_bytes: 640
n , m= map(int, input().split())

li = [list(map(int, input().split())) for _ in range(n)]

li.sort()
ans = 0

for i in li:
    if m <= i[1]:
        ans += m * i[0]
        break
    ans += i[0] * i[1]
    m -= i[1]

print(ans)

Measured memory_bytes: 27756
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

vector<int> G[100010];
typedef pair<int, int> P;
map<P, int> mp;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[100010], b[100010];
    rep(i, N - 1) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    set<int> st;
    rep(i, N) {
        set<int> tmp;
        for(auto to: G[i]) {
            int c = mp[{i, to}];
            if (c != 0) {
                tmp.insert(c);
            }
        }
        int cnt = 1;
        for(auto to: G[i]) {
            if(mp[{i, to}] == 0) {
                while(tmp.find(cnt) != tmp.end()) cnt++;
                mp[{i, to}] = cnt;
                mp[{to, i}] = cnt;
                st.insert(cnt);
                cnt++;
            }
        }
    }
    cout << st.size() << endl;
    rep(i, N - 1) {
        cout << mp[{a[i], b[i]}] << endl;
    }


    return 0;
}


Measured memory_bytes: 19328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	int s;
	vector<int>ss;
	for (int i = 0; i < 3; i++)
	{
		cin >> s;
		ss.push_back(s);
	}
	sort(ss.begin(), ss.end());
	ss.erase(unique(ss.begin(), ss.end()), ss.end());
	if (ss.size()==2)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF  int(1e6+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	long long int a, b,t;
	cin >> a >> b;
	if (a < b) {
		t = a;
		a = b;
		b = t;
	}
	long long int x,na=a,nb=b;
	while (nb) {
		x = nb;
		nb = na % nb;
		na = x;
	}
	cout << a * b / na << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

const int N = 1e5+5;
vector<ll> vec;

bool exists(ll num, int ind) {
    auto it = lower_bound(all(vec), num);
    if(it != vec.end() && *it == num) {
        if((int(it-vec.begin())) == ind) {
            it = lower_bound(it+1, vec.end(), num);
            if(it != vec.end() && *it == num) {
                return true;
            }
            else {
                return false;
            }
        }
        return true;
    }
    return false;
}

bool check(ll num, int ind) {
    for(ll i = 1; i*i<=num; i++) { 
        if(num % i == 0) {
            if(exists(i, ind)) return true;
            else if(exists(num/i, ind)) return true;
        }
    }
    return false;
}

int main() 
{ 
    fastio
    int n;
    cin>>n;
    vec.assign(n, 0);
    for(int i = 0; i<n; ++i) cin>>vec[i];

    sort(all(vec));
    int ans = 0;
    for(int i = 0; i<n; ++i) {
        ll cur = vec[i];
        if(check(cur, i) == 0) {
            //cout<<i<<endl;
            ans++; 
        }
    }  
    cout<<ans<<endl;
} 

Measured memory_bytes: 4708
#include <iostream>
using namespace std;
int h, w, bom[50][50];
int dx[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
string field[50];

int main(void){
    // Your code here!
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> field[i];
    for (int x = 0; x < h; x++) {
        for (int y = 0; y < w; y++) {
            if (field[x][y] == '#') {
                for (int i = 0; i < 8; i++) {
                    int nx = x + dx[i], ny = y + dy[i];
                    if (nx >= 0 && nx < h && ny >= 0 && ny < w && field[nx][ny] != '#') bom[nx][ny]++;
                }
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (field[i][j] == '#') cout << '#';
            else cout << bom[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod (int)(1e9 + 7)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int r,c;
    char ch;
    cin>>r>>c;
    int a[r][c];
    memset(a,0,sizeof(a));
    
    for(int i=0;i<r;++i)
    {
        for(int j=0;j<c;++j)
        {
            cin>>ch;
            if(ch=='.')
            {
                a[i][j] = 0;
            }
            else
            {
                a[i][j] = -1;
            }
        }
    }   
    for(int i=0;i<c;++i)
    {
        if(a[0][i] == -1)
            break;
        a[0][i] = 1;
    }
    for(int i=0;i<r;++i)
    {
        if(a[i][0] == -1)
            break;
        a[i][0] = 1;
    }

    for(int i=1;i<r;++i)
    {
        for(int j=1;j<c;++j)
        {
            if(a[i][j] == -1)
                continue;

            if(a[i-1][j] != -1){
                a[i][j] += a[i-1][j];
                a[i][j] %= mod;
            }
            if(a[i][j-1] != -1){
                a[i][j] += a[i][j-1];
                a[i][j] %= mod;
            }
        }
    }
    // for(int i=0;i<r;++i)
    // {
    //     for(int j=0;j<c;++j)
    //     {
    //         cout<<a[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<a[r-1][c-1]<<endl;
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main(){
   int n,m;
   cin >> n >> m;
   vector<vector<int>> g(n);
   rep(i,m){
      int a,b;
      cin >> a >> b;
      g[a-1].push_back(b-1);
      g[b-1].push_back(a-1);
   }
   if(g[0].size()==0){
      cout <<"No"<<endl;
      return 0;
   }

   bool seen[n];
   memset(seen,false,sizeof(seen));
   queue<int> q;
   q.push(0);
   seen[0] = true;
   int ans[n];
   while(true){
      int index = q.front();
      q.pop();
      rep(i,g[index].size()){
         int k = g[index][i];
         if(seen[k]) continue;
         seen[k]=true;
         ans[k]=index+1;
         q.push(k);
      }

      if(q.size()==0)break;
   }
   cout <<"Yes"<<endl;
   rep(i,n-1)cout << ans[i+1] << " "<<endl;
   return 0;
}

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

int main() {
  int n, l;
  cin >> n >> l;
  
  int all_aji = 0;
  for (int i = 0; i < n; i++) all_aji += l+i;
  int d = 101;
  for (int i = 0; i < n; i++) d = min(d, abs(l+i));
  if (all_aji < 0) cout << all_aji+d << endl;
  else cout << all_aji-d << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class C
{
	public static void Main()
	{
		int N = GetInt();
		long[] csum = new long[N+1];
		for(int i = 1; i <= N; i++)
			csum[i] = csum[i-1] + GetLong();

		long ans = long.MaxValue;
		for(int i = 1; i <= N-1; i++)
		{
			long x = csum[i];
			long y = csum[N] - csum[i];
			ans = Math.Min(ans, Math.Abs(x - y));
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 35164
#include <bits/stdc++.h>
using namespace std;
char s[1000001];
long long a=0,b=0;
int main()
{
	cin>>s;
	a=strlen(s)-2;
	for (int i=0,j=strlen(s)-1;i<j;i++,j--)
	{
		if (s[i]==s[j])
		b++;
	}
	if (b==(a+2)/2)
	cout<<"Second";
	else
	{
	if (s[0]==s[strlen(s)-1])
	{
		a=a-1;
		if (a%2==0)
		cout<<"Second";
		else
		cout<<"First";
	}
	else
	{
	if (a%2==0)
	cout<<"Second";
	else
	cout<<"First";	
	}
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long 

using namespace std;
const long double PI = acos(-1);
const int maxn = 2e5 + 7;

int n, m, a[maxn];
vector<int> vt[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
    cin >> n;
    for(int i = 2; i <= n; i++)
    {
        int x;
        cin >> x;
        vt[x].push_back(i);
    }
    for(int i = 1; i <= n; i++) cout << vt[i].size() << "\n";
}

Measured memory_bytes: 14568
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;i++)
using namespace std;
void cmax(int&x,const int&y){x=x>y?x:y;}
void cmin(int&x,const int&y){x=x<y?x:y;}
const int N=2e5+1;
int sz[N];
int fa[N];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void merge(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	fa[x]=y;
	sz[y]+=sz[x];
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	rep(i,1,n)
	fa[i]=i,sz[i]=1;
	int m;
	cin>>m;
	while(m--){
		int x,y;
		cin>>x>>y;
		merge(x,y);
	}
	int ans=1;
	rep(i,1,n)cmax(ans,sz[i]);
	cout<<ans<<'\n';
	return 0;
}


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

ans_field = [['']*(w+2) for i in range(h+2)]

for i in range(1,w+1):
    for j in range(1,h+1):
        if field[j-1][i-1] == '#':
            ans_field[j][i] = '#'




for i in range(1,w+1):
    for j in range(1,h+1):
        if ans_field[j][i] == '#':
            continue
        c = 0
        for k in range(3):
            if ans_field[j-1][i-1+k] == '#':
                c += 1
        
        if  ans_field[j][i-1] == '#':
            c += 1
        
        if  ans_field[j][i+1] == '#':
            c += 1
        
        for k in range(3):
            if ans_field[j+1][i-1+k] == '#':
                c += 1
        
        ans_field[j][i] = str(c)

for i in range(1,h+1):
    s = ''
    for j in range(1,w+1):
        s += ans_field[i][j]
    
    print(s)

Measured memory_bytes: 3188
while True:

    x, y, z = input().split()
    l = int(x)
    r = int(z)
    if y == '+':
        print(l + r)
    elif y == '-':
        print(l - r)
    elif y == '/':
        print(l // r)
    elif y == '*':
        print(l * r)
    else:
        break

Measured memory_bytes: 7652
// template version 1.2
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

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

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0LL)
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

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

template<typename A, size_t N, typename T> // n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  //input
  int k;cin>>k;
  int a[k];
  rep(i, k){
    cin>>a[i];
  }

  int l = 2; int r = 2;
  rrep(i, k){
    l = (l+a[i]-1)/a[i] * a[i];
    r = r/a[i] * a[i] + (a[i]-1);
    dump(l, r);
    if (r < l) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << l << " " << r << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

using namespace std;

//#define MD 10

int main(){
    long long int a,b,x,ans=0;
    cin>>a>>b>>x;
    b/=x;
    if(a%x==0){
        a/=x;
        a--;
    }else{
        a/=x;
    }
    ans=b-a;
    cout<<ans<<endl;
    return 0;
}

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

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

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

void Solve()
{
	ll N;
	cin >> N;
	
	string ans = 30 <= N ? "Yes" : "No";
	cout << ans << endl;
}

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


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
int read(){
	int x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
const int maxn=4005,mod=1e9+7;
int n,m;
int C[maxn][maxn];
void get_C(){
	REP(i,0,4000)
		C[i][0]=1;
	REP(i,1,4000)
		REP(j,1,i)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
}
int ans=0;
int main(){
	get_C();
	n=read(),m=read();
	ans=n+1;
	REP(i,1,m-1)
		REP(j,0,min(i-1,n-i)){
			int res=1;
			res=1ll*res*C[m-1][i]%mod*C[i-1][j]%mod*C[n-i-j+2][2]%mod;
			ans=(ans+res)%mod;
		}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  // 木を考えていることに注意
  // aiとbiが偶数回現れていればよさそう
  // 奇数回ならダメそう
  vector<int> count(n, 0);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    count[a]++;
    count[b]++;
  }
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (count[i] % 2 == 1) {
      ok = false;
    }
  }
  cout << (ok ? "YES" : "NO") << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
 
#define IS_DEBUG true
 
#define DEBUG_OUTPUT(X) if (IS_DEBUG) cout << X << endl
#define RESULT_OUTPUT(X) cout << X << endl
 
int main()
{
	int N;
	cin >> N;
 
	string s;
	cin >> s;
 
	int min = N;
  	vector<int> W;
  	if (s[0] == 'W')
       W.push_back(1);
  	else
      W.push_back(0);
  	for (int i = 1; i < N; i++)
    {
      if (s[i] == 'W')
        W.push_back(W[i - 1] + 1);
      else
         W.push_back(W[i - 1]);
    }
  	for (int i = 0; i < N; i++)
    {
      int sum = 0;
      if (i > 1)
      	sum += W[i - 1];
      if (i + 1 < N)
      	sum +=  (N - i - 1 - (W[N - 1] - W[i]));
      if (sum < min)
        min = sum;
    }
 
  	RESULT_OUTPUT(min);
 
	if (IS_DEBUG)
	{
		int end;
		cin >> end;
	}
	return 0;
}

Measured memory_bytes: 2812
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[500009],br[500009];
int main()
{
    ll a,b,c,i,j,k;
    string s,d;
    char q,w;
    cin>>a>>b;
    c=(a/b);
    if(a%b>0)c++;
    cout<<c<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int p;
vector<int> divide(int x){
	vector<int> v(p + 1,0); v[p] = 1; v[1] = p - 1;
	vector<int> w(p,0);
	for(int i=p;i>=1;i--){
		w[i - 1] = v[i];
		(v[i - 1] += x*v[i]) %= p;
	}
	return w;
}
		
int pw(int a, int x){
	int res = 1;
	while(x){
		while(!(x&1)){
			x /= 2;
			(a *= a) %= p;
		}
		x--;
		(res *= a) %= p;
	}
	return res;
}
int g(int x){
	return pw(x,p - 2);
}
int a[3010],inv[3010] = {};
vector<int> ans(3000,0);
int main(){
	int i,j;
	cin >> p;
	for(i=0;i<p;i++){
		int x = 1;
		for(j=0;j<p;j++){
			if(j==i) continue;
			(x *= (i - j + p)) %= p;
		}
		inv[i] = g(x);
	}
	for(i=0;i<p;i++){
		cin >> a[i];
		if(a[i]==1){
			vector<int> v = divide(i);
			for(j=0;j<p;j++){
				(ans[j] += inv[i]*v[j]) %= p;
			}
		}
	}
	for(i=0;i<p;i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int W = sc.nextInt();

        char[][] grid = new char[H][W];
        sc.nextLine();
        for (int i = 0; i < H; i++) {
            String line = sc.nextLine();
            for (int j = 0; j < W; j++) {
                grid[i][j] = line.charAt(j);
            }
        }

        // row check
        NEXT_ROW: for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (grid[i][j] == '#') continue NEXT_ROW;
            }

            for (int j = 0; j < W; j++) {
                grid[i][j] = '+';
            }
        }

        // col check
        NEXT_COL: for (int j = 0; j < W; j++) {
            for (int i = 0; i < H; i++) {
                if (grid[i][j] == '#') continue NEXT_COL;
            }

            for (int i = 0; i < H; i++) {
                grid[i][j] = '+';
            }
        }

        for (int i = 0; i < H; i++) {
            boolean needN = false;

            for (int j = 0; j < W; j++) {
                if (grid[i][j] == '+') continue;
                System.out.print(grid[i][j]);
                needN = true;
            }

            if (needN) System.out.print('\n');
        }
    }
}

Measured memory_bytes: 26192
import java.util.*;
 
public class Main{

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

        String S = sc.next();
        sc.close();

        S = S.replace("eraser", "");
        S = S.replace("erase", "");
        S = S.replace("dreamer", "");
        S = S.replace("dream", "");
        
        if(S.equals(""))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    ll n,a,b;
    cin>>n>>a>>b;

    ll ans=0;

    ans+=(n/(a+b))*a;
    ll x=min(n%(a+b),a);
    ans+=x;

    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *

N = INT()
A = LIST()

ans = 1
tmp = 0
for i in range(1, N):
	if A[i] == A[i-1]:
		continue
	elif tmp == 0:
		tmp = (A[i]-A[i-1])//abs(A[i]-A[i-1])
	elif tmp != (A[i]-A[i-1])//abs(A[i]-A[i-1]):
		ans += 1
		tmp = 0

print(ans)

Measured memory_bytes: 16392