akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

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

int main() {
    int n, x, y[100001], y_diff[100000], d;
    cin >> n >> x;
    for (int i = 0; i < n; i++) cin >> y[i];
    y[n] = x;

    // 昇順に座標をソート
    sort(y, y+n+1);

    // 各座標間の距離を求める
    for (int i = 0; i < n; i++) {
        y_diff[i] = y[i+1] - y[i];
    }

    int d_max = 0;
    if (n == 1) {
        d_max = y_diff[0];
    }
    else {
        // それらの最大公約数を求める(D)
        for (int i = 0; i < n-1; i++) {
            d = gcd(y_diff[i], y_diff[i+1]);
            y_diff[i+1] = d;
        }
        d_max = d;
    }

    cout << d_max << endl;
        
    return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

aite_to_rew = {'r': [0, 0, P], 's': [R, 0, 0,], 'p': [0, S, 0]}

total_score = 0
for i in range(K):
    tv = T[i::K]
    dp = aite_to_rew[tv[0]]

    for i in range(1, len(tv)):
        aite = tv[i]

        r_score = R if aite == 's' else 0
        s_score = S if aite == 'p' else 0
        p_score = P if aite == 'r' else 0

        dp_next = [
            max(dp[1] + r_score, dp[2] + r_score),
            max(dp[0] + s_score, dp[2] + s_score),
            max(dp[0] + p_score, dp[1] + p_score),
        ]
        dp = dp_next
    
    total_score += max(dp)

print(total_score)

Measured memory_bytes: 3316
//#include<bits\stdc++.h>
#include<iostream>
#include<stdlib.h>
#include<cstring>

using namespace std;

int n,make,weight_and_profit[105][2];
long long int saved[105][100005];

long long int maxi_pro(int pos,int w){
    if(pos==n+1)
        return 0;

    if(saved[pos][w]!=-1)
       return saved[pos][w];

    long long int ans=0;

    if(w+weight_and_profit[pos][0]<=make){
        ans=weight_and_profit[pos][1]+maxi_pro(pos+1,w+weight_and_profit[pos][0]);
    }
    ans=max(ans,maxi_pro(pos+1,w));
    saved[pos][w]=ans;
    return ans;
}


int main(){
    int i,j;

    for(i=0;i<105;i++){
        memset(saved[i],-1,sizeof(saved[i]));
    }

    cin>>n>>make;

    for(i=1;i<=n;i++){
        scanf("%d %d",&weight_and_profit[i][0],&weight_and_profit[i][1]);
    }

    cout<<maxi_pro(1,0)<<endl;



    return 0;
}


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

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

    if (N%2==0) {
        bread=N-1;
    }
    else {
        bread=N;
    }

    int kaage=0;
    int define=0;
    for (int i=1; i<bread+1; i+=2) {
        for (int j=1; j<bread; j++) {
            if (i%j==0) {
                kaage++;
            }
            else if (j==i-1 && kaage!=8) {
                kaage=0;
            }
            else if (j==i-1 && kaage==8) {
                define++;
            }
        }
    }
    cout << define << endl;
}
            
            
            
            


Measured memory_bytes: 3648
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

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

  int a, b, c;
  cin >> a >> b >> c;
  cout << max(0, c - (a - b)) << endl;

  return 0;
}

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

int main()
{
	string a,b;
	int i,l,l2;
	cin>>a>>b;
	l=a.size();l2=b.size();
	for(i=0;i<l2;i++)
	{
		cout<<a[i]<<b[i];
	}
	if(l2<l)cout<<a[l-1];
	cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int num;

	while( cin >> num ) {
		if (num == 0 )
			break;

		long int tmpsum = 0;
		long int currnum;
		long int maxnum = -999999999;
		for( int i = 0; i < num; i++ ) {
			cin >> currnum;

			if( currnum + tmpsum > maxnum ) {
				maxnum = currnum + tmpsum;
			}
			
			if( currnum + tmpsum > 0 )
				tmpsum += currnum;
			else
				tmpsum = 0;
		}
		cout << maxnum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n,d;
    std::cin >> n >>d;
    int ten[10][10];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            std::cin >> ten[i][j];
        }
    }
    int cnt=0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            double sum=0;
            for (int k = 0; k < d; k++) {
                sum+=pow(ten[i][k]-ten[j][k],2);
            }
            if(ceil(sqrt(sum))==floor(sqrt(sum))){
                cnt++;
            }
        }
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
n = int(input())
dp = list(0 for _ in range(n+1))

for i in range(2,n+1):
  #素因数分解の試し割り法
  while i%2==0:
    dp[2] += 1
    i //= 2
  f = 3
  while f*f<=i:
    if i%f==0:
      dp[f] +=1
      i //= f
    else:
      f += 2
  if i!=1:
    dp[i] += 1
#指数を数えていく
s = 1
for i in dp:
  if i!=0:
    s *= i+1
print(s%(10**9+7))

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

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

constexpr LL MOD = 998244353;
LL ksm(LL x,LL k){LL re=1;for(;k;k>>=1,x=x*x%MOD)if(k&1)re=re*x%MOD;return re;}
void modplus(LL& x, LL y) { x = (x + y) % MOD; };
void modsub(LL& x, LL y){ x = (x-y<0?x-y+MOD:x-y);}
void modmul(LL& x, LL y) { x = (x * y) % MOD; };
void modpow(LL& x, LL y) { x = (x + y) % MOD; };



LL n;
V<LL> a;
V<V<LL>> dp(n+1);
V<V<LL>> dp2(n+1);

int main(){
    INIT;
    cin >> n;
    LL s = 0;
    REP(i,n) { int x; cin >> x; a.push_back(x); s += x; }

    dp.resize(n+1);
    REP(i,n+1) dp[i].resize(s+1);
    dp[0][0] = 1;

    dp2.resize(n+1);
    REP(i,n+1) dp2[i].resize(s+1);
    dp2[0][0] = 1;

    FOR(i, 1, n+1) {
        for(int j = 0; j < a[i-1]; j++) {
            dp[i][j] += (dp[i-1][j]*2) % MOD;
            dp2[i][j] += (dp2[i-1][j]) % MOD;
        }
        for(int j = a[i-1]; j <= s; j++) {
            dp[i][j] += (dp[i-1][j]*2+dp[i-1][j-a[i-1]]) % MOD;
            dp2[i][j] += (dp2[i-1][j]+dp2[i-1][j-a[i-1]]) % MOD;
        }
    }

    LL ans = ksm(3, n);

    LL rgb = 0;
    LL d = ((s % 2 == 0) ? s/2 : (s+1)/2);
    FOR(i,d,s+1) modplus(rgb, dp[n][i]);
    modmul(rgb, 3);

    LL gb = 0;
    if(s % 2 == 0) {
        modplus(gb, dp2[n][s/2]);
        modmul(gb, 3);
    }

    modsub(ans, rgb);
    modplus(ans, gb);
    cout << ans << "\n";
}

Measured memory_bytes: 424064
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  string s;
  cin >> s;
  int k = s.length();

  int cnt = count_if(ALL(s), [](char c){return c == 'o';});
  int rem = 15 - k;

  if (cnt + rem >= 8) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}



Measured memory_bytes: 256
def readinput():
    n=int(input())
    p=[]
    for _ in range(n):
        p.append(int(input()))
    return n,p

def main(n,p):
    p.sort(reverse=True)
    #print(p)
    p[0]=p[0]//2
    return sum(p)

if __name__=='__main__':
    n,p=readinput()
    ans=main(n,p)
    print(ans)


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

int masu[20][20];

int main(void) {
    while (1) {
        for (int i = 0; i < 20; i++) {
            for (int j = 0; j < 20; j++) {
                masu[i][j] = 0;
            }
        }
        masu[1][1] = 1;

        int a, b, n;
        cin >> a >> b;
        if (a == 0 && b == 0) break;

        cin >> n;
        while (n--) {
            int tmp_x, tmp_y;
            cin >> tmp_x >> tmp_y;
            masu[tmp_y][tmp_x] = -1;
        }

        for (int i = 1; i <= b; i++) {
            for (int j = 1; j <= a; j++) {
                if (masu[i][j] < 0) continue;

                if (masu[i-1][j] >= 0) {
                    masu[i][j] += masu[i-1][j];
                }
                if (masu[i][j-1] >= 0) {
                    masu[i][j] += masu[i][j-1];
                }
            }
        }
        cout << masu[b][a] << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop(){
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];

	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a*b);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}

Measured memory_bytes: 548
# -*- coding: utf-8 -*-
import sys

X = int(input().strip())
#-----
calc = {}

for i in range(-118,120):
    calc[i] = i**5


for a in range(-118,120):
    for b in range(-118,120):
        if (calc[a] - calc[b]) == X:
            print(a,b)
            sys.exit()


Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <utility>
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
const lli inf = 1e18;

int main(){
	int n,m;
	cin >> n >> m;
	vector<vector<int> > s(m);
	for(int i=0; i<m; i++){
		int k;
		cin >> k;
		for(int j=0; j<k; j++){
			int a;
			cin >> a;
			a--;
			s[i].push_back(a);			
		}
	}
	vector<int> p(m);
	for(int i=0; i<m; i++){
		cin >> p[i];
	}

	int ans = 0;
	for(int i=0; i<(1<<n); i++){
		bool ok = true;
		for(int j=0; j<m; j++){
			int count = 0;
			for(int k=0; k<(int)s[j].size(); k++){
				if(i>>s[j][k] & 1) count++;
			}
			if(count % 2 != p[j]){
				ok = false;
				break;
			}
		}
		if(ok) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = b = c = ans = 0
for _ in range(n):
    s = input()
    ans += s.count("AB")
    a += s[-1] == "A"
    b += s[0] == "B"
    c += s[-1] + s[0] == "AB"
print(ans + min(a, b) - (0 < a == b == c))


Measured memory_bytes: 9160
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if(a>=1 && a<=9 && b>=1 && b<=9){
      System.out.println(a*b);
    }else{
      System.out.println(-1);
    }
  }
}


Measured memory_bytes: 23636
#include <stdio.h>
#include <stdlib.h>

int main(){
  int w,n,tmp,a,b;
  int i;
  int *arr;
  scanf("%d",&w);
  scanf("%d",&n);
  arr = (int *)calloc(w+1,sizeof(int));
  for(i=0;i<=w;i++)arr[i] = i;
  while(n){
    scanf("%d",&a);getchar();scanf("%d",&b);
    tmp = arr[a];
    arr[a] = arr[b];
    arr[b] = tmp;
    n--;
  }
  for(i=1;i<=w;i++)printf("%d\n",arr[i]);
}

Measured memory_bytes: 2688
n,s=map(int,input().split())
a=list(map(int,input().split()))
t=[[0]*(s+1) for i in range(n+1)]
t[0][0]=1
m=998244353
for i in range(n):
    for j in range(s+1):
        t[i+1][j]=t[i][j]*2
        if j>=a[i]:
            t[i+1][j]+=t[i][j-a[i]]
        t[i+1][j]%=m
print(t[-1][-1])

Measured memory_bytes: 135500
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;
const int MOD=1e9+7;

const int MAX_N=1e5;

int N;
ll A,B,X[MAX_N];

int main(){
	scanf("%d %lld %lld",&N,&A,&B);
	REP(i,N){
		scanf("%lld",&X[i]);
	}
	ll ans=0;
	FOR(i,1,N){
		ans+=min((X[i]-X[i-1])*A,B);
	}
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std ;

const int MAX = 2e5 + 10 ;

int arr[MAX] , Min[MAX][20][2] , lg[MAX] , occ[MAX] ;
int n  ;

struct sparse_table
{
	void preprocess()
	{
		lg[1] = 0 ;
		for(int i = 2 ; i <= n ; ++i)
			lg[i] = lg[i/2] + 1 ;
		for(int i = 1 ; i <= n ; ++i)
		{
			if(i & 1)
				Min[i][0][1] = arr[i] , Min[i][0][0] = 1e9 ;
			else
				Min[i][0][0] = arr[i] , Min[i][0][1] = 1e9 ;
		}
		for(int j = 1 ; (1 << j) <= n ; ++j)
		{
			for(int i = 1 ; i + (1 << j) - 1 <= n ; ++i)
			{
				Min[i][j][0] = min(Min[i][j-1][0] , Min[i + (1 << (j - 1))][j-1][0]) ;
				Min[i][j][1] = min(Min[i][j-1][1] , Min[i + (1 << (j - 1))][j-1][1]) ;
			}
		}
	}

	int RminQ(int l , int r , bool t)
	{
		int j = lg[r-l+1] ;
		return min(Min[l][j][t] , Min[r - (1 << j) + 1][j][t]) ;
	}
};

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 1 ; i <= n ; ++i)
	{
		cin>>arr[i] ;
		occ[arr[i]] = i ;
	}
	set< pair<int , int> >ranges ;
	ranges.insert({1 , n}) ;
	sparse_table tree ;
	tree.preprocess() ;
	set<int>Min ;
	Min.insert(tree.RminQ(1 , n , 1)) ;
	vector<int>ans ;
	while(Min.size())
	{
		int x = *Min.begin() ;
		int idx = occ[x] ;
		pair<int , int>p = *prev(ranges.lower_bound({idx+1 , -1})) ;
		int y = tree.RminQ(idx+1 , p.second , !(idx%2)) ;
		int idy = occ[y] ;
		ans.push_back(x) ;
		ans.push_back(y) ;
		Min.erase(x) ;
		ranges.erase(p) ;
		if(p.first < idx)
		{
			ranges.insert({p.first , idx-1}) ;
			Min.insert(tree.RminQ(p.first , idx-1 , p.first % 2)) ;
		}
		if(idx+1 < idy)
		{
			ranges.insert({idx+1 , idy-1}) ;
			Min.insert(tree.RminQ(idx+1 , idy-1 , (idx+1) % 2)) ;
		}
		if(idy+1 <= p.second)
		{
			ranges.insert({idy+1 , p.second}) ;
			Min.insert(tree.RminQ(idy+1 , p.second , (idy+1) % 2)) ;
		}
	}
	for(auto &i : ans)
		cout<<i<<" " ;
	cout<<"\n" ;
	return 0 ;
}		

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

int n,a[100005];

int main() 
{
	ios_base::sync_with_stdio(false);
	//freopen(".inp","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=n-1;i>=1;i--)
		if(a[i]>a[i+1])
			a[i]--;
	for(int i=2;i<=n;i++)
		if(a[i]<a[i-1])
		{
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
}

Measured memory_bytes: 640
import math

def koch(d, a, b):
    if d== 0:
        return
    s=[0,0]
    t=[0,0]
    u=[0,0]
    
    s[0] = (2.0*a[0]+1.0*b[0])/3.0
    s[1] = (2.0*a[1]+1.0*b[1])/3.0
    t[0] = (1.0*a[0]+2.0*b[0])/3.0
    t[1] = (1.0*a[1]+2.0*b[1])/3.0
    u[0] = (t[0] - s[0])*math.cos(math.radians(60))-(t[1] - s[1])*math.sin(math.radians(60)) + s[0]
    u[1] = (t[0] - s[0])*math.sin(math.radians(60))+(t[1] - s[1])*math.cos(math.radians(60)) + s[1]
    
    koch(d-1,a,s)
    print("{:.8f}".format(s[0]), "{:.8f}".format(s[1]))  
    koch(d-1,s,u)
    print("{:.8f}".format(u[0]), "{:.8f}".format(u[1]))  
    koch(d-1,u,t)      
    print("{:.8f}".format(t[0]), "{:.8f}".format(t[1]))  
    koch(d-1, t, b)

n = int(input())

p1=[0,0]
p2=[100,0]

print("{:.8f}".format(p1[0]), "{:.8f}".format(p1[1]))
koch(n, p1, p2)
print("{:.8f}".format(p2[0]), "{:.8f}".format(p2[1]))




Measured memory_bytes: 5832
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,k;
    cin>>n>>m>>k;
    long long int a[n],b[m];
    for(long int i=0;i<n;i++)
     cin>>a[i];
     for(long int i=0;i<m;i++)
     cin>>b[i];
     for(long int i=1;i<n;i++)
     {
         a[i]+=a[i-1];
     }
    for(long int i=1;i<m;i++)
    b[i]+=b[i-1];
    long int ans=0;
    for(long int i=0;i<n;i++)
    {
        long int temp=0;
        if(k>=a[i])
        {
            temp=i+1;
            long int ans1=0;
            long int l=0,r=m-1;
            while(l<=r)
            {
                long int mid=(l+r)/2;
                if(b[mid]<=k-a[i])
                {
                  ans1=max(ans1,mid+1);
                  l=mid+1;
                }
                else
                r=mid-1;
            }
            temp+=ans1;
            ans=max(ans,temp);
        }
    }
    long int ans1=0;
            long int l=0,r=m-1;
    while(l<=r)
            {
                long int mid=(l+r)/2;
                if(b[mid]<=k)
                {
                  ans1=max(ans1,mid+1);
                  l=mid+1;
                }
                else
                r=mid-1;
            }
            ans=max(ans,ans1);
    cout<<ans<<endl;
}

Measured memory_bytes: 6752
#include<iostream>
#include<map>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int solve(int n,int m,int *h,int *w){
  map<int,int> M;
  rep(i,m){//length
    int tmp=0;
    rep(j,i+1){
      tmp+=w[j];
    }
    M[tmp]++;
    REP(j,i+1,m){
      tmp=tmp-w[j-i-1]+w[j];
      //cout << "tmp"<<tmp << endl;
      M[tmp]++;
    }
  }

  int ret = 0;
  rep(i,n){
    int tmp=0;
    rep(j,i+1){
      tmp+=h[j];
    }
    ret+=M[tmp];
    REP(j,i+1,n){
      tmp=tmp-h[j-i-1]+h[j];
     ret+=M[tmp];
    }
  }
  return ret;
}

main(){
  int n,m;
  while(cin>>n>>m && n){
    int h[n],w[m];
    rep(i,n)cin>>h[i];
    rep(j,m)cin>>w[j];
    cout << solve(n,m,h,w) << endl;
  }
}

Measured memory_bytes: 12000
#include<stdio.h>
int main(){
    long long int n,i,j,flag=0;
    scanf("%lld",&n);
    for(i=n;;i++){
        if(n==2){
            printf("%lld",n);
            break;
        }
        for(j=2;j<i;j++){
            flag=0;
            if(i%j==0)
                break;
            else{
                flag=1;
            }
        }
        if(flag==1){printf("%lld",i);
        break;}
    }
    }


Measured memory_bytes: 1736
<?php
$stdin = explode(" ", trim(fgets(STDIN)));

if($stdin[0]>$stdin[1]){
    $x = $stdin[0];
    $y = $stdin[1];
} else {
    $x = $stdin[1];
    $y = $stdin[0];
}
$result = 0;

while($x%$y != 0){
    $rest = $x%$y;
    $x = $y;
    $y = $rest;
}
$result = $y;
print($result."\n");
?>


Measured memory_bytes: 9204
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define int long long
#define all(arr) arr.begin(),arr.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define br '\n'
/*int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
int MOD = 100001;*/

void solve()
{
	char n;
	cin>>n;
	int p =n;
	if(p>=65 && p<=90)
		cout<<'A'<<endl;
	else
		cout<<'a'<<endl;
}

int32_t main()
{
	FastIO; PRECISION;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

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

signed main()
{
    int n,w;
    cin >> n >> w;
    vector<int> x(n+1,0), v(n+1, 0);
    for (int i=1; i<=n; i++) cin >> x[i] >> v[i];
    vector<vector<long long> > f (n+1, vector<long long> (w*2+5, 0));
    for (int i=1; i<=n; i++)
    {
        for (int j=0; j<x[i]; j++)f[i][j] = f[i-1][j];
        for (int j=x[i]; j<=w; j++)
        {
            f[i][j] = max(f[i-1][j], f[i-1][j-x[i]] + v[i]);
        }
    }
    cout << f[n][w];
    return 0;
}


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



int main() {
    int a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    int tot = a;
    while (tot < b) {
        tot += a;
        tot--;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
import sys
sys.setrecursionlimit(10 ** 6)
N,M=map(int,input().split())
bridge=[]
size=[1]*(N+1)
tree=list(range(N+1))
def find(a):
    x=tree[a]
    if a==x:
        return a
    x=find(x)
    tree[a]=x
    return x
for i in range(M):
    A,B=map(int,input().split())
    bridge.append((A,B))
Ans=N*(N-1)//2
ans=[]
for a,b in bridge[::-1]:
    aroot=find(a)
    broot=find(b)
    if aroot==broot:
        ans.append(Ans)
        continue
    ans.append(Ans)
    Ans-=size[aroot]*size[broot]
    tree[broot]=aroot
    size[aroot]+=size[broot]
for i in ans[::-1]:
    print(i)

Measured memory_bytes: 37224
N, K = map(int, input().split())
A = list(map(int, input().split()))
Am = []
n0 = 0
Ap = []
for a in A:
    if a<0: Am.append(a)
    if a==0: n0+=1
    if a>0: Ap.append(a)

Am = sorted(Am)
Ap = sorted(Ap)
    
nm = len(Am)
np = len(Ap)

Nm = nm*np
N0 = n0*(n0-1)//2 + n0*(nm+np)
Np = nm*(nm-1)//2 + np*(np-1)//2

if K<=Nm:
    # K-th product is negative
    min_ok = 0
    max_ng = -10**20
    while min_ok-max_ng>1:
        tgt = (min_ok+max_ng)//2

        k=0
        i=0
        for a in Am:
            while i<np and a*Ap[i]>tgt: i+=1
            k+=np-i

        if k>=K:
            min_ok = tgt
        else:
            max_ng = tgt
            
    print(min_ok)

elif K<=Nm+N0:
    # K-th product is zero
    print(0)

else:
    # K-th product is positive
    K-= Nm+N0
    
    Am = [-a for a in Am[::-1]]
    
    min_ok = +10**20
    max_ng = 0
    while min_ok-max_ng>1:
        tgt = (min_ok+max_ng)//2

        k=0
        i=np-1
        for j,a in enumerate(Ap):
            while i>=0 and a*Ap[i]>tgt: i-=1
            if i<=j: break
            k+=i-j
            
        i=nm-1
        for j,a in enumerate(Am):
            while i>=0 and a*Am[i]>tgt: i-=1
            if i<=j: break
            k+=i-j
            
        if k>=K:
            min_ok = tgt
        else:
            max_ng = tgt
            
    print(min_ok)


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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>

ll n;
ll arr[100010][3];
ll dp[100010][3];
ll m(ll a,ll b,ll c){
	return max(a,max(b,c));
}
int main(){
	fast;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	}
	dp[0][0]=0;
	dp[0][1]=0;
	dp[0][2]=0;
	for(ll i=1;i<=n;i++){
		dp[i][0]=max(arr[i][1]+dp[i-1][1],arr[i][2]+dp[i-1][2]);
		dp[i][1]=max(arr[i][0]+dp[i-1][0],arr[i][2]+dp[i-1][2]);
		dp[i][2]=max(arr[i][1]+dp[i-1][1],arr[i][0]+dp[i-1][0]);
	}
	cout<<m(dp[n][0],dp[n][1],dp[n][2])<<endl;
	return 0;
}

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

int main() 
{
    int N;
    cin >> N;
    map<string, int>mp;
    for (int i = 0; i < N; i++) {
        string str = "";
        cin >> str;
        mp[str]++;
    }
    
    int MMM = 0;
    for (auto p : mp) {
        MMM = max(MMM, p.second);
    }
    for (auto p : mp) {
        if (MMM == p.second) {
            cout << p.first << endl;
        }
    }
}

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


int main() {
   
   int n; 
   cin >> n;
   
   int maxA = n / 4;
   int maxB = n / 7;
   
   bool ans = false;
   for (int i=0; i<=maxA; i++) {
       for (int j=0; j<=maxB; j++) {
           int sum = 4 * i + 7 * j;
           if (sum ==n) ans = true;
       }
   }
   if (ans) cout << "Yes" << endl;
   else cout << "No" << endl;
    
}

Measured memory_bytes: 3640
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	
	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		
		BigDecimal r = BigDecimal.valueOf(sc.nextDouble());
		BigDecimal pi = BigDecimal.valueOf(Math.PI);
		
		System.out.println(r.pow(2).multiply(pi) + " " + BigDecimal.valueOf(2).multiply(pi).multiply(r));
		
		sc.close();
	}

}

Measured memory_bytes: 28332
#include<stdio.h>
int main()
{
	int n, y, b, r, t, i, j, a;
	double x, u=0;
	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		scanf("%d", &y);
		u = b = 1;
		for (i = 0; i < n; i++) {
			scanf("%d%d%d", &b, &r, &t);
			if (t == 1) {
				x = 1 + y*r*0.01;
			}
			else {
				x = 1;
				for (j = 0; j < y; j++) {
					x = x*(1 + r*0.01);
				}
			}
			if (x > u) {
				u = x;
				a = b;
			}
		}
				printf("%d\n",a);
			}
		}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n+2,0);
    ll sum=0;
    FOR(i,1,n+1){
        cin>>a[i];
        sum+=abs(a[i]-a[i-1]);
        if(i==n) sum+=abs(a[i]);
    }
    FOR(i,1,n+1){
        cout<<sum-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))+abs(a[i-1]-a[i+1])<<endl;
    }
}

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

int main(){
  int n, m, count=0, mc=0, nc=0;
  cin >> n >> m;
  if(n==0 || m==0) count = 0;
  if(n==1) count=0;
  if(n>1){
    nc = n*(n-1);
    nc /= 2;
  }
  if(m>1){
    mc = m*(m-1);
    mc /= 2;
    
  }
  count = count + mc + nc;
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int wide;
    cin>>wide;
    int time;
    cin>>time;
    int x,y;
    for(int i=0;i<time;++i){
        cin>>x>>y;
        if((wide+1)/2<x){
            x=wide-x+1;
        }
        if((wide+1)/2<y){
            y=wide-y+1;
        }
        cout<<(min(x,y)-1)%3+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

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

int main(){
    ll a,b;
    string op;
    cin>>a>>op>>b;
    
    if(op == "+")cout<< a+b<<endl;
    else cout<< a-b<<endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

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; }


class A {
	int a, b;
public:
	A()
	{
		cin >> a >> b;
	}
	void solve()
	{
		cout << (a - 1) * (b - 1) << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
N, K = gets.chomp.split(" ").map(&:to_i)
An = gets.chomp.split(" ").map(&:to_i)

balls = Array.new(An.max, 0)

N.times do |i|
  balls[An[i] - 1] += 1
end

balls.sort!.reverse!

ans = 0
until balls.length <= K do
  ans += balls.pop
end

p ans

Measured memory_bytes: 19684
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int n, u, v;
    cin >> n >> u >> v;
    u--; v--;
    Graph G(n);
    rep(i, n-1){
        int a, b;
        cin>> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<pair<int, int>> que;
    que.push(make_pair(v, 0));
    vector<int> time(n, -1);
    while(!que.empty()){
        int m, t;
        tie(m, t) = que.front(); que.pop();
        time[m] = t;
        repe(i, G[m]){
            if(time[i] == -1){
                que.push(make_pair(i, t+1));
            }
        }
    }

    que.push(make_pair(u, 0));
    int ans = 0;
    vector<int> time2(n, -1);
    while(!que.empty()){
        int m, t;
        tie(m, t) = que.front(); que.pop();
        time2[m] = t;
        bool f= 0;
        repe(i, G[m]){
            if(time2[i] == -1){
                if(time[i] > t+1){
                    que.push(make_pair(i, t+1));
                    f = 1;
                }
            }
        }
        if(!f){
            chmax(ans, time[m]-1);
        }
    }
    chmax(ans, time[u]-1);
    cout << ans << endl;


}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 1; i <= n; i++) {
        auto m = prime_factor(i);
        for (int j = 2; j < 101; j++) mp[j] += m[j];
    }
    int p75 = 0, p25 = 0, p15 = 0, p5 = 0, p3 = 0;
    for (int i = 0; i < 100; i++) {
        if(mp[i] >= 74) p75++;
        if(mp[i] >= 24) p25++;
        if(mp[i] >= 14) p15++;
        if(mp[i] >= 4) p5++;
        if(mp[i] >= 2) p3++;
    }
    cout << p75 + p25 * (p3 - 1) + p15 * (p5 - 1) + p5 * (p5 - 1) * (p3 - 2) / 2 << endl;
    return 0;
}


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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;



int main() {
	speed;
	cout << fixed << setprecision(6);
	/*start*/
	int n;
	cin >> n;
	double m = n;
	if ( n % 2 == 0) {
		c(m/2/m);
	}
	else {
		c((n / 2 + 1) / m);

	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

ll D, pw10[21], res, S[21];

void f(int x, int y, ll c, ll t) {
	if (x == y) {
		if (t == 0) {
			res += c * 10;
		}
	}
	else if (x < y) {
		if (t == 0) {
			res += c;
		}
	}
	else {
		if (S[x] >= abs(t)) {
			for (int i = 0; i <= 9; ++i) {
				f(x - 1, y + 1, c*(10 - i), t - (pw10[x] - pw10[y])*i);
			}
			for (int i = 1; i <= 9; ++i) {
				f(x - 1, y + 1, c*(10 - i), t + (pw10[x] - pw10[y])*i);
			}
		}
	}
}

int main() {
	cin >> D;
	pw10[0] = 1;
	S[0] = 9;
	for (int i = 0; i < 20; ++i) {
		pw10[i + 1] = pw10[i] * 10;
		S[i + 1] = S[i] + pw10[i + 1] * 9;
	}
	for (int i = 1; i <= 20; ++i) {
		for (int j = 0; j <= 9; ++j) {
			f(i - 1, 1, 9 - j, D - (pw10[i] - 1)*j);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
import heapq

def solve():
    N = int(input())
    que = []
    for i in range(N):
        a, b = map(int, input().split())
        heapq.heappush(que, (-b, a))
    now = 10 ** 10
    while que:
        b, a = heapq.heappop(que)
        b = -b
        if now > b:
            now = b
        now -= a
        if now < 0:
            return False
    return True

if solve():
    print("Yes")
else:
    print("No")


Measured memory_bytes: 34412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define yes cout<<"YES"<<nl
#define no  cout<<"NO"<<nl
#define nl  '\n'
#define tr ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define tst int t;cin>>t;while(t--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
#define vi    vector<int>
#define    vl    vector<ll>
#define    si    set<int>
#define    sl    set<ll>
#define    msi    multiset<int>
#define    msl    multiset<ll>
#define    pii    pair<int,int>
#define    pil    pair<int,ll>
#define    pli    pair<ll,int>
#define    pll    pair<ll,ll>
#define    mp    make_pair
#define    pb    push_back

int main()
{
    string s,t;
    cin>>s>>t;
    int c=0,i;
    for(i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            c++;
    }
    cout<<c<<nl;

}


Measured memory_bytes: 3828
n = int(input())
value = list(map(int, input().split()))
cost = list(map(int, input().split()))
ret = 0
for state in range((1 << n)):
    values = costs = 0
    for shift in range(n):
        if (state >> shift) & 1 == 1:
            values += value[shift]
            costs += cost[shift]
    ret = max(ret, values - costs)
print(ret)

Measured memory_bytes: 42348
(* 配列版素集合データ構造 *)
module RawUnionFind : sig
  type t
  type class_

  (* n要素の素集合データ構造を作る *)
  val make : int -> t
  (* 要素がどの集合に属するか調べる *)
  (* 要素は0からn-1の整数である必要がある *)
  val find : t -> int -> class_
  (* 与えられた要素が属する集合同士を合併する *)
  val unite : t -> int -> int -> unit

  val compare_class : class_ -> class_ -> int
end = struct
  type t = { rank : int array; parent : int array }
  type class_ = int

  let make n =
    { rank = Array.make n 0;
      parent = Array.init n (fun c -> c) }

  let rec find uf x =
    if x = uf.parent.(x) then x
    else begin
      let y = find uf uf.parent.(x) in
      uf.parent.(x) <- y; y
    end

  let unite uf i j =
    let x = find uf i in
    let y = find uf j in
    if x <> y then begin
      if uf.rank.(x) < uf.rank.(y) then uf.parent.(x) <- y
      else begin
        uf.parent.(y) <- x;
        if uf.rank.(x) = uf.rank.(y) then
          uf.rank.(x) <- 1 + uf.rank.(x)
      end
    end

  let compare_class = compare
end

let () = Scanf.scanf "%d %d\n" (fun n m ->
  let ps = Array.init n (fun _ -> Scanf.scanf "%d " (fun p -> p - 1)) in
  let uf = RawUnionFind.make n in
  for i = 1 to m do
    Scanf.scanf "%d %d\n" (fun x y ->
      RawUnionFind.unite uf (x - 1) (y - 1))
  done;
  Array.mapi (fun i p -> RawUnionFind.find uf i = RawUnionFind.find uf p) ps
  |> Array.to_list
  |> List.filter (fun b -> b)
  |> List.length
  |> Printf.printf "%d\n")

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

 int a[200010];
   int ans[200010];

int main()
{
    
    int n,flag,anss;
    cin>>n;
    for(int i=2;i<=n;i++)  // 1 teke n porjonto number moddhe input gula kotobar ache seta evabe ber korbo
        cin>>a[i];
        //cout<<a[0];
    for(int i=2;i<=n;i++)
        ans[a[i]]++;
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<endl;
}


Measured memory_bytes: 5204
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

ll dp[400][400];
ll a[400];

ll search(const int start, const int end){
  if(start>=end) return dp[start][end]=0;
  if(dp[start][end]>=0) return dp[start][end];
  if(start+1==end) return dp[start][end] = a[start]+a[end];
  ll tmp=INFLL;
  ll sum=0;
  rep(i, start, end){
    ll tmp1 = search(start, i);
    ll tmp2 = search(i+1, end);
    tmp = min(tmp, tmp1+tmp2);
    sum += a[i];
  }
  sum += a[end];
  return dp[start][end] = tmp+sum;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  //vll a(N);
  rep(i, 0, N){
    cin >> a[i];
  }

  //vvll dp(N, vll(N, -1));
  memset(dp, -1, sizeof(dp));

  cout << search(0, N-1) << "\n";

  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

mt19937 tw(566);
uniform_int_distribution<ll> ll_distr;

ll rnd(ll a, ll b) {
    return ll_distr(tw) % (b - a + 1) + a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vi a(n);
    forn(i, n) cin >> a[i];
    forab(i, k, n) {
        if (a[i] > a[i - k]) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3988
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=sc.Ia;
		long lb=0,ub=(long)1e18-1,mid=0;
		while(lb+1!=ub){
			mid=(ub+lb)/2;
			if(Fu(mid)<=s[1]){ub=mid;}
			else{lb=mid;}
		}
		Console.WriteLine("{1}",lb,ub);
		long Fu(long n) {
			long p=0;
			for(int i = 0;i<s[0]&&p<=s[1];i++) {
				p+=(a[i]-1)/n;
			}
			return p;
		}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 44408
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

import java.util.*;
import java.util.Collections; // sorting use
import java.io.*;
import static java.lang.System.*;

public class Main{
	public static void main(String[] args){
		int n,x;
		ArrayList<Integer> m = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();
		x = sc.nextInt();
		for (int i = 0; i < n; ++i){
			m.add(sc.nextInt());
			x -= m.get(i);
		}
		out.println(n + x / Collections.min(m));
	}
}


Measured memory_bytes: 23764