akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int n, num[4];
double dp[310][310][310];

double dfs(int a, int b, int c) {
  if(a==0&&b==0&&c==0) return 0;
  if(dp[a][b][c]>=0) return dp[a][b][c];
  int sum = a + b + c;
  dp[a][b][c] = 1.0*n/sum;
  if(a>0) dp[a][b][c] += dfs(a-1,b,c)*a/sum;
  if(b>0) dp[a][b][c] += dfs(a+1,b-1,c)*b/sum;
  if(c>0) dp[a][b][c] += dfs(a,b+1,c-1)*c/sum;
  return dp[a][b][c];
}


int main() {
  memset(dp,-1,sizeof(dp));
  cin >> n;
  rep(i,n) {
    int x;  cin >> x;
    num[x]++;
  }
  printf("%.10f\n", dfs(num[1],num[2],num[3]));
  return 0;
}

Measured memory_bytes: 236552
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n;
	int loger = 4280;
	while(1){
		cin >> n;
		int sum = 1150;
		int b = 125;
		if(n == -1)break;
		n++;
		rep(i, n-11){
			if(i == 10)b = 140;
			if(i == 20)b = 160;
			sum += b;
		}
		cout << loger - sum << endl;;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int n; cin >> n;
    vector<vector<int>> e(n);
    rep(i, n) {
        int id; cin >> id; id--;
        int ne; cin >> ne;
        rep(j, ne) {
            int tn; cin >> tn; tn--;
            e[id].emplace_back(tn);
        }
    }

    queue<int> q;
    vector<int> aa(n);
    vector<int> d(n);
    q.emplace(0);
    aa[0] = 1;

    while(!q.empty()) {
        int nn = q.front();
        q.pop();
        rep(i, e[nn].size()) {
            if (aa[e[nn][i]]) continue;
            q.emplace(e[nn][i]);
            d[e[nn][i]] = d[nn] + 1;
            aa[e[nn][i]] = 1;
        }
    }
    rep(i, n) {
        if (aa[i]) {
            cout << i+1 << " " << d[i] << endl;
        } else {
            cout << i+1 << " " << -1 << endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 3164
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 0;
    for(int i = 0; i < n; i++) {
      int l = sc.nextInt();
      int r = sc.nextInt();
      ans += (r - l + 1);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 27728
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

struct Wside{
	int vertex;
	int weight;
	Wside(int a, int b){
		vertex=a; weight=b;
	}
};

vector<Wside>* info;
vector<int> scanned;
int n;
int minimum;

bool isScanned(int v){
	for(int i=0,sz=scanned.size(); i<sz; ++i){
		if(v==scanned[i]) return 1;
	}
	return 0;
}

int scan(){
	int temp_min=100000;
	int temp_v = 0;
	for(int i=0, sz=scanned.size(); i<sz; ++i){
		int s=scanned[i];
		for(int j=0, sz2=info[s].size(); j<sz2; ++j){
			if(isScanned(info[s][j].vertex)){
				continue;
			}
			temp_min = temp_min<info[s][j].weight? temp_min: info[s][j].weight;
			temp_v = temp_min<info[s][j].weight? temp_v: info[s][j].vertex;
		}
	}

	minimum += temp_min;
	scanned.push_back(temp_v);
	return 0;
}

int main()
{
	scanf("%d",&n);
	info = new vector<Wside> [n];

	int temp;
	for(int i=0; i<n; ++i){
		for(int j=0; j<n; ++j){
			scanf("%d",&temp);
			if(temp!=-1){
				info[i].push_back(Wside(j, temp));
			}
		}
	}

	scanned.push_back(0);
	while(scanned.size()!=n){
		scan();
	}
	cout << minimum << endl;

	delete[] info;

	return 0;
}



Measured memory_bytes: 3288
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	double r;
	cin >> r;

	cout << fixed << setprecision(20) <<  r * 2 * acos(-1) << endl;
}

Measured memory_bytes: 3772
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n int
	fmt.Fscan(r, &n)

	A := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &A[i])
	}

	shellSort(A, n)
}

func insertionSort(A []int, n int, g int) int {
	cnt := 0
	for i := g; i < n; i++ {
		v := A[i]
		j := i - g
		for j >= 0 && A[j] > v {
			A[j+g] = A[j]
			j = j - g
			cnt++
		}
		A[j+g] = v
	}
	return cnt
}

func shellSort(A []int, n int) {
	cnt := 0

	G := []int{}
	for i := 1; i <= n; i = 3*i + 1 {
		G = append(G, i)
	}
	m := len(G)
	fmt.Println(m)

	Gstr := []string{}
	for i := len(G) - 1; i >= 0; i-- {
		Gstr = append(Gstr, strconv.Itoa(G[i]))
	}
	fmt.Println(strings.Join(Gstr, " "))

	for i := 0; i < m; i++ {
		cnt += insertionSort(A, n, G[m-i-1])
	}
	fmt.Println(cnt)

	for _, a := range A {
		fmt.Println(a)
	}

}



Measured memory_bytes: 17460
import math

raw_input = input()
l = raw_input.split()
A = int(l[0])
B = int(l[1])

A_min = math.ceil((A*100)/8)
A_maxlim = math.floor(((A+1)*100)/8)

#print(str(A_min)+","+str(A_maxlim))

B_min = math.ceil((B*100)/10)
B_maxlim = math.floor(((B+1)*100)/10)

#print(str(B_min)+","+str(B_maxlim))

if A_min <= B_min and B_min < A_maxlim:
    print(B_min)
elif B_min <= A_min and A_min < B_maxlim:
    print(A_min)
else:
    print("-1")

Measured memory_bytes: 3064
n, m = map(int, input().split())
a = [[0] * m for i in range(n)]
b = [0] * m
for i in range(n):
	a[i] = list(map(int, input().split()))
for j in range(m):
	b[j] = int(input())
for i in range(n):
	s = 0
	for j in range(m):
		s += a[i][j] * b[j]
	print(s)




Measured memory_bytes: 5952
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())
 
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
 
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
 
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
 
constexpr ll INF = TEN(18);
const int MX = 3010;
 
ll dp[MX][MX][4];
ll v[MX][MX];
 
int main() {
    int R, C, K;
    cin >> R >> C >> K;
    rep(i, K) {
        int r, c, val;
        cin >> r >> c >> val;
        --r, --c;
        v[r][c] = val;
    }
 
    rep(i, MX) rep(j, MX) rep(k, 4) dp[i][j][k] = -INF;
    dp[0][0][0] = 0;
 
    rep(i, R) {
        rep(j, C) {
            for (int k = 2; k >= 0; --k) {
                if (dp[i][j][k] >= 0) {
                    chmax(dp[i][j][k + 1], dp[i][j][k] + v[i][j]);
                }
            }
            rep(k, 4) {
                if (dp[i][j][k] >= 0) {
                    if (i + 1 < R) {
                        chmax(dp[i + 1][j][0], dp[i][j][k]);
                    }
                    if (j + 1 < C) {
                        chmax(dp[i][j + 1][k], dp[i][j][k]);
                    }
                }
            }
        }
    }
 
    ll ans = -INF;
    rep(k, 4) chmax(ans, dp[R - 1][C - 1][k]);
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 357224
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int n;
string w[105];
bool vis[26];
map<string,int>s;
int main(){
	cin>>n;
	bool f=true;
	for(int i=1;i<=n;++i){
		cin>>w[i];
		if(s[w[i]])f=false;
		s[w[i]]=1;
	}
	for(int i=2;i<=n;++i){
		if(w[i-1][w[i-1].size()-1]==w[i][0])continue;
		f=false;
	}
	if(f)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll N;cin >>N;
    ll L[15],ma=0,sum=0;
    rep(i,N){
        cin >> L[i];
        if(L[i]>ma){
            ma=L[i];
        }
        sum+=L[i];
    }
    cout << (sum-ma>ma ? "Yes" :"No") <<  endl;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
string str;

vector<int> G[300];
bool visited[300];
int key;

bool solve(int pos,int prev){
  if(pos==key&&visited[pos])return true;
  if(visited[pos])return false;
  visited[pos]=true;

  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(prev==to)continue;
    if(solve(to,pos))return true;
  }
  return false;
}

int solve(){
  for(int i=1;i<=100;i++){
    memset(visited,0,sizeof(visited));
    key=i;
    if(solve(i,-1))return 1;
  }
  return 0;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>str>>b;
    if(str=="lock"){
      G[a].push_back(100+b);
    }else{
      G[100+b].push_back(a);
    }
  }
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto&& V : v)
#define all(x) (x).begin(), (x).end()
using lint = long long;
const int INF = 1 << 29;
const double EPS = 1e-9;
using namespace std;

int main(void) {
  string s;
  cin >> s;
  vector<pair<string, int>> vec{{"dream", 5}, {"dreamer", 7}, {"erase", 5}, {"eraser", 6}};
  set<string::iterator> set;
  set.insert(s.begin());
  string ans = "NO";
  while (!set.empty()) {
    auto pos = *set.begin();
    set.erase(pos);
    int left = s.end() - pos;
    if (!left) {
      ans = "YES";
      break;
    }
    allrep(V, vec) {
      if (left >= V.second && equal(all(V.first), pos)) {
        set.insert(pos + V.second);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(a == b && b == c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(void)
{
	int n;
	char prime[50000] = {0};
	int i, j;
	
	for (i = 2; i < 50000; i++){
		prime[i] = 1;
	}
	for (i = 2; i < sqrt(50000); i++){
		if (prime[i] == 1){
			for (j = i * 2; j < 50000; j += i){
				prime[j] = 0;
			}
		}
	}
	scanf("%d", &n);
	while (n != 0){
		int count = 0;
		
		for (i = 2; i <= n / 2; i++){
			for (j = n - i; i + j <= n; j++){
				if ((prime[i] & prime[j]) == 1 && i + j == n){
					count++;
					break;
				}
			}
		}
		printf("%d\n", count);
		
		scanf("%d", &n);
	}
	
	return 0;
}

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

int main(){
    string S;
    long long K;
    cin >> S >> K;
    
    long long count = 0; 
    while(1){
        if(S.substr(count, 1) == "1") count++;
        else break;
    }
    if (K <= count) cout << "1" << endl;
    else cout << S.substr(count, 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		String S = sc.get();
		if (S.contains("RRR")) {
			System.out.println(3);
		} else if (S.contains("RR"))
		{
			System.out.println(2);
		} else if (S.contains("R")){
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

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

int n, m;
int match[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
vector<int> a;
int dp[100001];
int parent[100001];
int picked[100001];
vector<int> result;

bool comp(const int& a, const int& b) {
    return a > b;
}

int solution(int n) {
    if (n == 0) {
        return 0;
    }
    
    int& ret = dp[n];
    if (ret != -1) {
        return ret;
    } else {
        for (int i = 0; i < m; i++) {
            if (n - match[a[i]] < 0) continue;
            if (ret < solution(n - match[a[i]]) + 1) {
                ret = solution(n - match[a[i]]) + 1;
                parent[n] = n - match[a[i]];
                picked[n] = a[i];
            }
        }
        return ret;
    }
}

void backtrack(int n) {
    if (parent[n] == -1) {
        return;
    }
    
    backtrack(parent[n]);
    result.push_back(picked[n]);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    cin >> n >> m;
    a.resize(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    
    sort(a.begin(), a.end(), comp);
    
    memset(dp, -1, sizeof(dp));
    memset(parent, -1, sizeof(parent));
    memset(picked, -1, sizeof(picked));
    
    solution(n);
    
    backtrack(n);
    
    sort(result.begin(), result.end(), comp);
    for (auto it : result) cout << it;
    cout << '\n';
    
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
vector<int> v[100005];
bool vis[100005];
int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=1;i<=m;i++){
		scanf("%d%d", &a[i], &b[i]);
		v[a[i]].push_back(b[i]);
	}
	int ans = 0;
	int mn = 1e9;
	for(int i=1;i<=n;i++){
		if(mn == i){
			ans++;
			mn = 1e9;
		}

		for(int j=0;j<v[i].size();j++){
			mn = min(mn, v[i][j]);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  
  cout << A.at(N - 1) - A.at(0) << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX



 
void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int diff = 0;
    rep(i,0,n-1)
    {
        int j = i+1;
        while(1)
        {
            int d = j-i;
            int k = j+d;
            if(k>=n)
                break;
            if(s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i])
                diff--;
            j++;
        }

        map<int,int> mp;
        rep(j,i,n-1)
            mp[s[j]]++;
        int ans = (mp['R']*mp['G']*mp['B'])/mp[s[i]];
        diff += ans;
    }

    cout <<diff << endl;


}


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

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



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

  vector<long long> LucasNumber(N+1);
  for(int i = 0; i <= N; i++){
    if(i == 0)
      LucasNumber.at(0) = 2;
    else if(i == 1)
      LucasNumber.at(1) = 1;
    else
      LucasNumber.at(i) = LucasNumber.at(i-1) + LucasNumber.at(i-2);
    }

    cout << LucasNumber.at(N) << endl;
}

Measured memory_bytes: 256
n,t = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]
ans = 1001
for i,j in l:
  if t >= j:
    ans = min(ans,i)
if ans == 1001:
  print("TLE")
else:
  print(ans)
  

Measured memory_bytes: 2940
#include <algorithm>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <fstream>
#include <math.h>

using namespace std;

int main(void)
{
	int k, s;
	cin >> k >> s;
	int count = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s-x-y;
			if (z >= 0 && z <= k)
				count++;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){

	while(1){
		int a; cin >> a;
		if(a == 0) return 0;
		a = 1000 - a;

		int ans = 0;

		ans += a/500;
		a %= 500;
		ans += a/100;
		a %= 100;
		ans += a/50;
		a %= 50;
		ans += a/10;
		a %= 10;
		ans += a/5;
		a %= 5;
		ans += a;

		cout << ans << endl;
	}

}



Measured memory_bytes: 3008
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	long long x,y;
	cin>>x>>y;
	
	long long g = __gcd(x,y);
	cout<<x*y/g;
	
	return 0;
}


Measured memory_bytes: 3616
A, B, C = map(int, input().split())
ans = 0

while 1:
	if A % 2 == 1:
		break
	if B % 2 == 1:
		break
	if C % 2 == 1:
		break
	a = B / 2 + C / 2
	b = A / 2 + C / 2
	c = A / 2 + B / 2
	ans += 1
	if a == A and b == B and C == c:
		ans = -1
		break
	else:
		A = a
		B = b
		C = c
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

#define pb push_back
#define mp make_pair

int n;

int  dfs(vector<vector<int> >& edges, int x, vector<int>& dp){
	if(dp[x] != -1){
		return dp[x];
	}
	int ans = 0;
	int total = edges[x].size();
	for(int i = 0;i < total;i++){
		ans = max(ans, 1 + dfs(edges, edges[x][i], dp));
	}
	dp[x] = ans;
	return dp[x];
}

int main(void){
	int m;
	// n - verices, m - edges
	cin >> n >> m;
	vector<int> dp(n,-1);
	vector<vector<int> > edges(n);
	int x, y;
	for(int i = 0;i < m;i++){
		cin >> x >> y;
		edges[x-1].pb(y-1);
	}
	for(int i = 0;i < n;i++){
		if(dp[i] == -1){
			dp[i] = dfs(edges, i, dp);
		}
	}
	int ans = 0;
	for(int i = 0;i < n;i++){
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9472
N, X = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

ans = 0

fl = True
for i in range(N):
  if A[i] <= X:
    ans += 1
    X -= A[i]
  else:
    fl = False
    break
    
if fl and X > 0:
  ans -= 1
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    long long sum = 0;

    for (int i = 0; i < N; ++i)
    {
        cin >> A.at(i);
        sum += A.at(i);
    }

    int ans = 0;
    
    for (int i = 0; i < N; ++i){
        if( A.at(i)*4*M >= sum){
            ans++;
        }
    }

    if( ans >= M ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

        return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int N;
    cin >>N;
    int a[N],b[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    for(int i=0;i<N;i++){
        cin >> b[i];
    }
    int sum=0;
    for(int i=0;i<N;i++){
        if(a[i]>b[i]) sum = sum + a[i]-b[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import numpy as np

n= int(input())
a = np.array(list(map(int, input().split())))
q = int(input())
actions = []
for i in range(q):
  actions.append(list(map(int, input().split())))

numbers = [0]*10**5
ans = a.sum()
a_unique, a_freq = np.unique(a,return_counts=True)
for i in range(len(a_unique)):
  numbers[a_unique[i]-1] = a_freq[i]

for action in actions:
  if numbers[action[0]-1] != 0:
    tmp = numbers[action[0]-1]
    numbers[action[0]-1] = 0
    numbers[action[1]-1] += tmp
    ans = ans -tmp*(action[0]-action[1])

  print(ans)

Measured memory_bytes: 51484
object Main{
  def main(args: Array[String]){
    if (sys.env.getOrElse("TEST", "")=="1"){

    }else{
      val input=io.Source.stdin.getLines().mkString("\n")
      println(solve(input).toString.trim());
    }
  }


  def solve(input:String):Int ={
    val nums = input.split(" ").map(_ .toInt)
    val times = nums(2)/nums(0)
    nums(1) * times 
  }
}

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

using namespace std;

#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using i64 = long long;
using iip = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

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

template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

const i64 M = 1e9 + 7;
const int INF = 1e9 + 1;

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

    string s,t;
    while (read(s, t)) {
        int n = s.size();
        int m = t.size();
        
        bool ok = false;
        for (int i = n - 1; i >= 0; i--) {
            int cc = 0;
            forn(j, m) {
                if (i + j < n && (s[i + j] == t[j] || s[i + j] == '?')) {
                    cc++;
                }
            }
            if (cc == m) {
                forn(j, m) {
                    s[i + j] = t[j];
                }
                ok = true;
                break;
            }
        }
        forn(i, n) {
            if (s[i] == '?') {
                s[i] = 'a';
            }
        }
        if (!ok) {
            cout << "UNRESTORABLE" << endl;
        } else {
            cout << s << endl;
        }
    }
}


Measured memory_bytes: 3596
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long
 
#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")
 
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
 
#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())
 
#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()
 
#define MX1     30001
#define MX2     1000000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Count[9];
 
lli Power(lli a,lli b)
{
    lli result=1;
 
    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }
 
        b=b>>1;
        a=(a*a)%mod;
    }
 
 return result;
}
 
int main()
{
    opt;
 
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli N,i;
    cin>>N;
    
    lli Maximum=0,Minimum=0;
    
    rep(i,0,N)
    {
        lli x;
        cin>>x;
    
        if(x>=3200)
        {
            Maximum++;
            continue;
        }
        
        x/=400;
        
        Count[x]++;
    }
    
    rep(i,0,9)
    {
        if(!Count[i])
        {
            continue;
        }
        
        Maximum++;
        Minimum++;
    }
    
    cout<<max(1LL,Minimum)<<' '<<Maximum;
    
    
    
    
    
    
    
    
    
    
    
    
    
 
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int main()
{
	string s1,s2;
	int c1,c2;
	string u;
	cin>>s1>>s2>>c1>>c2>>u;
	if(u==s1)
	{
		cout<<c1-1<<" "<<c2<<endl;
	}
	else
	{
		cout<<c1<<" "<<c2-1<<endl;
	}
	return 0;
}

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

int main() {
    int X,N;
    cin>>X>>N;
    vector<pair<int,int>> p(102);
    for (int i = 0; i < 102; i++){
        p[i].second=i;
        p[i].first=abs(i-X);
    }
    for (int i = 0; i < N; i++){
        int tmp;
        cin>>tmp;
        p[tmp].second=1000;
        p[tmp].first=1000;
    }
    sort(p.begin(),p.end());
    cout<<p[0].second<<endl;
}


Measured memory_bytes: 3688
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <iomanip>
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
using namespace std ;
inline int read() {
	int 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-48 ; ch = getchar() ; }
	return x * f ;
}

const int N = 61;
int n,m,sum,flag;
struct node{
	int x,y;
}e[N];
int fa[N];

inline int find(int x) {
	if(fa[x]==x) return x;
	return fa[x] = find(fa[x]);
}

inline void Union(int x,int y) {
	x = find(x); 
	y = find(y);
	if(x!=y) fa[x] = y;
}

int main() {
	n = read(); m = read();
	For(i, 1, m) e[i].x=read(), e[i].y=read();
	For(T, 1, m) {
		flag = 0;
		For(i, 1, n) fa[i] = i;
		For(i, 1, m) {
			if(i==T) continue;
			Union(e[i].x,e[i].y);
		} 
		For(i, 1, n) fa[i] = find(fa[i]);
		For(i, 1, n) if(fa[i]!=fa[1]) flag = 1;
		sum+=flag;
	}
	printf("%d\n",sum);
	return 0;
}









Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	queue<ll> q;
	int k;
	cin >> k;
	for (int i = 1; i < 10; i++) {
		q.push(i);
	}
	set<ll> s;
	while (true) {
		ll c = q.front();
		q.pop();
		ll l = c % 10;
		for (int d = l - 1; d <= l + 1; d++) {
			if (d >= 0 && d <= 9) {
				q.push(c * 10 + d);
			}
		}
		s.insert(-c);
		if (s.size() >= k)break;
	}
	cout << -*(s.begin());
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

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


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
    string str; cin >> str;
    int fee = 0;

    for (auto s:str){
        if (s == 'o') {
            fee += 100;
        }
    }

    cout << 700 + fee << endl;
    return 0;
}

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

using namespace std;
 
//#define int long long
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)

ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll modm(ll val, ll m) {
  ll res = val % m;
  if (res < 0) res += m;
  return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    ll n,m,k,ans=0;
    cin >> n >> m;
    vector<vector<ll>> A(n,vector<ll>(m,0));
    vector<ll> s(m,0);
    rep(i,n){
      cin >> k;
      for(int j=0;j<k;j++){
        cin >> A[i][j];
        A[i][j]--;
        s[A[i][j]]++;
      }
    }
    rep(c,m){
      if(s[c]==n){
        ans++;
      }
    }

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


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,n,p,m;
while(cin>>m>>n>>p){
int y[n];
for(i=0;i<n;i++)cin>>y[i];
l=0;k=0; int a=0;
for(i=0;i<m;i++){ k=0;
    for(j=0;j<n;j++){
        cin>>l;
        k+=(l*y[j]);
    }
    if(k+p>0) a++;
}
cout<<a<<endl;
}


return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,ans=0;
void Solve(){
    cin>>a>>b>>c;
    while(c>0&&b>=a){
        b-=a;
        c--;
        ans++;
    }
    cout<<ans<<endl;
}
int main(){
    Solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 1010
#define mod ((ll)1e9+7)
using namespace std;
typedef long long ll;
int n;
ll d[maxn],ans;
int p[maxn];
bool prime(int a) {
	if (p[a]>-1)
		return p[a];
	if (a==1) {
		p[a]=0;
		return 0;
	}
	p[a]=1;
	for (int i=2;i*i<=a;i++)
		if (a%i==0) {
			p[a]=0;
			break;
		}
	return p[a];
}
int main() {
	scanf("%d",&n);
	memset(p,-1,sizeof(p));
	memset(d,0,sizeof(d));
	for (int i=2;i<=n;i++) {
		int j=i,k=2;
		while (j>1) {
			
			if (j%k==0&&prime(k)) {
				d[k]++;
				d[k]%=mod;
				j/=k;
			}
			else {
				if (k==2)
					k++;
				else k+=2;
			}
		}
	}
	ans=1;
	for (int i=2;i<=n;i++) {
		ans*=(d[i]+1);
		ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    ll n;
    cin >> n;
    for(ll i=1;i<=n;i++) {
    	ll ch = (i*108)/100;
    	if(ch == n){
    		cout << i << "\n";
    		return;
    	}
    }
    cout << ":(\n";
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE 
      // OC;
    #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

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

using namespace std;

int main(){
	int array[3];
	for(int i = 0; i < 3; i++) scanf("%d",&array[i]);
	for(int i = 2; i > 0; i--){
		for(int j = 0; j < i; j++){
			if(array[j] > array[j+1])swap(array[j],array[j+1]);
		}
	}
	printf("%d %d %d\n",array[0],array[1],array[2]);
}



Measured memory_bytes: 2684
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
const int INF = 1000000000;
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int m = a[0];
    ll count =0;
    for(int i=1;i<n;i++){
        if(a[i]<m)count = count + m-a[i];
        if(a[i]>m)m=a[i];
    }
    
    cout<<count;
    return 0;
}




Measured memory_bytes: 4436
def battle():
    A_health, A_strength, B_health, B_strength = map(int, input().split())

    both_alive = True
    while both_alive:
        B_health -= A_strength

        if B_health <= 0:
            both_alive = False
            print('Yes')
            return

        A_health -= B_strength

        if A_health <= 0:        
            both_alive = False
            print('No')
            return


battle()

Measured memory_bytes: 9112
#include <stdio.h>
#define NUM 100000
//Merci soen Iech Merci


int main(){
	int n,i,ans;
	scanf("%d",&n);
	int c1[NUM],c2[NUM];
	int g = 1;	
	int gg = 0;
	int gn = 0;
	int ggn = 0;
	int k = 1;
	int kk = 0;
	int kn = 0;
	int kkn = 0;
	int deside,z;
	for(i = 0;i < NUM;i++){
		c1[i] = 0;
		c2[i] = 0;
		}
	for(i = 0;i < n;i++){
		deside = i % 2;
		scanf("%d",&z);
		if(deside == 0)
			c1[z]++;
		else
			c2[z]++;
		}
	for(i = 0;i < NUM;i++){
		if(c1[i] > g){
		gg = g;
		ggn = gn;
		g = c1[i];
		gn = i;
	}else if(c1[i] > gg){
		gg = c1[i];
		ggn = i;
	}
	if(c2[i] > k){
		kk = k;
		kkn = kn;
		k = c2[i];
		kn = i;
	}else if(c2[i] > kk){
		kk = c2[i];
		kkn = i;
	}
	}
	if(gn == kn){
		if(g + kk < gg + k){
			ans = n - gg - k;
	}else if(g == n / 2 && k == n / 2){
			ans = n / 2;
	}else{
			ans = n - g - kk;
	}
	}else{
			ans = n - g - k;
	}
	printf("%d",ans);
	return 0;
}

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

int  main()
{
	int n;
	cin >> n;
	vector<tuple<string , int, int>> p;
	rep(i, n)
	{
		string str; int a;
		cin >> str >> a;
		p.emplace_back(str, -a, i + 1);
	}
	sort(p.begin(), p.end());
	rep(i, n)
		cout << get<2>(p.at(i)) << endl;
	return (0);
}


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

using namespace std;

long long a[222222], f[222222];

bool valid(long long v, long long k, int n) {
    for(int i=0;i<n;i++) k -= max(a[i]-v/f[i],0ll);
    return k >= 0;
}

int main() {
    int n;
    long long k;
    cin >> n >> k;
    for(int i=0;i<n;i++) scanf("%lld", &a[i]);
    sort(a,a+n);
    reverse(a,a+n);
    for(int i=0;i<n;i++) scanf("%lld", &f[i]);
    sort(f,f+n);
    long long lo = -1, hi = 1e12+2, mi;
    while(lo+1 < hi) {
        mi = (lo+hi)/2;
        if(valid(mi, k, n)) hi = mi;
        else lo = mi;
    }
    cout << hi << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>


#include<stdlib.h>


#include<string.h>


int main(){


char x[1001],c[2];


int len,i,sum=0;


while(1){


scanf("%s",x);


if(x[0]=='0'){


break;


}


len=strlen(x);


for(i=0;i<len;i++){


c[0]=x[i];


sum+=atoi(c);


}


printf("%d\n",sum);


sum=0;


}


return 0;


}

Measured memory_bytes: 544
#include<bits/stdc++.h>
#define N 200005
using namespace std;
int n,m,K;
int in[N];
void solve(){
	scanf("%d",&n);
	int ma1=0,ma2=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&in[i]);
		if(in[i]>=ma2){
			ma1=ma2;
			ma2=in[i];
		}else if(in[i]>=ma1){
			ma1=in[i];
		}
	}
	for(int i=1;i<=n;i++){
		if(in[i]==ma2)printf("%d\n",ma1);
		else printf("%d\n",ma2);
	}
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 2432
n=int(input())
a=list(input().split())
b1=[]
b2=[]
if n%2==0:
    for i in range(n):
        if i%2!=0:
            b1.append(a[n-i])
        else:
            b2.append(a[i])
else:
    for i in range(n):
        if i%2==0:
            b1.append(a[n-1-i])
        else:
            b2.append(a[i])
 
b1.extend(b2)
 
print(" ".join(b1))

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  string S; cin >> S;
  int sum = 0;
  rep(i, S.length()) {
    sum += S[i] - '0';
  }
  if(sum%9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int N;
  cin >> N;
  int a = 0;
  int n = N;
  
  for (int i = 0; i < 9; i++) {
    a = a + ( n % 10 );
    n /= 10;
  }
  
  if (N % a == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

    int a,b ,c;
    cin >> a >> b >> c;
    bool flg = false;

    if(a == 5 && b == 5 && c == 7) flg = true;
    if(a == 5 && b == 7 && c == 5) flg = true;
    if(a == 7 && b == 5 && c == 5) flg = true;

    if(flg) cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 256
N = int(input())
Hight = [int(i) for i in input().split()]
Hight.append(10**10)
Point = []
Player = 0
Rpoint = 0
while Player < N :
    while (Hight[Player]) >= (Hight[Player + 1]) and Player < N :
        Rpoint += 1
        Player += 1
        Point.append(int(Rpoint))
    Point.append(int(Rpoint))
    Rpoint = 0
    Player += 1
    if Player == N:
        break
print(max(Point))


Measured memory_bytes: 14228
#include <queue>
#include <cstdio>
#include <limits>
#include <algorithm>
 
int main()
{
    int n, MAX = std::numeric_limits<int>::min();
    
    std::queue<int> R;
    
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++)
    {
        int temp;
        
        scanf("%d", &temp);
        
        R.push(temp);
        
        MAX = R.size() > 1 ? std::max(R.back() - R.front(), MAX) : MAX;
 
        if (R.back() < R.front())
        {
            while (R.size() > 1)
            {
                R.pop();
            }
        }
    }
 
    printf("%d\n", MAX);
 
    return 0;
}
 
// Time : O( 2n )

Measured memory_bytes: 3236