akhauriyash/Code-Regression huggingface dataset:
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

struct Integer{
public:
    ll gcd(ll a,ll b){return b ? gcd(b, a % b) : a;}
    ll lcm(ll a,ll b){return a / gcd(a, b) * b;}

    bool isPrime(ll x){
        if(x < 2) return false;
        if(x == 2) return true;
        if(x % 2 == 0) return false;
        for(ll i = 3;i <= sqrt(x) + 1;i += 2) if(x % i == 0) return false;
        return true;
    }

    vector<ll> divisor(ll M){
        vector<ll> dd;
        for(ll i = 1; i * i <= M; i++){
            if(M % i == 0){
                dd.push_back(i);
                if(i * i != M) dd.push_back(M / i);
            }
        }
        sort(dd.begin(), dd.end());
        return dd;
    }

    vector<ll> factor(ll M){ //素因数分解
        vector<ll> dd;
        if(M == 1){
            dd.push_back(1);
            return dd;
        }
        for(ll i = 2; i*i <= M; i++){
            while(M % i == 0){
                dd.push_back(i);
                M /= i;
            }
        }
        if(M != 1) dd.push_back(M);
        sort(dd.begin(), dd.end());
        return dd;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    Integer it;
    vector<ll> d = it.divisor(X);
    for(auto &e: d){
        ll v = 1;
        rep(a,0,5000){
            ll b = a - e;
            ll v1 = 1;
            rep(i,0,5) v1 *= a;
            ll v2 = 1;
            rep(i,0,5) v2 *= b;
            if(v1 - v2 == X){
                print(a,b);
                return 0;
            }
        }
    }
    
    

}

Measured memory_bytes: 3676
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    cins(all(a));
    ll ans = a[0]-1,m = 2;
    rep(i,1,n){
        if (a[i] == m){
            m++;
            continue;
        }
        if (a[i]%m == 0){
            ans += a[i]/m-1;
        }
        else{
            ans += a[i]/m;
        }
    }
    PRINT(ans);
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,t;
  cin >> n >> t;
  ll sum=0,M=0;
  rep(i,n) {
    ll x;
    R x;
    M=max(M,x);
    pr(max(1LL,(ll)ceil((double)(t-sum-x+1)/M)+1));
    sum+=x;
  }
}

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


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    string s;
    cin >> s;
    int a[4];
    int num = stoi(s);
    rep(i, 4) {
        a[3 - i] = num % 10;
        num /= 10;
    }
    rep(i, 8) {
        int ans = a[0];
        rep(j, 3) {
            if (i & (1 << j)) {
                ans += a[j + 1];
            } else {
                ans -= a[j + 1];
            }
        }
        if (ans == 7) {
            cout << a[0];
            rep(j, 3) {
                if (i & (1 << j)) {
                    cout << "+";
                } else {
                    cout << "-";
                }
                cout << a[j + 1];
            }
            cout << "=7" << endl;
            break;
        }
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  //input
  int n;cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int counter = 0;
  
  //compute
  for(int i = 0; i < n; i++) a[i] = a[i] - 1;
  for(int i = 0;i < n; i++) {
         if(a[a[i]] == i){
           counter += 1;
         }
  }
  int ans;
  ans = counter / 2;
 
  //output
  cout << ans << endl;
  
}

Measured memory_bytes: 3764
n = int(input())
tree = list(map(int, input().split()))

for i in range(n) :
    s = 'node ' + str(i + 1) + ': key = ' + str(tree[i])
    if (i > 0) & (i % 2 == 0) :
        s += ', parent key = ' + str(tree[i // 2 - 1])
    elif (i > 0) & (i % 2 == 1):
        s += ', parent key = ' + str(tree[i // 2])

    if i * 2 + 2 < n :
        s += ', left key = ' + str(tree[i * 2 + 1]) + ', right key = ' + str(tree[i * 2 + 2])
    elif i * 2 + 1 < n :
        s += ', left key = ' + str(tree[i * 2 + 1])

    print(s, ', ', sep = '')



Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

vector<pair<char,int>> vp;
vector<pair<char,int>> vp2;

void merge(int left,int right) {
    int mid = (left+right)/2;
    int n1 = mid - left;
    int n2 = right - mid;
    vector<pair<char,int>> l(n1+1,pair<char,int>('x',INF)),r(n2+1,pair<char,int>('x',INF));
    REP(i,n1) l[i] = vp2[left+i];
    REP(i,n2) r[i] = vp2[mid+i];
    int i = 0, j = 0;
    FOR(k,left,right) {
        if (l[i].second <= r[j].second) vp2[k] = l[i++];
        else vp2[k] = r[j++];
    }
}
void merge_sort(int left, int right) {
    if((left+1) >= right) return;
    int mid = (right-left)/2 + left;
    merge_sort(left,mid);
    merge_sort(mid,right);
    merge(left,right);
}

int partition(int p,int r) {
    auto x = vp[r].second;
    auto i = p - 1;
    FOR(j,p,r) {
        if (vp[j].second <= x) {
            i++;
            iter_swap(vp.begin()+i,vp.begin()+j);
        }
    }
    iter_swap(vp.begin()+i+1,vp.begin()+r);
    return i+1;
}

void quick_sort(int p,int r) {
    if (p < r) {
        auto q = partition(p,r);
        quick_sort(p,q-1);
        quick_sort(q+1,r);
    }
}


void solve() {
    int n;
    cin >> n;
    vp.resize(n);
    vp2.resize(n);

    REP(i,n) {
        char c; int v;
        cin >> c >> v;
        vp[i] = make_pair(c,v);
        vp2[i] = make_pair(c,v);
    }

    quick_sort(0,n-1);
    merge_sort(0,n);
    bool is_stable = true;
    REP(i,n) {
        if(vp[i].first != vp2[i].first) {
            is_stable = false;
            break;
        }
    }

    cout << ((is_stable) ? "Stable" : "Not stable") << endl;
    for(const auto &p : vp) {
        cout << p.first << " " << p.second << endl;
    }
}

int main() {
    solve();
    return 0;
}


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

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (h[i] >= k) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 47532
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int blue = 0, red = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0') ++red;
        else            ++blue;
    }
    cout << 2 * (red < blue ? red : blue) << endl;
    return 0;
}

Measured memory_bytes: 512
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	k,x := scanInt(), scanInt()

	if k*500 >= x {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main(){
    long long int a;
    long long int b;
    long long int c;
    long long int d;

    //入力
    cin >> a >> b >> c >> d;

    long long int ans;
    ans = max(a*c,a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int arr[100];
int checkSorted(int n, int arr[])
{

    int first = 0, second = 0;
    int count = 0;
    for (int i = 1; i < n; i++) {
        if (arr[i] < arr[i - 1]) {
            count++;
            if (first == 0)
                first = i;
            else
                second = i;
        }
    }

    if (count > 2)
        return false;
    if (count == 0)
        return true;

    if (count == 2)
        swap(arr[first - 1], arr[second]);

    else if (count == 1)
        swap(arr[first - 1], arr[first]);
    for (int i = 1; i < n; i++)
        if (arr[i] < arr[i - 1])
            return false;

    return true;
}

int main()
{
    int n,i;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>arr[i];
    if (checkSorted(n, arr))
        cout << "YES"<<endl;
    else
        cout << "NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int[] A = new int[N];
		
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		
		int min, tmp, cnt = 0;
		
		for(int i = 0; i < N - 1; i++) {
			min = i;
			
			for(int j = i + 1; j < N; j++) {
				if(A[min] > A[j]) {
					min = j;
				}
			}
			
			if(min != i) {
				tmp = A[min];
				A[min] = A[i];
				A[i] = tmp;
				
				cnt++;
			}
		}
		
		for(int i = 0; i < N; i++) {
			if(i == N - 1) {
				System.out.println(A[i]);
			} else {
				System.out.print(A[i] + " ");
			}
		}
		
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26412
#include <bits/stdc++.h>
typedef long long ll;
const int MOD = 1e9 + 7;
using namespace std;
//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    ll n, k, a[100 + 10], dp[100 + 10][100 + 10][255 + 100], add = 1, ans = 0;
    //こういうのはDP、とるか否かの2通りで
    //dp[i][j][k] := i番目まで、jが数列の長さ, kがxorしたやつの値
    cin >> n >> k;
    for(int i = 0; i < n ; i++){
        cin >> a[i];
    }

    for(int i = 0; i < n + 5; i++){
        for(int j = 0; j < n + 1 + 5; j++){
            for(int kk = 0; kk < 350; kk++){
                dp[i][j][kk] = 0;
            }
        }
    }
    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n + 1; j++){
            for(int kk = 0; kk < 340; kk++){
                (dp[i + 1][j][kk] += dp[i][j][kk]) %= MOD;
                if(j != 0){
                (dp[i + 1][j][kk] += dp[i][j - 1][kk ^ a[i]]) %= MOD;
                }
            }
        }
    }
    for(int i = 1; i < n + 1; i++){
        (add *= i) %= MOD;
        (ans += (dp[n][i][k] * add) % MOD) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 33792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int a[100005];
int main()
{
	int n;
	int t,x,y,k,m=0,x1=0,y1=0,t1=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t>>x>>y;
		k=abs(x-x1)+abs(y-y1);
		if(((t-t1)-k)%2==0&&(t-t1)-k>=0)
		a[i]=1;
		else
		a[i]=0;
		x1=x;
		y1=y;
		t1=t;
    }
    int i;
    for(i=1;i<=n;i++)
    {
    	if(a[i]==0)
    	{
    		printf("No\n");
    		break;
		}
	}
	if(i>n)
	printf("Yes\n");
return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define F first
#define S second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(n) for(int i=0;i<n;i++)
#define rf(n) for(int i=n-1;i>=0;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
using namespace __gnu_pbds;
using namespace std;
signed main()
{
	int n;
	cin>>n;
	double ans=0;
	if(n%3==0)
	{
		ans+=((n/3)*(n/3)*(n/3));
		printf("%.12lf",ans);
		return 0;
	}
	double val=(double)n/3;
	double val1=(double)n/3;
	double val2=(double)n-val-val1;
	ans+=(val*val1*val2);
	printf("%.12lf",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back







int main()
{

	ll n;
	cin >> n;

	ll arr[n + 1][3];
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= 2; j++)
			cin >> arr[i][j];
	}

	for (int i = 2; i <= n; i++)
	{
		arr[i][0] = arr[i][0] + max(arr[i - 1][1], arr[i - 1][2]);
		arr[i][1] = arr[i][1] + max(arr[i - 1][0], arr[i - 1][2]);
		arr[i][2] = arr[i][2] + max(arr[i - 1][0], arr[i - 1][1]);
	}


	cout << max(arr[n][0], max(arr[n][1], arr[n][2])) << endl;

}





Measured memory_bytes: 2688
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>

int main(){
    double a, b, x;
    std::cin >> a >> b >> x;

    double ref = a * b / 2, filled = x / a, ans = 0;
    if(filled <= ref){
        ans = M_PI / 2 - std::atan2(2 * filled, std::pow(b, 2));
    }else{
        ans = std::atan2(2 * (a * b - filled), std::pow(a, 2));
    }
    
    std::cout << std::fixed << std::setprecision(7) << ans / M_PI * 180 << std::endl;

    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int k;
	cin>>k;
	int ans=0;
	for(int a=1;a<=k;++a){
		for(int b=1;b<=k;++b){
			for(int c=1;c<=k;++c){
				int tmp=gcd(min(b,c),abs(b-c));
				ans+=gcd(min(a,tmp),abs(a-tmp));
			}
		}
	}
	cout<<ans<<"\n"s;
}

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

namespace contest_Csharp
{

    class Program
    {
        public static (long m, long s)[,] dp;

        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);

                var vals = Console.ReadLine().Split(' ').
                    Select(x => long.Parse(x)).ToList();

                
                var N = vals[0];
                //var X = vals[1];
                //var T = vals[2];
                var A= Console.ReadLine().Split(' ').
                    Select(x => long.Parse(x)).ToList();

                long height = 0;
                long ans = 0;
                for (int i = 0; i < N; i++)
                {
                    height = Math.Max(height, A[i]);
                    ans += height - A[i];
                }

                Console.WriteLine(ans);

                Console.Out.Flush();
            }




        }
    }

}




Measured memory_bytes: 47700
def examB():
    N = I()
    A = LI()
    cur = -1
    flag=True
    while(flag):
        for i in range(N):
            if A[i]%2==1:
                flag = False
                break
            A[i]=A[i]//2
        cur +=1
    print(cur)

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


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

struct data{
  int a;
  int b;
  int c;
};

int main(){
  int N;cin>>N;
  struct data hap[N];
  for(int i=0;i<N;i++){
    cin>>hap[i].a>>hap[i].b>>hap[i].c;
  }
  struct data dp[N];
  
  dp[0]=hap[0];
  
  
  for(int i=1;i<N;i++){
    dp[i].a=max(dp[i-1].b,dp[i-1].c)+hap[i].a;
    dp[i].b=max(dp[i-1].c,dp[i-1].a)+hap[i].b;
    dp[i].c=max(dp[i-1].a,dp[i-1].b)+hap[i].c;
  }
  
  cout<<max({dp[N-1].a,dp[N-1].b,dp[N-1].c})<<endl;
  
  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

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

	n = 1000 - (n % 1000);
	if (n % 1000 != 0)
		cout << n;
	else
		cout << 0;

	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(j,a,b) for(int j = a; j < (b); j++)
using namespace std;
using ll = long long;

int r[1001];

int main() {

	int a, b;
	int N;
	cin >> a >> b >> N;
	vector<int> s(N);
	vector<int> f(N);
	rep(i, N) {
		cin >> s[i] >> f[i];
		rep2(j, s[i], f[i]) {
			r[j] = 1;
		}
		r[f[i]] = 2;
   }
	int ans = 0;
	rep2(i, a, b) {
		if (r[i] == 1 || r[i] == 2) {
			ans = 1;
			break;
		}
	}
	if (r[a] == 2) {
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3100
from math import ceil
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
idx = 0
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
tA = [ceil(A[i]/10)*10 for i in range(len(A))]
print(sum(tA)+ans)

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

// int dp[205][10];

// int findnum(int k, int x) {
//     if (dp[k][x] != -1) return dp[k][x];
//     if (k == 1) return dp[k][x] = 1;
//     int res = 0;
//     for (int i = max(0, x - 1); i <= min(9, x + 1); i++) res += findnum(k - 1, i);
//     return dp[k][x] = res;
// }

// string solve(int K, int pre = -1) {
//     cerr << K << pre << endl;
//     for (int k = 2; k < 200; k++) {
//         if (pre == -1) {
//             for (int i = 1; i <= 9; i++) {
//                 int num = findnum(k, i);
//                 if (K >= num) K -= num;
//                 // else return to_string(i) + solve(K, i);
//                 // else return "raawfeaa";
//                 else {
//                     cout << "aweni" << endl;
//                     string res = to_string(i);
//                     return "fdafa";
//                 }
//             }
//         } else {
//             for (int i = max(pre - 1, 0); i <= min(pre + 1, 9); i++) {
//                 int num = findnum(k, i);
//                 if (K >= num) K -= num;
//                 // else return to_string(i) + solve(K, i);
//                 // else return "reavrae";
//                 else {
//                     cout << "ien3" << endl;
//                     string res = to_string(i);
//                     return "arbae";
//                 }
//             }
//         }
//     }
//     return "a";
// }

int main() {
    int K;
    scanf("%d", &K);
    // memset(dp, -1, sizeof(dp));
    deque<string> q;
    for (int i = 1; i <= 9; i++) q.push_back(to_string(i));
    // return 0;
    for (int i = 0; i < K - 1; i++) {
        string cur = q.front(); q.pop_front();
        int last = cur[cur.size() - 1] - '0';
        for (int j = max(last - 1, 0); j <= min(9, last + 1); j++) {
            q.push_back(cur + to_string(j));
        }
    }
    cout << q.front() << endl;
    return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
long long int ans=0;
#define  ll long long
//最大公約数
long long int getgcd(long long n, long long m)
{
  int r;
  if (n > m) {
    long long t = m;
    m = n;
    n = t;
  }
  while ((r = m % n) != 0) {
    m = n;
    n = r;
  }
return n;
}

//nの階乗を計算
long long factorial(long long n){
    long long int answer = 1;
while(n > 1){
  answer *= n;
  n--;
}
    return answer;
}

//組み合わせの数nCrを計算
long long calcNumOfCombination(long long  n, long long r){
    return factorial(n) / (factorial(r) * factorial(n-r));
}
 void yes(){
   printf("Yes\n");
 }

 void no(){
   printf("No\n");
 }

int main(int argc, char* argv[]){
	ll a = 0, b = 0,c=0,e=0;
  char h[20],l[20];
  scanf("%s %s",l,h);
  for (int i = 0; i < strlen(l); i++) {
    if (l[i]!=h[i]) {
      a=1;
    }
  }
  if (a==0) {
    yes();
  }else{
    no();
  }
}


Measured memory_bytes: 1664
k = int(input())
now = 7%k
if now == 0:
    print(1)
    exit()
ans = 1
for i in range(k+1):
    ans += 1
    now *= 10
    now += 7
    now %= k
    if now == 0:
        break
if now == 0:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 9136
ab=list(map(int,input().split()))
a=ab[0]+ab[1]
b=ab[0]*ab[1]
c=ab[0]-ab[1]
flag=0
if a>b:
  if a>c:
    print(a)
    flag=1
else:
  if b>c:
    print(b)
    flag=1
if flag==0:
  print(c)


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

i = 1

while i <= n:
    x = i
    if x%3 == 0:
        print(" "+ str(i), end="")
        i += 1
        continue
    while x:
        if x%10 == 3:
            print(" "+ str(i), end="")
            break
        x //= 10
    
    i += 1
print()


Measured memory_bytes: 5872
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <fstream>
#include <complex>
#include <math.h>

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 pair<long, long> PLL;
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(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

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

const long double EPS = 1e-12;
const LL INF = 1e18;

int month[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
string yobi[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
int main(){
	int mm,dd;
	while(cin>>mm>>dd){
		if(mm==0&&dd==0)break;
		int day=0;
		for(int i=1;i<=12;i++){
			if(mm==i){
				day+=dd-1;
				break;
			}
			day+=month[i];
		}
		cout<<yobi[day%7]<<endl;
	}
	return 0;
}
/*

*/

Measured memory_bytes: 1192
N = gets.to_i
hs = [[0, 0, 0]]
N.times {hs << gets.split.map(&:to_i)}

dp = [[0, 0, 0]]

1.upto(N) do |i|
  dp << [
      [dp[i - 1][1] + hs[i][0], dp[i - 1][2] + hs[i][0]].max,
      [dp[i - 1][0] + hs[i][1], dp[i - 1][2] + hs[i][1]].max,
      [dp[i - 1][0] + hs[i][2], dp[i - 1][1] + hs[i][2]].max
  ]
end

puts dp.last.max

Measured memory_bytes: 15996
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int k, x;
    cin >> k >> x;
    int n=x-k+1;
    for(int i=0; i<k*2-1; i++){
        cout << n << endl;
        n++;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
int dp[100005];
int w[100005];int v[100005];
int n,W;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>W;
    for (int i=1;i<=n;++i) cin>>w[i]>>v[i];
    for (int i=0;i<100005;++i) dp[i]=1e9+9;
    dp[0]=0;
    for (int i=1;i<=n;++i){
    	for (int j=100000;j>=v[i];--j){
    		dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
	for (int j=100000;j>=0;--j) if (dp[j]<=W){
		cout<<j<<endl;return 0;
	}
    return 0; 
}

Measured memory_bytes: 640
sx, sy, tx, ty = gets.split.map(&:to_i)

dx = tx - sx
dy = ty - sy

puts [
  'U' * dy + 'R' * dx,
  'D' * dy + 'L' * dx,
  'L' + ('U' * (dy + 1)) + ('R' * (dx + 1)) + 'D',
  'R' + ('D' * (dy + 1)) + ('L' * (dx + 1)) + 'U',
].join

Measured memory_bytes: 1788
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

lin n;

lin sum(lin l)
{
    lin t = l;
    lin result = 0;

    while (t > 0)
    {
        lin d = t % 10;
        result += d;
        t /= 10;
    }

    return result;
}

int main(void)
{
    cin >> n;

    lin b = 1;
    lin result = sum(n);

    while (b < n)
    {
        lin nn = n / b * b - 1;

        //cout << nn << endl;

        result = max(result, sum(nn));
        b *= 10;
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b==c+d) {
        cout<<"Balanced"<<endl;
    } else if(a+b>c+d) {
        cout<<"Left"<<endl;
    } else {
        cout<<"Right"<<endl;
    }
    return 0;
}


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

using namespace std;
const int MAXN = 4e5 + 5;
#define ll long long
int n;
ll d[MAXN], f[MAXN][2];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", d + i);
	f[1][1] = -1e18;
	for (int i = 2; i <= n; i ++) {
		if (i & 1) {
			f[i][1] = max(max(f[i - 3][1], f[i - 3][0]), max(f[i - 2][1], f[i - 2][0])) + d[i];
			f[i][0] = f[i - 2][0] + d[i - 1];
		}
		else {
			f[i][1] = max(f[i - 2][1], f[i - 2][0]) + d[i];
			f[i][0] = f[i - 2][0] + d[i - 1];
		} 
	} 
	printf("%lld\n", max(f[n][0], f[n][1]));
	return 0;
} 

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

using namespace std;
using ll = long long;

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

    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> c[i][j];
        }
    }

    int ans = 0, black = 0;
    for(int bi = 0; bi < 1 << h; ++bi) {
        for(int bj = 0; bj < 1 << w; ++bj) {
            black = 0;
            for(int i = 0; i < h; ++i) {
                for(int j = 0; j < w; ++j) {
                    if(bi >> i & 1 && bj >> j & 1 && c[i][j] == '#') black++;
                }
            }
            if(black == k) ans++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 3744
n = int(input())
As = list(map(int, input().split()))

HowManySubordinate = []
for i in range(n):
    HowManySubordinate.append(0)

for i in range(n-1):
    t = As[i] - 1
    HowManySubordinate[t] += 1

for i in range(len(HowManySubordinate)):
    print(HowManySubordinate[i])

Measured memory_bytes: 32364
import math
N,M=map(int, input().split())
if abs(N - M) > 1:
  print(0)
elif N == M:
  print((2*math.factorial(N)*math.factorial(M))%int(1e9+7))
else:
  print((math.factorial(N)*math.factorial(M))%int(1e9+7))

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9;
const int MOD=1e9+7;
const int MAXN=1e3+7;

int ans=INF;
int n,m,k,q;
int a[MAXN];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    FOR(i,0,n)cin>>a[i];
    FORE(j,1,100){
        int tans=0;
        FOR(i,0,n){
            int x=a[i]-j;
            tans+=x*x;
        }
        ans=min(ans,tans);
    }
    cout<<ans<<"\n";
    return 0;
}


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

int main() {
    int x;
    cin >> x;
    int ans = 0;
    for(int i = x;i < 1e6;i++){
        for(int j = 1; j * j <= i; j++){
            ans = i;
            if(i % j == 0 && j != 1 && i != j){
                ans = 0;
                break;
            }
        }
        if(ans != 0){
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,i;
    char op;    
    for(i=0; i<=20000; i++){
        scanf("%d %c %d", &a, &op, &b);
    if(op=='+'){
        printf("%d\n",a + b);
    }
    else if(op=='-'){
        printf("%d\n",a - b);
    }
    else if(op=='*'){
        printf("%d\n",a * b);
    }
    else if(op=='/'){
        printf("%d\n",a / b);
        }
    else if(op=='?') break;
        }
    return 0;
    
}



Measured memory_bytes: 2048
# ABC122B

s=input()

maxl=0
a="ACGT"
for i in range(len(s)):
    cntl=0
    if s[i] in a:
        cntl+=1
        for j in range(i+1,len(s)):
            if s[j] in a:
                cntl+=1
            else:
                break
    i+=cntl
    maxl=max(maxl,cntl)

print(maxl)
        

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int MAX_N=105;
int n;
char s[MAX_N];
int pre[MAX_N];
int rev[MAX_N];
int main()
{
	cin>>n;
	scanf("%s",s+1);
	For(i,1,n)
	{
		pre[i]=pre[i-1]|(1<<(s[i]-'a'));
	}
	per(i,n,1)
	{
		rev[i]=rev[i+1]|(1<<(s[i]-'a'));
	}
	int ans=0;
	For(i,1,n)
	{
		ans=max(ans,__builtin_popcount(pre[i]&rev[i+1]));
	}
	cout<<ans<<endl;
	return 0;
}



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

#ifndef DUMP
#define DUMP(...) void(0)
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int d, t, s;
  cin >> d >> t >> s;
  cout << (d <= s * t ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int N;
map<int,int>m;
int a[100010];
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>a[i];
        m[a[i]]++;
        m[a[i]+1]++;
        m[a[i]-1]++;
    }
    int cnt=0;
    for(auto i:m)
    {
        cnt=max(cnt,i.second);
    }
    cout<<cnt <<endl;

    return 0;
}


Measured memory_bytes: 5120
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1e9 + 7;

int main(void)
{
    int a, b, c;

    cin >> a >> b >> c;

    if (a == b)
    {
        if (b == c)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
    else if (b == c)
    {
        if (a == c)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
    else if (c == a)
    {
        if (a == b)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#input
N, P = map(int, input().split())
S = input()

# process
ans = 0
if P == 2 or P == 5:
    # 1桁目がPで割り切れる数をカウント
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i+1

else:
    cnt = [0]*P # S[i:N]%Pの結果をカウント
    num = 0
    tenPow = 1
    for i in reversed(range(N)):
        num = (num + int(S[i])*tenPow)%P
        tenPow = tenPow*10%P
        cnt[num] += 1

    ans += cnt[0]
    for c in cnt:
        ans += c*(c-1)//2 # c=0,1のときは0加算

# output
print(ans)


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int dp[100050][25];
vector<int> hotels;
int l;
int n;

int beki[30];

int f(int a, int b){
    if(dp[a][1] >= b){
        return 1;
    }
    for(int day = 0; day <= 24; day++){
        if(dp[a][day] >= b){
            //cout << "from " << a << " to " << dp[a][day - 1] << " need " << beki[day - 2] << endl;
            return beki[day - 2] + f(dp[a][day - 1], b);
        }
    }
}

int main() {
    beki[0] = 1;
    for(int i = 1; i <= 25; i++){
        beki[i] = beki[i - 1] * 2;
    }
    hotels.push_back(0);
    //cout.precision(10);
    cin >> n;
    for(int i = 1; i <= n; i++){
        int in;
        cin >> in;
        hotels.push_back(in);
    }
    cin >> l;
    for(int i = 1; i <= n; i++){
        dp[i][0] = i;
        dp[i][1] = distance(hotels.begin(), upper_bound(hotels.begin(), hotels.end(), hotels[i] + l)) - 1;
        //cout << dp[i][1] << endl;
    }
    for(int day = 2; day <= 24; day++){
        dp[n][day] = n;
        for(int pos = 1; pos <= n - 1; pos++){
            dp[pos][day] = dp[dp[pos][day - 1]][day - 1];
        }
    }
    int q;
    cin >> q;
    for(int i = 1; i <= q; i++){
        int a,b;
        cin >> a >> b;
        if(a > b){
            swap(a, b);
        }
        cout << f(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 11128
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    vl A(N); ll sum = 0;
    rep(i, N){
        cin >> A[i]; sum += A[i];
    }
    vl pv;
    for(ll i = 1; i*i <= sum; i++){
        if(sum%i == 0){
            pv.pb(i); pv.pb(sum/i);
        }
    }
    
    ll ans = 1;
    rep(i, pv.size()){
        vl md;
        rep(idx, N){
            ll m = A[idx]%pv[i];
            if(m!=0) md.pb(m);
        }
        sort(ALL(md));
        vl sum(md.size()+1, 0);
        rep(j, md.size()) sum[j+1] = sum[j] + md[j];
        
        rep(j, md.size()+1){
            ll l = sum[j];
            ll r = (md.size()-j)*pv[i] - (sum[md.size()] - sum[j]);
            if(max(l, r) <= K){
                chmax(ans, pv[i]); break;
            }
        }
        
    }
    cout << ans << endstr;
    return 0;
}


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

using namespace std;

const int N = 200000 + 7;

typedef pair<int, int> ii;

int n;
int a[N];
vector<ii> b;

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    b.push_back(ii(a[i], i));
  }

  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  
  for(int i = 0; i < n; ++i) {
    if(i == b[0].second) printf("%d\n", b[1].first);
    else printf("%d\n", b[0].first);
  }
  return 0;
}


Measured memory_bytes: 4080
n=int(input())
h=list(map(int,input().split()))

i=0
count=0
while i<=n-1:
    if h[i]==0:
        i+=1
    else:
        h[i]-=1
        count+=1
        k=i+1
        for l in range(k,n):
            if h[k]>0:
                h[k]-=1
                k+=1
            else:
                break

print(count)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976
#define MAX_N 100010

int main(){
	lint n,s=0;cin>>n;
	map<lint,lint>ma;ma[0]=1;
	LIV a(n);rep(i,n)cin>>a[i],s+=a[i],++ma[s];
	lint ans=0;
	for(auto i:ma)ans+=i.second*(i.second-1)/2;
	cout<<ans<<endl;
}

//int main(){//平方数を1<k<=nで割ったあまりを求める
//	lint n;cin>>n;
//	LIV ans(n);
//	for(int i=1;i<=n;++i){
//		set<int> s;
//		rep(x,i)s.insert(x*x%i);
//		cout<<i<<": ";
//		for(auto x:s)cout<<x<<",";cout<<endl;
//		ans[i-1]=s.size();
//	}rep(i,n)cout<<ans[i]<<endl;
//	getchar();
//	getchar();
//}

//sub-EOF


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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  int cnt=0;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  for(int i=0;i<n;i++){
    if(h[i]>=k)cnt++;
  }
  cout<<cnt<<endl;
}

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

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

  bool plus = a[0] >= 0 ? true : false;

  ll cnt  = 0;
  ll cnt2 = 0;
  ll sum  = 0;
  ll sum2 = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    sum2 += a[i];

    if (i % 2 == 0) {
      // +
      if (sum <= 0) {
        cnt += abs(sum) + 1;
        sum = 1;
      }
      // -
      if (sum2 >= 0) {
        cnt2 += sum2 + 1;
        sum2 = -1;
      }
    } else {
      // +
      if (sum2 <= 0) {
        cnt2 += abs(sum2) + 1;
        sum2 = 1;
      }
      // -
      if (sum >= 0) {
        cnt += sum + 1;
        sum = -1;
      }
    }
  }
  cout << min(cnt, cnt2) << endl;
}

Measured memory_bytes: 1024
k = int(input())
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(x[k-1])


Measured memory_bytes: 2940