akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  //約数列挙
  vector<int64_t> div(0);
  for(int n=1; n*n<=N; n++){
    if(N %n == 0){
      div.push_back(n);
      if(N /n != n){
        div.push_back(N /n);
      }
    }
  }
  
  int64_t ansA = -1;
  int64_t ansB = -1;
  
  for(int i=0; i<div.size(); i++){
    for(int64_t a = 0; a <= 500; a++){
      int64_t b = a - div[i];
      int64_t c1 = pow(a,4);
      int64_t c2 = pow(a,3)*b;
      int64_t c3 = pow(a,2)*pow(b,2);
      int64_t c4 = pow(b,3)*a;
      int64_t c5 = pow(b,4);
      int64_t c = c1 + c2 + c3 + c4 + c5;
      if(c*div[i] == N){
        ansA = a;
        ansB = b;
      }
    }
  }
  
  cout << ansA << " " << ansB << endl;
}



Measured memory_bytes: 4152
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	c, ans := 0, 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'W' {
			ans += i - c
			c++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
long long dp[100005][2],s[100005][2];
int a[100005];
int main() 
{
	//freopen("1.txt","w",stdout);
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i) scanf("%d",&a[i]);
	if(a[0]<0)
	{
		dp[0][0]=0;
		s[0][0]=a[0];
		dp[0][1]=1-a[0];
		s[0][1]=1;
	}
	else if(a[0]>0)
		 {
		 	dp[0][1]=0;
			s[0][1]=a[0];
			dp[0][0]=1+a[0];
			s[0][0]=-1;
		 }
		 else
		 {
		 	dp[0][0]=1;
			s[0][0]=-1;
			dp[0][1]=1;
			s[0][1]=1;
		 }
	for(int i=1;i<n;++i)
	{
		long long x=s[i-1][1];
		x+=a[i];
		if(x<0)
		{
			dp[i][0]=0;
			s[i][0]=x;
		}
		else if(x>0)
			 {
			 	dp[i][0]=1+x;
				s[i][0]=-1;
			 }
			 else
			 {
			 	dp[i][0]=1;
				s[i][0]=-1;
			 }
		dp[i][0]+=dp[i-1][1];

		x=s[i-1][0];
		x+=a[i];
		if(x<0)
		{
			dp[i][1]=1-x;
			s[i][1]=1;
		}
		else if(x>0)
			 {
			 	dp[i][1]=0;
				s[i][1]=x;
			 }
			 else
			 {
			 	dp[i][1]=1;
				s[i][1]=1;
			 }
		dp[i][1]+=dp[i-1][0];
	}
	printf("%lld\n",min(dp[n-1][0],dp[n-1][1]));
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	ll N, P;
	cin >> N >> P;

	vector<ll> A(N + 1);
	repn(i, N) cin >> A[i];

	ll dp[100][10000] = {};
	dp[0][0] = 1;

	repn(i, N) {
		rep(j, 10000) {
			dp[i][j] += dp[i - 1][j];
			if (j >= A[i]) { dp[i][j] += dp[i - 1][j - A[i]]; }
		}
	}

	ll ans = 0;
	rep(j, 10000) {
		if (j % 2 == P) { ans += dp[N][j]; }
	}
	
	cout << ans;
	system("PAUSE");

}





Measured memory_bytes: 8312
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	ll a,b,x;
	cin>>a>>b>>x;
	if(a)
		cout<<b/x-(a-1)/x<<endl;
	else
		cout<<b/x+1<<endl;
	return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;
    cin >> n;
    map<map<char,int>,int> list;
    REP(i,n){
        map<char,int> str;
        string t;
        cin >> t;
        REP(j,10){
            str[t[j]]++;
        }
        list[str]++;
    }
    ll count = 0;
    for(const auto& i:list){
        ll num = i.second;
        if(i.second==1)continue;
        else count += ((num-1)*num)/2;
    }
    COUT(count);
    return 0;
}  


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

int n[4]={0};
char b[5] = "KUPC";

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++){
        for(int j=0;j<4;++j)
            if(s[i] == b[j])n[j]++;
    }
    int mini = n[0];
    for(int i=1;i<4;++i) mini = min(mini, n[i]);
    cout << mini << endl;

    return 0;
}


Measured memory_bytes: 3168
import java.util.*;

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

    long h = sc.nextLong();
    int n = sc.nextInt();
    long[] a = new long[n];
    long sum = 0;
    String ans = "Yes";
    
    for(int i = 0; i < n; i++){
      a[i] = sc.nextLong();
      sum += a[i];
    }

    if(sum < h){
      ans = "No";
    }

    System.out.println(ans);
  }
}

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

// --- FIX begin --- cut here ---
template<typename F>
class FixPoint : private F {
public:
  explicit constexpr FixPoint(F&& f) noexcept : F(forward<F>(f)) {}

  template<typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return FixPoint<F>{forward<F>(f)};
}
// --- FIX end --- cut here ---

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  vector<vector<int>> win(N);
  for (int i = 0; i < N-1; i++) {
    int a; cin >> a; a--;
    win.at(a).push_back(i+1);
  }

  auto depth = fix([&](auto recF, int n) -> int {
      vector<int> ds;
      for (int i : win.at(n)) ds.push_back(recF(i));
      sort(ds.begin(), ds.end(), greater<int>());
      int ret = 0;
      for (int i = 0; i < (int)ds.size(); i++) {
        ret = max(ret, i + 1 + ds.at(i));
      }
      return ret;
    });

  cout << depth(0) << endl;
  return 0;
}


Measured memory_bytes: 12032
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 400+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

LL dp[nmax][nmax];

LL sum(int l,int r,const vector<LL> &v)
{
    LL s=0;
    for(int i=l;i<=r;i++)
        s += v[i];
    return s;
}

int main()
{
    optimizeIO();

    int tc = 1;

    while(tc--)
    {
        int n;
        cin>>n;

        vector<LL>v(n);

        for(int i=0;i<n;i++)
            cin>>v[i];

        for(int l=n-1;l>=0;l--)
        {
            for(int r=0;r<n;r++)
            {
                if(l==r) dp[l][r] = 0;
                else
                {
                    dp[l][r] = LLONG_MAX;
                    LL cost = sum(l,r,v);

                    for(int i=l;i<r;i++)
                        dp[l][r] = min(dp[l][r],dp[l][i] + dp[i+1][r] + cost);
                }
            }
        }

        cout<<dp[0][n-1]<<endl;
    }

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 4908
#include<bits/stdc++.h>
using namespace std;
const int maxn=3005;
int C[maxn][maxn],S[maxn][maxn],mod,f[maxn],g[maxn];
inline int add(int a,int b){return a+b>=mod?a+b-mod:a+b;}
inline int dic(int a,int b){return a-b<0?a-b+mod:a-b;}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline int qpow(int a,int b,int p=mod,int c=1){for(;b;b>>=1,a=1ll*a*a%p) if(b&1) c=1ll*c*a%p; return c;}
int main(){
	int n,ans=0;cin>>n>>mod;
	for(int i=C[0][0]=S[0][0]=1;i<=n+1;++i) {
		for(int j=C[i][0]=1;j<=i;++j) C[i][j]=add(C[i-1][j-1],C[i-1][j]),S[i][j]=add(S[i-1][j-1],mul(j,S[i-1][j]));
	}
	for(int i=0;i<=n;++i){
		int res=0;int t=qpow(2,qpow(2,n-i,mod-1)),bt=qpow(2,n-i),now=1;
		for(int j=0;j<=i;++j) res=add(res,mul(S[i+1][j+1],now)),now=mul(now,bt);
		f[i]=mul(res,mul(t,C[n][i]));
	}
	for(int i=0;i<=n;++i){
		if(i&1) ans=dic(ans,f[i]);
		else ans=add(ans,f[i]);
	}
	cout<<ans<<endl;
	return 0;
}

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

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

  int a = -1, b = -1;
  for(int i = 0; i < n-1; i++){
    if(p[i] > p[i+1]){
      if(a == -1){
        a = i;
      }else if(b == -1){
        b = i;
      }else{
        cout << "NO" << endl;
        exit(0);
      }
    }
  }
  if(p[b+1] > p[a+1] || (a>0 && p[b+1] < p[a-1]) || p[a] < p[b] || (b<p.size()-2 && p[a] > p[b+2])){
    cout << "NO" << endl;
    exit(0);
  }
  cout << "YES" << endl;
}


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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define FOR(i, a, b) for(int i = (a); i < (b); i++)

signed main() {
  IOS;
  int h,w, ans=0;
  cin >> h >> w;
  int hcnt[h+1][w+1], wcnt[h+1][w+1];
  string s[h];
  FOR(i,0,h) {
    cin >> s[i];
    int prev = -1, cnt=0;
    FOR(j,0,w) {
      if (s[i][j] == '.') {
        cnt++;
      } else {
        FOR(k,prev+1,j) hcnt[i][k] = cnt;
        cnt = 0;
        hcnt[i][j] = 0;
        prev = j;
      }
    }
    FOR(k,prev+1,w) hcnt[i][k] = cnt;
//    FOR(j,0,w)
//      cout << hcnt[i][j] << " ";
//    cout << endl;
  }

  FOR(j,0,w) {
    int prev = -1, cnt=0;
    FOR(i,0,h) {
      if (s[i][j] == '.') {
        cnt++;
      } else {
        FOR(k,prev+1,i) {
          wcnt[k][j] = cnt;
          ans = max(ans, hcnt[k][j] + wcnt[k][j]-1);
        }
        cnt = 0;
        wcnt[i][j] = 0;
        prev = i;
      }
    }
    FOR(k,prev+1,h) {
      wcnt[k][j] = cnt;
      ans = max(ans, hcnt[k][j] + wcnt[k][j]-1);
    }
  }

//  cout << endl;
//  FOR(i,0,h) {
//    FOR(j,0,w)
//      cout << wcnt[i][j] << " ";
//    cout << endl;
//  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35840
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	string s;
	cin>>s;
	rep(i,s.size()){
		s[i]-='A';
		s[i]-=3;
		s[i]=(s[i]+26)%26;
		s[i]+='A';
	}
	cout<<s<<endl;
}

Measured memory_bytes: 1180
n = int(input())
h = list(map(int, input().split()))

cnt1 = 0
cnt2 = 0
cnt3 = 0

for i in range(n-1):
  if h[i] > h[i + 1] + 1:
    cnt1 += 1
    break
  elif h[i] == h[i + 1] + 1 and (cnt2 > 0 or cnt3 > 0):
    cnt1 += 1
    break
  elif h[i] == h[i + 1] and cnt2 > 0:
    cnt3 = 1
  elif h[i] == h[i + 1] + 1:
    cnt2 = 1
  else:
    cnt2 = 0
    cnt3 = 0

if cnt1 >0:
  print("No")
else:
  print("Yes")

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

int main() {
  int A, B;
  cin >> A >> B;

  if (A == 1) A += 13;
  if (B == 1) B += 13;

  if (A > B)
    cout << "Alice" << endl;
  else if (B > A)
    cout << "Bob" << endl;
  else
    cout << "Draw" << endl;
  return 0;
}

Measured memory_bytes: 3564
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var N = NextInt();
		var X = NextInt();

		var min = int.MaxValue;
		for (var i = 0; i < N; i++) {
			var m = NextInt();
			min = Math.Min(min, m);
			X -= m;
		}
		WriteLine(N + X / min);
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const int imax = ~(1 << 31);
const long long linf = 1ll << 61;
const long long lmax = ~(1ll << 63);

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

int N;
pii X[200000];
int rep[200000];

int main(int argc, char* argv[])
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &X[i].first);
		X[i].second = i;
	}
	sort(X, X + N);
	for (int i = 0; i < N; i++) {
		rep[X[i].second] = i;
	}
	for (int i = 0; i < N; i++) {
		int j = rep[i];
		int mid;
		if (2 * j < N) {
			mid = X[N / 2].first;
		} else {
			mid = X[N / 2 - 1].first;
		}
		printf("%d\n", mid);
	}

	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, K;
    cin >> N >> K;
    vector<int> A(N), F(N);
    ll l = -1, r = 1e18;
    
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];
    sort(all(A));
    sort(all(F), greater<ll>());
    
    while ((l + 1) < r) {
        ll c = (l + r) / 2;
        
        bool ok = [&]{
            ll s = 0;
            
            rep(i, N) {
                s += max(0LL, A[i] - c / F[i]);
            }
            
            return (s <= K);
        }();
        
        if (ok) {
            r = c;
        }
        else {
            l = c;
        }
    }
    
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python
from typing import List


def input_int() -> int:
    return int(input())


def input_int_list() -> List[int]:
    return list(map(lambda x: int(x), input().split()))


def f(d_pair_list: list) -> str:
    n = 0
    for d_pair in d_pair_list:
        if d_pair[0] == d_pair[1]:
            n += 1
            if n >= 3:
                return 'Yes'
        else:
            n = 0
    return 'No'


if __name__ == '__main__':
    n = input_int()

    d_pair_list: List = list()
    for i in range(0, n):
        d_pair_list.append(input_int_list())
    print(f(d_pair_list))


Measured memory_bytes: 10224
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

int n;
int cnt = 0;
multiset<int> s;

int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;
        auto it = s.lower_bound(a);
        if (it == s.begin())
        {
            s.insert(a);
        }
        else
        {
            s.erase(--it);
            s.insert(a);
        }
    }

    cout << s.size() << endl;
}

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

def main():
    s = input().strip()
    ans = 0
    x = 0 # g を出した数 - p を出した数
    for c in s:
        if x > 0: # p を出せるので出す
            x -= 1
            if c == "g":
                ans += 1
        else: # g を出す
            x += 1
            if c == "p":
                ans -= 1

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
N, Q = inpl()
neighbor = [[] for i in range(N)]
for i in range(N-1):
    a, b = inpl()
    a -= 1
    b -= 1
    neighbor[a].append(b)
    neighbor[b].append(a)
X = [0] * N
for _ in range(Q):
    p, x = inpl()
    X[p-1] += x

result = [0] * N
result[0] = X[0]
visited = [False] * N
dfs_stack = [0]
x = 0
while dfs_stack:
    node = dfs_stack.pop()
    visited[node] = True
    for c in neighbor[node]:
        if visited[c]:
            continue
        else:
            dfs_stack.append(c)
            result[c] = result[node] + X[c]

print(' '.join(map(str,result)))

Measured memory_bytes: 122828
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int DP[20000];

int main(){
	
	int N, W;
	cin >> N >> W;
	
	for(int i = 0; i <= W; i++){
		DP[i] = 0;
	}
	
	for(int i = 0; i < N; i++){
		int v, w;
		cin >> v >> w;
		for(int j = w; j <= W; j++){
			DP[j] = max(DP[j], DP[j - w] + v);
		}
	}
	
	cout << DP[W] << endl;
	
	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
    
        LL n;
        cin>>n;
        string s;
        cin>>s;
        queue<int> a;
        queue<int> b;
        fr(i,0,n){
            if(s[i]=='W') a.push(i);
        }
         fr1(i,n-1,0){
            if(s[i]=='R') b.push(i);
        }
        
        LL ans=0;
        LL mn=a.size();
        if(a.empty() || b.empty()){
            cout<<0<<endl;
        }
        else{
            LL x,y;
           while(!a.empty() && !b.empty()){
              x=a.front();
              y=b.front();
              a.pop();
              b.pop();
              if(x<y){
                  swap(s[x],s[y]);
                  ans++;
              }
              else break;
           }
           cout<<min(ans,mn)<<endl;
        }
    return 0;
}

Measured memory_bytes: 4456
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 100000 + 5;

struct node {
    string s;
    int p, id;
    bool operator<(const node& b) const {
        if (s == b.s) return p > b.p;
        return s < b.s;
    }
} a[maxn];

int n, ans[maxn];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].s >> a[i].p;
        a[i].id = i;
    }
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n; i++) cout << a[i].id << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int b[14][14];
  int i,j,m=0,n=0,x,y,z;
  for(i=0;i<14;i++)for(j=0;j<14;j++)b[i][j]=0;
  while(scanf("%d,%d,%d",&x,&y,&z)!=EOF){
    x+=2;y+=2;
    b[x][y]++;
    b[x][y-1]++; b[x][y+1]++; b[x-1][y]++; b[x+1][y]++;
    if(z>1){
      b[x-1][y-1]++; b[x+1][y+1]++; b[x-1][y+1]++; b[x+1][y-1]++;
    }
    if(z>2){
      b[x][y-2]++; b[x][y+2]++; b[x-2][y]++; b[x+2][y]++;
    }
  }
  for(i=2;i<12;i++)for(j=2;j<12;j++){
    m=(m<b[i][j])?b[i][j]:m;
    n+=(b[i][j]==0);
  }
  printf("%d\n%d\n",n,m);
  return 0;
}

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

namespace ConsoleApp15
{
    class Class362
    {
        static void Main()
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(ab[0] * ab[1]);
        }
    }
}


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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()
#define sz(x) x.size()

#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,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
    int x;
    cin>>x;
    if(x>=30)cout<<"Yes\n";
    else cout<<"No\n";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		int N;
		N=sc.nextInt();
		int C[]=new int[50];
		int V[]=new int[50];
		int total=0;
		for(int i=0;i<N;i++) {
			
			V[i]=sc.nextInt();
			
		}
        for(int i=0;i<N;i++) {
			
			
			C[i]=sc.nextInt();
			
		}
        for(int i=0;i<N;i++) {
			
			
			if(V[i]-C[i]>=0) {
				total+=V[i]-C[i];
			}
			
		}
		System.out.println(total);
	}
		
	
	
		
	}
		
	


Measured memory_bytes: 23252
from collections import Counter


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


n = int(input())
c = Counter()

for i in range(2, n+1):
    c.update(prime_factorize(i))

d = {2: 0, 4: 0, 14: 0, 24: 0, 74: 0}
for k, v in c.items():
    for size in [2, 4, 14, 24, 74]:
        if v >= size:
            d[size] += 1

total = 0
if d[4] >= 2 and d[2] >= 3:
    total += d[4] * (d[4] - 1) // 2 * (d[2] - 2)

if d[14] >= 1 and d[4] >= 2:
    total += d[14] * (d[4] - 1)

if d[24] >= 1 and d[2] >= 2:
    total += d[24] * (d[2] - 1)

if d[74] >= 1:
    total += d[74]

print(total)


Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   debug::instance

using namespace std;

template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	ll K = fetch<ll>();
	int n = fetch<int>();
	auto a = fetch_vec<ll>(n);
	ll mx = 0;
	for(int i = 0; i < n; ++i) {
		int j = (i == n - 1 ? 0 : i + 1);
		ll dist = abs(a[i] - a[j]);
		dist = min(dist, K - dist);
		mx = max(mx, dist);
	}
	cout << K - mx << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1792
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  -- for i = 1, #ary do self.stage[stagenum][i] = ary[i] end
  -- for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local start_stage = 1
  while right - left + 1 < self.size[start_stage] do
    start_stage = start_stage + 1
  end
  local ret = self.emptyvalue
  local t1, t2, t3 = {start_stage}, {left}, {right}
  while 0 < #t1 do
    local stage, l, r = t1[#t1], t2[#t1], t3[#t1]
    table.remove(t1) table.remove(t2) table.remove(t3)
    local sz = self.size[stage]
    if (l - 1) % sz ~= 0 then
      local newr = mmi(r, mce((l - 1) / sz) * sz)
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)
      l = newr + 1
    end
    if sz <= r + 1 - l then
      ret = self.func(ret, self.stage[stage][mce(l / sz)])
      l = l + sz
    end
    if l <= r then
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)
    end
  end
  return ret
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = value
  if not silent then
    for i = self.stagenum - 1, 1, -1 do
      local dst = mce(idx / 2)
      local rem = dst * 4 - 1 - idx
      self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
      idx = dst
    end
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n = io.read("*n")
local tot = 1
for i = 1, n do tot = tot * 2 end
local mab = math.abs
local function merge(x, y)
  if x ~= y then
    return mab(x - y)
  else
    return x
  end
end
local st = SegTree.new(tot, merge, 0)
for i = 1, tot do
  st:setValue(i, io.read("*n"), true)
end
st:updateAll()
print(st.stage[1][1])


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

int main() {
  char a,b;
  int tosi,tuki,niti;
  cin >> tosi >> a >> tuki >> b >> niti;
  if(tosi <= 2019 && tuki <= 4){
    cout << "Heisei" << endl;
    return 0;
  }
cout << "TBD" << endl;
}


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

int main(){
    int x, y;
    cin >> x >> y;
    while(!(x == 0 && y == 0)){
        if (x > y){
            cout << y << " " << x << endl;
        }
        else {
            cout << x << " " << y << endl;
        }
        cin >> x >> y;
    }
}


Measured memory_bytes: 3080
/*
 * main.c
 *
 *  Created on: 2020/02/22
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}


int main()
{
	ll H = 0, W = 0, ans = 0;
	scanf("%lld %lld", &H, &W);
	ans = (H/2) * W;
	if ((W == 1) || (H == 1)) {
		ans = 1;
	} else {
		if (H%2 == 1) {
			ans += W/2;
			if ((W%2) == 1) {
				ans += 1;
			}
		}
	}
	printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
  long n,m,ans;
  scanf("%ld%ld",&n,&m);
  if (n*2<m){
    m-=n*2;
    ans=n+(m-m%4)/4;
  }else ans=(m-m%2)/2;
  printf("%ld\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1LL << 30;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt= 0;
    REP(i,s.size()) if(s[i]=='o') cnt++;

    cout << ((cnt+(15-s.size())>=8)?"YES":"NO") << endl;
}

Measured memory_bytes: 256
// need
#include <iostream>
#include <algorithm>
// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <queue>
//#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
// utility
#define all(i) (i).begin(), (i).end()
#define rep(i, n) for(int i=0;i<int(n);++i)
#define rrep(i, n) for(int i=int(n)-1;i>=0;--i)
#define in(a, x, b) (a<=x && x<b)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

template<typename S, typename T>
std::ostream& operator<<(std::ostream& os, std::pair<S, T> p) {
  os << "(" << p.first << ", " << p.second << ")"; return os;
}

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using PAIR = std::pair<int, int>;
using PAIRLL = std::pair<ll, ll>;
constexpr int MOD = 1000000007;


signed main() {
  int N, M;
  std::cin >> N >> M;

  std::vector<int> vec(N);
  
  int a, b;
  rep(i, M){
    std::cin >> a >> b;
    a--; b--;
    vec.at(a)++;
    vec.at(b)++;
  }

  rep(i, N) std::cout << vec.at(i) << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	long long int x;
	cin >> x;
	long long int a = 100;
	long long int ans = 1;
	while(1){
		a += a/100;
		if(a >= x){
			cout << ans << endl;
			return 0;
		}else{
			ans++;
		}
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void) {
    ll n, a, b, x[100010];
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) cin >> x[i];
    
    ll ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans += min(b, a * (x[i + 1] - x[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


int extend_gcd(int a, int b, int& x, int& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    int x1, y1;
    int d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

int rowNum[]={-1,0,0,1};
int colNum[]={0,-1,1,0};

int main()
{
	fastio
	int n,x,t;
	cin>>n>>x>>t;
	int ans=0;
	while(n>0)
	{
		ans+=t;
		n-=x;
	}

	cout<<ans<<endl;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = (ull)1e9 + 7;

int main(void)
{
	string s;
	cin >> s;
	int n = s.size();
	vector<vector<ll>> dp(n + 1, vector<ll>(4, 0));
	dp[0][0] = 1;
	rep(i, n) {
		char c = s[i];
		if (c == '?') {
			rep(j, 4) {
				(dp[i + 1][j] += dp[i][j] * 3) %= mod;
			}
			rep(j, 3) {
				(dp[i + 1][j + 1] += dp[i][j]) %= mod;
			}
		}
		else {
			rep(j, 4) {
				(dp[i + 1][j] += dp[i][j]) %= mod;
			}
			if (c == 'A') {
				(dp[i + 1][1] += dp[i][0]) %= mod;
			}
			if (c == 'B') {
				(dp[i + 1][2] += dp[i][1]) %= mod;
			}
			if (c == 'C') {
				(dp[i + 1][3] += dp[i][2]) %= mod;
			}
		}
	}
	cout << dp[n][3] << endl;
	return 0;
}


Measured memory_bytes: 7424
#include <stdio.h>

int main(void)
{
  int A[100], n, i, j, v,k;
  scanf("%d", &n);
  for(i=0;i<n;i++) {
    scanf("%d", A+i);
  }

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

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

Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
int main() {
    int s;
    cin>>s;

    int answer=0;

    vector<int>a(1000000,0);
    a[0]=s;
    for (int i=1;i<1000000;i++) {
        if(a[i-1]%2==0){
            a[i]=a[i-1]/2;
        }
        else{
            a[i]=3*a[i-1]+1;
        }
    }

    for(int i=0;i<1000000;i++){
        if(a[i]==1||a[i]==2||a[i]==4){
            answer=i+4;
            break;
        }
    }
    cout<<answer<<endl;
}


Measured memory_bytes: 4096
def calc(a, b):
    x = max(a, b)
    y = min(a, b)
    while True:
        c = x % y
        if c == 0:
            break
        x = y
        y = c
    return y

A, B, C, D = map(int, input().split())

E = int(C * D / calc(C, D))
l = int(B - B // C - B // D + B // E)
m = int((A-1) - (A-1) // C - (A-1) // D + (A-1) // E)

print(l-m)

Measured memory_bytes: 9224
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<City> al = new ArrayList<>();
		for (int i = 0; i < m; i++) {
			al.add(new City(i, sc.nextInt(), sc.nextInt()));
		}
		al.sort((x, y) -> x.year - y.year);
		int number[] = new int[n];
		for (int i = 0; i < m; i++) {
			al.get(i).number = number[al.get(i).pre - 1] + 1;
			number[al.get(i).pre - 1]++;
		}
		al.sort((x, y) -> x.id - y.id);

		for (int i = 0; i < m; i++) {
			sb.append(String.format("%06d", al.get(i).pre));
			sb.append(String.format("%06d", al.get(i).number) + "\n");
		}
		System.out.print(sb);
	}
}

class City {
	int id;
	int pre;
	int year;
	int number;

	public City(int id, int pre, int year) {
		this.id = id;
		this.pre = pre;
		this.year = year;
	}
}

Measured memory_bytes: 177284
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef	long long	ll;

int main(){
	for(int m,n,cut;scanf("%d%d%d",&n,&m,&cut),n;){
		static ll dp[30][300010];
		rep(i,n)rep(j,m*n+1)	dp[i][j]=0;
		rep(i,n){
			for(int j=i+1;j<=m*(i+1);j++){
				if(i==0)	dp[i][j]=1;
				else{
					for(int k=1;k<=m;k++){
						if(j-k>=1)	dp[i][j]+=dp[i-1][j-k];
					}
				}
			}
		}

		ll nu=0,de=1;
		rep(j,m*n+1)	nu+=max(1,j-cut)*dp[n-1][j];
		rep(i,n)		de*=m;
		printf("%.9f\n",(double)nu/de);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<fstream>
#include<functional>


using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;
using pr  = pair<int, int>;


int main() 
{
	int X;
	cin >> X;
	cout << (X >= 30 ? "Yes" : "No") << endl;
}


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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            B.BiteEating();
        }
    }

    class B
    {
        public static void BiteEating()
        {
            int[] a = Input.getIntArray();
            int apple = a[0];
            int taste = a[1];
            int preApplepie = 0;

            for(int i = 1; i <= apple; i++)
            {
                preApplepie = preApplepie + (taste + i - 1);
            }

            int tmp = 0;
            int applepie;
            int result=0;            
            for(int i = 1; i<= apple; i++)
            {   
                applepie = preApplepie - (taste + i -1 );
                int abs = Math.Abs(preApplepie - applepie);

                if(i==1)
                {
                    tmp = abs;
                    result = applepie;
                }
                else if(tmp > abs)
                {
                    tmp = abs;
                    result = applepie;
                }                    
            }

            Output.writeInt(result);
        }
    }
  
    class Input
    {
        public static int getInt()
        {
            int i = int.Parse(Console.ReadLine());
            return i;
        }

        public static string getString()
        {
            string s = Console.ReadLine();
            return s;
        }
        public static int[] getIntArray()
        {
            string[] s = Console.ReadLine().Split(' ');
            int[] num = s.Select(x=>int.Parse(x)).ToArray();
            return num;
        }
    }

    class Output
    {
        public static void writeInt(int i)
        {
            Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int max3(int a,int b,int c){
  int ans;
  ans = a;
  if(ans < b) ans = b;
  if(ans < c) ans = c;
  return ans;
}
int main(){
  int N,i,j,max;
  int a[100];
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&a[i]);
  max = 0;
  for(i=0;i<N;i++){
    for(j=i;j<N;j++){
      max = max3(max,a[i]-a[j],a[j]-a[i]);
    }
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 128
k = int(input())

import math
from functools import reduce

def gcd(*i):
    return reduce(math.gcd, i)
j = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            j += gcd(a,b,c)

print(j)

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

void Main()
{
    int n;
    cin >> n;
    long a[n];
    long count[n+1] = {0};
    for(int i=0; i<n; ++i){
        cin >> a[i];
        count[a[i]] += 1;
    }
    long ans[n+1];
    long total = 0;
    long ans_k[n+1];
    for(int i=1; i<=n; ++i){
        long c1 = max<long>(count[i], 0);
        long c2 = max<long>(count[i]-1, 0);
        long c3 = max<long>(count[i]-2, 0);
        ans[i] = c1*c2/2;
        ans_k[i] = c1*c2/2 - c2*c3/2;
        total += ans[i];
    }
    long ans_ak[n+1] = {0};
    for(int i=1; i<=n; ++i){
        ans_ak[i] = total - ans_k[i];
    }
    for(int k=0; k<n; ++k){
        cout << ans_ak[a[k]] << endl;
    }
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  for(int i = 0;i < n;i++)cin >> p[i];
  for(int i = 0;i < n;i++)cin >> q[i];
  vector<int> num(n);
  for(int i = 0;i < n;i++)num[i] = i + 1;
  int a,b;
  int count = 0;
  do{
    count++;
    bool yesp = true;
    bool yesq = true;
    for(int i = 0;i < n;i++){
      if(num[i] != p[i])yesp = false;
      if(num[i] != q[i])yesq = false;
      //cout << num[i] << " ";
    }
    //cout << endl;
    if(yesp)a = count;
    if(yesq)b = count;
  }while(next_permutation(num.begin(),num.end()));
  cout << abs(a-b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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); }

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

  int n, m;
  cin >> n >> m;
  vector<P> hu(n), ch(m);
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    hu[i] = make_pair(a, b);
  }
  rep(i, 0, m) {
    int c, d;
    cin >> c >> d;
    ch[i] = make_pair(c, d);
  }

  rep(i, 0, n) {
    int ans = -1, min_val = 1e9 + 7;
    rep(j, 0, m) {
      int t = abs(hu[i].first - ch[j].first) + abs(hu[i].second - ch[j].second);
      if (min_val > t) {
        ans = j + 1;
        min_val = t;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep1(i,n) for(int i=1;i<=n;++i)
int main(void){
    int n;
    while(cin>>n,n){
        bool sc[51][31]={};//[man][date]
        bool piece[51][51]={};
        int ans=-1;
        rep1(i,n){
            int f,date;
            cin>>f;
            rep1(j,f){
                cin>>date;
                sc[i][date]=true;
            }
        }
        rep1(i,n)piece[i][i]=true;

        rep1(date,30){
            rep1(i,n)rep1(j,n){
                if(sc[i][date] && sc[j][date]){
                    rep1(k,n)piece[j][k]=piece[i][k]|=piece[j][k];
                }
            }
            rep1(i,n){
                bool gather=true;
                rep1(j,n) gather &= piece[i][j];
                if(gather){
                    ans=date;
                    break;
                }
            }
            if(ans>0)break;
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 3080
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{

    class Program
    {

        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ') ;

            int n = int.Parse(str[0]);
            long h = long.Parse(str[1]);
            long w = long.Parse(str[2]);

            int ans = 0;

            long a = 0;
            long b = 0;

            for(int i = 0; i < n; i++)
            {
                str = Console.ReadLine().Split(' ');
                a = long.Parse(str[0]);
                b = long.Parse(str[1]);

                if(a >= h && b >= w)
                {
                    ans++;
                }

            }


            Console.WriteLine(ans);


        }
    }
}


Measured memory_bytes: 13140
def nCk(n, k, m=10**9+7):
    a = b = 1
    for i in range(k):
        a = (a * (n-i)) % m
        b = (b * (i+1)) % m
    return (a * pow(b, m-2, m)) % m

x,y = map(int,input().split())
if (x+y)%3 != 0 or min(x,y)*2 < max(x,y):
    ans = 0
else:
#パスカルの三角形より,n-1Ck-1を求める
    n = (x+y)//3 + 1
    k = x - (n-1) + 1
    ans = nCk(n-1,k-1)
print(ans)

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    int N; cin >> N;
    V<int> A(N); rep(i, N) cin >> A[i];
    multiset<int> st;
    rep(i, N) {
        auto it = st.lower_bound(A[i]);
        if (it == st.begin()) {
            st.insert(A[i]);
        } else {
            --it;
            st.erase(it);
            st.insert(A[i]);
        }
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 5376