akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,K;
	int A[200000];
	vint syurui;
	int sum[200001]={0};
	scan(N);scan(K);
	rep(i,N){
		scan(A[i]);
		sum[A[i]]++;
		if(sum[A[i]]==1) syurui.push_back(A[i]);
	}
	vint sumnum;
	rep(i,syurui.size()){
		sumnum.push_back(sum[syurui[i]]);
	}
	sort(sumnum.begin(),sumnum.end());
	//printf("%d %d\n",syurui.size(),sumnum.size());
	int kaeru=0;
	rep(i,(int)syurui.size()-K){
		//prin(i);
		kaeru+=sumnum[i];
	}
	prin(kaeru);
	return 0;
}


Measured memory_bytes: 4084
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int intN =0;
	static int sosuCnt =0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		String[] v = sc.nextLine().split(" ");

		int intN = Integer.parseInt(n);
		int intV[] = new int[intN];
		 for(int i = 0; i < v.length; i++){
			    intV[i] = Integer.parseInt(v[i]);
		 }

		Arrays.sort(intV);

		double result = 0;
		for (int i = 0; i < intV.length-1; i++) {
			if (i==0) {
				result = intV[0];
			}

			result = (result + intV[i+1])/2;
		}



		System.out.println(result);
	}
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define prev prev1
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R) {
	int val=rng() % R;
      assert(val>=0);
      return val;
}
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD1;

int a[105];
bool check[105];
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
           int x,n;
           cin>>x>>n;
           rep(i,1,n+1)cin>>a[i];
           rep(i,1,n+1)check[a[i]]=true;
           int min1=x+1;
           int num=-1;
           rep(i,0,105)
           {
                 if(check[i])continue;
                 if(min1>abs(i-x))
                 {
                       min1=abs(i-x);
                       num=i;
                 }
           }
           cout<<num<<endl;
      }      
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 5;
int n;

void solve(){
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    cout << (s + t[t.length() - 1] == t ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))

l = []
a.sort()

i = 0
num = 1
while i < len(a) - 1:
    if a[i+1] == a[i]:
        num += 1
        i += 1
    else:
        l.append(num)
        num = 1
        i += 1
l.append(num)

count = 0
for i in range(len(l)):
    if l[i] % 2 == 1:
        l[i] = 1
    else:
        count += 1
        l[i] = 1

if count % 2 == 0:
    print(sum(l))
else:
    print(sum(l) - 1)

Measured memory_bytes: 14276
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<P,ll>Q;


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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int m;
    if (a >= 13) m = b;
    else if (a >= 6 && a <= 12) m = b/2;
    else if (a <= 5) m = 0;

    cout << m << endl;


    return 0;
}


Measured memory_bytes: 888
bingo = []

for i in range(3):
    bingo.append(input().split(" "))

n = int(input())

for i in range(n):
    num = input()
    for j in range(3):
        for k in range(3):
            if num == bingo[j][k]:
                bingo[j][k] = 0

result = False

for i in range(3):
    if bingo[i][0] == 0 and bingo[i][1] == 0 and bingo[i][2] == 0:
        result = True
        
for i in range(3):
    if bingo[0][i] == 0 and bingo[1][i] == 0 and bingo[2][i] == 0:
        result = True

if bingo[0][0] == 0 and bingo[1][1] == 0 and bingo[2][2] == 0:
    result = True

if bingo[0][2] == 0 and bingo[1][1] == 0 and bingo[2][0] == 0:
    result = True

if result == True:
    print("Yes")
else:
    print("No")
    

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

#define ll long long
using namespace std;
int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void solve()
{
    int X;
    cin>>X;
    int g = gcd(X,360);
    cout<<360/g<<endl;
}

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

		
	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

int main()
{
	long N,K;
	cin >> N >> K;
	long A[N];
	long check[N];
	for(long i = 0; i< N; i++){
		cin >> A[i];
		check[i] = -1;
	}
	
	long now = 1;
	long count = 0;	
	long loop = 0;
	long no_loop = 0;
	long loop_times = 0;
	check[0] = 0;
	while(count < K){
		count++;
		now = A[now - 1];
//		cout << now << endl;
		if(check[now - 1] != -1) {
			loop = count - check[now - 1];
			no_loop = check[now - 1];
			loop_times =  (K - no_loop) % loop; 
				long now1 = 1;
				long count1 = 0;
				while(count1 < no_loop + loop_times){
					now1 = A[now1 - 1];
					count1++;
				}
					cout << now1 << endl;
					return 0;
				}
		else{
			check[now - 1] = count;
		}
	}
//	cout << tele << endl;
	

	cout << now << endl;
	
	return 0;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
typedef pair<int,int> P;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const vector<int> dy = {-1,0,1,0};
const vector<int> dx = {0,1,0,-1};

int main() {
    int d,g; cin >> d >> g;
    vector<P> problems(d);
    rep(i,d) cin >> problems[i].first >> problems[i].second;
    
    int ans = INF;
    for (int bit = 0; bit < 1<<d ; bit ++) {
        int tot = 0;
        int ret = 0;
        int left = -1;
        for (int i = 0; i < d;i ++) {
            if ((bit>>i)&1) {
                tot += 100 * (i + 1) * problems[i].first + problems[i].second;
                ret += problems[i].first;
            }
            else left = i;
        }

        if (tot >= g) {
            ans = min(ans,ret);
            continue;
        }

        if (tot + 100 * (left + 1) * (problems[left].first - 1) >= g) {
            int tmp = 100 * (left + 1);
            ret += (g - tot + tmp - 1)/tmp;
            ans = min(ans,ret);
        }
    }
    printf("%d\n",ans);
}

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

#define cp_io ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long int
#define oo 1000000010
#define MAX 1000000
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define nl "\n"

int main()
{
    cp_io;
    #ifndef ONLINE_JUDGE
    freopen("z_input.txt","rt",stdin);
    freopen("z_output.txt","wt",stdout);
    #endif
    ll n;
    cin >> n;
    
    ll a[n];
    ll sum = 0;
    unordered_map <ll,ll> m;

    for(int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
        m[a[i]]++;
    }
    
    ll q;
    cin >> q;
    while(q--)
    {
        ll b,c;
        cin >> b >> c;
        sum += m[b]*(c-b);
        m[c] += m[b];
        m.erase(b);
        cout << sum << nl;
        
    }
    return 0;
}

Measured memory_bytes: 7492
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
		string sUp = Console.ReadLine();
    string sDown = Console.ReadLine();
		long answer = n;

    for(int i = 0; i <= n; i++)
    {
      bool memo = true;
      for(int j = i; j < n; j++)
      {
        if(sUp[j] != sDown[j-i]) memo = false;
      }
      if(memo)
      {
        answer = n+i;
        break;
      }
    }

		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int n; cin >> n;
  string s; cin >> s;
  vi a(s.size()+1);
  rep(i,s.size()) if(s[i]=='.') a[i+1]++;
  rep(i,n) a[i+1] += a[i];

  int minv = inf;
  FOR(i,0,n+1){
    chmin(minv, a[n]-a[i]+(i-a[i]-a[0]));
  }
  cout << minv << endl;
}

Measured memory_bytes: 2180
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define mp make_pair
#define X first
#define Y second
#define INF 987654321
#define PI 3.14159265358979323846264
#define MOD 1000000007LL
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef complex<double> base;
ll POW(ll a, ll b) { if (b == 0)return 1; if (b == 1)return a; if (b & 1)return (a*POW(a, b - 1)) % MOD; ll t = POW(a, b / 2); return (t*t) % MOD; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };//동북남서
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

ll a[100000];
int n;
bool ok1(ll k)
{
	fup(i, 0, n - 1, 1)
	{
		ll t = k / a[i];
		k = a[i] * t;
	}
	return k >= 2;
}
bool ok2(ll k)
{
	fup(i, 0, n - 1, 1)
	{
		ll t = k / a[i];
		k = a[i] * t;
	}
	return k <= 2;
}
int main() {
	scanf("%d", &n);
	fup(i, 0, n - 1, 1)scanf("%lld", a + i);
	ll ans1 = -1, ans2 = -1;
	ll l = 2, r = 2000000000000000005;
	while (l <= r)
	{
		ll m = (l + r) / 2;
		if (ok1(m))r = m - 1;
		else l = m + 1;
	}
	ans1 = l;
	l = 2, r = 2000000000000000005;
	while (l <= r)
	{
		ll m = (l + r) / 2;
		if (ok2(m))l = m + 1;
		else r = m - 1;
	}
	ans2 = r;
	if (ans1 > ans2)
		puts("-1");
	else printf("%lld %lld", ans1, ans2);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define PB push_back
#define MP(x,y) make_pair(x,y)
#define SZ(x) (int)x.size()
#define F first
#define S second
#define ALL(x) x.begin(),x.end()
using namespace std;

typedef double DB;
typedef long double LDB;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<int,DB> pid;
typedef pair<DB,int> pdi;
typedef pair<DB,DB> pdd;

template<typename T>
inline bool getmin(T& a,const T& b) {return b < a? (a=b,true):false;}
template<typename T>
inline bool getmax(T& a,const T& b) {return b > a? (a=b,true):false;}
template<typename T>
inline bool inrange(const T& x,const T& L,const T& R) {return L<=x && x<=R;}

map<LL,LL> cnt;
const int maxn=1e5+5;
const int maxpc=3000+5;
int notprime[maxpc];
vector<LL> prime;
inline void getprime()
{
    LL up=sqrt(maxpc+0.5);
    for(LL i=2;i<=up;i++)
        for(LL j=i*i;j<maxpc;j+=i)  notprime[j]=1;
    for(LL i=2;i<maxpc;i++) if(!notprime[i]) prime.PB(i);
}
vector<pair<LL , LL > > showclass;
LL num[maxn];
vector<pii> fac[maxn];
int N;
inline void getallfac()
{
    for(const LL& p:prime)
        for(int i=0;i<N;i++)
        {
            if(num[i]%p==0)
            {
                LL t=0;
                while(num[i]%p==0) t++,num[i]/=p;
                fac[i].PB(MP(p,t));
            }
        }
    for(int i=0;i<N;i++) if(num[i]!=1)
    {
        LL possible=sqrt(num[i]+0.5);
        if(possible*possible==num[i]) fac[i].PB(MP(possible,2));
        else fac[i].PB(MP(num[i],1));
    }
}
int main()
{
    getprime();
    scanf("%d",&N);
    for(int i=0;i<N;i++) scanf("%lld",num+i);
    getallfac();
    for(int i=0;i<N;i++)
    {
        LL myclass=1,revclass=1;
        for(const auto& p:fac[i])
        {
            for(int j=0;j<(p.S%3);j++) myclass*=p.F;
            for(int j=0;j<(3-(p.S%3))%3;j++) revclass*=p.F;
        }
        cnt[myclass]++;

        if(myclass > revclass) swap(myclass,revclass);
        showclass.PB(MP(myclass,revclass));
    }
    
    sort(ALL(showclass));
    showclass.resize(unique(ALL(showclass)) - showclass.begin());

    LL ans=0;
    for(const auto& p:showclass)
    {
        if(p.F==1) ans+=(cnt[p.F]?1:0);
        else ans+=max(cnt[p.F],cnt[p.S]);
    }
    printf("%lld\n",ans);
}


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

typedef int64_t ll;

template <class T1, class T2>
using dict = std::unordered_map<T1, T2>;

int main(){
    ll A,B,K;
    cin >> A >> B >> K;
    cout << max(A-K,0L) << ' ' << min(B,max(A+B-K,0L)) << "\n";
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int d = sc.nextInt();
      int[][] array = new int[n][d];
      int count = 0;
      int sum = 0;
      for(int i = 0;i < n;i++) {
    	  for(int j = 0;j < d;j++) {
    		  array[i][j] = sc.nextInt();
    	  }
      }
      for(int i = 0;i < n;i++) {
    	  for(int k = 1;k < n-i;k++) {
    		  for(int j = 0;j < d;j++) {
    			  sum += (array[i][j]-array[i+k][j])*(array[i][j]-array[i+k][j]);
    		  }
    		  if(Math.sqrt(sum) == (int)Math.sqrt(sum)) count++;
        	  sum = 0;
    	  }
      }
      System.out.println(count);
      sc.close();
    }
}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0162

"""
import sys
from sys import stdin
from bisect import bisect_right, bisect_left
input = stdin.readline


def main(args):
    hammings = []

    temp = set()
    for i in range(21):
        for j in range(14):
            for k in range(9):
                ans = 2**i * 3**j * 5**k
                temp.add(ans)

    hammings = list(temp)
    hammings.sort()

    while True:
        try:
            m, n = map(int, input().split(' '))
        except ValueError:
            break

        s = bisect_left(hammings, m)
        t = bisect_right(hammings, n)

        print(t - s)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll mul(ll a,ll b){
	a%=mod;
	b%=mod;
	a=(a+mod)%mod;
	b=(b+mod)%mod;
	return (a%mod*b)%mod;
}
ll fpow(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1)ans=mul(ans,a);
		a=mul(a,a);
		b>>=1;
	}
	return ans%mod;
}
ll inv(ll x){
	return fpow(x,mod-2);
}
const ll p = (ll)1e9 + 7;
ll pow(ll a, ll b, ll m)
{
    ll ans = 1;
    a %= m;
    while(b)
    {
        if(b & 1)ans = (ans % m) * (a % m) % m;
        b /= 2;
        a = (a % m) * (a % m) % m;
    }
    ans %= m;
    return ans;
}
ll inv(ll x, ll p)//x关于p的逆元，p为素数
{
    return pow(x, p - 2, p);
}
ll C(ll n, ll m, ll p)//组合数C(n, m) % p
{
    if(m > n)return 0;
    ll up = 1, down = 1;//分子分母;
    for(int i = n - m + 1; i <= n; i++)up = up * i % p;
    for(int i = 1; i <= m; i++)down = down * i % p;
    return up * inv(down, p) % p;
}
ll Lucas(ll n, ll m, ll p)
{
    if(m == 0)return 1;
    return C(n % p, m % p, p) * Lucas(n / p, m / p, p) % p;
}

ll add(ll a,ll b){
	a=(a+mod)%mod;b=(b+mod)%mod;
	return (a+b+mod)%mod;
}
int main(){
	long long n,a,b;
	cin>>n>>a>>b;
	cout<<add(add(add(fpow(2,n),-1ll)%mod,-Lucas(n,a,mod))%mod,-Lucas(n,b,mod));
	return 0;
}


Measured memory_bytes: 256
n, m, x = gets.split.map(&:to_i)
ac = n.times.map{gets.split.map(&:to_i)}

c_sum = 0
sums = [0]*m
ac.each do |a|
  c_sum += a[0]
  (m).times do |i|
    sums[i] += a[i+1]
  end
end

if sums.any?{|v| v < x}
  puts -1
  exit
end

ans = 10**10
(1..n).each do |i|
  ac.combination(i).each do |as|
    sum = [0]*m
    c_sum = 0
    as.each do |a|
      c_sum += a[0]
      m.times do |j|
        sum[j] += a[j+1]
      end
    end
    if sum.all?{|v| v >= x}
      ans = c_sum if c_sum < ans
    end
  end
end

puts ans

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

const int MAX_N = 999999;
bool prime[MAX_N + 1];

void sieve()
{
  prime[0] = prime[1] = false;
  for(int i = 2; i <= MAX_N; ++i)
    prime[i] = true;
  for(int i = 2; i <= MAX_N; ++i)
    if(prime[i])
      for(int j = i * 2; j <= MAX_N; j += i)
	prime[j] = false;
}

int is_prime(int n)
{
  return prime[n];
}

int main()
{
  int n,i,ans; 

  while(cin >> n){
    sieve();
    for(i=1,ans=0;i<=n;i++)
      if(is_prime(i)) ans++;
    cout<<ans<<endl;
  }
}


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

int main() {
  
  int y,m,d;
  char c1,c2;
  cin >> y >> c1 >> m >> c2 >> d;
  
  if(m >= 5){
  cout << "TBD" <<endl;
  }
  else{
  cout << "Heisei" << endl;
  }
  

}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()

max = A[0]
ans = 0
for i in range(N):
    if A[i] > max:
        max = A[i]
    ans += max - A[i]
print(ans)

Measured memory_bytes: 96644
/// In the name of ALLAH
/// I'm THEOVE46
#include<bits/stdc++.h>
using namespace std;

#define gap             " "
#define nn              "\n"
#define pi              2*acos(0.0)
#define db              double
#define ft              float
#define ll              long long
#define ull             unsigned long long
#define pf              printf
#define sf              scanf
#define ff              first
#define ss              second
#define sc(n)           sf("%d",&n)
#define sc2(n, m)       sf("%d%d",&n,&m);
#define scl(n)          sf("%lld",&n)
#define scl2(n, m)      sf("%lld%lld",&n,&m);
#define pc(n)           pf("%d",n)
#define scf(f)          sf("%f",&f)
#define pcf(f)          pf("%f",f)
#define bfs             cin.get()
#define bfc             getchar()
#define gl(s)           getline(cin, s);
#define loop(a,n)       for(ll i=a; i<n; i++)
#define rloop(a,n)      for(ll i=a; i>n; i--)
#define tloop(test)     for(ll tl=1; tl<=test; tl++)
#define case1(z)        cout<<"Case "<<z<<": "
#define case2(z)        printf("Case %d: ",z)
#define vi              vector<int>
#define vl              vector<ll>
#define vld(vc,rw)      vector<vector<ll> >vc(rw)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define pis             pair<int,string>
#define psi             pair<string,int>
#define mls             map <ll,string>
#define msl             map <string,ll>
#define mll             map <ll,ll>
#define mp              make_pair
#define pb              push_back
#define itr             vector<int> :: iterator
#define sz(s)           s.size()
#define sl(s)           s.length()
#define Sort(s)         sort(s.begin(), s.end());
#define SortR(s)        sort(s.rbegin(), s.rend());
#define all(x)          x.begin(),x.end()
#define rall(x)         x.end(), x.begin()
#define MEM(ar,val)     memset(ar, (val), sizeof(ar))
#define IN(A,B,C)       assert(B<=A && A<=C)
#define EPS             1e-9
#define bug1            "**1**"
#define bug2            "****2****"
#define artri(b,h)      0.5*b*h
#define artrap(b1,b2,h) (b1+b2)/2*h
#define arcrl(r)        pi*r*r
#define vlsyl(r,h)      pi*r*r*h
#define vlcone(r,h)     pi*r*r*(h/3)
#define vlsph(r)        (4/3)*pi*r*r*r
#define flush           fflush(stdout);
#define pcn(dg,val)     fixed << setprecision(dg) << val
#define fap(x)          cout << __LINE__ << " says: " << #x << " = " << x << "\n"
#define FastIO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define showsort(n, a)  for(int i=0; i<n; i++) cout << a[i] << gap; cout << endl;

///THEOVE46

int main()
{
    FastIO;
    ll n, s=0, q, i, k, j, x, b, c;
    ll a[100004] = {0};
    cin >> n;
    for(i=0; i<n; i++)
    {
        cin >> x;
        a[x]++;
        s+=x;
    }
    cin >> q;
    while(q--)
    {
        cin >> b >> c;
        s += a[b]*c;
        s -= a[b]*b;
        a[c] += a[b];
        a[b] = 0;

        cout << s << endl;
    }
    return 0;
}

///   check for integer overflow, array bounds
///   check for n=1
///   - - - The Ove 46



Measured memory_bytes: 4412
N = int(input())
As = list(map(int, input().split()))
A2 = [abs(a) for a in As]
A2.sort()
cnt = 0
for a in As:
    if a< 0:
        cnt += 1
if cnt%2 == 0:
    print(sum(A2))
else:
    print(sum(A2[1:])-A2[0])
        

Measured memory_bytes: 14224
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int A[100000];
int int_counts[100000];
long long MOD = 1000000007;
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    long long ans = 1;
    for(int i = 0; i < N; i++){
        if(A[i] == 0){
            ans = (ans * (long long) (3 - int_counts[0])) % MOD;
        } else {
            ans = (ans * (long long) (int_counts[A[i] - 1] - int_counts[A[i]])) % MOD;
        }
        int_counts[A[i]] ++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    uint N; cin >> N;
    if(N%2==0){
        cout << N << endl;
    }else{
        cout << N*2 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=4000+10;

int n,A,B,ans[N];
int sta[N],top=0;

int query(int x,int y) {
	printf("? %d %d\n",x,y); fflush(stdout);
	char s[5]; scanf("%s",s);
	return s[0]=='Y';
}

int main() {
	A=read(),B=read(),n=A+B;
	if (A<=B) { puts("Impossible"); return 0; }
	for (int i=0;i<n;++i) {
		if (!top) sta[++top]=i;
		else {
			if (query(sta[top],i)) sta[++top]=i;
			else --top;
		}
	}
	for (int i=0;i<n;++i) {
		if (i==sta[top]) ans[i]=1;
		else ans[i]=query(sta[top],i);
	}
	printf("! ");
	for (int i=0;i<n;++i) putchar(ans[i]+'0');
	puts(""); fflush(stdout);
	return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int N;
  cin >> N;
  
  if (N == 0)
  {
    cout << 0 << endl;
    return 0;
  }

  vector<int> ans;
  for (int i = 0; i < 40; i++)
  {
    ans.push_back(mod(N, 2));
    N = (N - ans.at(ans.size() - 1)) / -2;
  }
  
  reverse(ans.begin(), ans.end());
  bool flg = false;
  for (int i = 0; i < ans.size(); i++)
  {
    if (!flg)
    {
      if (ans.at(i) == 1)
      {
        flg = true;
        cout << 1;
      }
    }
    else cout << ans.at(i);
  }
  cout << endl;
  
  for (int i = 0; i < ans.size(); i++)
  {
    cerr << ans.at(i);
  }
  cerr << endl;
}

Measured memory_bytes: 256
N, M, P = map(int, input().split())

edges = [[] for _ in range(N)]
edgesR = [[] for _ in range(N)]
E = []
for _ in range(M):
    fr, to, c = map(int, input().split())
    fr -= 1
    to -= 1
    E.append((fr, to, -(c - P)))
    edges[fr].append(to)
    edgesR[to].append(fr)

def dfs(edges, s):
    visited = [False] * N
    st = [s]
    visited[s] = True
    while st:
        for to in edges[st.pop()]:
            if not visited[to]:
                st.append(to)
                visited[to] = True
    return visited

canGo = dfs(edges, 0)
canBack = dfs(edgesR, N - 1)

minDist = [10**18] * N
minDist[0] = 0
for i in range(N + 1):
    for fr, to, c in E:
        d = minDist[fr] + c
        if minDist[to] > d:
            if i == N and canGo[fr] and canBack[to]:
                print('-1')
                exit()
            minDist[to] = d

print(max(0, -minDist[N - 1]))


Measured memory_bytes: 53480
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(void){
    ll ans=0;
    ll a,b;
    cin >> a >> b;
    if(b%a==0)ans=b+a;
    else ans=b-a;
    cout << ans << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>
#include<unordered_map>

#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8

#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	string s;
	cin>>s;
	int c=0;
	int ca=0;
	REP(i,n) {
		if(s[i]=='a') {
			if(c<a+b) {
				++c;
				printf("Yes\n");
			} else {
				printf("No\n");
			}
		}
		else if(s[i]=='b') {
			if(c<a+b&&ca<b) {
				++c;
				++ca;
				printf("Yes\n");
			} else {
				printf("No\n");
			}
		} else 	printf("No\n");
	}
}


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

string s[101];

int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> s[i];
	
	int a = 0;
	int flag = 1;
	for(int i=0; i<n; i++){
		if(s[i] == "A") a += 1;
		else if(s[i] == "Un")a -=1 ;
		
		if(a < 0) flag = 0;
	}
	if(a != 0) flag = 0;
	
	if(flag) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 3152
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n,m;
 
   cin >> n >> m;
  
   if(n<m){
     cout << 0 << endl;
   }else{
     cout << 10 << endl;
   }
   
   
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

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


Measured memory_bytes: 256
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout << setprecision(12)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); rep(w, 0, _t)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cntv(v,a) count(v.begin(),v.end(),a)
#define fans(x) \
    if ( x  ) coul("YES"); \
    else coul("NO")

struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod = 1000000007;
const ll mx =131080;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
//void segPre(ll l, ll h, ll in) {  ll segTree[3*mx];   if ( l == h ){  segTree[ in ] = arr[ l ];   return;  }   ll m = (l + h) / 2; pre(l, m, 2*in);  pre(m+1, h, 2*in+1);    segTree[ in ] = segTree[ in*2 ] | segTree[ in*2+1 ];   segTree[ in ] = segTree[ in*2 ] ^ segTree[ in*2+1 ];    }
// head collected
// Don't use variable name as --> prev, time, _t, w, y1


ll n, m, ara[10007], _, da;


start;
// op = 0 when n = even
    cin2(n, m);

    rep(i, 0, m){
        cin1(_);
        da += _;
    }


    if( n < da )
        coul("-1");
    else
        coul(n-da);

finish


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
bool solve(ll a, ll b, ll mid){
    if(mid < b){
        return true;
    }else{
        ll ana = ((mid + 1) / 2);
        ll bi = (mid + 2) / 2 + ((mid + 2) / 2 >= b ? 1 : 0);
        ll po = max(ana * bi, max((ana - 1) * (bi + 1), (ana + 1) * (bi - 1)));
        ll yo = (b + 1) * (mid - b + 1);
        if(max(po, yo) < a * b) return true;
        else return false;
    }
}
int main(){
    ll q;
    cin >> q;
    for(ll poyo = 0; poyo < q; poyo++){
        ll a, b;
        cin >> a >> b;
        if(a == b){
            cout << 2 * a - 2 << endl;
            continue;
        }
        if(a < b) a ^= b ^= a ^= b;
        ll low = 0, up = a + b - 2;
        while(up - low > 1){
            ll mid = (up + low) / 2;
            if(solve(a, b, mid)) low = mid;
            else up = mid;
        }
        cout << low << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

    string s; cin>>s;
    
    string t = "";
    for(int i=0; i<5; i++){
        t += "hi";
        if(t == s){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
# import math
# import statistics
# import itertools
# a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
N,A,B= map(int,input().split())
# f = list(map(int,input().split()))
# g = [input().split for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
count=0
ans=[]
for i in range(1,N+1):
    cal=[]
    for k in str(i):
        cal.append(int(k))

    if A<=sum(cal)<=B:
        ans.append(i)
        
print(sum(ans))
            


Measured memory_bytes: 9296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int n,m,l;
	cin >> n >> m >> l;
	vector<vector<ll>> A(n,vector<ll>(m)),
								B(m,vector<ll>(l)),
								ans(n,vector<ll>(l));

	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<m;j++)
		{
			cin >> A[i][j];
		}
	}

	for(int j=0;j<m;j++)
	{
		for(int k=0;k<l;k++)
		{
			cin >> B[j][k];
		}
	}

	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<l;j++)
		{
			for(int k=0;k<m;k++)
			{
				ans[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	for(int i =0 ;i<n;i++)
	{
		for(int j = 0;j<l;j++)
		{
			if(j)cout<<' ';
			cout<<ans[i][j];
		}
		cout<<endl;
	}


	return 0;
}


Measured memory_bytes: 3280
#include <stdio.h>
#include<math.h>
int sort(const void *a,const void *b){
return *(int*)b-*(int*)a;
}
int main(void)
{
int i;
int a;
char s[20];
scanf("%s",s);
for(i=strlen(s)-1;i>=0;i--){
	
	printf("%c",s[i]);
	
	
	
}
printf("\n");
return 0;
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d){
  cout <<"Left"<< endl;
  }
  else if(a+b<c+d){
    cout<<"Right"<<endl;
  }
  else{
    cout<<"Balanced"<<endl;
  }

    
    
}

Measured memory_bytes: 256
#include <stdio.h>

typedef unsigned long ulong;

static inline ulong diff(ulong a, ulong b){
    return __builtin_ctzl(a^b);
}

static inline void pl(long n){
#define L 8
    char c[L];
    long i=L-1;
    do{
        c[i]=n%10+'0';
        n/=10;
        i--;
    }while(n>0);
    for(i++;i<L;i++){
        putchar_unlocked(c[i]);
    }
}

#define N 17
long data[1<<N];

static void solve(long a, long b, const size_t sp, const size_t ep, long mask){
    if(ep-sp<=2){
        data[sp+0] = a;
        data[sp+1] = b;
        return;
    }
    const ulong d = diff(a, b);
    mask ^= (1<<d);
    const ulong ad = a&(1<<d);
    const ulong bd = b&(1<<d);
    a &= mask;
    b &= mask;
    const ulong ab = a ^ (mask&(-mask));
    const size_t mp = (sp+ep)/2;
    //printf("%ld %ld %ld\n", aa, ab, bb);
    solve(a, ab, sp, mp, mask);
    solve(ab, b, mp, ep, mask);
    for(size_t i=sp; i<mp; i++){ data[i] |= ad; }
    for(size_t i=mp; i<ep; i++){ data[i] |= bd; }
}

int main(void){
    long n, a, b;
    scanf("%ld %ld %ld", &n, &a, &b);
    if(__builtin_popcountl(a)%2 == __builtin_popcountl(b)%2){
        printf("NO\n");
        return 0;
    }
    solve(a, b, 0, 1<<n, 0xFFFFFFFFFFFFFFFF);
    const size_t m = 1<<n;
    printf("YES\n");
    for(size_t i=0; i<m-1; i++){
        pl(data[i]);
        putchar_unlocked(' ');
        //printf("%ld ", data[i]);
    }
    pl(data[m-1]);
    putchar_unlocked('\n');
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
	int H,p,c,f,l,b;
	int s[50];

	while(cin >> H){
		if(H==0){return 0;}

		p=0; b=-1;
		for(int i=0; i<50; i++){ s[i]=0;}
		for(int i=H-1; i>=0; i--){
			for(int j=0 ; j<5; j++){
				cin >> s[i*5+j];
			}
		}

		while(true){
			if(b==p){break;}
			b=p;
			for(int i=H-1; i>=0; i--){
				c=s[i*5+0]; l=1; f=0;
				for(int j=1 ; j<5; j++){
					if(c==s[i*5+j]){l++;}
					else if(l>=3){break;}
					else{ f=j; l=1; c=s[i*5+j];}
				}

				if(l>=3){
					for(int j=f ; j<l+f; j++){
						p+=s[i*5+j];
						s[i*5+j]=0;
					}
				}
			}

			for(int k=0; k<H-1; k++){		
				for(int i=H-1; i>0; i--){
					for(int j=0 ; j<5; j++){
						if(s[(i-1)*5+j]==0){
							s[(i-1)*5+j]=s[i*5+j];
							s[i*5+j]=0;
						}
					}
				}	
			}
		}
		cout << p << endl;
	}
}

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

int main() {
    ll a, b, c; cin >> a >> b >> c;
    if (4 * a * b < (c - a - b) * (c - a - b) && c - a - b > 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long ans=1e9,a[26]={},end[26]={},cnt=0;
  string s,alph="abcdefghijklmnopqrstuvwxyz";
  bool f=false;
  cin >> s;
  for(int i=0;i<26;i++){
    cnt=0;
    for(int j=0;j<s.size();j++){
      if(alph[i]!=s[j]){
        cnt++;
      }else{
        a[i]=max(a[i],cnt);
        end[i]=s.size()-j-1;
        cnt=0;
      }
    }
  }
  for(int i=0;i<26;i++){
    if(a[i]>0 or end[i]>0){
      ans=min(ans,max(a[i],end[i]));
      f=true;
    }
  }
  if(!f){
    ans=0;
  }
  cout << ans << endl;
  return 0; 
}

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

using namespace std;

typedef long long int ll;
 
template<class T> inline bool chmax(T& a,T b){ if(a<b){ a=b; return true;} return false; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){ a=b; return true;} return false; }
 
typedef pair<int,int> pair;

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

  if(s=="ABC") puts("ARC");
  else puts("ABC");
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
   

    int n,m,k;
    cin>>n>>m>>k;

    

    vector<int> xy[n+1];
    int row[n+1]={0},col[m+1]={0};

    ffor(i,0,k)
    {
        int x,y;
        cin>>x>>y;
        row[x]++;
        col[y]++;
        xy[x].pb(y);
    }
    int ans=0;
    set<pair<int,int>> s;
    ffor(i,1,m+1) s.insert({col[i],i});

    ffor(i,1,n+1)
    {
        for(auto y:xy[i])
        {
            s.erase({col[y],y});
            s.insert({col[y]-1,y});
        }
        auto it=s.end();
        it--;
       // cout<<i<<" "<<row[i]<<" "<<it->first<<" "<<it->second<<endl;
        ans=max(ans,it->first+row[i]);
        for(auto y:xy[i])
        {
            s.erase({col[y]-1,y});
            s.insert({col[y],y});
        }
    }
    cout<<ans;

    
    return 0;
}

/*




*/



Measured memory_bytes: 36440
#include<bits/stdc++.h>
#define pi pair<int,int>
#define F first
#define S second
using namespace std;
int main()
{
	int m,n,a,b,ans=0;
	cin>>m>>n;
	priority_queue<pi> q;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		q.push(pi(-a,-b));
	}
	while(q.size()>1)
	{
		int x1=0-q.top().F,y1=0-q.top().S;
		q.pop();
		int x2=0-q.top().F,y2=0-q.top().S;
		q.pop();
		if(y1<x2)
		{
			cout<<0;
			return 0;
		}
		q.push(pi(-x2,-min(y1,y2)));
	}
	ans=q.top().F-q.top().S+1;
	cout<<ans;
	return 0;
} 

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

int main()
{
  int N;
  cin >> N;
  
  char S[N][4];
  for(int i = 0; i < N; i++)
  {
      cin >> S[i];
  }
  vector<int> cnt(4);
  cnt.at(0) = 0;
  cnt.at(1) = 0;
  cnt.at(2) = 0;
  cnt.at(3) = 0;
  
  int j = 0;
  while(S[j][0] != '\0')
  {
    if(S[j][0] == 'A' && S[j][1] == 'C')
    {
      cnt.at(0)++;
    }
    if(S[j][0] == 'W' && S[j][1] == 'A')
    {
      cnt.at(1)++;
    }
    if(S[j][0] == 'T' && S[j][1] == 'L' && S[j][2] == 'E')
    {
      cnt.at(2)++;
    }
    if(S[j][0] == 'R' && S[j][1] == 'E')
    {
      cnt.at(3)++;
    }
    j++;
  }
  
  cout << "AC x " << cnt.at(0) << endl;
  cout << "WA x " << cnt.at(1) << endl;
  cout << "TLE x " << cnt.at(2) << endl;
  cout << "RE x " << cnt.at(3) << endl;
}

Measured memory_bytes: 3984
INF = 10**9
def solve(h, w, s):
    dp = [[INF] * w for r in range(h)]
    dp[0][0] = int(s[0][0] == "#")
    for r in range(h):
        for c in range(w):
            for dr, dc in [(-1, 0), (0, -1)]:
                nr, nc = r+dr, c+dc
                if (0 <= nr < h) and (0 <= nc < w):
                    dp[r][c] = min(dp[r][c], dp[nr][nc] + (s[r][c] != s[nr][nc]))
    return (dp[h-1][w-1] + 1) // 2

h, w = map(int, input().split())
s = [input() for r in range(h)]
print(solve(h, w, s))


Measured memory_bytes: 9236
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL X;
LL A[111];

void MAIN() {
    scanf("%d%lld", &N, &X);
    REP (i, N) scanf("%lld", A+i);

    sort(A, A+N);
    int ans = 0;
    REP (i, N) {
	if (X >= A[i]) {
	    ans++;
	    X -= A[i];
	}
    }

    if (ans == N && X > 0) ans--;
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 888
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N = 1e6+10;
const double eps = 0.00000001;
const ll mod = 1e9 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[N];
int main(){
    int k = read(),n = read();
    rep(i,1,n) a[i] = read();
    sort(a+1,a+n+1);
    int M = INF;
    rep(i,1,n-1){
        M = min(M,a[i]+(k-a[i+1]));
    }
    rep(i,2,n){
        M = min(M,k-a[i]+a[i-1]);
    }
    M = min(M,a[n]-a[1]);
    cout<<M;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <array>
#include <algorithm>

using namespace std;

int main() {
    string s;
    int count = 0;
    bool flag = false;
    int Max = 0;
    cin >> s;

    for(int i = 0; i < (int)(s.length()); i ++) {
        for(int j = i; j < (int)(s.length()); j ++){
            flag = false;
            for(int k = i; k <=  j; k ++) {
                if (!(s[k] == 'A' || s[k] == 'C' || s[k] == 'G' || s[k] == 'T')) {
                    flag = true;
                }
            }
            if(!flag) Max = max(Max,j-i+1);
        }
    }
    cout << Max;
    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define F first
#define int long long int
#define S second
#define boost ios_base::sync_with_stdio(false),cin.tie(NULL);
const int MOD = 998244353;
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp>  
//using namespace __gnu_pbds; 
//stringstream ss; string temp; ss<<str(original string) ss>>temp;

int32_t main()
{   
    boost
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    int n; cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans+=(a[i]*a[j]);
        }
    }
    cout<<ans<<endl;
    return 0;
} 


Measured memory_bytes: 384