akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;

ll INF = 1e+18;
using G = vector<map<int, int>>;

int 
main()
{
  int N; cin >> N;
  vector<int> arr(N), brr(N), crr(N);
  rep(i, 0, N) cin >> arr[i];
  sort(arr.begin(), arr.end());
  rep(i, 0, N) cin >> brr[i];
  sort(brr.begin(), brr.end());
  rep(i, 0, N) cin >> crr[i];
  sort(crr.begin(), crr.end());


  ll ans = 0;
  rep(i, 0, N){
    ll a = lower_bound(arr.begin(), arr.end(), brr[i]) - arr.begin();
    ll c = crr.end() - upper_bound(crr.begin(), crr.end(), brr[i]);
    ans += a * c;
  }

  cout << ans << endl;

}

Measured memory_bytes: 4584
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	char x1,y1;
	int a,b;
	cin>>x1>>y1;
	a=x1;
	b=y1;
	if(a<b) cout<<"<"<<endl;
	if(a==b) cout<<"="<<endl;
	if(a>b) cout<<">"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define fs first
#define sc second

using namespace std;

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

int main() {
  ll N;

  cin >> N;

  int ans[N];
  vector<P> aLst[N];

  queue<ll> que;
  bool start_added = false;
  for (int i = 0; i < N; ++i) {
    ll u, v, w;
    cin >> u;
    cin >> v;
    cin >> w;
    P tmp0(v - 1, w);
    aLst[u - 1].emplace_back(tmp0);
    P tmp1(u - 1, w);
    aLst[v - 1].emplace_back(tmp1);
  }

  que.push(0);
  ans[0] = 0;

  unordered_map<ll, bool> visited;

  while (!que.empty()) {
    ll cur = que.front();
    que.pop();
    // cout << "cur=" << cur << endl;
    for (size_t i = 0; i < aLst[cur].size(); ++i) {
      ll cur_child = aLst[cur][i].fs;
      if (visited.count(cur_child) == 0) {
        que.push(cur_child);
        visited[cur_child] = true;
        if (aLst[cur][i].sc % 2 == 0) {
          ans[cur_child] = ans[cur];
        } else {
          ans[cur_child] = 1 - ans[cur];
        }
      }
    }
  }

  for (int i = 0; i < N; ++i) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

int main() {
  int x, y, ans = 0;
  cin >> x >> y;
  if (x == 1 && y == 1) ans += 400000;
  if (x < 4) ans += (4 - x) * 100000;
  if (y < 4) ans += (4 - y) * 100000;
  cout << ans << endl;
}

Measured memory_bytes: 256
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())

a = (a1-b1)*t1
b = (a2-b2)*t2
if a < 0:
    a *= -1
    b *= -1

if a == -b:
    print("infinity")
    exit()
if a+b > 0:
    print(0)
else:
    c = -a-b
    print((a+c-1)//c + a//c)


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

int main() {
 int n;
 int a[110][110];
 int S[110][110];
 int s[110];
 cin >> n;
 for (int i=0; i<n; ++i) {
  for (int j=0; j<n; ++j) {
   cin >> a[i][j];
  }
 }
 for (int i=0; i<=n; ++i) {
  S[i][0] = 0;
  s[0] = 0;
  for (int j=0; j<n; ++j) {
   s[j+1] = s[j] + a[i-1][j];
   if (i == 0) { S[i][j+1] = 0; }
   else { S[i][j+1] = S[i-1][j+1] + s[j+1]; }
  }
 }
 int max = -10001;
 for (int i=0; i<n; ++i) {
  for (int j=i+1; j<=n; ++j) {
   for (int k=0; k<n; ++k) {
    for (int l=k+1; l<=n; ++l) {
     int t = S[j][l] - S[i][l] - S[j][k] + S[i][k];
     max = (t > max) ? t : max;
    }
   }
  }
 }
 cout << max << endl;
}


Measured memory_bytes: 1252
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int k;
    cin >> n >> k;
    int max = ((n-1)*(n-2))/2;
    if(k>max){
        cout << "-1\n";
    }else{
        cout << n-1+max-k << endl;
        int e = max-k;
        for(int i=2;i<=n;i++){
            printf("%d %d\n", 1, i);
        }
        for(int i=2;i<=n-1;i++){
            for(int j=i+1;j<=n;j++){
                if(e>0){
                    printf("%d %d\n", i, j);
                    e--;
                }else{
                    break;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, ma, mb, dp[50][101][101], a[40], b[40], c[40];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    rep(i, 0, 50) rep(j, 0, 101) rep(k, 0, 101) 
        dp[i][j][k] = INF;
    cin >> n >> ma >> mb;
    rep(i, 0, n) 
        cin >> a[i] >> b[i] >> c[i];
    
    dp[0][0][0] = 0;
    rep(i, 0, n) rep(j, 0, 101) rep(k, 0, 101) {
        if (dp[i][j][k] == INF) continue;
        dp[i+1][j][k] = min(dp[i][j][k], dp[i+1][j][k]);
        dp[i+1][j+a[i]][k+b[i]] = min(dp[i][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
    }

    int ans = INF;
    rep(j, 1, 101) rep(k, 1, 101) {
        if (j * mb == k * ma) ans = min(ans, dp[n][j][k]);
    }
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2304
// IF you wanna live in a place where people are not afraid of mice
// you must give up living in palace

#include<bits/stdc++.h>

#define s second
#define f first
#define pb push_back
#define int ll
#define D(x) cerr<<#x<<": "<<x<<endl
#define D2(x) cerr<<#x<<": "<<x<<ends
#define mid ((l+r) >> 1)
#define lc (id << 1)
#define rc ((id << 1) + 1)
#define lb(x) ((x) & -(x))

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAX=2e5,mod=1e9+7,base=41,INF=99999999999,sq=502;

int n,dp[101][100010],k,val[MAX],w[MAX];

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> w[i] >> val[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(j < w[i]) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + val[i]);
        }
    }
    cout << dp[n][k];
}


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


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

int main() {
	ll n, k;

	cin >> n >> k;

	vector<ll> h(n);
	rep(i,n) {
		cin >> h[i];
	}

	sort(h.rbegin(), h.rend());

	if (n <= k) {
		cout << 0 << endl;
		return 0;
	}
	ll total = 0;
	for(int i = k; i < n; i++) {
		total += h[i];
	}
	cout << total << endl;
	
	return 0;
}

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

using namespace std;

int main(){
	string S;

	cin >> S;

	if(S == "SUN"){
		cout << "7" << endl;
	}else if(S == "MON"){
		cout << "6" << endl;
	}else if(S == "TUE"){
		cout << "5" << endl;
	}else if(S == "WED"){
		cout << "4" << endl;
	}else if(S == "THU"){
		cout << "3" << endl;
	}else if(S == "FRI"){
		cout << "2" << endl;
	}else{
		cout << "1" << endl;
	}
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<ctime>
#include<cassert>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char c[1000][1000];
int main()
{	int n,ans=0; cin>>n;
	for(rint i=0;i<n;i++) scanf("%s",c[i]);
	for(rint i=0;i<n;i++)
	{	int tag=1;
		for(rint j=0;j<n;j++)
		for(rint k=0;k<n;k++) tag&=(c[j][k]==c[(k-i+n)%n][(j+i)%n]);
		if(tag) ans+=n;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 512
N = int(input())
h_list = list(map(int, input().split()))
 
dp = [float("inf") for _ in range(N + 1)]
dp[1] = 0
for i in range(2, N + 1):
    if i == 2:
        dp[2] = abs(h_list[1] - h_list[0])
    else:
        dp[i] = min(dp[i - 1] + abs(h_list[i-1] - h_list[i - 2]), dp[i - 2] + abs(h_list[i-1] - h_list[i - 3]))
print(dp[N])

Measured memory_bytes: 13928
def next(n,l):
    li = list(str(n).zfill(l))
    mn = int(''.join(sorted(li)))
    mx = int(''.join(sorted(li,reverse=True)))
    return mx - mn

while True:
    N,L = map(int,input().split())
    if L == 0: break
    arr = [N]
    for i in range(1,25):
        ai = next(arr[-1], L)
        if ai in arr:
            j = arr.index(ai)
            print('{0} {1} {2}'.format(j,ai,i-j))
            break
        arr.append(ai)

Measured memory_bytes: 5596
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>
#include<cassert>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで




using namespace std;
int n,m;
int a[200000];
int c[200000];
vector< pair <int,int> > v;

signed main(){
  cin >> n >> m;
  REP(i,n){
    cin >> a[i];
  }
  REP(i,m){
    int k1,k2;
    cin >> k1 >> k2;
    v.pb(pair<int,int> (k2,k1));
  }
  sort(a,a+n);
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());

  int t = -1;//made
  int now = 0;
  int ans = 0;
  int k2;
  REP(i,n){
    if(now==m&&t<i){
      ans += a[i];
      continue;
    }
    if(t<i){
      t += v[now].second;
      k2 = v[now].first;
      now ++;
    }
    ans += max(a[i],k2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3188
Imports System.Collections.Generic
Imports System.Console
Imports System.Math

Module Program
    Sub Main()
        Dim x As Integer = NextInt()
        Dim y As Integer = NextInt()

        Dim cnt As Integer
        Select Case Abs(x) - Abs(y)
            Case Is < 0
                cnt += Int(x < 0)
                cnt += Int(y < 0)
            Case Is > 0
                cnt += Int(x > 0)
                cnt += Int(y > 0)
            Case Is = 0
                cnt += Int(x <> y)
        End Select

        WriteLine(Abs(Abs(x) - Abs(y)) + cnt)
    End Sub

    Function Int(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


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

int main(){
    char a; cin>>a;
    char s[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    char b[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

    rep(i, 26){
        if(a == s[i]){
            cout <<"a"<<endl;
            break;
        }
        if(a == b[i]){
            cout << "A" << endl;
        }
}

}


Measured memory_bytes: 3616
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
i=0
ans=0
while i!=n:

    ans+=b[a[i]-1]
    if i!=0:
        if (a[i]-a[i-1])==1:
            ans+=c[a[i-1]-1]

    i+=1

print(ans)

Measured memory_bytes: 3064
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

void solve(vector<lint> &a, vector<lint> &b, vector<lint> &c, lint x, lint y, lint z, lint k){
    vector<lint> ab(x * y, 0);
    vector<lint> ans(0);
    for (int i=0; i<x; ++i){
        for (int j=0; j<y; ++j){
            ab.push_back(a[i] + b[j]);
        }
    }
    sort(ALL(ab), greater<lint>());
    for (int i=0; i<k; ++i){
        for (int j=0; j<z; ++j){
            ans.push_back(ab[i] + c[j]);
        }
    }
    sort(ALL(ans), greater<lint>());
    for (int i=0; i<k; ++i){
        cout << ans[i] << endl;
    }
    return;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<lint> a(x);
    vector<lint> b(y);
    vector<lint> c(z);
    for (int i=0; i<x; ++i){
        cin >> a[i];
    }
    for (int i=0; i<y; ++i){
        cin >> b[i];
    }
    for (int i=0; i<z; ++i){
        cin >> c[i];
    }
    solve(a, b, c, x, y, z, k);
    return 0;
}

Measured memory_bytes: 58868
n,k=map(int,input().split())
if k>((n-1)*(n-2))//2:
  print(-1)
  
else:
  i=0
  k=(n*(n-1))//2-k
  print(k)
  x=1
  y=2
  for i in range(k):
    print(x,y)
    if y==n:
      x+=1
      y=x+1
    else:
      y+=1

Measured memory_bytes: 3608
def d(p, q):
    return pos[p] - pos[q]

def solve():
    p0, p1, p2 = 0, 0, 0
    best = 0
    while p0 < N:
        # p1????±???????
        if p1 <= p0: p1 = p0 + 1
        while d(p1, p0) <= best and p1 - p0 < N:
            p1 += 1
        if d(p1, p0) <= best:
            p0 += 1
            continue
        # p2????±???????
        while d(p2, p1) > d(p1, p0) and p2 > p1:
            p2 -= 1
        if p2 <= p1: p2 = p1 + 1
        while d(p2,p1) < d(p1, p0) and p2 - p0 < N:
            p2 += 1
        if d(p2, p1) < d(p1, p0):
            p0 += 1
            continue
        # check
        if L - d(p2, p0) >= d(p1, p0):
            best = d(p1, p0)
            if best >= L//3:
                return best
        else:
            p0 += 1
    return best

N = int(input())
A = [0] * N
L = 0
for i in range(N):
    A[i] = int(input())
    L += A[i]
pos = [0] * (2*N)
for i in range(1, 2*N):
    pos[i] = pos[i-1] + A[(i-1)%N]

print(solve())

Measured memory_bytes: 20944
import math
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

s=input()
k=s.find('/')
y=int(s[:k])
s=s[k+1:]
k=s.find('/')
m=int(s[:k])
d=int(s[k+1:])

if y<=2019 and m<=4 and d<=30:
    print("Heisei")
else:print("TBD")


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int k;

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

void solve()
{
	cin >> k;
	int rs = 0;
	for (int i = 1; i <= k; ++i){
		for (int j = 1; j <= k; ++j){
			for (int l = 1; l <= k; ++l)
			{
				rs += gcd(i, gcd(j, l));
			}
		}
	}
	cout << rs << endl;
}

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


Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
int main(void){
  int a,b,C;
  double rad,S,L,h;
  scanf("%d %d %d",&a,&b,&C);
  rad = ((double)C/180)*M_PI;
  L = a+b+sqrt(a*a+b*b-2*a*b*cos(rad));
  S = a*b*sin(rad)/2;
  h = b*sin(rad);
  printf("%f %f %f\n",S,L,h);
  return 0;
}

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

using namespace std;

int main() {
    string word;
    int len, counter = 0;
    cin >> len >> word;
    
    for (int i = 0; i < len - 2; i++) {
        if (word[i] == 'A' && word[i+1] == 'B' && word[i+2] == 'C') {
            counter++;
        }
    }
    
    cout << counter << endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(){
    int N, K;
    int h[110000];
    int i, j;
    int min = 1000000000;

    scanf("%d %d", &N, &K);

    for(i=0; i<N; i++){
        scanf("%d", &h[i]);
    }

    qsort(h, N, sizeof(int), asc);

    for(i=0; i<=(N-K); i++){
        if(min > h[i+K-1] - h[i]){
            min = h[i+K-1] - h[i];
        }
    }

    printf("%d", min);

    return 0;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int X, A, B; cin >> X >> A >> B;
    if(B-A <= 0) cout << "delicious" << endl;
    else if(B-A <= X) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<algorithm>
#define _ 0
#define INF 0x7fffffff
#define re register
#define drep(i ,l ,r) for(re int i = (r) ; i >= (l) ; -- i)
#define rep(i ,l ,r) for(re int i = l ; i <= r ; ++ i)
#define Next(u ,i) for(re int i = head[u] ; i ; i = e[i].next)
const int N = 2e5 + 1;
int n ,x[N] ,y[N] ,a[N] ,b[N];
int read() {
    char cc = getchar() ; int cn = 0 ,flus = 1;
    while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus ; cc = getchar();}
    while(cc >= '0' && cc <= '9') cn = cn * 10 + cc - '0' ,cc = getchar();
    return flus * cn;
}
signed main() {
	n = read();
	rep(i ,1 ,n) x[i] = read() ,y[i] = read() ,a[i] = x[i] + y[i] ,b[i] = y[i] - x[i];
	std :: sort(a + 1,a + n + 1) ,std :: sort(b + 1,b + n + 1);
	printf("%d" ,std :: max(a[n] - a[1] ,b[n] - b[1]));
	return ~~(0^_^0);
}

Measured memory_bytes: 4724
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;


int main(void) {
	int n, k;
	int d[11];
	int p;

	cin >> n >> k;
	FOR(i, 1, k) {
		cin >> d[i];
	}
	p = n - 1;
	FOR(i, n, 1000000) {
		p += 1;
		FOR(u, 0, 10) {
			FOR(t, 1, k) {
				if (i >= 88880) {
					//cout << p << " " << i << " " << u << " " << t << " " << p / (int)pow(10, u) << endl;
				}
				
				if (p / (int)pow(10, u) == 0 ) {
					goto jump;
				}
				if ((p / (int)(pow(10, u))) % 10 == d[t]) {
					goto warp;
				}

			}
		}
	warp:;
	}
jump:;
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))
ans = 1
t = 0

for k in range(1,N):
    if A[k-1] > A[k]:
        t = -1
        break
    elif A[k-1] < A[k]:
        t = 1
        break
if t==0:
    print(1)
    exit(0)

k = 0
while k < N-1:
    k += 1
    if t == 1:
        if A[k-1] > A[k]:
            ans += 1
            while k+1<N and A[k]==A[k+1]:
                k += 1
            if k == N-1:
                break
            elif A[k] > A[k+1]:
                t = -1
            else:
                t = 1
    else:
        if A[k-1] < A[k]:
            ans += 1
            while k+1<N and A[k]==A[k+1]:
                k += 1
            if k == N-1:
                break
            elif A[k] > A[k+1]:
                t = -1
            else:
                t = 1

print(ans)

Measured memory_bytes: 14100
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,m,r,cost[200][200],city[8],mi = INF;
	cin >> n >> m >> r;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++) cost[i][j] = INF;
		cost[i][i] = 0;
	}
	for(int i = 0;i < r;i++){
		cin >> city[i];
		city[i]--;
	}
	for(int i = 0;i < m;i++){
		int a,b,c;
		cin >> a >> b >> c; a--;b--;
		cost[a][b] = c;
		cost[b][a] = c;
	}
	for(int k = 0;k < n;k++){
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++) cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]);
		}
	}
	sort(city,city + r);
	do{
		int ans = 0;
		for(int i = 0;i < r - 1;i++){
			ans += cost[city[i]][city[i + 1]];
		}
		mi = min(mi,ans);
    } while( next_permutation(city,city + r));
    cout << mi << endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    vector<int> cnt(3);
    rep(i,s.size()) {
        cnt[s[i]-'a']++;
    }
    int mx = max(cnt[0], max(cnt[1], cnt[2]));
    int mn = min(cnt[0], min(cnt[1], cnt[2]));
    if(mx-mn<=1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3752
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;

const int MOD = 1000000007;
const int INF = 1000000000;

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

int main(){
    int a, b, c; cin >> a >> b >> c;
    int mx = max({a, b, c});
    cout << a + b + c + 9*mx << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define _GLIBCXX_DEBAC
using namespace std;
	
int findx(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}

	return sum;
}

string divide[4] = { "dream","dreamer","erase","eraser" };

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

	reverse(s.begin(), s.end());
	for (int i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());
	
	bool can = true;
	for (int i = 0; i < s.size();) {
		bool can2 = false;
		for (int j = 0; j < 4; j++) {
			string d = divide[j];
			if (s.substr(i, d.size()) == d) {
				can2=true;
				i+=d.size();

			}
		}
		if (!can2) {
			can = false;
			break;
		}
	}

	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}










Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for (int i=(a); i<=(b); i++)

char s[101];
int len;
bool flag=true;

int main(void)
{
	cin>>len;
	scanf("%s",s);
	if (len%2==1)
		flag=false;
	else
		For(i,0,len/2-1)
		{
			if (s[i]!=s[i+len/2])
			{
				flag=false;
				break;
			}
		}
	if (flag)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <stack>

using namespace std;
int main(int argc, const char * argv[]) {
    
    string s; cin >> s;
    string t;
    for(int i=0; i<s.size(); i++){
        if (s[i]=='B'){
            if (t.size()!=0) t = t.substr(0, t.size()-1);
        }
        else {
            t += s[i];
        }
    }

    cout << t << endl;
    return 0;
}

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

int main()
{
  int ans(1000);
  string s;
  cin >> s;
  for (int i = 0; i <= s.length() - 3; i++) {
    ans = min(ans, abs(stoi(s.substr(i, 3)) - 753));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

sum = 0
sum_list = Array.new(N)
as.each.with_index do |a, i|
  sum += a
  sum_list[i] = sum
end

mod_table = Hash.new { 0 }
sum_list.each { |s| mod_table[s % M] += 1 }

ans = 0
sum = 0
as.each do |a|
  n = sum % M
  ans += mod_table[n]
  sum += a
  mod_table[sum % M] -= 1
end
puts ans


Measured memory_bytes: 12940
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
  
using namespace std;
  
void Solution()
{
    int a[100] = {0};
    string direction;
    
    for(int i = 1; i <= 6; i++)
    {
        cin>>a[i];
    }
    cin>>direction;
    
    for(int i = 0; i < (int)direction.size(); i++)
    {
        int temp1 = 0;
        int temp2 = 0;
        
        if(direction[i] == 'S')
        {
            temp1 = a[1];
            temp2 = a[2];
            a[1] = a[5];
            a[2] = temp1;
            a[5] = a[6];
            a[6] = temp2;
        }
        else if(direction[i] == 'N')
        {
            temp1 = a[1];
            temp2 = a[5];
            a[1] = a[2];
            a[2] = a[6];
            a[5] = temp1;
            a[6] = temp2;
        }
        else if(direction[i] == 'W')
        {
            temp1 = a[1];
            temp2 = a[4];
            a[1] = a[3];
            a[3] = a[6];
            a[4] = temp1;
            a[6] = temp2;
        }
        else if(direction[i] == 'E')
        {
            temp1 = a[1];
            temp2 = a[3];
            a[1] = a[4];
            a[3] = temp1;
            a[4] = a[6];
            a[6] = temp2;
        }
    }
    
    cout<<a[1]<<endl;
            
}
  
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>

void tanishi_sort(int a[]);
void tanishi_swap(int *a, int *b);

int main(void)
{
	int a[5];
	int i;

	for (i = 0; i < 5; i++){
		scanf("%d", &a[i]);
	}

	tanishi_sort(a);

	for (i = 0; i < 4; i++){
		printf("%d ", a[i]);
	}
	printf("%d\n", a[i]);

	return (0);
}

void tanishi_sort(int a[])
{
	int i, j;

	for (i = 0; i < 4; i++){
		for (j = i + 1; j < 5; j++){
			if (a[i] < a[j]){
				tanishi_swap(&a[i], &a[j]);
			}
		}
	}
}

void tanishi_swap(int *a, int *b)
{
	*a += *b;
	*b = *a - *b;
	*a -= *b;
}

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

void main_()
{
    int H, W;
    cin >> H >> W;
    vector<string> Css;
    copy_n(istream_iterator<string>(cin), H, back_inserter(Css));

    for (auto&& cs : Css) {
        cout << cs << "\n"
             << cs << "\n";
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
import heapq

H, W = list(map(int, input().split()))
Sl = []
for i in range(H):
	Sl.append(list(input()))

L = [["N" for j in range(W)] for i in range(H)]
c = 0

for i in range(H):
	for j in range(W):
		if L[i][j] == "N":
			L[i][j] = c
			Q = []
			heapq.heappush(Q, (i, j))
			while Q:
				x, y = heapq.heappop(Q)
				if x - 1 >= 0:
					if Sl[x][y] != Sl[x - 1][y] and L[x - 1][y] == "N":
						L[x - 1][y] = c
						heapq.heappush(Q, (x - 1, y))
				if x + 1 <= H - 1:
					if Sl[x][y] != Sl[x + 1][y] and L[x + 1][y] == "N":
						L[x + 1][y] = c
						heapq.heappush(Q, (x + 1, y))
				if y - 1 >= 0:
					if Sl[x][y] != Sl[x][y - 1] and L[x][y - 1] == "N":
						L[x][y - 1] = c
						heapq.heappush(Q, (x, y - 1))
				if y + 1 <= W - 1:
					if Sl[x][y] != Sl[x][y + 1] and L[x][y + 1] == "N":
						L[x][y + 1] = c
						heapq.heappush(Q, (x, y + 1))
			c += 1

xl = []
for i in range(c):
	xl.append([0, 0])

for i in range(H):
	for j in range(W):
		if Sl[i][j] == "#":
			xl[L[i][j]][0] += 1
		else:
			xl[L[i][j]][1] += 1

ans = 0
for i in range(c):
	ans += xl[i][0] * xl[i][1]

print(ans)

Measured memory_bytes: 24352
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int c[5010][5010];

ll comb(int N, int K) {
	if (N < 0 || K < 0 || K > N) return 0;
	return c[N][K];
}

ll H(int N, int K) {
	if (K == 0) return !N;
	return comb(N + K - 1, K - 1);
}

int main() {
	rep(i, 5010) {
		c[i][0] = 1;
		for (int j = 1; j <= i; j++)
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
	}
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	if (B % 2) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	for (int a = 0; a <= A; a++) {
		int d = A - a;
		for (int c = 0; c * 3 + d <= C; c++) {
			int b = B / 2;
			ll unko = comb(a+b+c+d, a) * comb(b+c+d, b) % MOD * comb(c+d, c) % MOD;
			int k = C - (c * 3 + d);
			unko = unko * H(k, b) % MOD;
			ans = (ans + unko) % MOD;
		}
	}
	cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
const int mod=1000000007;

long long powmod(long long a,long long b){
    long long c=1;
    while(b){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll nCr(ll n,ll r){
	ll x=1,y=1;
	rep(i,r){
		x=x*(n-i)%mod;
		y=y*(i+1)%mod;
	}
	return x*powmod(y,mod-2)%mod;
}

int main()
{
	ll n,a,b,ans=0;
	cin >> n >> a >> b;
	ans=powmod(2,n)-1-nCr(n,a)-nCr(n,b);
	cout << (ans%mod+mod)%mod << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void) {
  
  int N,A[100];
  double B[100];
  
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  
  double a = 0.0;
  for (int i = 0; i < N; i++) {
    B[i] = 1 / (double)A[i];
    a += B[i];
  }
  
  double b = 1 / a;
  
  printf("%6f", b);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long double a,b;
int main(){
	#ifndef DavidLaptop
		#ifdef FILIN
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b;
	a*=b;
	cout<<fixed<<setprecision(0)<<floor(a)<<endl;
	return 0;
}



Measured memory_bytes: 3808
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var n = toInt(input[0]);
	var ans = 0;

	function prime(n) {
	//n未満の素数を配列で返す。
		var ps, x, flg, j;
		ps = [2, 3];
		for(x = 5; x < n; x += 2) {
			flg = 0;
			for(j = 0; ps[j] * ps[j] <= x; j++) {
				if(x % ps[j] == 0) {
					flg = 1;
					break;
				}
			}
			if(flg == 0) {
				ps.push(x);
			}
		}
		return ps;
	}
	var primes = prime(100); //length 25
	var pows = []; //sisuu
	var a,b,c,d,p,q,r,s;
	var to = {};
	to[75] = 0;
	to[25] = 0;
	to[15] = 0;
	to[5] = 0;
	to[3] = 0;
	for(var i = 0; i < 25; i++){
		p = primes[i];
		a = 0;
		for(var j = 1; j <= n; j++){
			q = j
			while(q%p === 0){
				a++;
				q /= p;
			}
		}
		a++;

		pows[i] = a;

		if(a>74) to[75]++;
		if(a>24) to[25]++;
		if(a>14) to[15]++;
		if(a>4) to[5]++;
		if(a>2) to[3]++;
	}
	//console.log(pows);

	ans = to[75] + to[25]*(to[3] - 1) + to[15]*(to[5] - 1) + to[5]*(to[5] - 1)*(to[3] - 2)/2;




	console.log(ans);
}

Measured memory_bytes: 7500
//==========================================
// 🅐🅤🅣🅗🅞🅡: 🅐🅦🅚
//==========================================

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

void solve(){
	ll a, b, c, k;
	cin >> a>>b>>c>>k;

	if(k<=a){
		cout << k <<"\n";
	}
	else if(k<=a+b){
		cout << a<<"\n";
	}
	else cout << a-(k-(a+b))<<"\n";

}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	solve();
	
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define ff first
#define ss second
#define ll long long
#define ld long double
#define ull unsigned long long
#define bp(x) __builtin_popcount(x)
#define pr(x) for(auto it: x) cout<<it<<" "; cout<<endl;
#define endl "\n"
typedef vector<int> vi;
typedef vector< pair<int,int> > vii;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector< pair<ll,ll> > vll;

void nikal_pehli_fursat_mai(){
  int n;
  cin>>n;
  vl v(n);
  fi(0,n) cin>>v[i];
  ll ans=0;
  fi(1,n){
    if(v[i-1]>v[i]){
      ans+=v[i-1]-v[i];
      v[i]=v[i-1];
    }
  }
  cout<<ans<<endl;
}

int main(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc=1; 
  //cin>>tc;
  while(tc--){
    nikal_pehli_fursat_mai();
  }
}


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

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a[i];
    vector<int> b(n);
    rep(i,n) cin >> b[i];
    ll ans = 0;
    rep(i,n){
        if(a[i] >= b[i]){
            ans += b[i];
        } else {
            if(a[i+1] >= (b[i]-a[i])){
                ans += b[i];
            } else {
                ans += a[i] + a[i+1];
            }
            a[i+1] -= (b[i] - a[i]);
            if(a[i+1]<0) a[i+1] = 0;
        }
    }
    cout << ans << endl;

 
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
using namespace std;
signed main()
{
  int s,a,b,c,d;
  cin>>s;
  a=s/3600;
  d=s-3600*a;
  b=d/60;
  c=d-b*60;
  cout<<a<<":"<<b<<":"<<c<<"\n";
  return(0);
}



Measured memory_bytes: 3104
#include <cstdlib>
#include <iostream>
#include <string>
#include <utility>
#include <unordered_map>

using namespace std;

namespace {

typedef int (*Op)(int, int);

class Stack {
 public:
  Stack() : size_(100), ptr_(0) {
    s_ = new int[size_];
  }

  ~Stack() {
    delete[] s_;
  }

  bool Empty() const {
    return ptr_ == 0;
  }

  bool IsFull() const {
    return ptr_ >= size_;
  }

  pair<int, bool> Pop() {
    if (Empty()) {
      return make_pair(0, false);
    }
    const int r = s_[--ptr_];
    return make_pair(r, true);
  }

  bool Push(int n) {
    if (IsFull()) {
      return false;
    }

    s_[ptr_] = n;
    ptr_++;
    return true;
  }

 private:
  int size_;
  int ptr_;
  int* s_;
};

void Parse(const unordered_map<char, Op>& m,
           Stack* stack, const string& s) {
  if (s.size() == 0) {
    return;
  }
  const auto it = m.find(s[0]);
  if (it == m.end()) {
    stack->Push(atoi(s.c_str()));
    return;
  }

  const pair<int, bool> a = stack->Pop();
  if (!a.second) {
    return;
  }
  const pair<int, bool> b = stack->Pop();
  if (!b.second) {
    return;
  }
  stack->Push(it->second(b.first, a.first));
}
} // namespace

int main() {
  string line;
  getline(cin, line);
  Stack stack;

  const unordered_map<char, Op> ops = {
    {'+', [](int a, int b) { return a + b; }},
    {'-', [](int a, int b) { return a - b; }},
    {'*', [](int a, int b) { return a * b; }},
  };

  size_t begin = 0;
  for (;;) {
    const size_t end = line.find_first_of(" ", begin);
    if (end == string::npos) {
      Parse(ops, &stack, line.substr(begin));
      break;
    }
    Parse(ops, &stack, line.substr(begin, end-begin));
    begin = end + 1;
  }
  cout << stack.Pop().first << endl;
  return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
typedef long long ll;

int main()
{
	int n; cin >> n;
	int a[10000];
	REP(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	cout << a[n - 1] - a[0] << endl;
}

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

using namespace std;

int main(){
    string s;
    cin >> s;
    size_t size = s.length();  //文字列の長さ
    int count = 0;  //ハグする回数
    for(int i = 0; i < size / 2; i++){
        if(s.at(i) != s.at(size - i - 1)) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N=1000000007;
//ll power(ll a,ll b,ll mod)
//{
//    ll result=1;
//    while(b>0)
//    {
//        if(b%2==1)
//            result=(result*a)%mod;
//        a=(a*a)%mod;
//        b=b/2;
//    }
//    return result;
//}
//ll d,x,y;
//void extendedEuclid(ll a,ll b)
//{
//    if(b==0)
//    {
//        d=a; x=1; y=0;
//    }
//    else
//    {
//        extendedEuclid(b,a%b);
//        ll temp=x; x=y; y=temp-(a/b)*y;
//    }
//}
//ll modInverse(ll a,ll m)
//{
//    extendedEuclid(a,m);
//    return (x%m+m)%m;
//}
//ll lcm(ll a,ll b)
//{
//    if(a==0||b==0)
//        return 0;
//    else
//        return (a*b)/(__gcd(a,b));
//}
//void sieve(ll n)
//{
//    bool isPrime[n+1];
//    isPrime[0]=false; isPrime[1]=false;
//    for(ll i=2;i<=n;i++)
//        isPrime[i]=true;
//    for(ll i=2;i*i<=n;i++)
//    {
//        if(isPrime[i]==true)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//                isPrime[i]=false;
//        }
//    }
//}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j,k;
    string s;
    cin>>k>>s;
    if(s.length()<=k)
        cout<<s;
    else
    {
        for(i=0;i<k;i++)
            cout<<s[i];
        cout<<"...";
    }
}


Measured memory_bytes: 3652
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string s;
    cin >> s;
    int n=s.size();
    string ans=s;
    if(s[n-1]=='s'){
        ans+="es";
    }else{
        ans+="s";
    }
    cout<<ans<<endl;
    return 0;
}

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


int main() {
	int A, B, K;
	
	vector<int> ans;

	cin >> A >> B >> K;
	int k = K - 1;
	int C = min(A, B);
	for (int i = 1; i <= C; i++)
	{
		if (A % i == 0 && B % i == 0)
		{
			ans.push_back(i);
		}
	}
	reverse(ans.begin(), ans.end());

	cout << ans.at(k) << endl;
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {

  int n = in;
  int x = in;
  if (x == 1) {
    cout << ("No") << endl;
    return;
  }
  if (2 * n - 1 == x) {
    cout << ("No") << endl;
    return;
  }

  int r = x - n;
  cout << ("Yes") << endl;
  if (r < 0) {
    rrep(i, 2 * n + r, 2 * n) {
      cout << (i) << endl;
    }
    rep(i, 1, 2 * n + r) {
      cout << (i) << endl;
    }
  } else {
    rep(i, r + 1, 2 * n) {
      cout << (i) << endl;
    }
    rrep(i, 1, r + 1) {
      cout << (i) << endl;
    }
  }
  err(r);
}


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

int main() {
  for(int n, k, s; cin >> n >> k >> s && (n|k|s);) {
    int res = 0;
    for(int b = 0; b < (1<<n); ++b) {
      int sum = 0, num = 0;
      for(int i = 0; i < n; ++i) {
        if(b >> i & 1) {
          sum += i+1;
          num += 1;
        }
      }
      res += (sum == s && num == k);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    X = int(input())

    return X

def main(X: int) -> None:
    """
    メイン処理.

    Args:\n
        X (int): 最高レーティング（400 <= X <= 1999）
    """
    # 求解処理
    ans = 10 - (X // 200)

    # 結果出力
    print(ans)

if __name__ == "__main__":
    # 標準入力を取得
    X = get_input()

    # メイン処理
    main(X)


Measured memory_bytes: 9160
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define repp(i, a, b) for (int i = a; i < b; ++i)
#define vint vector<int>

int main() {
	long N, K;
	cin >> N >> K;
	vint A(N);
	rep(i, N){
		cin >> A[i];
	}

	long current = 1;
	long cnt = 0;

	vector<long> time(N, -1);

	bool found = false;

	while(true){
		if(cnt == K){
			cout << current << endl;
			break;
		}

		current = A[current - 1];
		++cnt;

		if(!found){
			if(time[current - 1] == -1){
				time[current - 1] = cnt;
			}else{
				long loop = cnt - time[current - 1];
				K = (K - cnt) % loop;
				cnt = 0;
				found = true;
			}
		}
	}
}

Measured memory_bytes: 5636