akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
char ss[maxn];
char ss1[maxn];
start{
    scanf("%s",ss+1);
    int cnt=0;
    strcpy(ss1+1,ss+1);
    int len=strlen(ss+1);
    for(int i=1;i<len;i++)
    {
        if(ss[i]==ss[i+1])
        {
            if(ss[i]=='0') ss[i+1]='1';
            if(ss[i]=='1') ss[i+1]='0';
            cnt++;
        }
    }
    ///cout<<cnt<<endl;
    int cnt2=0;
    for(int i=len;i>=2;i--)
    {
        if(ss1[i-1]==ss1[i])
        {
            if(ss1[i]=='0') ss1[i-1]='1';
            if(ss1[i]=='1') ss1[i-1]='0';
            cnt2++;
        }
    }
    ///cout<<cnt2<<endl;
    cout<<min(cnt,cnt2);
	end;
}


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

int main(){
	double r;
	double pi = 3.14159265358979;
	cin >> r;
	cout << fixed << setprecision(6);
	cout << fixed << setprecision(6) << pi * r * r << " " << fixed << setprecision(6)  << 2 * pi * r << "\n";

	return 0;
}





Measured memory_bytes: 3284
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

// ===============================================================

int main() {
	ll n, m; cin >> n >> m;
	bool ans = false;
	for (ll i = 0; i < n+1; i++) {
		for (ll j = 0; j < n+1; j++) {
			if (i + j <= n) {
				if (i * 1000 + j * 5000 + (n - i - j) * 10000 == m) {
					cout << n - i - j << " " << j << " " << i << endl;
					ans = true;
					break;
				}
			}
		}
		if (ans) break;
	}
	if (ans == false) {
		cout << -1 << " " << -1 << " " << -1 << endl;
	}
}

Measured memory_bytes: 3652
#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++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

int  main()
{
	long x; cin >> x;
	long ans = 0;
	for (int i = 1; i <= x; i++)
	{
		if (x == i*(i+1) / 2)
		{
			cout << i;
			return 0;
		}
		if (x < i*(i+1) / 2)
		{
			cout << i << endl;
			return 0;
		}
	}

	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll n, m, k; cin >> n>>m>>k;
    vector<ll> a(n+1, 0);
    vector<ll> b(m+1, 0);
    ll ans=0;

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

    ll d=m;
    for (int l = 0; l <= n; ++l) {
        if(k < a[l]) break;
        while (b[d]>k-a[l]) d--;
        ans = max(ans, l+d);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6404
/**
*       Author: K.R.Surrya  26/04/2020 17:42:57 
*
**/
#include<bits/stdc++.h>
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define fo(i,a,b)             for(int i=a;i<b;++i)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
using namespace std; 

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)  { return ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a,Args... args)
{
    cerr << *it << " = " << a <<endl;
    err(++it,args...);   //args is going to end.
}

void solve() {
    int N;
    cin >> N;
    set<string> visited;
    for(int i=0;i<N;++i) {
        string curr;
        cin >> curr;
        visited.insert(curr);
    }
    cout << visited.size() << endl;
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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


     auto start = chrono::high_resolution_clock::now();

     solve();

     auto end = chrono::high_resolution_clock::now();

     cerr << " Execution time : " << chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms"<<endl;

   
    return 0;
}


Measured memory_bytes: 19244
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void solve(int n, int k){
    cout << "Yes" << endl;
    cout << k+1 << endl;
    
    vector<queue<int>> q(k+1);
    vvi ans(k+1);
    
    rep(i, k) {
        q[0].push(i);
        ans[0].pb(i);
    }
    
    int now = k-1;
    
    rep3(i, 1, k){
        rep(j, i){
            int f = q[j].front(); q[j].pop();
            ans[i].pb(f);
        }
        rep(j, k-i){
            now++;
            q[i].push(now);
            ans[i].pb(now);
        }
    }
    
    rep(i, k+1){
        cout << k << " ";
        for(auto x : ans[i]) cout << x+1 << " ";
        cout << endl;
    }
    return;
}

void Main() {
    int n; cin >> n;
    int k = 1;
    int flag = 0;
    
    while((k+1) * k / 2 <= n){
        if((k+1) * k / 2 == n){
            flag = 1;
            break;
        }
        k++;
    }
    
    if(!flag) {
        cout << "No" << endl;
        return;
    }

    solve(n, k);
    return;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 4548
#include <stdio.h>
#include <string.h>
int main(){
  int len,i;
  char S[200];
  scanf("%s",S);
  len = strlen(S);
  for(i = 1;i <= len/2;i++){
    if(S[2*i-1] == 'R'){
      printf("No");
      return 0;
    }
  }
  for(i = 0;i<=len/2;i++){
    if(S[i*2] == 'L'){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
}

Measured memory_bytes: 128
import sys
class Lazysegtree:
    #RAQ
    def __init__(self, A, intv, initialize = True, segf = min):
        #区間は 1-indexed で管理
        self.N = len(A)
        self.N0 = 2**(self.N-1).bit_length()
        self.intv = intv
        self.segf = segf
        self.lazy = [0]*(2*self.N0)
        if initialize:
            self.data = [intv]*self.N0 + A + [intv]*(self.N0 - self.N)
            for i in range(self.N0-1, 0, -1):
                self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) 
        else:
            self.data = [intv]*(2*self.N0)

    def _ascend(self, k):
        k = k >> 1
        c = k.bit_length()
        for j in range(c):
            idx = k >> j
            self.data[idx] = self.segf(self.data[2*idx], self.data[2*idx+1]) \
            + self.lazy[idx]
            
    def _descend(self, k):
        k = k >> 1
        idx = 1
        c = k.bit_length()
        for j in range(1, c+1):
            idx = k >> (c - j)
            ax = self.lazy[idx]
            if not ax:
                continue
            self.lazy[idx] = 0
            self.data[2*idx] += ax
            self.data[2*idx+1] += ax
            self.lazy[2*idx] += ax
            self.lazy[2*idx+1] += ax
    
    def update(self, k, x):
        k = k + self.N0
        self.data[k] = x
        self._ascend(k)
    
    def query(self, l, r):
        L = l+self.N0
        R = r+self.N0
        Li = L//(L & -L)
        Ri = R//(R & -R)
        self._descend(Li)
        self._descend(Ri - 1)
        
        s = self.intv                                                              
        while L < R:
            if R & 1:
                R -= 1
                s = self.segf(s, self.data[R])
            if L & 1:
                s = self.segf(s, self.data[L])
                L += 1
            L >>= 1
            R >>= 1
        return s
    
    def add(self, l, r, x):
        L = l+self.N0
        R = r+self.N0

        Li = L//(L & -L)
        Ri = R//(R & -R)
        
        while L < R :
            if R & 1:
                R -= 1
                self.data[R] += x
                self.lazy[R] += x
            if L & 1:
                self.data[L] += x
                self.lazy[L] += x
                L += 1
            L >>= 1
            R >>= 1
        
        self._ascend(Li)
        self._ascend(Ri-1)

N, M = map(int, input().split())
LA = [[] for _ in range(N)]
for _ in range(M):
    l, r, a = map(int, sys.stdin.readline().split())
    LA[r-1].append((l-1, a))

dp = Lazysegtree([0]*(N+1), -10**16, True, max)

for i in range(N):
    res = 0
    t = dp.data[1]
    for l, a in LA[i]:
        res += a
        dp.add(l, i, a)
    dp.add(i, i+1, res + t)
print(dp.data[1])


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


int main()
{
	int n,a;
	vector<int>v;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	cout<<v[v.size()-1]-v[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        while(true) {
            int k = sc.nextInt();
            if(k == 0)  break;
            int sum = 0;

            for(int i = 0; i < k * (k-1)/2; i++) {
                sum += sc.nextInt();
            }

            System.out.println(sum / (k-1));
        }

    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define ff first
#define ss second
typedef long long ll;

int main(){
	ll a,b;cin>>a>>b;
	if(a<b)swap(a,b);
	if((a-b)%2==0){
		ll p=(a+b)/2;
		cout<<p<<endl;
	}
	else cout<<"IMPOSSIBLE"<<endl;
	
	return 0;
}


Measured memory_bytes: 3632
import math
n = int(input())
num=[]
minv = []

for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
        num.append([i,n//i])
maxv = 10**13

for i in num:
    if maxv > (i[0]+i[1]):
        maxv = i[0]+i[1]
print(maxv-2)

Measured memory_bytes: 40300
s = input()
t = ''
for i in range(len(s)):
    if s[i] in ('A', 'C', 'G', 'T'):
        t += '1'
    else:
        t += '0'
"""
print(t)
print(t.split('0'))
"""

print(max(map(len, t.split('0'))))

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

ll n, k;
vector<ll> A;

ll cut(ll mid){
    ll res = 0;
    rep(i, n) res += ((A[i] - 1) / mid);
    return res;
}

int main(){
    cin >> n >> k;
    A.resize(n);
    rep(i, n) cin >> A[i];
    
    ll left = 1, right = *max_element(ALL(A));
    while(right != left){
        ll mid = (right + left) / 2;
        if(cut(mid) > k) left = mid + 1;
        else right = mid;
    }

    cout << left << endl;
    
    return 0;
}

Measured memory_bytes: 4776
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:i32 = read();
    let b:i32 = read();

    println!("{}",
        if a >= 13 {b}
        else if a >= 6 {b/2}
        else {0}
    );
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

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

    if(S == "AAA" || S == "BBB"){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back

using ll = long long;
using namespace std;

const ll MAX = 200200;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
// 前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}
// 二項係数の計算
ll COM(ll n, ll k){
    if (n < 0 || k < 0 || n < k) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// a^n mod.p を計算する（二分累乗法）
ll modpow(ll a, ll n, ll p){
    ll res = 1;
    while (n) {
        if (n & 1) res = res * a % p;
        a = a * a % p;
        n >>= 1;
    }
    return res;
}
// a^(-1) mod.p を計算する（フェルマーの小定理）ただしpは素数
ll modinv(ll a, ll p = MOD){
    return modpow(a, p-2, p);
}

ll n;
vector<vector<ll>> G;
ll dp1[200200], dp2[200200];

void dfs1(ll v, ll p){
    dp1[v] = 0; // 頂点数
    dp2[v] = 1; // 求める組み合わせ
    for(ll nv : G[v]){
        if(nv == p) continue;
        dfs1(nv,v);
        dp1[v] += dp1[nv];
        dp2[v] = dp2[v] * dp2[nv] % MOD * COM(dp1[v], dp1[nv]) % MOD;
    }
    dp1[v]++;
}

void dfs2(ll v, ll p, ll prev){
    dp2[v] = dp2[v] * prev % MOD * COM(n-1,dp1[v]-1) % MOD; // dp2の更新
    for(ll nv : G[v]){
        if(nv == p) continue;
        prev = dp2[v] * modinv(dp2[nv] * COM(n-1, dp1[nv]) % MOD) % MOD;
        dfs2(nv,v,prev);
    }
}

int main(){
    cin >> n;
    G.assign(n,vector<ll>());
    rep(i,n-1){
        ll a, b; cin >> a >> b; a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    COMinit();
    dfs1(0,-1);
    dfs2(0,-1,1);
    rep(i,n) cout << dp2[i] << endl;
}

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

typedef long long lint;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    lint n, k;
    cin >> n >> k;
    lint ans = 0;
    if(k > 0){
        REP(b, k+1, n+1){
            ans += (n / b) * (b - k);
            lint tmp = (n / b) * b + k;
            if(tmp <= n){
                ans += (n - tmp + 1);
            }
        }
    }else{
        ans = n * n;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"

ans = ""
for i in range(len(S)):
    for j in range(len(ALPHA)):
        if S[i] == ALPHA[j]:
            ans += ALPHA[j+N]
            break

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

vector<LL> v1[100];

int main(){
	LL n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	if(n<10){
		cout<<n<<endl;
		return 0;
	}
	n-=9;
	for(i=1;i<=9;i++){
		v1[0].push_back(i);
	}
	for(i=1;;i++){
		for(auto num:v1[i-1]){
			a=num%10;
			for(j=-1;j<=1;j++){
				if(a+j<0 || a+j>=10)continue;
				v1[i].push_back(num*10+a+j);
			}
		}
		a=n-(int)v1[i].size();
		if(a<0){
			cout<<v1[i][n-1]<<endl;
			return 0;
		}
		n-=(int)v1[i].size();
	}
}

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

int main()
{
    int n, ans = 0;
    cin >> n;
    int v[n], c[n];
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        if (v[i] - c[i] > 0)
        {
            ans += v[i] - c[i];
        }
    }
    cout << ans << endl;
  	return 0;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最小公倍数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){

int N, Y;
cin >> N >> Y;

int x = -1,y = -1,z = -1;
bool flag1 = false,flag2 = false;
for(int i = 0; i <= N; i++){
    if(flag1 == true)break;
    for(int j = 0; j<= N -i; j++){
        if(flag2 == true)break;
        int k = N - i - j;
        if(10000*k + 5000*j + 1000*i == Y ){
            x = k;
            y = j;
            z = i;
            flag1 = true;
            flag2 = true;

        }
    }
}

cout << x << " " << y << " " << z << " "<< endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        int a[] = new int[n];

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

        int counter = bubbleSort(a, n);
        for (int i=0; i<n-1; ++i) {
            System.out.print(a[i] + " ");
        }
        System.out.println(a[n-1] + "\n" + counter);
    }

    public static int bubbleSort(int a[], int n) {
        boolean flag = true;
        int counter = 0;
        while (flag) {
            flag = false;
            for (int i=n-1; i>0; --i) {
                if (a[i] < a[i-1]) {
                    int tmp = a[i];
                    a[i] = a[i-1];
                    a[i-1] = tmp;
                    flag = true;
                    counter += 1;
                }
            }
        }
        return counter;
    }
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

int N, W;
int value[110], weight[110];
int dp[110][10100];

int main() {
   cin >> N >> W;
   rep (i, 0, N) {
      cin >> value[i] >> weight[i];
   }
   rep (w, 0, W+1) {
      dp[0][w] = 0;
   }
   rep (i, 0, N) {
      rep (w, 0, W+1) {
         if (w >= weight[i]) {
            dp[i+1][w] = 
               max(dp[i][w-weight[i]]+value[i], dp[i][w]);
         } else {
            dp[i+1][w] = dp[i][w];
         }
      }
   }
   cout << dp[N][W] << endl;

   return 0;
}


Measured memory_bytes: 7076
# 試合を頂点とした有向グラフを書く
# 対戦2チームを元に試合ID(頂点番号)に変換できるようにする
# 閉路があるとNGなので-1
# 閉路がない場合は最長経路が答え

import sys
readline = sys.stdin.readline

N = int(readline())

id_dic = {}
next_id = 0
def to_id(a,b):
  if a > b:
    a,b = b,a
  return id_dic[(a,b)]
def convert_to_id(a,b,next_id):
  if a > b:
    a,b = b,a
  if (a,b) not in id_dic:
    id_dic[(a,b)] = next_id
    return next_id + 1
  return next_id

G = [[] for i in range((N * (N - 1)) // 2)] # 試合グラフ
indegree = [0 for i in range((N * (N - 1)) // 2)] # 入次数
for i in range(N):
  A = list(map(int,readline().split()))
  cur = None
  for a in A:
    # i と a - 1の試合
    next_id = convert_to_id(i,a - 1,next_id)
    game = to_id(i,a - 1)
    if cur != None:
      G[cur].append(game)
      indegree[game] += 1 # 試合に対する入次数が1
    cur = game
  
done = [False for i in range((N * (N - 1)) // 2)] # 試合完了
# 各日付ごとに、入次数が0の試合から行っていく
# 入次数が0になった試合を翌日の試合リスト
stack = []
for i in range(len(indegree)):
  if indegree[i] == 0:
    stack.append(i)

if len(stack) == 0:
  print(-1)
  exit(0)
  
day = 0
while stack:
  day += 1
  nextday = []
  while stack:
    game = stack.pop()
    if done[game]: # 既に終わっている試合の場合　閉路と見なす
      print(-1)
      exit(0)
    done[game] = True
    for child in G[game]: # 翌日のゲームを探索
      indegree[child] -= 1
      if indegree[child] == 0: # 入次数が0になれば翌日試合できる
        nextday.append(child)
  stack = nextday

if sum(done) != ((N * (N - 1)) // 2):
  print(-1)
  exit(0)
print(day)

Measured memory_bytes: 168576
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K,X,Y;
int a,b,c,d;
string S,T;
vector<int> A,B;
//=============================
void input()
{
    cin>>X>>Y;
}
//=============================
void func(){}
/*
 - 樹形図をかく
*/
//=============================
void solve()
{
    if (X == -Y) cout<<1<<endl;
    else if (abs(X)<abs(Y)){
        cout<<abs(Y) - abs(X) + (X<0) + (Y<0)<<endl;
    }
    else {
        cout<< abs(X) - abs(Y) + (X>0) + (Y>0)<<endl;
    }

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
/*


The woods are lovely, dark and deep,   
But I have promises to keep,   
And miles to go before I sleep,   
And miles to go before I sleep.


*/
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w;
    cin >> h >> w;
    char mat[h][w];
    ll dp[h][w];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> mat[i][j];
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (mat[i][j]!='#')
            {
                if (j-1>=0 )
                    dp[i][j] += dp[i][j - 1]%mod;
                if (i-1>=0)
                    dp[i][j] += dp[i - 1][j]%mod;
            }
        }
    }
    cout << dp[h - 1][w - 1] % mod;
}

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

int main()
{
    int N;
    float K;
    cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++)
        cin >> A[i];

    int res = 1;
    if (N != K)
    {
        res += ceil((N - K) / (K - 1.0));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
  int key;
  struct node *p,*left,*right;
}node;
typedef struct node* Node;
void insert(int);
Node find(int);
void print(Node);
void inorder(Node);
void preorder(Node);
Node root,NIL;

int main(){
  int m,k,i;
  char string[8];
  scanf("%d",&m);
  for(i = 0; i < m; i++){
    scanf("%s",string);
    if(strcmp(string,"insert") == 0){
      scanf("%d",&k);
      insert(k);
    }
    else if(strcmp(string,"find") == 0){
      scanf("%d",&k);
      if(NIL == find(k))printf("no\n");
      else printf("yes\n");
    }
    else if(strcmp(string,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->p = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

Node find(int k){
  Node x = root;
  while(x != NIL && k != x->key){ 
    if(k < x->key) x = x->left;
    else x = x->right;
  }
  return x;
}

void inorder(Node r){
  if(r == NIL) return;
  inorder(r->left);
  printf(" %d",r->key);
  inorder(r->right);
}

void preorder(Node r){
  if(r == NIL) return;
  printf(" %d",r->key);
  preorder(r->left);
  preorder(r->right);
}
 

Measured memory_bytes: 19364
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  string s;
  cin >> s;
  rep(i, s.length()) {
    s[i] = 'x';
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
    int a,b;
    cin >> a >>b;
    string ans=":(";
    if(16-(a+b)>=abs(a-b)*2){
        ans ="Yay!";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second

void solve(){  
	string c;
	cin>>c;
	if(c=="A"){
		cout<<"T"<<endl;
	}
	if(c=="C"){
		cout<<"G"<<endl;
	}	
	if(c=="G"){
		cout<<"C"<<endl;
	}	
	if(c=="T"){
		cout<<"A"<<endl;
	}			 	 
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

string s[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main(){
	string t; cin >> t;
	REP(i, 7){
		if(s[i] == t) printf("%d\n", 7-i);
	}
}


Measured memory_bytes: 256
#include <cstddef>
#include <memory>
#include <utility>

template <class Key, class T> class splay_associative_array {
public:
	using key_type = Key;
	using value_type = T;
	using reference = value_type &;

private:
	class node_type {
	public:
		typename splay_associative_array::key_type key;
		typename splay_associative_array::value_type value;
		::std::unique_ptr<node_type> left, right;
		node_type(const key_type &key) : key(key), value(), left(), right() {}
	};
	using pointer = ::std::unique_ptr<node_type>;

	pointer root;

public:
	splay_associative_array() : root() {}

	reference operator[](const key_type &key) {
		pointer left, right;
		pointer *next_l = &left, *next_r = &right;
		while (1) {
			if (!root)
				root = ::std::make_unique<node_type>(key);
			if (!(root->key <= key)) {
				if (!root->left)
					root->left = ::std::make_unique<node_type>(key);
				if (!(root->left->key <= key)) {
					*next_r = ::std::move(root->left);
					root->left = ::std::move((*next_r)->right);
					(*next_r)->right = ::std::move(root);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
				else if (!(key <= root->left->key)) {
					*next_r = ::std::move(root);
					next_r = &(*next_r)->left;
					*next_l = ::std::move(*next_r);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
				else {
					*next_r = ::std::move(root);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
			}
			else if (!(key <= root->key)) {
				if (!root->right)
					root->right = ::std::make_unique<node_type>(key);
				if (!(root->right->key <= key)) {
					*next_l = ::std::move(root);
					next_l = &(*next_l)->right;
					*next_r = ::std::move(*next_l);
					next_r = &(*next_r)->left;
					root = ::std::move(*next_r);
				}
				else if (!(key <= root->right->key)) {
					*next_l = ::std::move(root->right);
					root->right = ::std::move((*next_l)->left);
					(*next_l)->left = ::std::move(root);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
				else {
					*next_l = ::std::move(root);
					next_l = &(*next_l)->right;
					root = ::std::move(*next_l);
				}
			}
			else {
				*next_l = ::std::move(root->left);
				root->left = ::std::move(left);
				*next_r = ::std::move(root->right);
				root->right = ::std::move(right);
				return root->value;
			}
		}
	}
};

#include <iostream>

int main() {
	using i64 = long long;
	int n;
	::std::cin >> n;

	splay_associative_array<i64, i64> mp;
	i64 sum = 0, ans = 0;
	mp[0] = 1;

	while (n--) {
		int a;
		::std::cin >> a;
		
		sum += a;
		ans += mp[sum]++;
	}

	::std::cout << ans << ::std::endl;

	return 0;
}


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

#define     Boost               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define     all(cont)           cont.begin(),cont.end()
#define     rall(cont)          cont.rbegin(),cont.rend()
#define     foreach(cont)       for(auto &value: cont)
#define     show(val)           cout<< #val << " -> " << val << endl
#define     flush               cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define     Case                cout<< "Case "<< ++cs << ": "
#define     mk                  make_pair
#define     pb                  push_back
#define     ff                  first
#define     ss                  second

typedef     long long                   ll ;
typedef     unsigned long long          ull ;
typedef     pair <int, int>             pii ;

const ll INF = (1LL<<60)-1 ;




//#define DEBUG
int main()
{
    Boost;

    #ifdef DEBUG
    freopen("input.txt","r",stdin);    // Read
    freopen("output.txt","w",stdout);  // Write
    #endif

    ll n,sum=0;
    cin>> n ;

    sum = n*(n+1)/2 ;
    ll temp = (n/3) ;
    temp = (temp*(temp+1))/2 ;
    temp *= 3 ;
    sum -= temp ;
    temp = n/5 ;
    temp = (temp*(temp+1))/2 ;
    temp *= 5 ;
    sum -= temp ;
    temp = n/((ll)5*3) ;
    temp = (temp*(temp+1))/2 ;
    temp *= ((ll)5*3) ;
    sum += temp ;

    cout << sum << endl ;

    return 0;
}




Measured memory_bytes: 3652
/**
*    author:  yuya1234
*    created: 08.07.2020 13:35:30
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  cin>>n;

  int tmp;
  int a[9];
  MEMSET(a,0);

  REP(i,n)
  {
    cin>>tmp;
    if(tmp<400)a[0]=1;
    else if(tmp<800)a[1]=1;
    else if(tmp<1200)a[2]=1;
    else if(tmp<1600)a[3]=1;
    else if(tmp<2000)a[4]=1;
    else if(tmp<2400)a[5]=1;
    else if(tmp<2800)a[6]=1;
    else if(tmp<3200)a[7]=1;
    else a[8]++;
  }

  int cnt=0,amax=0,amin=0;

  REP(i,8)
  {
    if(a[i]==1)cnt++;
  }

  if(a[8]==0)
  {
    amax=amin=cnt;
  }
  else
  {
    if(cnt==0)
    {
      amax=a[8];
      amin=1;
    }
    else
    {
      amax=cnt+a[8];
      amin=cnt;
    }
    
  }

  cout<<amin<<" "<<amax<<endl;
  

  return 0;
}

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

struct Dice{
  int n1,n2,n3,n4,n5,n6;
  Dice(int n1, int n2, int n3, int n4, int n5, int n6)
    :n1(n1), n2(n2), n3(n3), n4(n4), n5(n5), n6(n6) {}

  void N(){
    swap(n1,n2);swap(n2,n6);swap(n6,n5);
  }
  void S(){
    swap(n1,n5);swap(n5,n6);swap(n6,n2);
  }
  void E(){
    swap(n1,n4);swap(n4,n6);swap(n6,n3);
  }
  void W(){
    swap(n1,n3);swap(n3,n6);swap(n6,n4);
  }

  int funcf(int f, int a, int b, int c, int d){
    if(f==a)return b;
    if(f==b)return c;
    if(f==c)return d;
    if(f==d)return a;
    return 0;
  }

  int ansRight(int u, int f){
    if(u==n1)return funcf(f,n2,n3,n5,n4);
    if(u==n2)return funcf(f,n1,n4,n6,n3);
    if(u==n3)return funcf(f,n1,n2,n6,n5);
    if(u==n4)return funcf(f,n1,n5,n6,n2);
    if(u==n5)return funcf(f,n1,n3,n6,n4);
    if(u==n6)return funcf(f,n2,n4,n5,n3);
    return 0;
  }
};

template<class H>
void CIN(H& h){
  cin>>h;
}
template<class H, class... T>
void CIN(H &h, T&... t){
  cin>>h;
  CIN(t...);
}

int main(){
  int a,b,c,d,e,f;
  //cin>>a>>b>>c>>d>>e>>f;
  CIN(a,b,c,d,e,f);
  Dice dice(a,b,c,d,e,f);

  int n;cin>>n;
  for(int i=0; i<n; i++){
    int p,q;CIN(p,q);
    cout<<dice.ansRight(p,q)<<endl;
  }
}


Measured memory_bytes: 3088
#include<stdio.h>

int main(){
	
	int angka,a,b;
	
	scanf("%d",&angka);
	
	if(angka==1){
		printf("Hello World\n");
	}
	
	if(angka==2){
		
			scanf("%d",&a);
			scanf("%d",&b);
			
			printf("%d\n",a+b);
		
	}
	
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
n = int(input())
li = [0] * (10**5 + 3)
for _ in range(n):
    a, b = map(int, input().split())
    li[a] += 1
    li[b + 1] -= 1
for i in range(n + 1):
    li[i + 1] += li[i]
ans = 0
for i in range(1, n + 2):
    if i - 1 <= li[i]:
        ans = max(ans, i - 1)
print(ans)



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

const int MAX_N = 200005, MOD = 1000000007;
typedef long long i64;

class Data {
public:
  int x, v;
} p[MAX_N];

bool cmp(Data a, Data b) {
  return a.v < b.v;
}

bool cmp2(int a, int b) {
  return p[a].x < p[b].x;
}

bool cmp3(int a, int b) {
  return p[a].x > p[b].x;
}

vector<int> vec[MAX_N];

int N, st[MAX_N], L[MAX_N], R[MAX_N], id[MAX_N];
i64 f[MAX_N], sum[MAX_N];

bool cmp4(int a, int b) {
  if (L[a] != L[b]) return L[a] < L[b];
  return R[a] < R[b];
}

void update(int x, i64 val) {
  for (; x <= N + 1; x += x & -x)
    sum[x] = (sum[x] + val) % MOD;
}

i64 ask(int x) {
  i64 res = 0;
  for (; x; x -= x & -x)
    res = (res + sum[x]) % MOD;
  return res;
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    scanf("%d%d", &p[i].x, &p[i].v);
  sort(p + 1, p + N + 1, cmp);

  int top = 0;
  for (int i = 1; i <= N; ++i) {
    if (top <= 0 || p[st[top]].x < p[i].x) st[++top] = i;
    L[i] = st[lower_bound(st + 1, st + top + 1, i, cmp2) - st];
  }

  top = 0;
  for (int i = N; i; --i) {
    if (top <= 0 || p[st[top]].x > p[i].x) st[++top] = i;
    R[i] = st[lower_bound(st + 1, st + top + 1, i, cmp3) - st];
    id[i] = i;
  }

  sort(id + 1, id + N + 1, cmp4);
  update(1, 1);
  for (int i = 1; i <= N; ++i) {
    int x = id[i];
    i64 temp = ask(N + 1) - (L[x] > 1 ? ask(L[x] - 1) : 0);
    update(R[x] + 1, temp);
  }

  i64 result = (ask(N + 1) - ask(N)) % MOD;
  printf("%lld\n", (result + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 12288
#include <cstdio>
#include <iostream>
 
using namespace std;
 
int main()
{
	long long n,x,a[100100],ans = 0;
	cin >> n >> x >> a[0]; 
	for(int i=1;i<n;i++) 
	{
		cin >> a[i];
		long long sum = a[i] + a[i-1];
		if(sum>x) 
		{
			ans+=sum - x;
			a[i]-=sum-x;
			if(a[i]<0) a[i] = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int i = 0;
    std::string S;
    
    std::cin >> S;
    int S_length = S.length();
    int num_row[S_length] = {}; // 0配列
    while(i < S_length-1){
        int temp_thr = 0;
        int R_count = 0;
        int L_count = 0;
        while(1){
            R_count++;
            if(S[i+1] == 'L' ){
                temp_thr = i;
                num_row[temp_thr] += R_count - R_count/2;
                num_row[temp_thr + 1] += R_count/2;
                i++;
                break;
            }
            i++;
        }
        while(1){
            L_count++;
            if(S[i+1] == 'R' || i == S_length -1 ){
                num_row[temp_thr] += L_count/2;
                num_row[temp_thr + 1] += L_count - L_count/2;
                i++;
                break;
            }
            i++;
        }
    }
    for (int j = 0; j < S_length - 1; j++)std::cout << num_row[j] << " ";
    std::cout << num_row[S_length-1]<< std::endl;
    return 0;
}

Measured memory_bytes: 1024
strN = input()
N = int(strN)
p = {i: {j: 0 for j in range(1, 10)} for i in range(1, 10)}
for k in range(1, N+1):
    strk = str(k)
    i = int(strk[0])
    j = int(strk[-1])
    if i == 0 or j == 0:
        continue
    p[i][j] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += p[i][j] * p[j][i]

print(ans)


Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn dfs(tree: &Vec<Vec<usize>>, counter: &mut Vec<i64>, now: usize, from: usize) {
    for leaf in &tree[now] {
        if *leaf == from || *leaf == 1<<50 {
            continue;
        }
        counter[*leaf] += counter[now];
        // println!("leaf {} counter {:?} tree {:?}", *leaf, counter, tree);
        dfs(tree, counter, *leaf, now);
    }
}
fn main() {
    input!{
        n: usize,
        q: usize,
        ab: [(usize1, usize1);n-1],
        px: [(usize1, i64); q],
    }
    // println!("{:?}", ab);
    // println!("{:?}", px);
    let mut counter = vec![0;n];
    for &(p, x) in &px {
        counter[p] += x;
    }
    let mut tree = vec![vec![];n];
    for &(a,b) in &ab {
        tree[a].push(b);
        tree[b].push(a);
    }
    // println!("{:?}", tree);
    dfs(&tree, &mut counter, 0, 1<<50);
    // println!("{:?}", counter);
    for i in 0..n {
        if i==n-1 {
            println!("{}", counter[i]);
        }else{
            print!("{} ", counter[i]);
        }

    }
}

Measured memory_bytes: 41468
using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine().Trim();
            string T = Console.ReadLine().Trim();


            var correct = S == T.Substring(0, T.Length - 1);
            Console.WriteLine(correct ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 25892
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int[] dic = new int[N+1];
        for(int i=1;i<=Math.min(9,N);i++){
            dic[i] = i;
        }
        for(int i=10;i<=N;i++){
            dic[i] = i%10+dic[i/10];
        }
        long ans = 0;
        for(int i=1;i<=N;i++){
            if(dic[i]>=A&&dic[i]<=B) ans += i;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(10);
	ll k;
	string s;
	cin>>k>>s;
	if(s.size()<=k)
	cout<<s;
	else
	{
		for(int a=0;a<k;a++)
		cout<<s[a];
		cout<<"...";
	}
	return 0;
}

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

int main(){
  int64_t n;
  cin >> n;
  int64_t total = 0;
  for(int64_t i=1; i<=n ;i++){
    if(i % 3 != 0 && i % 5 != 0){
      total += i;
    }
  }
  cout << total << endl;
}
      

Measured memory_bytes: 3624
#include <stdio.h>

int main() {
	int n, i, cnt = 0;
	char tmp = '0';
	scanf("%d", &n);
	char s[100000];
	scanf("%s", s, 100000);

	for (i = 0; i < n; i++) {
		if (s[i] != tmp) {
			cnt++;
			tmp = s[i];
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> qua;
const double epx=1e-7;
int ccw(qua a,qua b,qua c)
{
    b-=a,c-=a,a=c*conj(b);
    if(a.imag()>epx) return 1;
    if(a.imag()<-epx) return -1;
    if(a.real()<-epx) return 2;
    if(abs(b)+epx<abs(c)) return -2;
    return 0;
}
int isintersect(qua a,qua b,qua c,qua d)
{
    return (ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0);
}
int main()
{
    int t;
    for(scanf("%d",&t); t; --t)
    {
        double x1,x2,x3,x4,y1,y2,y3,y4;
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        printf("%d\n",isintersect(qua(x1,y1),qua(x2,y2),qua(x3,y3),qua(x4,y4)));
    }
}



Measured memory_bytes: 3280