akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template<typename T>
struct Edge {
    int to; T cost;
    Edge (int to, T cost = 1) : to(to), cost(cost) { }
    bool operator< (const Edge &r) const { return (cost < r.cost); }
};

template<typename T>
using Graph = vector<vector<Edge<T>>>;

template <typename T>
vector<T> dijkstra(const Graph<T> &g, int s){
    using P = pair<T, int>;
    vector<T> ret(g.size(), -1);
    priority_queue<P, vector<P>, greater<P>> que;
    que.emplace(ret[s], s); ret[s] = 0;
    while (not que.empty()) {
        int v; T c; tie(c, v) = que.top(); que.pop();
        if (ret[v] < c) continue;
        for (const auto &e : g[v]) {
            if (ret[e.to] > ret[v] + e.cost or ret[e.to] == -1) {
                ret[e.to] = ret[v] + e.cost;
                que.emplace(ret[e.to], e.to);
            }
        }
    }
    return ret;
}

long double f (long double x) { return (x * x); }

int main() {
    long double a, b, c, d;
    int n;
    cin >> a >> b >> c >> d >> n;
    vector<pair<long double, long double>> p(n);
    vector<long double> r(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].first >> p[i].second >> r[i];
    }
    
    p.emplace_back(a, b); r.emplace_back(0);
    p.emplace_back(c, d); r.emplace_back(0);
    
    Graph<long double> g(n + 2);
    for (int i = 0; i < n + 2; i++) {
        for (int j = i + 1; j < n + 2; j++) {
            long double d = f(p[i].first - p[j].first) + f(p[i].second - p[j].second);
            d = sqrtl(d);
            d = max(0.0L, (long double)d - (r[i] + r[j]));
            g[i].emplace_back(j, d);
            g[j].emplace_back(i, d);
        }
    }
    
    vector<long double> dat = dijkstra(g, n);
    
    cout << fixed << setprecision(20) << dat[n + 1] << '\n';
    
    return 0;
}

Measured memory_bytes: 42860
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize
    }
    if a == b {
        println!("Draw");
    } else if a == 1 {
        println!("Alice");
    } else if b == 1 {
        println!("Bob");
    } else if a > b {
        println!("Alice");
    } else {
        println!("Bob");
    }
}


Measured memory_bytes: 2144
n,*a=map(int,open(0).read().split())
ans=[str(2*n-1)]
if max(a)>-min(a):
	i=a.index(max(a))
	for k in range(n):
		ans.append("{} {}".format(i+1,k+1))
	for k in range(n-1):
		ans.append("{} {}".format(k+1,k+2))
else:
	i=a.index(min(a))
	for k in range(n):
		ans.append("{} {}".format(i+1,k+1))
	for k in range(n-1):
		ans.append("{} {}".format(n-k,n-k-1))
print("\n".join(ans))

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

const int INF = 1 << 30;

int main(){
	long n;
	scanf("%ld", &n);
	int ans = INF;
	for(long i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			int cnt = 0;
			long d = n / i;
			while(d) {
				cnt++;
				d /= 10;
			}
			ans = min(ans, cnt);
		}
	}
	printf("%d", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define INF 1000000007
#define MOD 1000000007
#define SEP " "

class modint
{
	public:
	ll val;

	constexpr modint(const ll x = 0) noexcept : val(x % MOD) {}
	constexpr ll &value() noexcept {return (val);}
	constexpr modint operator+(const modint rhs) const noexcept {
		return (modint(*this) += rhs);
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint &operator+=(const modint rhs) noexcept {
		val += rhs.val;
		if (val >= MOD) {
			val -= MOD;
		}
		return (*this);
	}
	constexpr modint &operator-=(const modint rhs) noexcept {
		if (val < rhs.val) {
			val += MOD;
		}
		val -= rhs.val;
		return (*this);
	}
	constexpr modint &operator*=(const modint rhs) noexcept {
		val = val * rhs.val % MOD;
		return (*this);
	}
	constexpr modint &operator/=(modint rhs) noexcept {
		ll exp = MOD - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return (*this);
	}
};

int		main(void) {
	int n, k;
	cin >> n >> k;
	modint ans = 0;
	modint begin = 0;
	modint end = 1;
	for (int i = 0; i < k; i++)
	{
		begin += i;
		end += n - i;
	}
	ans += end - begin;
	for (int i = k; i < n + 1; i++)
	{
		begin += i;
		end += n - i;
		ans += end - begin;
	}
	cout << ans.val << endl;
}


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	string s;
	int cnt[26];
	memset(cnt,0,sizeof cnt);
	cin>>s;
	for(char c:s)
		cnt[c-'a']++;
	bool ok=true;
	for(int i=0;i<26;++i)
		ok&=cnt[i]%2==0;
	cout<<(ok?"Yes\n":"No\n");
}




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

int main() {
	
	int A,C,D,E,F;
	double G;
	cin >> A ;

	G = A / 1.08;
	C = A / 1.08;
	D = C * 1.08;
	E = (C+1) * 1.08;
	F = (C-1) * 1.08;

	if (D != A && E != A && F != A) {
		cout << ":(" << endl;
	}
	else if (D != A && E == A && F != A) {
		cout << C+1 << endl;
	}
	else 
	    cout << C << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
if sum(a)==0:
  print("Yes")
else:
  t=list(set(a))
  if len(t)==3 and n%3==0:
    if t[0]^t[1]==t[2] and a.count(t[0])==n//3 and a.count(t[1])==n//3:
      print("Yes")
    else:
      print("No")
  elif len(t)==2 and a.count(0)==n//3 and n%3==0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 20544
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val b = IntArray(n)
    for ((i, c) in readLine()!!.split(' ').map(String::toInt).withIndex()) {
        b[c - 1] = i + 1
    }
    val s = TreeSet<Int>()
    s.add(0)
    s.add(n + 1)
    var ans = 0L
    for ((i, p) in b.withIndex()) {
        ans += (s.ceiling(p)!! - p).toLong() * (p - s.floor(p)!!) * (i + 1)
        s.add(p)
    }
    println(ans)
}

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

int main()
{
  int arr[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<arr[k];
return 0;
}
  


Measured memory_bytes: 888
N, K = map(int, input().split())

########関数部分##############
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
############################
 
 
#####関数をつかってみる．#####
print(len(Base_10_to_n(N,K)))

Measured memory_bytes: 38448
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>

template<typename T>
inline std::string toStr(T&& t) {
    std::stringstream ss;
    
    ss << t;
    
    return ss.str();
}

bool isLoop(int i) {
    auto str1 = toStr(i);
    auto str2 = str1;
    
    std::reverse(str1.begin(), str1.end());
    
    return str1 == str2;
}

constexpr int max = 10 * 10 * 10 * 10;
int main() {
    int x, ans = 0;
    
    std::cin >> x;  

    for(int i = 0; i <= max; ++i) {
        if(isLoop(i) && std::abs(x - ans) > std::abs(x - i)) {
            ans = i;
        }
    }
    
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)1e9+7

int main() {
    string s; cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}


Measured memory_bytes: 256
#ABC070C
N=int(input())
T=[]
for _ in range(N):
	T.append(int(input()))

def GCD(a,b): #Greatest Common Diverser
	x = max(a,b)
	y = min(a,b)
	if x % y == 0:
		return y
	else:
		while x % y != 0:
			z = x % y
			x = y
			y = z
		else:
			return y
def LCM(a,b): #Least Common Multiple
	return a * b // GCD(a,b)
x=T[0]
for t in T:
	x=LCM(x,t)
print(x)

Measured memory_bytes: 3064
# coding: utf-8
from collections import deque


def solve(*args: str) -> str:
    h, w = map(int, args[0].split())
    black = [[True if s == '#' else False for s in S] for S in args[1:]]

    inf = 10**12
    counts = [[inf]*w for _ in range(h)]
    Q = deque([(0, 0, 0, False)])
    while Q:
        x, y, n, prev = Q.popleft()
        if h <= y or w <= x:
            continue

        if black[y][x]:
            if not prev:
                n += 1
                prev = True
        else:
            prev = False

        if n < counts[y][x]:
            counts[y][x] = n
            for dx, dy in [(1, 0), (0, 1)]:
                Q.append((x+dx, y+dy, n, prev))

    return str(counts[-1][-1])


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
long long H,ans;
void solve(){
    cin>>H;
    for(int tmp=1;H;++tmp,H>>=1){
        ans+=1ll<<tmp;
    }
    cout<<(ans>>1)<<endl;
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

const double PI = 3.1415926535853;

int main() {
    int a, b, h, m; cin >> a >> b >> h >> m;
    double ha = (h * 60 + m) / 720.0 * 360, ma = m * 6;
    double g = fabs(ha - ma);
    double x = cos(g / 180 * PI);
    printf("%.10lf\n", sqrt(a * a + b * b - 2 * a * b * x));
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5+5;
int cum[N][33];
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    run();
    string s,t;
    cin>>s>>t;
    int ans=0;
    for (int i = 0; i < sz(s); ++i) {
        ans+=s[i]!=t[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3764
a,b = map(int,input().split())

ans = 0

for i in range(a,b+1):
    s = str(i)
    if len(s) %2== 1:
        c = s[:len(s)//2]
        d = s[len(s)-1:len(s)//2:-1]
        if c == d:
            ans += 1
    else:
        c = s[:len(s)//2]
        d = s[len(s)-1:len(s)//2:-1]
        if c == d:
            ans += 1

print(ans)


Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

void solve() {
    string s;
    cin >> s;

    ll res = 0;
    for(char c : s)
        res += c - '0';
    cout << (res % 9 ? "No" : "Yes") << endl;
}

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

    int tc = 1;
    FOR(i, 1, tc + 1) {
        //cout << "Case #" << i << ": ";
        solve();
    }
}



Measured memory_bytes: 3764
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	int a[] = new int[5]; // 配列確保（大きめに）
        int n = 0; // データ数
        // データ入力
        for (int i = 0; i < 3; i++) {
            a[n] = scanner.nextInt();
            n++;
        }
	  	
        for (int i = 0; i < 3; i++) {
            int pos = i;
            for (int j = i + 1; j < n; j++) {
                if (a[j] < a[pos]) {
                    pos = j;
                }
            }
            int w = a[i];
            a[i] = a[pos];
            a[pos] = w;
        }
		for (int i = 0; i < 2; i++) {
        	System.out.print(a[i]+" ");
        }
        System.out.println(a[2]);
        scanner.close();
  }
}


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

int main() {
  vector<int>  A(3);
  for ( int i=0 ; i<3 ; i++){
  cin >> A.at(i);
  }
  
  sort ( A.begin() , A.end() );
    cout << A.at(0)+A.at(1) << endl;
}
  

Measured memory_bytes: 3604
#include<cstdio>
#define ll long long
int h[100000],n,a,b;
bool check(int t) {
	int c=0;
	for(int i = 1; i <= n; i ++ ) {
		c+=h[i]<=(ll)t*b?0:(h[i]-t*b+(a-b-1))/(a-b);
		if(c > t) return 0;
	}
	return c<=t;
}
int main() {
	scanf("%d%d%d",&n,&a,&b);
	for(int i = 1; i <= n; i ++ )scanf("%d", &h[i]);
	int l=1, r=1e9;
	while(l<r) {
		int mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
}

Measured memory_bytes: 512
#include <string.h>
#include <algorithm>
#include <cstdlib>  // abs() for integer
#include <iostream>
using namespace std;

int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  /*
  for (int i = 1; i <= K; i++) {
    if (A > 0)
      A += -1;

    else if (B > 0)
      B += -1;

    else
      break;
  }*/

  if (A + B <= K) {
    A = 0;
    B = 0;
  }

  else if (A - K >= 0)
    A = A - K;

  else if (A - K < 0) {
    B = B - (K - A);
    A = 0;
  }

  cout << A << " " << B << endl;

  return 0;
}

Measured memory_bytes: 256
nm = input('')
n=int(nm.split(' ')[0])
m=int(nm.split(' ')[1])
hs = input('').split(' ')

abmap = {}
for i in range(m):
    ab = input('')
    a = int(ab.split(' ')[0])
    b = int(ab.split(' ')[1])
    if a in abmap.keys():
        abmap[a].append(b)
    else:
        abmap[a] = [b]
    if b in abmap.keys():
        abmap[b].append(a)
    else:
        abmap[b] = [a]

ytb_cnt=0
for a,b in abmap.items():
    ah = int(hs[a-1])
    ytb = 1
    for bn in b:
        bh = int(hs[bn-1])
#        print("{}[{}]->{}[{}]".format(a,ah,b,bh))
        if ah <= bh:
            ytb=0
    if ytb == 1:
        ytb_cnt+=1
for h in range(len(hs)):
    if not (h+1) in abmap.keys():
#        print("{} is no root".format(h+1))
        ytb_cnt+=1
print(ytb_cnt)

Measured memory_bytes: 35344
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int x, a, b;
	cin >> x >> a >> b;

	if (abs(x - a) < abs(x - b))
	{
		cout << "A";
	}
	else
	{
		cout << "B";
	}

	return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	cout << a/b << endl;
	cout << a%b << endl;
	printf("%.10f\n",1.*a/b);
	return 0;
}

Measured memory_bytes: 1240
s = gets.chomp

unless s == s.reverse
  puts "No"
  exit
end

s2 = s[0, ((s.length - 1) / 2)]

unless s2 == s2.reverse
  puts "No"
  exit
end

s3 = s[((s.length + 3) / 2 - 1) .. -1]

unless s3 == s3.reverse
  puts "No"
  exit
end

puts "Yes"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isPossible(x) printf("%s\n",(x) ? "Possible" : "Impossible")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
// #define INF (1<<29)

const long long INF = 1LL<<50;

#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
// const int mod =(int)998244353;
const int mod =(int)1e9+7;

const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
  if(a<0)a=-a;
  if(b<0)b=-b;
    ll g;g=gcd(a,b);
    return b/g*a;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ios::sync_with_stdio(false);
    string S;
    cin>>S;
    int n=S.length();
    int d=0;
    REP(i,n){
        d+=(S[i]-'0');
        d%=9;
    }
    isYes(d==0);
    return 0;
} 
 

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  int n;
  cin >> n;
  vec1 a(n+1);
  for(int i = 0; i < n+1; i++) cin >> a.at(i);
  vec1 b(n);
  for(int i = 0; i < n; i++) cin >> b.at(i);
  
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    if(a.at(i) < b.at(i)) {
      b.at(i) = b.at(i) - a.at(i);
      ans = ans + a.at(i); 
      if(a.at(i+1) >= b.at(i)) {
        a.at(i+1) = a.at(i+1) - b.at(i);
        ans = ans + b.at(i);
      } else { // a.at(i+1) < b.at(i)
        ans = ans + a.at(i+1);
        a.at(i+1) = 0;
      }
    } else if(a.at(i) >= b.at(i)) {
      ans = ans + b.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n, m, a, b;
int main() {
	scanf("%d%d", &n, &m);
	scanf("%d%d", &a, &b);
	for (int i = 0; i < n; ++i, puts("")) {
		for (int j = 0; j < m; ++j) {
			if ((i < b) && (j < a) || (i >= b) && (j >= a)) {
				putchar('1');
			}
			else putchar('0');
		}
	}
	return 0;
}

Measured memory_bytes: 1280
a=[]
while True:
  n,x=map(int,input().split(' '))
  if n==0 and x==0:
    break
  a.append([n,x])

for n,x in a:
  res={}
  for i in range(1,n+1):
    for j in range(1,n+1):
      for k in range(1,n+1):
        if i+j+k==x and  i!=j and j!=k and k!=i:
          tmp=[i,j,k]
          tmp.sort()
          s=str(tmp[0])+str(tmp[1])+str(tmp[2])
          res[s]=1                               
  print(len(res))




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

int x[100002], y[100002];
char c[100002];

int field[2][2004][2004];
int K2;


int able_count(int sx, int sy, int kx, int ky, int is_black){
    // sx <= x < sx + kx && sy <= y < sy + ky
    int ret = 0;
    if(sx + kx - 1 >= K2){
        ret += able_count(0, sy, sx + kx - K2, ky, is_black);
        kx = K2 - sx;
    }
    assert(sx + kx - 1 < K2);
    if(sy + ky - 1 >= K2){
        ret += able_count(sx, 0, kx, sy + ky - K2, is_black);
        ky = K2 - sy;
    }
    assert(sy + ky - 1 < K2);
    ret += field[is_black][sx + kx - 1][sy + ky - 1];
    if(sx >= 1) ret -= field[is_black][sx - 1][sy + ky - 1];
    if(sy >= 1) ret -= field[is_black][sx + kx - 1][sy - 1];
    if(sx >= 1 && sy >= 1) ret += field[is_black][sx - 1][sy - 1];
    return ret;
}

int main(){
    int N, K;
    cin >> N >> K;

    K2 = K * 2;

    memset(field, 0, sizeof(field));
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i] >> c[i];
        int is_black = c[i] == 'B' ? 1 : 0;
        field[is_black][x[i] % K2][y[i] % K2]++;
    }

    for(int i=0;i<K2;i++){
        for(int j=1;j<K2;j++){
            field[0][i][j] += field[0][i][j-1];
            field[1][i][j] += field[1][i][j-1];
        }
    }

    for(int i=0;i<K2;i++){
        for(int j=1;j<K2;j++){
            field[0][j][i] += field[0][j-1][i];
            field[1][j][i] += field[1][j-1][i];
        }
    }

    int ans = 0;
    for(int i=0;i<K2;i++){
        for(int j=0;j<K2;j++){
            // black : i ~ i + K
            // white : otherwise
            int bl = i, br = (i + K) % K2;
            int wl = br;
            int wr = (wl + K) % K2;
            int s = 0;
            s += able_count(i, j, K, K, 1);
            s += able_count((i + K) % K2, (j + K) % K2, K, K, 1);
            s += able_count((i + K) % K2, j, K, K, 0);
            s += able_count(i, (j + K) % K2, K, K, 0);
            ans = max(ans, s);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 32512
#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 n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    if (10%p == 0) {
        ll ans = 0;
        rep(r,n) {
            if ((s[r]-'0') % p == 0) {
                ans += r+1;
            }
        }
        cout << ans << "\n";
        return 0; 
    }

    vector<int> d(n+1);
    int ten = 1;
    for (int i = n-1; i >= 0; --i) {
        int a = (s[i]-'0') * ten % p;
        d[i] = (d[i+1]+a) % p;
        ten *= 10; ten %= p;
    }
    vector<int> cnt(p);
    ll ans = 0;
    for (int i = n; i >= 0; --i) {
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cmath>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> p;
typedef vector<p> vp;
const int INF=1e9;
int n,ans=0;
string s;
void dfs(string t,bool three,bool five,bool seven)
{
  if(t.size()>s.size() || stoi(t)>stoi(s)) return;
  if(stoi(t)<=stoi(s) && (three && five && seven))
    {
      ans++;
    }
  dfs(t+'3',true,five,seven);
  dfs(t+'5',three,true,seven);
  dfs(t+'7',three,five,true);
}
int main(int argc,char const* argv[])
{
  cin >> s;
  string check="";
  dfs(check+'3',true,false,false);
  dfs(check+'5',false,true,false);
  dfs(check+'7',false,false,true);
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        string tmp1 = Reader.ReadLine();
        string tmp2 = Reader.ReadLine();

        string ans = "No";
        for (int i = 0; i < tmp1.Length; i++) {
            string tmp3 = tmp1.Substring(i) + tmp1.Substring(0, i);
            if(tmp3.Equals(tmp2)) {
                ans = "Yes";
                break;
            }
        }
        Console.WriteLine(ans);
    }





    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"




abc
cab



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n,b) << endl;
}

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

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

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

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 998244353LL;

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

struct BIT{
  ll bit[1000010];
  void add(ll a,ll w){
    for(ll x = a; x < 1000010; x+=(x&-x)) bit[x]+=w;
  }
  ll sum(ll a){
    ll ret = 0;
    for ( ll x = a; x > 0;x-=(x&-x)) ret += bit[x];
    return ret;
  }
};

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

int main() {
    ll N;
    cin>>N;
    vector<P> v(N);
    rep(i,N) cin>>v[i].first>>v[i].second;
    sort(v.begin(),v.end());
    vector<ll> y(N),Y(N);
    rep(i,N) y[i]=Y[i]=v[i].second;
    sort(y.begin(),y.end());
    rep(i,N){
      ll s = lower_bound(y.begin(),y.end(),Y[i])-y.begin()+1;
      Y[i] = s;
    }
    BIT B;
    vector<vector<ll>> cnt(N,vector<ll>(4));
    rep(i,N){
      cnt[i][1] = B.sum(Y[i]);
      B.add(Y[i],1);
    }
    BIT C;
    rep(i,N){
      cnt[N-i-1][2] = C.sum(Y[N-i-1]);
      C.add(Y[N-i-1],1);
    }
    rep(i,N){
      cnt[i][0] = i-cnt[i][1];
      cnt[i][3] = N-i-1-cnt[i][2];
    }
    ll al = pow(2LL,N,mod)-1;
    ll ans = 0;
    rep(i,N){
      ll t = 0;
      rep(j,4){
       t += (pow(2LL,cnt[i][j]+cnt[i][(j+1)%4],mod)-pow(2LL,cnt[i][j],mod))%mod;
      }
      ans = (ans + (al - t))%mod;
    }
    if(ans<0) ans += mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 26736
#include<iostream>
#include<vector> 
#include<string>
#include<algorithm>
#include<iomanip>
#include<queue>

using namespace std;

vector<vector<int> > to;
vector<int> c;
vector<bool> done;
vector<int> nodes;
vector<pair<int,int> > ab;
int nodecount;

queue<int> q;

/*

void bfs(int id)
{
	done[id]=true;	
	nodes[id]=c[nodecount];
	nodecount++;

//cout << id << endl;
		
	for(int i=0;i<to[id].size();i++)
	{
		int nxid=to[id][i];
		if(done[nxid]!=true)
			bfs(nxid);
	}

}

*/

void bfs(int id)
{
	q.push(id);
	while(!q.empty())
	{
		int now=q.front();q.pop();

		done[now]=true;
		nodes[now]=c[nodecount];
		nodecount++;
		for(int i=0;i<to[now].size();i++)
		{
			int nxid=to[now][i];
			if(done[nxid]!=true)
				q.push(nxid);
		}
	}
}

int val(void)
{
	int ans=0;
	for(int i=0;i<ab.size();i++)
		ans+=min(nodes[ab[i].first],nodes[ab[i].second]);
	return ans;
}

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

	to=vector<vector<int> >(n);
	
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		ab.push_back(make_pair(a,b));
		to[a].push_back(b);
		to[b].push_back(a);
	}
	c=vector<int>(n);
	for(int i=0;i<n;i++)
		cin >> c[i];
	sort(c.begin(),c.end());
	reverse(c.begin(),c.end());

	int ans=0;
	int ansid=0;

	for(int i=0;i<1;i++)
	{
		done=vector<bool>(n,false);
		nodes=vector<int>(n,0);
		nodecount=0;
		bfs(i);
		int tmp=val();
		if(tmp>ans)
		{
			ans=tmp;
			ansid=i;	
		}
	}


	cout << ans << endl;

	done=vector<bool>(n,false);
	nodes=vector<int>(n,0);
	nodecount=0;
	bfs(ansid);
	for(int i=0;i<n;i++)
		cout << nodes[i] << " ";
	cout << endl;



}

Measured memory_bytes: 1152
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 100
using namespace std;

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

  int n;
  cin >> n;
  int a[n], b[n], c[n], d[n];
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < n; i++){
    cin >> c[i] >> d[i];
  }

  tuple< int, int, string > all[2 * MAX_N];
  int sp = 0;
  for(int i = 0; i < n; i++){
    all[sp++] = make_tuple(a[i], b[i], "red");
  }
  for(int i = 0; i < n; i++){
    all[sp++] = make_tuple(c[i], d[i], "blue");
  }
  sort(all, all + 2 * n);

  int count = 0;
  bool exist[2 * n];
  fill(exist, exist + 2 * n, true);
  for(int i = 0; i < 2 * n; i++){
    if(get< 2 >(all[i]) == "blue"){
      int mx = -1;
      for(int j = i - 1; j >= 0; j--){
        if(exist[j] && 
            get< 2 >(all[j]) == "red" &&
            get< 1 >(all[j]) < get< 1 >(all[i]) &&
            (mx == -1 || get< 1 >(all[mx]) < get< 1 >(all[j]))){
          mx = j;
        }
      }
      if(mx != -1){
        exist[mx] = false;
        ++count;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
n,m=[int(i) for i in input().split()]
dp=[1,1] ;a=set() ; mod=(10**9+7)
for i in range(m):
    a.add(int(input()))
if 1 in a: dp[1]=0
for i in range(2,n+1):
    if i not in a:
        dp.append((dp[-1]+dp[-2])%mod)
    else:
        dp.append(0)
print(dp[-1])
    


Measured memory_bytes: 53084
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 4e5;
int t, n;
ll a[200];
string s;
int f(){
  cin >> n;
  FOR(i, 0, n) cin >> a[i];
  cin >> s;
  V<ll> v;
  FORR(i, n-1, 0){
    ll e = a[i];
    for(ll l:v) mins(e, e^l);
    if(!e) continue;
    if(s[i]-'0'){
      return 1;
    }else{
      v.pb(e);
    }
  }
  return 0;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> t;
  FOR(_, 0, t) cout << f() << endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    vector<int> res(N * N, 0), x(N * N);
    vector<P> a, b;
    for (int i = 1; i <= N; i++)
    {
        cin >> x[i];
        x[i]--;
        a.push_back(P(x[i], i));
        b.push_back(P(x[i], i));
        res[x[i]] = i;
    }
    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend());
    int idx = 0;
    for (int i = 0; i < N; i++)
    {
        // q を q - 1 個
        int q = a[i].second;
        for (int j = 0; j < q - 1; j++)
        {
            while (res[idx])
            {
                idx++;
            }
            res[idx] = q;
            idx++;
        }
    }
    idx = N * N - 1;
    for (int i = 0; i < N; i++)
    {
        // q を N - q 個
        int q = b[i].second;
        for (int j = 0; j < N - q; j++)
        {
            while (res[idx])
            {
                idx--;
            }
            res[idx] = q;
            idx--;
        }
    }
    bool f = true;
    // 1 <= i <= N に対し, x_i までに i が i 個
    vector<int> sum(N + 1, 0);
    idx = 0;
    for (int i = 0; i < N; i++)
    {
        int p = a[i].first, q = a[i].second;
        while (idx <= p)
        {
            sum[res[idx]]++;
            idx++;
        }
        if (sum[q] != q)
            f = false;
    }
    if (!f)
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    for (int i = 0; i < N * N; i++)
    {
        if (i == 0)
            cout << res[i];
        else
            cout << " " << res[i];
    }
    cout << endl;
}


Measured memory_bytes: 3200
// This is the start of  template//
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long int
#define double long long double
#define vll vector<int>
#define pb push_back
#define pll pair<int,int>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
void input(){
#ifndef ONLINE_JUDGE 
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout); 
#endif
}
#define INF LONG_LONG_MAX
#define mod 1000000007
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define cases int t; cin>>t; while(t--)
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  input();
  int n,ans= 0,max1=INT_MIN;
  cin>>n;
  array(a,n);
  rep(i,0,n)
  {
    max1 = max(max1 , a[i]);
     ans += max1 -a[i]; 
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4760
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
  int N = 0;
  int H = 0;
  int count =0;
  int preH = 0;
  int ans = 0;
  vector<int> ans_array;

  cin >> N;
  cin >> H;

  while(count < N-1){
    preH = H;
    cin >> H;

    if(H <= preH){
      ans++;
    }else{
      ans_array.pb(ans);
      ans = 0;
    }
    //printf("%d\n",ans);
    count++;
  }

  ans_array.pb(ans);
  ans = 0;
  ans = *max_element(ans_array.begin(),ans_array.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>

using namespace std;

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

    int matrix[3][3];
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            cin >> matrix[i][j];

    int n, x;
    cin >> n;

    for (int q = 0; q < n; q++)
    {
        cin >> x;

        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                if (matrix[i][j] == x)
                    matrix[i][j] = 0;
    }

    bool condition = false;

    for (int i = 0; i < 3; i++)
    {
        int sum = 0;

        for (int j = 0; j < 3; j++)
            sum += matrix[i][j];

        if (sum == 0) condition = true;
    }

    for (int j = 0; j < 3; j++)
    {
        int sum = 0;

        for (int i = 0; i < 3; i++)
            sum += matrix[i][j];

        if (sum == 0) condition = true;
    }

    int sum = 0;
    for (int i = 0; i < 3; i++)
        sum += matrix[i][i];
    if (sum == 0) condition = true;

    sum = matrix[0][2] + matrix[1][1] + matrix[2][0];
    if (sum == 0) condition = true;

    cout << ((condition) ? "Yes" : "No") << "\n";

    return 0;
}


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

using namespace std;

int main() {
    set<int> set;
    int n,q;
    int count = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        int s;
        cin >> s;
        set.insert(s);
    }
    cin >> q;
    for(int i = 0;i < q;i++){
        int t;
        cin >> t;
        for(int a : set){
            if(a == t)count++;
        }
    }
    cout << count << endl;
    return 0;
};


Measured memory_bytes: 3148
#include "iostream"
using namespace std;
int asb(int a){
  if(a<0){
    return(-1*a);
  }
  else{
    return(a);
  }
}
int main(){
  long long a;long long b;
  cin>>a>>b;
  long long d=(a+b)/2;
  if((asb(a-d))==(asb(b-d))){
    cout<<d<<endl;
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
  }


}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d; cin >> n >> d;
    int len = 2 * d + 1;
    cout << (n + len - 1) / len << endl;
    return 0;
}




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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){for(int i=0;i<n;i++) cin>>f[i];}

template<typename T,typename U>
void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];}
template<typename T,typename U>
void Printarray2(T f,U n){for(int i=0;i<n;i++) cout<<f[i]<<endl;}
template<typename T,typename U,typename V>
void Printarray3(T f,U a,V b){
  rep(i,a){
    rep(j,b){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}
template<typename T,typename U>
void Printarray4(T f,U n){
  rep(i,n){
    rep(j,n){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}

void flagfunc(bool flag,string A,string B){flag ? cout<<A<<endl : cout<<B<<endl;}
void flag2func(bool flag){flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;}
void flag3func(bool flag){flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,r;cin>>n>>r;
  n<10 ? cout<<r+100*(10-n)<<endl : cout<<r<<endl;
}

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

const long M = 1046527;
string H[M];

long getKey(string str){
    long sum = 0 , digit = 0 , p = 1;
    for (int i = 0; i < str.size() ; ++i) {
        if (str[i] == 'A') {
            digit = 1;
        } else if (str[i] == 'C') {
            digit = 2;
        } else if (str[i] == 'G') {
            digit = 3;
        } else if (str[i] == 'T') {
            digit = 4;
        } else digit = 0;
        sum += p * digit;
        p *= 5;
    }
    return sum;
}

long hash1(long x) { return x % M ; }
long hash2(long x) { return 1 +  x % (M - 1)   ;}

long insert(string str){
    long x =getKey(str);
    for (int i = 0;  ; i++) {
            long h = (hash1(x) +  i * hash2(x)) % M;
            if (H[h] == str) return 1;
            else if (H[h].size() == 0){
                H[h] = str;
                return 0;
            }
        }
    }



long find(string str){
    long x =getKey(str);
    for (int i = 0;  ; i++) {
        long h = (hash1(x) +  i * hash2(x)) % M;
        if (H[h] == str) return 1;
        else if (H[h].empty()) return 0;
    }
}

int main(){
    string str,com;
    int n;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> com >> str;
        if(com == "insert"){
            insert (str);
        } else if (com == "find") {
            if(find (str)){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 25876