akhauriyash/Code-Regression huggingface dataset:
class node():
    def __init__(self, key, parent, left, right):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right

root = None

def insert(z):
    global root

    y = None
    x = root

    while x != None:
        y = x

        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y

    if y == None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def find(key):
    
    x = root
    answer = None

    while x != None:

        if key == x.key:
            answer = x
            break

        if key < x.key:
            x = x.left
        else:
            x = x.right
    
    return answer
    
def delete(key):
    z = find(key)

    if z.left == None and z.right == None:
        if key < z.parent.key:
            z.parent.left = None
        else:
            z.parent.right = None
    
    elif z.left != None and z.right == None :
        if z.key < z.parent.key:
            z.parent.left = z.left
        else:
            z.parent.right = z.left
        
        z.left.parent = z.parent
    
    elif z.left == None and z.right != None :
        if z.key < z.parent.key:
            z.parent.left = z.right
        else:
            z.parent.right = z.right
        
        z.right.parent = z.parent

    elif z.left != None and z.right != None:
        next_node = z.right

        while next_node.left != None:
            next_node = next_node.left

        new_key = next_node.key
        delete(new_key)

        z.key = new_key

def Inorder_TreeWalk(node):
    if node is None:
        return

    Inorder_TreeWalk(node.left)
    print(" " + str(node.key), end="")
    Inorder_TreeWalk(node.right)

def Preorder_TreeWalk(node):
    if node is None:
            return
            
    print(" " + str(node.key), end="")
    Preorder_TreeWalk(node.left)
    Preorder_TreeWalk(node.right)

def Main():
    global root
    n = int(input())
    
    for i in range(n):
        inp = input().split()
        ope = inp[0]

        if ope == "insert":
            insert(node(int(inp[1]), None, None, None))
        
        elif ope == "find":
            target = find(int(inp[1]))

            if target != None:
                print("yes")
            else:
                print("no")

        elif ope == "delete":
            delete(int(inp[1]))

        elif ope == "print":
            Inorder_TreeWalk(root)
            print()
            Preorder_TreeWalk(root)
            print()
Main()


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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define mp make_pair
#define F first
#define S second


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(long long* a,long long n,long long val){
	for(long long i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	//cin>>t;
	while(t--){

	}
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)
	    cout<<"bust\n";
	else 
	    cout<<"win\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
    string s; cin >> s;
    ll res = 0;
    rep(i, s.size()) {
        if (i%2) {
            if (s.at(i) == 'g') res++;
        } else {
            if (s.at(i) == 'p') res--;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3736
#include <iostream>
using namespace std;
 
int main()
{
  	string s;
  	cin >>s;
  	string kq="Yes";
  	for(int i=0;i<s.size();i++) 
    	if((i%2 && s[i]=='R')||(i%2==0 && s[i]=='L')) {kq="No";break;}
  	cout<<kq;
}

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

int main(){
    string s;
    cin>>s;
    bool f=true;
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]=='L'){
                f=false;
            }
        }else{
            if(s[i]=='R'){
                f=false;
            }
        }
    }
    if(f){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import *
from functools import *
from collections import *
from heapq import heapify, heappop, heappush, heappushpop

from math import gcd

INF = float('inf')
NIL = - 1

N = int(input())
ans = 0
for i in range(1, N + 1):
    if i == 1:
        ans += N ** 2
        continue
    for j in range(1, N + 1):
        if j == 1:
            ans += N
            continue
        tmp = gcd(i, j)
        if tmp == 1:
            ans += N 
            continue
        for k in range(1, N + 1):
            if k == 1:
                ans += 1
                continue
            ans += gcd(tmp, k)
print(ans)




Measured memory_bytes: 68488
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func calc() string {
	sc.Split(bufio.ScanWords)
	n := 0
	n += nextInt() * 100
	n += nextInt() * 10
	n += nextInt()

	if n%4 == 0 {
		return "YES"
	}
	return "NO"

}

func main() {
	fmt.Println(calc())
}


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


int gcd3(int a,int b,int c){
    int temp=gcd(a,b);
    int answer=gcd(temp,c);
    return answer;
}

int main(void){
    int k;
    int sum=0;
    cin >>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                sum+=gcd3(i,j,l);
            }
        }
    }
    cout <<sum;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll p[200005];


int main() {
	int n;
	cin >> n;
	ll a[100005];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	ll count = 1;
	ll ans=0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			count++;
		}
		else {
			if (count % 2 == 1) {
				ans++;
			}
			count = 1;
		}

	}
	if (count % 2 == 1) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    
    int n; cin >> n;
    //vector<int> a(n);
    set<int> st;
    for(int i = 0; i < n; i++){
        int in; cin >> in;
        if(st.find(in) == st.end()){
            st.insert(in);
        }else{
            st.erase(in);
        }
    }

    
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 4864
#include <iostream>

using namespace std;

int v[100001];

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

  string s;
  cin >> s;

  for (int i = 0; i < n; i++) {
    v[i + 1] = v[i] + (s[i] == 'A' && s[i + 1] == 'C' ? 1 : 0);
  }

  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << v[r - 1] - v[l - 1] << endl;
  }

  return 0;
}

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

typedef long long ll;
typedef pair<int, int> Pair;

const int N = 3000;
const ll INF = 1000000000000, mod = 7 + 1e9;

int n;
double p[N], dp[N][N];

double go(int in, int h){
  if(in == n) return h > n - h;
  if(dp[in][h] != INFINITY) return dp[in][h];
  return dp[in][h] = (1 - p[in]) * go(in + 1, h) + p[in] * go(in + 1, h + 1);
}

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

  cin >> n;
  for(int i = 0; i < n; i++) cin >> p[i];
  for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) dp[i][j] = INFINITY;

  cout << fixed << setprecision(10);
  cout << go(0, 0) << endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    long long ans = 0;
    rep(i,N) {
        int a;
        cin >> a;
        ans += a - 1;
    }

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

Measured memory_bytes: 256
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define N (ll)(1e6+3)
#define INF (ll)(1e18+3)

#define ll long long
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define per(i,a,n) for(ll i = n-1; i >= a; i--)

//using namespace __gnu_pbds;
using namespace std;
 
// typedef
// tree<
//     pair<ll,ll>,
//     null_type,
//     less<pair<ll,ll>>,
//     rb_tree_tag,
//     tree_order_statistics_node_update>
// ordered_set;

string s;

void solve() {
    cin >> s;
    ll ans = INF;
    rep(i,0,26) {
        char ch = 'a'+i;

        ll cur = 0, mx = 0;
        rep(j,0,s.size()) {
            if (s[j] != ch)
                cur++;
            else
                cur = 0;
            mx = max(mx, cur);
        }
        ans = min(ans,mx);
    }
    cout << ans << endl;
}


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

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

int main() {
  
  long long n;
  cin >> n;
  
  long long ans = 0;
  
  for(int i = 1; i <= n; i++){
    if(i % 3 == 0 && i % 5 == 0) {
      //FizzBuzz
    } else if(i % 3 == 0) {
      //Fizz
    } else if(i % 5 == 0) {
      //Buzz
    } else {
      ans = ans + i; 
    }
  }
  
  cout << ans;
  
}


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

int main(){
    int n;  cin >> n;
    vector<ll> a(n), b(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i) >> b.at(i);
    }
    ll sum=0;
    for(int i=n-1; 0<=i; i--){
        if((sum+a.at(i))%b.at(i)==0) continue;
        sum += b.at(i)-(sum + a.at(i))%b.at(i);
    }
    cout << sum << endl;
}
  

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

int coll(int s) {
	int count = 1;
	int t = s;

	while (true) {
		if (t == 1 || t == 2 || t == 4) {
			break;
		}
		else if (t % 2 == 0) {
			t /= 2;
		}
		else {
			t = 3 * t + 1;
		}
		count++;
	}

	return count + 3;
}


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

	cout << coll(s) << endl;
}


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

int main() {
  string S;
  cin >> S;
  vector<string> date = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
  
  for (int i = 0; i < 7; i++) {
    if (i == 6) {
      cout << i+1 <<endl;
      break;
    }
    if (S == date.at(i)) {
      cout << 6-i <<endl;
      break;
    }
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	string a[h];
	for(int i = 0; i < h; i++) cin >> a[i];
	int x = 0, y = 0;
	int ans = 1;
	int count = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(a[i][j] == '#') count++;
		}
	}
	if(count != (h + w - 1)) cout << "Impossible" << endl;
	else cout << "Possible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long long a,b;
	while(cin>>a>>b)
	{
		int c=a+b;
		int n=0;
		while(c>0)
		{
			c=c/10;
			n++;
		}
		cout<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
"use strict"

function Main(input) {
  let lines = input.split('\n');
  let x = parseInt(lines[0], 10);

  if ( x === 1 ) {
    console.log('0');
  } else {
    console.log('1');
  }

  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29616
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	auto& in = cin;
	long long x;
	in >> x;
	long long maxVal = 1800;

	for (long long a = -maxVal; a <= maxVal; ++a) {
		for (long long b = -maxVal; b <= maxVal; ++b) {
			if ((pow(a, 5) - pow(b, 5)) == x) {
				cout << a << ' ' << b;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*4
#define ll long long
int n,m;
int a[nn];
vector<int> ans,seq;
void solve()
{
	if(seq[0]%2)
	{
		ans.push_back(seq[0]-1);
		ans.push_back(2);
	}
	else
	{
		ans.push_back(seq[0]-1);
		ans.push_back(2);
	}
	
	for(int i=1;i<seq.size()-1;i++)
		ans.push_back(seq[i]);
	
	int cn=seq.size()-1;
	if(seq[cn]%2)
	{
		ans.push_back(seq[cn]-1);
	}
	else
	{
		ans.push_back(seq[cn]-1);	
	}
	
}
void output()
{
	int vnt=0;for(int i=0;i<ans.size();i++) if(ans[i]==0) vnt--;
	cout<<(int)ans.size()+vnt<<"\n";
	for(int i=0;i<ans.size();i++) if(ans[i])printf("%d ",ans[i]);
}
int main()
{
	cin>>n>>m;int od=0;
	for(int i=1;i<=m;i++) scanf("%d",&a[i]),od+=a[i]%2;
	if(m==1) 
	{
		cout<<a[1]<<"\n";
		if(n%2==1)
		{
			while(n>=2) ans.push_back(2),n-=2;
			if(n) ans.push_back(n);
		}
		else
		{
			int t=n/2;if(t%2==0) t++;
			ans.push_back(t);n-=t;
			while(n>=2) ans.push_back(2),n-=2;
			if(n) ans.push_back(n);
		}
		output();
		exit(0);
	}
	if(od>2)
	{
		puts("Impossible");
		exit(0);
	}
	
	if(od==2)
	{
		for(int i=1;i<=m;i++)
			if(a[i]%2)
			{
				seq.push_back(a[i]),a[i]=0;
				break;
			}
		for(int i=1;i<=m;i++) if(a[i]&&a[i]%2==0) seq.push_back(a[i]);
		for(int i=1;i<=m;i++) if(a[i]%2) seq.push_back(a[i]);
			
	}
	if(od==1)
	{
		for(int i=1;i<=m;i++)
			if(a[i]%2)
				seq.push_back(a[i]),a[i]=0;
		for(int i=1;i<=m;i++) if(a[i]&&a[i]%2==0) seq.push_back(a[i]);
	}
	if(od==0)
	{
		for(int i=1;i<=m;i++)
				seq.push_back(a[i]);
	}
	for(int i=0;i<seq.size();i++) printf("%d ",seq[i]);cout<<"\n";
	solve();output();
	return 0;  
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  vector<bool> dp(10010, false);
  dp[0] = true;
  REP(i,N){
	int x;
	cin >> x;
	for(int j=10010-1;j>=x;--j)
	  dp[j] = dp[j] || dp[j-x];
  }

  int ans = 0;
  REP(x,10010)
	if(dp[x] && x%10 != 0)
	  maxi(ans, x);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using ll = long long;
using namespace std;
ll N;
ll v[200005];
ll sum[200005];
ll r[200005];
ll K;
class Segtree {
  vector<int> tree;
  int n;
 public:
  Segtree(const int len) {
    n = len;
    tree = vector<int>(2 * n, 0);
  }

  void update(int pos, int val) {
    pos += n;
    tree[pos] = val;
    int par = pos / 2;
    while (par > 0) {
      tree[par] = tree[par * 2] + tree[par * 2 + 1];
      par /= 2;
    }
  }

  int query(int l, int r) {
    l += n;
    r += n;
    int ret = 0;
    while (l <= r) {
      if (l & 1) {
        ret +=tree[l];
        l++;
      }
      if ((r & 1) == 0) {
        ret += tree[r];
        r--;
      }
      l /= 2;
      r /= 2;
    }
    return ret;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> N >> K;
  for(int i = 0; i < N; ++i) {
    cin >> v[i];
    v[i] -= K;
  }

  sum[0] = 0;
  for(int i = 0; i < N; ++i) {
    sum[i + 1] = sum[i] + v[i];
  }

  // count bigger elements on right side
  iota(r, r + N + 1, 0);

  sort(r, r + N + 1, [](const int a, const int b) {
    if (sum[a] != sum[b]) return sum[a] > sum[b];
    return a > b;
  });

  ll ret = 0;
  Segtree st(N + 1);
  for(int i = 0; i < N + 1; ++i) {
    int c = r[i];
    ret += st.query(c + 1, N);
    st.update(c, 1);
  }
  cout << ret << endl;

}

Measured memory_bytes: 6528
//
//  main.cpp
//  A - Two Integers
//
//  Created by Anson Thai on 11/4/20.
//  Copyright © 2020 Anson Thai. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {
    // insert code here...
    //std::cout << "Hello, World!\n";
    
    int x, y;
    
    std::cin >> x;
    std::cin >> y;
    
    int m = 2;
    
    if (x%y == 0)  {
        std::cout << -1 << std::endl;
        return 0;
    }
    
    
    int test = m*x;
    int test2 = (10^18)/x;
    int test3 = x*y;
    while ((m)<=(y*2)) {
        if (((m*x)%y) == 0) {
            m++;
        } else {
            std::cout << m*x << std::endl;
            return 0;
            
        }
    }
    
    std::cout << -1 << std::endl;
    
    
    return 0;
}


Measured memory_bytes: 256
class Comb
  def initialize(n)
    create_pascals_triangle(n)
  end

  def comb(n, k)
    return 0 if n < k
    @dp[n][k]
  end

  def print_triangle
    n = @dp.size
    0.upto(n - 1) do |i|
      tmp = []
      0.upto(i) do |j|
        tmp << @dp[i][j]
      end
      puts tmp.join("\s")
    end
  end

  private

  def create_pascals_triangle(n)
    @dp = Array.new(n + 1) { Array.new(n + 1, 1) }

    1.upto(n) do |i|
      1.upto(i - 1) do |j|
        @dp[i][j] = @dp[i - 1][j - 1] + @dp[i - 1][j]
      end
    end
  end
end


MOD = 10 ** 9 + 7

def blue_and_red_balls(n, k)
  c = Comb.new(n)
  blue = k
  red = n - k
  (1..k).each do |i|
    puts c.comb(red + 1, i) * c.comb(blue - 1, i - 1) % MOD
  end
end

n, k = gets.split.map(&:to_i)
blue_and_red_balls(n, k)

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

int main(void) {
  long long N, M;
  cin >> N >> M;
  long long mi = min(N, M / 2);
  N -= mi;
  M -= 2 * mi;
  cout << mi + M / 4 << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c, d = [int(e) for e in input().split()]

    c1 = c // b + 1
    if c % b == 0:
        c1 -= 1

    c2 = a // d + 1
    if a % d == 0:
        c2 -= 1

    ans = 'Yes' if c1 <= c2 else 'No'
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61684
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

const ll INF=1000000000;

int main(){
    ll n;
    cin>>n;
    lvec a(n);
    rep(i,n) cin>>a[i];
    ll ans;
    set<ll> st;
    rep(i,n){
        if(a[i]==1) st.insert(1);
        if(!st.empty()&&a[i]-*rbegin(st)==1) st.insert(a[i]);
    }
    if(!st.empty()) cout<<n-st.size()<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 11136
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll n;
    cin>>n;
    Yes(n>=30);
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
//    ll T;
//    cin>>T;
//    while(T--)
    solve();
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int n;
int a[205];
int ans=0;
int main()
{
    cin>>n;
    n*=2;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=n-1;i>=1;i-=2)
        ans+=a[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    A = Scanner.map_int()
    A = [a - (i + 1) for i, a in enumerate(A)]
    A.sort()
    if N % 2 == 1:
        m = A[N // 2]
        print(sum([abs(a - m) for a in A]))
    else:
        m = A[N // 2 - 1]
        ans = sum([abs(a - m) for a in A])
        m = A[N // 2]
        ans = min(ans, sum([abs(a - m) for a in A]))
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 116720
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int X; cin >> X;
    if (X >= 30) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int d[105][2];
int main()
{
    int n;
    scanf("%d",&n);
    int flag=0;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&d[i][0],&d[i][1]);
        if(d[i][0]==d[i][1])
        {
            flag++;
        }
        else
        {
            flag=0;
        }
        if(flag==3)ans=1;
    }
    if(ans==0)
    {
        printf("No\n");

    }
    else
    {
        printf("Yes\n");
    }

}


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

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

const long long MOD = 1000000007;

int main(){
  string s;
  cin >> s;
  bool ans = true;
  
  rep(i,s.size()){
    if(i%2==0 && s.at(i)!='h') ans=false;
    if(i%2==1 && s.at(i)!='i') ans=false;
  }
  if(s.size()%2==1) ans=false;
  if(ans) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

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

int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if ((i & 1) && s[i] == 'g') ans++;
		if (!(i & 1) && s[i] == 'p') ans--;
	}
	cout << ans << endl;
}

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

int main() {
    int A, B, M, minA=2e9, minB=2e9, ans, tmp, x, y, c;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);

    for(int i=0; i<A; i++){
	cin >> a[i];
	minA=min(minA, a[i]);
    }
    for(int i=0; i<B; i++){
	cin >> b[i];
	minB=min(minB, b[i]);
    }
    ans=minA+minB;

    for(int i=0; i<M; i++){
	cin >> x >> y >> c;
	x--; y--;
	tmp= a[x] + b[y] - c;
	ans = min(ans, tmp);
    }

    cout << ans << endl;
    
} 


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    string input;
    cin>>input;
    string hoge=input;
    reverse(input.begin(),input.end());
    if(hoge==input) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
	char s[200001],t[200001],c[26]={0},d[26]={0};
	scanf("%s %s",s,t);
	long long len = strlen(s),i,j;
	for(i=0;i<len;i++){
		c[(int)(s[i])-97]++;
		d[(int)(t[i])-97]++;
	}
	for(i=0;i<26;i++){
		int num = c[i];
		for(j=0;j<26;j++){
			if(d[j]==num){
				d[j]=0;
				break;
			}
		}
		if(j==26){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	
	return 0;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll n; cin >> n;
    out((n+1)*n/2);
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll

int main(){
  int n,y;cin>>n>>y;
  rep(i,n+1){
    rep(j,n+1){
      if(i+j>n)continue;
      if(10000*i+5000*j+1000*(n-i-j)==y){
        cout << i << " " << j << " " << n-i-j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
using namespace std;


ll gcd(ll a, ll b) {
  if (a == 0)return b;
  return gcd(b % a, a);
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ll n;cin>>n;
  ll m,k;cin>>m>>k;
  ll a[n],b[m];
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  for(int i=0;i<m;i++){
      cin>>b[i];
  }
  int i=0,j=0;
  ll cnt=0,ans=0;
   ll s=0,e=n+m;
   for(int i=1;i<n;i++) a[i]+=a[i-1];
   for(int j=1;j<m;j++) b[j]+=b[j-1];
   for(int i=0;i<n;i++){
       if(a[i]<=k){
           ll up=upper_bound(b,b+m,k-a[i])-b;
           ans=max(ans,i+1+up);
       }
   }
   for(int i=0;i<m;i++){
       if(b[i]<=k){
           ll up=upper_bound(a,a+n,k-b[i])-a;
           ans=max(ans,i+1+up);
       }
   }
  cout<<ans;
}




  

Measured memory_bytes: 6744
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '(L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
 
    string s;
    cin>>s;
    if(s.find('9')!=string::npos){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }





}


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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  INT(n); INT(c);
  vector<vector<pair<int, int>>> vs(c + 1);
  REP(n){
    INT(si); INT(ti); INT(ci);
    vs[ci].EB(si, ti);
  }
  REP(i, 1, c + 1){
    vector<pair<int, int>> v0 = vs[i], v;
    if (v0.empty()){continue;}
    sort(v0.begin(), v0.end());
    auto it = v0.begin();
    int l = (*it).first, r = (*it).second;
    REP(SZ(v0)){
      it++;
      if (it == v0.end() || r != (*it).first){
        v.EB(l, r);
        l = (*it).first; r = (*it).second;
      } else {
        r = (*it).second;
      }
    }
    vs[i] = v;
  }
  vector<int> vi(200002, 0);
  for(auto v: vs){
    for(auto e: v){
      vi[e.first * 2]++;
      vi[e.second * 2 + 1]--;
    }
  }
  int ans = 0, tmp = 0;
  for(auto e: vi){
    tmp += e;
    ans = max(ans, tmp);
  }
  printf("%d\n", ans);
  return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int a[N];
int cnt[4][N];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    string s;
    cin >> n >> s;
    FOR(i, 0, s.size() - 1)
    {
        if(s[i] == 'R') a[i + 1] = 1;
        if(s[i] == 'G') a[i + 1] = 2;
        if(s[i] == 'B') a[i + 1] = 3;
    }
    FOR(i, 1, n)
    {
        if(a[i] == 1)
        {
            cnt[1][i] = cnt[1][i - 1] + 1;
            cnt[2][i] = cnt[2][i - 1];
            cnt[3][i] = cnt[3][i - 1];
        }
        if(a[i] == 2)
        {
            cnt[1][i] = cnt[1][i - 1];
            cnt[2][i] = cnt[2][i - 1] + 1;
            cnt[3][i] = cnt[3][i - 1];
        }
        if(a[i] == 3)
        {
            cnt[1][i] = cnt[1][i - 1];
            cnt[2][i] = cnt[2][i - 1];
            cnt[3][i] = cnt[3][i - 1] + 1;
        }

    }
    /*
    FOR(i, 1, 3)
        {
            FOR(j, 1, n)
                cout << cnt[i][j] << " ";
            cout << endl;
        }
    */
    ll ans = 0;
    FOR(i, 1, n)
        FOR(j, i + 1, n)
        {
            if(a[i] == a[j]) continue;
            int val = 6 - a[i] - a[j];
            int pos = j + (j - i);
            if(pos > n)
            {
                ans += cnt[val][n] - cnt[val][j];
            }
            else
            if(pos == n)
            {
                ans += cnt[val][n - 1] - cnt[val][j];
            }
            else
            {
                ans += cnt[val][pos - 1] - cnt[val][j] + cnt[val][n] - cnt[val][pos];
            }
        }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3744
def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A

def main():
    N = int(input())
    S = input()
    #N = 5000
    #S = "a"*N
    import time
    star = time.time()
    A = [[] for i in range(N)]
    for i in range(N):
        A[i] = [0]*i + z_algo(S[i:])
    ans = 0
    for i in range(N):
        for j in range(N):
            if i + A[i][j] <= j and ans < A[i][j]:
                ans = A[i][j]
    
    g = time.time()
    #print(g-star)
    print(ans)
    
main()

Measured memory_bytes: 257668
#include<stdio.h>
int main()
{
   int i,H,N,A;

   scanf("%d %d",&H,&N);

   for(i=0; i<N; i++)
   {
       scanf("%d",&A);
       H=H-A;
   }
   if(H<=0)
   printf("Yes");
   else
   printf("No");


}

Measured memory_bytes: 128
package main 

import (
	"fmt"
)

func main() {
	var a, b, d, n int
	fmt.Scan(&a, &b, &d)
	n = 0
	for i := a; i <= b; i++ {
		if (d % i == 0) {
			n++
		}
	}
	fmt.Println(n)
}


Measured memory_bytes: 1152
from itertools import combinations

inf = 2 * 10 ** 10

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

ret = inf

for combi in combinations(range(n), r=k):
    set_ = set(combi)

    t = 0
    p = a[0] - 1
    for i, x in enumerate(a):
        if i in set_:
            if p >= x:
                t += p + 1 - x
                p += 1
            else:
                p = x
        else:
            if p < x:
                p = x
    ret = min(ret, t)

print(ret)


Measured memory_bytes: 3064
// include
// ----------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>

// repetition
// ----------------------------------------------------------------------------
#define FOR(i, a, b) for (i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// memory clear
// ----------------------------------------------------------------------------
#define CLRNUM(a) memset((a), 0, sizeof(a))
#define CLRBOOL(a, flag) memset((a), flag, sizeof(a))
#define CLRCHAR(a) memset((a), '\0', sizeof(a))

// debug
// ----------------------------------------------------------------------------
#define DEBUGNUM(x) printf("%d\n", x);
#define DEBUGCHAR(x) printf("%c\n", x);
#define DEBUGSTR(x) printf("%s\n", x);
#define DEBUGFORNUM(i, a, b, x) FOR(i, a, b){ printf("%d ", x[i]); }
#define DEBUGFORCHAR(i, a, b, x) FOR(i, a, b){ printf("%c ", x[i]); }
#define DEBUGREPNUM(i, n, x) REP(i, n){ printf("%d ", x[i]); }
#define DEBUGREPCHAR(i, n, x) REP(i, n){ printf("%c ", x[i]); }

// other
// ----------------------------------------------------------------------------
#define PUTNL printf("\n")

// constant
// ----------------------------------------------------------------------------
#define INF 1000000000

int main(void)
{
    int n;
    int i, j;
    char str[1024];

    scanf("%d", &n);

    CLRCHAR(str);

    getchar();
    for (i = 0; i < n; ++i){
        fgets(str, sizeof(str), stdin);
        
        for (j = 0; str[j] != '\0'; j++){
            if (str[j] == 'H'){
                if (str[j + 1] == 'o'){
                    if (str[j + 2] == 's'){
                        if (str[j + 3] == 'h'){
                            if (str[j + 4] == 'i'){
                                if (str[j + 5] == 'n'){
                                    if (str[j + 6] == 'o'){
                                        str[j + 6] = 'a';
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        
        printf("%s", str);
        
        CLRCHAR(str);
    }
    
}

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




int main(void) {
  int n;
  cin >> n;
  int a[300001];
  rep(i,3*n) cin >> a[i];
  sort(a,a+3*n,greater<int>());
  ll sum = 0;
  for (int i=1;i <2*n;i+=2){
    sum += a[i];
  }
  cout << sum << endl;
  
  
  
 
   
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std ;
int main () {
  int K;
  cin>>K;
  
  if(K%2==1){
    int ans1 = ((K-1)/2) * ((K+1)/2);
    cout << ans1 << endl;
  }else{
    int ans2 = (K/2) * (K/2);
    cout << ans2 << endl;
  }  
  
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    ll curMax = a[0];
    for (int i = 1; i < n; i++) {
        if (a[i] > curMax) curMax = a[i];
        else ans += curMax - a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4820
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    int p[55];
    int ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d", &p[i]);
        if(p[i] != i)
            ++ans;
    }
    if(ans <= 2)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
n=gets.to_i
ps=gets.split.map(&:to_i)
ans=0
1.upto(n-2) do |i|
  ans+=1 if (ps[i-1]<ps[i] && ps[i]<ps[i+1]) || (ps[i+1]<ps[i] && ps[i]<ps[i-1])
end
puts ans


Measured memory_bytes: 1788
#include <stdio.h>

int main(void)
{
  int N,K,i,j,k,tmp,sum = 0;
  int l[100];

  scanf("%d %d",&N,&K);
  for(i = 0;i < N;i++)
    scanf("%d",&l[i]);

  for(i = 0;i < N;i++)
    for(j = 0;j < N - 1;j++)
      {
        if(l[j] < l[j + 1])
          {
            tmp = l[j];
            l[j] = l[j + 1];
            l[j + 1] = tmp;
          }
      }

  for(i = 0;i < K;i++)
    sum = sum + l[i];

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

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#define N 2005
using namespace std;

int n, m, k, r1, r2, c1, c2, ar[N][N], ac[N][N], b[N][N];
char a[N][N];
int main()
{
	int i, j;
	cin >> n >> m >> k;
	for (i = 0; i < n; i++) {
		scanf("%s", a[i]);
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			b[i+1][j+1] = b[i+1][j] + b[i][j+1] - b[i][j] + (a[i][j] == '1');
			ar[i+1][j+1] = ar[i+1][j] + ar[i][j+1] - ar[i][j] + (i > 0 && a[i][j] == a[i-1][j] && a[i][j] == '1');
			ac[i+1][j+1] = ac[i+1][j] + ac[i][j+1] - ac[i][j] + (j > 0 && a[i][j] == a[i][j-1] && a[i][j] == '1');
		}
	}
	while (k--) {
		scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
		printf("%d\n", b[r2][c2] - b[r2][c1-1] - b[r1-1][c2] + b[r1-1][c1-1] - (ar[r2][c2] - ar[r2][c1-1] - ar[r1][c2] + ar[r1][c1-1] + ac[r2][c2] - ac[r2][c1] - ac[r1-1][c2] + ac[r1-1][c1]));
	}
	return 0;
}

Measured memory_bytes: 52864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> vec(M);
    rep(i,M){
        cin >> vec[i];
    }
    sort(all(vec));
    vector<int> dist_vec(M - 1);
    rep(i,M - 1){
        dist_vec[i] = vec[i + 1] - vec[i];
    }
    sort(all(dist_vec));
    int ans = vec[M - 1] - vec[0];
    if (N >= M){
        ans = 0;
    }
    else{
        rep(i,N - 1){
            ans -= dist_vec[M - 2 - i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;
int main() {
  int x;
  cin >> x;
  int count = 1;
  while(true) {
    if(x <= 2){
      count = 0;
      break;
    }else if(x - 3 > 2) {
      x = x - 3;
      count++;
    }else {
      break;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256