akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toLong() }.toMutableList()

    for (i in 0 until n - 1) {
        val f = aa[i]
        val s = aa[i + 1]

        if (f > 0 && s > 0) {

        } else if (f > 0 && s < 0) {

        } else {
            aa[i] = f * -1
            aa[i + 1] = s * -1
        }

    }

    if (aa.all { it > 0 }) {
        println(aa.sum())
    } else {
        var min = Long.MAX_VALUE
        var sum = 0L
        for (i in 0 until n) {
            min = Math.min(min, Math.abs(aa[i]))
            sum += Math.abs(aa[i])
        }

        println(sum - min * 2)
    }
}

Measured memory_bytes: 59816
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    S = input()
    MOD = 1000000007

    d = defaultdict(lambda: 0)
    for s in S:
        d[s] += 1

    ans = 1
    for n in d.values():
        if n == 0: continue
        ans *= (n+1)
    print((ans-1) % MOD)
    # print(ans - 1)
if __name__ == '__main__':
    solve()



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

using namespace std;

struct edge {
    int to, cost,id;
};
typedef vector<vector<edge> > AdjList;
AdjList graph;

typedef pair<int, int> P;

const int INF = 10000000;

vector<int> dist;
vector<int> prever;
vector<int> rout;


void dijkstra(int n, int s){
    dist = vector<int>(n,INF);
    prever = vector<int>(n,-1);
    rout = vector<int>(n,-1);

    dist[s] = 0;

    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first){
            continue;
        }
        for(int i=0;i<graph[v].size();i++){
            edge e = graph[v][i];
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                prever[e.to] = v;
                rout[e.to] = e.id;
                que.push(P(dist[e.to],e.to));
            }
        }
    }
}

vector<int> get_path(int t){ //頂点tへの最短路
    vector<int> path;
    for(; t != -1;t=prever[t]){
        path.push_back(t);

    }

    reverse(path.begin(), path.end());
    return path;
}

vector<int> Get_path(int t){ //頂点tへの最短路
    vector<int> path;
    for(; t != -1;t=prever[t]){
        path.push_back(rout[t]);
    }

    reverse(path.begin(), path.end());
    return path;
}

int main(){
    int n, m;
    cin >> n >> m;
    graph = AdjList(n);
    map<ll,ll>mp;
    for(int i=0;i<m;i++){
        int from, to, cost;
        cin >> from >> to >> cost;
        from--;to--;
        graph[from].push_back((edge){to,cost,i});
        graph[to].push_back((edge){from,cost,i});

    }

  //  rep(i,n-1){
      for (int j=0;j<n;j++){
      dijkstra(n,j);
  //  }

      rep(i,n){
        vector<int> ans = Get_path(i);
        for(int k=0;k<ans.size();k++){
          //cout << i<<'i'<<j<<'j'<<ans[k] << endl;
        mp[ans[k]]++;
        }

      //  cout<<endl;
      }

    //  cout<<'T'<<endl;

    }

ll cnt=mp.size();
cout<<m+1-cnt;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    ll K,N;cin>>K>>N;
    vector<ll> A(N);
    REP(i,N) cin>>A[i];
    vector<ll> dist(N);
    REP(i,N-1) dist[i]=A[i+1]-A[i];
    dist[N-1]=K+A[0]-A[N-1];
    ll ans=1e18;
    REP(i,N) ans=min(ans,K-dist[i]);
    cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n;
    cin>>n;
    vector<ll> as(n);
    rep(i, n) cin>>as[i];

    int cnt = 0;
    rep(i, n) if (as[i] < 0) cnt++;
    ll ans = 0;
    rep(i, n) ans += abs(as[i]);

    if (cnt % 2 == 1) {
        ll m = 1001001001;
        rep(i, n) if (abs(as[i]) < m) m = abs(as[i]);
        ans -= 2 * m;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair
 

int main(){
  CIN(n,m);
  VC2(m,a,b);
  V v(n,INF);
  REP(i,m)v[a[i]-1]=min(v[a[i]-1],b[i]-1);
  int ans = 0;
  ll dam_ind = INF;
  REP(i,n){
    if(dam_ind == i){
      ++ans;
      dam_ind = INF;
    }
    dam_ind = min(dam_ind,v[i]);
  }
  COUT(ans);

  return 0;
}


Measured memory_bytes: 2688
r, g, b, n = map(int, input().split())
 
count = 0
for i_r in range(0,int(n/r)+1):
    if (n - r*i_r)<0:continue
    for i_g in range(0,int(n/g)+1):
        if (n - r*i_r - g*i_g)<0:continue
        if 0==((n - r*i_r - g*i_g)%b):
 
            count +=1
 
print(count)

Measured memory_bytes: 40556
#include<bits/stdc++.h>
using namespace std;
int mx=0;
int n,m;
int a[200010],father[200010],num[200010];
int findfather(int x){
	int z=x;
	while(x!=father[x]){
		x=father[x];
	} 
	while(z!=father[z]){
		int a=z;
		z=father[z];
		father[a]=x;
	}
	return x;
}
void Union(int a,int b){
	int faA=findfather(a);
	int faB=findfather(b);
	if(faA!=faB)father[faA]=faB;
}
int main(){
	int u,v;
	cin>>n>>m;
	for(int i=1;i<=n;i++)father[i]=i; 
	for(int i=1;i<=m;i++){
		cin>>u>>v;
		Union(u,v);
	} 
	for(int i=1;i<=n;i++)num[findfather(i)]++;
	for(int i=1;i<=n;i++)mx=max(num[i],mx);
	cout<<mx<<endl;
} 

Measured memory_bytes: 5128
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> X(N);
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>X[i];
        ans+=X[i]*X[i];
    }

    for(int i=1;i<=100;i++){
        int tmp=0;
        for(auto p:X){
            tmp+=(p-i)*(p-i);
        }
        if(ans>tmp){
            ans=tmp;
        }
    }

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

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

ll zetai(ll a,ll b){
  if(a>b) return a-b;
  else return b-a;
}

int main(){
  ll n,d;
  cin>>n>>d;
  vector<ll>x(n);
  vector<ll>y(n);
  vector<ll>dis2(n,0);
  ll cnt=0;
  for(ll i=0;i<n;i++){
    cin>>x[i]>>y[i];
    dis2[i]=x[i]*x[i]+y[i]*y[i];
    if(dis2[i]<=d*d){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  
  return 0;
}

Measured memory_bytes: 7984
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n';

using namespace std;

int n, i;

int main(){

    cin >> n >> i;

    cout << (n-i)+1;



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

// char** arr = new char*[r];
// for(long long i = 0; i < r; i++) arr[i] = new char[c];

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	if strings.Count(s, "a") == 1 && strings.Count(s, "b") == 1 && strings.Count(s, "c") == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

int main() {
    int N, A;
    scanf("%d%d", &N, &A);
    if (N % 500 == 0 || N % 500 <= A) {
        printf("Yes");
        return 0;
    } else {
        printf("No");
        return 0;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int h,w; cin >> h >> w;
	int a,b; cin >> a >> b;

	cout << h * w - a * w - h * b + a * b << endl;

}


Measured memory_bytes: 256
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=n;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define re return 0;
// *#######################################################################################*
// *#########################################################################################*
    //      ll ans=0,b[5000005]={0},a[5000005],i,n,x=0;                
    

int main()
{
      
      fast
         
         
         
         ll n,k,x,y;
         cin>>n>>k>>x>>y;
         
         ll s=0;
         
         s+=(min(k,n))*x;
         if(n-k>0){
         s+=(n-k)*y;
         }
         o(s)
         
         
         
         
         
        
	re
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int cnt = 0;
  while (A > 0 && C > 0) {
    if (cnt%2 == 0) {
      C -= B;
    }
    else {
      A -= D;
    }
    cnt++;
  }
  if (cnt%2 == 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
	int n, a = 0;
	long long Ans = 0;
	scanf("%d", &n);
	for(int i = 1, x; i <= n; ++i) {
		scanf("%d", &x);
		a = max(a, x);
		Ans += a - x;
	}
	printf("%lld", Ans);
	return 0;
}

Measured memory_bytes: 3808
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<ctime>

#define int long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

const int inf=1e18,N=2e5+5;

int n,sum=1,a[N];


IL int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

signed main()
{
	n=read();
	Rf(i,1,n) a[i]=read();
	Rf(i,1,n) {
		if(a[i]==0) {
			puts("0");
			return 0;
		}
	}
	Rf(i,1,n) {
		R int s=a[i];
		if(sum*s<sum) {
			sum=-1;break;
		}
		sum*=s;
		if(sum>inf) {
			sum=-1;break;
		}
	}
	write(sum);

    return 0;
}


Measured memory_bytes: 4420
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

int main() {
	int n, m; cin >> n >> m;
	map<ll, ll> cnt;
	ll s = 0;
	for (int i = 0; i < n; i++) {
		ll a; cin >> a;
		s += a;
		cnt[s%m]++;
	}
	ll ans = 0;
	for (auto p : cnt) {
		ll t = p.second + (p.first == 0);
		ans += t*(t - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n, b) << "\n";
    return 0;
}


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

using namespace std;

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

int gcd(int a, int b, int c) {
    return gcd(gcd(a, b), c);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (int k = 1; k <= n; ++k) {
                ans += gcd(i, j, k);
            }
        }
    }
    cout << ans << endl;
}

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

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

    int cnt[n] = {0};
    rep(i, n - 1) {
        if (s.substr(i, 2) == "AC") cnt[i + 1]++;
        cnt[i + 1] += cnt[i];
    }

    rep(i, q) {
        int l, r;
        cin >> l >> r;
        cout << cnt[r - 1] - cnt[l - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
S = input()

alph = [0] * 26

for index, i in enumerate(S):
    pointer = ord(i) - ord("a")
    alph[pointer] += 1


if(len(S) == 26):
    if(S=="zyxwvutsrqponmlkjihgfedcba"):
        print(-1)
        exit()
    else:
        old=""
        for i, s1 in enumerate(S[::-1]):
            if i != 0 and s1 < old[-1]:
                out = S[:len(S)-i-1] + min([o for o in old if o > s1])
                print(out)
                exit()
            old += s1
        
else:
    for i in range(26):
        if(alph[i]==0):
            print(S+chr(i+ord("a")))
            exit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d, k;
    cin >> a >> b >> c >> d >> k;
    int t1 = 60 * a + b, t2 = 60 * c + d;
    int dif = t2 - t1;
    cout << dif - k << '\n';
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

const int MAX = 10000000;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/****** define constant end ********/

/****** define variable start ******/
/*
ll n;
vl a;
*/
string s, t;
/******* define variable end *******/
int solve() {
	cin >> s >> t;
	ll ans = 0;
	REP(i, s.size()-t.size()+1){
		ll anstmp = 0;
		REP(j, t.size()){
			if(s.substr(i + j, 1) == t.substr(j, 1)){
				anstmp++;
			}
		}
		ans = max(ans, anstmp);
	}
	cout << t.size() - ans << endl;
	/*
	cin >> n;
	a.resize(n);
	vl sumvec(n+1);
	sumvec[0] = 0;
	REP(i, n){
		cin >> a[i];
		sumvec[i+1] = sumvec[i] + a[i];
		sumvec[i+1] %= MOD;
	}
	ll ans = 0;
	REP(i, n){
		ans += (sumvec[n]  - sumvec[i+1]) * a[i];
		ans %= MOD;
	}
	ans %= MOD;
	cout << ans << endl;
	*/
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int N;
  string S;
  cin >> N >> S;

  vi l(N + 1), r(N + 1);
  rep(i, N) {
    if (S[i] == 'W') {
      l[i + 1] = l[i] + 1;
      r[i + 1] = r[i];
    } else {
      r[i + 1] = r[i] + 1;
      l[i + 1] = l[i];
    }
  }

  int res = INF;
  rep(i, N) res = min(res, l[i] + (r[N] - r[i + 1]));

  cout << res << endl;
}

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

int main()
{
    int n;
    cin>>n;
    float s[n];
    for(int i=0;i<n;i++)
    {
    cin>>s[i];
    }
    float sum=0;
    sort(s,s+n);
    sum=(s[0]+s[1])/2;
    for(int i=2;i<n;i++)
    {
        sum=(sum+s[i])/2;
    }
    cout<<sum;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main { 
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  for(int i = 0;i < 3000;i++) {
	  int a = sc.nextInt();
	  int b = sc.nextInt();
         if(a ==0 && b == 0){
		  break;
	  }
	  else if(a>=b) {
		  System.out.printf("%d %d\n",b,a);
	  }
	  else if(a<b){
		  System.out.printf("%d %d\n",a,b);
	  }
	  }
  }
}



Measured memory_bytes: 39952
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int N;
vector<vector<P> > v(100000);
int table[100000];
void solve(int now, int color){
  table[now] = color;
  for(int i=0 ; i<v[now].size() ; i++){
    P p = v[now][i];
    if(table[p.fi] != 0){
      continue;
    }
    if(p.se %2 == 0){
      solve(p.fi, color);
    }else{
      solve(p.fi, -color);
    }
  }
}
int main(){
  cin>>N;
  rep(i,0,N-1){
    ll x,y,z;  cin>>x>>y>>z;
    --x;  --y;
    v[x].push_back(P{y, z});
    v[y].push_back(P{x, z});
  }
  for(int i=0 ; i<N ; i++){
    table[i] = 0;
  }
  solve(0, 1);
  rep(i,0,N){
    cout << (table[i] == -1 ? 0 : 1) << endl;
  }
  return 0;
}


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

using namespace std;

const int N = 2e3+7;
const int MOD = 1e9+7;

template <int _MOD> struct Mint
{
    int v = 0;
    Mint() {}
    Mint(int _v) : v((_v%_MOD+_MOD)%_MOD) {}
    Mint(long long _v) : v(static_cast<int>((_v%_MOD+_MOD)%_MOD)) {}
    Mint operator = (const int _v) { this->v = _v; return *this; }
    Mint operator = (const long long _v) { this->v = static_cast<int>(_v%_MOD); return *this; }
    bool operator < (const Mint &b) const { return v < b.v; }
    bool operator > (const Mint &b) const { return v > b.v; }
    bool operator == (const Mint &b) const { return v == b.v; }
    bool operator != (const Mint &b) const { return v != b.v; }
    bool operator <= (const Mint &b) const { return v < b.v || v == b.v; }
    bool operator >= (const Mint &b) const { return v > b.v || v == b.v; }
    Mint operator + (const Mint &b) { return Mint(v+b.v); }
    Mint operator - (const Mint &b) { return Mint(v-b.v); }
    Mint operator * (const Mint &b) { return Mint(1ll*v*b.v); }
    Mint operator / (const Mint &b) { return Mint(b.inv()*v); }
    Mint operator += (const Mint &b) { return *this = *this+b; }
    Mint operator -= (const Mint &b) { return *this = *this-b; }
    Mint operator *= (const Mint &b) { return *this = *this*b; }
    Mint operator /= (const Mint &b) { return *this = *this/b; }
    Mint pow(int p) const {
        Mint res(1), x(*this);
        while (p) {
            if (p&1) res = res*x;
            x *= x;
            p >>= 1;
        }
        return res;
    }
    Mint inv() const { return pow(_MOD-2); }
    friend istream& operator >> (istream &is, Mint &mt) { return is >> mt.v; }
    friend ostream& operator << (ostream &os, const Mint &mt) { return os << mt.v; }
};
using mint = Mint<MOD>;

int n, m;
int s[N], t[N];
mint dp[N][N];
// dp[i][j] s[1~i] t[1~j]

int main()
{
    cin >> n >> m;
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) cin >> s[i], dp[i][0] = 1;
    for (int i = 1; i <= m; ++i) cin >> t[i], dp[0][i] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (s[i] == t[j]) {
                dp[i][j] = dp[i-1][j]+dp[i][j-1];
            } else {
                dp[i][j] = dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
            }
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int n, k;
ll fac[N], inv[N];
ll powmod(ll a, ll b)
{
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans*a%mod;
		a = a*a%mod;
		b >>= 1;
	}
	return ans;
}
void init(int n)
{
	fac[0] = 1;
	for(int i=1;i<=n;i++) fac[i] = fac[i-1]*i%mod;
	inv[n] = powmod(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) inv[i] = inv[i+1]*(i+1)%mod;
}
ll comp(ll a,ll b)
{
	if(a<b||b<0||a<0) return 0;
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> k;
 	init(n);
 	ll ans = 0;
 	for(int i=0; i<=min(n-1, k); i++)
 	{
 		ll cur = comp(n, i)*comp(n-1, n-i-1)%mod;
 		ans = (ans + cur)%mod;
 	}
 	if(ans<0) ans += mod;
 	cout << ans;
	return 0;
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

string S, T;

int main(){
    cin >> S >> T;
    cout << T << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define double long double
const int mod = 1e9 + 7;
const int K = 26;

int32_t main()
{
    fastio;

    int n; cin >> n;
    int minL = INT_MAX, minR = INT_MAX;
    int L0 = 0, R0 = 0;
    int tL = 0, tR = 0;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        int L = 0, R = 0;
        int ob = 0, cb = 0;
        for (int j = 0; j < (int)s.size(); j++) {
            if (s[j] == '(') ob++;
            else cb++;

            if (ob >= cb) {
                ob -= cb;
            } else {
                L += cb;
            }

            cb = 0;
        }
        R = ob;
        if(L == 0) R0 += R;
        if(R == 0) L0 += L;
        if(L != 0 && R != 0){
            tL += L;
            tR += R;
            minL = min(minL, L);
            minR = min(minR, R);
        }
    }

    bool poss = true;
    if(tR > 0){
        if(L0 == 0) poss = false;
        if(L0 < minR) poss = false;
    }

    if(tL > 0 ){
        if(R0 == 0) poss = false;
        if(R0 < minL) poss = false;
    }
    if(tL + L0 != tR + R0) poss = false;
    cout << (poss ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 300

const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int dp[ARRAY_MAX][ARRAY_MAX];

int main() {

	string s;
	vector<vector<int> > vec;

	while (getline(cin, s))
	{
		vector<int> a;
		int siz = s.size();
		int t = 0;
		for (int i = 0; i < siz; i++)
		{
			if (isdigit(s[i]))
			{
				t = t * 10 + s[i] - '0';
			}
			if(s[i] == ',' || i == siz - 1)
			{
				a.push_back(t);
				t = 0;
			}
		}
		vec.push_back(a);
	}
	
  
	dp[0][0] = vec[0][0];
	int center = vec.size() / 2;


	for (int i = 0; i < vec.size()-1; i++)
	{
		for (int j = 0; j < vec[i].size(); j++)
		{
			if (i < center)
			{	
				//配るdp
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + vec[i + 1][j]);
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + vec[i + 1][j + 1]);
			}
			else
			{
				if (j == 0)
				{
					
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + vec[i + 1][j]);
				}
				else if (j == vec[i].size() - 1)
				{
					dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + vec[i + 1][j - 1]);
				}
				else
				{
					
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + vec[i + 1][j]);
					dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + vec[i + 1][j - 1]);
				}
			}
		}
	}
	cout << dp[vec.size() - 1][0] << endl;



	return 0;
}


Measured memory_bytes: 3104
n = int(input())
ac = wa = tle = re = 0
while n > 0:
    j = input()
    if j == 'AC':
        ac += 1
    if j == 'WA':
        wa += 1
    if j == 'TLE':
        tle += 1
    if j == 'RE':
        re += 1
    n -= 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;
	multimap<int,int>m;
	multimap<int,int>::iterator itr;
	for(int x=0;x<n;x++){
		int a,b;
		cin>>a>>b;
		m.insert({b,a});
	}
	int ct=0;
	for(itr=m.begin();itr!=m.end();itr++){
		ct+=itr->second;
		if(ct>itr->first){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";







	
	
return 0;	
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define vi vector<ll>
const int INF = 1e9;
const int N = 100005;

void solve() {
	int sa, ha, sb, hb;
	cin >> ha >> sa >> hb >> sb;
	while (1) {
		hb -= sa;
		//cout << hb << " ";
		if (hb <= 0) break;
		ha -= sb;
		//cout << ha << " ";
		if (ha <= 0) break;
	}

	if (hb <= 0) cout << "Yes";
	else cout << "No";


}

int main() {

	FASTIO;

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif

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

Measured memory_bytes: 3580
N = int(input())
A = list(map(int, input().split()))
B = [0]
for i in range(1, N):
    if A[i - 1] - A[i] > 0:
        B.append(A[i - 1] - A[i])
        A[i] += A[i - 1] - A[i]
print(sum(B))

Measured memory_bytes: 32172
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        Console.WriteLine(Math.Ceiling((double)input.Sum()/2));


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 11348
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>

using namespace std;


int main() {
	map<int, int> mp;
	long long int n, m=0,tmp=0,ax=0,k=0,t[5000],p[5000],x[300000],res[5000];
	string str, str2[5000];
	cin >> n >>k;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
		if (x[i] == 1) { tmp = i; }
	}
	
	cout <<(n-2)/(k-1)+1;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define MAXN 100007
using namespace std;

int n, d[MAXN];

int main(){
    cin >> n;
    for(register int i = 1; i <= n; ++i){
        cin >> d[i];
    }
    sort(d + 1, d + n + 1);
    int k = n / 2;
    cout << d[k + 1] - d[k] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (C >= A && C <= B) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 1000000000

int main(){
  int M,K;
  cin>>M>>K;
  if((1<<M)<=K){
    cout<<-1<<endl;
  }else if(M>1){
    cout<<K<<" ";
    for(int i=0;i<(1<<M);i++){
      if(i==K){
        continue;
      }
      cout<<i<<" ";
    }
    cout<<K<<" ";
    for(int i=(1<<M)-1;i>=0;i--){
      if(i==K){
        continue;
      }
      cout<<i<<" ";
    }
    cout<<endl;
  }else if(M==1){
    if(K==0){
      cout<<"0 0 1 1"<<endl;
    }else{
      cout<<-1<<endl;
    }
  }else if(M==0){
    if(K==0){
      cout<<"0 0"<<endl;
    }else{
      cout<<-1<<endl;
    }
  }
}


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

using namespace std;

int main(void)
{
        int x, y, z;
        cin >> x >> y >> z;
        int sum = z;
        int cnt = 0;
        int unit = y + z;
        while(sum <= x){
                sum += unit;
                cnt++;
        }
        cout << cnt - 1 << endl;
        return 0;
}

Measured memory_bytes: 256
class Node
  attr_reader :go, :come

  def initialize(id)
    @id = id
    @go = []
    @come = []
  end
end

class Arrow
  attr_reader :source, :sink, :label
  
  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
    source.go << self
    source.come << self
  end
end

class Result
  attr_reader :target, :spell

  def initialize(target, spell)
    @target = target
    @spell = spell
  end
end

def advance(table, nodes, arrows)
  next_table = {}
  nodes.each do |node|
    best = table[node]
    node.go.each do |arrow|
      result = table[arrow.sink]
      next unless result
      test = arrow.label + result.spell
      if !best || test < best.spell
        best = Result.new(arrow.sink, test)
      end
    end
    next_table[node] = best if best
  end
  next_table
end

def check(table, result)
  return false unless result

  used = {}
  loop do
    node = result.target
    return true unless node
    return false if used[node]
    used[node] = true
    result = table[node]
  end
end

def work(nodes, arrows, start, goal)
  table = {goal => Result.new(nil, '')}
  (nodes.size*6).times do
    table = advance(table, nodes, arrows)
  end
  result = table[start]
  puts check(table, result) ? result.spell : 'NO'
end

loop do
  n, a, s, g = STDIN.gets.split.map(&:to_i)
  break if n == 0

  nodes = (0...n).map{|i| Node.new(i)}

  arrows = (0...a).map do |i|
    x, y, lab = STDIN.gets.split
    x = x.to_i
    y = y.to_i
    Arrow.new(nodes[x], nodes[y], lab)
  end

  start = nodes[s]
  goal = nodes[g]

  work(nodes, arrows, start, goal)
end

Measured memory_bytes: 26136
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,W;
    cin >> N >> W;
    vl w(N),v(N);
    rep(i,N){
        cin >> w[i] >> v[i];
    }
    ll dp[N+1][N+1][3*N+1];
    rep(i,N+1){
        rep(j,N+1){
            rep(k,3*N+1){
                dp[i][j][k]=0;
            }
        }
    }
    FOR(i,1,N+1){
        rep(j,N+1){
            rep(k,3*N+1){
                dp[i][j][k]=dp[i-1][j][k];
                if(k>=w[i-1]-w[0]&&j>=1)chmax(dp[i][j][k],dp[i-1][j-1][k-(w[i-1]-w[0])]+v[i-1]);
            }
        }
    }
    ll ans=0;
    rep(i,N+1){
        rep(j,3*N+1){
            if(j+w[0]*i<=W)chmax(ans,dp[N][i][j]);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void)
{
	int a,b;
	string s;
	cin >> a >> b >> s;

	for(int i=1;i<=a+b+1;i++)
	{
		if(i==a+1 && s[i-1]!='-')
		{
			cout << "No" << endl;
			return 0;
		}
		if(i!=a+1 && s[i-1]=='-')
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
n, k, q = gets.chomp.split(" ").map(&:to_i)
ans = Array.new(n, 0)
q.times do |i|
	ans[gets.chomp.to_i-1] += 1
end
n.times do |i|
	puts	k - q + ans[i] > 0 ? "Yes" : "No"
end








Measured memory_bytes: 3196
N,Q=map(int,input().split())
S=input()
LR=[map(int,input().split()) for i in range(Q)]

data=[0 for i in range(N)]
for i in range(N-1):
    data[i+1]=data[i]
    if S[i]+S[i+1]=="AC":
        data[i+1]+=1
for l,r in LR:
    print(data[r-1]-data[l-1])


Measured memory_bytes: 52832
import sys
import math
import bisect

def main():
    a, b, c = map(int, input().split())
    k = int(input())
    while b <= a and k > 0:
        b <<= 1
        k -= 1
    while c <= b and k > 0:
        c <<= 1
        k -= 1
    if a < b and b < c:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
#include <iostream>
using namespace std;
int main()
{
  int H, W;
  cin >> H >> W;
  string C[H];
  for (int i = 0; i < H; i++)
    cin >> C[i];
  for (int i = 0; i < H; i++)
  {
    cout << C[i] << endl;
    cout << C[i] << endl;
  }
  return 0;
}

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


struct Sieve {
        int n;
        vector<int> f,primes;
        
        Sieve(int n=1):n(n),f(n+1){
                f[0] = f[1] = -1;
                for(long long i=2;i<=n;++i){
                        if(f[i]) continue;
                        primes.push_back(i);
                        f[i] = i;
                        for(long long j = i*i;j <= n;j += i) {
                                if(!f[j]) f[j] = i;
                        }
                }
        }
        
        bool isPrime(int x){return f[x] == x;}
        
        vector<int> factorList(int x){
                vector<int> res;
                while(x != 1){
                        res.push_back(f[x]);
                        x /= f[x];
                }
                return res;
        }
        
        vector<pair<int,int>> factor(int x){
                vector<int> fl = factorList(x);
                if(fl.size() == 0) return {};
                vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
                for(int p:fl){
                        if(res.back().first == p){
                                res.back().second ++;
                        }else{
                                res.emplace_back(p,1);
                        }
                }
                return res;
        }
        
};
 
int main() {
  Sieve sieve(105);
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n){
    auto f = sieve.factor(i+1);
    for(auto p:f){
      mp[p.first] += p.second;
    }
  }
  //for(auto i:mp) cout << i.first << " " << i.second << endl;
  int a=0,b=0,c=0,d=0,e=0;
  for(auto p:mp){
    if(p.second>=74) a++;
    if(p.second>=24) b++;
    if(p.second>=2) c++;
    if(p.second>=14) d++;
    if(p.second>=4) e++;
  }
  int ans = a+b*(c-1)+d*(e-1)+(e*(e-1)/2) * (c-2);
  /*cout << a<< endl;
  cout << b << endl;
  cout << c << endl;
  cout << d << endl;
  cout << e << endl;*/
  cout << ans << endl;

  return 0;
}






Measured memory_bytes: 256
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    n,c = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    b = [int(i) for i in ipt().split()]
    nj = [[] for j in range(c+1)]
    nj[0] = [1]*401
    for j in range(1,c+1):
        for i in range(401):
            nj[j].append(nj[j-1][i]*i%mod)
    snj = [[0] for j in range(c+1)] #累積和,snj[j][b]-snj[j][a-1]で使用
    for j in range(c+1):
        sj = snj[j]
        ssj = nj[j]
        for i in range(1,401):
            sj.append((sj[-1]+ssj[i])%mod)
    dp = [snj[k][b[0]]-snj[k][a[0]-1] for k in range(c+1)]
    for i in range(1,n):
#        print(dp)
        ai = a[i]
        bi = b[i]
        for j in range(c,-1,-1):
            dp[j] = dp[j]*(bi-ai+1)%mod
            for k in range(1,j+1):
                dp[j] = (dp[j]+dp[j-k]*(snj[k][bi]-snj[k][ai-1]))%mod

    print(dp[c]%mod)


    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 78628
while 1:
    mid,term,add = map(int,input().split())
    if mid == -1 and term == -1 and add == -1:
        break
    s = mid + term
    if mid == -1 or term == -1:
        rank = 'F'    
    elif s >= 80:
        rank = 'A'
    elif s >= 65:
        rank = 'B'
    elif s >= 50:
        rank = 'C'
    elif s >= 30:
        if add >= 50:
            rank = 'C'
        else:
            rank = 'D'
    else:
        rank = 'F'
    print(rank)

Measured memory_bytes: 7592
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))  // xが範囲内か
#define sort_u(x) sort((x).begin(),(x).end())
#define sort_d(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()  // 配列のサイズ
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;  // 確認したいとき
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))  // 切り上げたいとき
#define newline puts("")
#define v(T) vector<T>  // Tはどんな型でもいい
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;  // ******
typedef vector<vi> vvi;
typedef vector<ll> vl;  // ******
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}  // vi a(n); cin>>a;
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//mins(ans,now);  ansに最小値が入る
//if(max(ans,now)) ansが小さければ更新して実行。cnt++とか。
//ll sum = suma(a);

int main() {
    int n, k; cin >> n;
    vi a(n); cin>>a;
    int ans = 0;
    vp vp;
    rep(i,n){
        P p = make_pair(a[i],i);
        vp.pb(p);
    }
    sort_u(vp);
    rep(i,n){
        cout << vp[i].se+1 << " ";
    }
}

/*
g++ a.cpp
./a.out

oj d
oj t

debug:ctrl+shift+B problemin

*/


Measured memory_bytes: 4652