akhauriyash/Code-Regression huggingface dataset:
import math
j,f,h,m=map(int,input().split())
df=6*m
dh=m/2+30*h
d=0
if df>dh:
  d=df-dh
else:
  d=dh-df
l=(j**2+f**2-2*j*f*math.cos(math.radians(d)))**0.5
print(l)


Measured memory_bytes: 9564
#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() {
    string s;
    cin >> s;
    string ans = "No";
    
    string before = s;
    reverse(s.begin(), s.end());
    string after = s;
    
    int len = (s.length() - 1) / 2;
    string half = s.substr(0, len);
    string half_before = half;
    reverse(half.begin(), half.end());
    string half_after = half;
    
    
    
    if ((before == after) && (half_before == half_after)) ans = "Yes";
    cout << ans << endl;
}

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

int Partition(int, int);

int A[100000];

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

  scanf("%d",&n);
  if( n<1 || 100000<n ) exit(0);

  for( i=0 ; i<n ; i++ ){
    scanf("%d",&A[i]);
    if( A[i]<0 || 100000<A[i] ) exit(1);
  }

  standard = Partition(0, n);

  for( i=0 ; i<n ; i++ ){
    if( i==n-1 ){
      printf("%d\n",A[i]);
    }
    else if( i==standard ){
      printf("[%d] ",A[i]);
    }
    else{
      printf("%d ",A[i]);
    }
  }
  
  return 0;
}

int Partition(int p, int r){
  int i, j, x, tmp;

  x = A[r-1];
  i = p-1;

  for( j=0 ; j<r-1 ; j++ ){
    if( A[j] <= x ){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  
  tmp = A[i+1];
  A[i+1] = A[r-1];
  A[r-1] = tmp;

  return i+1;
}

Measured memory_bytes: 988
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <chrono>
#include <bitset>
using namespace std;

class Timer {
	chrono::high_resolution_clock::time_point start, end;
	double limit;

public:
	Timer() {
		start = chrono::high_resolution_clock::now();
	}
	Timer(double l) {
		start = chrono::high_resolution_clock::now();
		limit = l;
	}

	double getTime() {
		end = chrono::high_resolution_clock::now();
		return chrono::duration<double>(end - start).count();
	}

	bool Over() {
		if (getTime() > limit) {
			return true;
		}
		return false;
	}

	void setLimit(double l) {
		limit = l;
	}
	void setStart() { start = chrono::high_resolution_clock::now(); }
	double getLimit() { return limit; }
};


class Xor128 {
	unsigned static int x, y, z, w;
public:
	Xor128() {
		x = 31103110, y = 123456789, z = 521288629, w = 88675123;
	}

	unsigned int rand()
	{
		unsigned int t;
		t = (x ^ (x << 11)); x = y; y = z; z = w;
		return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
	}
};
unsigned int Xor128::x, Xor128::y, Xor128::z, Xor128::w;

int H, W;
char GRID[12][12];

int ni = -1, nj = -1;

void swapGRID(int m, int i, int j) {
	if (m) {
		for (int k = 0; k < H; k++)swap(GRID[k][i], GRID[k][j]);
	}
	else {
		for (int k = 0; k < W; k++)swap(GRID[i][k], GRID[j][k]);
	}
}
bool is_() {
	bool flag = true;

	for (int i = 0; flag && i < H; i++) {
		for (int j = 0; flag && j < W; j++) {
			if (GRID[i][j] != GRID[H - 1 - i][W - 1 - j]) {
				ni = i, nj = j;
				flag = false;
			}
		}
	}
	return flag;
}

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) {
		char c; cin >> c;
		GRID[i][j] = c;
	}

	if (H == 1 && W == 1) {
		cout << "YES" << endl;
		return 0;
	}

	Timer tmr;

	Xor128 rnd;
	int loop = 0;
	while (1) {
		if (loop % 100000 == 0) {
			if (tmr.getTime()>1.9)break;
		}

		int m, i, j;
		m = rnd.rand() % 2;
		if (H == 1)m = 1;
		if (W == 1)m = 0;

		if (m) {
			if(nj==-1)i = rnd.rand() % W;
			else i = nj;
			do {
				j = rnd.rand() % W;
			} while (i == j);
		}
		else {
			if (ni == -1)i = rnd.rand() % H;
			else i = ni;
			do {
				j = rnd.rand() % H;
			} while (i == j);
		}


		swapGRID(m, i, j);
		if (is_()) {
			cout << "YES" << endl;
			return 0;
		}

		loop++;
	}
	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#define INF ((int)1e9)
using namespace std;
int N;
vector<int> line;
vector<int> gop;
vector<int> dp;
set<int> f;
queue<int> que;
int func(int place){
	if(line[place] == 0)return gop[place] = place;
	if(f.count(place) > 0)return -1;
	if(gop[place] != INF)return gop[place];
	f.insert(place);
	return gop[place] = func(place + line[place]);	
}
/*
int func2(int place,int time){
	if(used[place])return INF;
	used[place] = true;
	if(place == N - 1)return time;
	if(dp[place] >= 0)return dp[place];
	int res = INF;
	for(int i=place+1,I=min(N,place+7);i<I;++i){	
		if(gop[i] == -1)continue;
		res = min(res, func2(gop[i], time + 1));	
	}
	used[place]=false;
	return dp[place] = res;
}
*/
int main(){
	cin >> N;
	line.resize(N);
	for(int i=0;i<N;++i){
		cin >> line[i];
	}	
	gop.resize(N, INF);
	for(int i=0;i<N;++i){	
		func(i);
		f.clear();
	}
	dp.resize(N, -1);
	que.push(0);
	dp[0] = 0;
	while(!que.empty()){
		int place = que.front();que.pop();
		for(int i=place+1,I=min(N,place+7);i<I;++i){
			if(dp[gop[i]] >= 0)continue;
			dp[gop[i]] = dp[place] + 1;
			que.push(gop[i]);
		}
	}
	cout << dp.back() << endl;	
	return 0;
}



Measured memory_bytes: 10140
#include<stdio.h>
#define N 100000
typedef struct {
  int parent,left,right;
}jeep;
jeep A[N];
int main(){
  int total,i,j,a,b,son,di,count,c,d;
  scanf("%d",&total);
  for(i=0;i<total;i++){
    A[i].parent=-1;
    A[i].left=-1;
    A[i].right=-1;
  }
  for(i=0;i<total;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      if(j==0){
        scanf("%d",&son);
        A[a].left=son;
        A[son].parent=a;
      }
      else{
        scanf("%d",&son);
        A[di].right=son;
        A[son].parent=a;
      }
      di=son;
    }
  }
  for(i=0;i<total;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",A[i].parent);
    c=i;
    count=0;
    while(1){
      if(A[c].parent==-1)break;
      c=A[c].parent;
      count++;
    }
    printf("depth = %d, ",count);
    if(A[i].parent==-1){
      printf("root, ");
    }
    else if(A[i].left==-1&&A[i].parent!=-1){
      printf("leaf, ");}
    else{
      printf("internal node, ");
    }
    printf("[");
    if(A[i].left!=-1){
      printf("%d",A[i].left);
      d=A[i].left;
      while(1){
        if(A[d].right==-1)break;
        printf(", %d",A[d].right);
        d=A[d].right;
      }
    }
    printf("]\n");
  }
  return 0;
}


Measured memory_bytes: 2876
#include <stdio.h>

int main(void){

int a, b, c, x;

scanf("%d %d %d", &a, &b, &c);

if (a > b){
x = a;
a = b;
b = x;
}
if (b > c){
x = b;
b = c;
c = x;
}
if (a > b){
x = a;
a = b;
b = x;
}
printf("%d %d %d\n", a, b, c);
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    ll A, B, K;
    cin>>A>>B>>K;
    if(A>=K){
        cout << A-K << " " << B << endl;
    } else if(B>=K-A){
        cout << 0 << " " << B+A-K << endl;
    }else {
        cout << 0 << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b;
	cin>>a>>b;
	if(a>=13){
		cout<<b;
	}
	else if(a>=6){
		cout<<(b/2);
	}
	else cout<<"0";
	return 0;
}


Measured memory_bytes: 256
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n;
    cin >> n;
    ll a[n], s = 0;
    rep(i, n){
        cin >> a[i];
        s += a[i];
    }
    ll ans = INT_MAX, ss = 0;
    rep(i, n){
        ss += a[i];
        ll pk = s-ss;
        ans = min(ans, abs(pk- ss));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
import time
import re
import math
import fractions

def main():
    global s
    s=input()
    print(hoge(0,"",0))
def hoge(index,now,total):
    global s
    if(index==len(s)):return total+int(now)
    if index==0:
        return hoge(index+1,now+s[index],total)
    else:
        return hoge(index+1,now+s[index],total)+hoge(index+1,s[index],total+int(now))
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global N,A,B,C,D,memo,mx,mn,temp



Measured memory_bytes: 5300
import itertools
import math
import fractions
import functools
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
goke = sum(a)
for i in range(n):
    if b[i] > a[i]:
        a[i+1] -= (b[i]-a[i])
        if a[i+1] < 0:
            a[i+1] = 0
        a[i] = 0
    else:
        a[i] -= b[i]

print(goke - sum(a))

Measured memory_bytes: 107616
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

string lcs(string s1, string s2) {
    string ret;
    int n = s1.length(), m = s2.length();
    vector<vector<int> > dp(n+1, vector<int>(m+1));
    for(int i = 0; i < n; i++) {
        dp[i][0] = 0;
    }
    for(int i = 0; i < m; i++) {
        dp[0][i] = 0;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(s1[i-1] == s2[j-1]) {
                dp[i][j] = 1 + dp[i-1][j-1];
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    int i = n, j = m;
    while(ret.length() < dp[n][m]) {
        while(dp[i][j] == dp[i][j-1]) j--;
        while(dp[i][j] == dp[i-1][j]) i--;
        ret.push_back(s2[j-1]);
        i--;
        j--;
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    cout << lcs(s1, s2);
    return 0;
}


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

using namespace std;
#define int long long
signed main(){
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin>>n;
	int x=n/2;
	double ans=1.0*(x+1)/n;
	if(n%2==0)cout<<0.500000;
	else cout<<ans;
	return 0;
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	int a,b,c;
  cin >> a >> b >> c;
  if(a == b && a != c){
    cout << "Yes";
  }else if(b == c && c != a){
    cout << "Yes";
}else if(c == a && a != b){
  cout << "Yes";
}else{
  cout << "No";
}
cout << endl;
}

Measured memory_bytes: 3588
#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;
    cin >> n;

    vector<vector<int>> nex(n);
    vector<vector<int>> cost(n);
    vector<int> ans(n);
    rep(i,n) ans[i]=-1;
    rep(i,n-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--; v--;
        w=w%2;
        nex[u].push_back(v);
        cost[u].push_back(w);
        nex[v].push_back(u);
        cost[v].push_back(w);
    }

    /*
    cout << "graph" << endl;
    rep(i,n){
        cout << i <<endl;
        cout << "to ";
        for(auto& sub: nex[i]) cout << sub << " ";
        cout << endl;
        cout << "w  ";
        for(auto& sub: cost[i]) cout << sub << " ";
        cout << endl;
    }
    */
    stack<int> next_list;
    stack<int> weight;
    next_list.push(0);
    weight.push(0);
    while(!next_list.empty()){
        int now;
        int temp;
        now = next_list.top();
        next_list.pop();
        temp = weight.top();
        weight.pop();
        if(ans[now]!=-1) continue;
        /*
        cout << "v " << now << " ";
        cout << "w " << temp << endl;;
        */
        if(temp==0) ans[now]=0;
        else ans[now]=1;
        for(auto& sub:nex[now]) next_list.push(sub);
        for(auto& sub:cost[now]){
            int e;
            e = (temp + sub)%2;
            weight.push(e);
        }

    }
    //cout << "ans" << endl;
    rep(i,n) cout << ans[i]  << endl;

}

Measured memory_bytes: 11904
S=input()

T=S.count("C")

if S[0]!="A":
    print("WA")

elif "C" in S[2:-1] and T==1 :
    S2=S.replace("A", "")
    S2=S2.replace("C" , "")
    if S2.islower() :
        print("AC")
    else:
        print("WA")
    
else:
    print("WA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll m;
    cin >>m;
    
    cout << 48 - m << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();

        int sum = (L-1) * N + N*(N+1)/2;


        if(L>=0){
            System.out.println(sum-L);
        }else{
            System.out.println(sum-Math.min(L+N-1,0));
        }


    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using llong = long long;

void fnInput(int& rnLimit, vector<llong>& rvnCostA, vector<llong>& rvnCostB)
{
  int nCostASiz, nCostBSiz;
  cin >> nCostASiz >> nCostBSiz >> rnLimit;
  rvnCostA.resize(nCostASiz + 1);
  rvnCostB.resize(nCostBSiz + 1);

  for (int i = 1; i < rvnCostA.size(); i++)
  {
    int nOneCost;
    cin >> nOneCost;
    rvnCostA[i] = rvnCostA[i - 1] + nOneCost;
  }

  for (int i = 1; i < rvnCostB.size(); i++)
  {
    int nOneCost;
    cin >> nOneCost;
    rvnCostB[i] = rvnCostB[i - 1] + nOneCost;
  }
}

int fnMaxSelCnt(int nLimit, const vector<llong>& cnrvnCostA, 
                            const vector<llong>& cnrvnCostB)
{
  int nMaxSelCnt = 0;
  int nBgnB = cnrvnCostB.size() - 1;
  int nxA = 0;

  while (nxA < cnrvnCostA.size()  &&
         cnrvnCostA[nxA] <= nLimit   )
  {
    int nxB = nBgnB;

    while (cnrvnCostB[nxB] > nLimit - cnrvnCostA[nxA])
      nxB--;

    nMaxSelCnt = max(nMaxSelCnt, nxA + nxB);
    nBgnB = nxB;

    nxA++;
  }
  return nMaxSelCnt;
}
 
int main()
{
  int nLimit;
  vector<llong> vnCostA, vnCostB;

  fnInput(nLimit, vnCostA, vnCostB);
  cout << fnMaxSelCnt(nLimit, vnCostA, vnCostB) << endl;

  return 0;
}

Measured memory_bytes: 6436
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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













int main(){
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
}

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

int main() {
  int n;
  cin >> n;
  cout << n*n*n << endl;
}


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

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

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 

fast;

ll a,b,n;
cin>>a>>b>>n;

if(n<b)
{
    ll a1=a*n/b;
    ll a2=n/b;
    a2*=a;
    cout<<a1-a2<<endl;
}

else
{
    ll z=n/b;
    z*=b;
    z--;

    ll a1=a*z/b,a2=z/b;
    a2*=a;
    cout<<a1-a2<<endl;
}


}

Measured memory_bytes: 3584
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.MathContext

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)
    val W = BigDecimal(sc.nextInt())
    val H = BigDecimal(sc.nextInt())
    val x = BigDecimal(sc.nextInt())
    val y = BigDecimal(sc.nextInt())
    var manyAnswerFlg = 0
    if(x == W.divide(BigDecimal(2), MathContext.DECIMAL128) && y == H.divide(BigDecimal(2), MathContext.DECIMAL128)){
        manyAnswerFlg = 1
    }

    println((W * H).divide(BigDecimal(2), MathContext.DECIMAL128))
    println(manyAnswerFlg)
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< int, int > Pi;
typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const double DINF = 5e14, eps = 1e-10;
//const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

ll MOD=998244353;

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

vector< long long >FACT;
vector< long long >IFACT;
int N;
	
long long extgcd(long long a,long long b, long long &x,long long &y) {
		long long g = a;
		x = 1;
		y = 0;
		if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
		return g;
}

long long invMod(long long a, long long m) {
		long long x, y;
		if (extgcd(a, m, x, y) == 1) return (x + m) % m;
		else                         return 0;
}

long long mod_pow(long long x, long long n) {
		long long res = 1;
		while (n > 0) {
			if (n & 1) res = res * x%MOD;
			x = x * x%MOD;
			n >>= 1;
		}
		return res;
}
	
void inverse(int n) {
		N = n;
		FACT.resize(N + 1);
		IFACT.resize(N + 1);
		FACT[0] = 1;
		IFACT[0] = 1;
		for (int i = 1;i <= N;i++) {
			FACT[i] = FACT[i - 1] * i % MOD;
			IFACT[i] = invMod(FACT[i], MOD);
		}
}
	
long long combi(int n, int r) {
		if (n < 0 || r < 0 || r > n)return 0;
		if (r > n / 2)r = n - r;
		return FACT[n] * IFACT[n - r] % MOD*IFACT[r] % MOD;
}


ll cul(int n,int r){
	return combi(n+r-1,r);
}

int k,n;
ll two[5010];

int main() {
	cin>>k>>n;
	inverse(5010);
	two[0]=1;
	for(int i=1;i<=4000;i++){
		two[i]=two[i-1]*2;
		two[i]%=MOD;
	}
	for(int i=2;i<=2*k;i++){
		int p=0,l=0;
		for(int j=1;j<=k;j++){
			if(j>i-j)break;
			if(i-j<=k)p++;
		}
		ll ans=0;
		if(i%2==0)l=k-p*2+1;
		else l=k-p*2;
		if(i%2==1){
		for(int j=0;j<=p;j++){
			ll c=combi(p,j)*two[j]%MOD;
			c=c*combi(n-j+j+l-1,n-j)%MOD;
			ans+=c;
			ans%=MOD;
			}
		}
		else{
			for(int j=0;j<p;j++){
			ll c=combi(p-1,j)*two[j]%MOD;
			c=c*combi(n-j+j+l-1,n-j)%MOD;
			ll d=combi(p-1,j)*two[j]%MOD;
			d=d*combi(n-1-j+j+l-1,n-1-j)%MOD;
			ans+=c+d;
			ans%=MOD;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
/* imp functions
ARRAYS AND STRINGS
	sorting arrays - sort(array,array+n);
	finding size of string - str.length();

VECTORS:
	assign() – It assigns new value to the vector elements by replacing old ones
	push_back() – It push the elements into a vector from the back
	pop_back() – It is used to pop or remove elements from a vector from the back.
	insert() – It inserts new elements before the element at the specified position
	erase(v.begin()+i) – It is used to remove elements from a container from the specified position or range.
	swap() – It is used to swap the contents of one vector with another vector of same type. Sizes may differ.
	clear() – It is used to remove all the elements of the vector container
	emplace() – It extends the container by inserting new element at position
	emplace_back() – It is used to insert a new element into the vector container, the new element is added to the end of the vector
	v.reverse(v.begin(),v.end()) - reversing vector
	v.size() - finding size of vector
	v.sort(v.begin(),v.end()) - sorting vectors
	find(v.begin() , v.end() , element) - finding element in given vector in order n
	lower_bound(v.begin() , v.end() , element) - returns pointer pointing to element equal to or greater than the given element
 	upper_bound(v.begin() ,v.end() , element) -returns pointer pointing to element greater than the given element
*/

/* Properties of modulo:Fermat's little theorem
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define ll long long 
#define pb push_back
#define gcd __gcd
// checking whether a number is prime or not
bool compare(ll x, ll y){
    return x>y;
}
// checking whether a number is prime or not
ll isprime(ll n){
    if(n==1) return 0;
    else if(n==2) return 1;
    else{
        for(ll i=2;i<=sqrt(n);i++){
            if(n%i==0) return 0;
        }
    return 1;   
    }
}
// returning vector containing all prime numbers less than a given number
vector<ll> get_prime_factors_less_than(ll n){
    vector<ll> factor;
    vector<ll> prime(n,1);
    prime[0]=0,prime[1]=0;
    for(ll i = 2 ; i <= n ; i++){
        if(prime[i]==1){
            for(ll j=i*i;j<=n;j=j+i) prime[j]=0; 
            factor.push_back(i);
        }
    }
    return factor;
}
//returning vector containing index refering to elements of normal array after sorting it
vector<ll> retain_index(ll arr[], ll n){ 
    vector<pair<ll, ll> > vp; 
    for (ll i = 0; i < n; ++i) { 
        vp.push_back(make_pair(arr[i], i)); 
    } 
    sort(vp.begin(), vp.end());
    vector<ll> retain;
    for (ll i = 0; i < vp.size(); i++) { 
        ll a = vp[i].second;
        retain.pb(a);
    }
    return retain;
}
//returns x^y in order logn 
ll power(ll x, ll y) 
{ 
    if (y == 0) return 1; 
    ll a = power(x,y/2);
    if (y % 2 == 0) return a * a; 
    else return x * a * a; 
} 
int main(){
    IOS;
    ll n , m;
    cin>>n>>m;
    ll a = (n*(n-1))/2;
    ll b = (m)*(m-1)/2;
    cout<<a+b<<endl;

}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >>n;
	
	vector<VI> ck(n, VI(n, 9));
	rep(i, n){
		int a, x, y;
		cin >>a;
		rep(j, a){
			cin >>x >>y;
			ck[i][x-1] = y;
		}
	}
	int ans = 0;
	rep(i, 1<<n){
		bool ok = 1;
		rep(j, n) if(i>>j &1){
			rep(k, n){
				if(ck[j][k] ==9) continue;
				if((i>>k &1) && ck[j][k] !=1) ok=0;
				if(!(i>>k &1) && ck[j][k] !=0) ok=0;
			}
		}
		if(ok) ans = max(ans, __builtin_popcount(i));
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		// reverse(a.begin(),a.end());
		// n=s.length();
		ll a,b,d;
		cin>>a>>b>>c>>d;
		// ll a[n];
		n=(b/c)-((a-1)/c);
		m=(b/d)-((a-1)/d);
		j=c*d/__gcd(c,d);
		k=(b/j)-((a-1)/j);
		i=n+m-k;
		c=b-a+1-i;
		cout<<c;
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
using namespace std;
int n;
double dp[301][301][301];

double solve(int x, int y, int z){
  if(x<0 || y<0 || z<0)
    return 0.0;
  if(x==0&&y==0&&z==0)
    return 0.0;
  if(dp[x][y][z] > -0.9)
    return dp[x][y][z];
  double exp = n + x*solve(x-1,y,z) + y*solve(x+1,y-1,z) + z*solve(x,y+1,z-1);

  return dp[x][y][z] = exp/(x+y+z);
}

int main(){
  cin>>n;
  int x,y,z;
  x = y = z = 0;
  memset(dp, -1, sizeof(dp));
  for(int i=0;i<n;i++){
    int t;
    cin>>t;
    if(t==1)
      x++;
    else if(t==2)
      y++;
    else
      z++;
  }
  //cout<<solve(x,y,z)<<endl;
  cout<<fixed<<setprecision(10)<<solve(x,y,z)<<endl;
  return 0;
}

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

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


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

void solve()
{
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		if (n % i == 0)
			ans += n / i - 1;
		else
			ans += (n / i);
	}
	cout << ans << endl;
}

signed main()
{
	fasterthanlight;
	int T; T = 1;
	//cin>>T;
	while (T--)
	{
		solve();
	}

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
  vector<int> v = {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 << v.at(k-1) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{

    public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      	long H = sc.nextInt();
        long W = sc.nextInt();

        long sum = 0;
      	
        if(H == 1 || W == 1){
        	sum = 1;	
        }
      	else{
	      	long base1 = W / 2 + W % 2;
    	  	long base2 = (W -1)/2 + (W - 1) % 2;
      	
      		sum = (H / 2) *(base1 + base2) + (H % 2)*base1;	
        }
      
        System.out.println(sum);
    }
}

Measured memory_bytes: 25300
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int a, b;
	char op;

	cin >> a >> op >> b;
	if (op == '+')
		cout << a + b;
	else
		cout << a - b;

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=(s);i<(t);++i)
#define per(i,s,t) for(int i=((t)-1);i>=s;--i)
#define repb(i,s,t) for(int i=(s);i<=(t);++i)
#define lepb(i,s,t) for(int i=(s);i>=(t);--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define mst(a,b) memset(a,b,sizeof(a))
#define dd(x) cout<<#x<<'='<<x<<' '
#define de(x) cout<<#x<<'='<<x<<'\n'
#define fi first
#define se second
#define sq(x) ((x)*(x))
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int inf = 0x3f3f3f3f;
const ll inff = 4557430888798830399ll;
const db eps = 1e-10;
const db pi = acos(-1.0);
const ll mod = 1e9+7;

#define maxn 100005
bool vis[maxn];

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,a,b,o;vector<pii> v;ll s,A,B;
	s=A=B=0;mst(vis,0);o=0;
	cin>>n;
	rep(i,0,n){cin>>a>>b;v.pb({a,i});v.pb({b,i});A+=a;B+=b;}
	sort(all(v));
	rep(i,0,n)
	{
		s+=v[i].fi;
		if(vis[v[i].se])o=1;
		else vis[v[i].se]=1;
	}
	if(!o)
	{
		if(v[n-1].se!=v[n].se)s=s-v[n-1].fi+v[n].fi;
		else s=min(s-v[n-1].fi+v[n+1].fi,
					s-v[n-2].fi+v[n].fi);
	}
	cout<<min(s,min(A,B))<<endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;
const double PI = 3.14159265358979323846;

ll wari(ll a)
{

    ll i = 1;

    int count = 0;

    while (i * i <= a)
    {

        if (a % i == 0)
        {

            count++;

            if (i * i != a)
            {

                count++;
            }
        }

        i++;
    }

    return count;
}

int main()
{
    int N;

    cin >> N;

    ll ans = 0;


    int i=1;

    while(i<N){

        int sub = N/i;


        int count = min(sub,i);


        int k_max = count; 


         if(N==k_max*i){

            k_max--;
        }




        count= k_max*2;



        if(k_max==i){

            count--;
        }


        ans+=count;
        i++;



    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
 int s;
 int m;
 int h;

 cin >> s;

 m = s / 60;
 s = s % 60;
 h = m / 60;
 m = m % 60;

 cout << h << ":" << m << ":" << s << endl;

}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>

int main(){
  int n;
  std::cin >> n;
  std::vector<long> a(n);
  for(int i = 0; i < n; i++) std::cin >> a.at(i);
  std::vector<long> b;
  for(int i = n-1; i >= 0; i -= 2){
    b.push_back(a.at(i));
  }
  for(int i = n%2; i < n; i += 2){
    b.push_back(a.at(i));
  }
  for(int i = 0; i < n; i++){
    if(i != n-1) std::cout << b.at(i) << " ";
    else std::cout << b.at(i) << std::endl;
  }
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    rep (i, n)
        cout << s[i] << t[i];
    cout << endl;

    return 0;
}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

void solve(){
	int l;
	cin>>l;
	double ans = (l/3.0)*(l/3.0)*(l/3.0);
	cout<<setprecision(10)<<fixed<<ans<<endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

vector<int> kyousitsu;
vector<int> A;
int N;
int main()
{

    cin >> N;

    kyousitsu.assign(N, 0);
    A.assign(N, 0);

    rep(i, N)
    {
        cin >> A[i];
    }

    rep(i, N)
    {
        kyousitsu[A[i] - 1] = i + 1;
    }

    rep(i, N)
    {
        cout << kyousitsu[i] << " ";
    }
}

Measured memory_bytes: 1536
n, x = map(int,input().split())
xl = list(map(int,input().split()))

xl.append(x)
xl.sort()

onesam = 0

if len(xl) == 1:
    print(abs(xl[0] - x))
    exit()

for i in range(len(xl)-1):
    one_sa = xl[i+1] - xl[i]
    if onesam == 0:
        onesam = abs(one_sa)
    else:
        short,big = min(onesam,one_sa),max(onesam,one_sa)
        if big % short == 0:
            onesam = short
            continue
        else:
            while big % short != 0:
                short = short -1
#                 for k in range(2,short+1):
#                     if short % k == 0:
#                         short = short // k
#                         break
            onesam = short
            
print(onesam)

Measured memory_bytes: 14224
import sys
import numpy as np
input = sys.stdin.readline

N, M = map(int,input().split())
li = list(map(int, input().split()))

answer = np.ones(N)

for x in range(M):
  A, B = map(int,input().split())
  if li[A-1] > li[B-1]:
     answer[B-1] = 0
  elif li[B-1] > li[A-1]:
     answer[A-1] = 0
  else:
     answer[A-1] = 0
     answer[B-1] = 0

print('{:.0f}'.format(sum(answer)))

Measured memory_bytes: 38760
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
ll nod(ll n) 
{ 
    return floor(log10(n) + 1); 
}  
ll pfact(ll n)
{
	ll cnt=0;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			cnt++;
			while(n%i==0)
			{
				n=n/i;
			}
		}
	}
	if(n!=1) cnt++;
	return cnt;
}
bool isprime(ll n)
{
	ll ch=true;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)ch=false;
	}
	return ch;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin>>s>>t;
	t.pop_back();
	if(s==t)cout<<"Yes\n";
	else cout<<"No\n";	
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>  // pow, sqrt, sin, cos
using namespace std;


bool _isZero(double x) {
  const double epsilon = 1e-10;
  if (abs(x) < epsilon) return true;
  else return false;
}


int main() {
  int X;
  cin >> X;
  assert(X >= 1);
  assert(X <= 179);

  const double PI = 3.14159265358979323846;
  const int TIMEOUT = 100000000;
  double x;
  double y;
  // const double denom = 2 * (1 - cos(X*PI/180));
  for (int k = 1; k < TIMEOUT; k++) {
    x = 1 + cos(k*X*PI/180) - cos((k+1)*X*PI/180) - cos(X*PI/180);
    y = 0 + sin(k*X*PI/180) - sin((k+1)*X*PI/180) + sin(X*PI/180);
    // cout << "k, (x, y): " << k + 1 << ", (" << x << ", " << y << ")" << endl;
    if (_isZero(x) && _isZero(y)) {
      cout << k + 1 << endl;
      return 0;
    }
  }
  return -1;
}


Measured memory_bytes: 3956
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<(a-c)*(b-d);

}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int a[1000];
	int i;

	scanf("%d", &n);

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

	/* DENIEDと出力するのは、偶数かつ、3または5の倍数以外の数字が存在するときのみ */
	for (i = 0; i < n; i++)
	{
		if (a[i] % 2 == 0)
		{
			if (a[i] % 3 != 0 && a[i] % 5 != 0)
			{
				printf("DENIED\n");
				return 0;
			}
		}	
	}
	
	printf("APPROVED\n");

	return 0;
}

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

int main(){
    ll X; cin >> X;
    ll m = 100;
    int n = 0;
    while(1){
        n++;
        m = m * 1.01;
        if(m >= X){
            cout << n << endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;

int g1[81][81];
int g2[81][81];
bool dp[81][81][10000];


int main() {
	int H, W;
	cin>>H>>W;
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g1[i][j];
		}
	}
	
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g2[i][j];
		}
	}
	
	dp[0][0][abs(g1[0][0] - g2[0][0])] = true;

	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			for (int k = 0;k <= 6400;++k) {
				if (dp[i][j][k]) {
					dp[i][j+1][abs(k - abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i][j+1][abs(k + abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i+1][j][abs(k - abs(g1[i+1][j] - g2[i+1][j]))] = true;
					dp[i+1][j][abs(k + abs(g1[i+1][j] - g2[i+1][j]))] = true;
				}
			}
		}
	}
	
	for (int i = 0;i <= 6400;++i) {
		if (dp[H-1][W-1][i]) {
			cout<<i<<endl;
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 63744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,i0,n) for(int i=i0;i<n;++i)
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define INF12 1000000000000 //10^12
#define INF9 1000000000 //10^9
#define MOD 10000007 //10^9+7


int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, int> counts;
    rep(i,0,N) {
        ll a;
        // cin >> A.at(i);
        cin >> a;
        counts[a]++;
    }
    int ans = 0;
    for(auto x:counts) {
        int c = x.second;
        if(c%2) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <string>
using namespace std;
typedef long long ll;

ll inf9 = 1000000000, inf12 = 1000000000000;

int main(void){
    ll n, C, d[35][35], c[505][505], mod3[3][35];
    cin >> n >> C;
    
    for (int i = 1; i <= C; i++) mod3[0][i] = mod3[1][i] = mod3[2][i] = 0;
    
    for (int i = 0; i < C*C; i++) cin >> d[i/C+1][i%C+1];
    for (int i = 0; i < n*n; i++) {
        cin >> c[i/n+1][i%n+1];
        mod3[(i/n + i%n+2) % 3][c[i/n+1][i%n+1]]++;
    }
    
    ll best[3][3];
    for (int i = 0; i < 9; i++) best[i/3][i%3] = 999999999;
    
    for (int i = 0; i < 3; i++) {
        for (int j = 1; j <= C; j++) {
            ll dif = 0;
            for (int k = 1; k <= C; k++) {
                dif += mod3[i][k] * d[k][j];
            }
            dif += 1e12 * j;
            
            if (dif % inf9 < best[i][0] % inf9) {
                best[i][2] = best[i][1];
                best[i][1] = best[i][0];
                best[i][0] = dif;
            }
            else if (dif % inf9 < best[i][1] % inf9){
                best[i][2] = best[i][1];
                best[i][1] = dif;
            }
            else if (dif % inf9 < best[i][2] % inf9){
                best[i][2] = dif;
            }
        }
    }
    
    ll mn = 1e18;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                ll tmp;
                if (best[0][i] / inf12 == best[1][j] / inf12 || 
                best[1][j] / inf12 == best[2][k] / inf12 || 
                best[2][k] / inf12 == best[0][i] / inf12) tmp = 1e18;
                else {
                    tmp = best[0][i] % inf9 + best[1][j] % inf9 + best[2][k] % inf9;
                }
                mn = min(tmp, mn);
            }
        }
    }
    
    cout << mn << endl;
    
    /*
    for (int i = 1; i <= C; i++) {
        cout << mod3[0][i] <<" "<< mod3[1][i] <<" "<< mod3[2][i] << endl;
    }
    
    cout << best[0][0] <<" "<< best[1][0] <<" "<< best[2][0] << endl;
    cout << best[0][1] <<" "<< best[1][1] <<" "<< best[2][1] << endl;
    cout << best[0][2] <<" "<< best[1][2] <<" "<< best[2][2] << endl;
    cout << best[0][0] + best[1][0] + best[2][0] << endl;*/
    
    
}


Measured memory_bytes: 2176
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n,h,i,j,ct=0;
		cin>>n>>h;
		for(i=0;i<n;i++){
			cin>>j;
			ct+=(j>=h);
		}
		cout<<ct;
	}
	return 0;
}	

Measured memory_bytes: 256
import re
n=int(input())
a=list(map(int,input().split()))
change_num=0
flag=True
while(flag):
	flag=False
	for i in range(n-1):
		if(a[i] > a[i+1]):
			a[i],a[i+1] = a[i+1],a[i]
			change_num+=1
			flag=True
print(re.sub("[\[\]\,]","",str(a)))
print(change_num)


Measured memory_bytes: 6548