akhauriyash/Code-Regression huggingface dataset:
n, k = gets.chomp.split.map(&:to_i)
v = gets.chomp.split.map(&:to_i)

max = 0
(0..([n, k].min)).each do |i|
  (0..i).each do |left|
    right = i - left
    list = v[0, left] + v[-right, right]
    list.sort!
    (k-i).times do
      break if list.empty?
      break if list[0] >= 0
      list.shift
    end
    sum = list.reduce(&:+).to_i
    max = sum if max < sum
  end
end

puts(max)

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    if(s[0] == '1') cnt++;
    if(s[1] == '1') cnt++;
    if(s[2] == '1') cnt++;
    cout << cnt << endl; 
}

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

int main(){
    int N, M ;
    cin >> N >> M;
    vector <int> s(M);
    vector <int> c(M);
    for (int i = 0; i < M; ++i) {
        cin >> s.at(i) >> c.at(i);
    }
    ///////////////

    vector <int> out(N);
    for (int i = 0; i < N; ++i) {
        out.at(i) = 0;
    }
    if(N != 1){
        out.at(0) = 1;
    }
  

    for (int j = 0; j < M; ++j) {
        out.at(s.at(j)-1) = c.at(j);
    }

    int not_exist = 0;
//    for (int i = 1; i < M; ++i) {
//        if((s.at(i-1)==s.at(i)) && (c.at(i-1) != c.at(i))){
////            cout << -1 << endl;
//            not_exist = 1;
//        }
//    }
    for (int i=0; i < M; i++){
        for (int j = 0; j < M; ++j) {
            if((s.at(i)==s.at(j)) && (c.at(i) != c.at(j))){
                not_exist = 1;
            }
        }
    }

    if((out.at(0) == 0) && N != 1){
        not_exist=1;
//        cout << -1 << endl;
    }
    if(not_exist == 1){
        cout << -1 << endl;
    }
    if(not_exist != 1) {
        for (int i = 0; i < N; ++i) {
            cout << out.at(i);
        }
    }
}

Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  N=I()
  A=LI()

  l=[0]
  for x in A:
    l.append(l[-1]+x)

  # print(l)

  ans=0
  for i in range(N):
    _ans=(l[N]-l[i+1])*A[i]
    ans+=_ans
    ans%=mod

  return ans

# main()
print(main())


Measured memory_bytes: 33324
W, H, N = map(int, input().split())

G = [[1] * H for _ in range(W)]

for _ in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        for x_ in range(x):
            for y_ in range(H):
                G[x_][y_] = 0

    if a == 2:
        for x_ in range(x, W):
            for y_ in range(H):
                G[x_][y_] = 0
    
    if a == 3:
        for x_ in range(W):
            for y_ in range(y):
                G[x_][y_] = 0
    
    if a == 4:
        for x_ in range(W):
            for y_ in range(y, H):
                G[x_][y_] = 0

ans = 0
for g in G:
    # print (g)
    ans += sum(g)

print (ans)

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

using namespace std;
typedef long long ll;

// #define DEBUG

int set_time = 1;
const int maxint = 1000;
struct timestamp;
vector<int> color;
vector<timestamp> ts;
vector< vector<int> > connective;

struct timestamp
{
    int node;
    int discoverry_time;
    int terminate_time;
};

void init_ts(int n, timestamp *a)
{
    a->node = n;
    a->discoverry_time = -1;
    a->terminate_time = -1;
}

void disp_ts(timestamp a)
{
    cout << a.node + 1 << " " << a.discoverry_time << " " << a.terminate_time << endl;
}

void dfs(int x, timestamp *a, vector<int> v)
{
    color[x] = 1;
    a->discoverry_time = set_time;
    set_time++;
    for (auto itr = v.begin(); itr != v.end(); itr++)
    {   
        if (color[*itr] == -1)
            dfs(*itr, &ts[*itr], connective[*itr]);
    }

    a->terminate_time = set_time;
    set_time++;
    
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, v, k, x;
    cin >> n;
    timestamp tsi;
    connective.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v >> k;
        color.push_back(-1);
        init_ts(i, &tsi);
        ts.push_back(tsi);
        for (int j = 0; j < k; j++)
        {
            cin >> x;
            connective[i].push_back(x-1);
        }
        
    }
    for (int i = 0; i < n; i++){
        if (color[i] == -1)
            dfs(i, &ts[i], connective[i]);
    }

    for_each(ts.begin(), ts.end(), disp_ts);

    return 0;
}


// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 3172
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main(args: Array<String>) {
    val S = readLine()!!
    val w = readInts()[0]
    println((0 until S.length step w).map { S[it] }.joinToString(""))

}

Measured memory_bytes: 36024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int cnt[300010], kinda[300010], wa[300010], xa[300010], ans[300010];

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i){
	    int a;
	    cin >> a;
	    ++cnt[a];
	}
	int mx=0;
	for(int i=1; i<=N; ++i){
	    ++kinda[cnt[i]];
	    mx=max(mx, cnt[i]);
	}
	wa[mx+1]=0;
	for(int i=mx; i>=0; --i) wa[i]=wa[i+1]+kinda[i];
	xa[0]=0;
	for(int i=1; i<=N; ++i) xa[i]=xa[i-1]+kinda[i]*i;
	ans[1]=N;
	int now=0;
	for(int i=N; i>1; --i){
	    while((now+1)*i<=wa[now+1]*(now+1)+xa[now]) ++now;
	    ans[i]=now;
	}
	for(int i=1; i<=N; ++i) cout << ans[i] << endl;
	return 0;
}



Measured memory_bytes: 6144
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  ll x;
  cin >> N >> x;
  ll a[N];
  REP(i, N) cin >> a[i];
  ll best[N];
  REP(i, N) best[i] = a[i];
  ll ans = 1e18;
  REP(m, N) {
    ll tmp = 0;
    REP(i, N) best[i] = min(best[i], a[(i - m + N) % N]);
    REP(i, N) tmp += best[i];
    ans = min(ans, tmp + x * m);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	int N;
	vector<int> L;
	L.reserve(2048);

	scanf("%d", &N)+1;

	int tmp;
	for (int i = 0; i < N; i++) {
		scanf("%d", &tmp)+1;
		L.push_back(tmp);
	}
	sort(L.begin(), L.end());

	int count = 0;
	int a, b, c1, c2;
	for (a = 0; a < N - 2; a++) {
		for (b = a + 1; b < N - 1; b++) {
			for (c1 = b + 1; c1 < N; c1++) {
				if (L[b] < L[c1] + L[a] && L[c1] < L[a] + L[b]) {
					break;
				}
			}
			for (c2 = N - 1; c2 > b; c2--) {
				if (L[b] < L[c2] + L[a] && L[c2] < L[a] + L[b]) {
					break;
				}
			}
			if (c2 - c1 + 1 > 0) count += c2 - c1 + 1;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
n = int(input())
ABC = [tuple(map(int, input().split())) for i in range(n)]
A = [a for a, b, c in ABC]
B = [b for a, b, c in ABC]
C = [c for a, b, c in ABC]
DP = [[0 for j in range(3)] for i in range(n+1)]
for i in range(1, n+1):
    DP[i][0] = max(DP[i-1][1], DP[i-1][2])+A[i-1]
    DP[i][1] = max(DP[i-1][2], DP[i-1][0])+B[i-1]
    DP[i][2] = max(DP[i-1][0], DP[i-1][1])+C[i-1]
print(max(DP[n]))


Measured memory_bytes: 44104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N, M;
    cin >> N >> M;
    vi v;
    v.resize(N);
    vi l[MAX_N];

    REP(i, N)
    {
        cin >> v[i];
    }

    REP(i, M)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        l[a].push_back(b);
        l[b].push_back(a);
    }

    int ans = 0;
    REP(i, N)
    {
        int tmp = v[i];
        bool flg = true;
        REP(j, l[i].size())
        {
            if (v[l[i][j]] >= tmp)
            {
                flg = false;
                break;
            }
        }
        if (flg)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12236
# import sys
# input = sys.stdin.readline
import itertools
import collections


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n, m = input_list()
    rooms = []
    for _ in range(m):
        rooms.append(input_list())
    prev = [0]*n
    to_list = [[] for i in range(n)]
    for a, b in rooms:
        to_list[a-1].append(b-1)
        to_list[b-1].append(a-1)
    next_q = collections.deque()
    flags = [-1] * n
    flags[0] = 999
    next_q.append(0)
    while next_q:
        cur = next_q.popleft()
        for room in to_list[cur]:
            if flags[room] == -1:
                flags[room] = cur
                next_q.append(room)
    print('Yes')
    for i in range(1, n):
        print(flags[i]+1)


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 123900
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        
        if(a < b){
            if(a < c && c < b){
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            if(b < c && c < a){
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

    }
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[200001];
    Scs(s);
    int N = strlen(s);
    ll ans = 1ll*N*(N-1)/2;
    vi cnt(256);
    Rep(i,N){
        cnt[s[i]]++;
    }
    Repe(i,'z'+1,'a'){
        ans -= 1ll*cnt[i]*(cnt[i]-1)/2;
    }

    printf ("%lld\n", ans+1 );

    return 0;
}



Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
//10:26-10:28
ll N,K;
string S;
vector<ll> hito;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>K>>S;
    char lst='1';
    ll lstinx=0;
    S.push_back('1');
    REP(i,(ll)S.size()){
        if(lst!=S[i]){
            hito.push_back(i-lstinx);
            lst=S[i];
            lstinx=i;
        }
    }
    hito.push_back(S.size()-1-lstinx);
    ll ans=0,sm=0;
    REP(i,min(2*K+1,(ll)hito.size())){
        sm+=hito[i];
    }
    ans=sm;
//    cout<<sm<<endl;
    REP(i,(ll)hito.size()-2*K-2){
        sm-=hito[i]+hito[i+1];
        sm+=hito[i+2*K+1]+hito[i+2*K+2];
        ans=max(ans,sm);
        i++;
//        cout<<sm<<endl;
    }
    cout<<ans<<endl;
    /*
    for(auto i:hito){
        cout<<i<<endl;
    }
    */
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

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

    set<string> S;
    rep(i,N){
        string s; cin >> s;
        S.insert(s);
    }

    cout << S.size() << endl;
}


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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"No\n"
#define CY cout<<"Yes\n"

using namespace std;
using ll = long long;
ll recur(ll i,vector<ll>&v)
{
   // if(i==v.size()) return INT_MAX;
    if(i==v.size()-1) return 0;
    ll m1=recur(i+1,v)+abs(v[i+1]-v[i]);
    ll m2=LLONG_MAX;
    if(i+2<v.size()) m2=recur(i+2,v)+abs(v[i+2]-v[i]);
    return min(m1,m2);
}
void solve()
{
   ll n; cin>>n;
   //ll k; cin>>k;
   ll v[n][3]={0};
   rep(i,n) cin>>v[i][0]>>v[i][1]>>v[i][2];
   ll dp[n][3]={0};
   dp[0][0]=v[0][0];
   dp[0][1]=v[0][1];
   dp[0][2]=v[0][2];
   for(int i=1;i<n;i++)
   {
        dp[i][0]=v[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=v[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=v[i][2]+max(dp[i-1][1],dp[i-1][0]);
        //cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<"\n";
   }
   cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
    //cin>>t;
    while(t--)
        {solve();}
    return 0;
}

Measured memory_bytes: 8336
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b;
    scanf("%d %d",&a, &b);
    
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2104
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

int main()
{
    ll r=in(),d=in(),x=in();
    REP(i,10)cout<<(x=r*x-d)<<endl;
}

Measured memory_bytes: 256
S = input()
n = len(S)
mod = (10**9 + 7)

dp = [[0] * 5 for _ in range(n + 1)]

dp[n] = [0, 0, 0, 1, 0]
for i in range(n-1, -1, -1):
    m1 = 3 if S[i] == '?' else 1
    for j in range(4):
        m2 = 1 if S[i] == '?' or j == 'ABC'.find(S[i]) else 0
        dp[i][j] = (dp[i+1][j] * m1 + dp[i+1][j+1] * m2) % mod
print(dp[0][0])

Measured memory_bytes: 27600
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;

constexpr ll mod=1e9+7;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}

int n;
vector<int> g[200200];
ll p[200200];
ll d[202020];

ll q[202020];
ll qq[202020];

void dfs(int s,int pp){
	d[s]=1;
	for(int t:g[s]){
		if(t==pp)continue;
		p[t]=s;
		dfs(t,s);
		d[s]+=d[t];
		(q[s]*=q[t])%=mod;
	}
	(q[s]*=mod_pow(d[s],mod-2))%=mod;
}

void dfs2(int s,int p){
	ll re=1;
	for(int t:g[s]){
		if(t==p)continue;
		(re*=q[t])%=mod;
	}
	for(int t:g[s]){
		if(t==p)continue;
		(qq[t]*=qq[s]*re%mod*mod_pow(q[t],mod-2)%mod*mod_pow((n-d[t]),mod-2)%mod)%=mod;
		dfs2(t,s);
	}
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1;i<n;i++){
		int a,b; cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(int i=0;i<n;i++){
		q[i]=1;
		qq[i]=1;
	}
	p[0]=-1;
	dfs(0,-1);
	dfs2(0,-1);
	ll res=1;
	for(int i=1;i<n;i++){
		(res*=i)%=mod;
	}
	for(int i=0;i<n;i++){
		ll ans=res;
		for(int t:g[i]){
			if(p[t]==i){
				(ans*=q[t])%=mod;
			}else{
				(ans*=mod_pow(n-d[i],mod-2))%=mod;
				ll re=q[t];
				(re*=d[t])%=mod;
				(re*=mod_pow(q[i],mod-2))%=mod;
				(ans*=re)%=mod;
				(ans*=qq[t])%=mod;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 20212
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }


//B
ll a[110];
int main(){
  ll n;
  cin>>n;
  bool p=true;
  rep(i,0,n)cin>>a[i];
  rep(i,0,n){
    if(a[i]%2==0){
      if(a[i]%5!=0&&a[i]%3!=0)p=false;
    }
  }
  if(p)cout<<"APPROVED";
  else cout<<"DENIED";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
struct Team { string name; int score; };
bool cmp(const Team &a, const Team &b) { return a.score > b.score; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    bool flag = false;
    while(true)
    {
        int n; cin >> n;
        if(n == 0) break;
        if(flag) cout << endl;
        vector<Team> v(n);
        for(int i = 0; i < n; i++)
        {
            string name; cin >> name;
            int w, l, d; cin >> w >> l >> d;
            int s = w * 3 + d;
            v[i] = {name, s};
        }
        stable_sort(v.begin(), v.end(), cmp);
        for(int i = 0; i < v.size(); i++) cout << v[i].name << "," << v[i].score << endl;
        flag = true;
    }
    return 0;
}




Measured memory_bytes: 2996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int A, B;
	int ans;
	
	cin >> A >> B;

	if ( (A + B ) % 2 == 0){
		printf("%d",(A+B )/2 );
	}else{
		printf("IMPOSSIBLE");
	}

	//printf("No");


	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
template<class T>inline void read(T&a){
	char c=getchar();int f=1;a=0;
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();}
	while(c<='9'&&c>='0') a=(a<<1)+(a<<3)+c-48,c=getchar();
	a*=f;
}
template<class T>void write(T a){
	if(a<0) putchar('-'),a=-a;
	if(a>9) write(a/10);
	putchar(a%10+48);
}
const int o=110;
int n,a[o],ans;
int main(){
	read(n);for(int i=1;i<=n;++i) read(a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<n;++i) for(int j=i+1;j<n;++j) for(int k=j+1;k<=n;++k) if((a[i]^a[j])&&(a[j]^a[k])&&a[i]+a[j]>a[k]) ++ans;
	write(ans);
	return 0;
}

Measured memory_bytes: 1536
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
typedef long long int ll;
typedef string::const_iterator State;
typedef pair<int,int> P;
class ParseError {};
const ll INF=1LL<<50;
char fi[101][101];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
double EPS = 1e-14;
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003



int bow[353][353]={0};
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))
	return 0;
	return a+b;
}

/*struct P{
	double x,y;
	P(){}
		P(double x,double y):x(x),y(y){
		}
		P operator + (P p){
			return P(add(x,p.x),add(y,p.y));
		}
		P operator - (P p){
			return P(add(x,-p.x),add(y,-p.y));
		}
		P operator *(double d){
			return P(x*d,y*d);
		}
		double dot(P p){
			return add(x*p.x,y*p.y);
		}
		double det(P p){
			return add(x*p.y,-y*p.x);
		}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> 	qs(n*2);
	
	rep(i,n){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
			k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
		k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int n,m;
vector<double> p;
P ps[101];
*/
//char c[520][520];
long long mod=1000000007;
long long pow(ll i,ll j){
	ll tmp=1;
	while(j){
		if(j%2) tmp=tmp*i%mod;
		i=i*i%mod;
		j/=2;
	}
	return tmp;
}

int expression(State&);
int term(State&);
int factor(State&);
int number(State&);
int expression(State &begin){
	int ret = term(begin);
	
	for(;;){
		if(*begin == '+'){
			begin++;
			ret += term(begin);
		}
		else if(*begin == '-'){
			begin++;
			ret -= term(begin);
		}
		else
			break;
	}
	return ret;
}

int term(State &begin){
	int ret = factor(begin);
	
	for(;;){
		if(*begin=='*'){
			begin++;
			ret *= factor(begin);
		}
		else if(*begin=='/'){
			begin++;
			ret /= factor(begin);
		}
		else
			break;
	}
	return ret;
}

int factor(State &begin){
	int ret;
	if(*begin == '('){
		begin++;
		ret = expression(begin);
		begin++;
	}
	else
	ret = number(begin);
	
	return ret;

}

int number(State &begin){
	int ret =0;
	
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin - '0';
		begin++;
	}
	return ret;
}




int main(void){

	
	string s;
	
	cin>>s;
	
	string a="";
	for(int i=0;i<s.size();i++){
		if(s[i]=='B'&&a.size()>0)
		a.erase(a.end()-1);
		else if(s[i]!='B')
			a+=s[i];
	}
	
	cout<<a<<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
const int nmax=3012;
int n,dp[nmax];
char s[nmax];
int main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    dp[1]=1;
    for(int i=2; i<=n; ++i){
        if(s[i-1]=='<'){
            for(int j=1,s=0,tmp=0; j<=i; ++j){
                s=dp[j-1]+tmp;
                if(s>=MOD)s-=MOD;
                tmp=dp[j];
                dp[j]=s;
            }
        }
        else
            for(int j=i-1,s=0; j>0; --j){
                s+=dp[j];
                if(s>=MOD)s-=MOD;
                dp[j]=s;
            }
    }
    int res=0;
    for(int i=1; i<=n; ++i){
        res+=dp[i];
        if(res>=MOD)res-=MOD;
    }
    printf("%d",res);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
int n, k;
std::vector<ll> v;

int main(int argc, char const *argv[]) {
    cin >> n >> k;
    v.assign(n, 0);
    if (k >= n) {
        std::cout << 0 << std::endl;
        return 0;
    }
    for (ll i = 0; i < n; i++) {
        cin >> v[i];
    }
    std::sort(v.begin(), v.end(), [](const auto& l, const auto& r) {
        return l > r;
    });
    ll p = 0;
    for (auto i = v.begin()+k; i != v.end(); i++) {
        p += *i; 
    }
    std::cout << p << std::endl;
    
    return 0;
}

Measured memory_bytes: 1920
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    Asort = sorted(A)

    sumMed = 0
    for i in range(n):
        sumMed += Asort[n + i * 2]

    print(sumMed)

resolve()

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

int main()
{
    int a, b;
    string op;
    while (true)
    {
        cin >> a >> op >> b;
        if (op == "?")
            break;
        if (op == "+")
            cout << a + b << endl;
        if (op == "-")
            cout << a - b << endl;
        if (op == "*")
            cout << a * b << endl;
        if (op == "/")
            cout << a / b << endl;
    }
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n,x;cin>>n;
    map<int,int> dic;
    for(int i=0;i<n;i++){
        cin>>x;dic[x]+=1;
    }
    int ans=0;
    for(auto p:dic){
        auto v=p.second;
        if(v%2==1)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8136
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{
ll a;
cin>>a;
cout<<(a+(a*a)+(a*a*a));
}

Measured memory_bytes: 3600
param = list(map(int, input().split()))
n = param[0]
k = param[1]

i = 1
ret = 0
while i <= n:
    cnt = 0
    tmp = k
    while i < tmp:
        tmp = tmp / 2
        cnt += 1
    ret += pow(0.5, cnt)
    i += 1
ret = ret / n
print(ret)


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
  return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) //繰り返し自乗法
{
  if (P == 0)
  return 1;
  if (P % 2 == 0)
  {
    int t = mpow(N, P / 2, M);
    return t * t % M;
  }
  return N * mpow(N, P - 1, M) % M;
}
signed main()
{
  int N;
  string S;
  cin >> N >> S;
  rep(i,S.length()){
    S[i] -= 'A';
    S[i] += N;
    S[i] = (S[i] % 26) + 'A';
    cout << S[i] ;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
  int n,a,b,i,j,k;
  cin>>n>>a>>b;
  i=n/(a+b);
  j=n%(a+b);
  k=i*a;
  if(j>=a)
    k=k+a;
  else
    k=k+j;
  cout<<k;
}

Measured memory_bytes: 256
#include <cstdio>

int n;
int rabbits[100001];

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

        int likes = 0;

        for (int i = 1; i <= n; i++) {
                if (rabbits[rabbits[i]] == i) {
                        likes++;
                }
        }

        printf("%d\n", likes / 2);

        return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#define MAX 100001
using namespace std;

class Queue{
    vector<pair<string, int> > q;
    int head = 0;
    int tail = 0;
public:
    Queue(){
        q.resize(MAX);
    }
    bool is_empty(){
        return head == tail;
    }
    void enqueue(pair<string, int> num){
        q[tail] = num;
        tail = (tail + 1) % MAX;
    }
    pair<string, int> dequeue(){
        pair<string, int> ret = q[head];
        head = (head + 1) % MAX;
        return ret;
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    Queue que1;
    for (int i = 0; i < n; i++) {
        string p;
        int num;
        cin >> p >> num;
        que1.enqueue(make_pair(p, num));
    }
    Queue que2;
    int time_ = 0;
    while(!que1.is_empty()) {
        pair<string, int> front = que1.dequeue();
        if (front.second <= q) {
            time_ += front.second;
            front.second = time_;
            que2.enqueue(front);
        } else {
            front.second -= q;
            time_ += q;
            que1.enqueue(front);
        }
    }
    while (!que2.is_empty()) {
        pair<string, int> front = que2.dequeue();
        cout << front.first << " " << front.second << endl;
    }
    return 0;
}

Measured memory_bytes: 8340
// g++ -std=c++14

/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/


#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(c) c.begin(),c.end()
#define inf 1000000000000000001
#define pii pair<int, int>
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll

const int N = 1e6 + 100;
const int MOD = 998244353;

int n, arr[N];
int cnt[N];
int f[N], g[N];
int power(int x, int t){
    int ans = 1;
    while(t > 0) {
        if(t & 1) ans = 1LL * ans * x % MOD;
        x = 1LL * x * x % MOD;
        t >>= 1;
    }
    return ans;
}

inline int sub(int a, int b){
    a %= MOD;
    b %= MOD;
    a = ((a - b) % MOD + MOD) % MOD;
    return a;
}

inline int add(int a, int b){
    a %= MOD;
    b %= MOD;
    a = (a + b) % MOD;
    return a;
}

inline int mul(int a, int b){
    a %= MOD;
    b %= MOD;
    a = (a * b) % MOD;
    return a;
}

inline int inv(int a){
    a = a % MOD;
    a = power(a, MOD - 2);
    return a;
}


int c2(int x) {
    int temp = (x * (x - 1)) / 2;
    return temp % MOD;
}

int32_t main(){ _
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        cnt[arr[i]]++;
    }
    int ans = 0;
    for (int i = N - 1; i >= 1; i--) {
        int s = 0;
        for (int j = i; j < N; j += i) {
            f[i] = sub(f[i], f[j]);
            f[i] = add(f[i], mul(s, mul(cnt[j], j)));
            f[i] = add(f[i], mul(c2(cnt[j]), mul(j, j)));
            s = add(s, mul(cnt[j], j));
        }
        ans = add(ans, mul(f[i], inv(i)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 20736
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

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

    for(int i = 0; i < S.size(); i++){
        cout << "x";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = list(map(int, input().split()))
heights = list(map(int, input().split()))
roads = [list(map(int, input().split())) for i in range(m)]

arrows = [True] * n

for road in roads:
    if heights[road[0] - 1] == heights[road[1] - 1]:
        res = [False, False]
    elif heights[road[0] - 1] < heights[road[1] - 1]:
        res = [False, True]
    else:
        res = [True, False]
    arrows[road[0] - 1] &= res[0]
    arrows[road[1] - 1] &= res[1]
    

print(len([i for i in arrows if i]))

Measured memory_bytes: 32600
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int n, A[10010];

int Abs(int x) {return x < 0 ? -x : x;}

int main() {
    scanf("%d", &n);
    int tot = 0;
    for(int i = 1; i <= n; i++) scanf("%d", &A[i]), tot += A[i];
    int mn = 2333333, v;
    for(int i = 1; i <= n; i++)
        if(Abs(n * A[i] - tot) < mn) v = i, mn = Abs(n * A[i] - tot);
    printf("%d\n", v - 1);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#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 FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, k, d[210000], ans;

vector<ll> g[210000];
int main() {
    cin >> n;
    REP(i, n - 1){
        ll a, b;
        cin >>a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    REP(i, n){
        vector<ll> v;
        ll nans = d[i] + i + 1;
        //cout << nans << endl;
        v.push_back(-1);
        v.push_back(i);
        REP(j, g[i].size()){
            if (g[i][j] > i) continue;
            v.push_back(g[i][j]);
        }
        sort(ALL(v), greater<ll>());
        REP(i, (ll)v.size() - 1){
            nans -= (v[i] - v[i + 1]) * i;
        }
        d[i + 1] = nans;
        //cout << nans << " " << i << endl;
        ans += nans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 20456
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var m = cin.nextInt();
            var c = cin.nextInt();
            var b = cin.ArrayInt(m);
            var aa = new List<int[]>();
            for (int i = 0; i < n; i++)
            {
                aa.Add(cin.ArrayInt(m));
            }

            var ans = 0;
            for (int i = 0; i < n; i++)
            {
                var p = 0;
                for (int j = 0; j < m; j++)
                {
                    p += aa[i][j] * b[j];
                }
                p += c;
                if (p > 0) ans++;
            }

            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin >> n >> l;
  int i;
  vector<string> vec(n);
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(i=0;i<n;i++){
    cout << vec.at(i);
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();

		int[] dir = new int[N];
		for (int i = 0; i < N; i++) {
			dir[i] = sc.nextInt();
		}

		int[] flgs = new int[N];
		Arrays.fill(flgs, -1);
		int steps = 0;
		int now = 1;
		int target = dir[now - 1];
		flgs[now - 1] = steps;
		steps++;
		while (true) {
			now = target;
			target = dir[now - 1];
			if (flgs[now - 1] == -1) {
				flgs[now - 1] = steps;
			}else {
				K =(K - steps)%(steps-flgs[now - 1]);
				break;
			}
			if (K - steps == 0) {
				K = K - steps;
				break;
			}
			steps++;
		}
		for (int i = 0; i < K; i++) {
			now = target;
			target = dir[now - 1];
		}
		System.out.println(now);
	}
}

Measured memory_bytes: 60504
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int q;
  cin >> q;
  while (q--) {
    int b, m, e;
    cin >> b >> m >> e;
    rotate(v.begin() + b, v.begin() + m, v.begin() + e);
  }
  for (int i = 0; i < n; i++) {
    if (i)
      cout << " ";
    cout << v[i];
  }
  cout << endl;
}


Measured memory_bytes: 3184
PROGRAM ATCODER

implicit none
integer :: n,i,ans=0
integer,allocatable :: v(:), c(:)

read*, n
allocate(v(n),c(n))
read*, v(1:n), c(1:n)

do i = 1, n, 1
  if ( v(i)-c(i) > 0 ) then
    ans = ans + v(i) - c(i)
  end if
end do

print'(i0)', ans 

END PROGRAM ATCODER

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

using namespace std;

long long int q, h, s, d, n, min1, min2;

int main()
{
    cin >> q >> h >> s >> d >> n;
	min1 = min({4 * q, 2 * h, s});
	min2 = min(min1 * 2 , d);
	cout << (n / 2) * min2 + (n % 2) * min1 << endl;
    return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [0]
for i in range(1, n):
    to = min(i, k) + 1
    dp += [min([dp[-j] + abs(h[i] - h[i - j]) for j in range(1, to)])]
print(dp[-1])

Measured memory_bytes: 58208
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main(){
	int A, B;
	sci(A), sci(B);
	cout << ((A-1)*(B-1)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	
	int a, b;
	scanf("%d %d", &a, &b);
	if(a==b) {
		printf("a == b\n");
	}
	else if(a<b) {
		printf("a < b\n");
	}
	else if(a>b) {
		printf("a > b\n");
	}
	
	
	return 0;
}


Measured memory_bytes: 2596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

bool C(long long mid, long long A, long long B, vector<long long> h){
    int N = h.size();

    for(int i=0; i<N; i++) h[i] -= mid * B;

    long long ans = 0;
    for(int i=0; i<N; i++)
        if(h[i] > 0){
            ans += h[i] / (A - B);
            if(h[i] % (A - B) != 0) ans++;
        }

    if(ans <= mid) return true;
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    long long A, B;
    cin >> N >> A >> B;
    vector<long long> h(N);
    for(int i=0; i<N; i++) cin >> h[i];

    long long ub = 1000000000;
    long long lb = 0;
    while(ub - lb > 1){
        long long mid = (ub + lb) / 2;
        if(C(mid, A, B, h)) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}


int main() {
	bool f=0;
	int n; cin >> n;
	set<ll> s;
	rep(i, n) {
		ll tmp; cin >> tmp;
		if (s.count(tmp)) {
			f = 1;
		}
		else {
			s.emplace(tmp);
		}
	}
	cout << (f ? "NO" : "YES") << endl;

	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int H,W;
int n;
int c[10010];
int G[110][110];
int main(){
    scanf("%d%d",&H,&W);
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d",&c[i]);
    }
    int p = 1;
    for(int i = 0; i < H; i++){
        if(i & 1){
            for(int j = W-1; j >= 0; j--){
                if(c[p] > 0){
                    G[i][j] = p;
                    c[p]--;
                }
                else{
                    p++;
                    G[i][j] = p;
                    c[p]--;
                }
            }
        }
        else{
            for(int j = 0; j < W; j++){
                if(c[p] > 0){
                    G[i][j] = p;
                    c[p]--;
                }
                else{
                    p++;
                    G[i][j] = p;
                    c[p]--;
                }
            }
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            printf("%d%c",G[i][j],j == W-1 ? '\n' : ' ');
        }
    }
    return 0;
}


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

int main(){
	int N;
	string s;
	cin>>N>>s;
	int bc=0,rc=0;
	rep(i,N){
		if(s.at(i)=='B'){
			bc++;
		}else{
			rc++;
		}
	}
	if(rc>bc){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 384
n,w  = map(int, (input().split()))
goods = [list(map(int, input().split())) for _ in range(n)]
MAX_V = sum(map(lambda x: x[1], goods))+1
INF = 10**19

dp = [[INF for _ in range(MAX_V)] for _ in range(n+1)]
dp[0][0] = 0

for i in range(1, n+1):
    for j in range(MAX_V):
        #print(dp)
        if j-goods[i-1][1] >= 0:
            dp[i][j] = min(dp[i-1][j-goods[i-1][1]]+goods[i-1][0], dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]

ans = 0
for i in range(MAX_V):
    if dp[n][i] <= w:
        ans = max(ans, i)

print(ans)


Measured memory_bytes: 173960