akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A,A+3);
  cout << (abs(A[1]-A[0]) + abs(A[2]-A[1])) << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  map<int,int>a;
  set<int>s;
  for(int i=0;i<n;i++)
  {
    int t;
    cin>>t;
    if(s.count(t)==0)
    {
      s.insert(t);
      a.insert(make_pair(t,0));
    }
    a[t]++;
  }
  long long c=0,b=0;
  for(auto x:s)
  {
    if(a[x]>=2 && x>b)b=x;
  }
  if(b==0)
  {
    cout<<0<<endl;
    return 0;
  }
  a[b]-=2;
  for(auto x:s)
  {
    if(a[x]>=2 && x>c)c=x;
  }
  long long area=b*c;
  cout<<area<<endl;
  return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}/*swap 交換*/
ll max2(ll a,ll b){return a>=b?a:b;}/*2つのうち大きい数を返す*/ 
ll min2(ll a,ll b){return a>=b?b:a;}/*2つのうち小さい数を返す*/ 
ll ABS(ll a){return a>=0?a:(-a);}/*絶対値*/ 
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    ll n,m,ans=0;
    scanf("%lld%lld",&n,&m);
    ll x[m],y[m],box[n],ball[n];
    rep(i,0,n) box[i]=1;
    rep(i,0,n) ball[i]=i==0?1:0;
    rep(i,0,m){
        scanf("%lld%lld",&x[i],&y[i]);
    }
    rep(i,0,m){
        box[x[i]-1]--;
        box[y[i]-1]++;
        if(ball[x[i]-1]==1){
            if(box[x[i]-1]==0){
                ball[x[i]-1]=0;
            }
            ball[y[i]-1]=1;
        }
    }
    rep(i,0,n){
        if(ball[i]==1) ans++;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N, M;cin >> N >> M;
	ll ans = 0;
	ll max = 0;
	ll x;
	vector <pair<long long, bool>>pairs(1e6+7);
	string S;
	for (int i = 0;i < M;i++) pairs[i] = make_pair(0,false);
	for (int i = 0;i <M;i++) {
		cin >> x >> S;
		if (S == "AC") {
			if (pairs[x].second == false) {
				pairs[x].second =true;
				ans++;
				max += pairs[x].first;
			} 
		}
		if (S == "WA") {
			if (pairs[x].second == false) {
				pairs[x].first++;
			}
		}
	}
	cout<< ans <<" "<< max <<endl;
}

Measured memory_bytes: 15872
#include <stdio.h>

using namespace std;

int main(){
	int a,b,c,count = 0;
	scanf("%d %d %d",&a,&b,&c);
	for(int i = a; i <= b; i++){
		if(c%i == 0) count++;
	}
	printf("%d\n",count);
}


Measured memory_bytes: 2760
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,X,T; cin >> N >> X >> T;

    res = (N+X-1)/X*T;
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

Measured memory_bytes: 3628
A, B, C, D = map(int,input().split())

def calc(n):
    return (B // n) - ((A - 1) // n)

def lcm(c, d):
    a, b = c, d
    if c < d:
        a, b = d, c
    while b != 0:
        a, b = b, a % b

    return c * d // a

E = lcm(C, D)
print(calc(1) -calc(C)-calc(D)+calc(E) )

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<deque>
#include<iomanip>
#include <math.h>

using namespace std;
typedef long long ll;

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

    vector<ll> A(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    vector<ll> sort_A = A;
    sort(sort_A.begin(), sort_A.end(), greater<ll>());

    ll max_A = sort_A[0];

    for(int i = 0; i < N; i++)
    {
        if(max_A != A[i])
        {
            cout << max_A << endl;
        }
        else
        {
            cout << sort_A[1] << endl;
        }
        

        // vector<ll> _A = A;
        // _A.erase(_A.begin() + i);
        // cout << *max_element(_A.begin(), _A.end()) << endl;
    }
}

Measured memory_bytes: 4736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication28 {
    class Program {
        static void Main(string[] args) {

            string[] str = Console.ReadLine().Split(' ');
            string[] str2 = Method(str);
            Console.WriteLine(str2.Length);//数える
        }

        private static string[]  Method(string[] str) {

            return str.Distinct().ToArray(); //配列の値の重複を削除
        }
    }
}


Measured memory_bytes: 13280
fun main(args: Array<String>) {
    var str = readLine()
    if(str != null) {
        val ary = str.split(Regex("\\s+"))
        val a = ary[0].toInt()
        val b = ary[1].toInt()
        val c = ary[2].toInt()
        val ans = if (a<b && b<c) "Yes"
        else "No"
        println(ans)
    }
 }


Measured memory_bytes: 29564
#include<iostream>

using namespace std;

int main(){
	double a, b;
	cin >> a >> b;
	if(a > b)
		cout << "GREATER" << endl;
	if(a < b)
		cout << "LESS" << endl;
	if(a == b)
		cout << "EQUAL" << endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, h: [i64; n]);

    let mut count = 0;
    let mut max = -1;
    for v in h {
        if max <= v {
            max = v;
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2156
use proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        _c: i64,
        k: i64,
    }

    let answer = if k <= a {
        k
    } else if k <= a + b {
        a
    } else {
        2 * a + b - k // a - (k - (a + b)) = a - k + a + b
    };

    println!("{}", answer);
}


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

// author: Seong Yong-ju ( @sei40kr )

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); --i)

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

#define ALL(a) (a).begin(), (a).end()

#define P pair<int, int>

using namespace std;

const double pi = 4 * atan((double) 1.0);

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

  P start, dest;
  int n;
  cin >> start.first >> start.second >> dest.first >> dest.second >> n;
  bool invert = false;
  if (dest.first < start.first) {
    swap(start, dest);
  }
  if (dest.second < start.second) {
    invert = true;
    start.second *= -1;
    dest.second *= -1;
  }
  set<pair<int, int>> ps;
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    if (invert) {
      y *= -1;
    }
    if (start.first <= x && x <= dest.first && start.second <= y && y <= dest.second) {
      ps.emplace(x, y);
    }
  }

  P vec = make_pair(dest.first - start.first, dest.second - start.second);

  size_t l = ps.size();
  int dp[l];
  fill(dp, dp + l, INT_MAX);
  for_each(ps.begin(), ps.end(), [l, &dp](const auto &p) {
    *lower_bound(dp, dp + l, p.second) = p.second;
  });
  long k = lower_bound(dp, dp + l, INT_MAX) - dp;

  double ans = 0;
  if (min(vec.first, vec.second) < k) {
    --k;
    ans += 10 * M_PI - 20;
  }
  ans += (long) 100 * (vec.first + vec.second) + (5 * M_PI - 20) * k;

  cout << fixed << setprecision(19) << ans << endl;
}


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

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n;
  scanf("%d", &n);
  int ld = 1;
  int rd = 33000;
  while(rd - ld > 1){
    int md = (rd + ld) / 2;
    if(md * md > n)rd = md;
    else ld = md;
  }
  cout << ld * ld << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    
    if K > 41:
        K = 41
    
    for k in range(K):
        B = [0 for i in range(N)]
        for i in range(N):
            low = max(0,i-A[i])
            high = min(N-1,i+A[i])
            B[low] += 1
            if high+1 < N:
                B[high+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        A = B
    
    print(*A)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 168992
#include<iostream>
using namespace std;
int main(){
  int n,m,p,o,i,j,k,b,sum;
  int card;
  cin >> n >> m >> p;
  while(n!=0){
    sum=0;
    for(i=0;i<n;i++){
      if(m-1==i){
	cin >> card;
	sum+=card;
      }else{
	cin >> b;
	sum+=b;
      }
    }
    if(card==0) cout << 0 << endl;
    else cout << ((100-p)*sum/card) <<endl;
    cin >> n >> m >> p;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, k;
    cin >> n >> k;
    cout << (n - k + 1) << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

typedef set<int> si;
typedef set<ii> sii;
typedef set<ld> sd;
typedef set<ll> sl;

typedef map<int, int> mii;
typedef priority_queue<int> pqi;
typedef queue<int> qi;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second

mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int ans = 0;
void dfs(int u, int p, vector<vector<int>> &g, vector<pair<int, int>> &depth) {
    for (auto v : g[u]) {
        if (v == p) continue;
        dfs(v, u, g, depth);
        if (depth[v].f + 1 >= depth[u].f) depth[u] = {depth[v].f + 1, depth[u].f};
        else if (depth[v].f + 1 > depth[u].s) depth[u].s = depth[v].f + 1;
    }
    ans = max(ans, depth[u].f + depth[u].s);
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0, u, v; i < n - 1; i++) {
        cin >> u >> v, u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
 
    vector<pair<int, int>> depth(n);
    dfs(0, -1, g, depth);
    
    ans++;
    if (ans % 3 == 2) cout << "Second" << endl;
    else cout << "First" << endl;
}

/*
USE LONG LONG!!!!

1 2 0 1 2 0 1 2
1 2 3 4 5 6 7 8
1 2 1 1 2 1 1 2

:pray: :fishy15:
:pray: :summitosity:
:pray: :prodakcin:

          .=     ,        =.
  _  _   /'/    )\,/,/(_   \ \
   `//-.|  (  ,\\)\//\)\/_  ) |
   //___\   `\\\/\\/\/\\///'  /
,-"~`-._ `"--'_   `"""`  _ \`'"~-,_
\       `-.  '_`.      .'_` \ ,-"~`/
 `.__.-'`/   (-\        /-) |-.__,'
   ||   |     \O)  /^\ (O/  | .        <-  BESSIE THE COW
   `\\  |         /   `\    /
     \\  \       /      `\ /
      `\\ `-.  /' .---.--.\
        `\\/`~(, '()      ('
         /(O) \\   _,.-.,_)    
        //  \\ `\'`      /
       / |  ||   `""""~"`
     /'  |__||
           `o
*/

Measured memory_bytes: 27776
#include<bits/stdc++.h>
using namespace std;
#define llt long long int
#define pb push_back
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int a,b,c;
	llt dp[3][2];
	cin>>a>>b>>c;
	n--;
	dp[0][0]=a;dp[1][0]=b;dp[2][0]=c;
	while(n--){
		cin>>a>>b>>c;
		dp[0][1]=max(dp[1][0]+a,dp[2][0]+a);
		dp[1][1]=max(dp[0][0]+b,dp[2][0]+b);
		dp[2][1]=max(dp[1][0]+c,dp[0][0]+c);
		dp[0][0]=dp[0][1];
		dp[1][0]=dp[1][1];
		dp[2][0]=dp[2][1];
	}
	cout<<max(dp[0][0],max(dp[1][0],dp[2][0]));
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 100000;
int N,K;

int t[MAX_N+1];
long long d[MAX_N+1];

std::vector<std::pair<long long, int>> sushi;

bool compare(std::pair<long long, int> a, std::pair<long long, int> b) {
    return a.first > b.first;
}

main(int argc, char **argv) {
    std::cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        std::cin >> t[i] >> d[i];
    }

    for (int i = 1; i <= N; i++) {
        sushi.push_back(std::pair<long long, int>(d[i], t[i]));
    }

    std::sort(sushi.begin(), sushi.end(), compare);

    long long tmp = 0;
    //long long int kind_num[MAX_N] = {};
    int kind_flag[MAX_N+1] = {};
    long long x = 0;
    std::vector<int> not_need_for_kind;
    for (int i = 0; i < K; i++) {
        tmp += sushi[i].first;
        //kind_num[sushi[i].second]++;
        if (kind_flag[sushi[i].second] == 0) {
            kind_flag[sushi[i].second] = 1;
            x++;
        } else {
            not_need_for_kind.push_back(i);
        }
    }
    tmp += x * x;

    long long ret = tmp;

    for (int i = K; i < N; i++) {
        if (not_need_for_kind.size() == 0) {
            break;
        }
        if (kind_flag[sushi[i].second] == 0) {
            const int idx = not_need_for_kind[not_need_for_kind.size()-1];
            tmp -= sushi[idx].first;
            tmp -= x * x;

            x++;
            tmp += sushi[i].first;
            tmp += x * x;
            kind_flag[sushi[i].second] = 1;
            not_need_for_kind.pop_back();

            ret = std::max(ret, tmp);
        }
    }

    std::cout << ret << std::endl;
}


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

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

Measured memory_bytes: 3616
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] answer = new int[q];
        int[] point = new int[n];

        for(int i = 0;i < q;i++){
            answer[i] = sc.nextInt();
            point[answer[i]-1]++;
        }
        
        for(int i = 0;i < n;i++){
            if(k-q+point[i] > 0){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 80600
n = int(input())
elements = list(map(int, input().split()))

newList = [0]
prev = elements[0]

for i in range(1,len(elements)):
  if prev<elements[i]:
    newList.append(0)
  else:
    newList.append(1)
  prev = elements[i]
count = 0

maxCount = 0
prev = 1
for i in range(1, len(newList)):
  if newList[i] == 0:
    count = 0
  elif newList[i] == 1:
      if prev == 1:
          count += 1
  maxCount = max(maxCount, count)
print(maxCount)

Measured memory_bytes: 14228
s=input()
c=0
if(s[0]=='R' and s[1]=='R' and s[2]=='R'):
  c=3
elif((s[0]=='R' and s[1]=='R') or (s[1]=='R' and s[2]=='R')):
  c=2
elif (s[0]=='R' and s[2]=='R'):
  c=1
elif(s[0]=='R' or s[1]=='R' or s[2]=='R'):
  c=1
print(c)


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

int main() {
    int x;
    cin >> x;
    if (x == 0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3544
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
A = sorted(A)

# 約数列挙
def divisor(n):
  result = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      result.append(i)
      if i != n // i:
        result.append(n//i)
  return result

# A(intのlist)のうちdで割り切れるものがlen(A)-1個以上あればTrue
def check(A, d):
  count = 0
  for a in A:
    if a % d == 0:
      continue
    count += 1
    if count > 1:
      return False
  return True

for i in sorted(list(set(divisor(A[0])+divisor(A[1]))))[::-1]:
  if check(A, i):
    print(i)
    exit()

Measured memory_bytes: 14400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
using namespace std;
using LLI = long long int;


int main(int argc, char *argv[])
{
    int N;
    cin >> N;

    vector<int> h(N+2, -1);
    for (int i=0; i<N; i++) {
        cin >> h[i+1];
    }

    int total = 0;
    int countInStep = 0;

    do {
        countInStep = 0;
        for (int i=1; i<N+2; i++) {
            if (h[i] > 0 && h[i-1] <= 0) {
                countInStep++;
            }
        }
        for (int i=1; i<N+1; i++) {
            h[i]--;
        }
        total += countInStep;
    } while (countInStep > 0);
    
    cout << total;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main(){
string s;
  ll n;
  cin>>s>>n;
  string ans="";
  for(ll i=0;i<s.size();i++){
  if(i%n==0)
    ans+=s[i];
  }
  cout<<ans;
return 0;
}

Measured memory_bytes: 256
r, c = map(int, input().split())

A = []
for i in range(r):
    A.append([int(x) for x in input().split()])

b = []
for j in range(c):
    b.append(int(input()))

for i in range(r):
    inner = 0
    for j in range(c):
        inner += A[i][j] * b[j]
    print(inner)


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

int main(){
	int n,prev1=-1,cnt=0,prev2=-1;
	cin >> n;
	vector<int> v(n);
	for (int i=0; i<n; ++i){
		cin >> v[i];
	}
	for (int i=1; i<n-1; ++i){
		int a=min(v[i],min(v[i-1],v[i+1])),b=max(v[i],max(v[i-1],v[i+1]));
		if (v[i] != a and v[i] != b) ++cnt;
	}
	cout << cnt;
}

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

#define ll long long
using namespace std;
const int maxn = 1e5 + 7;
ll s[maxn];
priority_queue<ll> que;

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &s[i]);
        que.push(-s[i]);
    }
    ll ans = 1, tmp = -1;
    while (que.size() >= 2) {
        ll a = -que.top();
        que.pop();
        ll b = -que.top();
        que.pop();
        if (a * 2 >= b) {
            ans++;
        } else {
            ans = 1;
        }
        tmp = a + b;
        que.push(-tmp);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
typedef pair < ll , pair < ll , ll > > cm;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)
#define clean cout.flush()

const ll mod = (ll)1e9+7;
const ll maxn = (ll)2e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};


void solve(){
	vector < ll > v;
	ll n;
	cin >> n;
	ll a;
	f1(n) cin >> a, v.pb(a);
	priority_queue < ll > p;
	sort(v.begin(), v.end());
	p.push(v.back());
	v.pop_back();
	ll ans = 0;
	while(v.size() > 0){
		ll k = v.back();
		p.push(k);
		p.push(k);
		v.pop_back();
	}
	for(ll i = 1; i < n; i++){
		ans += p.top();
		p.pop();
	}
	cout << ans;
	return;
}


int main(int argc, char *argv[]) {
   
   ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    //	printf("Case %lld: \n",++CT);
		solve();
	}
    
    return 0;
}

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

int main() {
    int cnt=0;
    string S,T;
    cin >> S >> T;
    for(int i=0;i<S.size();i++){
        if(S.at(i)!=T.at(i)){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3916
N,M = map(int,input().split())
l_input = []
for i in range(M):
    l_input.append(list(map(int,input().split())))
l_sorted = sorted(l_input,key=lambda x: x[1])
nids = dict()
cities = dict()
l_out = []
for s in l_sorted:
    ni = nids.get(s[0], 0)
    ni += 1
    cities[s[1]] = ni
    nids[s[0]] = ni

for c in l_input:
    print('{0:06}{1:06}'.format(c[0], cities[c[1]]))


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll H, N, A[1010], B[1010];
ll dp[1010][10101];
ll i, j, k;
int main(){
    scanf("%lld%lld", &H, &N);
    fornum(i,0,N){
        scanf("%lld%lld", &A[i], &B[i]);
    }
    
    fornum(i,0,H+2){
        dp[0][i] = 1e18;
    }
    dp[0][0] = 0;
    fornum(i,0,N){
        fornum(j,0,H+2){
            dp[i + 1][j] = dp[i][j];
        }
        fornum(j,0,H){
            dp[i + 1][min(j + A[i], H)] = min(dp[i + 1][min(j + A[i], H)], min(dp[i][j] + B[i], dp[i + 1][j] + B[i]));
        }
    }
    printf("%lld", dp[N][H]);
    return 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int l;
	cin>>l;

	double x=double(l)/3;
	cout<<setprecision(12)<<x*x*x<<endl;

	return 0;
}


Measured memory_bytes: 256
// Charan Sriramula
 
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
 
const ll logx=30;
const ll N=1e5+5;
const ll INF=1e18+5;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;
 
#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)
 
inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
 
#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

ll n,m,p,dis[N],neg[N];
vector<pair<ll,ll> > g[N];
vector<pair<ll,pair<ll,ll> > > vec;

void BellmanFord()
{
  for(ll i=2;i<=n;i++){dis[i]=-INF;}
  for(ll i=1;i<=n;i++)
  {
    for(auto j:vec)
    {
      ll u=j.f,v=j.s.f,wei=j.s.s;
      if(dis[u]==-INF){continue;}
      if(dis[v]<dis[u]+wei){dis[v]=dis[u]+wei;}
    }
  }
  for(auto j:vec)
  {
    ll u=j.f,v=j.s.f,wei=j.s.s;
    if(dis[u]==-INF){continue;}
    if(dis[v]<dis[u]+wei)
    {
      dis[v]=dis[u]+wei;
      neg[v]=1;
    }
  }
  for(ll i=1;i<=n;i++)
  {
    for(auto j:vec)
    {
      if(neg[j.f]){neg[j.s.f]=1;}
    }
  }
  if(neg[n]){cout<<-1<<endl;exit(0);}
  //for(ll i=1;i<=n;i++){trace2(i,dis[i]);}
  cout<<max(0LL,dis[n])<<endl;
}

int main()
{
  cin>>n>>m>>p;
  while(m--)
  {
    ll u,v,w;
    cin>>u>>v>>w;
    w-=p;
    g[u].pb(mp(v,w));
    vec.pb(mp(u,mp(v,w)));
  }
  BellmanFord();
}

Measured memory_bytes: 3072
import java.io.*;
import java.util.*;

 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      String s=sc.next();
      String t=sc.next();
      char c[]=s.toCharArray();
      char d[]=t.toCharArray();
      boolean flag=true;
      int cnt=0;
      int k=0;

      for(int i=0;i<26;i++){
          alphabet.add(new ArrayList<Integer>());
      }

      for(int i=0;i<s.length();i++){
          int p=(int)(c[i]-'a');
          ArrayList<Integer> alp=alphabet.get(p);
          alp.add(i);
      }

      for(int i=0;i<t.length();){
          int j=0;
          k=-1;
          cnt++;
          while(i+j<t.length()){
              int p=(int)(d[i+j]-'a');
              k=binarysearch(p, k+1);

              if(k<0){
                  break;
              }
              j++;
          }

          if(j==0){
              flag=false;
              break;
          }
          i+=j;
      }

      if(flag){
          out.println((long)s.length()*(long)(cnt-1)+(long)k+1L);
      }else{
          out.println(-1);
      }
      out.close();
   }

   public static ArrayList<ArrayList<Integer>> alphabet=new ArrayList<>();

   public static int binarysearch(int p,int key)
   {
       int ng=-1;
       ArrayList<Integer> alp=alphabet.get(p);
       int ok=(int)alp.size();

       while((int)Math.abs(ok-ng)>1){
           int mid=(ok+ng)/2;

           if(alp.get(mid)<key){
               ng=mid;
           }else{
               ok=mid;
           }
       }
       if(ok<alp.size()){
           return alp.get(ok);
       }
       return -1;
   }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(ll i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(ll i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(ll i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(ll i = a; i >= b; i-=x)
#define tc ll tt; cin >> tt; for(ll cs = 1; cs <= tt; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

int main() {
	IOS
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	while(b<=a) {
		b*=2;
		k--;
	}
	while(c<=b) {
		c*=2;
		k--;
	}
	cout<<(k>=0?"Yes\n":"No\n");
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstring>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)

double X[512];
double Y[512];
double Z[512];
bool see[512];

double len(double x, double y, double z) {
  return sqrt(x * x + y * y + z * z);
}

int main() {
  int N;
  while( 1 ) {
    memset(see, 0, sizeof(see));
    scanf("%d", &N);
    if( N == 0 ) break;
    REP(i, N) {
      double x, y, z;
      scanf("%lf%lf%lf", &x, &y, &z);
      X[i] = x;
      Y[i] = y;
      Z[i] = z;
    }

    int M;
    scanf("%d", &M);
    REP(i, M) {
      double x, y, z, t;
      scanf("%lf%lf%lf%lf", &x, &y, &z, &t);

      REP(n, N) {
        double s = ( x * X[n] + y * Y[n] + z * Z[n]) / ( len(x,y,z) * len(X[n], Y[n], Z[n]) );
        if( acos(s) <= t )
          see[n] = true;
      }

    }

    int ans = 0;
    REP(i, N) if( see[i] ) ans++;
    printf("%d\n", ans);
  }
  return 0;
}

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

int main() {
  int n, x;
  cin >> n >> x;
  
  int d = 0, l, i;
  for(i=0;d<=x && i<=n;i++) {
    cin >> l;
    d = d + l;
  }
  cout << i << endl;
}



Measured memory_bytes: 256
from collections import Counter
s = [s for s in input()]
cnt = Counter(s)
if "N" in cnt.keys() or "S" in cnt.keys():
    if "N" not in cnt.keys() or "S" not in cnt.keys():
        print("No")
        exit()
if "W" in cnt.keys() or "E" in cnt.keys():
    if "W" not in cnt.keys() or "E" not in cnt.keys():
        print("No")
        exit()
print("Yes")

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

int main(){
	int n,m;

	while(1){
		cin >> n >> m;
		if((n == 0)&&(m == 0)){
			break;
		}

		int A[n],B[m];
		int Asum = 0;
		int Bsum = 0;
		int check = 0;
		int Sum = 200;
		int Anum,Bnum;

		for (int i = 0; i <= n-1; i++){
			cin >> A[i];
			Asum += A[i];
		}
		for (int i = 0; i <= m-1; i++){
			cin >> B[i];
			Bsum += B[i];
		}

		for (int i = 0; i <= n-1; i++){
			for (int j = 0; j <= m-1; j++){
				if ((Asum - A[i] + B[j]) == (Bsum - B[j] + A[i])){
					//cout << A[i] << B[j] << endl;
					if (Sum >= (A[i] + B[j])){
						Anum = A[i];
						Bnum = B[j];
						Sum = A[i]+B[j];
					}
					check = 1;
				}
			}
		}
		if(check == 1){
			cout << Anum << " " << Bnum << endl;
		}
		if(check == 0){
			cout << -1 << endl;
		}

	}


}

Measured memory_bytes: 1160
n,k = map(int,input().split())
check = [int(i) for i in range(1,n + 1)]

num = []
for i in range(k):
  x = input()
  test = list(map(int, input().split()))
  for j in test:
    num.append(j)

num = set(check) ^ set(num)

print(len(num))


Measured memory_bytes: 9184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class _C
{
	void _()
	{
		//
		var N = _Ns()[0];
		var K = _Ns()[0];
		var X = _Ns()[0];
		var Y = _Ns()[0];

		var ans = N * X;

		if(N-K>=1)
			ans -= ((N-K)*( X-Y));

		Console.WriteLine(ans);
	}	

	static void Main(string[] args)
  {
    new _C()._();
  }

  #region

  string _S()
  {
    return Console.ReadLine();
  }

  string[] _Ss()
  {
    return Console.ReadLine().Split();
  }

  int[] _N(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

  int[] _Ns()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }
  #endregion
}


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

int main() {
  long long N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<long long> cnt(N);
  cnt.at(0) = 0;
  
  
  for (long long i = 1; i < N; i++) {
    if ((S.at(i-1) == 'A') && (S.at(i) == 'C')) {
      cnt.at(i) = cnt.at(i-1) + 1;
    }
    else {
      cnt.at(i) = cnt.at(i-1);
    }
  }
  
  for (long long i = 0;i < Q;i++) {
    long long l,r;
    cin >> l >> r;
    l--;
    r--;
    cout << cnt.at(r) - cnt.at(l) << endl;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); 
map<ll,int> m;
int main() {
	ios;
	int n,i,f=0;
	ll x;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x;
		m[x]++;
	}
	for(auto j:m)
	{
		if(j.second>1) {
			f=1;
			break;
		}
	}
	if(!f) cout<<"YES\n";
	else cout<<"NO\n";
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
using Graph=vector<vector<int>>;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  lint n;
  cin>>n;
  vector<lint> l;
  lint b=0;
  lint sum=0;
  rep(i,n){
    lint t;cin>>t;
    l.pb(t);
    if(b>t){
    sum+=b-t;
    }
    else {
      b=t;
    }
  }
  cout<<sum<<endl;



}

Measured memory_bytes: 5344
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;

LL n,ans;

int main(void){
	scanf("%lld",&n);
	ans=(1+n)-2ll;
	for(LL i=1;i*i<=n;i++){
		if(n%i==0)ans=min(ans,i+(n/i)-2ll);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
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[2][n];
		for (int i = 0; i < 2; i++)
			for (int j = 0; j < n; j++)
				a[i][j] = sc.nextInt();
		int ans = a[0][0];
		for (int k = 0; k < n; k++) {
			ans += a[1][k];
		}
		for (int k = 1; k < n; k++) {
			int t = 0;
			for (int l = 0; l < k; l++)
				t += a[0][l];
			for (int l = k - 1; l < n; l++)
				t += a[1][l];
			if (t > ans)
				ans = t;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

int main()
{
	cout << fixed << setprecision(6);
	unsigned long long s;
	cin >> s;

	vector<pair<unsigned, unsigned>> xys(3);
	
	const auto ninth_ten = 1000000000ULL;

	if (s <= ninth_ten) {
		xys[0] = make_pair(0, 0);
		xys[1] = make_pair(1, 0);
		xys[2] = make_pair(0, (unsigned)s);
	}
	else if (s == ninth_ten * ninth_ten) {
		xys[0] = make_pair(0, 0);
		xys[1] = make_pair(ninth_ten, 0);
		xys[2] = make_pair(0, ninth_ten);
	}else {
		auto w = 0ULL, h = 0ULL, modu = 0ULL;
		auto adder = ninth_ten / 4;
		bool adder_done = false;
		for (auto i = ninth_ten / 2;;) {
			if (i >= 1ULL && i <= ninth_ten &&
				s / i >= 1ULL && s / i <= ninth_ten) {
				if (i < ninth_ten) {
					h = i;
					w = s / i;
					modu = s % i;
				}
				else {
					h = s / i;
					w = i;
					modu = s % i;
				}
				if (modu == 0) {
					xys[0] = make_pair(0, 0);
					xys[1] = make_pair(w, 0);
					xys[2] = make_pair(0, h);
				}
				else {
					xys[0] = make_pair(modu, 0);
					xys[1] = make_pair(0, h);
					xys[2] = make_pair(w, h + 1);
				}
				break;
			}
			if (!adder_done) {
				if (s / i < 1ULL) i -= adder;
				if (s / i > ninth_ten) i += adder;
				adder = (adder + 1) / 2;
			}
			else {
				if (i < 100000) i += adder;
				if (i >= 100000) i -= adder;
			}
			if (i <= 0 || i >= ninth_ten) {
				adder = 1;
				adder_done = true;
			}
		}
	}
	for (int i = 0; i < 3; ++i) {
		cout << xys[i].first << " " << xys[i].second;
		if (i < 2)cout << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    long long int i,a,b,d,c=0;
    cin>>a>>b>>d;

    for(i=a;i<=b;i++,a++)
    {
        if(i%d==0)
        {
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        char[] s = S.toCharArray();
        char[] t = T.toCharArray();
        int ans = 2*N;
        lavel:
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N - (i); j++) {
                if (s[i + j] != t[j]) {
                    continue lavel;
                }
                if (j == N - i - 1) {
                    System.out.println((N+i));
                    return;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef double ld;
typedef pair<int,int> p2;
typedef pair<p2,int> p3;
typedef vector<ll> vi;
const ll Mod = 7 + 1e9;
const ll INF32 = 5 + 2e9;
const ll INF64 = 1 + 1e18;
const ll MAX = 5+ 3e2;

int N,c1,c2,c3;
ld dp[MAX][MAX][MAX],p[MAX];


int main()
{
    cin >> N;
    for(int i=1; i<=N; i++)
    {
        int x;
        cin >> x;
        x == 1 ? c1++ : x==2 ? c2++ : c3++;
    }
    for(int k=0 ; k<=N; k++)
        for(int j=0; j<=N; j++)
            for(int i= (j + k ? 0 : 1) ; i<=N; i++)
            {
                ld res = 0;
                if( i )
                    res += i*(1 + dp[i-1][j][k] );
                if( j )
                    res += j*( 1 + dp[i+1][j-1][k] );
                if( k )
                    res += k*( 1 + dp[i][j+1][k-1] );
                res/= (ld) N;
                if( N < i+j+k ) { dp[i][j][k] = res; continue; }
                ld q = (ld) (N - (i+j+k))/N;
                dp[i][j][k] = (res + q)/(1 - q);
            }
    cout << setprecision(10) << fixed << dp[c1][c2][c3];
    return 0;
}


Measured memory_bytes: 219392
n, m = [int(x) for x in input().split(' ')]

edges = [(input().split(' ')) for _ in range(m)]
ans = 0


def bfs(bridge):
    queue = ['1']
    visited = set()
    while queue:
        node = queue.pop()
        visited.add(node)
        next_nodes = [
            x[1] for x in edges if x[0]==node and x[1] not in visited and bridge!=x
        ] + [
            x[0] for x in edges if x[1]==node and x[0] not in visited and bridge!=x
        ]
        queue.extend(next_nodes)
        if len(visited) == n:
            return False
    return True


for edge in edges:
    if bfs(edge):
        ans += 1

print(ans)

Measured memory_bytes: 3064
a,b,k=map(int,input().split())
count1=0
count2=0
if a<=k:
  count1=0
  if b-(k-a)>0:
    count2=b-(k-a)
  else:
    count2=0
else:
  count1=a-k
  count2=b
print(str(count1)+' '+str(count2))



Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<ll, ll>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll n, m;
    cin >> n >> m;
    vector<P> a(n);
    rep(i, n) cin >> a[i].first >> a[i].second;
    ll ans = 0;
    sort(whole(a));
    rep(i, n) {
        if (a[i].second<=m) {
            m -= a[i].second;
            ans += a[i].first*a[i].second;
        }
        else {
            ans += a[i].first*m;
            m-=m;
        }
        if (m<=0) break;
    }
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll L, R;
    cin >> L >> R;
    ll ans = INF;
    for (ll x = L; ((x < R) && (x < (L + 2019))); x++){
        for (ll y = L + 1; ((y <= R) && (y < (L + 2019))); y++){
            if (x > y){continue;}
            ll tmp = x * y % 2019;
            if (tmp < ans){ans = tmp;}
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256