akhauriyash/Code-Regression huggingface dataset:
// Author - Abhishek giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 100000000007
#define V(type) vector<type> 
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)

/*##################################################################################*/


/*
int prime[1000001] ;
vector<ll> v ;
void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(ll i = 2 ; (ll)i*i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            v.pb(i);
            for(ll j = i*i ; j <= 1000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}
*/

/*
bool isprime(ll n)
{
    for(ll i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}
*/

/*
ll fib(int n) 
{ 
  ll a = 0, b = 1, c, i; 
  if( n == 0) 
    return a; 
  for (i = 2; i <= n; i++) 
  { 
    c = (a + b); 
    a = b; 
    b = c; 
  } 
  return b; 
}
*/

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

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

*/
/*
ll findgrouplcm(ll arr[], ll n) 
{ 
    ll ans = arr[0]; 
  
    for (ll i = 1; i < n; i++) 
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));
  
    return ans; 
}


ll powerwithmod(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}

*/

/*
ll setBitNumber(ll n) 
{ 
    n |= n >> 1; 
    n |= n >> 2; 
    n |= n >> 4; 
    n |= n >> 8; 
    n |= n >> 16; 
    n |= n >> 32;
    n = n + 1; 
  
    return (n >> 1); 
} 
*/

/*
void decToBinary(ll n,string &s) 
{ 
    for (int i = 63; i >= 0; i--) { 
        int k = n >> i; 
        if (k & 1) 
            s += "1"; 
        else
            s += "0"; 
    } 
}
*/
/*
void countdiv(ll l,set<ll> &v){
    int div = 0 ;
    for(ll i = 2 ;i*i <= l ; i++){
        if(l % i == 0){
            v.insert(i);
            v.insert(l/i);
        }
    }
}
*/

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll testcases = 1;
    //cin>>testcases;
    while(testcases--)
    {
        ll a ,b ,c ,k;
        in(a)>>b>>c>>k;
        if(k <= a){
            cout<<k;
        }
        else
        if(k <= (a+b)){
            cout<<a;
        }
        else
        if(k <= (a+b+c))
        {
            cout<<a-(k-(a+b));
        }
        else{
            cout<<"0";
        }
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    if (n % 2) cout << "No";
    else if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3648
"""
N段の階段 M個の階段が壊れている
"""

N, M = map(int, input().split())
arr = [int(input()) for _ in range(M)]
no_step =[0]*N

if N==1:
    print(1)
    exit()

for i in range(M):
    no_step[arr[i]-1]=1

count = [0]*N
if no_step[0]==0:
    count[0]=1

if no_step[1]==1:
    count[1]=0
elif no_step[0]==0 and no_step[1]==0:
    count[1]=2
elif no_step[0]==1 and no_step[1]==0:
    count[1]=1

for i in range(3,N+1,1):
    count[i-1] = count[i-2]+count[i-3]
    if no_step[i-1] == 1:
        count[i-1] = 0

ans =count[N-1]%1000000007
print(ans)

Measured memory_bytes: 470520
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int MAX = 2000100;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(long long n, long long k){
    if (n < k) return 0LL;
    if (n < 0LL || k < 0LL) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long f(ll r, ll c) {
    return COM(c+r, c);
}

int main()
{
    ll r1, c1, r2, c2;
    scanf("%lld %lld %lld %lld", &r1, &c1, &r2, &c2);

    COMinit();

    //ll res = f(r2+1, c2+1) - f(r1,c2+1) - (f(r2+1, c1) - f(r1, c1));
    //printf("%lld\n", res%MOD);
    ll res = (f(r2+1, c2+1) - f(r1, c2+1) + MOD)%MOD;
    res = (res - (f(r2+1, c1) - f(r1,c1) + MOD)%MOD + MOD)%MOD;
    printf("%lld\n", res);
    return 0;
}

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

typedef long long ll;
#define MAX 100001
#define MOD 1000000007

ll modpow(ll x, ll n)
{
    ll result = 1;
    ll xx = x;

    while (n > 0) {
        if (n & 1) result = result * xx % MOD;
        n >>= 1;
        xx = xx * xx % MOD;
    }

    return result;
}

ll mod(ll n)
{
    ll result = n;
    while (result < 0) result += MOD;
    return result % MOD;
}
int main(int, char**)
{
    int n, k;

    cin >> n >> k;

    ll gcd_count[MAX];
    for (int i = k; i >= 1; i--) {
        gcd_count[i] = modpow(k / i, n);
        for (int j = i * 2; j <= k; j += i) gcd_count[i] = mod(gcd_count[i] - gcd_count[j]);
    }

    ll result = 0;
    for (int i = 1; i <= k; i++)
        result = mod(result + mod(gcd_count[i] * i));

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 4372
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
	class Person
	{
		public int K;
		public int[] L;
		public Person(string[] s)
		{
			this.K = int.Parse(s[0]);
			this.L = new int[K];
			for (int i = 0; i < this.K; i++)
			{
				this.L[i] = int.Parse(s[i + 1]);
			}
		}
	}

	class MainClass
	{
		public static void Main(string[] args)
		{
			string[] s = Console.ReadLine().Split(' ');
			int N = int.Parse(s[0]);
			int M = int.Parse(s[1]);
			Person[] persons = new Person[N];
			Stack<Person> s1 = new Stack<Person>();
			for (int i = 0; i < N; i++)
			{
				s = Console.ReadLine().Split(' ');
				persons[i] = new Person(s);
			}
			bool[] blang = new bool[M + 1];
			bool[] bperson = new bool[N];

			s1.Push(persons[0]);
			bperson[0] = true;
			foreach (int x in persons[0].L)
			{
				blang[x] = true;
			}
			int tmp = 1;
			while (true)
			{
				for (int i = 1; i < N; i++)
				{
					if (!bperson[i])
					{
						foreach (int x in persons[i].L)
						{
							if (blang[x])
							{
								bperson[i] = true;
								s1.Push(persons[i]);
								foreach (int y in persons[i].L)
								{
									blang[y] = true;
								}
								break;
							}
						}
					}
				}
				if (tmp == s1.Count())
					break;
				else
					tmp = s1.Count();
			}
			if(s1.Count() == N)
				Console.WriteLine("YES");
			else
				Console.WriteLine("NO");
		}
	}
}


Measured memory_bytes: 16436
#include <stdio.h>
typedef unsigned long long ULL;
 
ULL gcd(ULL a, ULL b);
ULL lcm(ULL a, ULL b);
 
int main(){
    ULL a, b, c, d;
    scanf("%llu %llu %llu %llu", &a, &b, &c, &d);
 
    b = b - b / c - b / d + b / lcm(c, d);
    a = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / lcm(c, d);
 
    printf("%llu\n", b - a);
    return 0;
}
 
ULL gcd(ULL a, ULL b){
    return ((b != 0) ? gcd(b, a % b) : a);
}
 
ULL lcm(ULL a, ULL b){
    return a * b / gcd(a, b);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 int func(int t,int F){
   while(1){
     if(t % F == 0){
       return t;
     }
     else t += 1;
   }
 }
int main() {
  int N;
  cin >> N;
  vector<tuple<int,int,int>> p(N-1);
  for(int i = 0;i<N-1;i++){
   cin >> get<0>(p[i]);
   cin >> get<1>(p[i]);
   cin >> get<2>(p[i]); 
    }
    for(int i = 0;i < N-1;i++){
      int t = get<0>(p[i]) + get<1>(p[i]);
     for(int j = i;j < N-2;j++){
       if(t >= get<1>(p[j+1])/*Sj+1*/ && t % get<2>(p[j+1])/*Fj+1*/ == 0){
         t += get<0>(p[j+1]);
       }
       else if(t >= get<1>(p[j+1]) && t % get<2>(p[j+1]) != 0){
         t = func(t,get<2>(p[j+1])) + get<0>(p[j+1]);
          }
       else if(t < get<1>(p[j+1])){
         t = get<0>(p[j+1]) + get<1>(p[j+1]) ;
       }
       
      }
      cout << t << endl;
    }
      cout << 0 << endl;            
}

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

#pragma region Debug
void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cout << H << " ";
	debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
#pragma endregion

// コンパイル時、エイリアス「debug」を使用 --> マクロが使えるように

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	int n;
	cin >> n;
	vi a(n);
	rep(i,n){
		cin >> a[i];
	}

	sort(a.begin(), a.end(), greater<int>());
	priority_queue<int> pq;
	pq.push(a[0]);
	int ans = 0;
	FOR(i,1,n){
		ans += pq.top();
		pq.pop();
		rep(j,2){
			pq.push(a[i]);
		}
	}

	cout << ans << endl;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

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

int n, m;
char a[55][55], b[55][55];

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

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

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			cin >> b[i][j];
		}
	}

	for (int i = 0; i <= n-m; i++) {
		for (int j = 0; j <= n-m; j++) {
			bool same = 1;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (b[k][l] != a[i+k][j+l]) {
						same = 0;
					}
				}
			}

			if (same) {
				cout << "Yes\n";
				return 0;
			}
		}
	}

	cout << "No\n";
 
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int input[3] = {0};
	int i = 0;
	
	int five = 0;
	int seven = 0;
	
	scanf("%d %d %d", &input[0], &input[1], &input[2]);
	
	for(i = 0; i < 3; i++){
		if(5 == input[i]){
			five++;
		}else if(7 == input[i]){
			seven++;
		}
	}
	
	if(2 == five && 1 == seven){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	
	return 0;
		
}

Measured memory_bytes: 128
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define pb push_back
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
int n,q;
string s;
vi tree[2000009];
void build(int node,int l,int r){
    if(l == r){
        for(int i=0;i<26;i++) tree[node].pb(0);
        tree[node][s[l]-'a'] = 1;
        return;
    }
    build(node*2,l,mid);
    build(node*2+1,mid+1,r);
    for(int i=0;i<26;i++){
        tree[node].pb(0);
        tree[node][i] = tree[node*2][i];
        tree[node][i] += tree[node*2+1][i];
    }
}
void upd(int node,int l,int r,int k,char z){
    if(l == r){
        tree[node][s[l]-'a'] = 0;
        s[l] = z;
        tree[node][s[l]-'a'] = 1;
        return;
    }
    if(k <= mid) upd(node*2,l,mid,k,z);
    else upd(node*2+1,mid+1,r,k,z);
    for(int i=0;i<26;i++){
        tree[node][i] = tree[node*2][i];
        tree[node][i] += tree[node*2+1][i];
    }
}
vi query(int node,int l,int r,int s,int e){
    if(s <= l && e >= r) return tree[node];
    if(s <= mid && e > mid){
        vi a = query(node*2,l,mid,s,e);
        vi b = query(node*2+1,mid+1,r,s,e);
        vi ret;
        for(int i=0;i<26;i++){
            ret.pb(0);
            ret[i] = a[i]+b[i];
        }
        return ret;
    }
    if(s <= mid) return query(node*2,l,mid,s,e);
    return query(node*2+1,mid+1,r,s,e);
}
int main(){
    fast,cin>>n>>s>>q;
    build(1,0,n-1);
    while(q--){
        int t; cin>>t;
        if(t == 1){
            int id; char z;
            cin>>id>>z,id--;
            upd(1,0,n-1,id,z);
        }
        else{
            int l,r;
            cin>>l>>r;
            l--;r--;
            vi v = query(1,0,n-1,l,r);
            int curr = 0;
            for(int i=0;i<26;i++){
                curr += (v[i] > 0);
            }
            cout<<curr<<endl;
        }
    }
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> s(m);
    vector<int> c(m);
    rep(i,m) cin >> s.at(i) >> c.at(i);
    int ans = -1;
    int start,end;
    if(n == 1) start = 0,end = 10;
    else if(n == 2) start = 10,end = 100;
    else if(n == 3) start = 100,end = 1000;

    for(int i = start; i < end; i++) {
        string check = to_string(i);
        bool ok = true;
        rep(j,m){
            if((int)(check.at(s.at(j) - 1) - '0') != c.at(j)) ok = false;
        }
        if(ok) {ans = i; break;}
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;

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

ll mod_inv(ll x, ll mod) { return mod_pow(x, mod - 2, mod); }

ll mod_comb(int n, int k, ll mod) {
    if (n < k) return 0;
    if (n - k < k) k = n - k;
    ll x = 1, y = 1;
    for (int i = 0; i < k; i++) x = x * (n - i) % mod;
    for (int i = k; i > 0; i--) y = y * i % mod;
    return x * mod_inv(y, mod) % mod;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = (mod_pow(2, n, MOD) - 1) - mod_comb(n, a, MOD) - mod_comb(n, b, MOD);
    while (ans < 0) ans += MOD;
    cout << ans << endl;
}

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

int solve_testcase() {
  int N; cin >> N;
  if(N == 0) return 1;

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

  int ans = 0;
  for(int i=0; i<N; i++) {
    if(A[i] * N <= sum) ans++;
  }
  cout << ans << endl;
  
  return 0;
}

int main() {
  while(!solve_testcase());
  return 0;
}



Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String cubes = sc.nextLine();

		String cubeArray[] = cubes.split("");
		int arrayLength = cubeArray.length;
		int redCount = 0, blueCount = 0;
		for (String cube : cubeArray) {
			if (cube.equals("1")) {
				blueCount++;
			} else {
				redCount++;
			}
		}
		int remainderCubes = Math.abs(blueCount - redCount);
		System.out.println(arrayLength - remainderCubes);
	}

}


Measured memory_bytes: 34248
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S = "";
long long K;
char A;
long long cnt = 0; 

int main() {
	cin >> S;
	scanf("%lld", &K);
	for(int i = 0; i < S.size(); i++) {
		if(S[i] != '1') {
			A = S[i];
			break;
		}
		else {
			cnt++;
		}
	}
	if(K <= cnt) {
		printf("1\n");
	}
	else {
		cout << A;
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

using namespace std;

int main() {
    string n;
    cin>>n;
    long long sum=0;
    for(int i=0;i<n.size();i++)
        sum += n[i]-'0';

    if(sum%9==0)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define ull unsigned long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pul pair<ull,LL> 
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int mod=998244353;
template<typename T> void chkmin(T &x,T y) {if(y<x) x=y;}
template<typename T> void chkmax(T &x,T y) {if(y>x) x=y;}
template<typename T> void upd(T &x,T y) {if((x+=y)>=mod) x-=mod;}
int sl,fh;
db x;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	scanf("%lf",&x);
	printf("%.10lf\n",(x/3.0)*(x/3.0)*(x/3.0));
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
F = [LIST() for _ in range(N)]
P = [LIST() for _ in range(N)]

ans = -INF
for x in product([0, 1], repeat=10):
	x = list(x)
	if 1 in x:
		profit = 0
		for i in range(N):
			common = sum([x[j]*F[i][j] for j in range(10)])
			profit += P[i][common]
		ans = max(ans, profit)

print(ans)

Measured memory_bytes: 5200
#include <stdio.h>

int main() {
  int n, s[100000], q, t[50000], i, left, right, mid, count = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &s[i]);

  scanf("%d", &q);
  for(i = 0; i < q; i++)
    scanf("%d", &t[i]);

  for(i = 0; i < q; i++){
    left = 0;
    right = n;

    while(left < right){
      mid = (left + right)/2;

      if(s[mid] == t[i]){
	count++;
	break;
      }

      else if(s[mid] < t[i])
	left = mid + 1;
      else
	right = mid;
    }

  }

  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1184
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long A, B, C, D;
  cin >> A >> B >> C >> D;
  A += B;
  C += D;
  if (A < C) puts("Right");
  else if (A > C) puts("Left");
  else puts("Balanced");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int dx[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[8] = {-1, 0, 1, 1, -1, -1, 0, 1};
int main(){
  int H, W;
  scanf("%d %d", &H, &W);
  char c[H][W + 1];
  for(int i = 0; i < H; i++) scanf("%s", c[i]);
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(c[i][j] == '.'){
        int count = 0;
        for(int k = 0; k < 8; k++){
          int nx = i + dx[k], ny = j + dy[k];
          if(0 <= nx && nx < H && 0 <= ny && ny < W && c[nx][ny] == '#') count++;
        }
        c[i][j] = '0' + count;
      }
    }
  }
  for(int i =0 ; i < H; i++) printf("%s\n", c[i]);
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> A(n), B(n), C(n);
  rep(i,n) cin >> A[i];
  rep(i,n) cin >> B[i];
  rep(i,n) cin >> C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  vector<ll> res(n);
  ll temp = 0;
  for (int i = n-1; i >= 0; --i) {
    auto it = lower_bound(C.begin(), C.end(), B[i]+1) - C.begin();
    temp += C.size() - it;
    res[i] = temp;
  }
  ll ans = 0;
  rep(i,n) {
    auto it1 = lower_bound(B.begin(), B.end(), A[i]+1) - B.begin();
    if (it1 == n) break;
    ans += res[it1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
N=int(input())
D=[map(int, input().split()) for i in range(N)]
x, y = [list(i) for i in zip(*D)]

s=0
l=[]
for i in range(N):
  if x[i]==y[i]:
    s+=1
    if i==N-1:
      l.append(s)
  elif x[i]!=y[i]:
    l.append(s)
    s=0

if max(l)>=3:
  print("Yes")
else:
  print("No")

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M, Q; cin >> N >> M >> Q;
    vector<ll> p(Q), q(Q);

    // L, Rを二次元座標として，二次元累積和(長方形の差し引き)
    ll a[N][N]; rep(i, N){rep(j, N){a[i][j] = 0;}}
    ll s[N + 1][N + 1]; rep(i, N + 1){rep(j, N + 1){s[i][j] = 0;}}

    rep(i, M){ll l, r; cin >> l >> r; l--; r--; a[l][r]++;}
    rep(i, Q){cin >> p.at(i) >> q.at(i);}

    rep(i, N){rep(j, N){
        s[i + 1][j + 1] = s[i][j + 1] + s[i + 1][j] - s[i][j] + a[i][j];
    }}
    // rep(i, N + 1){rep(j, N + 1){cout << s[i][j] << " ";} cout << endl;}
    rep(i, Q){
        ll l = p.at(i) - 1, r = q.at(i);
        cout << s[r][r] + s[l][l] - s[r][l] - s[l][r] << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    
    int maxl = *max_element(l.begin(), l.end());
    int sum = 0;
    rep(i, n) sum += l[i];
    if (maxl < sum - maxl) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace AOJ.Volume5
{
    public class DataConversion
    {
        public static int Main()
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }

                // ASCII
                var map = new int[128];
                for(int i = 0; i < 128; i++) { map[i] = i; }

                for (int i = 0; i < n; i++)
                {
                    var input = Console.ReadLine();
                    char bef = input[0];
                    char aft = input[2];

                    map[(int)bef] = (int)aft;
                }

                n = int.Parse(Console.ReadLine());
                for(int i = 0; i < n; i++)
                {
                    char bef = Console.ReadLine()[0];
                    Console.Write((char)map[(int)bef]);
                }

                Console.Write("\n");
            }
            return 0;
        }
    }
}

Measured memory_bytes: 8828
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 3e5+5;
int l[MAX], c[MAX];
map<ii, bool> mp;
int L, C, ans;

int main(int argc, char ** argv) {
	int N, M, K, x, y;
	scanf("%d%d%d", &N, &M, &K);
	rep(i, 0, K) {
		scanf("%d%d", &x, &y);
		l[x]++; c[y]++;
		mp[mk(x, y)] = 1;
	}
	rep(i, 0, MAX) L = max(L, l[i]);
	rep(i, 0, MAX) C = max(C, c[i]);
	vector<int> numL, numC;
	rep(i, 0, MAX) if(l[i] == L) numL.pb(i);
	rep(i, 0, MAX) if(c[i] == C) numC.pb(i);
	rep(i, 0, numL.size()) {
		rep(j, 0, numC.size()) {
			if(mp.count(mk(numL[i], numC[j])))
				ans = max(ans, L+C-1);
			else ans = L+C;
			if(ans == L+C) break;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

bool broken[100005];

const long long MOD = 1e9+7;

long long memo[100005];

long long dp(int i){
	if(broken[i]){
		return 0;
	}else if(i == 0){
		return 1;
	}else if(i == 1){
		return 1;
	}else if(memo[i] != -1){
		return memo[i];
	}else{
		return memo[i] = (dp(i-2)+dp(i-1)) % MOD;
	}
}

int main(){
	int N, M;
	scanf("%d%d", &N, &M);
	
	memset(broken, 0, sizeof(broken));
	
	for(int i = 0; i < M; i ++){
		int x;
		scanf("%d", &x);
		broken[x] = 1;
	}
	
	memset(memo, -1, sizeof(memo));
	printf("%d", dp(N));
}


Measured memory_bytes: 2816
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {

	int n;
	cin >> n;
	vector <int> x(n);
	rep(i, n) cin >> x.at(i);
	sort(x.begin(), x.end());
	reverse(x.begin(), x.end());
	vector <int> mochi(1, 101);
	rep(i, n) {
		if (x.at(i) < mochi.at(0)) mochi.insert(mochi.begin(), x.at(i));
		else continue;
	}

	cout << mochi.size() - 1 << endl;


	return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

#[fastout]
fn main() {
  input!{
    n: usize,
    csf: [(usize, usize, usize); n-1]
  };

  for i in 0..n-1 {
    let mut time = 0;
    for j in i..n-1 {
      let (c, s, f) = csf[j];
      if time <= s {
        time = s+c;
      } else if time % f == 0 {
        time += c;
      } else {
        time += f - time % f + c;
      }
    }
    echo!(time);
  }
  echo!(0);
}


Measured memory_bytes: 2168
#include <cstdio>
#define ll long long int

int main(int argc, char const* argv[])
{
	int n, m, l;
	scanf("%d %d %d", &n, &m, &l);
	int ** a = new int*[n];
	int ** b = new int*[m];
	for(int i = 0; i < n; i++){
			a[i] = new int[m];
			for(int j = 0; j < m; j++){
					scanf("%d", a[i]+j);
			}
	}
	for(int i = 0; i < m; i++){
			b[i] = new int[l];
			for(int j = 0; j < l; j++){
					scanf("%d", b[i]+j);
			}
	}
	for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
					ll sum = 0;
					for(int k = 0; k < m; k++)sum += (ll)a[i][k]*b[k][j];
					if(j == l - 1)printf("%lld\n", sum);
					else printf("%lld ", sum);
			}
	}
	return 0;
}



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

int main(){
 int r,g,b;
  cin >> r >> g >> b;
  //４の倍数は下二桁が4の倍数だったらおｋっていうやつ
  int res = g * 10 + b;
  if(res % 4 == 0){
   cout << "YES" << endl; 
  }else{
   cout << "NO" << endl; 
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string.h>
#include<string>
#include<set>
#include<limits.h>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<functional>
#include<stack>
#include<deque>
#include<queue>
using namespace std;

signed main() {
	string a; cin >> a;
	a[3] = '8';
	cout << a << endl;
}

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

int main(){
  int n,a,b;
  int c = 0;
  int ans = 0;
  cin >> n;
  vector<int> num(n),A(n),B(n);
  
  for(int i=1;i<=n;i++) num.at(i-1) = i;
  for(int i=1;i<=n;i++) cin >> A.at(i-1);
  for(int i=1;i<=n;i++) cin >> B.at(i-1);
  do{
    bool aa = true, bb = true;
    for(int i=0;i<n;i++){
      if(num.at(i) != A.at(i)) aa = false;
      if(num.at(i) != B.at(i)) bb = false;
    }
    c++;
    if(aa) a = c;
    if(bb) b = c;
  }while(next_permutation(num.begin(),num.end()));    
  if(a >= b) ans = a-b;
  else ans = b-a;
  cout << ans << endl;
}


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

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        cout << A[i] << " ";
    }
    cout << endl;
}

inline void solve() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a == 5 && b == 5 && c == 7) {
        cout << "YES" << endl;
    } else if (a == 5 && b == 7 && c == 5) {
        cout << "YES" << endl;
    } else if (a == 7 && b == 5 && c == 5) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3616
MODD = 10**9 + 7 

def modinv(a,m)-> int:
    b = m
    u = 1
    v = 0
    while (b):
        t = a // b
        a -= t * b
        a,b= b,a
        u -= t * v
        u,v= v,u
    u %= m
    if (u < 0):
        u += m
    return u


fac=[1]*200001
infac=[1]*200001
aaa=1
for i in range(1,200001):
    aaa=(aaa*i)%MODD
    fac[i]=aaa
    infac[i]=modinv(aaa,MODD)
    #print(fac[i])

import math as m

def perm(x,y,z) -> int:
    #print(fac[x]//(fac[y]*fac[z]))   
    return ((fac[x]*infac[y]*infac[z])%MODD)

h,w,a,b= [int(x) for x in input().split()]
A = h-a
B = b-1
C = h-1
D = w-b-1
j=0
k=B
kl = C
jl = D
ans = 0
for i in range(A):
  ans+=perm(B+i,B,i)*perm(C+D-i,C-i,D)
print(ans%MODD)

Measured memory_bytes: 24804
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		char[] x = sc.next().toCharArray();
		ArrayDeque<Character> deque = new ArrayDeque<>();
		for (int i = 0; i < x.length; i++) {
			if (x[i] == 'S') {
				deque.push(x[i]);
			} else {
				if (deque.isEmpty()) {
					deque.push(x[i]);
				} else if (deque.peek() == 'S') {
					deque.pop();
				} else {
					deque.push(x[i]);
				}
			}
		}
		System.out.println(deque.size());
	}
}


Measured memory_bytes: 27960
void main()
{
    int n = readln.chomp.to!int;
    dchar[] s = readln.chomp.to!(dchar[]);

    foreach (i; 0 .. s.length)
    {
        foreach (j; 0 .. n)
        {
            if (s[i] == 'Z')
            {
                s[i] = 'A';
            }
            else
            {
                s[i] = s[i].to!string.succ.to!dchar;
            }
        }
    }

    s.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int main() {
    int n;
	scanf("%d",&n);
	int h[n];
	for(int i=0;i<n;i++)scanf("%d",&h[i]);
	int dp[n];
	for(int i=0;i<n;i++)dp[i]=2000000010;
	dp[0]=0;
	for(int i=0;i<n-1;i++){
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
		if(i+2<n)dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
	}
	printf("%d",dp[n-1]);
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0;
vl flag, color; vll path;
//***********//
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	ll count = 1;
	ll key = A[0];
	for (i = 0; i < N-1; i++) {
		if (A[i] == A[i + 1]) {
			count++;
		}
		else {
			if (count < key) {
				ans += count;
			}
			else {
				ans += count-key;
			}
			count = 1;
			key = A[i + 1];
		}
		//debug(i, ans);
	}
	if (count < key) {
		ans += count;
	}
	else {
		ans += count-key;
	}
	cout << ans;
}


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

int n, A[500010];

void maxheap(int key){
	int l,r,largest;
	l=2*key;
	r=2*key+1;
	if(l<=n&&A[l]>A[key]){
		largest=l;
	}
	else{
		largest=key;
	}
	if(r<=n&&A[r]>A[largest]){
		largest=r;
	}
	if(largest!= key){
		swap(A[largest],A[key]);
		maxheap(largest);
	}
}

int main() {
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>A[i];
	}
	for(int i=n/2;i>=1;i--){
		maxheap(i);
	}
	for(int i=1;i<=n;i++){
		printf(" %d",A[i]);
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 5096
from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

N = int(input())
a = getlist()
b = getlist()
c = [b[i] - a[i] for i in range(N)]

n = sum(c)
if n < 0:
	print("No")
else:
	m = 0
	for i in range(N):
		x = c[i]
		if x >= 1:
			if x % 2 == 0:
				m += x // 2
				c[i] = 0
			else:
				m += x // 2 + 1
				c[i] = -1
	if n >= m:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 4856
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}
int main() {
	int N = 0, K = 0,a=0,ans= 1000000009,sum=0;
	vector<int>minu, plu;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a < 0) {
			minu.insert(minu.begin(), a);
		}
		else {
			plu.push_back(a);
		}
	}
	for (int i = 0; i <= K; i++) {
		if (plu.size() >= i && minu.size() >= K - i) {
			if (i == 0) {
				sum = abs(minu[K - 1]);

			}
			else if (i == K) {
				sum = plu[i-1];
			}
			else {
				sum = plu[i - 1] + abs(minu[K - i - 1]);
				sum += min(plu[i - 1], abs(minu[K - i - 1]));
			}
			
			ans = min(ans, sum);
		}
	}
	cout << ans << endl;
	return 0;
}

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

LL A, B, C, D;
map<LL, LL> memo;
LL solve(LL N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    if (memo.count(N)) return memo[N];
    LL l2 = (N/2)*2;
    LL r2 = ((N+1)/2)*2;
    LL l3 = (N/3)*3;
    LL r3 = ((N+2)/3)*3;
    LL l5 = (N/5)*5;
    LL r5 = ((N+4)/5)*5;

    LL res = 1e18;
    if (N < res/D) res = N*D;
    res = min(res, llabs(l2-N)*D + A + solve(l2/2));
    res = min(res, llabs(r2-N)*D + A + solve(r2/2));

    res = min(res, llabs(l3-N)*D + B + solve(l3/3));
    res = min(res, llabs(r3-N)*D + B + solve(r3/3));

    res = min(res, llabs(l5-N)*D + C + solve(l5/5));
    res = min(res, llabs(r5-N)*D + C + solve(r5/5));

    memo[N] = res;

    return res;
}

int main() {
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        LL N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << "\n";
    }

}


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

#define f(i,a,b) for(  ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

#define PI acos(-1)

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

const ll MAX = 1e3+12;
const ll inf = 5e18;


int main(){
	fastio;
	ll tc,n,m;
//	cin>>tc;
	tc=1;
	string s;
	f(tt,1,tc+1){
		cin>>n;
		ll a = n/3,b = n/5,c=n/15;
		ll ans = (n*(n+1))/2 - (3LL*a*(a+1))/2 - (5LL*b*(b+1))/2 + (15LL*c*(c+1))/2;
		cout<<ans<<endl;
	}

}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n ;
	cin>> n ;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int count = 0 ;
	rep(i,n){
		if(a[i] %2 == 0 ) count ++ ;
	}
	if(count == n) {
		cout << "second"<<endl;
	}else cout << "first"<<endl;
}


Measured memory_bytes: 640
import math
import itertools

def gcd(a,b,c):
    return math.gcd(math.gcd(a,b),c)

K = int(input())
abc = itertools.combinations_with_replacement(list(range(1,K+1)),3)

ans = 0
for a,b,c in abc:
    p = len(set([a,b,c]))
    if p==1:
        ans += gcd(a,b,c)
    elif p==2:
        ans += gcd(a,b,c) * 3
    else:
        ans += gcd(a,b,c) * 6
print(ans)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  int s;
  cin >> s;
  if(s == 7 | s == 5 | s == 3)
    cout << "YES" << endl;
  else 
    cout << "NO" << endl;
}

Measured memory_bytes: 3632
//https://atcoder.jp/contests/dp/tasks/dp_q
// use of upper bound and lower bound on map
# include <bits/stdc++.h>
using namespace std;
#define int long long int
struct flower
{
	int h;
	int b;
};
int bottom(flower f[], int n)
{
	map<int, int> m;//only stores the eligble elements'
	//that too in increasing order enabling us to
	//use upperbound fxn in just logn complexity
	int dp[n + 1];
	dp[0] = f[0].b;
	m[f[0].h] = f[0].b;
	int ans = f[0].b;
	for (int i = 1; i < n; i++)
	{
		dp[i] = f[i].b;
		auto it = m.upper_bound(f[i].h);
		auto it2 = it;
		if (it != m.begin())
		{
			it--;
			dp[i] += it->second;
		}
		it = it2;
		while (it != m.end() && it->second <= dp[i])
		{
			auto temp = it;
			temp++;
			m.erase(it);
			it = temp;
		}
		m[f[i].h] = dp[i];
		ans = max(ans, dp[i]);
	}
	return ans;
}
int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n;
	cin >> n;
	flower f[n];
	for (int i = 0; i < n; i++)
	{
		cin >> f[i].h;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> f[i].b;
	}
	cout << bottom(f, n);
}
// 9
// 4 2 5 8 3 6 1 7 9
// 6 8 8 4 6 3 5 7 5

// 31


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  static const ll MAX = 100010LL;
  ll N, A[3][MAX], dp[3][MAX];

  void init() {
    scanf("%lld", &N);
    rep(i, N) rep(j, 3) cin >> A[j][i];
  }

  void solve() {
    ll ans = 0;
    rep(j, 3) dp[j][0] = 0;
    rep(i, N) rep(j, 3) {
      dp[j][i+1] = 0;
      rep(k, 3) if(j!=k) {
        dp[j][i+1] = max(dp[j][i+1], dp[k][i] + A[j][i]);
        ans = max(ans, dp[j][i+1]);
      }
    }
    cout << ans << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	int n, a, b;
	cin >> n >> a >> b;

	vector<ll> arr(n);
	for(auto& i: arr) cin >> i;

	using BIG = __int128_t;

	BIG ans = 1e18;
	BIG lb = 0, ub = 1e18;

	while(lb <= ub){
		BIG mid = (lb + ub) / 2;

		BIG moves = 0;

		for(auto i: arr){
			BIG num = i - mid * b;
			if(num > 0) moves += (num + a - b - 1) / (a - b);
		}

		if(moves > mid){
			lb = mid + 1;
		}
		else{
			ans = mid;
			ub = mid - 1;
		}
	}

	assert(ans <= 4e18);

	cout << (ll)ans << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3964
N, X = map(int, input().split())
L = list(map(int, input().split()))
pref_sum = [0]*(N+1)
ans = 0

for i in range(N):
    pref_sum[i+1] = L[i]+pref_sum[i]



for s in pref_sum:
    if s <= X:
        ans += 1     
print(ans)

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

int main(void){

    string S; cin>>S;
    int N =S.size();
    int ans = N;
    for (int i = 0; i < N-1;) {
        if(S[i]==S[i+1]){
            ans--;
            i+=3;
        }else{
            i++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
from math import ceil
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

"""
目標とする最長の長さをxとして、それをk回で達成
できるか
aをソートしたので、途中でkを超えることが判明したら打ち切る
"""

def isOK(x):
    cnt = 0
    for _a in a:
        if _a<=x:
            return True
        try:
            cnt+=_a//x
        except:
            return False
        if cnt>k:
            return False
    return True

ng = 0
ok = 10**9+1

while abs(ng-ok)>0.1:
    mid = (ng+ok)/2
    if isOK(mid):
        ok = mid
    else:
        ng = mid
    if ok < 1:
        break
ok = ceil(ok)
if isOK(ok-1):
    print(ok-1)
else:
    print(ok)


Measured memory_bytes: 31220
program ABC059B
    implicit none
    integer(8)::i
    character(100)::A,B
    integer(8)::flg=0
    read(5,*)A,B

    if(len_trim(A)>len_trim(B))then
        flg=1
    else if(len_trim(A)<len_trim(B))then
        flg=2
    else
        do i=1,len_trim(A)
            if(ichar(A(i:i))>ichar(B(i:i)))then
                flg=1
                exit
            else if(ichar(A(i:i))<ichar(B(i:i)))then
                flg=2
                exit
            end if
        end do
    end if

    if(flg==1)then
        print'(A)',"GREATER"
    else if(flg==2)then
        print'(A)',"LESS"
    else
        print'(A)',"EQUAL"
    end if
end program ABC059B

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

void debug(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;

    int a[n];
    set<pair<int,int>> st;
    for(int i=0; i<n; i++){
    	cin>>a[i];
    	st.insert(make_pair(a[i],i+1));
    }

    for(auto i:st){
    	cout<<i.second<<" ";
    }

    return 0;
  }

Measured memory_bytes: 8632
import math
import collections
from operator import mul
from functools import reduce
import bisect

#n,m=map(int,input().split())

s=input()
k=int(input())
a=[]
for i in range(len(s)):
    for j in range(i+1,min(i+2+k,len(s)+1)):
        a.append(s[i:j])
a=sorted(list(set(a)))
print(a[k-1])









Measured memory_bytes: 41328