akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main() {
    int n, q, ans = 0;
    cin >> n;
    int s[n];
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    cin >> q;
    int t[q];
    for (int j = 0; j < q; ++j) {
        cin >> t[j];
    }
    for (int k = 0; k < q; ++k) {
        //cout << t[k] << endl;
        int left = 0, right = n, mid;
        while (left < right) {
            mid = (right + left) / 2;
            if (t[k] == s[mid]) {
                ans++;
                //cout << t[k] << endl;
                break;
            } else if (t[k] < s[mid]){
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        
    }
    cout << ans << endl;
    return 0;
}


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

int main() { 
    string a, b, c;
    cin >> a >> b >> c;

    a[0] -= 32;
    b[0] -= 32;
    c[0] -= 32;
    cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    ll l;
    cin >> l;
    cout << setprecision(10) << pow((l/3.0), 3.0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
void comb(vector<vector <long long int> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
      v[k][j] %= 1000000007;
    }
  }
}

int main(){
  int N;
  cin >> N;
  int M = N/3;
  vector<vector<long long int> > v(N+1,vector<long long int>(N+1,0));
  
  long long ans = 0;
  for(int i = 0; i < M; i++){
    int L = N - 3*(i+1);
    comb(v);
    ans += v[L+i][i] % 1000000007;
    ans %= 1000000007;
  }
  cout << ans << endl;
}



Measured memory_bytes: 34572
#include<iostream>

using namespace std;



bool isLarge(int y, int m){
  if(y%3 == 0 || m%2) return true;
  return false;
}
void solve(int y,int m,int d){
  int ans;
  if(isLarge(y,m)) ans = 20-d;
  else ans = 19-d;
  m++;
  for(int i = m; i <= 10; i++)
    if(isLarge(y,i)) ans += 20;
    else ans += 19;
  y++;

  for(int i = y; i < 1000; i++)
    for(int j = 1; j <= 10; j++)
      if(isLarge(i,j)) ans += 20;
      else ans += 19;

  cout << ans+1<< endl;
}
int main(){
  int n;
  cin >> n;
  while(n--){
    int y,m,d;
    cin >> y >> m >> d;
    solve(y,m,d);
  }
  return 0;
}

Measured memory_bytes: 0
# coding: utf-8
# Your code here!
N,M=map(int,input().split())
H=list(map(int,input().split()))

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

ans=0

for i in range(N):
    judge=True
    for item in way[i]:
        if H[i]<=H[item]:
            judge=False
            break
    if judge:
        ans+=1
print(ans)

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

# 一番左はいつも見えている
ans = (10**9)*15
for i in range(2**(n-1)):
    pattern = []
    for j in range(n-1):
        if (i >> j) & 1:
            pattern.append(j+1)
    if len(pattern) != (k-1): continue
    count = 0
    prev = a[0]
    for l in range(1, n):
        if l not in pattern:
            prev = max(prev, a[l])
            continue
        if a[l] <= prev:
            extended = prev + 1
            count += (extended - a[l])
            prev = extended
        else:
            prev = a[l]
    #print(count)
    ans = min(ans, count)
print(0 if k == 1 else ans)


Measured memory_bytes: 42992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;


ll ans=0;
int n;
vector<int> E[201010];
VI v(201010);
VI w(201010);

VI tw(202020);

void dfs(int cu, int pa = -1) {
  v[cu]=1;
  w[cu]=tw[n-1]-1;
  for(int to:E[cu]) {
    if (to != pa) {
      //
      dfs(to,cu);
      //
      v[cu]+=v[to];
      w[cu]+=w[to];
      w[cu]+=(mod-tw[v[to]]+1)%mod;
      w[cu]%=mod;
    }
  }
  w[cu]+=(mod-(tw[n-v[cu]])+1)%mod;
  w[cu]%=mod;
}



ll modinv(ll a) {
    ll m=mod;
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(){
  int i,j;
  cin>>n;
  for(i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--; b--;
    E[a].pb(b);
    E[b].pb(a);
  }
  tw[0]=1;
  for(i=1;i<202020;i++){
    tw[i]=tw[i-1]*2%mod;
  }
  dfs(0);
  for(i=0;i<n;i++){
    //cout<<i+1<<" "<<w[i]<<" "<<v[i]<<endl;
  }
  ll ans=w[0]*modinv(tw[n])%mod;
  cout<<ans<<endl;

  
  return 0;
}


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

int main(){
	string s;
	cin >> s;
	string t;
	cin >> t;
	int ans = 0;
	rep(i,3){
		if(s[i] == t[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  
  int N;
  
  cin>>N;
  
  int A[N]={0};
  int B[N+1]={0};
  
  for(int i = 1;i < N;i++){
   cin>>A[i];
  }
 
  for(int i = 1;i < N;i++){
   if(A[i] > 0)B[A[i]]++;
  }
  
  for(int i = 1;i < N+1;i++){
   cout<<B[i]<<endl;
  }
  
  
 return 0; 
}

Measured memory_bytes: 5180
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int a;
	cin >> a;
	if (a % 2 == 0){
		cout << a << endl;
	}
	else{
		cout << a * 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s,s1[2]={""};
    ll c[2]={0};
    cin>>s;
    rep(0,i,4){
        string s0=s.substr(i,1);
        if(s1[0]==""){
            ++c[0];
            s1[0]=s0;
        }else if(s1[0]==s0){
            ++c[0];
        }else if(s1[1]==""){
            s1[1]=s0;
            ++c[1];
        }else if(s1[1]==s0){
            ++c[1];
        }
        if(c[1]==2){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
def main():
    num = int(input())

    def ggg():
        for divisor in range(1, num + 1):
            quotient = num // divisor
            yield (quotient + 1) * quotient * divisor // 2

    print(sum(ggg()))


if __name__ == '__main__':
    main()

# Python 3.8.2: 1332 ms
# Pypy 3 (7.3.0): 172 ms


Measured memory_bytes: 67424
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 10007;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*-----Library-----*/
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<100000;i++){
        if((int)(i*1.08)==n){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
}


Measured memory_bytes: 256
import heapq
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


n,k = map(int,input().split())

#最大距離2の最大の頂点数
max_vtx = (n-1)*(n-2)*0.5

if k > max_vtx:
    print(-1)
    exit()

#追加すべき辺数
add_line = max_vtx - k

#必要辺数
line = int(n-1 + add_line)

print( line )

for i in range(1,n):
    print(1,i+1)

cur = 0

for i in range(2,n+1):
    if cur >= add_line:
            break
    for j in range(3,n+1):
        if i >= j:
            continue
        if cur >= add_line:
            break
        print(i,j)
        cur += 1

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

  int m , n_min , n_max;
  int P[200];
  while(true){
    int ans, max_gap = 0;
    cin >> m >> n_min >> n_max;
    if(m == 0 && n_min == 0 && n_max == 0)   break;

    for(int i = 0 ; i < m ; i++)   cin >> P[i];

    for(int i = n_min - 1 ; i < n_max ; i++){
      if(max_gap <= P[i] - P[i + 1]){
        max_gap = P[i] - P[i + 1];
        ans = i + 1;
      }
    }
      cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3104
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if (a<b) swap(a,b);
    if (a<c) swap(a,c);
    if (b<c) swap(b,c);
    cout<<a-c;
}

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

using ll = long long int;

ll N, M;

ll comb[2005][2005];

ll power(ll x, ll n){
    x %= M;
    ll res = 1;
    while(n > 0){
        if(n&1) res = res*x%M;
        x = x*x %M;
        n >>= 1;
    }
    return res;
}

int main(){
    cin >> N >> M;
    
    for(int i=0;i<=N;i++){
        for(int j=0;j<=i;j++){
            if(j==0 || j==i){
                comb[i][j] = 1;
            }else{
                comb[i][j] = (comb[i-1][j]+comb[i-1][j-1])%M;
            }
        }
    }

    ll ans = 0;
    for(ll a=1;a<N;a++){
        ll b = N-a;
        ll s = 0;
        for(ll x=0;x<=a;x++){
            s += (power(power(2,(a-x))-1+M,b)*comb[a][x]%M*(x&1?-1:1)+M)%M;
            s %= M;
        }
        ans += s*comb[N][a]%M*power(2,a*(a-1)/2)%M*power(2,b*(b-1)/2);
        ans %= M;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 25656
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

// 入力
int n, W;
int weight[110], value[110];

// DPテーブル
int dp[110][10010];

int main() {
  cin >> n >> W;
  for (int i = 0; i < n; ++i) cin >> value[i] >> weight[i];

  // DP初期条件: dp[0][w] = 0
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;

  // DPループ
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }

  cout << dp[n][W] << endl;
}


Measured memory_bytes: 7056
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int sum(int n){
    int sum=0;
    while(n>0){
        sum += n%10;
        n/=10;
    }
    return sum;
}

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i=0;i<N;i++){
        cin >> v.at(i);
    }
    int btn=1;
    for(int i=0;i<N+1;i++){
        btn = v.at(btn-1);
        if(btn==2){
            cout << i+1 <<endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
const int INF = 1e9;
typedef long long ll;
using namespace std;

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


int main() {
	ll l, r;
	cin >> l >> r;

	ll ans = INF;
	r = min(r, l + 2019);

	for (ll i = l; i < r; i++) {
		for (ll j = l + 1; j <= r; j++) {
				ans = min(ans, i * j % 2019);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(vector<T> & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(vector<T>& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(vector<T>& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(vector<T>& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>T Sum(vector<T> a, T init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define In(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn(T,name,n) vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn2(T,name,name2,n) vector<T> name(n),name2(n); rep(i,n)cin>>name[i]>>name2[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	In(string ,s, t);
	reverse(all(t));
	YES(s == t);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define int long long
const int inf=2147483647;
il int read()
{
int x=0;int f=1;
char s=getchar();
while(s<'0' || s>'9')
{if(s=='-')f=-1;s=getchar();}
while(s>='0' && s<='9')
{x=x*10+s-'0';s=getchar();
}
return x*f;		
}

struct Edge
{int u,v,w;}edge[2001000];
int head[2001000],tot;
//void add(int x,int y,int w){
  //  ed[++tot].nxt=head[x];
	//ed[tot].to=y;
	///./ed[tot].w=w;
	//head[x]
int Min_value[2001000];
int fa[555000],n,q,ans,eu,ev,cnt;

il bool cmp(Edge a,Edge b)
{return a.w<b.w;}

il int Union(int x)
{while(x!=fa[x])x=fa[x]=fa[fa[x]];
return x;}

il void kruscal()
{
sort (edge+1,edge+1+cnt,cmp);
for(int i=1;i<=cnt;i++)
{int ttt=0;
int eu=Union(edge[i].u);
int ev=Union(edge[i].v);
if(eu==ev){continue;}
	ans+=edge[i].w;
	fa[eu]=ev;++ttt; 
	if(ttt==n-1)
	{break;}}}
signed main()
{
	n=read();
	q=read();
    memset(Min_value,0x3f,sizeof(Min_value));
    while(q--)
    {
        int u=read()+1;int v=read()+1;int w=read();
        edge[++cnt]=(Edge){u,v,w};
        Min_value[u]=min(Min_value[u],w+1);
        Min_value[v]=min(Min_value[v],w+2);
    }
	for(int i=1;i<=n;i++)
	{fa[i]=i;}
	for(int i=1;i<=n;i++){
		Min_value[i%n+1]=min(Min_value[i%n+1],Min_value[i]+2);
	}
	for(int i=1;i<=n;i++){
		Min_value[i%n+1]=min(Min_value[i%n+1],Min_value[i]+2);
	}
	for(int i=1;i<=n;i++){
		edge[++cnt]=(Edge){i,i%n+1,Min_value[i]};
	}
kruscal();
cout<<ans;
return 0;
}

Measured memory_bytes: 28416
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define init(a,x) memset(a,x,sizeof(a))

ll n,m; ll dp[1003][1003]; char grid[1003][1003];

bool isvalid(ll i , ll j)
{
	if(i<0 || i>=n || j<0 || j>=m)return false;
	else
	{
		if(grid[i][j]=='#')return false; else return true;
	}

}

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	cin>>n>>m;
	init(dp,0);

	forA(i,0,n,1)forA(j,0,m,1)cin>>grid[i][j];
	ll r=0,c=0;
	forA(i,0,n,1){if(grid[i][0]=='.')dp[i][0]=1; else break;}
	forA(i,0,m,1){if(grid[0][i]=='.')dp[0][i]=1; else break;}

	forA(i,1,n,1)
	{
		forA(j,1,m,1)
		{
			if(grid[i][j]=='.')dp[i][j]=((dp[i-1][j]%mod)+(dp[i][j-1]%mod))%mod;
		}
	}

	//forA(i,0,n,1){forA(j,0,m,1)cout<<dp[i][j]<<" "; cout<<"\n";}

	cout<<dp[n-1][m-1];
	return 0;
}

Measured memory_bytes: 12460
N, X = map(int, input().split())

pos = X
eat = 0
for i in range(N-1, -1, -1):
    nlayer = 2 ** (i+2) - 3
    npatie = 2 ** (i+1) - 1
    if pos == 1:
        break
    elif pos <= 1 + nlayer:
        pos -= 1
        if i == 0:
            eat += 1
        continue
    elif pos == 2 + nlayer:
        eat += npatie + 1
        break
    elif pos <= nlayer * 2 + 2:
        eat += npatie + 1
        if i == 0:
            eat += 1
        pos -= nlayer + 2
    else:
        eat += npatie * 2 + 1
        break

print(eat)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)




int main() {
  ll x;
  cin >> x;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));
  if (x == 1) cout << "0" << endl; 
  else cout << "1" << endl;

  return 0;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-


def main():
    from bisect import bisect

    n = int(input())
    a = sorted(list(map(int, input().split())))
    b = sorted(list(map(int, input().split())))
    c = sorted(list(map(int, input().split())))
    ans = 0

    for bi in b:
        a_count = bisect(a, bi - 1)
        c_count = n - bisect(c, bi)
        ans += a_count * c_count

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22720
import scala.io.StdIn

object Main extends App {
  val Array(a, b, c, d) = StdIn.readLine.split(" ").map(_.toInt)

  val start = math.max(a, c)
  val end = math.min(b, d)
  val ans = math.max(end - start, 0)

  println(ans)
}

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

using namespace std;

int main(void) {
   int k, t;
   cin >> k >> t;

   vector<int> a(t);
   for (int i = 0; i < t; i++) {
     cin >> a[i];
   }
   sort(a.begin(), a.end());

   while (t - 2 >= 0 && a[t - 2] != 0) {
      a[t - 1] -= a[t - 2];
      a[t - 2] = 0;
      sort(a.begin(), a.end());
   }

   if (a[t - 1]) {
     cout << a[t - 1] - 1 << endl;
   } else {
     cout << 0 << endl;
   }

  return 0;
}

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

#define MOD 1000000007

int n;
int k;


vector<int> dv;
vector<long long int>  way;

long long int ppow(long long int i, long long int j) {
	long long int res = 1LL;
	while (j) {
		if ((j & 1LL)) {
			res *= i;
			if (res >= MOD) {
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD) {
			i %= MOD;
		}
	}
	return res;
}

int main() {
	cin >> n >> k;
	for (long long int i = 1; i*i <= n; i++) {
		if(n%i==0)dv.push_back(i);
		if (n%i == 0)dv.push_back(n / i);
	}
	sort(dv.begin(), dv.end());
	dv.erase(unique(dv.begin(), dv.end()), dv.end());
	for (int i = 0; i < dv.size(); i++) {
		way.push_back(ppow(k, (dv[i] + 1) / 2));
		for (int j = 0; j < i; j++){
			if (dv[i] % dv[j] == 0) {
				way[i] += MOD - way[j];
				if (way[i] >= MOD)way[i] %= MOD;
			}
		}
	}
	long long int ans = 0;
	for (int i = 0; i < dv.size(); i++) {
		if (dv[i] % 2 == 0) {
			ans += way[i] * dv[i]/2;
		}
		else {
			ans += way[i] * dv[i];
		}
		if (ans >= MOD)ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#塗り方としては"0101..."か"1010..."の2種類しかない。２つとの差分を求めて少ない方を出力すればok
S = input()
N = len(S)
cost1 = 0
cost2 = 0
for i in range(N):
    if i % 2 == 0:
        if S[i] == "0":
            cost1 += 1
        else:
            cost2 += 1
    else:
        if S[i] == "1":
            cost1 += 1
        else:
            cost2 += 1

if cost1 < cost2:
    print(cost1)
else:
    print(cost2)


Measured memory_bytes: 3188
#include<iostream>
#include<string>
using namespace std;
string x,y;
int dp[1005][1005];
int lcs(string x,string y)
{

    int Max=-1;
    int n=x.size(),m=y.size();
    x=' '+x;
    y=' '+y;
    for(int i=1;i<=n;i++)dp[i][0]=0;        //边界条件就是从此开始的，所以要置为1，
    for(int i=1;i<=m;i++)dp[0][i]=0;        //不然循环查询的次数多了就会造成错误
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
         if(x[i]==y[j])dp[i][j]=dp[i-1][j-1]+1;
         else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
         //Max=max(Max,dp[i][j]);
        }
    return dp[n][m];
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
         cin>>x>>y;
        cout<<lcs(x,y)<<endl;
    }
    return 0;
}



Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int n,m;
    cin>>n>>m;
    vector<ll>a(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    vector<pair<int,ll>>v(m);
    for(int i=0;i<m;++i){
        int b;
        ll c;
        cin>>b>>c;
        v[i]={c,b};
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    vector<ll>vv;
    for(int i=0;i<n;++i){
        for(int j=0;j<v[i].second;++j){
            if(vv.size()==n)goto BREAK;
            vv.push_back(v[i].first);
        }
    }
    BREAK:
    ll ans=0;
    for(int i=0;i<n;++i){
        if(i<vv.size()){
            a[i]=max(a[i],vv[i]);
        }
        ans+=(ll)a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3704
#include <iostream>
using namespace std;
 
int main() {
	int a,b;
  	cin >> a >> b;
  	if(a <= b) {
    	cout << 1;
      	return 0;
    }
  	if(a % (2 * b + 1)) {
    	cout << a / (2 * b + 1) + 1;
    } else {
    	cout << a / (2 * b + 1);
    }
}

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

ans = 0
0.upto(n) do |i|
  0.upto(n-i) do |j|
    next if i + j > m
    b = (a[0,i] + a[-j,j]).dup
    b.sort!
    count = m - j - i
    while count > 0 && b.size > 0
      count -= 1
      b.shift if b.first < 0
    end
    sum = b.inject(0,:+)
    ans = sum if ans < sum
  end
end

puts ans

Measured memory_bytes: 2172
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <climits>

#define int long long int

using namespace std;

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

    int n, m, l, q;
    cin >> n >> m >> l;
    vector<vector<int>> a(n, vector<int>(n, LLONG_MAX / 2));

    for (int i = 0; i < m; i++)
    {
        int from, to, w;
        cin >> from >> to >> w;
        from--, to--;
        a[from][to] = w;
        a[to][from] = w;
    }

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

    for (int k = 0; k < n; k++)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                a[i][j] = min(a[i][j], a[i][k] + a[k][j]);

    vector<vector<int>> d(n, vector<int>(n, INT_MAX));

    for (int s = 0; s < n; s++)
    {
        queue<int> que;
        que.push(s);
        d[s][s] = 0;

        while (!que.empty())
        {
            int x = que.front();
            que.pop();
            for (int j = 0; j < n; j++)
                if (d[s][j] == INT_MAX && a[x][j] <= l)
                {
                    d[s][j] = d[s][x] + 1;
                    que.push(j);
                }
        }
    }

    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int s, t;
        cin >> s >> t;
        s--, t--;
        cout << (d[s][t] == INT_MAX ? -1 : d[s][t] - 1) << "\n";
    }

    return 0;
}


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

using namespace std;

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double t;
    if (x > a * a * b / 2){
        double y = (2 * x - a * a * b) / (a * a);
        t = 90 - abs(atan(a / (b - y)) * 180 / M_PI);
    } else {
        double y = 2 * x / (a * b);
        t = 90 - atan(y / b) * 180 / M_PI;
    }
    
    cout << setprecision(8);
    cout << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define PB push_back
#define ub upper_bound
#define lb lower_bound
#define ins insert
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin>>S;
    if((S[2]==S[3])&&(S[4]==S[5]))
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> num(n);
  bool h =true;
  for(int i = 0; i < n; i++){
    cin >> num[i];
  }
  
  for(int i = 0; i < n; i++){
    if(num[i]%2==0){
      if(num[i]%3!=0&&num[i]%5!=0){
      h = false;
      }
    }
  }
  
  if(h) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


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

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

    string key = "keyence";
    if(s == key){
        printf("YES\n");

        return 0;
    }

    for(int i = 0; i < s.size(); i++){
        for(int j = i; j < s.size(); j++){
            string word = "";
            for(int k = 0; k < s.size(); k++){
                if(i <= k and k <= j){
                    continue;
                } 
                word += s[k];
            }

            if(word == key){
                printf("YES\n");
                return 0;
            }
        }
    }

    printf("NO\n");

   return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, l, t) = (v[0] as usize, v[1], v[2]);
    let mut xs = vec![];
    let mut ws = vec![];
    for _ in 0..n {
        let v = read_vec::<i64>();
        xs.push(v[0]);
        ws.push(if v[1] == 2 { -1 } else { 1 });
    }
    let reversed = ws[0] == -1;
    if reversed {
        for i in 0..n {
            xs[i] = (l - xs[i]) % l;
            ws[i] = -ws[i];
        }
    }

    let mut poses = vec![];
    for (&x, &w) in xs.iter().zip(ws.iter()) {
        if w == 1 {
            poses.push((((x + t) % l), w));
        } else {
            poses.push((((l + (x - t) % l) % l), w));
        }
    }

    poses.sort();

    let mut count = 0;
    for i in 1..n {
        if ws[i] == -1 {
            count += 2 * t / l;
            if (2 * t) % l >= (xs[i] - xs[0] + l) % l {
                count += 1;
            }
        }
    }
    let count = count as usize % n;

    let zero_pos = ((xs[0] + t) % l, 1);
    let mut zero_idx = 0;
    for i in 0..n {
        if poses[i] == zero_pos {
            zero_idx = i;
        }
    }
    let mut answers = vec![0; n];

    for i in 0..n {
        if reversed {
            answers[i] = poses[(2 * n - i + zero_idx - count) % n].0;
        } else {
            answers[i] = poses[(i + zero_idx + n - count) % n].0;
        }
    }
    debug!(count, zero_idx);

    if reversed {
        for i in 0..n {
            answers[i] = (l - answers[i]) % l;
        }
    }
    for ans in answers {
        println!("{}", ans);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 9340
S = input()

for i in range(1,len(S)):
    d = S[0:len(S)-i]
    if i %2 == 0:
        if d == d[0:(len(S)-i)//2] + d[0:(len(S)-i)//2]:
            e = len(S) - i
            break
print(e)

Measured memory_bytes: 2940
// C.

#include <iostream>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	LL a, b;
	double d;
	cin >> a >> d;
	b = (LL)(d * 100 + 1e-10);
	LL ans = (a * b) / 100;
	cout << ans << endl;
	return 0;
}


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

int main(){
  int a[10]={0};
  int n,sum=0;
  cin >> n;
  string s;
  cin >> s;
  r(i,n-2){
    if(a[s[i]-'0']==0){
    a[s[i]-'0']++;
      int b[10]={0};
    for(int j=i+1;j<n-1;j++){
      if(b[s[j]-'0']==0){
      b[s[j]-'0']++;
        int c[10]={0};
      for(int k=j+1;k<n;k++){
        if(c[s[k]-'0']==0){
        c[s[k]-'0']++;
        sum++;
        }
      }
      }
    }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 764
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    a_list = [int(x) for x in input().rstrip().split(" ")]
    a_list.sort()

    print(sum([a for i, a in enumerate(a_list[n:]) if i % 2 == 0]))


if __name__ == "__main__":
    resolve()


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n;
    cin>>n;
    Array a(n);
    REP(i,n) cin>>a[i];
    sort(all(a));
    ll sum=0;
    ll last=-1;
    REP(i,n-1){
        sum+=a[i];
        if(sum*2<a[i+1]) last=i;
    }
    cout<<n-last-1<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
# coding: utf-8
#
    
def main(a,b):
    if 0 == a * b % 2:
        print('No')
    else:
        print('Yes')
    
    
if __name__ == '__main__':
    try:
        n  = int(input().strip())
        if 1 == n:
            print('Hello World')
        elif 2 == n:
            a = int(input().strip())
            b = int(input().strip())
            print(a + b)
    except EOFError:
        pass


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

int main(){
  char c;
  cin >> c;

  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  vl cnt(n,0);
  ll ans=1;
  rep(i,n){
    cnt[a[i]]++;
    if(a[i]==0){
      if(cnt[a[i]]<4){
        ans=ans*(4-cnt[a[i]])%MOD;
      }
      else{
        ans=0;
      }
    }
    else{
    if(cnt[a[i]]==3&&cnt[a[i]-1]==3){
      ans*=1;
    }
    else if(cnt[a[i]]==2&&cnt[a[i]-1]==2){
      ans*=1;
    }
    else if(cnt[a[i]]==2&&cnt[a[i]-1]==3){
      ans =ans*2%MOD;
    }
    else if(cnt[a[i]]==1&&cnt[a[i]-1]==3){
      ans =ans*3%MOD;
    }
    else if(cnt[a[i]]==1&&cnt[a[i]-1]==2){
      ans =ans*2%MOD;
    }
    else if(cnt[a[i]]==1&&cnt[a[i]-1]==1){
      ans *=1;
    }
    else ans=0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
//Wrong Answer
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

struct Pair {
	int first, second;
	Pair(int f, int s) { first = f; second = s; }
	Pair() {}
	bool operator < (const Pair &r) const { return (first != r.first) ? first < r.first : second < r.second; }
};

int n;
int p[100];
Pair dp[101][50001];	//dp[i][j] = ?????????0???i-1?????????????????????????????????, ???1???100?????????????¨?j????????£????????????????????¨??????500?????????-dp[i][j].first?????????????????£????????£????????????dp[i][j].second[???]??§?????????

void update(int id, int coin) {
	int mod1000 = p[id] % 1000;
	int mod500 = p[id] % 500;
	
	dp[id + 1][coin] = min(dp[id][coin], dp[id + 1][coin]);
	
	if (mod1000 == 0) {
		if (coin >= 500) {
			dp[id + 1][coin - 500] = min(dp[id + 1][coin - 500], Pair(dp[id][coin].first - 1, dp[id][coin].second + p[id]));
		}
	}
	else if (mod1000 <= 500) {
		dp[id + 1][coin + 500 - mod1000] = min(dp[id + 1][coin + 500 - mod1000], Pair(dp[id][coin].first - 1, dp[id][coin].second + p[id]));
	}
	else if (mod1000 <= 999) {
		dp[id + 1][coin + 1000 - mod1000] = min(dp[id + 1][coin + 1000 - mod1000], Pair(dp[id][coin].first, dp[id][coin].second + p[id]));
		if (coin >= mod1000 - 500) {
			dp[id + 1][coin - mod1000 + 500] = min(dp[id + 1][coin - mod1000 + 500], Pair(dp[id][coin].first - 1, dp[id][coin].second + p[id]));
		}
	}
}

int main() {
	while (cin >> n) {
		int i, j;
		
		if (!n) break;
		for (i = 0; i < n; i++) cin >> p[i];
		
		for (i = 0; i <= n; i++) for (j = 0; j < 500 * n; j++) dp[i][j] = Pair(1, 114514);	//Be careful!!
		dp[0][0] = Pair(0, 0);
		
		for (i = 0; i < n; i++) {
			for (j = 0; j < 500 * n; j++) {
				if (dp[i][j].first > 0) continue;	//Be careful!!
				update(i, j);
			}
		}
		
		Pair ans = Pair(0, 0);	//Be careful!!
		for (j = 0; j < 500 * n; j++) {
			ans = min(ans, dp[n][j]);
		}
		cout << -ans.first << " " << ans.second << endl;
	}
	return 0;
}

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

int main () {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a.at(i);
    }
    //差を求めていく
    int ans = 0;
    rep(i, n-1) {
        ans = max(ans, a.at(i+1) - a.at(i));
    }
    //0越え 円環は切って伸ばすのがいいらしい。
        ans = max(ans,a.at(0) + k - a.at(n-1));

    printf("%d\n",k - ans);
}

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

int gcd(int a, int b){
  int x = abs(a);
  int y = abs(b);
  int z = 0;
  
  try{
    if(x == 0 && y == 0){
      throw "gcd(0,0) is infinity.";
    }
  }
  catch(string s){
    cout << s << endl;
    return 1;
  }
  
  if(x >= y){
    if(y == 0){
      return x;
    }
    else{
      z = y;
      y = x % y;
      x = z;
      return gcd(x, y);
    }
  }
  else{
    if(x == 0){
      return y;
    }
    else{
      z = x;
      x = y % x;
      y = z;
      return gcd(x, y);
    }
  }
}
 
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int res = A % B;
  if(C % gcd(res, B) == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
  int n,l;
  cin>>n>>l;
  
  int ans=(l+(l+n-1))*n/2;
  
  if(l<=0&&0<=(l+n-1)){
  }
  else if(l>0){
    ans-=l;
  }
  else{
    ans-=(l+n-1);
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <functional>
#include <array>
#include <algorithm>

using namespace std;

int main() {

	int N = 0;
	int K;

	cin >> N >> K;

	int total = 0;

	vector<int> juice(N);

	for (int i = 0; i < N; i++)
	{
		cin >> juice.at(i);
	}

	sort(juice.begin(), juice.end());

	for (int j = 0; j < K; j++)
	{
		total = total + juice[j];
	}

	cout << total;

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define ff		first
#define sd      second
#define mod 	1000000007
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define inf 	1e18
#define vi          vector<int>
#define pb  	push_back
#define full(x) x.begin(), x.end()
#define int 	long long
#define pq 	priority_queue<int,int>
#define ford(i, a, b) for (int i=a; i<(b); i++)
#define foro(i, a) for (int i=0; i<(a); i++)
#define w(t)	int t; cin>>t; while(t--)

const int N = 1e5 + 5;



using namespace std;

#define IOS ios:: sync_with_stdio(0);cin.tie(0); cout.tie(0);


void abc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int pow(int n, int p, int md)
{
	int ans  = 1;

	while (p > 0)
	{
		int last = (p & 1);
		if (last == 1)
		{
			ans = (ans * n) % md ;
		}
		n = (n * n) % md;
		p = p >> 1;
	}

	return ans;
}
int x, y, GCD;
void ExtendedEuclid(int a, int b)
{
	if (b == 0)
	{
		y = 0;
		x = 1;
		GCD = a;
		return;
	}

	ExtendedEuclid(b, a % b);
	int cx = y;
	int cy = x - (a / b) * y;

	x = cx;
	y = cy;
}

int inv(int n, int md)
{
	ExtendedEuclid(n, md);
	return (x + md) % md;
}
int fact[2000005];
void facto()
{
	fact[0] = 1;
	fact[1] = 1;
	for (int i = 2; i <= 2000005; i++)
	{
		fact[i] = (i * fact[i - 1]) % mod ;
	}
}
int lucas(int a, int md)
{
	return pow(a, md - 2, md);
}

void solve()
{
	//Code here;
	int x;
	cin >> x;

	if (x >= 30)
	{
		cout << "Yes" << endl;
	} else
	{
		cout << "No" << endl;
	}


}
int32_t main()
{
	IOS;



	solve();


	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c){
    cout << "1" << endl;
  }
  if((a == b && b != c) || (a != b && b == c)){
    cout << "2" << endl;
  }
  if(a == c && a != b){
    cout << "2" << endl;
  }
  if(a != b && (b != c && a != c)){
    cout << "3" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
 
using namespace std;
 
typedef long long ll;
 
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }
 
namespace pb_ds {   
    namespace io {
        const int MaxBuff = 1 << 15;
        const int Output = 1 << 23;
        char B[MaxBuff], *S = B, *T = B;
        #define getc() ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T) ? 0 : *S++)
        char Out[Output], *iter = Out;
        inline void flush() {
            fwrite(Out, 1, iter - Out, stdout);
            iter = Out;
        }
    }
 
    template<class Type = int> inline Type read() {
        using namespace io;
        register char ch; register Type ans = 0; register bool neg = 0;
        while(ch = getc(), (ch < '0' || ch > '9') && ch != '-')     ;
        ch == '-' ? neg = 1 : ans = ch - '0';
        while(ch = getc(), '0' <= ch && ch <= '9') ans = ans * 10 + ch - '0';
        return neg ? -ans : ans;
    }
}
 
using namespace pb_ds;
 
void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}
 
const int N = 3e5 + 1e3;
 
int n, a[N];
 
ll pre[N], suf[N];
 
priority_queue<int> Max;
priority_queue<int, vector<int>, greater<int>> Min;
 
int main () {
 
	File();
 
	n = read();
	For (i, 1, n * 3) a[i] = read();
 
	For (i, 1, n)
		Min.push(a[i]), pre[i] = pre[i - 1] + a[i];
 
	For (i, n + 1, 2 * n) {
		pre[i] = pre[i - 1];
		if (a[i] > Min.top())
			pre[i] += a[i] - Min.top(), Min.pop(), Min.push(a[i]);
	}
 
	Fordown (i, n * 3, n * 2 + 1)
		Max.push(a[i]), suf[i] = suf[i + 1] + a[i];
 
	Fordown (i, n * 2, n + 1) {
		suf[i] = suf[i + 1];
		if (a[i] < Max.top())
			suf[i] += a[i] - Max.top(), Max.pop(), Max.push(a[i]);
	}
 
	ll ans = pre[n] - suf[n + 1];
	For (i, n, 2 * n)
		chkmax(ans, pre[i] - suf[i + 1]);
	printf ("%lld\n", ans);
 
	return 0;
}

Measured memory_bytes: 6648
n = int(input())
r = [0] * 200000
for i in range(n):
    r[i] = int(input())
#最大の利益はマイナスのこともあるため、初期値に十分マイナスの値を設定しておく
maxv = -2000000000
minv = r[0]

for j in range(1, n):
    #　現在のmaxvよりも大きな利益が出たら更新
    maxv = max(maxv, r[j] - minv)
    # 今よりも低い価格がでたらminvを更新する
    minv = min(minv, r[j])
print(maxv)


Measured memory_bytes: 13376
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
s = set()
s1 = set()
same_s = set()
ans = 0
for i in a:
    if i in s1:
        same_s.add(i)
    if i not in s:
        s1.add(i)
        ans +=1
        for j in range(10**6 // i + 1):
            s.add(j*i)
print(ans - len(same_s))

Measured memory_bytes: 88560
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <limits>
#include <sstream>
#include <typeinfo>

using namespace std;

//r[k][i] = (i 番目のホテルから 2k 日以内に到達可能な最右のホテル番号)
int r[18][100000];

int main() {
	int N;
	cin >> N;
	vector<int> x(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	int L;
	cin >> L;
	for (int i = 0; i < N; i++) {
		r[0][i] = (int)(upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1);
	}
	for (int k = 0; k < 17; k++) {
		for (int i = 0; i < N; i++) {
			r[k+1][i] = r[k][r[k][i]];
		}
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (a > b)
			swap(a, b);
		int ans = 0;
		for (int k = 17; k >= 0; k--) {
			if (r[k][a] < b) {
				ans += (1 << k);
				a = r[k][a];
			}
		}
		while (a < b) {
			ans ++;
			a = r[0][a];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 8192
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      s: chars,
    }

    let mut ans = 0;
    use std::char;
    for d1 in 0..10 {
        let d1 = char::from_digit(d1, 10).unwrap();
        for d2 in 0..10 {
            let d2 = char::from_digit(d2, 10).unwrap();
            let mut ok = vec![false; 10];
            let mut mode = 0;
            for i in 0..n {
                if mode == 0 {
                    if s[i] == d1 {
                        mode = 1;
                    }
                } else if mode == 1 {
                    if s[i] == d2 {
                        mode = 2;
                    }
                } else {
                    let d3 = s[i].to_digit(10).unwrap() as usize;
                    ok[d3] = true;
                }
            }

            for i in 0..10 {
                if ok[i] {
                    ans += 1;
                }
            }
        }
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352