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

const double EPS = 1e-10;

double add(double a, double b){
    if( abs(a + b) < EPS * (abs(a) + abs(b))) return 0;
    return a + b;
}

// 二次元ベクトル構造体
struct P{
    double x, y;
    P(){}
    P(double x, double y) : x(x), y(y){
    }
    P operator + (P p){
        return P(add(x, p.x), add(y, p.y));
    }
    P operator - (P p){
        return P(add(x, -p.x), add(y, -p.y));
    }
    P operator * (double d){
        return P(x * d, y * d);
    }
    P operator / (double d){
        return P(x / d, y / d);
    }
    double dot(P p){ // 内積
        return add(x * p.x, y * p.y);
    }
    double det(P p){ // 外積
        return add(x * p.y, -y * p.x);
    }
};

// 2点間の長さ
double dist(P a, P b){
    return sqrt((b-a).dot(b-a));
}
double dist2(P a, P b){
    return (b-a).dot(b-a);
}

//　線分p1-p2上に点qがあるか判定
bool on_seg(P p1, P p2, P q){
    return (p1 - q).det(p2 - q) == 0 && (p1 - q).dot(p2 - q) <= 0;
}

// 直線p1-p2と直線q1-q2の交点
P intersection(P p1, P p2, P q1, P q2){
    return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}

int N;
vector<P> p;
bool Cis(P circle, double r){
    rep(i, 0, N){
        if(dist(circle, p[i]) > r + EPS) return false;
    }
    return true;
}

int main(){
    cin >> N;
    p.resize(N);
    rep(i, 0, N) cin >> p[i].x >> p[i].y;
    double ans = 1e9;

    rep(i, 0, N){
        rep(j, 0, N) if(i != j){
            P mid = (p[i] + p[j] ) * 0.5;
            double r = dist(p[i], mid);
            if(Cis(mid, r)) ans =  min(ans, r);
        }
    }
    //cout << ans << endl;

    rep(i, 0, N){
        rep(j, 0, N) if(i != j){
            rep(k, 0, N) if(i != k && j != k){
                P mid;
                double A = dist2(p[j], p[k]), B = dist2(p[i], p[k]), C = dist2(p[i], p[j]),
                S = fabs((p[j]-p[i]).det(p[k]-p[i]));
                mid = p[i] * A * (B + C - A)  + p[j] * B * (C + A - B) + p[k] * C * (A + B - C);
                mid = mid / (A*(B+C-A)+B*(C + A - B) + C * (A + B - C ));
                double r = dist(p[i], mid);
                if(Cis(mid, r)) ans =  min(ans, r);
            }
        }
    }
    cout << fixed << setprecision(10) <<  ans << endl;


}

Measured memory_bytes: 256
from heapq import heappush, heappop

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

h = []
for a in A:
    heappush(h, -a)
for _ in range(M):
    heappush(h, -(-heappop(h) // 2))

print(-sum(h))

Measured memory_bytes: 64664
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end

h,n=get_i
a=get_i
puts yn_judge(h<=a.inject(:+))

Measured memory_bytes: 8708
# https://atcoder.jp/contests/abc128/tasks/abc128_b

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N = int(input())
    reviews = []
    for i in range(N):
        s, p = input().split()
        p = int(p)
        reviews.append((i+1, s, p))

    reviews.sort(key=lambda x: (x[1], -x[2]))
    for r in reviews:
        print(r[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

string divide[4] = {"dream","dreamer","erase","eraser"};

int main(){
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    for(int i=0;i<4;i++){
        reverse(divide[i].begin(),divide[i].end());
    }
    bool can = true;
    for(int i=0;i<s.size();){
        bool can2 = false;
        for(int j=0;j<4;j++){
            if(s.substr(i,divide[j].size()) == divide[j]){
                can2 =true;
                i += divide[j].size();
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BStringPalindrome {
public:
    bool ok(string s) {
        int l = 0;
        int r = s.size() -1;
        while (l < r) {
            if (s[l] != s[r]) return false;
            l++;
            r--;
        }
        return true;
    }
    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;
        if (!ok(s)) {
            cout << "No" << endl;
            return;
        }
        if (!ok(s.substr(0, s.size() / 2))) {
            cout << "No" << endl;
            return;
        }
        if (!ok(s.substr( s.size() / 2 + 1))) {
            cout << "No" << endl;
            return;
        }
        cout << "Yes" << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BStringPalindrome solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int a;
	string s;
	cin >> a >> s;
	if (a < 3200) {
		cout << "red" << endl;
	} else {
		cout << s << endl;
	}
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



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

int main() {
  string S;
  cin >> S;
  vector<int> a(4);
  vector<string> op(4);
  
  for (int i=0; i<4; i++){
    a.at(i) = stoi(S.at(i)+""s);
  }
  
  int target = 7;
  
  int retval;
  string output = "";
  for (int tmp=0;tmp<(1<<3);tmp++){
    bitset<3> s(tmp);
    
    retval = a.at(0);
    for (int i=2;i>=0;i--){
      if (s.test(i)) { // +に対応
        retval += a.at(3-i);
        op.at(2-i) = "+";
      }
      else { // -に対応
        retval -= a.at(3-i);
        op.at(2-i) = "-";
      }
    }
        
    if (retval == target) {
      output = to_string(a.at(0));
      for (int i=0;i<3;i++){
        output += op.at(i);
        output += to_string(a.at(i+1));
      }
      output += "=" + to_string(target);
      break;
    }
  }
  
  cout << output << endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
 
  int i;
 
  /* 文字 */
  char moji;
 
  /* 文字を入力 */

  scanf("%c", &moji);
 
  /* アルファベットの小文字か大文字かを判定 */
  if((moji>= 'a') && (moji<='z')){
    printf("a\n");
  }
  else if((moji>= 'A') && (moji<='Z')){
    printf("A\n");
  }
  else {
  }
 
  return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,s2; cin>>s>>s2; s+=s2;
	int a=stoi(s),i=sqrt(a);
	cout<<(i*i==a?"Yes"s:"No"s)<<"\n"s;
}

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

using namespace std;

int main()
{
  int a[4], b[2];
  for(int i = 0; i < 4; i++) cin >> a[i];
  for(int i = 0; i < 2; i++) cin >> b[i];
  sort(a, a + 4, greater<int>());
  sort(b, b + 2, greater<int>());
  int ans = 0; 
  for(int i = 0; i < 3; i++) ans += a[i];
  cout << ans + b[0] << endl;
  return 0;
}

Measured memory_bytes: 1176
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        printArray(createArray(scn.nextInt()));
    }
    
    public static int[] createArray(int n) {
        int[] ary = new int[6];
        for(int i = 0; i < n; i++) {
            int idx = ((int)scn.nextDouble() - 160) / 5;
            ary[idx > 0 ? (idx < 5 ? idx : 5) : 0]++;
        }
        return ary;
    }
    
    public static void printArray(int[] ary) {
        for(int i = 0; i < 6; i++) {
            StringBuilder sb = new StringBuilder(i + 1 + ":");
            for(int j = 0; j < ary[i]; j++) {
                sb.append("*");
            }
            System.out.println(sb);
        }
    }
}

Measured memory_bytes: 28048
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        mut c: [usize; 3]
    }
    c.sort();
    let mut ans = 3;
    if c[0] == c[1] {
        ans -= 1;
    }
    if c[1] == c[2] {
        ans -= 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, M; cin >> N >> M;
    int ac[N] = {};
    int wa[N] = {};
    REP(i, 0, M) {
        int p; string res; cin >> p >> res;
        p--;
        if (res == "AC") {
            if (ac[p] == 0) {
                ac[p]++;
            }
        } else {
            if (ac[p] > 0) continue;
            wa[p]++;
        }
    }

    int accnt = 0, wacnt = 0;
    REP(i, 0, N) {
        if (ac[i] > 0) {
            accnt++;
            wacnt += wa[i];
        }
    }
    cout << accnt << " " << wacnt << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        final long mod1 = (n + k) % k;
        final long mod2 = (k - mod1) % k;
        System.out.println(Math.min(mod1, mod2));
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  double L;
  cin >> L;
  cout << fixed << setprecision(10);
  cout << L*L*L/27 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
//#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
int main(){
	
	int n,T,min=666666;
	int c[111111],t[111111];
	cin>>n>>T;
	for(int i=0;i<n;i++){
		cin>>c[i]>>t[i];
		if(min>=c[i] && t[i]<=T){
			min=c[i];
		}
	}
	if(min==666666)cout<<"TLE"<<endl;
	else cout<<min<<endl;
	
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n--){
    string in,s;
    cin>>in>>s;
    for(int i=in.size()-1;i>=0;i--){
      if(in[i]=='C')
	s=s.substr(1)+s[0];
      else if(in[i]=='A')
	reverse(all(s));
      else if(in[i]=='E'){
	//cout<<s.size()<<endl;
	int tmp=s.size();
	if(!(tmp%2))
	  s=s.substr(tmp/2)+s.substr(0,tmp/2);
	else
	  s=s.substr(tmp/2+1)+s[tmp/2]+s.substr(0,tmp/2);
      }else if(in[i]=='J')
	s=s[s.size()-1]+s.substr(0,s.size()-1);
      else if(in[i]=='M'){
	rep(j,s.size())if(isdigit(s[j])){
	  s[j]++;
	  if(s[j]>'9')s[j]='0';
	}
      }else if(in[i]=='P'){
	rep(j,s.size())if(isdigit(s[j])){
	  s[j]--;
	  if(s[j]<'0')s[j]='9';
	}
      }
      //cout<<s<<endl;
    }
    cout<<s<<endl;
  }

}

Measured memory_bytes: 1208
#include<iostream>  
using namespace std;  
typedef long long ll;  
ll f(ll a,ll b)
{  
    if(a==0) return b;  
    else return f(b%a,a);  
}  
int main()
{  
    ll n,t[101];  
    cin>>n;  
    for(int i=0;i<n;i++) 
		cin>>t[i];  
    ll x=t[0];  
    for(int i=1;i<n;i++)
	{  
        ll y=f(x,t[i]);  
        x*=(t[i]/y);  
    }  
    cout<<x<<endl;  
}  

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;

vector<int> G[100005];
int N,S[100005];

void dfs(int x, int l)
{
	S[x]++;
	for (int y : G[x]) if (y != l){
		dfs(y,x);
		S[x] += S[y];
	}
}

int main()
{
	scanf ("%d",&N);
	for (int i=1;i<N;i++){
		int x,y; scanf ("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(1,0);

	if (N % 2){puts("First"); return 0;}
	for (int i=1;i<=N;i++) if (G[i].size() == 1){
		int p = G[i][0];
		int u = 2;
		for (int y : G[p]) if (y != i){
			if (S[p] > S[y]){
				if (S[y] % 2){puts("First"); return 0;}
				u += S[y];
			}
		}
		if (u % 2){puts("First"); return 0;}
	}
	puts("Second");

	return 0;
}

Measured memory_bytes: 6144
package main

import (
	"fmt"
	"strconv"
)

func nextInt() int {
	var i int
	fmt.Scan(&i)
	return i
}

func main() {
	_ = nextInt()
	w := nextInt()
	n := nextInt()

	var c, hc int
	var l string
	for i := 1; i <= n; i++ {
		a := nextInt()
		s := strconv.Itoa(i)
		for j := 0; j < a; j++ {
			if c%w == 0 {
				hc++
			}
			if l == "" {
				l = s
			} else {
				if hc%2 == 1 {
					l += " " + s
				} else {
					l = s + " " + l
				}
			}
			c++
			if c%w == 0 {
				fmt.Println(l)
				l = ""
			}
		}
	}
}

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

int main() {
  ll A,B,K;
  cin >> A >> B >> K;

  //Kの数字とA,Bの数字による場合分け
  if (K <= A){
    cout << A - K << " " << B << endl;
  }
  else if (K <= A + B){
    cout << 0 << " " << B - (K - A) << endl;
  }
  else {
    cout << 0 << " " << 0 << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

SD = list(input().rstrip())
T = list(input().rstrip())

lenSD = len(SD)
lenT = len(T)

def match(i):
    s = SD[i:i+lenT]
    for i in range(len(s)):
        if s[i] == '?':
            continue
        if s[i] != T[i]:
            return False

    return True




match_i = -1
for i in range(lenSD):
    if (lenSD - lenT) < i:
        break

    if match(i):
        match_i = i

if match_i == -1:
    print('UNRESTORABLE')
    exit()

# 場所が決まった
i = match_i
for j in range(lenT):
    if SD[i+j] == '?':
        SD[i+j] = T[j]

for i in range(lenSD):
    if SD[i] == '?':
        SD[i] = 'a'

print(*SD, sep="")

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

using namespace::std;

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

        vector<int> a;

        int curr = -1;
        int cnt = 0;

        for (int i = 0; i < N; i++)
        {
                int x;
                cin >> x;

                if (x == curr)
                        a.back()++;
                else
                        a.push_back(1);

                curr = x;
        }

        int ans = 0;
        for (int i = 0; i < a.size(); i++)
                ans += a[i] / 2;

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256
#負の切り捨てがよろしくない
# -3/2 = -2 ? -1
class Fixnum
	def /(o)
		r=1.0*self.fdiv(o)
		return r<0 ? r.ceil : r.floor
	end
end
gets.to_i.times{puts(eval(gets.chop.chop))}


Measured memory_bytes: 6156
N = int(input())
S = input()

ans = S[1:].count("E")
now = S[1:].count("E")

for idx, s in enumerate(S):
    if idx == 0:
        continue
    if S[idx-1] == "W":
        now += 1
    if s == "E":
        now -= 1
    ans = min(ans, now)
print(ans)

Measured memory_bytes: 43504
// Believe in yourself
#include<bits/stdc++.h>
#include<ctime>

using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007
#define decimal(i,n) fixed << setprecision(i) << n
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;


void eea(ll a,ll b,ll &x,ll &y)
{
    if (a == 1)
    {
        x = 1; y = 0;
        return;
    }
    ll x1, y1;
    eea(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
}
ll mi(ll a,ll m)
{
    ll x,y;
    eea(a,m,x,y);
    x= (x%m+m)%m;
    return x;
}

/*
Enter the test case


Some helpful points
1.) Calm yourself
2.) check for semicolon or data type mismatch
3.) It can be solved
*/

int main()
{
    // clock_t time_req;
    // time_req = clock();
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);    
    ll t=1;
    // cin>>t;
    while(t--)
    {
       ll n;
       cin>>n;
       ll a[n];
       ll ans=0;
       for(ll i=0;i<n;i++)
       cin>>a[i];
       ll m=a[0];
       for(ll i=1;i<n;i++)
       {
           m=max(m,a[i]);
           if(m>a[i])
           ans=ans+m-a[i];
       }
       cout<<ans<<"\n";
    }
    // time_req = clock()-time_req;
    // cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;
}



Measured memory_bytes: 5092
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC067B - Snake Toy

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();   // 1 <= k <=n <= 50
        int k = sc.nextInt();
        Integer[] l = new Integer[n];

        for (int i = 0; i < n ; i++) {
            l[i] = sc.nextInt();
        }

        Arrays.sort(l, Collections.reverseOrder());

        int max = 0;
        for (int i = 0; i < k; i++) {
            max += l[i];
        }

        System.out.println(max);
    }

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100005
#define INF 0x3f3f3f3f
#define MS(x, i) memset(x, i, sizeof x)
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define MOD 998244353
#define NOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

inline int read()
{
    int res = 0, sgn = 1;
    char c = getchar();

    while(c < '0' || c > '9')
    {
        if(c == '-')
            sgn = -1;
        c = getchar();
    }

    while(c >= '0' && c <= '9')
    {
        res = res * 10 + c - '0';
        c = getchar();
    }

    return res * sgn;
}

int main()
{
    map<int, int> mp;
    int flag = 0;
    int n = read();
    for(int i = 0; i < n; i++)
    {
        int num = read();
        if(mp[num] != 0)
            flag = 1;
        mp[num]++;
    }
    if(flag == 1)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
}


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

using namespace std;

int main(){
    long long n, k, ans = 0;
    multiset<long long> prices;
    cin >> n >> k;
    for(long long i = 0; i < n; i++){
        long long p;
        cin >> p;
        prices.insert(p);
    }
    for(multiset<long long>::iterator itr = prices.begin(); itr != prices.end(); itr++){
        if(k < 1) break;
        ans += *itr;
        k--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
 
char str[1005];
char p[1005];
 
int main()
{
    int q, a, b;
    char op[10], *x, *y, c;
     
    scanf("%s%d", str, &q);
    while (q--) {
        scanf("%s%d%d", op, &a, &b);
        if (op[2] == 'i') {             // print
            b++, c = *(str+b), *(str+b) = 0, puts(str+a), *(str+b) = c;
        } else if (op[2] == 'v') {      // reverse
            x = str+a, y = str+b;
            while (x < y) {
                c = *x, *x = *y, *y = c;
                x++, y--;
            }
        } else {                        // replace
            scanf("%s", p);
            x = str+a, y = p;
            while (*y) *x++ = *y++;
        }
    }
    return 0;
}


Measured memory_bytes: 2088
N = int(input())
Di = input().split()
D = {}
for d in Di:
    if d in D:
        D[d] += 1
    else:
        D[d] = 1
M = int(input())
T = input().split()
judge = 0

for t in T:
    if (t in D) and (D[t] != 0):
        D[t] -= 1
    else:
        judge = 1
        break

if judge == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 47968
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, M;
    cin >> n >> M;
    vector<int> a(M);
    for(int i = 0; i < M; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    map<int, int> m;
    m.insert(make_pair(1, 2));
    m.insert(make_pair(2, 5));
    m.insert(make_pair(3, 5));
    m.insert(make_pair(4, 4));
    m.insert(make_pair(5, 5));
    m.insert(make_pair(6, 6));
    m.insert(make_pair(7, 3));
    m.insert(make_pair(8, 7));
    m.insert(make_pair(9, 6));

    vector<int> dp(n+1);
    for(int i = 0; i <= n; i++)
    {
        dp[i] = -1;
    }
    dp[0] = 0;

    for(int i = 2; i <= n; i++)
    {
        for(int j = 0; j < M; j++)
        {
            int num = m[a[j]];
            if(num <= i && dp[i-num] != -1)
            {
                dp[i] = max(dp[i], dp[i-num] + 1);
            }
        }
    }
    while(n > 0)
    {
        for(int i = 0; i < M; i++)
        {
            int num = m[a[i]];
            if(n >= num && dp[n-num] == dp[n]-1)
            {
                cout << a[i];
                n -= num;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    priority_queue<int, vector<int>, greater<int>> pq;
    for(int i = 0; i < N; i++) {
        int p;
        cin >> p;
        pq.push(p);
    }

    int sum = 0;
    for(int i = 0; i < K; i++) {
        sum += pq.top();
        pq.pop();
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=1e4+10;
const ll MOD=17;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
int cnt[MAXN];
void solve(){
    int n;
    cin>>n;
    for(int x=1;x<=100;x++){
        for(int y=1;y<=100;y++){
            for(int z=1;z<=100;z++){
                int t=x*x+y*y+z*z+x*y+y*z+z*x;
                if(t<=1e4){
                    cnt[t]++;
                }
            }
        }
    }
    for(int u=1;u<=n;u++){
        cout<<cnt[u]<<"\n";
    }
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  int N;
  cin >> N;
  int A[N];
  for (int& i : A)
    cin >> i;

  sort(A, A + N, greater<int>());
  vector<int> comf;
  ll comfort = A[0];
  for (int i = 1; i < N; i++) comf.push_back(A[i]), comf.push_back(A[i]);
  for (int i = 0; i < N-2; i++) comfort += comf[i];

  cout << comfort;
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  cout << nl;
  // }

  return 0;
}

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-9
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int t,n;

int main(){
    cin >>t >>n;
    printf("%.9f", 1.0 * t / n);
}

/*
uniform_int_distribution<type>(l, r)(rng)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
*/


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
const int p = 1e9 + 7;
ll inv[maxn];
ll fac[maxn];
ll invfac[maxn];
void init()
{
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= maxn; i++)
    {
        inv[i] = (p - p / i) * inv[p % i] % p;
    }
}
ll C(ll n, ll m)
{
    fac[0] = invfac[0] = invfac[1] = 1;
    for (int i = 1; i <= n; i++)
    {
        fac[i] = (ll)fac[i - 1] * i % p;
    }
    for (int i = 2; i <= n; i++)
        invfac[i] = (ll)(p - p / i) * invfac[p % i] % p;
    for (int i = 2; i <= n; i++)
    {
        invfac[i] = (ll)invfac[i - 1] * invfac[i] % p;
    }
    //cout << fac[n] * invfac[m] % p * invfac[n - m] % p << "\n";
    ll res = n < m ? 0 : (ll)fac[n] * invfac[m] % p * invfac[n - m] % p;
    return res;
}
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int X, Y;
    cin >> X >> Y;
    if ((X + Y) % 3 != 0 || (2 * Y - X < 0) || (2 * X - Y < 0))
    {
        cout << 0 << "\n";
    }
    else
    {
        ll m = (2 * X - Y) / 3;
        ll n = (2 * Y - X) / 3;
        cout << C(n + m, n) << "\n";
    }
    return 0;
}

Measured memory_bytes: 14040
#!/usr/bin/env python3
#ABC54 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n,k,l = map(int,input().split())
par1 = [i for i in range(n)]
par2 = [i for i in range(n)]

rank1 = [0]*(n)
rank2 = [0]*(n)

def find(x,i):
    if i == 1:
        if par1[x] == x:
            return x
        else:
            par1[x] = find(par1[x],i)
            return par1[x]
    else:
        if par2[x] == x:
            return x
        else:
            par2[x] = find(par2[x],i)
            return par2[x]

def union(x,y,i):
    x = find(x,i)
    y = find(y,i)
    if i == 1:
        if rank1[x] < rank1[y]:
            par1[x] = y
        else:
            par1[y] = x
            if rank1[x] == rank1[y]:
                rank1[x] += 1
    else:
        if rank2[x] < rank2[y]:
            par2[x] = y
        else:
            par2[y] = x
            if rank2[x] == rank2[y]:
                rank2[x] += 1

for _ in range(k):
    p,q = map(int,input().split())
    union(p-1,q-1,1)
for _ in range(l):
    r,s = map(int,input().split())
    union(r-1,s-1,2)

f = defaultdict(lambda : 0)
for i in range(n):
    x = (find(i,1),find(i,2))
    f[x] += 1
    
ans = []
for i in range(n):
    x = (find(i,1),find(i,2))
    ans.append(f[x])
print(*ans)


Measured memory_bytes: 121476
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}


int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	vector<int> tmp(3);
	cin >> tmp[0] >> tmp[1] >> tmp[2];

	sort(tmp.begin(), tmp.end());
	int need = (tmp[2] - tmp[0]) + (tmp[2] - tmp[1]);
	if (need % 2 == 0)
	{
		cout << need / 2;
	}
	else
	{
		cout << need / 2 + 2;
	}


	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    int w,a,b;
    scanf("%d %d %d",&w,&a,&b);
    int ba=a,ea=a+w,bb=b,eb=b+w;
    if((eb>=ba&&eb<=ea)||(bb>=ba&&bb<=ea)){
        printf("0");
    }
    else {
        if(bb>ea)   printf("%d",bb-ea);
        else if(ba>eb)  printf("%d",ba-eb);
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
           
            int N = sc.nextInt();
            int num = 0;
            
            for (int i=1; i<=N; i++) {
                num += i;
            }
        System.out.println(num);
    }
}

Measured memory_bytes: 23892
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) cout << C << endl;
    else if (B == C) cout << A << endl;
    else cout << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;
typedef long long ll;

using namespace std;

void solve() {
    int N, K;
    cin >> N >> K;
    ll R, S, P;
    cin >> R >> S >> P;
    string T;
    cin >> T;

    ll ans = 0;
    REP(i, K) {
        int t = i;
        string s = "";
        while (t < N) {
            s += T[t];
            t += K;            
        }
        bool flag = false;
        REP(i, s.length()) {
            if (i && s[i] == s[i-1] && flag) {
                flag = false;
                continue;
            }
            flag = true;
            if (s[i] == 'r') ans += P;
            if (s[i] == 'p') ans += S;
            if (s[i] == 's') ans += R;
        }
    }
    print(ans);
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

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

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


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;

    vector<bool> eraf(N + 1, true);
    eraf[0] = eraf[1] = false;
    for (int i = 2; i <= N; i++) {
        if (eraf[i]) {
            for (int j = i * 2; j <= N; j += i) {
                eraf[j] = false;
            }
        }
    }
    vector<int> prime;
    rep(i, 0, N + 1) {
        if (eraf[i]) prime.push_back(i);
    }
    vector<int> num(prime.size(), 1);
    for (int i = 2; i <= N; i++) {
        int tmp = i;

        for (int j = 0; tmp != 1;) {
            if (tmp % prime[j] == 0) {
                num[j]++;
                tmp /= prime[j];
            }else{
                j++;
            }
        }
    }

    ll ans = 1;
    rep(i,0,num.size()){
        ans *= num[i];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n, cnt=1;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    int h = a[0];
    for(int i=1; i<n; i++){
        if(h<=a[i]){
            cnt++;
            h = a[i];
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

const INF = 0x7FFFFFFF

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		n, _ := strconv.Atoi(buf[0])
		m, _ := strconv.Atoi(buf[1])
		if n == 0 && m == 0 {
			break
		}
		chair := make([]string, n+1)
		for i := range chair {
			chair[i] = "#"
		}
		chair[n] = "Sentinel"
		for i := 0; i < m; i++ {
			scanner.Scan()
			switch who := scanner.Text(); who {
			case "A": // 左から眺めて行って空いている席があったら即座に座る
				for j := 0; j < n; j++ {
					if chair[j] == "#" {
						chair[j] = "A"
						break
					}
				}
				// log.Println(chair)
				break // 次の人を読み込む
			case "B":
				flag := true
				// 右端からAの隣でない席を探していく
				for j := n-1; j > -1; j-- {
					if chair[j] == "#" && (j == 0 || chair[j-1] != "A") && chair[j+1] != "A" {
						flag = false
						chair[j] = "B"
						break
					}
				}
				// Aの隣しか空いていないので一番左端の空いている席に座る
				if flag {
					for j := 0; j < n; j++ {
						if chair[j] == "#" {
							chair[j] = "B"
							break
						}
					}
				}
				// log.Println(chair)
				break // 次の人を読み込む
			case "C":
				if i == 0 {
					chair[n/2] = "C" // 先客が誰もいないときは真ん中の椅子に座る
				} else {
					for j := 0; j < n; j++ { // 左から舐めて
						if chair[j] != "#" { // その席が空いていなくて
							if chair[j+1] == "#" { // 右隣が空いているなら座る
								chair[j+1] = "C"
								break
							} else if j != 0 && chair[j-1] == "#" { // 右隣が空いていないので左隣に座る
								chair[j-1] = "C"
								break
							}
						}
					}
				}
				// log.Println(chair)
				break // 次の人を読み込む
			case "D":
				distanceTable := make([]int ,n)
				for j := range distanceTable {
					distanceTable[j] = INF
				}
				for j:= 0; j < n; j++ {
					if chair[j] != "#" {
						for k := 0; k < n; k++ {
							distanceTable[k] = min(distanceTable[k], abs(j-k))
						}
					}
				}
				// log.Println("distanceTAble:", distanceTable)
				at := 0
				distance := 0
				for j := 0; j < n; j++ {
					if distance < distanceTable[j] {
						at = j
						distance = distanceTable[j]
					}
				}
				chair[at] = "D"
				// log.Println(chair)
				break // 次の人を読み込む
			}
		}
		fmt.Println(strings.Join(chair[:len(chair)-1], ""))
	}
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1748
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

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

    int x[N][D];
    int ans = 0;

    rep(i, 0, N) rep(j, 0, D) {
        cin >> x[i][j];
    }

    rep(i, 0, N) rep(j, i, N) {
        if(i == j) continue;
        double d = 0;
        rep(k, 0, D) {
            d += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
        }
        d = sqrt(d);
        //cout << "i j " << i << j << " " <<d << endl;
        int d_int = (int)d;
        if(d - d_int < 1e-15) { ans++; }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

string ins;

int
main()
{
  ins.reserve(10);
  unordered_map<string, long long> mp;

  long long n, res(0);
  cin >> n;

  FOR(i,n) {
    cin >> ins;
    std::sort(ins.begin(), ins.end());
    int kasu = mp[ins];
    if (kasu) {
      res += kasu;
    }
    ++mp[ins];
  }

  cout << res << endl;
	return 0;
}


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

namespace cs
{
    public class Program
    {
        public static void Main(string[] args)
        {
            
            var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            
            var N = input[0];
            var A = input[1];
            var B = input[2];

            Console.WriteLine(Math.Min(N * A, B));


           

            




            
            
/*
            Console.WriteLine();
            Console.WriteLine("続行するにはアレ");*/
            //Console.ReadKey();
           
        }

        private static long Factorial(long number)
{
	if (number < 0)
		return -1; //Error

	long result = 1;

	for (long i = 1; i <= number; ++i)
		result *= i;

	return result;
}
public static long ncr2(long n, long r){
    var fact = n;
    var fact2 = r;
    long fact1;
    long per;
            for (long i = n - 1; i >= 1; i--)
            {
                fact = fact * i;
            }
            fact2 = r;
            for (long i = r - 1; i >= 1; i--)
            {
                fact2 = fact2 * i;
            }
            long number;
            number = n - r;
            fact1 = number;
            for (long i = number - 1; i >= 1; i--)
            {
                fact1 = fact1 * i;
            }
            fact1 = fact2 * fact1;
            per = fact / fact1;
            return per;
}
public static long NCR(long n, long r)
{
	return Factorial(n) / (Factorial(r) * Factorial(n - r));
}

        class vec{
            long from{get;set;}
            long to{get;set;}

            public vec(long[] x){
                from = x[0];
                to = x[1];
            }

        }


        public static long modder(){
            return (long)Math.Pow(10,9) + 7;
        }

        public static long GCD(long n, long m){
            
            if(m % n == 0) return n;
            else return GCD(m%n, n);

        }

        public static long LCD(long n, long m){

            return m * n / GCD(n,m);
        }
    }
}


Measured memory_bytes: 13140
N=int(input())
S=input()
l=0
a=1
for i in range(2*N):
    if S[i]=="W":
        if l%2==0:
            a=a*l%(10**9+7)
            l-=1
        else:
            l+=1
    else:
        if l%2==0:
            l+=1
        else:
            a=a*l%(10**9+7)
            l-=1
if l!=0:
    a=0
for i in range(1,N+1):
    a=a*i%(10**9+7)
print(a)

Measured memory_bytes: 40288
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long int n;
	cin >> n;
	long long int ans=0,fact ,b;
	if(n&1)
	{
		ans=0;
	}
	else
	{
		fact=5;
		while(n>= fact)
		{
			b= n/fact ;
			//if(b%2==0)
				ans+=b/2;
			fact*=5;
		}
	}
	cout<<ans;
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n;cin>>n;
  vector<ll> a(n);
    
  rep(i,n){
    cin>>a[i];
  }

  auto maxIt = max_element(all(a));
  size_t maxIndex = distance(a.begin(), maxIt);
  auto minIt = min_element(all(a));
  size_t minIndex = distance(a.begin(), minIt);
  if(abs(*maxIt)>abs(*minIt)){
    vector<string> ans;
    ans.pb(to_string(maxIndex+1)+" "+"1");
    a[0]+=*maxIt;   
    maxIt = max_element(all(a));
    maxIndex = distance(a.begin(), maxIt);
    ans.pb(to_string(maxIndex+1)+" "+"1"); 
    a[0]+=*maxIt;
    rep(i,n-1){
      ans.pb(to_string(i+1)+" "+to_string(i+2));  
      a[i+1]+=a[i];
      if(a[i+1]<a[i]){
        ans.pb(to_string(i+1)+" "+to_string(i+2));  
        a[i+1]+=a[i];
      }
    }

    cout<<ans.size()<<endl;
    rep(i,ans.size()){
      cout<<ans[i]<<endl;
    }
  }else{
    minIt = min_element(all(a));
    minIndex = distance(a.begin(), minIt);
    vector<string> ans;
    ans.pb(to_string(minIndex+1)+" "+to_string(n));
    a[n-1]+=*minIt;   
    minIt = min_element(all(a));
    minIndex = distance(a.begin(), minIt);
    ans.pb(to_string(minIndex+1)+" "+to_string(n));
    a[n-1]+=*minIt;
    rep(i,n-1){
      ans.pb(to_string(n-i)+" "+to_string(n-i-1));  
      a[n-i-2]+=a[n-i-1];
      if(a[n-i-1]<a[n-i-2]){
        ans.pb(to_string(n-i)+" "+to_string(n-i-1));  
        a[n-i-2]+=a[n-i-1];
      }
    }

    cout<<ans.size()<<endl;
    rep(i,ans.size()){
      cout<<ans[i]<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;


int main() {

    int N;
    cin >> N;

    vector<int> L(2 * N);
    for (int i = 0; i < 2 * N; i++) cin >> L[i];

    sort(L.rbegin(), L.rend());

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += min(L[i * 2], L[i * 2 + 1]);
    }

    cout << ans << endl;

    return 0;
}



























Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	ans := 0
	for i := 0; i < n-2; i++ {
		if s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512