akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    ll N;
    cin >> N;
    vll b(N);
    for(auto &a:b) {cin >> a;};
    bool f = false;
    vll v;
    while(1) {
        vll prev = b;
        for(int i = b.size() - 1; i >= 0; i--) {
            // cout << i << " " << b[i] << endl;
            if(b[i] - 1 == i) {
                ERASE(b, i);
                v.push_back(i);
                break;
            }
        }
        if(b == prev) {
            f = false;
            break;
        }
        if(b.empty()) {
            f = true;
            break;
        }
    }
    if(f) {
        reverse(v.begin(), v.end());
        for_each(v.begin(), v.end(), [&](ll a){
            cout << a + 1 << endl;
        });
    }else {
        cout << -1 << endl;
    }
}

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


Measured memory_bytes: 256
x,y,X,Y=map(int,input().split())
a=X-x
b=Y-y
cnt=0
new_cnt=0
l=[]
L=[]
for i in range(a):
  l.append('R')
  cnt+=1

for i in range(b):
  l.append('U')
  new_cnt+=1

for i in l:
  if i=='R':
    l.append('L')
  elif i=='U':
    l.append('D')

l.append('D')
L.append('D')

for i in range(cnt+1):
  l.append('R')
  L.append('R')
  
for i in range(new_cnt+1):
  l.append('U')
  L.append('U')
l.append('L')
L.append('L')
l.append('U')
for i in L:
  if i=='R':
    l.append('L')
  elif i=='U':
    l.append('D')
l.append('R')

print(('').join(l))




  
  

Measured memory_bytes: 9268
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)
	var ans string
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			s := getNextString(scanner)
			if s == "snuke" {
				ans = fmt.Sprintf("%c%d", j+'A', i+1)
			}
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 640
#include <iostream>
#define MAX_P 1000000
using namespace std;
int g;
int minx=0;
void price(int a,int b,int c){
	if(a/5*1520+a%5*380+b/4*1870+b%4*550+c/3*2244+c%3*850<minx)
		minx=a/5*1520+a%5*380+b/4*1870+b%4*550+c/3*2244+c%3*850;
	return; 
}

void shop(int g,int a,int b,int c){
	if(g==0){
		price(a,b,c);
		return;
	}else if(g<0){
		return;
	}
	shop(g-200,a+1,b,c);
	shop(g-300,a,b+1,c);
	shop(g-500,a,b,c+1);
	return;
}

int main(){
	while(1){
		cin >> g;
		if(g==0)break;
		minx=MAX_P;	
		shop(g,0,0,0);
		cout << minx << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


string s;

int main(){
	cin >> s;
	
	if(s[6] == '4' && s[8] == '3') cout << "Heisei" << endl;
	else if(s[6] <= '4' && s[5] == '0') cout << "Heisei" << endl;
	else cout << "TBD" << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
list = []
for i in range(n):
  s,t = input().split()
  list.append((s, int(t)))
x = input()
flag = False
time = 0
i = 0

while i < n:
  if list[i][0] == x:
    flag = True
    time = time - list[i][1]
  if flag == True:
    time = time + list[i][1]
  i = i + 1
print(time)

Measured memory_bytes: 3064
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
//#include <unordered_map>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 300010


template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
//inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


int main(){
    //freopen("f2.in","r",stdin);
    //freopen("A.out","w",stdout);
    //freopen("1.txt","w",stdout);
    //srand(time(0));
    int T=30,j,k,i,ca=0,m;
    ll n,x;scanf("%lld%lld",&n,&x);
    ll ans=n;n-=x;
    while(1){
        if(n%x==0){
            ans+=(n/x*2-1)*x;break;
        }
        else ans+=(n/x*2)*x;
        n%=x;
        if(n==0)break;
        if(n<x)swap(n,x);
    }
    printf("%lld\n",ans);
    //cerr<<1.*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const string space=" ";
int main(){
    while(1){
        int n,l,r;
        cin>>n>>l>>r;
        if(!n)break;
        int a[n];
        rep(i,n)cin>>a[i];
        int ans=0;
        REP(i,l,r){
            int j;
            for(j=0;j<n;j++){
                if(i%a[j]==0){
                    if(j%2==0)ans++;
                    break;
                }
            }
            if(j==n&&n%2==0)ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}



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

#define ll long long int

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast_io std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define trace3(x,y,z) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;
#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(),(v).end()

using namespace std;
///////////////////////////////////////////////////////

string s;
vector<int> adj[30];
int maxe[30];

int main()
{
	fast_io;

	cin>>s;

	FOR(i,0,25) adj[i].pb(0);
	FOR(i,0,25) maxe[i] = -1;

	// trace(s);

	REP(i,s.size()){
		adj[s[i]-'a'].pb(i+1);
	}

	FOR(i,0,25) adj[i].pb(s.size()+1);

	// trace(s);

	FOR(i,0,25){
		for(int j = 1;j<adj[i].size();++j){
			// trace2(i,j);
			maxe[i] = max(maxe[i] , adj[i][j] - adj[i][j-1]-1); 
		}
	}

	// for(int u:adj[0]){
	// 	cout<<u<<" ";
	// }
	// cout<<endl;

	// trace(s);
	// FOR(i,0,25){
	// 	cout<<maxe[i]<<" ";
	// }
	// cout<<endl;

	int ans = INT_MAX;

	FOR(i,0,25){
		if(maxe[i] == -1) continue;

		ans = min(ans , maxe[i]);
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
        a[i] *= n;
    }
    int ne = M, nei =  -1;
    for (int i = 0; i < n; ++i) {
        int d = abs(a[i] - sum);
        if (d < ne) {
            ne = d;
            nei = i;
        }
    }
    cout << nei << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[2000]={0};
// 标记峰顶和谷底，并特判最后的降序数列   下一个最高点卖出 
int main(){
    ll n,sum=0,mon=1000;
    scanf("%lld",&n);
	for(ll i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	a[n+1]=-1;
	
	for(ll i=1;i<=n;i++){
		if(a[i+1]>a[i]){  // 买入 
			ll q=mon/a[i]; // 买入个数 
				
			sum+=q;
			mon-=q*a[i];	
			 
		}
		else if(a[i+1]<a[i]){
			if(sum>0){
				mon+=sum*a[i];
				sum=0;
			}
		} 
	} 
	/*if(sum>0){
		mon+=sum*a[n];
		sum=0;
	}*/
	
	
	
	printf("%lld",mon);

    return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
vector<int> edge[200010];
int vis[200010];
void dfs(int x){
	vis[x]=1;
	for(int i=0;i<edge[x].size();i++){
		if(vis[edge[x][i]]) continue;
		dfs(edge[x][i]);
	}
	return;
}
int main(){
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int k;
		cin>>k;
		for(int j=1;j<=k;j++){
			int l;
			cin>>l;
			edge[i].push_back(n+l);
			edge[n+l].push_back(i);
		}
	}
	dfs(1);
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
}


Measured memory_bytes: 8960
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    const int MAX_V_SUM = 2 * 1000 * 100;

    int N, W;
    cin >> N >> W;

    vi w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vvll dp(N + 1, vll(MAX_V_SUM + 1, INF));
    dp[0][0] = 0;

    rep(i, N)
    {
        reple(j, 0, MAX_V_SUM)
        {
            chmin(dp[i + 1][j], dp[i][j]);

            if(j - v[i] >= 0) chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
        }
    }

    revrep(i, MAX_V_SUM + 1)
    {
        if (dp[N][i] <= W)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 162652
n, l = map(int, input().split())
t = []
t2 = []
for i in range(n):
    taste = l+(i+1)-1
    t.append(taste)
    t2.append(taste**2)
oa = t[t2.index(min(t2))]
ans = sum(t) - oa
print(ans)

Measured memory_bytes: 9088
# coding: utf-8
# Your code here!
#a = list(map(int, input().split()))
i=int(input())
lst = []

while i > 0:
    lst.append(i%10)
    i //= 10 # 必須
lst.reverse()
if len(lst)==3:
    lst.insert(0,0)
elif len(lst)==2:
    lst.insert(0,0)
    lst.insert(1,0)
elif len(lst)==1:
    lst.insert(0,0)
    lst.insert(1,0)
    lst.insert(2,0)
elif len(lst)==0:
    lst.insert(0,0)
    lst.insert(1,0)
    lst.insert(2,0)
    lst.insert(3,0)
#print(str(lst[0])+str(lst[1]))
#print(str(lst[2])+str(lst[3]))

if (int(str(lst[0])+str(lst[1]))>=1 and int(str(lst[0])+str(lst[1]))<=12) or (int(str(lst[2])+str(lst[3]))>=1 and int(str(lst[2])+str(lst[3]))<=12):
    if (int(str(lst[0])+str(lst[1]))>=1 and int(str(lst[0])+str(lst[1]))<=12) and (int(str(lst[2])+str(lst[3]))>=1 and int(str(lst[2])+str(lst[3]))<=12):
        print("AMBIGUOUS")
    elif int(str(lst[0])+str(lst[1]))>=1 and int(str(lst[0])+str(lst[1]))<=12:
        print("MMYY")
    elif int(str(lst[2])+str(lst[3]))>=1 and int(str(lst[2])+str(lst[3]))<=12:
        print("YYMM")
    else:
        print("NA")
else:
    print("NA")



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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n;
    cin>>n;
    cout<<n*n*3<<endl;

        return 0;
}

Measured memory_bytes: 764
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	if err := io.writer.Flush(); err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := NewIo()
	defer io.Flush()
	A := io.Next()
	if strings.ToUpper(A) == A {
		io.PrintLn("A")
		return
	}
	io.PrintLn("a")
}


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int x; cin >> x;
    if(x<1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

struct BIT {
    int n;
    vector<int> bit; // 1-indexd

    BIT(int sz) {
        bit.resize(sz + 1);
        n = sz;
    }

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

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

    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    vector<int> sum(N + 1);
    REP(i, N) {
        cin >> a[i];
        sum[i + 1] = a[i] + sum[i];
    }
    vector<int> b(N + 1);
    FOR(i, 1, N) {
        b[i] = sum[i] - i * K;
    }
    vector<int> sb = b;
    sort(sb.begin(), sb.end());
    sb.erase(unique(sb.begin(), sb.end()), sb.end());
    map<int, int> id;
    REP(i, sb.size()) {
        id[sb[i]] = i;
    }

    BIT bit(N + 1);

    int ans = 0;
    REP(i, b.size()) {
        int idx = id[b[i]] + 1;
        ans += bit.sum(idx);
        bit.add(idx, 1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 20608
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0 || m == 0){ break; }
		int table[100];
		for(int i = 0; i < m; i++){ table[i] = m - i - 1; }
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				int t;
				cin >> t;
				table[j] += t * m;
			}
		}
		sort(table, table + m, greater<int>());
		for(int i = 0; i < m; i++){
			cout << (m - table[i] % m) << ((i == m - 1) ? '\n' : ' ');
		}
	}
	return 0;
}

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

 int n,w;
 vector<int> a,v;

 int main(void)
 {
     cin>>n>>w;
     a.resize(n);
     v.resize(n);
     for (int i = 0; i < n; i++) {
         cin>>a[i]>>v[i];
     }
     unordered_map<ll,ll> mp[2];
     mp[0][0]=0;
     int k=0;
     for (int i = 0; i < n; i++) {
         mp[!k][0]=0;
         for(auto x:mp[k]){
             mp[!k][x.first]=max(mp[!k][x.first],mp[k][x.first]);
             mp[!k][x.first+a[i]]=max(mp[!k][x.first+a[i]],x.second+v[i]);
         }
         k=!k;
     }
     mp[k][0]=0;
     int ret=0;
     for(auto x:mp[k]){
         if(x.first<=w){
             ret=max(ret,int(x.second));
         }
     }
     cout<<ret<<endl;
     return 0;
 }

Measured memory_bytes: 768
#include <iostream>

using namespace std;

int n, a[500000];
const int INF = 1e9 + 1;
int ans = 0;

void merge(int l, int m, int r) {
    int n1 = m - l;
    int n2 = r - m;
    int al[n1 + 1], ar[n2 + 1];
    for (int i = 0; i < n1; ++i)
        al[i] = a[l + i];
    for (int i = 0; i < n2; ++i)
        ar[i] = a[m + i];
    al[n1] = INF;
    ar[n2] = INF;
    for (int i = 0, j = 0, k = l; k < r; ++k) {
        ans++;
        if (al[i] <= ar[j])
            a[k] = al[i++];
        else
            a[k] = ar[j++];
    }
}

void mergeSort(int l, int r) {
    if (l + 1 < r) {
        int m = (l + r) / 2;
        mergeSort(l, m);
        mergeSort(m, r);
        merge(l, m, r);
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    mergeSort(0, n);
    for (int i = 0; i < n; ++i) {
        cout << a[i];
        if (i < n - 1)
            cout << " ";
    }
    cout << endl << ans << endl;

    return 0;
}


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

long long n, q, l, r;
string s;
vector<long long>a,c;

int main(){
	cin >> n >> q >> s;
	int sez=s.length();
	for (int i=0;i<sez-1;i++){
		if (s[i]=='A' && s[i+1]=='C'){
			a.push_back(i+1);
			c.push_back(i+2);
		}
	}
	int sez1=a.size();
/*	for (int i=0;i<sez1;i++){
		cout << a[i] << " ";
	}
	cout << "\n";
	for (int i=0;i<sez1;i++){
		cout << c[i] << " ";
	}
	cout << "\n";*/
	while (q--){
		cin >> l >> r;
		auto low=lower_bound(a.begin(), a.end(), l);
		auto up=upper_bound(c.begin(), c.end(), r);
//		cout << up-c.begin() << " " << low-a.begin() << "\n";
		cout << (up-c.begin())-(low-a.begin()) << "\n";
	}
}

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

int main(){
	int N, M;
	std::cin >> N >> M;

	std::vector<int> s(M);
	std::vector<int> c(M);

	for(int i = 0; i < M; i++){
		std::cin >> s[i] >> c[i]; 
	}

	// 全探索 
	for(int i = 0; i <= 999; i++){
		// 整数を配列にして見やすくする 
		// 1桁目 
		std::vector<int> d(1, i % 10);	// iを桁ごとに分けた配列 
		// 2桁目以降 
		int tmp = i / 10;	// 桁を切り下げて 
		while(tmp){
			d.push_back(tmp % 10);	// おしりを取ってきて入れる 
			tmp /= 10;				// 桁を切り下げる 
		}
		// 条件に合うか考える 
		// 桁が違う? 
		if(d.size() != N){
			continue;
		}
		// 入力された条件と違う? 
		bool isOk = true;
		std::reverse(d.begin(), d.end());	// 配列を並べ替えて見やすくする 
		for(int j = 0; j < M; j++){
			if(d[s[j] - 1] != c[j]){
				isOk = false;
			}
		}
		if(isOk == true){
			std::cout << i << std::endl;
			return 0;
		}
	}
	std::cout << -1 << std::endl;
	return 0;
}


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

int main() {
  int sum = 0, maxDiff = 0;
  for (int i = 0; i < 5; i++) {
    int a; cin >> a;
    int b = (a + 9) / 10 * 10;
    sum += b;
    maxDiff = max(maxDiff, b - a);
  }
  cout << sum - maxDiff << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

void show(int a[])
{
//	for (int i = 0; i < 10; i++)
//		printf("%d ", a[i]);
//	printf("\n");
}

void quicksort(int a[], int left, int right)
{

	int p;	//中央値
	int L = left, R = right;		//ループ中で変化するleft、right
	int temp;
	p = a[(left + right) / 2];

	while (1)
	{
		while (a[L] < p) L++; while (a[R] > p)
			R--;
		
		if (L >= R)
			break;

		temp = a[R];
		a[R] = a[L];
		a[L] = temp;

		L++;
		R--;
	}

	show(a);

	if (left < L - 1) quicksort(a, left, L - 1); if (right > R + 1)
		quicksort(a, R + 1, right); 
	
}

int main(void)
{
	int a,b,c[100010],i,d[100010];
	long long x=0;
	scanf("%d %d",&a,&b);
//	if(a>=b){
//		a=3;
//	}
	for(i=0;i<b;i++){
		scanf("%d",&c[i]);
	}
	quicksort(c,0,b-1);
	for(i=0;i<b-1;i++){
		d[i]=c[b-i-1]-c[b-i-2];
	}
	quicksort(d,0,b-2);
	for(i=0;i<b-a;i++){
		x=x+d[i];
	}
//	if(a>=b){
//		printf("%d\n",0);
//	}else{
		printf("%lld\n",x);
//	}
//	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll n;
    cin>>n;
    ll maxl=0,sum=0;
    rep(0,i,n){
        ll l;
        cin>>l;
        maxl=max(maxl,l);
        sum+=l;
    }
    if(sum-maxl>maxl){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  string S7, T;
  cin >> S7 >> T;
  string ans = S7;
  int s = -1;
  rep(i, sz(S7)-sz(T)+1){
    rep(j, sz(T)){
      if(S7.at(i+j) != T.at(j) && S7.at(i+j) != '?'){
        break;
      }
      if(j == sz(T)-1){
        s = i;
      }
    }
  }
  if(s == -1){
    cout << "UNRESTORABLE" << endl;
  }
  else{
    rep(i, sz(T)){
      ans.at(s+i) = T.at(i);
    }
    rep(i, sz(ans)){
      if(ans.at(i) == '?'){
        ans.at(i) = 'a';
      }
    }
    cout << ans << endl;
  }
}

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

#define pb         push_back

const int INF = 100000000;

int calc_mcxi(string input);
string get_mcxi(int val);
char mcxi_ch[4] = {'i', 'x', 'c', 'm'};

int main(void) {
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		string t1, t2;
		cin >> t1 >> t2;

		int num1 = calc_mcxi(t1);
		int num2 = calc_mcxi(t2);

		//cout << num1 << endl;
		//cout << num2 << endl;
		//cout << num1 + num2 << endl;
		cout << get_mcxi(num1 + num2) << endl;
	}
	
	return 0;
}

int calc_mcxi(string input){
	int ret = 0;

	int mcxi = 0;
	int coe = 1;
	for(int i=0; i<input.size(); i++){
		if(input[i] == 'm')	{mcxi = 1000; ret += coe*mcxi; coe = 1;}
		if(input[i] == 'c')	{mcxi = 100;  ret += coe*mcxi; coe = 1;}
		if(input[i] == 'x')	{mcxi = 10;   ret += coe*mcxi; coe = 1;}
		if(input[i] == 'i')	{mcxi = 1;    ret += coe*mcxi; coe = 1;}

		if(input[i] >= '2' && input[i] <= '9') coe = input[i] - '0';
		//cout << "coe:" << coe << " ret:" << ret << endl;
	}

	return ret;
}

string get_mcxi(int val){
	string ret;
	vector<int> dig(4, 0);

	int i = 0;
	while(val){
		dig[i] = val % 10;
		val /= 10;
		i++;
	}

	for(int i=3; i>=0; i--){
		if(dig[i] >= 1){
			if(dig[i] >= 2){
				ret += to_string(dig[i]);
			}
			ret += mcxi_ch[i];
		}
	}

	return ret;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;

int N, M;
string s;

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

    vector<int> steps;
    int target = N;
    int init;
    while (true) {
        init = target - M;
        if (init <= 0) break;
        bool found = false;
        for (int i = init; i < init + M; ++i) {
            if (s[i] == '0') {
                steps.push_back(target - i);
                target = i;
                found = true;
                break;
            }
        }
        if (!found) {
            cout << "-1"; return 0;
        }
    }
    steps.push_back(target);
    for (int i = steps.size() - 1; i >= 0; --i) cout << steps[i] << " ";

    return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
ll n, m, q;
vector<ll> a, b, c, d;

ll score(const vector<ll> &A){
    ll num = 0;
    rep(i, q){
        if(A[b[i]] - A[a[i]] == c[i]) num += d[i];
    }
    return num;
}

ll dfs(vector<ll> &A){
    if(A.size() == n) return score(A);

    ll num = 0;
    ll pos;
    if(A.empty()) pos = 0;
    else pos = A.back();

    _rep(i, pos, m){
        A.push_back(i);
        num = max(num, dfs(A));
        A.pop_back();
    }
    return num;
}

int main(){
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);

    rep(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    vector<ll> A;
    cout << dfs(A) << endl;
}


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

int main() {
int n;
  cin>>n;
  int p=n%100;
  int k;
  if(p==0) {k=0;}
  else{
  k=(p-1)/5+1;
  }

  if(n>=k*100){
    cout<<1<<endl;}
  else{
    cout<<0<<endl;}
  return 0;
  
  
  
  
  
}

Measured memory_bytes: 256
use strict;
use warnings;

my @a;
{
  for (my $i=0; $i<3; $i++) {
    my $in = <STDIN>;
    my @b = split(" ", $in);
    $a[$i] = \@b;
  }
}
my $n = <STDIN>;
chomp $n;
my @b;
{
  for (my $i=0; $i<$n; $i++) {
    my $in = <STDIN>;
    chomp $in;
    $b[$i] = $in;
  }
}
for (my $i=0; $i<3; $i++) {
  for (my $j=0; $j<3; $j++) {
      for (my $k=0; $k<$n; $k++) {
        if ($a[$i][$j] == $b[$k]) {
          $a[$i][$j] = 0;
        }
      }
  }
}
for (my $i=0; $i<3; $i++) {
  if ($a[$i][0]==0 && $a[$i][1]==0 && $a[$i][2]==0) {
    print "Yes\n";
    exit;
  }
  if ($a[0][$i]==0 && $a[1][$i]==0 && $a[2][$i]==0) {
    print "Yes\n";
    exit;
  }
}
if ($a[0][0]==0 && $a[1][1]==0 && $a[2][2]==0) {
  print "Yes\n";
  exit;
}
if ($a[0][2]==0 && $a[1][1]==0 && $a[2][0]==0) {
  print "Yes\n";
  exit;
}
print "No\n";

Measured memory_bytes: 768
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<pair<ll, ll>> s(n);
  for (int i = 0; i < n; ++i) {
    ll x, d;
    cin >> x >> d;
    s[i].first = x - d;
    s[i].second = x + d;
  }
  sort(s.begin(), s.end(), [](pair<ll, ll> a, pair<ll, ll> b) { return a.second < b.second; });
  int result = 0;
  ll last = -ll(1e10);
  for (auto p : s) if (p.first >= last) {
    result++;
    last = p.second;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//ll dp[100010];
vl g[100010];
ll dfs(ll v,ll par=-1){
    vl sum;
    for(auto nv:g[v]){
        if(nv==par)continue;
        sum.pb(dfs(nv,v));
    }
    sort(all(sum));rev(all(sum));
    ll res=0;
    rep(i,sum.size()){
        chmax(res,sum[i]+i+1);
    }
    return res;
}
int main(){
    ll n;cin >> n;
    rep(i,n-1){
        ll t;cin >> t;t--;
        g[i+1].pb(t);
        g[t].pb(i+1);
    }
    cout << dfs(0) <<endl;
}

Measured memory_bytes: 15104
#include <stdio.h>

int main(){
    int A, B, C, X, Y;
    int n_a = 0, n_b = 0, n_c = 0;
    int result = 0;
    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
    if((A + B) > 2 * C){
        if(X > Y){
            n_c += 2 * Y;
            X -= Y; Y = 0;
        }else{
            n_c += 2 * X;
            Y -= X; X = 0;
        }
    }
    if(X > 0){
        if(A > 2 * C){
            n_c += 2 * X;
        }else{
            n_a += X;
        }
        X = 0;
    }
    if(Y > 0){
        if (B > 2 * C){
            n_c += 2 * Y;
        }else{
            n_b += Y;
        }
        Y = 0;
    }
    printf("%d\n", A * n_a + B * n_b + C * n_c);
    return 0;
}


Measured memory_bytes: 128
#n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

#n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

t = list(input())
dp = [0] * (len(t) + 1)

ans = []
swich = 0

for i in range(0,len(t)):

    if t[i] == "?":
        ans.append("D")
    else:
        ans.append(t[i])
print("".join(ans))


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

int main() {
	int n,i;
	cin >> n;
	vector<int> a(n);
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	for(i=0; i<n; i++){
		if(a[i]%2==0){
			if((a[i]%3)*(a[i]%5)){
				cout << "DENIED" << endl; return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((ll)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((ll)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
 
ll x;
ll Main() {
    cin >> x;

    if (x>=400 && x <= 599) {
        cout << "8" << endl;
    } else if(x>=600 && x <= 799) {
        cout << "7" << endl;
    } else if(x>=800 && x <= 999) {
        cout << "6" << endl;
    } else if(x>=1000 && x <= 1199) {
        cout << "5" << endl;
    } else if(x>=1200 && x <= 1399) {
        cout << "4" << endl;
    } else if(x>=1400 && x <= 1599) {
        cout << "3" << endl;
    } else if(x>=1600 && x <= 1799) {
        cout << "2" << endl;
    } else if(x>=1800 && x <= 1999) {
        cout << "1" << endl;
    }
    
    return 0;
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
  int x;cin>>x;
  int ans=1;
  for(int i=2;i<=sqrt(x);i++){
    int a=1;
    while(a<=x){
      ans=max(ans,a);
      a*=i;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3680
import sys
input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)

N, MOD = map(int, input().split())


G = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = map(int, input().split())
    G[x].append(y)
    G[y].append(x)
G[0].append(1)
G[1].append(0)

DP1 = [-1] * (N + 1)
DP1[0] = 0
parent = [-1] * (N + 1)
parent[1] = 0

def dfs(x, p):
    tmp = 1
    for next_ in G[x]:
        if next_ == p:
            continue
        parent[next_] = x
        tmp *= (dfs(next_, x) + 1)
        tmp %= MOD
    DP1[x] = tmp
    return tmp

dfs(1, 0)
# print (DP1)

DP2 = [1] * (N + 1)
stack = [1]

#next_とyとで2重ループになってO(N^2) (星型のとき)
while stack:
    x = stack.pop()

    # 累積積のパート

    #ここが同じ値を返すかチェックする
    n = len(G[x])
    lst1 = [1] * (n + 1)
    lst2 = [1] * (n + 1)
    for i in range(n):
        #親のときだけは違うルールで対処
        if G[x][i] == parent[x]:
            lst1[i + 1] = lst1[i] * DP2[x] % MOD
        else:
            lst1[i + 1] = lst1[i] * (DP1[G[x][i]] + 1) % MOD

        if G[x][n - 1 - i] == parent[x]:
            lst2[n - i - 1] = lst2[n - i] * DP2[x] % MOD
        else:
            lst2[n - i - 1] = lst2[n - i] * (DP1[G[x][n - 1 - i]] + 1) % MOD
    
    for i in range(n):
        if G[x][i] == parent[x]:
            continue
        tmp = lst1[i] * lst2[i + 1] % MOD
        tmp += 1 #白色の分
        DP2[G[x][i]] = tmp % MOD
        stack.append(G[x][i])

# print (DP2)

for i in range(1, N + 1):
    print ((DP1[i] * DP2[i]) % MOD)

# print (DP1)
# print (DP2)

Measured memory_bytes: 87012
//itp1_topic3_b

#include <bits/stdc++.h>

using namespace std;

int main(){

  for ( int i=1 ;; i++){
  int x;
  cin>>x;
  if( x == 0 ) break;
  cout<<"Case "<<i<<": "<<x<<endl;

  }

  return 0;

  }


Measured memory_bytes: 3076
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
res = sum(B)

for i in range(len(C)):
  if A[i]+1 == A[i+1]:
    res += C[A[i]-1]

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 998244353
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define int long long
signed main(){
    int n;
    string s;
    cin >> n >> s;
    int a[3]={};
    vector<int> p(3*n);    
    for(int i=0;i<3*n;i++){
        if(s[i]=='R'){
            p[i] = 0;
        }else if(s[i]=='G'){
            p[i] = 1;
        }else{
            p[i] = 2;
        }
    }
    int ans = 1;
    rep(i,n){
        ans *= (i+1);
        ans %= mod;
    }
    rep(i,3*n){
        if(a[p[i]]==0){
            int c = 0;
            rep(j,3){
                if(a[j]==0)c++;
            }
            if(c==1){
                int mi = inf;
                rep(j,3){
                    if(a[j]!=0){
                        mi = min(mi,a[j]);
                        a[j]--;
                    }
                }
                ans *=mi;
                ans %= mod;
            }else if(c==2){
                rep(j,3){
                    if(a[j]!=0){
                        ans *= a[j];
                        ans %= mod;
                    }
                }
                a[p[i]]++;
            }else{
                a[p[i]]++;
            }
        }else{
            if(max({a[0],a[1],a[2]})==a[p[i]]){
                a[p[i]]++;
            }else{
                
                rep(j,3){
                    if(a[j]!=0&&a[j]!=a[p[i]]){
                        ans *= (a[j]-a[p[i]]);
                        ans %= mod;
                        break;
                    }
                }
                a[p[i]]++;
            }
        }
        //cerr << i << " " << ans << " " << a[0] << " " << a[1] << " " << a[2] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	string x;
	cin>>x;
	x[5]=' ';
	x[13]=' ';
	cout<<x<<endl;
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

Measured memory_bytes: 256
# S = input()
N = int(input())

# A = list(map(int, input().split()))
AB = [list(map(int,input().split())) for _ in range(N)]

ans = 0

P = [[0,0,0] for _ in range(N)]

for i in range(N):
    P[i][0] = AB[i][0] + AB[i][1]
    P[i][1] = AB[i][0]
    P[i][2] = AB[i][1]

P.sort()
P.reverse()

for i in range(N):
    if (i % 2 == 0):
        ans += P[i][1]
    else:
        ans -= P[i][2]
    # if(N % 2 == 1):
    #     if (i % 2 == 0):
    #         ans += AB[i][0]
    #     else:
    #         ans -= AB[i][1]
    # else:
    #     if (i % 2 == 1):
    #         ans += AB[i][0]
    #     else:
    #         ans -= AB[i][1]

print(ans)


Measured memory_bytes: 38168
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char s[20];
int main()
{
    scanf("%s",&s);
    int n=strlen(s);
    int w=1<<(n-1);
    ll sum=0;
    for(int i=0;i<w;i++)
    {
         ll t=s[0]-'0';
        for(int j=0;j<n;j++)
        {
           if(i&1<<j||j==n-1)
           {
               sum+=t;
               t=0;
               if(j==n-1)break;
           }
            t=t*10+s[j+1]-'0';
        }
    }
    cout<<sum<<endl;
}


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



int main(){
    int r,g;
    cin >> r >> g;
    cout << 2*g-r <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";
template <class T> void chmax(T& a, const T& b) { if (b > a) a = b; }
using pll = pair<ll, ll>;

vector<vector<ll>> v;
vector<pll> v2;
vector<ll> v3;
priority_queue<ll, vector<ll>, greater<ll>> q;
ll ans = 0;

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

    ll n, k;
    cin >> n >> k;
    v.resize(n+1);

    REP(i, n) {
        ll t, d;
        cin >> t >> d;
        v[t].push_back(d);
    }

    REP(i, n+1) {
        if (v[i].empty()) continue;

        sort(ALL(v[i]), greater<ll>());

        v2.push_back({v[i][0], 1ll});
        for (ll j=1; j<v[i].size(); j++) {
            v2.push_back({v[i][j], 0ll});
        }
    }
    sort(ALL(v2), greater<pll>());

    ll sum = 0;
    ll nt = 0;
    REP(i, k) {
        if (v2[i].second == 0)
            q.push(v2[i].first);  // 取り除く対象のみ追加
        sum += v2[i].first;
        nt += v2[i].second;
    }
    ans = sum + nt*nt;

    for (ll i=k; i<n; i++) {
        if (v2[i].second == 0) continue;

        v3.push_back(v2[i].first);
    }

    REP(i, v3.size()) {
        if (q.empty()) break;
        
        ll top = q.top();
        q.pop();
        sum = sum - top + v3[i];
        nt++;
        chmax(ans, sum + nt*nt);
    }

    cout << ans << LF;

    return 0;
}


Measured memory_bytes: 8176
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>

using std::vector;
using std::printf;

template<typename T>
void dump(vector<T> vec) {
    for (auto x : vec) {
        std::cout << x << " ";
        std::cout << std::endl;
    }
}

// ---------------------------

vector<int> counter;
vector< vector<int> > structure;

// void recursive_add(int pos, int x) {
//     counter[pos] += x;
//     for (auto j : structure[pos]) {
//         recursive_add(j, x);
//     }
// }

int main() {
    int M, D;
    std::cin >> M >> D;

    int dH, dL;
    int ret = 0;
    for (int m = 1; m <= M; ++m) {
        for (int d = 20; d <= D; ++d) {
            dH = d / 10;
            dL = d % 10;
            if ((dL != 1) && (dH * dL == m)) {
                // printf("%d %d\n", m, d);
                ret++;
            }
        }
    }

    printf("%d", ret);

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBeautifulStrings solver = new BBeautifulStrings();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBeautifulStrings {
        private static final String YES = "Yes";
        private static final String NO = "No";

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            String w = in.string();
            int[] c = new int[26];
            w.chars().forEach(x -> c[x - 'a']++);
            for (int x : c) {
                if (x % 2 == 1) {
                    out.println(NO);
                    return;
                }
            }
            out.println(YES);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 27988
# Union Find 木
from sys import setrecursionlimit


def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t


def unite(parent, i, j):
    i = find(parent, i)
    j = find(parent, j)
    if i == j:
        return
    parent[j] += parent[i]
    parent[i] = j


setrecursionlimit(10 ** 5)

N, M = map(int, input().split())

parent = [-1] * N
for _ in range(M):
    X, Y, Z = map(int, input().split())
    unite(parent, X - 1, Y - 1)
print(len([x for x in parent if x < 0]))


Measured memory_bytes: 6212