akhauriyash/Code-Regression huggingface dataset:
n, q = map(int, input().split())
s = input()

count = 0
counts = []
prev = ''
for c in list(s):
    if prev + c == 'AC':
        count += 1
    counts.append(count)
    prev = c

for _ in range(q):
    l, r = map(int, input().split())
    print(counts[r - 1] - counts[l - 1])


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

int main() {
    int N;
    cin >> N;
    vector<int> A(4);
    A[0] = N / 1000;
    A[1] = (N / 100) % 10;
    A[2] = (N / 10) % 10;
    A[3] = (N / 1) % 10;

    // for (int i = 0; i < 4; i++) {
    //     cout << A[i] << " ";
    // }
    // cout << endl;

    for (int bit = 0; bit < (1 << 3); bit++) {
        int ans = A[0];
        for (int i = 0; i < 3; i++) {
            if (bit & (1 << i)) {
                ans += A[i + 1];
            }
            else {
                ans -= A[i + 1];
            }
        }
        if (ans == 7) {
            for (int i = 0; i < 3; i++) {
                cout << A[i];
                if (bit & (1 << i)) {
                    cout << "+";
                }
                else {
                    cout << "-";
                }
            }
            cout << A[3] << "=7" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

ll n,k,a,b,c,d,x,y,z,m,l;
ll ans;
vecl arr(N);
ll dp[509][509];
ll pre[N];





void test_case() {

    ll n;
    cin>>n;


    vecl arr(n);
    rep(i,n) {
        cin>>arr[i];
    }

    vecl pre_sum(n+1, 0);

    for(int i=1; i<=n; i++) {
        pre_sum[i] = pre_sum[i-1] + arr[i-1];
    }

    for(int l=n-1; l>=0; l--) {
        for(int r =l; r<n; r++) {
            if(l==r) {
                dp[l][l] = 0;
            } else {
                dp[l][r] = LONG_MAX;
                ll sum = pre_sum[r+1] - pre_sum[l];
                // cout<<sum<<endl;
                for(int i=l; i<=r; i++) {
                    dp[l][r] = min(dp[l][r], dp[l][i] + dp[i+1][r] + sum);
                }
            }
        }
    }

    // for(int i=0; i<n; i++) {
    //     for(int j=0; j<n; j++) {
    //         cout<<dp[i][j]<<" ";
    //     }
    // }


    cout<<dp[0][n-1]<<endl;




}


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}


Measured memory_bytes: 5568
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int a,b;
	cin >>a >> b;
	cout<<max(max(a+b,a-b),a*b)<<endl;	
	return 0;
}

Measured memory_bytes: 256
import math
K=int(input())
count=0
for t in range(1,K+1):
    for s in range(t,K+1):
        for v in range(s,K+1):
            if t!=s!=v:
                count+=(6*math.gcd((math.gcd(t,s)),v))
            elif (t==s and t!=v) or (t==v and t!=s)or (s==v and s!=t):
                count+=(3*math.gcd((math.gcd(t,s)),v))
            else:
                count+=math.gcd((math.gcd(t,s)),v)
print(count)

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

Int n;
Int res;

void rec(Int x, bool a, bool b, bool c) {
    if (n < x) return;
    if (x <= n and a and b and c) res++;
    rec(x * 10 + 7, true, b, c);
    rec(x * 10 + 5, a, true, c);
    rec(x * 10 + 3, a, b, true);
}

int main() {
    cin >> n;
    rec(0, false, false, false);
    dump(res);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] nums = new int[n];
		int ans=0;

		for(int i=0;i<n;i++) {
			nums[i]=sc.nextInt();
		}

		for(int i=0;i<n-2;i++) {
			if(nums[i]<nums[i+1] && nums[i+1]<nums[i+2] || nums[i+2]<nums[i+1] && nums[i+1]<nums[i]) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22356
n = int(input())
a = list(map(int,input().split()))
nums = {0:0,1:0,2:0,3:0}
for i in range(n):
    num = a[i] % 4
    nums[num] += 1
if nums[2] % 2 == 0:
    if nums[1] + nums[3] - 1 <= nums[0]:
        print("Yes")
    else:
        print("No")
elif nums[2] % 2 == 1:
    if nums[1] + nums[3] <= nums[0]:
        print("Yes")
    else:
        print("No")

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

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

int main() {
  int64_t ans, a, b;
  cin >> a >> b;
  ans = a * b / gcd(a, b);
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a[4];
main(){
	register int i,j;
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	if((a[1]==a[2]&&a[1]!=a[3])||(a[2]==a[3]&&a[1]!=a[2]))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a, b, res;

int main()
{
    cin >> a >> b;

    int tmp1 = a + b;
    int tmp2 = a - b;
    int tmp3 = a * b;

    if (tmp1 > tmp2)
        res = tmp1;
    else
        res = tmp2;

    if (tmp3 > res)
        res = tmp3;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace okayama__112
{
    class Program
    {
        static void Main(string[] args)
 
        {
            int n;
            n = int.Parse(Console.ReadLine());
            switch(n)
            {
                case 1:
                    Console.WriteLine("Hello World");
                        break;
                case 2:
                    int a = int.Parse(Console.ReadLine());
                    int b = int.Parse(Console.ReadLine());
                    Console.WriteLine(a + b);
                    break;




            }
                
                

     
             

            

        }
    }
}


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

bool dfs(string s){
    if(s=="ABC") return true;
    bool ret=false;
    string a="",b="",c="";
    //cerr<<s<<endl;
    bool pos=false;
    int n=s.size();
    if(n%2==0) return false;
    if(n<=3 && s!="ABC") return false;
    bool pa=true,pb=true,pc=true;
    for(int i=0;i<n;){
        if(i<n-2 && s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            pos=true;
            a+='A';
            b+='B';
            c+='C';
            i+=3;
        }
        else {
            a+=s[i];
            b+=s[i];
            c+=s[i];
            if(s[i]=='A') pa=false;
            if(s[i]=='B') pb=false;
            if(s[i]=='C') pc=false;
            i++;
        }
    }
    if(!pos) return false;
    if(pa) ret|=dfs(a);
    if(pb) ret|=dfs(b);
    if(pc) ret|=dfs(c);
    return ret;
}

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

    string s;
    cin>>s;
    if(s.size()%2==0){
        cout<<"No"<<endl;
        return 0;
    }
    if(dfs(s)){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;


}


Measured memory_bytes: 46292
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vll a(n),b(n);
	rep(i,n) cin >> a[i] >> b[i];
	ll ans = 0;
	for(int i=n-1; i>=0; i--){
		a[i] += ans;
		ll x = (b[i]-a[i]%b[i])%b[i];
		ans+=x;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
 /*struct cmp{ bool operator() ( const, const )const{}};
  use as set<ll> ,cmp> a*/
int main()
{
  ios::sync_with_stdio(false);cin.tie(0);
  //freopen("input.txt" , "r" , stdin );
  ll n,m;
  cin>>n>>m;
  vector<ll> a[n+1];
  ll visited[n+1] = {};
  visited[1] = 1;
  for(ll i = 1 ;i<m+1 ;i++)
  {
      ll x,y;
      cin>>x>>y;
      a[x].push_back(y);
      a[y].push_back(x);
  }
  queue<ll> q;
  q.push(1ll);
  vector<ll> distance(n+1,0),position(n+1);
  distance[1] = 0 ;
  
  while(!q.empty())
   {
      ll s = q.front();
      q.pop();
      for( auto it : a[s])
      {
          if(visited[it])
          {
             if(distance[it]>distance[s]+1)
             {
                 
                 distance[it] = distance[s] + 1;
                 position[it] = s;
             }
             continue;
          }
          else
          {
          visited[it] = 1;
          distance[it] = distance[s] + 1;
          position[it] = s;
          
          }
          q.push(it);
      }
 
  }
  
  bool ok = true;
  for(ll i = 1 ; i<n+1 ; i++)
    if(visited[i]!=1) ok = false;
  if(ok)
  {
      cout<<"Yes\n";
      for(ll i = 2 ; i<n+1 ;i++)
        cout<<position[i]<<endl;
  }
  else
  {
      cout<<"No";
  }
 
  return 0;
}


Measured memory_bytes: 14460
#include<stdio.h>
char s[19][19];
void dfs(int a,int b){
	int j;
	for(j=-3;j<4;j++){
		if(a+j>=0 && a+j<8 && s[a+j][b]=='1'){
			s[a+j][b]='0';
			dfs(a+j,b);
		}
		if(b+j>=0 && b+j<8 && s[a][b+j]=='1'){
			s[a][b+j]='0';
			dfs(a,b+j);
		}
	}
}
int main(){
	int n,i,x,y,c;
	scanf("%d",&n);
	for(c=1;c<=n;c++){
		scanf("\n");
		for(i=0;i<8;i++)scanf("%s",s[i]);
		scanf("%d%d",&x,&y);
		s[y-1][x-1]='0';
		dfs(y-1,x-1);
		printf("Data %d:\n",c);
		for(i=0;i<8;i++)printf("%s\n",s[i]);
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int n,m,tot,dp[310][310][310],head[310],left[310],val[310],nxt[310];
void add(int u,int l,int x){
	nxt[++tot]=head[u];
	left[tot]=l;
	val[tot]=x;
	head[u]=tot;
	return;
}
bool check(int a,int b,int c){
	int k=max(a,max(b,c));
	for(int i=head[k];i;i=nxt[i]){
		int l=left[i],x=val[i];
		if((a>=l)+(b>=l)+(c>=l)!=x)
			return 0;
	}
	return 1;
}
int DP(){
	int ret=0;
	dp[0][0][0]=1;
	for(register int i=0;i<=n;i++)
		for(register int j=0;j<=n;j++)
			for(register int k=0;k<=n;k++){
				if(!dp[i][j][k])
					continue;
				if(!check(i,j,k)){
					dp[i][j][k]=0;
					continue;
				}
				int l=max(i,max(j,k))+1;
				if(l==n+1){
					ret+=dp[i][j][k];
					if(ret>=mod)
						ret-=mod;
					continue;
				}
				dp[l][j][k]+=dp[i][j][k];
				if(dp[l][j][k]>=mod)
					dp[l][j][k]-=mod;
				dp[i][l][k]+=dp[i][j][k];
				if(dp[i][l][k]>=mod)
					dp[i][l][k]-=mod;
				dp[i][j][l]+=dp[i][j][k];
				if(dp[i][j][l]>=mod)
					dp[i][j][l]-=mod;
			}
	return ret;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		add(r,l,x);
	}
	printf("%d",DP());
	return 0;
}

Measured memory_bytes: 114816
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll H,W,D;
    cin>>H>>W>>D;
    
    cout<<floor(W/D)-floor((H-1)/D);//+(H%D==0?1:0);
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
	string str;			// string型を使用する場合、scanf関数は使用できない？？
	string order, p, c;
	int q, a, b;
	int i, j;

	cin >> str;
	cin >> q;

	for(i=0;i<q;i++){
		cin >> order >> a >> b;

		if(order == "print"){
			for(j=a;j<=b;j++)
				cout << str[j];
			cout << endl;
		}
		else if(order == "reverse"){
			c =  str;
			for(j=a;j<=b;j++)
				str[j] = c[b+a-j];
		}
		else if(order == "replace"){
			cin >> p;
			for(j=a;j<=b;j++)
				str[j] = p[j-a];
		}
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

// 400, 30min

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 60
#define MAX_V 2510

ll H, W;
string S[MAX_N] = {};

struct edge{ int to, cost; };
typedef pair<int, int> P;   // first は最短距離、 second は頂点の番号

int V;
vector<edge> G[MAX_V];      // ノード i からのびている edge の vector 。ダイクストラ前に自分で入力する
int d[MAX_V];

// 始点 s から各頂点への最短距離を求める
void dijkstra(int s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first){ continue; }
        REP(i, G[v].size()) {
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}


signed main()
{
    cin >> H >> W;
    REP(i, H) {
        cin >> S[i];
    }
    V = H * W;
    REP(i, H) {
        REP(j, W) {
            ll node_id = i * W + j;
            edge e;
            // 上下左右にエッジを伸ばす
            if(i > 0 && S[i-1][j] == '.') {
                ll to_id = (i-1) * W + j;
                e.to = to_id;
                e.cost = 1;
                G[node_id].push_back(e);
            }
            if(i < H-1 && S[i+1][j] == '.') {
                ll to_id = (i+1) * W + j;
                e.to = to_id;
                e.cost = 1;
                G[node_id].push_back(e);
            }
            if(j > 0 && S[i][j-1] == '.') {
                ll to_id = i * W + (j-1);
                e.to = to_id;
                e.cost = 1;
                G[node_id].push_back(e);
            }
            if(j < W-1 && S[i][j+1] == '.') {
                ll to_id = i * W + (j+1);
                e.to = to_id;
                e.cost = 1;
                G[node_id].push_back(e);
            }
        }
    }
    dijkstra(0);
    ll dist = H * W - 1;
    if(d[dist] == INF) {
        printf("-1\n");
        return 0;
    }
    ll remain = d[dist] + 1;
    // 白マスの数を数える
    ll white = 0;
    REP(i, H) {
        REP(j, W) {
            if(S[i][j] == '.') { white++; }
        }
    }
    printf("%lld\n", white - remain);
    return 0;
}


Measured memory_bytes: 512
/*-------------------------------"ANJAN AGARWALA"-----------------------------

         _/_/_/_/    _/_/    _/   _/_/_/_/   _/_/_/_/    _/_/    _/   
        _/    _/    _/ _/   _/         _/   _/    _/    _/ _/   _/        
       _/_/_/_/    _/   _/ _/         _/   _/_/_/_/    _/  _/  _/         
      _/    _/    _/    _/_/   _/    _/   _/    _/    _/    _/_/  
     _/    _/    _/      _/   _/_/_/_/   _/    _/    _/      _/   

-------------------------------------@anjn98---------------------------------*/

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long long int LL;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define PR(a)           cout<<"("<<a<<")";
#define ED              cout<<'\n';
#define endl            '\n'
#define loop(j,a,n)     for(int j=a;j<=n;j++)
#define loop1(j,a,n)    for(int j=a;j>=n;j--)
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define SC(n)           scanf("%d",&n)
#define PB              push_back
#define MP              make_pair
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007


const int N=2e5+99;

int n;
ll tree[4*N],b[N],h[N],dp[N];

void update(int nd,int l,int r,int i,ll v)
{
    if(l>r || r< i || i<l ) return;
    if(l==r)
        return void(tree[nd]=v);
    int lt=2*nd,rt=lt|1,mi=(l+r)/2;
    update(lt,l,mi,i,v);
    update(rt,mi+1,r,i,v);
    tree[nd]=max(tree[lt],tree[rt]);
}

ll query(int nd,int l,int r,int i,int j)
{
    if(l>r || r< i || j<l ) return 0;
    if(i<=l && r<=j) return tree[nd];
    int mi=(l+r)/2,lt=2*nd, rt=lt|1 ;   
    return max(     query(lt,l,mi,i,j),
                    query(rt,mi+1,r,i,j)   )    ;
}

int main() 
{
    IO

    cin>>n;
    for(int i=1;i<=n;i++)cin>>h[i];
    for(int i=1;i<=n;i++)cin>>b[i];

    ll mx=0;
    for(int i=1;i<=n;i++)
    {
        ll ta=query(1,1,n,1,h[i]-1)+b[i];
        mx=max(mx,ta);
        update(1,1,n,h[i],ta);
    }
    cout<<mx<<endl;

}




 

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

// Data Type
#define ull     unsigned long long int
#define ll      long long int

// Loops
#define loop(i,s,e)     for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    for(ll i=(s);i>=(e);i--)

// Stl
#define pb      push_back
#define eb      emplace_back
#define pf      push_front
#define popb    pop_back
#define popf    pop_front
#define mp      make_pair
#define ff      first
#define ss      second

// Maths
#define PI          (2*acos(0.0))
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    (((a)*(b))/(__gcd((a),(b))))
#define log(x,b)    (log(x)/log(b))
#define INF         LLONG_MAX

// Big data
const int Mod = 1e9+7;
#define mul(a,b)         ((a%Mod)*(b%Mod))%Mod
#define sum(a,b)         ((a%Mod)+(b%Mod))%Mod

// Bit-Manipulation
#define setbit(n,pos)       n |= (1LL<<pos)
#define resetbit(n,pos)     n &= (~(1LL<<pos))
#define toogle(n,pos)       n ^= (1LL<<pos)
#define atpos(n,pos)        ((n&(1LL<<pos))!=0)

// Extra
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; nl;
#define nl              cout<<'\n'
#define endl            '\n'

void solve()
{
	ll a,b;
	cin>>a>>b;
	cout<<((a*b)/__gcd(a,b));
}

int main()
{
	try
	{
		ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int t = 1; 
		while(t--)
			solve();
	}
    catch(...)
    {
    	// nothing.
    }
	return 0;
}
/*
greater<int>()
fill_n(array,size,value);
fill(start,end,value);
getline(cin,string);
cin.getline(char array,size);
LLONG_MAX
DBL_MAX
*/

Measured memory_bytes: 256
#include <stdio.h>
int max(int i, int j);
int min(int i, int j);

int main(void){
    int i, j;
    int n;
    int R[200000];
    int max_v;
    int min_past;
    int tmp;
    scanf("%d", &n);
    for(i = 0; i < n; ++i){
        scanf("%d", &R[i]);
    }
    max_v = R[1]-R[0];
    min_past = R[0];
    for(i = 1; i < n; ++i){
            max_v = max(max_v, R[i]-min_past);
            min_past = min(min_past, R[i]);
    }
    printf("%d\n", max_v);
    return 0;
}

int max(int i, int j){
    if(i > j) return i;
    else return j;
}

int min(int i, int j){
    if(i < j) return i;
    else return j;
}


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

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

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

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

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

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

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

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

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

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

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

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



void solve(){
  ll N, K, S;
  cin >> N >> K >> S;
  if(S == 1000000000){
    rep(i, K){
      cout << S << " ";
    }
    rep(i, N-K){
      cout << 1 << " ";
    }
    cout << endl;
  }else{
    rep(i, K){
      cout << S << " ";
    }
    rep(i, N-K){
      cout << 1000000000 << " ";
    }
    cout << endl;
  }
}


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


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int max=a[0];
	int pos=0;
	for(int i=0;i<n;i++)
	{
		if(max<a[i])
		{
			max=a[i];
			pos=i;
		}	
	}
	int count=0;
	for(int i=0;i<n;i++)
	{
		if(max==a[i])
			count++;
	}	
	if(count>1)
	{
		for(int i=0;i<n;i++)
			cout<<max<<endl;

	}
	else
	{
		int tmp=a[0];
		if(tmp==max)
			tmp=a[1];
		for(int i=0;i<n;i++)
		{
			if(a[i]>tmp && a[i]!=max)
			{
				tmp=a[i];
			}
		}
		for (int i = 0; i < n; ++i)
		{
			if(i==pos)
			{
				cout<<tmp<<endl;
			}
			else
			{
				cout<<max<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 9007199254740997;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

const int w=5;
const int k=800;
const int n=26;
int ww;
int d;

VI c(n);
VVI s(365,VI(n));

struct st{
	VI a;
	ll score;
	bool operator<(const st &another) const {return score < another.score;};
};

vector<st> f(st p){
	VI a=p.a; ll score=p.score;
	int now=a.size()+1;
	VI last(n,0);
	REP(i,a.size())
		last[a[i]]=i+1;
	VI down(n); ll downsum=0;
	REP(i,n){
		down[i]=c[i]*(now-last[i]);
		downsum+=down[i];
	}
	a.push_back(-1);
	vector<st> tmp;
	REP(i,n){
		a[now-1]=i;
		tmp.push_back({a,score-downsum+down[i]+s[now-1][i]});
	}
	sort(ALL(tmp));
	vector<st> ret;
	REP(i,ww)
		ret.push_back(tmp[n-1-i]);
	return ret;
}

int main(){
	cin >> d;
	REP(i,n) cin >> c[i];
	REP(i,d)REP(j,n) cin >> s[i][j];
	priority_queue<st> q;
	VI a(0);
	q.push({a,0});
	REP(i,d){
		priority_queue<st> next;
		ww=w;
		REP(j,k){
			if(j%200==0)
			ww--;
			if(q.empty())
				break;
			for(auto nx:f(q.top()))
				next.push(nx);
			q.pop();
		}
		q=next;
	}
	REP(i,d)
		cout << q.top().a[i]+1 << endl;
	//cout << q.top().score << endl;
	return 0;
}

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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = 160 + 10;
int n, m, a[MAXN][MAXN], b[MAXN][MAXN];
bitset<MAXN * MAXN> dp[MAXN][MAXN];

void update(int x, int y, bitset<MAXN * MAXN> &f) {
    int v1 = a[x][y] - b[x][y] + 80;
    int v2 = b[x][y] - a[x][y] + 80;
    dp[x][y] = dp[x][y] | (f << v1) | (f << v2);
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> b[i][j];
        }
    }

    dp[1][1].set(a[1][1] - b[1][1] + 80);
    dp[1][1].set(b[1][1] - a[1][1] + 80);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (i < n) {
                update(i + 1, j, dp[i][j]);
            }
            if (j < m) {
                update(i, j + 1, dp[i][j]);
            }
        }
    }

    int ans = (int)1e9;
    for (int i = 0; i < MAXN * MAXN; ++i) {
        int v = i - 80 * (n + m - 1);
        if (dp[n][m][i]) {
            ans = min(ans, abs(v));
        }
    }

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

Measured memory_bytes: 48256
n = int(input())
a = list(map(int, input().split()))

sub = []
for i in range(n):
    sub.append(a[i] - i - 1)
sub.sort()

def geta(b):
    un=0
    for i in range(n):
        un+=abs(sub[i]-b)
    return un

med = sub[n//2]
ans=10**20
for i in range(med-1,med+1):
    num = geta(i)
    if ans > num:
        ans=num
print(ans)

Measured memory_bytes: 99668
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int min=(h2*60+m2)-(h1*60+m1)-k;
    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
struct iofix
{
   ios_base::Init i;
   iofix() {
      cin.sync_with_stdio(0);
      cin.tie(0);
      cout.sync_with_stdio(0);
      cout.tie(0);
      cout.precision(10);
      cout << fixed;
   }
} iofix;
const int64_t M = 10008;
int64_t N; 
std::vector<int64_t> v(M);
void solve(){
     cin >> N;
     for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            if(i*i+j*j+i*j>=N)
                continue;
            for(int k=1;k<=N;k++){
            if(i*i+j*j+k*k+i*j+i*k+j*k <=N)
                v[i*i+j*j+k*k+i*j+i*k+j*k]++;
           }
        }
     }
     for(int i=1;i<=N;i++)
          cout << v[i] << "\n";
}

int main(){
   	solve();

   return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <tuple>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using namespace std;

int N;
double p[3005];
double dp[3005][3005];

int main(void) {
    cin >> N;
    REP(i, 1, N) {
        cin >> p[i];
    }
    
    dp[1][0] = 1;
    dp[1][1] = p[1];
    for (int i=1; i<=N; i++) {
        dp[i][0] = 1;
    }
    for (int i=2; i<=N; i++) {
        for (int j=1; j<=i; j++) {
            if (i == j) {
                dp[i][j] = dp[i-1][j-1] * p[i];
            } else {
                dp[i][j] = dp[i-1][j] + (dp[i-1][j-1] - dp[i-1][j]) * p[i];
            }
        }
    }
    
    printf("%.10lf\n", dp[N][(N+1)/2]);
    
    return 0;
}



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

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];
    long long res = 0;
    for(int bit = 0;bit < (1<<N);++bit){
        bool ok = true;
        for(int i = 0; i < M;++i){
            int con = 0;
            for(auto v : s[i]){
                if(bit&(1<<v)) ++con;
            }
            if(con % 2 != p[i]) ok = false;
        }
        if(ok) ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n,k;
int ans;
int main ()
{
	scanf("%d%d",&n,&k);
	while(n>=k)
	{
		n-=1;
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
//author : raghav_0901
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define int long long int
#define f(i,s,e) for(i=s;i<e;++i)
#define fr(i,s,e) for(i=s;i>=e;i--)
#define all(x) (x).begin(),(x).end()
#define _in(v) for(auto &x:v) cin>>x;
#define ff(i,s,e,f) for(i=s;i<e && f;++i)
#define mem(arr,val) memset(arr, val, sizeof(arr));
#define _out(v) for(auto x:v) cout<<x<<' '; cout<<'\n';
#define _var register int i,j,num,ans=0,cnt=0,sum=0,t=1;
#define ARENA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef vector<int> vec;
typedef pair<int,int> pr;

const int lim = 1000000;
const int mod = 1000000;

signed main(void)
{
    ARENA
    int n,i,ans=0;cin>>n;
    f(i,1,n+1)
        if(i%5 && i%3)
            ans+=i;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

char peek(){
    char c=getchar();
    ungetc(c,stdin);
    return c;
}

struct Tree_t{
    int voters;
    vector<Tree_t> children;
};

Tree_t parse(){
    getchar();
    int a=0;
    Tree_t ret;
    while (isalnum(peek())){
        a=a*10+(getchar()-'0');
    }

    if (a) {
        ret.voters=a;
        goto end;
    }

    
    while(peek()!=']'){
        ret.children.push_back(parse());
    }

end:
    getchar();
    return ret;
}

int solve(const Tree_t& a){
    if (a.children.empty()) return (a.voters+1)/2;

    vector<int> candi;
    for(const auto &i:a.children ) candi.push_back(solve(i));
    sort(candi.begin(),candi.end());

    auto ans=0;
    for(int i=0;i<(candi.size()+1)/2;i++) ans+=candi[i];
    return ans;
}

int main(){

    int n;
    scanf("%d\n",&n);
    for(int i=0;i<n;i++){
        
        
        printf("%d\n",solve(parse()));
        getchar();
        // puts("hello");
    }

    

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

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


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

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

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

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

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}


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

ll N;
vector<ll> E[100010];
int main(){
  cin >> N;
  ll n = -1;
  for(ll i = 1; i <= 100010; i++){
    if(i * (i+1) / 2 == N) n = i;
  }
  if(n == -1){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  cout << n+1 << endl;
  ll now = 1;
  for(ll i = 0; i <= n; i++){
    for(ll j = i + 1; j <= n; j++){
      E[i].pb(now);
      E[j].pb(now);
      now++;
    }
  }
  rep(i, n+1){
    cout << n << " ";
    rep(j, n){
      cout << E[i][j];
      if(j == n-1) cout << endl;
      else cout << " ";
    }
  }

}


Measured memory_bytes: 7296
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (c >= a && c <= b)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(){
  int n;
  cin >> n;
  int ac=0;
  int wa=0;
  int tle=0;
  int re=0;
  string str;
  for(int i=0; i<n; i++){
    cin >> str;
    if("AC"==str)ac++;
    if("WA"==str)wa++;
    if("TLE"==str)tle++;
    if("RE"==str)re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <stdlib.h>

#define INC(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define DEC(i, a, b) for(int (i) = (a); (i) > (b); --(i))
#define REP(i, n)    INC(i, 0, n)
#define comp(a, b) int comp(const void *(a), const void *(b))

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int abs(int x){
    return x > 0? x : -x;
}

int max(int a, int b){
    return a > b? a : b;
}

int min(int a, int b){
    return a < b? a : b;
}


int main(){
    char str[5];
    cin >> str;
    int p = 0, m = 0;
    REP(i, 4) {
        if(str[i] == '+') p++;
        else m++;
    }
    cout << p -m << endl;
    return 0;
}

Measured memory_bytes: 256
program main
   implicit none
   integer,allocatable,dimension(:)::a
   integer::n,i,ma,counter=0
   read(*,*)n
   allocate(a(n))
   read(*,*)a
   ma=a(1)
   do i=1,n
     if(ma<=a(i))then
       counter=counter+1
       ma=a(i)
     endif
   enddo
   write(*,'(i0)')counter
end program main


Measured memory_bytes: 640
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    if a.count(0) > 0:
        ret = 0
    else:
        ret = 1
        for i in a:
            ret *= i
            if ret > 1e18:
                ret = -1
                break
    print(ret)

Measured memory_bytes: 21788
#include <stdio.h>
int main(void){
	int n;
	scanf("%d",&n);
	int a[n];
	int b[n];
  int i;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[a[i]-1]=i+1;
	}
	for(i=0;i<n;i++){
		printf("%d ",b[i]);
	}
return(0);
}

Measured memory_bytes: 1536
#include <stdio.h>
int main() {
  int a,b,c,d,e,k;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  scanf("%d",&k);
  if(k>=e-a){
    printf("Yay!");
  }else{
    printf(":(");
  }
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
(n, ), *s = [[*map(int, i.split())] for i in open(0)]
a, b = list(zip(*s))
c = 0
for i in reversed(range(n)):
    q = (a[i] + c) % b[i]
    c += b[i] - q if q > 0 else 0
print(c)


Measured memory_bytes: 35148
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
from math import gcd
ans=a[0]
for i in range(1,n):
  ans=ans*a[i]//gcd(ans,a[i])
s=sum(pow(x,mod-2,mod) for x in a)
print(s*ans%mod)


Measured memory_bytes: 10192
#include<bits/stdc++.h>
using namespace std;
int n,y,ans,ic,uc,hc;
int main(){
    cin>>n>>y;


    for(int i=0;i<n+1;i++){
        if(1000*i>y||i>n)break;
        for(int u=0;u<n+1;u++){
            if(1000*i+5000*u>y||i+u>n)break;
            for(int h=0;h<n+1;h++){
                if(1000*i+5000*u+10000*h>y||i+u+h>n)break;
                if(1000*i+5000*u+10000*h==y&&i+u+h==n){
                    ic=h;
                    uc=u;
                    hc=i;
                    ans=1;
                    break;
                }
            }if(ans)break;
        }if(ans)break;
    }

    for(int i=0;i<1000000000*100000;i++){
        int aho;
    }








    if(ans==1){
        cout<<ic<<" "<<uc<<" "<<hc<<endl;
    }else{
        cout<<"-1 -1 -1"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=1001 ;
int main()
{
   fast ;
   ll h,n ;
   cin>>h>>n ;
   ll ans=h/n ;
   if(h%n!=0)
    ans++ ;


   cout<<ans ;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if ((s.length() % 2) ^ (s[0] == s.back())) cout << "First";
    else cout << "Second";
}


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

using namespace std;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    // freopen("data.in","r",stdin);

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    cout << max(a*b,c*d) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    string s;
    cin >> s;
    rep(i, s.size())
    {
        if (s[i] == '1')
            s[i] = '9';
        else if (s[i] == '9')
            s[i] = '1';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#define T 999
D[T][T],i,j,x,y,a,b,c,R,F=T*9;main(k){scanf("%*d%d%d",&x,&y);for(D[0][0]=F;~scanf("%d%d%d",&a,&b,&c);)for(i=T;i-->a;)for(j=T;j-->b;)k=D[i-a][j-b]-c,D[i][j]<k?D[i][j]=k:0;for(i=x,j=y;i<T&&j<T;i+=x,j+=y)D[i][j]>R?R=D[i][j]:0;printf("%d\n",R>0?F-R:-1);}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main() {
    int b1, b2, b3;
    int c[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];

        }
    }

    for (int a1 = 0; a1 <= 100; a1++) {
        for (int a2 = 0; a2 <= 100; a2++) {
            for (int a3 = 0; a3 <= 100; a3++) {
                b1 = c[0][0] - a1;
                b2 = c[0][1] - a1;
                b3 = c[0][2] - a1;

                bool is_valid = true;

                int a[] = {a1, a2, a3};
                int b[] = {b1, b2, b3};

                for (int i = 0; i < 3; i++) {
                    for (int j = 0; j < 3; j++) {
                        if (c[i][j] != a[i] + b[j]) {
                            is_valid = false;
                        }
                    }
                }
                if (is_valid) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int A,B,C,K;
		A=sc.nextInt();
		B=sc.nextInt();
		C=sc.nextInt();
		K=sc.nextInt();
		int max=A;
		if(A>=K) {
			max = K;
		}
		else if(A+B>=K) {
			max=A;
		}else {
			max=A-(K-A-B);
		}
		System.out.println(max);
		
	}
}





Measured memory_bytes: 35756
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d)
		cout<<"Yes";
	else if(abs(a-b)<=d && abs(b-c)<=d)
		cout<<"Yes";
	else
		cout<<"No";
	return 0; 
}

Measured memory_bytes: 256
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


class Main {

    /*static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;

    public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    public static boolean isPalindrome(String str)
    {

        // Pointers pointing to the beginning
        // and the end of the string
        int i = 0, j = str.length() - 1;

        // While there are characters toc compare
        while (i < j) {

            // If there is a mismatch
            if (str.charAt(i) != str.charAt(j))
                return false;

            // Increment first pointer and
            // decrement the other
            i++;
            j--;
        }

        // Given string is a palindrome
        return true;
    }*/

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

            int hn=sc.nextInt();
            int m=sc.nextInt();
            int h[]=new int[hn];
            int s=0;
            for(int j=0;j<hn;j++)
            {
                h[j]=sc.nextInt();
            }
            Arrays.sort(h);
            if(hn<=m)
                System.out.println(0);
            else
            {
                long ans=0;
                for(int j=0;j<hn-m;j++)
                    ans+=h[j];
                System.out.println(ans);
            }

        }
    }




Measured memory_bytes: 64960