akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define MAX 100

int n,c,k=0;
int pre[MAX],in[MAX],post[MAX];


int find(int x){
	int i;
	for(i=0;i<n;i++)if(x==in[i])return i;
	return 0;
}

void rec(int l,int r){
	int x,y;
	if(l >= r)return;
	
	x=pre[k++];
	y=find(x);
	rec(l,y);
	rec(y+1,r);
	post[c++]=x;
}

int main(void){
	int i;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&pre[i]);
	}
	
	for(i=0;i<n;i++){
		scanf("%d",&in[i]);
	}
	
	rec(0,n);
	
	for(i=0;i<n;i++){
		if(i != n-1)printf("%d ",post[i]);
		else printf("%d\n",post[i]);
	}
	return 0;
}


Measured memory_bytes: 2120
main = interact $ unlines . map (show . sum_of_prime_numbers . read) . (takeWhile (/="0")) . lines

sum_of_prime_numbers n = sum (take n primes)

primes = 2:3:[x | i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x]
 where isPrime n = null [i | i<-takeWhile (\x -> x*x <= n) primes, rem n i == 0]

Measured memory_bytes: 6948
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    LL a;
    LL b;
    LL n;

    cin >> a >> b >> n;
    LL tmp=n/b;
    tmp=tmp*b;
    LL ans0;
    if(tmp>0){
        ans0=(a*(tmp-1))/b-a*((tmp-1)/b);
    }else{
        ans0=0;
    }

    LL ans1=(a*n)/b-a*(n/b);
    if(ans0>ans1){
        cout << ans0 << endl;
    }else{
        cout << ans1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll long long
#define endl '\n'
#define pi 3.14159265
string s,t;
ll n,m;
ll dp[3001][3001];
ll f(ll i,ll j)
{
    if(i==n||j==m)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(s[i]==t[j])
        dp[i][j]=1+f(i+1,j+1);
    else
        dp[i][j]=max(f(i+1,j),f(i,j+1));
    return dp[i][j];
}
void p(ll i,ll j)
{
    if(i==n||j==m)
        return;
    if(s[i]==t[j])
    {
        cout<<s[i];
        p(i+1,j+1);
    }
    else
    {
        if(f(i+1,j)>f(i,j+1))
            p(i+1,j);
        else
            p(i,j+1);
    }
}
int main()
{
    IOS;
    cin>>s>>t;
    n=s.length();
    m=t.length();
    memset(dp,-1,sizeof(dp));
    p(0,0);
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

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

   int n;
   cin >> n;
   vector<int> d(3);
   rep(i, 0, 3) cin >> d[i];
   vector<P> q;
   rep(i, 0, n) {
      string s;
      cin >> s;
      int a, b;
      if (s == "AB") a = 0, b = 1;
      if (s == "AC") a = 0, b = 2;
      if (s == "BC") a = 1, b = 2;
      q.emplace_back(a, b);
   }
   string ans;
   auto add = [&](int a, int b) {
      d[a]++;
      d[b]--;
      ans += 'A' + a;
   };
   q.emplace_back(0, 1);
   rep(i, 0, n) {
      int a = q[i].first;
      int b = q[i].second;
      if (!d[a] && !d[b]) {
         cout << "No" << endl;
         return 0;
      }
      if (!d[a]) {
         add(a, b);
      } else if (!d[b]) {
         add(b, a);
      } else {
         int na = q[i + 1].first;
         int nb = q[i + 1].second;
         if (a == na || a == nb) {
            add(a, b);
         } else {
            add(b, a);
         }
      }
   }
   cout << "Yes" << endl;
   rep(i, 0, n) { cout << ans[i] << endl; }
   return 0;
}

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

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define sz(c) int(c.size())
#define clr(v, d)   memset(v, d, sizeof(v))
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF             INT64_MAX
#define NINF            INT64_MIN

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<pll> vll;
typedef vector<ll> vl;

string neg2base(ll num)
{
    string res="";
    while(num!=0)
    {
        ll rem=num%(-2);
        num=num/(-2);
        if(rem<0)
        {
            num++;
            rem+=1;
        }
        res=to_string(rem)+res;

    }
    return res;
}
int main()
{
    //    std::ios_base::sync_with_stdio(false);
    //    cin.tie(NULL);
    //    cout.tie(NULL);

    //    freopen("popcorn.in", "r", stdin);

    //    ll t;
    //    cin>>t;
    //    while(t--)
    //    {

    ll arr[5],k;
    cin>>arr[0]>>arr[1]>>arr[2]>>arr[3]>>arr[4]>>k;
    sort(arr,arr+5);
    if(arr[4]-arr[0]<=k)
        cout<<"Yay!"<<endl;
    else
        cout<<":("<<endl;
    return 0;
}


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

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

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

long long n, m;

long long gcd(long long a, long long b)
{
    return b ? gcd(b, a % b) : a;
}

int main()
{
    scanf("%lld %lld", &n, &m);

    long long num = gcd(n, m);

    cout << n / num * m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    int i=0;
    for(;i<n-1;){
        if(i+1<a[i+1]){
            i++;
        }else break;
    }
    int cnt=0;
    for(int j=0;j<n;j++){
        if(a[j]>i)cnt++;
    }
    if((cnt-i)%2&&(a[i]-i)%2){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
}

Measured memory_bytes: 640
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 1000000007;

#define M 1000000007


// 入力

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

    vector<ll> lower(H+1, LLONG_MAX);

    for (ll i = 0; i < n; ++i) cin >> a[i] >> b[i];

    lower[0] = 0;
    for (ll h = 0; h <= H; ++h) {
        for (ll i = 0; i < n; ++ i) {
            if (h >= a[i]) {
                if (lower[h - a[i]] != LLONG_MAX) {
                    lower[h] = min(lower[h], lower[h-a[i]] + b[i]);
                }
            }
        }
    }

    ll ans = lower[H];
    for (ll i = 0; i < n; ++i) {
        for (ll j = 0; j < a[i]; ++ j) {
            if (lower[H-j] == LLONG_MAX) continue;
            ans = min(ans, lower[H-j]+b[i]);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int k, x;
  cin >> k >> x;
  for (int i = x - k + 1; i < x + k; i++) {
    if (i < -1000000 || 1000000 < i) continue;
    cout << i << flush;
    if (i == x + k)
      cout << endl;
    else
      cout << " " << flush;
  }
  return 0;
}

Measured memory_bytes: 256
/*  ex3_3
    hangan2020 */

#include <stdio.h>
int main(void){
    int number, base, digit_num;
    digit_num = 0;
    /*Reading number and base*/
    scanf("%d %d", &number, &base);
   /*Calculate number of digits*/
    while ( number > 0 ){
        number = number / base;
        digit_num = digit_num + 1; 
    }
    printf("%d", digit_num);
    return 0;
}


Measured memory_bytes: 128
n, m, x = list(map(int, input().split()))
c = [0] * n
a = [[]  for _ in range(n)]
INF = float('inf')
ans = INF

for i in range(n):
    line = list(map(int, input().split()))
    c[i] = line[0]
    a[i] = line[1:]

for s in range(1<<n):
    smart = [0] * m
    cost = 0
    for i in range(n):
        if not(s>>i & 1):continue
        cost += c[i]
        for j in range(m):
            smart[j] += a[i][j]

    flg = True
    for i in range(m):
        if smart[i] < x:
            flg = False
    if flg:
        ans = min(ans, cost)
if ans == INF:
    print(-1)
else: print(ans)


Measured memory_bytes: 9128
#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>;

int main(){
    int a;
    cin >> a;
    int ans;
    ans=a+a*a+a*a*a;
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<climits>
#include<vector>
using namespace std;
int frog(vector<int> h,int n){
    vector<int> dp(n+1);
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        int op1=abs(h[i]-h[i-1])+dp[i-1];
        int op2=abs(h[i]-h[i-2])+dp[i-2];
        dp[i]=min(op1,op2);
    }
    return dp[n];
}
int main(){
    int n;
    cin>>n;
    vector<int> h(n+1);
    for(int i=1;i<=n;++i){
        cin>>h[i];
    }
    int f=frog(h,n);
    cout<<f<<endl;
}


Measured memory_bytes: 4552
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
typedef long long ll;
using namespace std;

bool key(int start, string str) {
    if (str == "keyence") {
        return true;
    }
    for (int i = 1; i < str.size() - start; i++) {
        string tmp = str.substr(0, start) + str.substr(start+i);
        if (tmp == "keyence") {
            return true;
        }
    }
    return false;
}

int main() {
    
    string s; cin >> s;
    string keyence = "keyence";
    bool first = true;
    for (int i = 0; i < s.size(); i++) {
        if (first) {
            if (s[i]==keyence[i]) {
                if (i == keyence.size()-1) {
                    cout << "YES" << endl;
                    return 0;
                }
                continue;
            } else {
                first = false;
            }
        }
        if (key(i, s)) {
            cout << "YES" << endl;
            return 0;
        }
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    return 0;
}


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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

void solve () {
	ll n, d, x, y, cnt = 0;
	cin >> n >> d;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		if (x * x + y * y <= d * d) cnt++;
	}
	cout << cnt << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
  #endif
	int t = 1;
	while (t--) {
		solve();
	}
 	return 0;
}

Measured memory_bytes: 3660
s = input()

if len(s) >= 4 and len(s) <= 10 and s[0]=="A" and s[2:-1].count("C")==1:
    try:
        ss = list(s[2:-1])
        ss.remove("C")
        ss += s[-1]
        if s[1].islower() and ''.join(ss).islower():
            print("AC")
        else:
            print("WA")
    except:
        print("WA")
else:
    print("WA")


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    double l;
    cin>>l;

    printf("%.10f\n",l*l*l/27);

    return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/abc123_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

ll N;
ll A[5];

void solve() {
  cin >> N;
  ll min_ = 100000000000000000;
  loop(n,0,5) {
    cin >> A[n];
    chmin(min_, A[n]);
  }
  cout << (ll)ceil(N/(double)min_) + 4 << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
using lint = long long int;

int main()
{
	int N;
	cin >> N;

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

	int* ordered = new int[N];
	memcpy(ordered, p, sizeof(int)*N);
	sort(ordered, ordered + N);

	int diffCount = 0;
	for (int i = 0; i < N; i++) {
		if (p[i] != ordered[i]) {
			diffCount++;
		}
	}
	if (diffCount <= 2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	delete[] p;
	p = nullptr;
	return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#endif

#ifdef _DEBUG
void init_global_B() {}
#else

#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    int M = 40000; // >= sqrt(1e9)
    
    int ans = 1;
    REP(i, M) {
        if (i*i > N) {
            ans = (i - 1)*(i - 1);
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)
int D, N;

int main()
{
	cin >> D >> N;
	if (D == 0) {
		if (N == 100) cout << 101 << endl;
		else cout << N << endl;
	} else if (D == 1) {
		if (N == 100) cout << 10100 << endl;
		else cout << N * 100 << endl;
	} else {
		if (N == 100) cout << 1010000 << endl;
		else cout << N * 10000 << endl;
	}
	return 0;
}

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

typedef long long ll;

int vecmax(vector<int> vec){
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    return vec.at(0);
}

int gcd(int a, int b){
    if(a<b){
        swap(a,b);
    }
    int r=0;
    while(a%b>0){
        r=a%b;
        a=b;
        b=r;
    }
    return b;
}

map<int,int> L;
map<int,int> R;


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

    L[1]=A.at(0);
    R[1]=A.at(N-1);
    

    int memory=0;

    for(int i=2;i<N;i++){
        L[i]=gcd(L[i-1],A.at(i-1));
        
        if(L[i]==1){
            memory=i;
            break;
        }
    }
    if(memory>0){
        for(int i=memory;i<N;i++){
            L[i]=1;
        }
    }

    int memo=0;
    for(int i=2;i<N;i++){
        R[i]=gcd(R[i-1],A.at(N-i));

        if(R[i]==1){
            memo=i;
            break;
        }
    }
    if(memo>0){
        for(int i=memo;i<N;i++){
            R[i]=1;
        }
    }

    L[0]=R[N-1];
    R[0]=L[N-1];
    int ans=1;
    for(int i=0;i<N;i++){
        if(ans<gcd(L[i],R[N-i-1])){
            ans=gcd(L[i],R[N-i-1]);
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 9984
#include <stdio.h>

int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if(A==B && B==C){
    printf("No\n");
  }else if(A==B || B==C || C==A){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1648
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int x, y, ptr;
    
    while (1) {
        scanf("%d %d", &x, &y);
        if (x==0 && y==0) break;
        if (x>y) {
            ptr = x;
            x = y;
            y = ptr;
        }
        printf("%d %d\n", x, y);
    }
    
    return 0;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","w",stdout);
    //FILE *fptr2=freopen("out.txt","w",stdout);
    
    
    int x;
    cin>>x;
    
    if(x>=30) cout<< "Yes";
    else cout<< "No";
    

    return 0;
}


Measured memory_bytes: 3632
#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 namespace std; 

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

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

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> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";} 
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    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 n;
    cin >> n;

    ll d;
    cin >> d;
    d *= d;
    
    int ans = 0;
    irep(i, n) {
        ll x, y;
        cin >> x >> y;
        if((x*x+y*y) <= d) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

/*atcoder*/



Measured memory_bytes: 3620
import itertools
n = int(input())
L = list(map(int,input().split()))
L.sort()
answer=0
for ls in itertools.combinations(L, 3):
    if (ls[0]+ls[1]>ls[2]) and (ls[0]!=ls[1]and ls[1]!=ls[2]):
        answer +=1
print(answer)

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

int main() {
  int n;
  cin>>n;
  vector<vector<int>> a(n,vector<int>(2));
  vector<vector<int>> b(n,vector<int>(2));
  for(int i=0;i<n;i++){
    cin>>a.at(i).at(0);
    cin>>a.at(i).at(1);
  }
  for(int i=0;i<n;i++){
    cin>>b.at(i).at(0);
    cin>>b.at(i).at(1);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  int ans=0;
  for(int i=0;i<n;i++){
    int p=-1;
    int cur=-1;
    for(int j=0;j<n;j++){
      if(a.at(j).at(0)<b.at(i).at(0)){
        if(a.at(j).at(1)<b.at(i).at(1)){
          if(cur<a.at(j).at(1)){
            p=j;
            cur=a.at(j).at(1);
          }
        }
      }
      else{
        break;
      }
    }
    if(p!=-1){
      ans++;
      a.at(p).at(1)=114514;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
//using lli = __int128;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using vqi = vector<qi>;
using pqi = priority_queue<li>;
using pi = pair<li, li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li, li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = LLONG_MAX;
constexpr li mod = 1000000007;

void Yes(li b) {
	if (b)cout << "Yes";
	else cout << "No";
}
void yes(li b) {
	if (b)cout << "yes";
	else cout << "no";
}

/* //__int128用
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}
*/


double ev(li a) {
	return (a + 1) / 2.0;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout.precision(16);

	li N, K;
	cin >> N >> K;

	vi p(N);

	Input(p);

	double e=0;

	Rep(i,K){
		e+=ev(p[i]);
	}

	double maxe=e;

	Rep(i,N-K){
		e -= ev(p[i]);
		e += ev(p[i+K]);
		maxe=max(maxe,e);
	}

	cout<<maxe;




}

Measured memory_bytes: 4792
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dp[201010][2];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<string>s(n);
	ll ans = 0;
	ll b = 0;
	ll a = 0;
	ll c = 0;
	rep(i, n) {
		cin >> s[i];
		ll k = s[i].length();
		rep(j, k-1) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B')ans++;
		}
		if (s[i][0] == 'B')b++;
		if (s[i][k - 1] == 'A')a++;
		if (s[i][0] == 'B' && s[i][k - 1] == 'A')c++;
	}
	ll res = min(a, b);
	ans += res;
	if (a == b && b == c&&a!=0)ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    int N,D,X;
    cin >> N >> D >> X;
    int ans = X;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        for(int i=0; i*tmp+1 <= D; i++) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	int n; cin >> n;
	long long ans = 0;
	int pos = n;
	for (int i = 1; i <= n; i++) {
		while (1ll * i * pos >= n) pos--;
		ans += pos;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3568
s = input()
t = input()

d = {x: 0 for x in "abcdefghijklmnopqrstuvwxyz"}
e = {x: 0 for x in "abcdefghijklmnopqrstuvwxyz"}

for i in range(len(s)):
    if d[s[i]] == 0 and e[t[i]] == 0:
        d[s[i]] = t[i]
        e[t[i]] = s[i]
    else:
        if d[s[i]] != t[i] or e[t[i]] != s[i]:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 41840
use std::io;


/// https://beta.atcoder.jp/contests/abc062/tasks/abc062_b
fn main() {
    let (h, w) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut vec = Vec::new();
    let template = vec!['#'; w + 2];
    vec.push(template.clone());
    for _ in 0..h {
        let mut i = read_one::<String>().chars().collect::<Vec<char>>();
        i.push('#');
        i.insert(0, '#');
        vec.push(i);
    }
    vec.push(template.clone());
    for v in vec {
        for c in v {
            print!("{}", c);
        }
        println!();
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

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

    //good luck kittu!
    string s; int t, n;
    cin>>s>>t;
    n = s.size();

    deque<char> q;
    for(int i = 0; i<n; i++) q.push_back(s[i]);
    int r = 0, type, p;
    char c;
    
    while(t--){
        cin>>type;
        if(type==1) r = (r+1)%2;
        else{
            cin>>p>>c;
            if(r){
                if(p==1) q.push_back(c);
                else q.push_front(c);
            }
            else{
                if(p==1) q.push_front(c);
                else q.push_back(c);
            }
        }
    }

    if(!r){
        while(!q.empty()){
            cout<<q.front();
            q.pop_front();
        }
    }
    else{
        while(!q.empty()){
            cout<<q.back();
            q.pop_back();
        }
    }
    return 0;
}

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

N, K = map(int, input().split())

MOD = 998244353

I = [tuple(map(int, input().split())) for _ in range(K)]

class SegmentTreeDual():
    def __init__(self, arr, op=lambda x, y: y if y != -1 else x, ie=-1):
        self.h = (len(arr) - 1).bit_length()
        self.n = 2**self.h
        self.ie = ie
        self.op = op
        self.val = [ie for _ in range(self.n)]
        self.laz = [ie for _ in range(2 * self.n)]
        for i in range(len(arr)):
            self.val[i] = arr[i]

    def propagate(self, k):
        if self.laz[k] == self.ie: return
        if self.n <= k:
            self.val[k - self.n] = self.op(self.val[k - self.n], self.laz[k])
        else:
            self.laz[2 * k] = self.op(self.laz[2 * k], self.laz[k])
            self.laz[2 * k + 1] = self.op(self.laz[2 * k + 1], self.laz[k])
        self.laz[k] = self.ie

    def update(self, lt, rt, x):
        lt += self.n
        rt += self.n
        while rt - lt > 0:
            if lt & 1:
                self.laz[lt] = self.op(self.laz[lt], x)
                self.laz[lt] %= MOD
                lt += 1
            if rt & 1:
                rt -= 1
                self.laz[rt] = self.op(self.laz[rt], x)
                self.laz[rt] %= MOD
            lt >>= 1
            rt >>= 1

    def get(self, idx):
        res = self.val[idx]
        idx += self.n
        while idx:
            res = self.op(res, self.laz[idx])
            res %= MOD
            idx >>= 1
        return res

from operator import add

arr = [0] * N
arr[0] = 1

S = SegmentTreeDual(arr, add, 0)

for i in range(N - 1):
    s = S.get(i)
    for l, r in I:
        S.update(min(i + l, N), min(i + r + 1, N), s)

print(S.get(N - 1) % MOD)

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

int W, H, T, P;
int hiryou[55][55];
bool plant[55][55];
int ans = 0;
signed main()
{
  cin >> W >> H >> T >> P;
  for(int i = 0; i < P; i++){
    int x, y, t;
    cin >> x >> y >> t;
    hiryou[y][x]++;
  }
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> plant[i][j];
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      ans += hiryou[i][j] * plant[i][j];
    }
  }

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

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

const long long INF = 1LL << 61;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)cin >> A[i];

    unordered_map<int, int> mp;

    for (int i = 0; i < N; i++) {
        if (mp[A[i]] == 0)mp[A[i]]++;
        else {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

}

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

const int maxn=(int)1e5+10;
const int inf=(int)1e9+696969;
int h[maxn];
int dp[maxn];

int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	dp[1]=0; dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
	{
		int mini=inf;
		for(int j=i-1;j>=max(1,i-k);j--)
			mini=min(mini,dp[j]+abs(h[i]-h[j]));
		dp[i]=mini;
	}
	printf("%d\n",dp[n]);
}

Measured memory_bytes: 1024
namespace NF64
{
	public static class AOJ
	{
		public static void Main(string[] args)
		{
			var i = System.Console.ReadLine().Split();
			var a = int.Parse(i[0]);
			var b = int.Parse(i[1]);
			var s = "a == b";
			if (a < b)
				s = "a < b";
			else if (a > b)
				s = "a > b";
			System.Console.WriteLine(s);
		}
	}
}

Measured memory_bytes: 9020
#include<iostream>
using namespace std;
int main(){
int a,b,n,x,y;
while(1){
cin>>a>>b;
if(a==0)break;
int route[a+1][b+1];
cin>>n;
for(int i=1;i<=a;i++){
    for(int j=1;j<=b;j++){
        route[i][j]=0;
    }
}
for(int i=0;i<n;i++){
cin>>x>>y;
route[x][y]=-1;
}

route[1][1]=1;
for(int i=1;i<=a;i++){
for(int j=1;j<=b;j++){
if(route[i][j]==-1){
route[i][j]=0;
}else{
if(i>1) route[i][j]+=route[i-1][j];
if(j>1) route[i][j]+=route[i][j-1];
}



}
}


cout<<route[a][b]<<endl;

}
return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll n,s=0; cin>>n;
  ll a[n]; for(int i=0;i<n;++i) { cin>>a[i]; s+=a[i]; }
  ll x1=s/n , x2 = s/n + 1;
  s=0;
  ll s2=0;
  for(int i=0;i<n;++i) {
  	s += (a[i]-x1)*(a[i]-x1);
    s2 += (a[i]-x2)*(a[i]-x2);
  }
    cout << min(s,s2);
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    string S, T;
    cin >> S;
    cout << string (S.length(), 'x') << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b,c,d = LI()
if a <= c <= b:
    if b < d:
        print(b-c)
    else:
        print(d-c)
elif c <= a <= d:
    if b < d:
        print(b-a)
    else:
        print(d-a)
else:
    print(0)


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

int n,dis[500*500+5];
bool on[500*500+5];

inline int getR(const int &x){
    return (x-1)/n+1;
}

inline int getC(const int &x){
    return (x-1)%n+1;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    memset(on,1,sizeof(on));
    cin>>n;
    int mov[]={-n,1,n,-1};
    for(int i=1;i<=n*n;i++){
        dis[i]=min({getR(i)-1,n-getR(i),getC(i)-1,n-getC(i)});
    }
    int ans=0;
    for(int i=1;i<=n*n;i++){
        int cur;
        cin>>cur;
        ans+=dis[cur];
        on[cur]=0;
        deque<int> q;
        q.push_back(cur);
        while(!q.empty()){
            int x=q.front();
            q.pop_front();
            for(int dir=0;dir<4;dir++){
                int y=mov[dir]+x;
                if(y>0&&y<=n*n&&dis[y]>dis[x]+on[x]){
                    dis[y]=dis[x]+on[x];
                    if(on[x])q.push_back(y);
                    else q.push_front(y);
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;



#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}



int main(){

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

    int n, y;

    cin >> n >> y;

    int i, j;
    int sum;
    for(i = 0; i <= n; ++i){
        for(j = 0; j <= n; ++j){
            if(i*5000 + j*1000 + (n-i-j)*10000 == y && (n-i-j)>=0){
                cout << n-i-j << sp << i << sp << j << endl;
                return 0;
            }

        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
template<class T> int gmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class T> int gmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
using namespace std;

int main() {
    int n, d;
    while(~scanf("%d %d", &n, &d)) {
        printf("%d\n", (int)ceil(n*1.0 / (2 * d + 1)));
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
int main() {
	std::string  c;
	std::cin >> c;
	if (c == "a") {
		std::cout << "vowel" << std::endl;
	}
	else if (c == "i") {
		std::cout << "vowel" << std::endl;
	}
	else if (c == "u") {
		std::cout << "vowel" << std::endl;
	}
	else if (c == "e") {
		std::cout << "vowel" << std::endl;
	}
	else if (c == "o") {
		std::cout << "vowel" << std::endl;
	}
	else {
		std::cout << "consonant" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

typedef long long ll;

int main()
{
    ll n;
    cin>>n;
    if(n%1000==0)
    cout<<0;
    else
    cout<<1000-n%1000;

    return 0;
}


Measured memory_bytes: 3632
from sys import stdin

input = stdin.readline


MOD = 10**9 + 7



def solve():
    N = int(input())
    point = [tuple(map(int,inp.split())) for inp in stdin.read().splitlines()]
    pa = max(point,key = lambda x: x[0] + x[1])
    pb = min(point,key = lambda x: x[0] + x[1])
    pc = max(point,key = lambda x: x[0] - x[1])
    pd = min(point,key = lambda x: x[0] - x[1])
    r1 = pa[0] + pa[1] - pb[0] - pb[1]
    r2 = pc[0] - pc[1] + pd[1] - pd[0]
    print(max(r1,r2))
if __name__ == '__main__':
    solve()


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


int main()
{
	int n, k; cin >> n >> k;
	int p[n];
	for (int i = 0; i < n; ++i)
		cin >> p[i];
	sort(p, p+n);
	int c = 0;
	for (int i = 0; i < k; ++i)
		c += p[i];
	cout << c << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <random>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b; cin >> a >> b;
	cout << a/b+a%b << endl;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int64_t> H(100010);

	for(int i = 0; i < N; i++) cin >> H[i];

	if(N == 1)
	{
		cout << "Yes" << endl;
		return 0;
	}

	int64_t max = 0;
	for(int i = 0; i < N; i++)
	{
		if(max < H[i]) max = H[i];
		else if(max - H[i] >= 2)
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define STR_LENGTH (6)
int main(int argc, char* argv[])
{
	//ABC160 A
	char s[STR_LENGTH + 1];

	//S coffee
	scanf("%s", &s);
	
	if (s[2] != s[3]) {
		printf("No");
		return 0;
	}

	if (s[4] != s[5]) {
		printf("No");
		return 0;
	}

	printf("Yes");

	return 0;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int M = 0;
  
  for(int i = 0; i < K; i++){
    if(i < A){
      M++;
    }
    else if(i >= A + B){
      M--;
    }
    else{
    }
  }
  
  cout << M << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
ll const MOD=1000000007;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(ALL(a));
    auto itr=upper_bound(ALL(a),a[a.size()-1]/2.0);
    int m;
    if(abs(a[a.size()-1]/2.0-*itr)<abs(a[a.size()-1]/2.0-*(itr-1))){
        m=*itr;
    }
    else m=*(itr-1);
    cout<<a[a.size()-1]<<" "<<m<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define f first
#define s second
#define mp make_pair

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using treap = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin>>x;
  cout<<(!x)<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

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

  int ans = 0;  
  for(int i = 0; i < n - 1; i++) {
    int cnt = 0;
    int j = 0;
    while(a[i] == a[i + j]) {
      cnt++;
      j++;
    }

    i += cnt - 1;
    ans += cnt / 2;
  }

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

Measured memory_bytes: 256
H, W = gets.chomp.split(" ").map(&:to_i)
C = []
10.times{
  C << gets.chomp.split(" ").map(&:to_i)
}
A = Hash.new{|h, k| h[k] = 0}
H.times{
  gets.chomp.split(" ").map(&:to_i).each{|a| A[a] += 1}
}

wk = (0..9).to_a.map{|i|
  dp = Array.new(10, 10**3)
  bef = [i]
  dp[i] = 0
  until bef.empty? do
    nxt = []
    bef.each{|j|
      (0..9).each{|k|
        if dp[k] > C[j][k] + dp[j] then
          dp[k] = C[j][k] + dp[j]
          nxt << k
        end
      }
    }
    bef = nxt.uniq
  end
  dp[1]
}

puts A.inject(0){|r, (k, v)| r + (k == -1 ? 0 : wk[k] * v)}


Measured memory_bytes: 2428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		
		int k = Integer.parseInt(sc.next());
		
		char [][]c = new char [h][w];
		
		for(int i = 0 ; i < h ;i++) {
			String s = sc.next();
			for(int j = 0 ; j < w ;j++) {
				c[i][j] = s.charAt(j);
				
			}
		}
		
		int ans = 1000000000;
		//切れ目となりうる数はh-1箇所
		for(int i = 0 ; i < (1 << h-1) ;i++) {
			
			int gnum = 0; 	// 横に区切ることでできるチョコの枚数
			int [] d = new int [h]; 	//列ごとでどのグループに属するか
			
			for(int j = 0 ; j < h -1 ; j++) {
				if((i >> j & 1) == 1 ) {
					d[j+1] = d[j] + 1;	//切れ目が存在するとき
					gnum++;
				}
				else {
					d[j+1] = d[j];	//切れ目が存在しないとき
				}
			}
			
			int wcut = 0; //縦方向にいくつ切れ目を入れるか
			boolean jdg = true;	//そもそも適切に切ることができるのかどうか
			int []num = new int [gnum+1]; //グループにいくつ白チョコがあるか
			
			for(int j = 0 ; j < w ; j++) {
				boolean ok = true; 	//j行目を区切る必要があるかのチェック
				int []can = new int [gnum+1]; 	//一列につきk個以上の白チョコがあるか
				for(int l = 0 ; l < h ; l++) {
					num[d[l]] += c[l][j] - '0';
					can[d[l]] += c[l][j] - '0';
					if(num[d[l]] > k) {
						ok = false;
					}
					if(can[d[l]] > k) {
						jdg = false;
					}
				}
				if(!ok) {
					wcut++;
					num = can; //j行目でk個を超えたのでj-1とj行の間で切る。
							   //新しいグループとしてj行目以降から始める
							
				}
			}
			if(jdg) {
				ans = Math.min(ans, gnum + wcut);		
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 39884
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int>n(3);
  cin>>n[0]>>n[1]>>n[2];
  sort(n.begin(),n.end());
  cout<<((n[1]-n[0])%2?n[2]-n[1]+(n[1]-n[0])/2+2:n[2]-n[1]+(n[1]-n[0])/2)<<endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  stack<char> stk;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(') {
      stk.push(s[i]);
    } else {
      if (stk.size() && stk.top() == '(') stk.pop();
      else stk.push(s[i]);
    }
  }
  while (stk.size()) {
    char tmp = stk.top();
    stk.pop();
    if (tmp == '(') {
      s.push_back(')');
    } else {
      s = "(" + s;
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char str[1001];
	int i;
	
	fgets(str, 1000, stdin);
	
	i = 0;
	while (str[i] != '\0'){
		if (str[i] <= 'z' && str[i] >= 'a'){
			str[i] -= ('a' - 'A');
		}
		i++;
	}
	
	printf("%s", str);
	
	return (0);
}

Measured memory_bytes: 940
//24
#include<iostream>
#include<algorithm>
#include<iomanip>

using namespace std;

struct L{
  int y,l,r,f;
  bool operator<(L a)const{
    return y<a.y;
  }
};

int main(){
  int cs=0;
  for(int n;cin>>n,n;){
    L l[200];
    for(int i=0;i<n;i++){
      double x,y,r;
      cin>>x>>y>>r;
      L &a=l[2*i],&b=l[2*i+1];
      a.l=b.l=(x-r)*100+.5+20000;
      a.r=b.r=(x+r)*100+.5+20000;
      a.y=(y-r)*100+.5+20000;
      b.y=(y+r)*100+.5+20000;
      a.f=1;
      b.f=-1;
    }
    sort(l,l+n*2);
    int c[60001]={};
    unsigned sum=0;
    for(int i=0;i<2*n-1;i++){
      for(int j=l[i].l;j<l[i].r;j++){
	c[j]+=l[i].f;
      }
      int h=l[i+1].y-l[i].y;
      sum+=(60001-count(c,c+60001,0U))*h;
    }
    cout.precision(2);
    cout<<++cs<<' '<<fixed<<sum/10000.<<endl;
  }
  return 0;
}
      

Measured memory_bytes: 1548