akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;

//const ll nmax=100001;
const ll inf=1000000000+7;
const ll smax=100000;
ll dp[smax+1][4];

int main(){
    ll m1,m2;
    string abc="ABC";
    string s;
    cin>>s;
    dp[0][0]=1;

    //for(ll j=0;j<=3;j++){
    //    for(ll i=1;i<=s.length();i++){

    for(ll i=1;i<=s.length();i++){
        for(ll j=0;j<=3;j++){

            if(s[i-1]=='?')m1=3ll;
            else m1=1ll;
            if(s[i-1]==abc[j-1]||s[i-1]=='?') m2=1ll;
            else m2=0ll;

            //cout<<"i:"<<i<<", j:"<<j<<", m1:"<<m1<<", m2:"<<m2<<endl;

            if(j==0) dp[i][j]=dp[i-1][j]*m1;
            else dp[i][j]=m1*dp[i-1][j]+m2*dp[i-1][j-1];
            dp[i][j]%=inf;
        }
    }
    cout<<dp[s.length()][3]%inf<<endl;
    /*for(ll i=0;i<=s.length();i++){
        for(ll j=0;j<=3;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    return 0;
}


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

signed main(){
    int n;
    string s;
    cin>>n>>s;
    int a=0,maxa=0;
    for(int i=0;i<n;i++){
        if(s[i]==')'){
            a++;
        }
        else a--;
        if(maxa<a)maxa=a;
    }
   // cerr<<a<<' '<<maxa;
   for(int i=0;i<maxa;i++){
        cout <<'(';
       
    }
    cout<< s;
    for(int i=0;i<maxa-a;i++){
        cout << ')';
       
    }
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  int a[n];
  double sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  sum/=n;
  double diff=1e5;
  int ans=-1;
  rep(i,n){
    if(diff>abs(sum-a[i])){
      diff=abs(sum-a[i]);
      ans=i;
    }
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 256
MOD = 1000000007

N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))

dp = [[0 for j in range(M+1)] for i in range(N+1)]
for i in range(N+1):
    dp[i][0] = 1
for j in range(M+1):
    dp[0][j] = 1

for i in range(N):
    for j in range(M):
        if S[i] == T[j]:
            dp[i+1][j+1] = dp[i+1][j]+dp[i][j+1]
        else:
            dp[i+1][j+1] = dp[i+1][j]+dp[i][j+1]-dp[i][j]
        dp[i+1][j+1] %= MOD

print(dp[-1][-1])

Measured memory_bytes: 74332
n = int(input())
s = input()
x = [0] * n

def pcnt(x):
    return bin(x).count('1')

def f(x):
    if x == 0: return 0
    return f(x % pcnt(x)) + 1

for i in range(n):
    x[i] = int(s[i])

pc = sum(x)
ans = [0] * n
for b in range(2):
    npc = pc
    if b == 0:
        npc += 1
    else:
        npc -= 1

    if npc <= 0: continue

    r0 = 0
    for i in range(n):
        r0 = (r0 * 2) % npc
        r0 += x[i]

    k = 1
    for i in range(n - 1, -1, -1):
        if x[i] == b:
            r = r0
            if b == 0:
                r = (r + k) % npc
            else:
                r = (r - k + npc) % npc
            ans[i] = f(r) + 1
        k = (k * 2) % npc

for i in ans:
    print(i)

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

int main() {
    
    int n;
    cin >> n;
    int count = 0;
    for (int i = 0; i < n; i++) {
        int d1;
        int d2;
        cin >> d1 >> d2;
        if (d1 == d2) {
            count++;
        } else {
            count = 0;
        }
        if (count == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX+1];

void maxHeapify(int i){
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i){
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main(){
  cin >> H;

  for(int i=1; i <= H; i++) cin >> A[i];

  for(int i=H / 2; i >= 1; i--) maxHeapify(i);

  for(int i=1; i <= H; i++){
    cout << " " << A[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 4968
def count(l):
    odd = {}
    even = {}
    for idx, d in enumerate(l):
        if idx%2 == 0:
            res = even
        else:
            res = odd
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return odd, even
n = int(input())
data = list(map(int, input().split()))
odd, even = count(data)
odd = sorted(odd.items(), key=lambda x:-x[1])
even = sorted(even.items(), key=lambda x:-x[1])
if len(odd) == 1 and len(even) == 1:
    if odd[0][0] != even[0][0]:
        print(0)
    else:
        print(min(odd[0][1], even[0][1]))
else:
    size = n//2
    if odd[0][0] != even[0][0]:
        ans = 2*size - odd[0][1] - even[0][1]
        print(ans)
    else:
        ans1 = 2*size - odd[0][1] - even[1][1]
        ans2 = 2*size - odd[1][1] - even[0][1]
        print(min(ans1, ans2))

Measured memory_bytes: 17652
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p, s;
    cin >> n >> k >> s;
    vector <ll> v;
    for(i = 1; i <= n; i++){
        if(k == 0){
            if(s == 1000000000){
                v.pb(1);
            }
            else{
                v.pb(s+1);
            }
            continue;
        }
        if(i <= k){
            v.pb(s);
        }
        else{
            if(s != 1000000000){
                v.pb(s+1);
            }
            else{
                v.pb(1);
            }
        }
    }
    for(auto i : v){
        cout << i << " ";
    }

    return 0;
}


Measured memory_bytes: 2292
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <unordered_map>
#define debug(x) cout << #x << "==" << x << endl;

using namespace std;

const int INF = 1e+8;

//??\???
#define MAX_N 50000
#define MAX_M 20
int N;
int M;
int C[MAX_M];

// dp ????????????
unordered_map<int,int> dp;


int least_coins(int s) {

  if(s < 0) { return INF; }     // checked ??§ out of bounds ??????????????????!!
  if(s == 0) { return 0; }

  if( dp.count(s) == 1 ) { return dp[s]; }

  int mn = INF;
  for(int i = 0; i < M; i++) {
    mn = min( mn, least_coins( s - C[i] ) + 1 );
  }


  return dp[s] = mn;

}

int main() {
  ios::sync_with_stdio(false);

  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> C[i];
  }

  cout << least_coins(N) << endl;

  return 0;
}

Measured memory_bytes: 7292
// Bismillahirrahmanirrahim
// by Batrrr Tolkynbayev
#include <bits/stdc++.h>
// skripi krasava
#define respa return 0
#define all(x) x.begin(), x.end()
#define sz size
#define pb push_back
#define eb emplace_back
#define forn(i, x, n) for(int i = x; i <= n; ++i)
#define forr(i, n, x) for(int i = n; i >= x; --i)

using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 2e5 + 17, M = N << 2, mod = 1e9 + 7; 

int tt = 1, n, a[N], odd;

void solve () {
	cin >> n;
	forn(i, 1, n) {
		cin >> a[i]; 
		odd += (a[i] & 1);
	}
	if (!(odd & 1)) cout << "YES";
	else cout << "NO";
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// cin >> tt;
	while (tt--) solve();
	respa;
}

Measured memory_bytes: 4024
#include<stdio.h>
int main(void){
	int i=0;
	char s[1001]={0};
	scanf("%s",s);
	while(s[i]!='\0'){
		if(s[i]>=68){printf("%c",s[i]-3);}
		else{printf("%c",s[i]+23);}
		i+=1;
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2060
#!/usr/bin/env python3
import sys


def solve(S: int, K: int):
    for i in range(K):
        c = S[i]
        if c != '1':
            print(c)
            return
    print(1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(S, K)

if __name__ == '__main__':
    main()


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

int main(){
   int N;
   std::cin >> N;
   std::vector<int> a(N);
   for (int i=0; i<N; i++){
      std::cin >> a.at(i);
   }
   long long int sum = 0;
   for (int i=0; i<N; i++){
      sum = sum + a.at(i)-1;
   }
   std::cout << sum << std::endl;
}



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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;

    vector<unsigned long> A(N), B(N);
    for(unsigned long i{0}, a, b; i < N; ++i){
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
    }

    if(N & 1){
        nth_element(begin(A), begin(A) + N / 2, end(A));
        nth_element(begin(B), begin(B) + N / 2, end(B));
        cout << B[N / 2] - A[N / 2] + 1 << endl;
    }else{
        nth_element(begin(A), begin(A) + N / 2, end(A));
        nth_element(begin(B), begin(B) + N / 2, end(B));
        nth_element(begin(A), begin(A) + N / 2 - 1, begin(A) + N / 2);
        nth_element(begin(B), begin(B) + N / 2 - 1, begin(B) + N / 2);
        cout << B[N / 2 - 1] + B[N / 2] - A[N / 2 - 1] - A[N / 2] + 1 << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

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

int main()
{
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	ll LCM = 1;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		a[i] /= 2;
		LCM = lcm(LCM, a[i]);
		if (LCM > m)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		if ((LCM / a[i]) % 2 == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	if ((m / LCM) % 2)
	{
		cout << (m / LCM + 1) / 2 << endl;
	}
	else
	{
		cout << (m / LCM) / 2 << endl;
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<queue>
#define ll long long
using namespace std;
int n,m,x,y,head[1000010],cnt=0;
ll z,dis[1000010];
struct Node{
	int u;
	ll dis;
	bool operator <(const Node &rhs)const{
		return dis>rhs.dis;
	}
};
priority_queue<Node>q;
struct Edge{
	int v,nxt;
	ll w;
}e[1000010];
void addEdge(int u,int v,ll w){
	e[++cnt].v=v;
	e[cnt].w=w;
	e[cnt].nxt=head[u];
	head[u]=cnt;
}
int main(){
	scanf("%d%d",&n,&m);
	for(register int i=2;i<=n;i++)addEdge(i,i-1,0);
	for(register int i=1;i<=m;i++){
		scanf("%d%d%d",&x,&y,&z);
		addEdge(x,y,z);
	}
	for(register int i=1;i<=n;i++)dis[i]=1e18;
	dis[1]=0;
	q.push((Node){1,0});
	while(!q.empty()){
		Node now=q.top();q.pop();
		if(now.dis!=dis[now.u])continue;
		for(register int i=head[now.u];i;i=e[i].nxt){
			if(dis[e[i].v]>dis[now.u]+e[i].w){
				dis[e[i].v]=dis[now.u]+e[i].w;
				q.push((Node){e[i].v,dis[e[i].v]});
			}
		}
	}
	printf("%lld",dis[n]<1e18?dis[n]:-1);
	return 0;
}

Measured memory_bytes: 11640
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
  set <string >s;
  string st;
  ll t;
  cin>>t;
  while(t--) {
    cin>>st;
    s.insert(st);
  }
  cout<<sz(s);
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 19376
from bisect import bisect_left as bl
x=int(input())
t=2*(10**5)
p=[]
q=[1]*(t)
for i in range(2,t):
    if q[i]:
        p.append(i)
        for j in range(2*i,t,i):
            q[j]=0
print(p[bl(p,x)])

Measured memory_bytes: 42096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    ll w, h, x, y;  cin >> w >> h >> x >> y;
    double ans = (double)w*h/2.0;
    
    cout << fixed << setprecision(20) << ans << ' ';
    if(2*x==w && 2*y==h)
        cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

const ll INF = 1e18;
const ll MOD = 1e9+7;
const int MAX = 1001001;
ll 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;
    }
}
ll 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;
}
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    COMinit();
    int x,y; cin >> x >> y;
    if( (x+y)%3!=0 || x>2*y || y>2*x ){
        cout << 0 << endl;
    }else{
        int n=(x+y)/3;
        int r=abs(x-n);
        cout << COM(n,r) << endl;
    }
    return 0;
}


Measured memory_bytes: 27028
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int INF = (int)1e9;

using ll = long long;

int b[MAXN];

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int add_left = 0;
    if (s[0] == '(') {
        b[0] = 1;
    } else {
        b[0] = -1;
    }
    for (int i = 1; i < n; ++i) {
        if (s[i] == '(') {
            if (s[i - 1] == ')' && b[i - 1] < 0) {
                add_left -= b[i - 1];
                b[i] = 1;
            } else {
                b[i] = b[i - 1] + 1;
            }
        } else {
            b[i] = b[i - 1] - 1;
            // (((((((()))())
            // (((()))())
        }
    }
    int add_right = 0;
    if (b[n - 1] > 0) {
        add_right += b[n - 1];
    } else if (s[n - 1] == ')'){
        add_left -= b[n - 1];
    }
    for (int i = 0; i < add_left; ++i) {
        cout << '(';
    }
    cout << s;
    for (int j = 0; j < add_right; ++j) {
        cout << ")";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<math.h>
#include <cstdio>
#include<iomanip>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,m,n) for(int i=m;i<(int)(n);i++)
const int inf = 10e9 + 7;
using namespace std;
int a[15];
signed main() {
	int n;
	cin >> n;
	int sum = 0;
	rep(i, n) {
		cin >> a[i]; sum += a[i];
	}
	sort(a, a + n);
	sum -= a[n - 1];
	if (sum >a[n - 1])cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main() {
    string S;
    cin >> S;
    int cnt = 0;
    int ans = 0;
    rep(i, S.size()) {
        if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') {
            cnt += 1;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import Control.Monad.Primitive
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic.Mutable as VGM
import Data.STRef
import Data.IORef

main :: IO ()
main = do
  n <- read <$> getLine
  [a,b] <- map read . words <$> getLine
  ps <- VU.unfoldrN n (BS.readInt . BS.dropWhile (<'!')) <$> BS.getLine
  print $ (\(q1,q2,q3) -> minimum [q1,q2,q3]) $ VU.foldl'
    (\(!q1,!q2,!q3) p -> if | p <= a -> (q1+1,q2,q3)
                            | p <= b -> (q1,q2+1,q3)
                            | otherwise -> (q1,q2,q3+1))
    (0,0,0) ps


Measured memory_bytes: 508
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}


ll N;
string S;
ll dp[1000010][2];


void solve(){
  cin >> S;
  reverse(S.begin(), S.end());
  S += '0';
  N = S.size();
  rep(i, N+1){
    rep(j, 2){
      dp[i][j] = INFL;
    }
  }
  dp[0][0] = 0;
  rep(i, N){
    rep(j, 2){
      rep(k, 10){
        ll sum = j + k + S[i] - '0';
        ll nj = sum / 10;
        sum %= 10;
        dp[i+1][nj] = min(dp[i+1][nj], dp[i][j] + sum + k);
      }
    }
  }

  cout << dp[N][0] << endl;
}


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


Measured memory_bytes: 17820
#include <iostream>

int main(){
   int A, B, C, K;
   std::cin >> A >> B >> C >> K;

   int max = A;
   if(max<B) max = B;
   if(max<C) max = C;
   int sum = A + B + C - max;
   for(int i=0; i<K; ++i){
      max *= 2;
   }
   std::cout << sum + max << std::endl;

   return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            int hh = input / 3600;
            int mm = (input % 3600) / 60;
            int ss = ((input % 3600) % 60);
            Console.WriteLine(hh + ":" + mm + ":" + ss);
        }
    }
}

Measured memory_bytes: 9024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#define REP(i,a,b) for(register int i=a;i<=b;++i)
using namespace std;
void File(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}
int n,a,b;
int main(){
	//File();
	cin>>n>>a>>b;
	if((b-a)%2==0)cout<<"Alice"<<endl;
	else cout<<"Borys"<<endl;
	return 0;
}


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

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u)
{
    for (int v = nt[u]; v < n; v++)
    {
        nt[u] = v + 1;
        if (M[u][v])
            return v;
    }
    return -1;
}

void dfs_visit(int r)
{
    for (int i = 0; i < n; i++)
    {
        nt[i] = 0;
    }
    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while (!S.empty())
    {
        int u = S.top();
        int v = next(u);
        if (v != -1)
        {
            if (color[v] == WHITE)
            {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }
        else
        {
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs()
{
    for (int i = 0; i < n; i++)
    {
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;

    for (int u = 0; u < n; u++)
    {
        if (color[u] == WHITE)
        {
            dfs_visit(u);
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main()
{
    int u, k, v;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n ; j++)
        {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++)
    {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++)
        {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs() ;
    return 0 ;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int k;
    string s;
    cin >> k >> s;
    if ((int)s.size() <= k) cout << s << '\n';
    else cout << s.substr(0, k) + "..." << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back
using namespace std;
const int N= 1e6 + 10;

int main(){ 
  fast;
  string s;
  cin >> s;
  if((s[0] == s[1] && s[1] == s[2])||(s[3] == s[1]  && s[1] == s[2]))
    cout << "Yes";
  else
    cout << "No";





  
  return 0;
}
    


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(void)
{
  int s, w;
  
  cin >> s >> w ;
  
  if((s > 0 && s <= 100) &&
     ( w > 0 && w <= 100))
  {
   if( s <= w)
   {
     cout << "unsafe" << endl;
   }
   else
   {
     cout << "safe" << endl;
   }
  }
  
  return 0;
}

Measured memory_bytes: 3632
using System;

namespace abc082A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = 0;
            if ((A + B) % 2 != 0)
                C = (A + B) / 2 + 1;
            else
                C = (A + B) / 2;
            Console.WriteLine(C);
        }
    }
}


Measured memory_bytes: 13396
#include<cstdio>
using namespace std;
int n,a,b,c,l1,l2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if((a^i)&1){printf("No\n");return 0;}
		if(a>i||(l1&&!((l1^a)&1))){if(!l1)l1=a;else if(a<l2){printf("No\n");return 0;}else if(a<l1)l2=a;else l1=a;}
		if(i&1){if(b<a)b=a;}else if(c<a)c=a;
		if(b>i&&c>i){printf("No\n");return 0;}
		if(b<=i&&c<=i)l1=l2=0;
	}
	printf("Yes\n");
}

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

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

    int a,b,h,m;
    double deg;
    cin >> a>>b>>h>>m;
    deg = abs(5.5 * m - 30 * h);
    deg = min(deg,360-deg);
    cout <<setprecision(20) << pow(pow(a,2)+pow(b,2)-2*cos(deg*M_PI/180)*a*b,0.5)<<endl;

    return 0;
}


Measured memory_bytes: 4312
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
'''
with open('./b09.txt') as f:
    N, M, K = map(int, f.readline().split())
    A = list(map(int, f.readline().split()))
    B = list(map(int, f.readline().split()))
'''
A_cnt = 0
B_cnt = 0
ans = 0
nowK = K
for A_idx in range(N):
    if nowK < A[A_idx]:
        break
    ans += 1
    nowK -= A[A_idx]
    A_cnt += 1
for B_idx in range(M):
    if nowK < B[B_idx]:
        break
    ans += 1
    nowK -= B[B_idx]
    B_cnt += 1
tmp_ans = ans
finish = False
for i in range(A_cnt, 0, -1):
    nowK += A[i - 1]
    tmp_ans -= 1
    for j in range(B_cnt, M):
        if finish or nowK < B[j]:
            break
        nowK -= B[j]
        tmp_ans += 1
        B_cnt += 1
    ans = max(tmp_ans, ans)
print(ans)




Measured memory_bytes: 118092
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
int main()
{
    vok();
    int n,k;
    IN n>>k;
    vll a(n);
    loop(i,0,n)
    {
        IN a[i];
    }
    loop(i,0,k)
    {
        vll temp(n,0);
        loop(j,0,n)
        {
            int low=j-a[j];
            int high=j+a[j];
            low=max(low,0);
            high=min(high,n-1);
            // OUT low<<" "<<high<<endl
            temp[low]++;
            if(high!=n-1)
            {
                temp[high+1]--;
            }
        }
        bool flag=true;
        // loop(j,0,n)
        // {
        //     OUT temp[j]<<" ";
        // }
        loop(j,1,n)
        {
            temp[j]+=temp[j-1];
            if(temp[j]!=temp[j-1])
            {
                flag=false;
            }
        }
        // loop(j,0,n)
        // {
        //     OUT temp[j]<<" ";
        // }
        // OUT endl
        a=temp;
        if(flag)
        {
            loop(j,0,n)
            {
                a[j]+=(k-1-i);
            }
            break;
        }
    }
    loop(i,0,n)
    {
        OUT min(a[i],(ll)n)<<" ";
    }
    OUT endl
    return 0;
}

Measured memory_bytes: 6308
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{

    public static void main(String[] args) throws IOException{
        //input                                                                   
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] temp_A = br.readLine().split(" ");
        int[] A = new int[n];
        for(int i = 0; i < n; i++){
            A[i] = Integer.parseInt(temp_A[i]);
        }
        //solve                                                                   
        int pivot = partition(A, 0, n-1);
        //output                                                                  
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            if(i != 0){
                sb.append(" ");
            }
            if(i == pivot){
                sb.append('[');
                sb.append(A[pivot]);
                sb.append(']');
            }else{
                sb.append(A[i]);
            }
        }
        System.out.println(sb);

    }
    public static int partition(int[] A, int p, int r){
        int x = A[r];
        int i = p-1;
        int temp = 0;
        for(int j = p; j < r; j++){
            if(A[j] <= x){
                i++;
                //A[j]??¨A[i]?????????                                                
                temp = A[j];
                A[j] = A[i];
                A[i] = temp;
            }
        }
        temp = A[i+1];
        A[i+1] = A[r];
        A[r] = temp;

        return i+1;
    }

}

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

int main(){
  long long k, a, b;
  cin >> k >> a >> b;
  if(b-a>2){
    if(a-1+2<=k){
     long long sum = 0;
      k -= a-1+2;
      sum += b;
      sum += (b-a)*(k/2);
      sum += k%2;
      cout << sum << endl;
    }else{
      cout << k+1 << endl;
    }
  }else{
    cout << k+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,d=100,year=0;cin>>x;
  while(d<x) {
    d=floor(d*1.01);
    year++;
  }
  print(year);
  return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 60

#define MAX_V 200


int main(){
  int n,m;
  int sum = 0;
  int ans = 0;
  
  scanf("%d%d",&n,&m);

  for(int i=0;i<n;i++){
    int k, v[SIZE];
    printf("lst %d\n",i);
    fflush(stdout);
    scanf("%d",&k);
    for(int i=0;i<k;i++) scanf("%d",v+i);
    ans += k*(k-1);
  }

  printf("ans %d\n",ans);
  fflush(stdout);
  
  return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

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

  int d = 1000000;
  int a = 0, b = 0;
  for (int i = 0; i < n; ++i) {
    a += w[i];
    b = 0;
    for (int j =i+1; j < n; ++j) {
      b += w[j];
    }
    int tmp = abs(a - b);
    if (d > tmp) {
      d = tmp;
    }
  }

  cout << d << endl;

  return 0;
}

Measured memory_bytes: 256
def partition(arr, p: int, r: int):
    x = arr[r]
    i = p - 1
    for j in range(p, r):
        if arr[j] <= x:
            i += 1
            arr[i], arr[j] = arr[j], arr[i]
    arr[i + 1], arr[r] = arr[r], arr[i + 1]
    return i + 1

n = int(input())
a = list(map(int, input().split()))
index = partition(a, 0, n - 1)
ans = []
for i in range(n):
    ans.append('[' + str(a[i]) + ']' if i == index else str(a[i]))
print(*ans)



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

int main()
{
  int n,d;
  cin >> n >> d;
  
  int x = 2 * d + 1;
  int ans = 0;
  if(n % x == 0){
    ans = n / x;
  }else{
    ans = n / x + 1;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
/*
[ ( ^ _ ^ ) ]
*/

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;


    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int s = in.nextInt();
        int mod = 998244353;
        int[] a = new int[n+1];
        for(int i=1; i<=n; i++) {
            a[i] = in.nextInt();
        }
        long[][] dp = new long[n+1][s+1];
        long[] p = new long[s+1];
        for(int i=1; i<=n; i++) {
            for(int j=1; j<=s; j++) {
                if(a[i]==j) {
                    dp[i][j] = i;
                }
                dp[i][j] += (j-a[i]>0)?p[j-a[i]]:0;
                dp[i][j] %= mod;
                // if(j-a[i]>0) for(int k=1; k<i; k++) {
                //     dp[i][j] += dp[k][j-a[i]];
                // }
            }
            for(int j=1; j<=s; j++) {
                p[j] += dp[i][j];
                p[j] %= mod;
            }
            // show("i", i, dp);
            // show("p", p);
            // show("");
        }
        long rs = 0;
        for(int i=1; i<=n; i++) {
            rs += (dp[i][s] * ((n - i + 1l)%mod))%mod;
            rs %= mod;
        }
        out.println(rs);
    }
    

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        out.close();
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 126800
n = int(input())

lis = [0] * (n+1)

s = int(n ** 0.5)

for i in range(1, s+1):
    for j in range(1, s+1):
        for k in range(1, s+1):
            t = i**2 + j**2 + k**2 + i*j + j*k + i*k
            tmp = [i,j,k]
            
            if t <= n:
                lis[t] += 1

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

Measured memory_bytes: 9568
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int g(int po){
	if(po == 4||po == 6 || po == 9 || po == 11 ){
		return 2;
	}
	else if(po == 2){
		return 1;
	}
	else {
		return 0;
	}
}


int main(){
	int x,y;
	cin >> x>>y;
	


	if(g(x) == g(y)){
		cout <<"Yes"<<endl;
	}
	else{
		cout << "No" <<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
//#include<queue>
#include<algorithm>
//#include<iostream>
//#include<assert.h>
using namespace std;
 
int q;
#define LL long long
int main()
{
	scanf("%d",&q);
	while (q--)
	{
		int a,b; scanf("%d%d",&a,&b);
		if (a==1 && b==1) {puts("0"); continue;}
		if (a>b) a^=b^=a^=b; LL c=1ll*a*b-1,d=(LL)(sqrt(c)+1e-13);
		if (d*d>c) d--;
		LL ans=2*d-1;
		if (a==b) ans++;
		if (d==c/d) ans--;
		if (c/d==a && d!=a) ans--;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#define NDEBUG
#include <bits/stdc++.h> 

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,t,s) for(int i = (int)(t); i >= (int)(s); --i)
#define rep(i,n) repU(i,0,n - 1)
#define rep1(i,n) repU(i,1,n)
#define all(v) begin(v),end(v)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1) / (d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = (1 << 30) - 1;
const ll INF_64 = (1LL << 62) - 1;
const int MOD = 1e9 + 7;

ll Pow(ll n, ll m, int mod = MOD){
	ll res = 1,pow = n % mod;
	while(m) {
		if(m & 1LL) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

ll Inv(ll n, int mod = MOD){ return Pow(n % mod, mod - 2, mod); }

void Fact_table(ll *fact, int range, int mod = MOD){
	fact[0] = 1;
	rep1(i,range) fact[i] = fact[i - 1] * i % mod;
}

void Fact_inv_table(ll *fact_inv, ll *fact, int range, int mod = MOD){
	rep(i,range + 1) fact_inv[i] = Inv(fact[i]);
}

ll Comb(int n, int m, ll *fact, ll *fact_inv, int mod = MOD){
	if(n < m || m < 0) return 0;
	ll rev = fact_inv[m] * fact_inv[n - m] % mod;
	return rev * fact[n] % mod;
}

int N,A,B,C,D;
ll fact[1010],fact_inv[1010],memo[1010][1010];

ll cal(int m, int x, int y){
	int cur = x * y;
	ll res = Comb(m,cur,fact,fact_inv);
	if(memo[x][y] < 0){
		memo[x][y] = 1;
		while(cur){
			memo[x][y] = memo[x][y] * Comb(cur,x,fact,fact_inv) % MOD;
			cur -= x;
		}
	}
	res = res * memo[x][y] % MOD;
	return res * fact_inv[y] % MOD;
}

void solve(){
	ll dp[1010] = {};
	dp[0] = 1;
	repD(i,B,A){
		repD(j,N,1){
			dp[j] = dp[j];
			repU(k,C,D){
				if(j < i * k) break;
				dp[j] += dp[j - i * k] * cal(j,i,k);
				dp[j] %= MOD;
			}
		}
	}
	cout << dp[N] << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	rep(i,1010) fill(all(memo[i]),-1);
	Fact_table(fact,1005);
	Fact_inv_table(fact_inv,fact,1005);
	cin >> N >> A >> B >> C >> D;
	solve();
}






Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000
int main(){
  string s;
  int ans=INF;
  cin>>s;
  for(int i=0;i<s.size()-2;i++){
    ans=min(ans,abs(753-((s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0')));
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define int long long
#define ld long double
#define sb __builtin_popcount
#define vi vector<int>
#define vc vector<char>
#define ii pair<int, int>
#define pq priority_queue<ii, vector<ii>, greater<ii>>
#define vii vector<ii>
#define sz(a) int((a).size())
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <=n; i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define in(a, b) (b.find(a) != string::npos)
#define minin(a) *min_element(all(a))
#define maxin(a) *max_element(all(a))
#define X first
#define Y second
#define fill(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define rall(v) reverse(v.begin(), v.end())
#define el "\n"
#define mx3(a, b, c) max(max(a, b), c)
#define mn3(a, b, c) min(min(a, b), c)
#define S(v) accumulate(all(v), (ll)0)
#define SP(n) cout.precision(n)
#define PI = atan(1.0) * 4.0;
#define MOD = 1e9 + 7;
void start() {
    fio;
    SP(10);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
    start();
    int n;
    cin>>n;
    if(n>=30)cout<<"Yes"<<el;
    else cout<<"No"<<el;
    return 0;
}


Measured memory_bytes: 3648
def main():    
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    s = sum(p[:k])
    maxs = s
    for i in range(n-k):
        s = s - p[i] + p[i+k]
        if s > maxs:
            maxs = s
    ans = (maxs+k)/2
    print(ans)
main() 

Measured memory_bytes: 25060
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;
#define RED 0
#define BLUE 1
#define GREEN 2

using namespace std;

int main (void) {
    ll N, ans;
    cin >> N;
    string S;
    cin >> S;
    ans = 0;
    ll CharCount[3][N];
    REP(int,i,0,N){
      CharCount[0][i] = 0;
      CharCount[1][i] = 0;
      CharCount[2][i] = 0;
    }
    for ( ll i = N; i > 0; i-- ){
      if ( S.at(i-1) == 'R' ){
        for ( ll j = i - 1; j > 0; j-- ){
          CharCount[RED][j-1]++;
        }
      }
      else if ( S.at(i-1) == 'B'){
        for ( ll j = i-1; j > 0; j-- ){
          CharCount[BLUE][j-1]++;
        }
      }
      else{
        for ( ll j = i-1; j > 0; j-- ){
          CharCount[GREEN][j-1]++;
        }
      }
    }
    
    for ( ll i = 0; i < N - 2; i++ ){
      for ( ll j = i + 1; j < N - 1; j++ ){
        //cout << i << j << endl;
        if ( ( S.at(i) == 'R' && S.at(j) == 'G' )  || 
             ( S.at(i) == 'G' && S.at(j) == 'R' ) ){
          //cout << "Yes" << endl;
          ans += CharCount[BLUE][j];
          if ( 2 * j - i < N ){
            if ( S.at(2*j-i) == 'B' ) ans--;
          }
        }
        else if ( ( S.at(i) == 'R' && S.at(j) == 'B' )  || 
                  ( S.at(i) == 'B' && S.at(j) == 'R' ) ){
          ans += CharCount[GREEN][j];
          if ( 2 * j - i < N ){
            if ( S.at(2*j-i) == 'G' ) ans--;
          }
        }
        else if ( ( S.at(i) == 'G' && S.at(j) == 'B' )  || 
                  ( S.at(i) == 'B' && S.at(j) == 'G' ) ){
          ans += CharCount[RED][j];
          if ( 2 * j - i < N ){
            if ( S.at(2*j-i) == 'R' ) ans--;
          }
        }
        else continue;
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3692
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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

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

int main() {
	int k, x;
	cin >> k >> x;

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


Measured memory_bytes: 256
N = int(input())

temp = False;

def fun(n):
	global temp;

	if temp == True:
		return;
	else:
		if n < 0:
			return;
		elif n == 0:
			temp = True;
		else:
			fun( n - 4 );
			fun( n - 7 );

fun(N);

if temp == True:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 2940
import java.util.Scanner;

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

    String s = sc.next();
    char[] dances = s.toCharArray();

    boolean y = false;
    for (int i = 1; i <= dances.length; i++) {
      if (i % 2 == 0) {
        y = dances[i-1] == 'L' || dances[i-1] == 'U' || dances[i-1] == 'D';
        if (!y) {
          System.out.println("No");
          return;
        }
      } else {
        y = dances[i-1] == 'R' || dances[i-1] == 'U' || dances[i-1] == 'D';
        if (!y) {
          System.out.println("No");
          return;
        }
      }
    }
    if (y) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35592
#include<stdio.h>
#define INF 10000000
int min(int,int);
void warshall_floyd(void);

int graph[21][21];
int V;

int main(void){
  int i,j,road,a,b,c,d;
  int x1,x2,y1,y2;
  for(i=0;i<21;i++){
    for(j=0;j<21;j++){
      graph[i][j]=INF;
    }
  }
  
  scanf("%d",&V);
  scanf("%d",&road);
  for(i=0;i<road;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    graph[a][b]=c;
    graph[b][a]=d;
  }
  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
  warshall_floyd();

    printf("%d\n",y1-graph[x1][x2]-graph[x2][x1]-y2);

  return 0;
}

int min(int x,int y){
  return (x>y)?y:x;
}

void warshall_floyd(){
  int i,j,k;
  for(k=0;k<=V;k++)
    for(i=0;i<=V;i++)
      for(j=0;j<=V;j++)
	graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
}

Measured memory_bytes: 0