akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    if(N%2==0){
        cout<<N<<endl;
    }else{
        cout<<2*N<<endl;
    }



    return 0;
    

}

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

const ll MOD = 998244353;

long long pow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    int n, s;
    cin >> n >> s;
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    vector<vector<ll>> dp(n+1, vector<ll>(s+1, 0));
    dp[0][0] = pow(2ll, (ll)n);
    ll inv_2 = pow(2ll, MOD-2);
    rep(i, n) rep(j, s+1) {
        dp[i+1][j] = dp[i][j];
        if (j >= A[i]) dp[i+1][j] += dp[i][j-A[i]] * inv_2 % MOD;
        dp[i+1][j] %= MOD;
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 73576
#define _USE_MATH_DEFINES
#include <cmath>

#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n;
	unsigned int a,b,c;
	
	cin >> n;
	
	while (n)
	{
		cin >> a >> b >> c;
		int max, v1, v2;
		if (a > b && a > c)
		{
			if (pow(a, 2) == pow(b, 2) + pow(c, 2))
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
		else if (b > a && b > c)
		{
			if (pow(b, 2) == pow(a, 2) + pow(c, 2))
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
		else if (c > a && c > b)
		{
			if (pow(c, 2) == pow(a, 2) + pow(b, 2))
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
		
		n--;
	}
	return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N;
    cin >> N;
    if(N == 1) {
        cout << "Yes" << endl;
        cout << 2 << endl;
        cout << 1 << " " << 1 << endl;
        cout << 1 << " " << 1 << endl;
      	return 0;
    }
    bool ret = false;
    int A = 0;
    int B = 0;
    for(int i = 0;i < N;i++) {
        if(i * (i + 1) == 2 * N) {
            ret = true;
            A = i;
            B = i + 1;
            break;
        }
    }
    if(ret == false) {
        cout << "No" << endl;
    }
    else {
        vector<queue<int>> vec(B);
        int cnt = 1;
        for(int i = 0;i < B - 1;i++) {
            for(int j = i + 1;j < B;j++) {
                vec.at(i).push(cnt);
                vec.at(j).push(cnt);
                cnt++;
            }
        }
        cout << "Yes" << endl;
        cout << B << endl;
        for(int i = 0;i < B;i++) {
            cout << A << " ";
            for(int j = 0;j < A;j++) {
                cout << vec.at(i).front() << " ";
                vec.at(i).pop();
            }
            cout << endl;
        }
    }
}

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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define st first
#define nd second

using namespace std;

const int N = 22;
int n, k, l, m;

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	out << v.size() << '\n';
	for(auto e : v) out << e << '\n';
	return out;
}

struct asd {
	int x, y, c;
};

ostream& operator<<(ostream& out, asd p) {
	return out << p.x << ' ' << p.y << ' ' << p.c;  
}


vector <asd> edge;
priority_queue <pair<int, int> > pq;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> l;

	n = 20;
	m = 0;
	pq.push({1, 20});
	for(int i = n - 1, k = 0; i > 1 ; i--, k++) {
		m++;
		edge.push_back({i, i+1, 0});
		m++;
		edge.push_back({i, i+1, (1 << k)});
		pq.push({(1 << (k + 1)), i});
	}

	// l--;
	while(l) {
		while(pq.top().st > l)
			pq.pop();
		edge.push_back({1, pq.top().nd, l - pq.top().st});
		l -= pq.top().st;
	}
	cout << n << ' ';
	cout << edge;
	// cout << edge << '\n';
}	

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public int[] DP;
        
        public void Run()
        {
            N = Input.ReadInt();
          
            var list = new List<int>();
            list.Add(1);
            for (int x = 6; x <= N; x *= 6)
            {
                list.Add(x);
            }
            for (int x = 9; x <= N; x *= 9)
            {
                list.Add(x);
            }

            DP = new int[N + 1];
            for (int i = 0; i <= N; i++) DP[i] = int.MaxValue;

            DP[0] = 0;
            for (int i = 1; i <= N; i++)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    int x = list[j];
                    if(i >= x) DP[i] = Math.Min(DP[i], DP[i - x] + 1);
                }
            }

            Console.WriteLine(DP[N]);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13204
/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
using namespace std;

#define      inl(x)              scanf("%lld",&x)
#define      in(x)               scanf("%d",&x)
#define      mxx                 10000000000000
#define      mnn                 -10000000000000
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      max_3(a,b,c)        max(a, max(b,c))
#define      max_4(a,b,c,d)      max(a,max(b,max(c,d)))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      min_4(a,b,c,d)      min(a,min(b,min(c,d)))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      O(x)                cout<<x<<endl
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      EMB                 emplace_back
#define      MP                  make_pair
#define      PII                 pair<int,int>
#define      MII                 map<int,int>
#define      FAST()              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const ll MOD = 998244353;
//auto it=std:: unique(v.B,v.E);
//v.resize(std::distance(v.B,it));
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cout<<a<<endl;
#define bug2(a,b)  cout<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
/*----*/
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll binpow(ll a, ll b){ll res = 1;while (b > 0) {if (b & 1)res*=a;a*=a;b>>=1;}return res;}
ll fact(ll num){ll fac=1;while(num!=1){fac=fac*num;num--;}return fac;}
string to_binary(int x) {string s;while(x > 0) {s += (x % 2 ? '1' : '0');x /= 2;}reverse(s.begin(), s.end());return s;}
ll nsum(ll num){return (num*(num+1))/2;}
/*-----*/
const int N=2e5+5;

/*-----*/
//vector<int> v[202];

/*-----*/
int main()
{
	FAST();

       ll test=1;
       //cin>>test;
       while(test--){
           ll n,ans;
           string s;
           for(int i=1;i<=5;i++){
                ll a;
            cin>>a;
            if(a==0) ans=i;
           }
           cout<<ans<<endl;

        }
	loser;
}
///////LeArN MoRe AnD Wait FoR ThE Result///////


Measured memory_bytes: 3616
N, K = map(int, input().split())
S = input()

A = []
if S[0] == '0':
  A.append(0)

i = 0
while i < len(S):
  j = i
  while j < len(S) and S[i] == S[j]:
    j += 1
  A.append(j - i)
  i = j

ans = 0
tot = 0
r = 0

for l in range(len(A)):
  while r < len(A) and r - l < 2 * K + 1:
    tot += A[r]
    r += 1
  if l % 2 == 0:
    ans = max(ans, tot)
  if l == r:
    r += 1
  else:
    tot -= A[l]

print(ans)


Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   if(b-a==c-b) cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <random>
#include <chrono>
#include <cassert>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

struct RandNum {

	mt19937 mt;
	RandNum() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

	lint operator()(lint a, lint b) {
		uniform_int_distribution<lint> dist(a, b);
		return dist(mt);
	}
	lint operator() (lint b) { return (*this)(0LL, b); }

	template<class Ite>
	void shuf(Ite first, Ite last) { shuffle(first, last, mt); }

};

class Prime {
private:
	void Eratos(lint N) {
		for (lint i = 2; i * i < N; i++) {
			if (Ptb[i]) for (int j = 0; i * (j + 2) < N; j++) Ptb[i *(j + 2)] = 0;
		}
	}
public:
	vector<int> Ptb;
	Prime(lint N) : Ptb(N + 1, 1) { Eratos(N + 1); }

	vector<pair<lint, int>> Pfact(lint num) {
		vector<pair<lint, int>> res;
		for (lint i = 2; i * i <= num; i++) {
			int cnt = 0;
			while (num % i == 0) {
				cnt++;
				num /= i;
			}
			if (cnt) res.emplace_back(i, cnt);
		}
		if (num != 1) res.emplace_back(make_pair(num, 1));
		return res;
	}

	bool isPrime(lint num) {
		if (num < 2) return false;
		else if (num < (int)(Ptb.size())) return (bool)(Ptb[num]);
		else if (num == 2 || num == 3) return true;
		else if (num % 2 == 0 || num % 3 == 0) return false;
		else if (num % 6 != 1 && num % 6 != 5) return false;
		for (lint i = 5; i * i <= num; i += 6) {
			if (num % i == 0) return false;
			if (num % (i + 2) == 0) return false;
		}
		return true;
	}
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	Prime p(300000);

	vector<int> ans;
	for (int i = 2; i < 55555 && ans.size() < N; i += 5) if (p.isPrime(i)) ans.emplace_back(i);

	for (const auto &e : ans) cout << e << " ";
	cout << "\n";

	return 0;
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func bordersInt(in_map [][]int, invalid int) [][]int{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]int, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]int, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func bordersString(in_map [][]string, invalid string) [][]string{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]string, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]string, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	var N, W int
	fmt.Scan(&N, &W)
	input_lines := make([][]int, N)
	memo := make([][]int, N+1)
	for i:=0; i<N+1; i++ {
		memo[i] = make([]int, W+1)
	}
	for i:=0; i<N; i++ {
		input_lines[i] = scanIntSplit(2)
	}
	for i:=0; i<N; i++ {
		vi, wi := input_lines[i][0], input_lines[i][1]
		for w:=1; w<W+1; w++ {
			if w >= wi {
				if memo[i+1][w-wi]+vi > memo[i][w] {
					memo[i+1][w] = memo[i+1][w-wi]+vi
				} else {
					memo[i+1][w] = memo[i][w]
				}
			} else {
				memo[i+1][w] = memo[i][w]
			}
		}
	}
	fmt.Println(memo[N][W])
}


Measured memory_bytes: 9648
fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(" ").map(String::toLong)
    val s = readLine()!!
    val total = LongArray(n.toInt() + 1) { 0L }
    for (i in 0 until (n.toInt() - 1)) {
        total[i + 1] = total[i] + if (s[i] == 'A' && s[i + 1] == 'C') 1 else 0
    }
    total[n.toInt()] = total[n.toInt() - 1]
    for (i in 1..q) {
        val (l, r) = readLine()!!.split(" ").map(String::toInt)
        println(total[r-1] - total[l-1])
    }
}

Measured memory_bytes: 58680
n,k = map(int,input().split())
def func_10_to_k(X, n):
    if (int(X/n)):
        return func_10_to_k(int(X/n), n)+str(X%n)
    return str(X%n)
r = func_10_to_k(n,k)
print(len(r))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n,k;cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){
		int p;cin>>p;
		arr[i] = p;
	}
	sort(arr,arr+n);
	int sum=0;
	for(int i=0;i<k;i++){
		sum += arr[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int n,m,x,a[200],b,c,l;
int main(){
    cin>>n>>m>>x;
    for(int i=0;i<m;i++){
        cin>>l;
        a[l]=1;
    }
    for(int i=x;i<n;i++){
        if(a[i]==1){b++;}
    }
    for(int i=x;i>0;i--){
        if(a[i]==1){c++;}
    }
    cout<<min(b,c)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    map<string, int> s;
    for (int i = 0; i < N; i++)
    {
        string ss;
        cin >> ss;
        s[ss]++;
    }
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string ss;
        cin >> ss;
        s[ss]--;
    }

    int m = 0;
    for (auto itr = s.begin(); itr != s.end(); ++itr)
    {
        m = max(m, itr->second);
    }
    cout << m << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
hs = gets.split.map(&:to_i)

# link = Hash.new([])
list = Array.new(n, 0)
m.times do |i|
  a, b = gets.split.map(&:to_i)
  if hs[a-1] <= hs[b-1]
    #  link[a] += [b]
    list[a-1] += 1
  end
  if hs[a-1] >= hs[b-1]
    # link[b] += [a]
    list[b-1] += 1
  end
end

# puts n - link.count
puts list.count(0)

Measured memory_bytes: 22536
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long int mod = 1e9 +7;

long long int pow2mod(int n){
	long long int ret=1;
	for(int i=0; i<n; i++){
		ret = ret*2 % mod;
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	
	bool success = true;
	if(n%2 == 0){
		for(int i=0; i<n; i++){
			if(a[i] != i/2*2 +1){
				success = false;
				break;
			}
		}
	}else{
		for(int i=0; i<n; i++){
			if(a[i] != (i+1)/2*2){
				success = false;
				break;
			}
		}
	}
	
	if(success){
		cout << pow2mod(n/2) << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}

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

four = len(a)-len(list(filter(lambda x:x%4, a)))
two = len(a)-len(list(filter(lambda x:x%2, a))) - four
no = len(a) - four - two

if two: print("YNeos"[no>four::2])
else: print("YNeos"[no-four>1::2])

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <double> vd;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <vd> vvd;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;

const int MOD = 1e9+7;

int main()
{
    int n; cin >> n;
    vvi a(n, vi (n));
    for(int i = 0; i < n; i++)
        for(int j = 0; j<n; j++)
            cin >> a[i][j];
    vvi state(1<<n, vi(n, 0));

    // memset(state, 0, sizeof(state));

    for(int i = 0; i < n; i++)
        if(a[i][0])
            state[1<<i][0] = 1;
    
    for(int i = 0; i < (1<<n); i++)
        for(int j = 1; j < n; j++)  
            if(j == __builtin_popcount(i) -1)
                for(int k = 0; k < n; k++)
                    if(((1<<k)&i) && a[k][j])
                        state[i][j] =(state[i][j] + state[i^(1<<k)][j-1])%MOD;

    cout << state[(1<<n) - 1][n-1] << endl;

}

Measured memory_bytes: 248064
a = input()

if(a=="SUN"):
  print(7)
elif(a=="MON"):
  print(6)
elif(a=="TUE"):
  print(5)
elif(a=="WED"):
  print(4)
elif(a=="THU"):
  print(3)
elif(a=="FRI"):
  print(2)
elif(a=="SAT"):
  print(1)
     

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define loop1(i,n) for(long long int i = 1;i <= n; i++)
#define loop(i,n) for(long long int i = 0;i < n; i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define lli long long int 
#define li long int
#define pair(int) pair<int, int>
using namespace std;


int  main(){
    fast;
    lli n,W;
    cin>>n>>W;
    lli weight[n+1] = {0}, v[n+1] = {0};
    loop1(i,n)
        cin>>weight[i]>>v[i];
    lli dp[W+1][n+1];
    loop(i,n+1)
        loop(w,W+1)
            dp[w][i] = 0;

    loop1(w,W)
        if(w>=weight[1])
            dp[w][1] = v[1];

    for(lli i=2;i<=n;i++){
        loop1(w,W){
            if(w>=weight[i]){
                dp[w][i] = max(dp[w-weight[i]][i-1]+v[i], dp[w][i-1]);
            }
            else{
                dp[w][i] = dp[w][i-1];
            }
        }
    }
    cout<<dp[W][n]<<endl;
    return 0;
}

Measured memory_bytes: 79232
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = getLine >> readInts >>= print . maximum . solve 0

solve c [_] = [c]
solve c (h1:h2:hs)
	| h1 >= h2 = solve ( c + 1 ) (h2:hs)
	| otherwise = c : solve 0 (h2:hs)

Measured memory_bytes: 9852
#include <bits/stdc++.h>
using namespace std;
int n,a,b,p[5005],idx[5005][5005],cum[5005][5005];
long long dp[5005][5005];
long long solve(int i,int j)
{
	if (!idx[i][j])
	return 0;
	if (dp[i][j]!=-1)
	return dp[i][j];
	return dp[i][j]=min(a+solve(i,p[idx[i][j]]-1),1LL*b*(cum[i][j]-cum[idx[i][j]][j])+solve(idx[i][j]-1,j));
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
		for (int j=1;j<=n;j++)
		{
			idx[i][j]=idx[i-1][j];
			if (p[i]<=j && p[i]>p[idx[i][j]])
			idx[i][j]=i;
			cum[i][j]=cum[i-1][j]+(p[i]<=j);
		}
	}
	memset(dp,-1,sizeof(dp));
	printf("%lld",solve(n,n));
}

Measured memory_bytes: 395268
#include <bits/stdc++.h>
int n, k, ans, i;
char s[100010];
int main() { // 每次翻转区间至多增加2的高兴人数
    for (scanf("%d%d%s", &n, &k, s), i = 1; i < n || (printf("%d\n", std::min(ans + 2 * k, n - 1)), exit(0), 0); i++) ans += (s[i] == s[i - 1]);
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a==b && b==c) cout << 1 << endl;
  else if(a==b || b==c || a==c) cout << 2 << endl;
  else cout << 3 << endl;
  return 0;
}


Measured memory_bytes: 3560
use std::io::*;
use std::str::*;
use std::collections::HashSet;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let A: i64 = read().unwrap();
    let B: i64 = read().unwrap();
    let C: i64 = read().unwrap();
    let mut v = Vec::new();
    v.push(A);
    v.push(B);
    v.push(C);
    v.sort_by(|a, b| b.cmp(a));
    let a = v[0];
    let b = v[1];
    let c = v[2];
    if (a - b) % 2 == 0 && (a - c) % 2 == 0 {
        println!(
            "{}",
            (((a - b) as f64 / 2.0).floor() as usize + ((a - c) as f64 / 2.0).floor() as usize)
                as usize,
        );
    } else if (a - b) % 2 == 1 && (a - c) % 2 == 1 {
        println!(
            "{}",
            (a - b + ((c + a - b) as f64 / 2.0).floor() as i64) as usize
        );
    } else if (a - b) % 2 == 1 && (a - c) % 2 == 0 {
        let a = a + 1;
        let c = c + 1;
        println!(
            "{}",
            (((a - c) as f64 / 2.0).floor() as usize + ((a - b) as f64 / 2.0).floor() as usize)
                as usize + 1,
        );
    } else {
        let a = a + 1;
        let b = b + 1;
        println!(
            "{}",
            (((a - b) as f64 / 2.0).floor() as usize + ((a - c) as f64 / 2.0).floor() as usize)
                as usize + 1,
        );
    }
}


Measured memory_bytes: 4352
import sys
input = sys.stdin.buffer.readline

N = int(input())
G = [[]]
A = []

for _ in range(N):
    a = int(input())
    if len(G[-1]) > 0 and G[-1][-1] > a:
        G.append([])
    A.append(a)
    G[-1].append(a)

def isOk():
    if any(l[-1] + 1 < r[0] for l, r in zip(G, G[1:])):
        return False
    for grp in G:
        if any(l + 1 < r for l, r in zip(grp, grp[1:])):
            return False
    return A[0] == 0

if not isOk():
    print(-1)
    exit()

ans = 0
A = [-10**18] + A[::-1]

for r, l in zip(A, A[1:]):
    if l >= r:
        ans += l
print(ans)


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll a, b;
    cin >> a >> b;
    cout << (a + b) / 2 + (a + b) % 2 << endl;
    return 0;
}


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

using ll = long long;

int main()
{
    ll a, b, k; cin >> a >> b >> k;
    ll xx = a - k;

    if (xx < 0) cout << 0 << ' ' << (b - abs(xx) >= 0 ? b - abs(xx) : 0);
    else cout << a - k << ' ' << b;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){

char s[10];
int n,k,i;
scanf("%d\n%s\n%d",&n,s,&k);

for(i=0;i<n;i++)
if(s[k-1]!=s[i])
s[i]='*';

printf("%s",s);
return 0;
}

Measured memory_bytes: 128
//Using Stack Data Structure

#include <stdio.h>

int stack[10];
int n;	//stack pointer

void init(){
	n = 0;
}

void push(int x){
	stack[n++] = x;
}

int pop(){
	return stack[--n];
}

int main(void){
	init();
	int o;
	while(scanf("%d", &o) != EOF){
		if(o == 0){
			printf("%d\n", pop());
		}else{
			push(o);
		}
	}
	
	return 0;
}

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

void push(int x);
int pop(void);

int num = 0;
int stack[100];

int main(){

	char op[7];
	int x;
	int i;

	while(scanf("%s",op) != EOF){
		if(op[0] == '+'){
			push(pop() + pop());
		}
		else if(op[0] == '-'){
			x = pop();
			push(pop() - x);
		}
		else if(op[0] == '*'){
			push(pop() * pop());
		}
		else{
			push(atoi(op));
		}
	}

	printf("%d\n", pop());

	return 0;
}

void push(int x){
	stack[num++] = x;
}

int pop(){
	return stack[--num];
}

Measured memory_bytes: 548
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long ai, ao, at, aj, al, as, az;
		ai = sc.nextLong();
		ao = sc.nextLong();
		at = sc.nextLong();
		aj = sc.nextLong();
		al = sc.nextLong();
		as = sc.nextLong();
		az = sc.nextLong();
		long ans = 0;
		ans = Math.max(ans, ai / 2 * 2 + ao + aj / 2 * 2 + al / 2 * 2);
		if (ai > 0 && aj > 0 && al > 0)
			ans = Math.max(ans, 3 + (ai - 1) / 2 * 2 + ao + (aj - 1) / 2 * 2 + (al - 1) / 2 * 2);
		System.out.println(ans);
	}
}


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

string S;
int main(){
	while(cin >> S){
		bool judge = false;
		int a,b;
		for(int i=0;i<S.size()-1;i++){
			if(S[i] == S[i+1]){
				judge = true;
				a = i+1;
				b = i+2;
			}
		}
		if(judge) cout << a << " " << b << endl;
		else{
			for(int i=0;i<S.size()-2;i++){
				if(S[i] == S[i+2]){
					judge = true;
					a = i+1;
					b = i+3;
				}
			}
			if(judge) cout << a << " "  << b << endl;
		}
		if(!judge) cout << -1 << " " << -1 << endl;
	}
}

Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
	int a[3];
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	int leng = sizeof(a) / sizeof(a[0]);
	for (int j = 0;j < 2;j++) {
		for (int i = 0; i < leng - 1; i++)
		{
			if (a[i] > a[i + 1])
				swap(a[i], a[i + 1]);
		}
	}

	printf("%d %d %d\n",a[0],a[1],a[2]);

	

	
	

	return 0;
}


Measured memory_bytes: 2720
#include <iostream>

using namespace std;

int main(){
 int A,B,C,K;
   cin >> A >> B >> C >> K;
  if(K <= A)
  {
   cout << K << endl; 
  }
  if(K <= A+B && K > A)
  {
   cout << A << endl; 
  }
  if(K <= A+B+C && K > A+B)
  {
    cout << 2*A+B-K << endl;
  }
  return 0;
}


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

int N, W;
int v[100], w[100];
int dp[100][10001];

// maximize sum of value
int solve(int idx, int limit) {
  if (idx >= N)
    return 0;

  if (dp[idx][limit] != -1)
    return dp[idx][limit];

  int ret = solve(idx + 1, limit);
  if (w[idx] <= limit)
    ret = max(solve(idx + 1, limit - w[idx]) + v[idx], ret);

  return dp[idx][limit] = ret;
}

int main(void) {
  cin >> N >> W;
  for (int i = 0; i < N; i++)
    cin >> v[i] >> w[i];

  memset(dp, -1, sizeof(dp));

  cout << solve(0, W) << endl;
  return 0;
}

Measured memory_bytes: 7036
import sys

p = [0] * 51
v = 0
for i in range(10):
    p[i] = p[36-i] = (i+3)*(i+2)*(i+1)//6

for i in range(10,19):
    p[i] = p[36-i] = (i+1)*(i+2)*(i+3)//6 - 2*(i-9)*(i-8)*(i-7)//3

for i in sys.stdin:
    print(p[int(i)])

Measured memory_bytes: 7616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <list>
#include <vector>
#include <queue>
#define max 10005
#define inf 0x3fffffff
 
using namespace std;
 
int n,e;
list<int> out;
vector<int> G[max];
queue<int> q;
bool v[max];
int indeg[max];
 
void bfs() {
    int i;
    //queue<int> q;
    //q.push(u);
    //v[u]=true;
    while(!q.empty()) {
        int tmp=q.front();
        q.pop();
        out.push_back(tmp);
        for(i=0;i<G[tmp].size();i++) {
            int s=G[tmp][i];
            indeg[s]--;
            if(indeg[s]==0 && v[s]==false) {
                q.push(s);
                v[s]=true;
            }
        }
    }
}
 
int main() {
    int i;
     
    scanf("%d %d",&n,&e);
     
    for(i=0;i<n;i++) {
        v[i]=false;
        indeg[i]=0;
    }
     
    for(i=0;i<e;i++) {
        int d1,d2;
        scanf("%d %d",&d1,&d2);
        G[d1].push_back(d2);
        indeg[d2]++;
    }
     
    /*for(i=0;i<n;i++) {
        if(indeg[i]==0 && v[i]==false) bfs(i);
    }*/
    
    for(i=0;i<n;i++) {
        if(indeg[i]==0 && v[i]==false) {
        	q.push(i);
        	v[i]=true;
		}
    }
    
    bfs();
     
    for(list<int>::iterator it=out.begin();it!=out.end();it++) {
        printf("%d\n",*it);
    }
     
    return 0;
}



Measured memory_bytes: 4140
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int main(){
    int n, m;
    cin >> n >> m;
    VI ans(n);
    REP(i,m){
        int u, v;
        cin >> u >> v;
        ans[u-1]++;
        ans[v-1]++;
    }
    REP(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
// ABC333

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>

using namespace std;

int main() {
    int a , b;
    cin >> a >> b;
    bool result = false;
    if (a % 2 != 0 && b % 2 != 0) {
        result = true;
    }

    if (result) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N,M,X=map(int, input().split())
A=list(map(int, input().split()))
low = 0
high = 0
for a in A:
    if a < X:
        low += 1
    else:
        high += 1
print(min(low, high))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    long long int arr[1000],i,po=0;
    for(i=1;i<6;i++)
    {
        cin >> arr[i];
    }
    for(i=1;i<6;i++)
    {
        if(arr[i]==0)
            po=i;
    }
    cout << po << endl;

}


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

int main(){
    string s;
    cin >> s;
    int counter=0;
    if(s[0] == '1'){
        counter += 1;
    }
    if(s[1] == '1'){
        counter += 1;
    }
    if(s[2] == '1'){
        counter += 1;
    }
    cout << counter << endl;
}

Measured memory_bytes: 3548
#include <iostream>
#include <map>
using namespace std;
const int maxn = 2e5 + 5;
int N, M, f[maxn];
int findSet(int n) { return f[n] == n ? n : f[n] = findSet(f[n]); }
int main() {
    cin >> N >> M;
    for(int i = 1; i <= N; ++i) f[i] = i;
    while(M--) {
        int a, b;
        cin >> a >> b;
        int fa = findSet(a), fb = findSet(b);
        if(fa != fb) {
            f[fa] = fb;
        }
    }
    map<int, int> cnt;
    for(int i = 1; i <= N; ++i) cnt[findSet(i)]++;
    int ans = 0;
    for(auto p : cnt) {
        ans = max(ans, p.second);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13640
#include <stdio.h>

int main(){

  int n,r,c[4][13];
  int i=0,k=0;
  char e;


  for(i=0;i<4;++i){
    for(k=0;k<13;++k){
      c[i][k]=0;
    }
  }

  scanf("%d",&n);

  for(i=0;i<n;++i){
    scanf("%c",&e);
    if(e=='\n'){
      scanf("%c",&e);
    }
    scanf("%d",&r);

    if(e=='S') c[0][r-1]=1;
    if(e=='H') c[1][r-1]=1;
    if(e=='C') c[2][r-1]=1;
    if(e=='D') c[3][r-1]=1;
  }
  
  for(i=0;i<4;++i){
    for(k=0;k<13;++k){
      if(c[i][k]==0){
	if(i==0) printf("S %d\n",k+1);
	if(i==1) printf("H %d\n",k+1);
	if(i==2) printf("C %d\n",k+1);
	if(i==3) printf("D %d\n",k+1);
      }
    }
  }
  


  return 0;
}



Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    ll a, b, k;
    cin >> a >> b >> k;
    ll t = min(a, k);
    a -= t;
    k -= t;
    if (k > 0){
        t = min(b, k);
        b -= t;
    }
    cout << a << ' ' << b << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3592
import sys

def answer():
    input = sys.stdin.readline
    M = int(input())

    digits = 0
    total = 0

    for i in range(M):
        c, d = map(int, input().split())
        digits += d
        total += d * c

    ans = (digits-1) + (total-1) // 9

    print(ans)


if __name__ == '__main__':
    answer()


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            var inputs = new List<int>();
            for(int i =0;i<3;i++)
            {
                inputs.AddRange(Console.ReadLine().Split(' ').Select(s => int.Parse(s)));
            }
            var tmp = inputs.GroupBy(s => s).Select(g => g.Count()).ToList();
            tmp.Sort();
            for(int i=0;i<tmp.Count;i++)
            {
                if((i<2&&tmp[i]!=1) ||(1<i&&tmp[i]!=2))
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
            Console.WriteLine("YES");
        }
    }

Measured memory_bytes: 13524
#include <stdio.h>
 
int main(){
	int N, a, b, c;

	scanf("%d", &N);

	a = N / 100;

	b = (N - a * 100) / 10;

	c = (N - a * 100 - b * 10);

	if(a == c) {
		printf("Yes");
	}

	else {
		printf("No");
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 1e5 + 55;//, mod = 1e9 + 7;
int n, e, c, sz = 0;
int a[maxn], b[maxn], vis[maxn];
map<int, int> id, cnt;
vi g[maxn];
int getid(int x) {
	if(!id.count(x)) id[x] = sz++;
	return id[x];
}
void add_edge(int u, int v) {
	e++;
	g[u].pb(v);
	g[v].pb(u);
}
void dfs(int v) {
	vis[v] = 1;
	for(int i : g[v])
		if(!vis[i]) dfs(i);
}
void solve() {
	for(int i = 0; i < sz; i++) if(!vis[i]) c++, dfs(i);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i], a[0] ^= a[i], cnt[a[i]]++;
	for(int i = 1; i <= n; i++) cin >> b[i], b[0] ^= b[i], cnt[b[i]]--;
	cnt[a[0]]++, cnt[b[0]]--;
	for(auto i : cnt) if(i.second) return cout << -1, 0;
	for(int i = 1; i <= n; i++) {
		if(a[i]!=b[i]) add_edge(getid(a[i]), getid(b[i]));
	}
	int zero = 1;
	for(int i = 0; i < n; i++) zero &= a[i] == b[i];
	if(zero) return cout << 0, 0;
	getid(a[0]);
	getid(b[0]);
	solve();
	cout << e + c - 1;
}


Measured memory_bytes: 19456
ars = "abcdefghijklmnopqrstuvwxyz"
S = input()
def iftasai(s):
  for i in s:
    if s.count(i) > 1:
      return False
  return True
if len(S) != 26:
  for i in ars:
    if not (i in S):
      print(S + i)
      quit()
elif S == "zyxwvutsrqponmlkjihgfedcba":
  print(-1)
  quit()
else:
  for i in range(1,len(S)+1):
    n = ars.index(S[-i])
    tmp = ars[n+1:]
    for j in tmp:
      ans = S[:-i] + j
      if iftasai(ans):
        print(ans)
        quit()

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dc[4] = {1, -1, 0,  0};
const int dr[4] = {0,  0, 1, -1};
//const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
//const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int h, w;
    cin >> h >> w;
    
    v_string s(h);
    cin >> s;
    
    queue<pii> q;
    v2_int dist(h, v_int(w, 0));
    v2_bool done(h, v_bool(w, false));
    irep(i, h) {
        irep(j, w) {
            if(s[i][j] == '#') {
                q.push(pii(i,j));
                done[i][j] = true;
            }
        }
    }
        
    while(q.size()) {
        pii t = q.front(); q.pop();
        irep(x,4) {
            int row = t.fi + dr[x];
            int col = t.se + dc[x];
            if(row < 0 || row >= h) { continue; }
            if(col < 0 || col >= w) { continue; }
            if(s[row][col] == '#' || done[row][col]) { continue; }
            done[row][col] = true;
            dist[row][col] = dist[t.fi][t.se] + 1;
            q.push(pii(row,col));
        }
    }

    int ans = 0;
    irep(i, h) {
        irep(j, w) {
            chmax(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

/*atcoder*/


Measured memory_bytes: 17172
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back

using namespace std;

int main() {

      int n;
       cin>>n;
       int a[n];
       map<int,int> m;
       for(int i=0;i<n;i++)
       {
           cin>>a[i];
           m[a[i]]++;
       }
      int co=0;
      //hi
       for(int i=0;i<n;i++)
       {
           int f=0;
           for(int j=2;j*j<=(a[i]);j++)
           {
               if(a[i]%j==0)
               {
                   if(m[j]==0&&m[a[i]/j]==0)
                   {
                       
                   }
                   else
                   {
                       f=123;
                       break;
                   }
               }
           }
           if(f==0&&m[a[i]]==1&&m[1]==0)
           {
               co++;
           }
       }//vdkngdnnnn
       if(m[1]>1||m[1]==0)
       cout<<co;
       else
       cout<<co+1;
      
}


Measured memory_bytes: 33160
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
inline int Log2(ll x) {int k; for(k=0; x>0; ++k) x>>=1; return k;} // number of binary digits
template<typename T> inline int count_between(vector<T>& a, T l, T r) {
  return lower_bound(all(a), r) - lower_bound(all(a), l); // [l, r)
}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {
  rep(i, v.size()) is >> v[i]; return is;
}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
  rep(i, v.size()) os << v[i] << " "; os << endl; return os;
}
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;


int main() {
  ll n; cin >> n;
  priority_queue<P> pql0, pql;
  priority_queue<P, vector<P>, greater<P>> pqr0, pqr;
  rep(i, n) {
    int l, r; cin >> l >> r;
    pql0.push(P(l, i));
    pqr0.push(P(r, i));
  }

  pql = pql0;
  pqr = pqr0;

  int now = 0;
  ll ans1 = 0;
  vector<bool> used(n, false);
  int cnt = 0;
  while (!pql.empty() && !pqr.empty()) {
    int x, i;
    if (cnt%2) {
      tie(x, i) = pql.top(); pql.pop();
      if (used[i]) continue;
      if (now < x) {
        ans1 += x-now;
        now = x;
      }
    }
    else {
      tie(x, i) = pqr.top(); pqr.pop();
      if (used[i]) continue;
      if (now > x) {
        ans1 += now-x;
        now = x;
      }
    }
    used[i] = true;
    ++cnt;
  }
  ans1 += abs(now);

  ll ans = ans1;

  pql = pql0;
  pqr = pqr0;
  
  now = 0;
  ans1 = 0;
  used = vector<bool>(n, false);
  cnt = 1;
  while (!pql.empty() && !pqr.empty()) {
    int x, i;
    if (cnt%2) {
      tie(x, i) = pql.top(); pql.pop();
      if (used[i]) continue;
      if (now < x) {
        ans1 += x-now;
        now = x;
      }
    }
    else {
      tie(x, i) = pqr.top(); pqr.pop();
      if (used[i]) continue;
      if (now > x) {
        ans1 += now-x;
        now = x;
      }
    }
    used[i] = true;
    ++cnt;
  }
  ans1 += abs(now);
  
  chmax(ans, ans1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3564
n = (int)(input())
a = list(map(int, input().split(" ")))
q = (int)(input())
m = list(map(int, input().split(" ")))
lst = []
for i in range(2 ** n, 0, -1):
    temp = 0
    for j in range(n):
        if (i >> j) & 1:
            temp += a[j]
    lst.append(temp)
for k in range(q):
    if m[k] in lst:
        print("yes")
    else:
        print("no")


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

using namespace std;

vector<int> g[111111];
int p[111111], A, B;
int f(int u, int v) {
	if (p[v]) return v == A;
	p[v] = 1;
	int b = 0;
	for (int w : g[v])
		if (w != u) b |= f(v, w);
	return b;
}
int main() {
	int n, m, c = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cout << ([&]()->int {
		m = 0;
		for (int i = 0; i < n; i++) {
			int x = g[i].size();
			if (x % 2) return 0;
			m = max(m, x);
			if (x == 4) c++, A = B, B = i;
		}
		if (m > 4) return 1;
		if (c != 2) return c > 2;
		p[B] = 1;
		return f(0, A);
	}() ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int x;
	cin>>x;
	if(x>=30) cout<<"Yes\n";
	else cout<<"No\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}


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

using namespace std;

int main(void) {

  long long N;
  cin >> N;

  vector<long long> f(N);
  
  for(long long n = 1; n <=N; n++) {
    if (n == 6) {
      cout << 1 << endl;
      continue;
    }
    long long count = 0;
    long long sqrtn = sqrt(n);
    for(long long x = 1; x <= sqrtn; x++ ) {
      for (long long y = x; y<=sqrtn; y++) {
        for (long long z = y; z <= sqrtn; z++) {
          long long add = 0;
          if (x*x + y*y + z*z + x*y + y*z + z*x == n) {
            add = 1;
            if (x==y && y==z) {
              add = add * 1;
            } else if (x == y || y == z) {
              add = add * 3;
            } else {
              add = add * 6;
            }
          }
          count += add;
        }
      }
    }
    cout << count << endl;
  }

}


Measured memory_bytes: 3660