akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(string, s);

    for (size_t i = 0; i < s.size(); i += 2) {
        if (s.substr(i, 2) != "hi") {
            output("No");
            return 0;
        }
    }

    output("Yes");

    return 0;
}


Measured memory_bytes: 764
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner  sc=new Scanner(System.in);
        Integer[] N=new Integer[4];
        int sum=0,product=1;
        for(int i=0;i<4;i++){
            N[i]=sc.nextInt();
            sum+=N[i];
            product*=N[i];
        }
        if(sum==21&&product==252){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
   }
}

Measured memory_bytes: 21844
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef db T;
const db eps = 1e-8;
int sgn(T x){return (x>eps)-(x<-eps);}
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    void read(){scanf("%lf%lf",&x,&y);}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    P operator + (const P&b) const {return P(x+b.x,y+b.y);}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    P operator * (const T&k) const {return P(x*k,y*k);}
    T operator ^ (const P&b) const {return x*b.y-y*b.x;}
    bool operator < (const P&b) const {return sgn(y-b.y)?y<b.y:x<b.x;}
};
db abs(P a){return sqrt(a*a);}
typedef vector<P> polygon;
T diameter(polygon A) {
    int n=sz(A);if(n <= 1) return 0;
    int l=0,r=0;rep(i,1,n) (A[i]<A[l])&&(l=i),(A[r]<A[i])&&(r=i);
    db res=abs(A[l]-A[r]);int i=l,j=r;
    do (++(((A[(i+1)%n]-A[i])^(A[(j+1)%n]-A[j]))>=0?j:i))%=n,
        res=max(res,abs(A[i]-A[j]));
    while(i!=l||j!=r);
    return res;
}

int main(){
    int n;scanf("%d",&n);
    polygon A;
    rep(i,0,n){
        P p;p.read();
        A.pb(p);
    }
    printf("%.10f\n",diameter(A));
    return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> ds(n);
    for (int i = 0; i < n; i++) cin >>ds[i];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans += ds[i] * ds[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3524
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	int H, W;
	cin >> H >> W;

	const int MAX_N = 1010;

	bool a[MAX_N][MAX_N];
	int memo[MAX_N][MAX_N];

	int dx[4] = { 1,0,-1,0 };
	int dy[4] = { 0,1,0,-1 };
	string str;
	REP(i, H) {
		cin >> str;
		REP(j, W) {
			if (str[j] == '.') a[i][j] = 0;
			else a[i][j] = 1;
		}
	}

	queue<P> q;

	REP(i, H) {
		REP(j, W) {
			if (a[i][j] == 1) {
				q.push(make_pair(i, j));
				memo[i][j] = 0;
			}
		}
	}
	int ans = 0;
	while (q.size() > 0) {
		int y = q.front().first;
		int x = q.front().second;

		REP(i, 4) {
			if (x + dx[i] >= 0 && x + dx[i] < W && y + dy[i] >= 0 && y + dy[i] < H) {
				if (a[y + dy[i]][x + dx[i]] == 0) {
					a[y + dy[i]][x + dx[i]] = 1;
					q.push(make_pair(y + dy[i], x + dx[i]));
					memo[y + dy[i]][x + dx[i]] = memo[y][x] + 1;
				}
			}
		}
		q.pop();

	}
	REP(i, H) {
		REP(j, W) {
			ans = max(ans, memo[i][j]);
		}
	}
	ANS(ans);

	return 0;
}


Measured memory_bytes: 13328
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

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

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

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

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


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


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

signed main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];
    
    if (N == 1 || N == 2) {
        cout << 1 << endl;
        return 0;
    }
    
    int ans = 1000000000;
    rep(i, N) rep(j, N) {
        if (i == j) continue;
        int p = x[i] - x[j];
        int q = y[i] - y[j];
        int cost = N;
        rep(k, N) {
            int X = x[k] - p;
            int Y = y[k] - q;
            rep(l, N) if (x[l] == X && y[l] == Y) --cost;
        }
        ans = min(ans, cost);
    }
    
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    vector<vector<int>> A(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> A[i][j];
    int N;
    cin >> N;
    set<int> se;
    rep(_, N) {
        int b;
        cin >> b;
        se.insert(b);
    }

    rep(i, 3) {
        bool ok = true;
        rep(j, 3) {
            if (se.find(A[i][j]) == se.end()) ok = false;
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(j, 3) {
        bool ok = true;
        rep(i, 3) {
            if (se.find(A[i][j]) == se.end()) ok = false;
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    bool ok = true;
    rep(i, 3) if (se.find(A[i][i]) == se.end()) ok = false;
    if (ok) {
        cout << "Yes" << endl;
        return 0;
    }

    ok = true;
    rep(i, 3) if (se.find(A[i][2 - i]) == se.end()) ok = false;
    if (ok) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}


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

using namespace std;

int main() {
    stack<int> S1;
    stack<pair<int, int> > S2;
    int sum = 0;
    vector<int> ans;

    char c;
    for (int i = 0; cin >> c; i++) {
        if (c == '\\') S1.push(i);
        else if (c == '/' && S1.size() > 0) {
            int j = S1.top();
            S1.pop();
            int a = i - j;
            sum += a;
            while (S2.size() > 0 && S2.top().first > j) {
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    while (S2.size() > 0) {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int k = 0; k < ans.size(); k++) {
        cout << " " << ans[k];
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3228
#!/usr/bin/python

import sys
import math 

#Input Functions
#===============

input = sys.stdin.readline

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

#===============

def run_test() :
    (a, b) = map(float, input().split())
    a = int(a)
    b = int(b * 100 + 0.5)
    a *= b
    a //= 100
    print(int(a))

def main() :
	run_test()

if __name__ == '__main__' :
	main()


Measured memory_bytes: 9008
import java.math.BigInteger;
import java.util.Scanner;

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

        String str = scanner.nextLine();

        String[] dateStrings = str.split("/");

        BigInteger tmp = new BigInteger(dateStrings[0] + dateStrings[1] + dateStrings[2]);

        BigInteger judgeDay = new BigInteger("20190430");

        if(0 <= judgeDay.compareTo(tmp)){
            System.out.println("Heisei");
        }else{
            System.out.println("TBD");
        }
    }

}

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

int main()
{
  int n;
  cin >> n;
  int count = 0;
  for (auto i = 1; i <= n; i += 2) {
    int divisor = 0;
    for (auto j = 1; j <= i; j++) {
      if (i % j == 0) divisor++;
    }
    if (divisor == 8) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define loop(i,a,b) for(int i=a;i<b;i++)
int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    int n;
    cin>>n;
    char s[101],s1[104];
    cin>>s;
    if(strlen(s)==n)
        cout<<s<<endl;
    else
    {
        int j=0;
        loop(i,0,n)
        {
            s1[j++]=s[i];
        }
        s1[j++]='.';
        s1[j++]='.';
        s1[j++]='.';
        s1[j]='\0';
        cout<<s1<<endl;
    }


    return 0;
}


Measured memory_bytes: 3632
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

int main()
{
	int n,k;

	scn(n); scn(k);

	set<int> st;

	rep(i,1,n+1)
	st.insert(i);

	rep(i,1,k+1)
	{
		int x;

		scn(x);

		rep(j,0,x)
		{
			int val;

			scn(val);

			if(st.find(val)!=st.end())
			st.erase(val);
		}
	}

	pri((int)st.size());
	

    return 0;
}

Measured memory_bytes: 3796
#include<iostream>
#include<math.h>

using namespace std;

int powI(int b, int p) {
	int r = 1;
	for (int i = 0; i < p; i++) {
		r *= b;
	}
	return r;
}

int main() {

	int X, max = 0;
	cin >> X;
	for (int i = 1; i <= sqrt(double(X)); i++) {
		for (int j = 1;j<10; j++) {
			int tmp = powI(i, j);
			if (tmp > X) {
				break;
			}
			if (tmp >= max) {
				max = tmp;
			}
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
import itertools


def solve():
    n = int(input())
    c = 0
    for i in range(3, len(str(n)) + 1):
        for v in itertools.product(["3", "5", "7"], repeat=i):
            num = int("".join(v))
            if is_good(num) and num <= n:
                c += 1
    return c


def is_good(i):
    return set(str(i)) == {"3", "5", "7"}


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int qsort_comp(const void* x,const void* y) {
	return strcmp((const char*)x,(const char*)y);
}

int N,M;
int U[256][12];

int main(void) {
	int i;
	int T[12];
	int closed=1;
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%s",U[i]);
	qsort(U,N,sizeof(U[0]),qsort_comp);
	scanf("%d",&M);
	for(i=0;i<M;i++) {
		scanf("%s",T);
		if(bsearch(T,U,N,sizeof(U[0]),qsort_comp)) {
			printf("%s by %s\n",closed?"Opened":"Closed",T);
			closed=!closed;
		} else {
			printf("Unknown %s\n",T);
		}
	}
	return 0;
}

Measured memory_bytes: 660
#if defined(LOCAL)
// #define RANDOM_TEST
#define PROBLEM_NAME "b"
const double _max_double_error = 1e-9;
#include "testutils.h"
#endif
#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<int>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

#if defined(LOCAL)
bool local = true;
#define L(x...) debug(x)
#else
bool local = false;
#define L(x, ...) (x)
#endif
struct VoidStream { void operator&(std::ostream&) { } };
#define LOG !(local) ? (void) 0 : VoidStream() & cerr

void solve(istream& cin, ostream& cout) {
  l n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  if (a > b) swap(a, b);
  bool ok = false;
  l x = a, y = a;
  l t = n - 1;
  while (t >= 0) {
    l from = x + c * t;
    l to = y + d * t;
    if (b > to) {
      ok = false;
      break;
    }
    if (b >= from) {
      ok = true;
      break;
    }
    t--;
    x -= d;
    y -= c;
  }
  cout << (ok ? "YES" : "NO") << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 256
def INSTR():
	return input()

def INNUM():
	return int(INSTR())

def INSTR_S():
	return INSTR().split()

def INNUM_S():
	return map(int, INSTR_S())

def INSTR_SM(n):
	return [tuple(INSTR_S()) for _ in range(n)]

def INNUM_SM(n):
	return [tuple(INNUM_S()) for _ in range(n)]

A, B = INSTR_S()
print("H" if (A == "H" and B == "H") or (A == "D" and B == "D") else "D")


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e3 + 5);

ll n;
int l[MAX_N];

ll count_exclude(int i, int j) {
  int summation = l[i] + l[j];

  int index = lower_bound(l, l + n, summation) - l;

  ll part = (ll)(n - index);

  return part;
}

int main(void) {
  // Here your code !
  scanf("%lld", &n);

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

  sort(l, l + n);

  ll whole = n * (n - 1) * (n - 2) / 6;

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      whole -= count_exclude(i, j);
    }
  }

  ll ans = whole;

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

  return 0;
}


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

using namespace std;

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

	int ans = 1;
	char c = s[0];
	for (int i = 1; i < s.length(); i++) {
		if (c == s[i]) {
			if (s.length() - i >= 3) {
				i += 2;
				ans += 2;
			}
			else if (s.length() - i == 2) {
				ans++;
				break;
			}
			else {
				break;
			}
		}
		else {
			ans++;
		}
		c = s[i];
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string str = to_string(N);
  if (str.find('9') != string::npos) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int h, w, l;
    int rect = 0, dia = 0;
    
    while(scanf("%d,%d,%d", &h, &w, &l) != EOF){
        if(h * h + w * w == l * l) rect++;
    
        if(h == w) dia++;
    }
    
    printf("%d\n%d\n", rect, dia);
 
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll dp[5005];

int main(void){
	int n;
	scanf("%d",&n);
	dp[0]=1;
	for(int i=0;i<=n;i++){
		for(int j=3;i+j<=n;j++){
			dp[i+j]+=dp[i];
			dp[i+j]%=MOD;
		}
	}
	printf("%lld\n",dp[n]);
	return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18+7;
const int N = 305;
int n,m;
ll l;

ll dist[N][N];
ll dp[N][N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m>>l;
	for(int i=0; i<n; ++i){
		for(int j=0; j<n; ++j){
			dist[i][j] = inf;
			if( i == j )
				dist[i][j] = 0;
		}
	}
	for(int i=0; i<m; ++i){
		int a,b; ll x;
		cin>>a>>b>>x;
		a--; b--;
		dist[a][b] = x;
		dist[b][a] = x;
	}

	for(int k=0; k<n; ++k){
		for(int i=0; i<n; ++i){
			for(int j=0; j<n; ++j){
				dist[i][j] = min( dist[i][j], dist[i][k] + dist[k][j] );
			}
		}
	}

	for(int i=0; i<n; ++i){
		for(int j=0; j<n; ++j){
			if( dist[i][j] <= l){
				dp[i][j] = 0;
			}else{
				dp[i][j] = inf;
			}
		}
	}
	for(int k=0; k<n; ++k){
		for(int i=0; i<n; ++i){
			for(int j=0; j<n; ++j){
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + 1 );
			}
		}
	}
	int q;
	cin>>q;
	while(q--){
		int a,b;
		cin>>a>>b;
		a--; b--;
		if( dp[a][b] == inf ){ cout<<-1<<'\n'; }
		else{ cout<<dp[a][b]<<'\n'; }
	}


	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <vector>
typedef long long ll;
const int maxn = 1e5 + 5;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
char str[105][105];
int vis[105][105];

int main (int argc, char **argv) {
  int h, w;
  std::cin >> h >> w;
  for (int i=0; i < h; i++) {
    for (int j=0; j < w; j++) {
      std::cin >> str[i][j];
    }
  }

  memset(vis, 0, sizeof(vis));

  for (int i=0; i < h; i++) {
    int sum = 0;
    for (int j=0; j < w; j++) {
      if (str[i][j] == '.') {
        sum++;
      }
    }
    if (sum == w) {
      for (int j=0; j < w; j++) {
        vis[i][j] = 1;
      }
    }
  }

  for (int i=0; i < w; i++) {
    int sum = 0;
    for (int j=0; j < h; j++) {
      if (str[j][i] == '.') {
        sum++;
      }
    }

    if (sum == h) {
      for (int j=0; j < h; j++) {
        vis[j][i] = 1;
      }
    }
  }

  for (int i=0; i < h; i++) {
    bool flag = false;
    for (int j=0; j < w; j++) {
      if (!vis[i][j]) {
        std::cout << str[i][j];
        flag = true;
      }
    }
    if (flag) {
      std::cout << std::endl;
    } 
  }
  return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

long power(long a, long b) {
    return b ? power(a*a%MOD, b/2) * (b%2?a:1)%MOD:1;
}

long perm(int N, int K) {
    long x = 1;
    for(int i = 1; i <= K; i++) x = x * (N-i+1) % MOD;
    return x % MOD;
}

long comb(int N,int K) {
    long x = 1, y = 1;
    for(int i = 1; i <= K; i++) {
        x = x * (N-i+1) % MOD;
        y = y * i % MOD;
    }
    return x * power(y, MOD-2) % MOD;
}

bool isprime(int n) {
    if(n < 2) return false;
    for(int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

void dfs(const vector<vector<int> > &G, int v, vector<int> &seen) {
    seen[v] = true;

    for(int next_v : G[v]) {
        if(seen[next_v]) continue;
        dfs(G, next_v, seen);
    }
}

void yes() { cout << "Yes" << endl;}
void no() { cout << "No" << endl;}



int main() {
	int a, b; cin >> a >> b;
	cout << a * b << endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using p = pair<int,int>;

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

    vector<vector<p>> v(n);

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        v[i].resize(a);
        for(int j = 0; j < a; j++){
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first;
        }
    }

    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        bool flag = true;
        for(int i = 0; i < n; i++){
            if(!(bit & (1 << i)))
                continue;
            for(p xy : v[i]){
                int x = xy.first;
                int y = xy.second;
                if(y == 1 && !(bit & (1 << x)))
                    flag = false;
                if(y == 0 && bit & (1 << x))
                    flag = false;
            } 
        }
        if(flag){
            int cnt = 0;
            for(int j = 0; j < n; j++){
                if(bit & (1 << j))
                    cnt++;
            }
            ans = max(ans, cnt);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
H, W = list(map(lambda x: int(x), input().split(" ")))
A = []
ans = []
whiterows = []
whitecols = []

for i in range(H):
  A.append(list(input()))
  if A[i].count("#") == 0:
    whiterows.append(i)

tA = [list(a) for a in zip(*A)]
for j in range(W):
  if tA[j].count("#") == 0:
    whitecols.append(j)

rows = list(filter(lambda r: r not in whiterows, list(range(H))))
cols = list(filter(lambda c: c not in whitecols, list(range(W))))

for k in rows:
  ans.append("".join([A[k][l] for l in cols]))

print("\n".join(ans))

Measured memory_bytes: 9364
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n+1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def main():
    N = NI()
    edges = [NLI() for _ in range(N-1)]
    graph = [[] for _ in range(N+1)]
    edge_dict = {}
    for i, edge in enumerate(edges):
        graph[edge[0]].append(edge[1])
        graph[edge[1]].append(edge[0])
        edge_dict[(edge[0], edge[1])] = i+1

    queue = deque()
    queue.append(1)
    seen = [0]*(N+1)
    colors = [-1] * N
    colors[1] = 1
    now_colors = deque()
    now_colors.append(-1)
    while queue:
        now = queue.popleft()
        now_color = now_colors.popleft()
        seen[now] = 1
        nexts = graph[now]
        color = 1
        for goto in nexts:
            if seen[goto] == 0:
                a, b = min(now, goto), max(now, goto)
                if color == now_color:
                    color += 1
                colors[edge_dict[(a, b)]] = color
                queue.append(goto)
                now_colors.append(color)
                color += 1
    print(max(colors))
    for i in range(1, N):
        print(colors[i])



if __name__ == "__main__":
    main()

Measured memory_bytes: 54392
using System;
using System.Linq;

// https://atcoder.jp/contests/abc123/tasks/abc123_b
namespace BFiveDishes
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            const int DishCount = 5;
            var timeWithPaddings = new Tuple<int, int>[DishCount];
            for (var i = 0; i < DishCount; i++)
            {
                var cookingTime = int.Parse(Console.ReadLine());
                var padding = cookingTime % 10 == 0 ? 0 : 10 - cookingTime % 10;
                timeWithPaddings[i] = Tuple.Create(cookingTime, padding);
            }

            // 一番 PaddingTime の長い料理を最後に注文することで最短時間となる
            var maxPadding = timeWithPaddings.Max(t => t.Item2);
            var sum = timeWithPaddings.Sum(t => t.Item1 + t.Item2) - maxPadding;

            // 解答の出力
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11348
import java.util.Scanner;

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

		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();

		char c[] = S.toCharArray();

		c[K - 1] = Character.toLowerCase(c[K - 1]);

		for (int i = 0; i < N; i++) {
			System.out.print(c[i]);
		}
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	string O, E;
	cin >> O >> E;

	int O_s = O.length();
	int E_s = E.length();
	if (O_s > E_s) {
		for (int i = 0; i < E_s; i++) {
			cout << O[i] << E[i];
		}
		cout << O[O_s - 1] << endl;
	}
	else if (O_s < E_s) {
		for (int i = 0; i < O_s; i++) {
			cout << O[i] << E[i];
		}
		cout << E[E_s - 1] << endl;
	}
	else {
		for (int i = 0; i < O_s; i++) {
			cout << O[i] << E[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i

ans = n
0.upto(n) do |i|
    tmp = 0
    t = i
    while t > 0
        tmp += t % 6
        t /= 6
    end
    t = n - i
    while t > 0
        tmp += t % 9
        t /= 9
    end
    ans = tmp if ans > tmp
end
puts ans


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

// 入力
int N, M;
int dp[100001];        // メモ化再帰
vector<int> G[100001]; // グラフ
// vector<vector<int>> G; // グラフ

int rec(int v) {
    if (dp[v] != 0)
        return dp[v]; // 既に更新済み

    int res = 0;
    for (auto nv : G[v]) {
        res = max(res, rec(nv) + 1);
    }
    return dp[v] = res; // メモしながらリターン
}

int main() {
    // 入力受け取り
    cin >> N >> M;
    // G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y; // 0-indexed にする
        G[x].push_back(y);
    }

    // 全ノードを一通り更新しながら答えを求める
    int res = 0;
    for (int v = 0; v < N; ++v) {
        res = max(res, rec(v));
    }
    cout << res << endl;
}

Measured memory_bytes: 8192
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
from collections import deque

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

A = sorted(A, reverse=True)
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr


queue_A = deque(A)
queue_B = deque()

for i in range(M):
    if len(queue_B) > 0 and queue_B[0] >= queue_A[0]:
        queue_A.appendleft(queue_B.popleft())
    queue_A[0] //= 2
    if len(queue_A) > 1 and queue_A[0] < queue_A[1]:
        queue_B.append(queue_A.popleft())

print(sum(queue_A) + sum(queue_B))

Measured memory_bytes: 20336
using System;
using System.Linq;
using System.Collections.Generic;

namespace Competition
{
    class Program
    {
        static void Main(string[] args)
        {
            var kx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var K = kx[0]; var X = kx[1];

            var res = new List<int>();
            var s = X - K + 1;
            res.Add(s);
            for(var i = 0; i < K * 2 - 2; i++)
            {
                res.Add(++s);
            }
            Console.WriteLine(string.Join(" ", res));
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

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

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double c = sc.nextDouble();

		double h = b * Math.sin(Math.toRadians(c));
		double S = a * h / 2;
		double L = a + b + Math.sqrt(a*a + b*b - 2*a*b*Math.cos(Math.toRadians(c)));

		System.out.println(S);
		System.out.println(L);
		System.out.println(h);
	}

}


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

#define mid(s,e)        (s+(e-s)/2)
#define YES             cout << "YES" << endl
#define NO              cout << "NO" << endl
#define sin(s)	        getline(cin, s)
#define ll              long long
#define ull             unsigned long long
#define dd              double
#define mx 1000005


int main()
{
    //freopen("A.txt","r",stdin);
    //freopen("A.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    int a,b,c;
    cin>>a>>b>>c;
    ll m=a*b;
    if(m<c)
    {
        cout<<m<<endl;
    }
    else
    {
        cout<<c<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#   In this template you are not required to write code in main

import sys
inf = float("inf")
#sys.setrecursionlimit(1000000)


# abc='abcdefghijklmnopqrstuvwxyz'
# abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
# mod,MOD=1000000007,998244353
# vow=['a','e','i','o','u']
# dx,dy=[-1,1,0,0],[0,0,1,-1]

#from cmath import sqrt
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi,gcd
from bisect import bisect_left,bisect_right
#import numpy as np


def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n,d=get_ints()
d=2*d+1
ans=0
if n%d==0:
    ans=0
else:
    ans+=1
ans+=n//d
print(ans)

Measured memory_bytes: 3188
import math
A, B = map( int, input().split() )
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if ( n!=1 ) and ( arr==[] ):
        arr.append(n)

    return set( arr )

a = factorization(A)
b = factorization(B)
cnt = 0
for i in a:
  if i in b:
    cnt += 1

print( cnt + 1 )



Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

struct mint {
  ll x;
  mint(ll x = 0) : x(x % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

class combination {
 private:
  vector<mint> fact, finv;

 public:
  combination(int N) {
    fact = finv = vector<mint>(N + 1);
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    for (ll i = 2; i <= N; i++) {
      fact[i] = fact[i - 1] * i;
      finv[i] = fact[i].inv();
    }
  }
  mint f(int i) { return fact[i]; }
  mint comb(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fact[n] * finv[k] * finv[n - k];
  }
  mint hcomb(int n, int k) {
    if (n == 0 && k == 0) return 1;
    return comb(n + k - 1, k);
  }
};

int main() {
  //
  ll n;
  cin >> n;
  map<ll, ll> m;
  int i0 = -1, i1 = -1;
  rep(i, n + 1) {
    ll a;
    cin >> a;
    if (m.find(a) != m.end()) {
      i0 = m[a];
      i1 = i;
      // cerr << a << ":" << i0 << "-" << i1 << endl;
    }
    m[a] = i;
    // cerr << a << ":" << i << endl;
  }
  int lenout = i0 + (n - i1);
  combination comb(n + 1);

  REP(len, 1, n + 2) {
    mint ans = comb.comb(n + 1, len);
    int len0 = len - 1;
    // cerr << i0 << " " << i1 << endl;
    if (len0 <= lenout) {
      ans -= comb.comb(lenout, len0);
    }
    cout << ans.x << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;

const int MAXN=1e5+7;

int n,k;
ll sum[MAXN],sum2[MAXN],a[MAXN],ans;

int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		if(a[i]>0) sum[i]+=a[i];
	}
	for(int i=1;i<=n;i++) {
		sum[i]+=sum[i-1];
		sum2[i]=sum2[i-1]+a[i];
	}
	
	for(int i=k;i<=n;i++)
		ans=max(ans,sum[n]-sum[i]+sum[i-k]+max(0ll,sum2[i]-sum2[i-k]));
	printf("%lld",ans);
}

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

int main() {
  int a = 0, x = 0, y = 0, z = 0;
  cin >> a;
  
  x = a/100; y = (a%100)/10; z = (a%100)%10;
  
  cout << x + y + z << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;


string s,t;
mt pos;
vl pos_ptr;
mt pos_mem;
ll ans;

void error(){
  cout << -1 << endl;
  exit(0);
}

int main(){
  cin >> s >> t;
  pos = mt(26);
  pos_ptr = vl(26);
  for(ll i = 0;i < s.size();i++){
    pos[s[i]-'a'].push_back(i);
  }
  // for(ll i = 0;i < 26;i++){
  //   for(auto y : pos[i]) cerr << y << " ";
  //   cerr << endl;
  // }
  pos_mem = mt(26, vl(s.size()));
  pos_mem = mt(s.size(), vl(26));
  for(ll i = 0;i < s.size();i++){
    for(ll j = 0;j < 26;j++){
      if(pos[j].size() > pos_ptr[j]){
        if(pos[j][pos_ptr[j]] < i) pos_ptr[j]++;
        if(pos[j].size() > pos_ptr[j]) pos_mem[i][j] = pos[j][pos_ptr[j]];
        else pos_mem[i][j] = -1;
      }else{
        pos_mem[i][j] = -1;
      }
    }
  }
  for(ll i = 1;i < s.size();i++){
    for(ll j = 0;j < 26;j++){
      if(pos_mem[i][j] < 0) pos_mem[i][j] = pos_mem[0][j];
    }
  }
  // for(ll i = 0;i < s.size();i++){
  //   for(ll j = 0;j < 26;j++){
  //     cerr << pos_mem[i][j] << " ";
  //   }
  //   cerr << endl;
  // }
  ll ptr = 0;
  for(ll i = 0;i < t.size();i++){
    ll nxt_ptr = pos_mem[ptr][t[i]-'a'];
    if(nxt_ptr < 0) error();
    if(nxt_ptr < ptr) ans += s.size();
    ptr = (nxt_ptr+1);
    if(ptr >= s.size()){
      ans += s.size();
      ptr = 0;
    }
  }
  cout << ans+ptr << endl;



}


Measured memory_bytes: 46000
#include <bits//stdc++.h>
using namespace std;
#define int long long
signed main() {
    int A,N,Max=0;
    cin >> N;
    long long goukei=0;
    for(int i=0;i<N;i++){
        cin >> A;
        goukei+=max<int>(Max-A,0);
        Max=max(A,Max);
    }
    cout << goukei << endl;
    
}



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

const int MAXN = 300005;
int x[MAXN], y[MAXN];
int t1[MAXN], t2[MAXN];
int flag1[MAXN], flag2[MAXN];

int main() {
	int h, w, m, ans = 0;
	scanf ("%d %d %d", &h, &w, &m);
	for(int i = 1; i <= m; i++) {
		scanf ("%d %d", &x[i], &y[i]);
		t1[x[i]]++;
		t2[y[i]]++;
	}
	int ma1 = 0, x_ = 0, y_ = 0, ma2 = 0;
	for(int i = 1; i <= h; i++) {
		if(t1[i] > ma1) {
			ma1 = t1[i];
			x_ = i;
		}
	}
	for(int i = 1; i <= m; i++)
		if(x[i] == x_)
			flag1[y[i]]++;
	for(int i = 1; i <= w; i++) 
		if(t2[i] - flag1[i] > ma2) 
			ma2 = t2[i] - flag1[i];
	ans = max(ans, ma2 + ma1);
	ma1 = 0, ma2 = 0;
	for(int i = 1; i <= w; i++) {
		if(t2[i] > ma1) {
			ma1 = t2[i];
			y_ = i;
		}
	}
	for(int i = 1; i <= m; i++)
		if(y[i] == y_)
			flag2[x[i]]++;
	for(int i = 1; i <= h; i++) 
		if(t1[i] - flag2[i] > ma2) 
			ma2 = t1[i] - flag2[i];
	ans = max(ans, ma2 + ma1);
	
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9444
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define pii pair<LL,LL> 

int n;
pii a[100005];
LL x[100005],y[100005],p[100005]; 

int main()
{
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
		a[i].first=x[i]+y[i];
		a[i].second=i;
	}
	sort(a,a+n);
	reverse(a,a+n);
	
	LL ans=0;
	for(int i=0;i<n;i++)
		if(i%2==0) ans+=x[a[i].second];
		else ans-=y[a[i].second];
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 3456
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

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

#define MOD 1000000007

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

//割り算
long divi(long U,long D){
    if(U==D) return 1;

    if(U%D==0) return (U/D)%MOD;
    else return divi(U+MOD,D);
}

//nCmを求める
long combination(int n, int m){
    long U=1;
    long D=1;

    for(int i=n;i>(n-m);i--) U=(U*i)%MOD;
    for(int i=1;i<=m;i++) D=(D*i)%MOD;

    long ans=divi(U,D);
    return ans;
}


int main(void){
    int N,M;
    scanf("%d%d",&N,&M);

    int prime_factor[100000];
    for(int i=0;i<100000;i++) prime_factor[i]=0;

    //素因数分解
    int p_factor_num=0;
    for(int i=2;i*i<=M;i++){
        if(M%i==0){
            while(M%i==0){
                prime_factor[p_factor_num]++;
                M=M/i;
            }
            p_factor_num++;
        }
    }
    if(M>1){
        prime_factor[p_factor_num]++;
        p_factor_num++;
    }

    long long ans=1;
    for(int i=0;i<p_factor_num;i++){
        ans*=combination(prime_factor[i]+N-1,prime_factor[i]);
        ans%=MOD;
    }
    printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 512
input_line = list(input())
place_of_one = int(input_line[-1])
if place_of_one in [2, 4, 5, 7, 9]:
    print('hon')
elif place_of_one in [0, 1, 6, 8]:
    print('pon')
elif place_of_one in [3]:
    print('bon')

Measured memory_bytes: 9172
#include <iostream>

int main(void)
{
    int n, data_a, data_b;
    int score_a, score_b;


    while(1)
    {
        std::cin >> n;
        if (n == 0) break;
        score_a = 0;
        score_b = 0;
        for(; n > 0 ; n--) {
            std::cin >> data_a;
            std::cin >> data_b;
            if (data_a > data_b) {
                score_a += (data_a + data_b);
            } else if(data_a < data_b) {
                score_b += (data_a + data_b);
            } else {
                score_a += data_a;
                score_b += data_b;
            }
        }
        std::cout << score_a << " " << score_b << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {
	char c[100],*st;
	int n,f,ca1,ca2,d;
	stack<int> as;
	stack<char> bs;
	cin >> n;
	for (n;n>0;n--) {
	cin >> c; st=c;
	while(true) {
		if (st[0]=='=') break;
		f=0; d=0;
		if (st[0]=='-') if (st==c) d=1; else if ((st-1)[0]=='(') d=1;
		if ((st[0]>='0' && st[0]<='9') || d==1) {
			as.push(atoi(st)); f=1; st++;
		    for (st;st[0]>='0' && st[0]<='9';st++);	}
		else { if (st[0]==')') { bs.pop(); f=1;} else bs.push(st[0]); st++;}
		if (bs.empty() || f==0) continue;
		while(true){
			if (bs.empty()) break; else if (bs.top()=='(') break;
            if (bs.top()=='*' || bs.top()=='/') {
				ca2=as.top(); as.pop(); ca1=as.top(); as.pop(); 
				if (bs.top()=='*') ca1=ca1*ca2; else ca1=ca1/ca2;
				as.push(ca1); bs.pop();	}
			else if (st[0]!='*' && st[0]!='/') {
                ca2=as.top(); as.pop(); ca1=as.top(); as.pop(); 
				if (bs.top()=='+') ca1=ca1+ca2; else ca1=ca1-ca2;
				as.push(ca1); bs.pop(); } else break;
		}
	}
		cout << as.top() << endl;
		as.pop();
	}
	return 0;
	}

Measured memory_bytes: 1216
n, m = map(int, input().split())

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

ab.sort(key=lambda x: x[0])

ans = 0
while m > 0:
    a, b = ab.pop(0)
    ans += min(m, b) * a
    m -= min(m, b)

print(ans)


Measured memory_bytes: 22748
import sys
import copy
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c = na()
print('YES' if b - a == c - b else 'NO')




Measured memory_bytes: 3444
n,k=map(int,input().split())
s=[tuple(map(int,input().split())) for _ in range(n)]
b=bin(k)[2:]
r=sum(b for a,b in s if k|a==k)
for i in range(len(b)-1):
    if b[i]=='0':
        continue
    l=int(b[:i]+'0'+'1'*(len(b)-i-1),2)
    r=max(r,sum(b for a,b in s if l|a==l))
print(r)

Measured memory_bytes: 64984