akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int64_t n, m;
    cin >> n >> m;

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

    sort(a.begin(), a.end());
    vector<int64_t> asum(n + 1);
    asum[n] = 0;
    rrep(i, n)
    {
        asum[i] = asum[i + 1] + a[i];
    }

    int lb = 0, ub = 2 * a[n - 1] + 1;
    int64_t lbM = (int64_t)n * n;
    int64_t lbScore = asum[0] * 2 * n;

    while (ub - lb > 1)
    {
        int mid = (lb + ub) / 2;
        int64_t cnt = 0;
        int64_t score = 0;
        int j = n - 1;
        rep(i, n)
        {
            while (j >= 0 && a[i] + a[j] >= mid)
                j--;
            cnt += n - (j + 1);
            score += asum[j + 1] + (int64_t)(n - (j + 1)) * a[i];
        }

        if (cnt >= m)
        {
            lb = mid;
            lbM = cnt;
            lbScore = score;
        }
        else
        {
            ub = mid;
        }
    }
    cout << lbScore - (lbM - m) * lb << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <vector>
#include <cmath>
#include <stdint.h>

int main(void)
{
  using namespace std;
  uint8_t N;
  uint16_t sum = 0;
  scanf("%hhu", &N);
  
  vector <int> A(N), B(N), C(N-1);
  
  for (int i = 0; i < N ; ++i)
    scanf("%hhu", &A[i]);
  
  for (int i = 0; i < N ; ++i)
    scanf("%hhu", &B[i]);
  
  for (int i = 0; i < N-1 ; ++i)
    scanf("%hhu", &C[i]);
  
  for (int i=0 ; i < N ; ++i) {
    sum += B[A[i]-1];
    
    if (A[i]+1 == A[i+1])
      sum += C[A[i]-1];
  }
  
  printf("%hu", sum);
  return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
ls = list(map(int, input().split()))

c = collections.Counter(ls)

ls_s = c.most_common()
ls_s.sort(reverse=True)

mul = []

for i in range(len(ls_s)):
    if ls_s[i][1] >= 4:
        if len(mul) == 0:
            print(ls_s[i][0] ** 2)
            break
        elif len(mul) == 1:
            print(ls_s[i][0] * mul[0])
            break
    elif ls_s[i][1] >= 2:
        mul.append(ls_s[i][0])
    
    if len(mul) >= 2:
        print(mul[0] * mul[1])
        break
    elif i == len(ls_s) - 1:
        print(0)

Measured memory_bytes: 21668
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> states;
//偶数番目(0,2,,)は直立、奇数番目(1,3,,)は逆立ち

int main()
{
    int n, k;
    cin>>n>>k;
    string s;
    cin>>s;

    bool is_stand = true;
    int idx = 1;
    states.push_back(0);
    states.push_back(0);
    REP(i,n) {
        if (s[i] == '0') {
            if (is_stand) {
                states[idx]++;
            } else {
                states.push_back(1);
                idx++;
                is_stand = true;
            }
        } else {
            if (is_stand) {
                states.push_back(1);
                idx++;
                is_stand = false;
            } else {
                states[idx]++;
            }
        }
    }
    REP(i,k*2+2) states.push_back(0);

    vector<int> scc;
    int fscc = 0;
    REP(i,k * 2 + 1) {
        fscc += states[i];
    }
    scc.push_back(fscc);
    int size = states.size();
    idx = 0;
    for (int i = k * 2 + 1; i < size; i += 2, idx++) {
        scc.push_back(scc[idx] - states[i - k * 2 - 1]  - states[i - k * 2 - 0]
        + states[i] + states[i+1]);
    }
    cout<<*MAX_ELEMENT(scc)<<endl;

    return 0;
}


Measured memory_bytes: 1528
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	pp := make([]float64, n)
	ss := make([]float64, n+1)

	for i := 0; i < n; i++ {
		pp[i] = getNextFloat64(scanner)
		ss[i+1] = ss[i] + (pp[i]+1)/2.0
	}

	var ans float64
	for i := 0; i+k <= n; i++ {
		if ans < ss[i+k]-ss[i] {
			ans = ss[i+k] - ss[i]
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 4864
#include <iostream>

using namespace std;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << char(a[0] + ('A' - 'a')) << char(b[0] + ('A' - 'a')) << char(c[0] + ('A' - 'a')) << '\n';
  return 0;
}

Measured memory_bytes: 256
import bisect
from operator import itemgetter
import math
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


W,H,x,y = IL()

cnt = 0
if x*2 == W and y*2 == H:
  cnt = 1

print((H*W)/2,cnt)

Measured memory_bytes: 12232
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,l;
    cin>>n>>l;
    int mini;
    if(l>=0) mini=l;
    else if(n+l-1<=0) mini=n+l-1;
    else mini=0;
    cout<<(l+n+l-1)*n/2-mini;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;

int N;

int main() {
  cin >> N;
  for (int i = 1; i < 10; i++) {
      for (int j = 1; j < 10; j++) {
          if (i * j == N) {
              cout << "Yes" << endl;
              return 0;
          }
      }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var count int
	var forecast, weather string
	
	fmt.Scanf("%s",&forecast)
	fmt.Scanf("%s",&weather)
	
	for i:=0; i < len(forecast); i++ {
		if forecast[i] == weather[i] {
			count++
		}
	}
	
	fmt.Printf("%d",count)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
    vector <string> v;
    stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x);
    return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
    cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
    err(++it, args...);
}
 
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

string s[N];
bool vis[25][25];
int dis[25][25];

int h,w;
int res=0;
void bfs(int x,int y){
    queue<pii>q;

    q.push({x,y});
    vis[x][y]=true;

    while(!q.empty()){
        int xx=q.front().ff,yy=q.front().ss;

        q.pop();

        for(int i=0;i<4;i++){
            int xxx=xx+dx[i],yyy=yy+dy[i];

            if(xxx>=0 and xxx<h and yyy>=0 and yyy<w and !vis[xxx][yyy] and s[xxx][yyy]!='#'){
                vis[xxx][yyy]=true;
                dis[xxx][yyy]=dis[xx][yy]+1;
                res=max(res,dis[xx][yy]+1);
                q.push({xxx,yyy});
            }
        }

    }


}

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
   // cin>>t;
    while(t--){     
        cin>>h>>w;
        for(int i=0;i<h;i++){
            cin>>s[i];
        }

        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                for(int ii=0;ii<h;++ii){
                    for(int jj=0;jj<w;++jj){
                        vis[ii][jj]=false;
                        dis[ii][jj]=0;
                    }
                }

                if(s[i][j]=='.'){
                    bfs(i,j);
                }
            }
        }

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



        //printf("Case %d: ",++te);
    }
    return 0;
}




Measured memory_bytes: 8064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }

int main(){
	// in;
	// out;
	ll n;
	cin>>n;
	printf("%.12lf\n",n*n*n*1.0/27);
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3]){
		cout << "Bad" << endl;
	}else{
		cout << "Good" << endl;
	}


	return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S; cin >> S;
  
  //main
  if((S[0]-'0')*1000+(S[1]-'0')*100+(S[2]-'0')*10+(S[3]-'0') < 2019){
    cout << "Heisei" << endl;
  }else if((S[0]-'0')*1000+(S[1]-'0')*100+(S[2]-'0')*10+(S[3]-'0') > 2019){
    cout << "TBD" << endl;
  }else if((S[5]-'0')*10+(S[6]-'0') < 5){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
  
  // output

  return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
int n;
long long a[100005];
long long ans;
int f;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<0)
		{
			f++;
			a[i]=-a[i];
		}
		ans+=a[i];
	}
	sort(a,a+n);
	if(f%2==1)
		ans-=2*a[0];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
s = input()
p = int(s[0]+s[1])
b = int(s[2]+s[3])
if (p >12 or p ==0) and (1 <= b <= 12):
  print('YYMM')
elif (1 <= p <= 12) and (1 <= b <= 12):
  print('AMBIGUOUS')
elif (p > 12 or p==0) and (b > 12 or b==0):
  print('NA')
elif (1 <= p <= 12) and (b > 12 or b ==0):
  print('MMYY')

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	string S;
	string K = "keyence";

	cin >> S;

	int i = 0, j = 0;
	while(j<K.size()){
		if(S[i++] != K[j++]){
			j--;
			break;
		}
	}

	int x = 1, y = 1;
	while(j + y <= K.size()){
		if(S[S.size()-x] != K[K.size()-y]){
			break;
		}
		x++;y++;
	}
	y--;

	if(j + y >= K.size()){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int A,B,C;
    cin>>A>>B>>C;
    if(B>=A*C) cout<<C<<endl;
    else cout<<B/A<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, N, K;
	int ans = 0;

	scanf("%d %d", &N, &K);
	ans = K;
	for (i = 1; i < N; ++i)
	{
		ans *= K-1;
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
int n,r,i,j,a[100];
main(){
scanf("%d",&n);
for(;i<n;)scanf("%d",a+i++);
for(i=0;i<n;i++){
for(j=0;j<i;j++){
if(a[i]<a[j])r++;
}
}
std::sort(a,a+n);
for(i=0;i<n;){if(i)printf(" ");printf("%d",a[i++]);}
printf("\n%d\n",r);
}

Measured memory_bytes: 3248
#include <stdio.h>
#include<math.h>
int main(void)
{
int n,s[1001],i,sum=0;
double ave,a=0;
while(1)
{
scanf("%d",&n);
if(n==0)break;
for(i=0; i<n; i++){
scanf("%d",&s[i]);
sum+=s[i];
}
ave=(double)sum/n;
for(i=0; i<n; i++)
{
a+=((s[i]-ave)*(s[i]-ave));
}
printf("%f\n",sqrt((double)a/n));
sum=0; a=0;
}
return 0;
} 



Measured memory_bytes: 2052
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b)
     printf("a < b\n");
    else if(a>b)
      printf("a > b\n");
    else if(a==b)
      printf("a == b\n");
    return 0;
 }


Measured memory_bytes: 2132
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import sys

WHITE, GRAY, BLACK = 0, 1, 2
D_MAX = int(1e7 + 1)


def generate_adj_matrix(v_info):
    for each in v_info:
        v_index, v_adj_length, *v_adj_list = map(int, each)
        # assert len(v_adj_list) == v_adj_length * 2
        for pair in zip(v_adj_list[::2], v_adj_list[1::2]):
            init_adj_matrix[v_index][pair[0]] = pair[1]

    return init_adj_matrix


def dijkstra_path():
    path_list[0] = 0

    while True:
        min_cost = D_MAX
        current_vertex_index = None
        for i in range(vertices_num):
            if color[i] is not BLACK and path_list[i] < min_cost:
                min_cost = path_list[i]
                current_vertex_index = i

        if min_cost == D_MAX:
            break

        color[current_vertex_index] = BLACK
        current_vertex_index_info = adj_table[current_vertex_index]
        for adj_vertex_index in current_vertex_index_info.keys():
            current_adj_weight = current_vertex_index_info.get(adj_vertex_index)
            if color[adj_vertex_index] is not BLACK:
                alt_path = path_list[current_vertex_index] + current_adj_weight
                if alt_path < path_list[adj_vertex_index]:
                    # update path_list
                    path_list[adj_vertex_index] = alt_path
                    parent_list[adj_vertex_index] = current_vertex_index
                    color[adj_vertex_index] = GRAY

    return path_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    init_vertices_table = (map(lambda x: x.split(), _input[1:]))
    # assert len(init_vertices_table) == vertices_num

    parent_list, path_list = [-1] * vertices_num, [D_MAX] * vertices_num
    color = [WHITE] * vertices_num
    init_adj_matrix = tuple(dict() for _ in range(vertices_num))
    adj_table = generate_adj_matrix(init_vertices_table)
    ans = dijkstra_path()
    for j in range(vertices_num):
        print(j, ans[j])

Measured memory_bytes: 8076
import sys

card_all = [""] * 3
card_num = [0] * 3

# SA Aさんのカード
card_all[0] = input()
card_num[0] = len(card_all[0])

# SB Bさんのカード
card_all[1] = input()
card_num[1] = len(card_all[1])

# SC Cさんのカード
card_all[2] = input()
card_num[2] = len(card_all[2])

# 最初はAさんから
card = 'a'
while True:
    i = ord(card) - ord('a')
    # 次のカードを取り出し
    card = card_all[i][0:1]
    # カード数を減算
    card_num[i] -= 1
    if card_num[i] == -1:
        break
    # 出したカードを削除
    card_all[i] = card_all[i][1:]

# 誰が勝ったか
if (card_num[0] == -1):
    print("A")
if (card_num[1] == -1):
    print("B")
if (card_num[2] == -1):
    print("C")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

using P = Pa<int,int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Q;
    cin >> N >> Q;
    vec<int> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    vvec<mint> dp(N,vec<mint>(N));

    for(int i=0;i<N;i++) for(int j=0;j<N;j++) if(A[i]<=A[j]) dp[i][j] = 1;
    mint inv2 = ((mint) (2)).inv();
    for(int _=0;_<Q;_++){
        int x,y;
        cin >> x >> y;
        x--; y--;
        if(x>y) swap(x,y);
        vec<mint> dpx(N,1),dpy(N,1);
        vec<mint> dp_x(N,1),dp_y(N,1); 
        for(int i=0;i<N;i++){
            if(i!=x && i!=y){
                dpx[i] = (dp[x][i]+dp[y][i])*inv2;
                dp_x[i] = (dp[i][x]+dp[i][y])*inv2;
            }
            if(i!=x && i!=y){
                dpy[i] = (dp[y][i]+dp[x][i])*inv2;
                dp_y[i] = (dp[i][x]+dp[i][y])*inv2;
            }
        }
        dpx[y] = (dp[x][y]+dp[y][x])*inv2;
        dpy[x] = (dp[x][y]+dp[y][x])*inv2;
        dp[x].swap(dpx);
        dp[y].swap(dpy);
        for(int i=0;i<N;i++) if(i!=x && i!=y){
            dp[i][x] = dp_x[i];
            dp[i][y] = dp_y[i];
        }
    }
    mint ans = 0;
//    for(int i=0;i<N;i++) for(int j=0;j<N;j++) cerr << dp[i][j] << (j!=N-1? " ":"\n");
    for(int i=0;i<N;i++) for(int j=i+1;j<N;j++) ans += ((mint) 1-dp[i][j]);
    cout << ans*((mint) 2).pow(Q) << "\n";
}

Measured memory_bytes: 72832
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		StringBuilder str = new StringBuilder();

		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='B') {
				if(str.length()!=0) {
					str.deleteCharAt(str.length()-1);
				}
			}else {
				str.append(s.charAt(i));
			}
		}
		System.out.println(str);
		/*if(N!=0) {
			System.out.println("Yes");//Yes or YES注意！！
		}else {
			System.out.println("No");//No or NO注意！！
		}*/

	}
	public static int sample(int n) {
		return n;
	}

}


Measured memory_bytes: 21332
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
const ll N = 1000000000000000;

int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int c[2019];
    fill(c, c + 2019, 0);
    ++c[0];

    int ans = 0, n = 0, m = 1;
    for (int i = 0; i < s.size(); ++i) {
        n = (n + m * (s[i] - '0')) % 2019;
        m = (m * 10) % 2019;
        ++c[n];
        if (i < 3) {
            continue;
        }
        ans += c[n] - 1;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

typedef long long LL;

LL a[200010], f[200010], sum[200010];
LL n;

int main() {
    read(n);
    for (int i = 1; i <= n; ++i)    read(a[i]);
    sum[1] = a[1];
    for (int i = 2; i <= n; ++i)    sum[i] = sum[i - 2] + a[i];
    for (int i = 2; i <= n; ++i) {
        if (i & 1) {
            f[i] = std::max(f[i - 1], f[i - 2] + a[i]);
        } else {
            f[i] = std::max(f[i - 2] + a[i], sum[i - 1]);
        }
    }
    printf("%lld\n", f[n]);
    return 0;
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    ll l,r;
    cin>>l>>r;

    ll ans=1LL<<60;
    for(int i=l;i<=min(r,l+3000);i++){
        for(int j=i+1;j<=min(r,l+3000);j++){
            ll tmp=i%2019;
            tmp=(tmp*(j%2019))%2019;
            ans=min(ans,tmp);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

void run (void) {
  i32 n, sum;
  scanf ("%" SCNi32 "%" SCNi32, &n, &sum);
  for (i32 x = 0; x <= n; ++x) {
    for (i32 y = 0; y <= n - x; ++y) {
      for (i32 z = 0; z <= n - x - y; ++z) {
        if (10000 * x + 5000 * y + 1000 * z == sum && x + y + z == n) {
          printf ("%" PRIi32 " %" PRIi32 " %" PRIi32 "\n", x, y, z);
          return;
        }
      }
    }
  }
  puts ("-1 -1 -1");
}

int main (void) {
  run();
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long 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;
}

int main() {
    string s;
    cin >> s;
    if(s == "ABC") {
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        if(a==b && b== c) cout<<a<<" "<<b<<" "<<c<<endl;
        else cout<<c<<" "<<a<<" "<<b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long x,y;
    cin >> x >> y;
    long ans = 0;
    if(x==0){
        x += abs(y);
        ans += abs(y);
    }
    
    if(y-x == abs(abs(y)-abs(x))){
        ans += y-x;
    }else if(y+x ==abs(abs(y)-abs(x)) || -y-x == abs(abs(y)-abs(x))){
        ans += abs(abs(y)-abs(x))+1;
    }else{
        ans += abs(abs(y)-abs(x))+2;
    }




    cout << ans << endl;

}

Measured memory_bytes: 3600
# Binary tree 二分木の表現


class Node():
    
    def __init__(self):
        self.parent = -1
        self.left = -1
        self.right = -1


def settype(u):
    if T[u].parent == -1:
        Type[u] = "root"
    elif Deg[u] == 0:
        Type[u] = "leaf"
    else:
        Type[u] = "internal node"


def setdepth(u, p):
    Dep[u] = p
    if T[u].left != -1:
        setdepth(T[u].left, p + 1)
    if T[u].right != -1:
        setdepth(T[u].right, p + 1)


def setheight(u):
    hl, hr = 0, 0
    if T[u].left != -1:
        hl = setheight(T[u].left) + 1
    if T[u].right != -1:
        hr = setheight(T[u].right) + 1
    H[u] = max(hl, hr)
    return H[u]


n = int(input())
T = [Node() for i in range(n)]
S = [-1 for i in range(n)]
Deg = [0 for i in range(n)]

for i in range(n):
    id, left, right = (int(j) for j in input().split())
    if left != -1:
        T[id].left = left
        T[left].parent = id
        S[left] = right
        Deg[id] += 1
    if right != -1:
        T[id].right = right
        T[right].parent = id
        S[right] = left
        Deg[id] += 1

rootid = -1

for id in range(n):
    if T[id].parent == -1:
        rootid = id
        break

Dep = [-1 for i in range(n)]
setdepth(rootid, 0)

Type = ["" for i in range(n)]
for id in range(n):
    settype(id)

H = [-1 for i in range(n)]
setheight(rootid)

for id in range(n):
    print("node ", id, ": parent = ", T[id].parent, ", sibling = ", S[id], ", degree = ", Deg[id], ", depth = ", Dep[id], ", height = ", H[id], ", ", Type[id], sep="")



Measured memory_bytes: 5656
package main

import(
    "fmt"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    fmt.Println((a+b)%24)
}





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

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
int a[30];
bool ok;
int main(){
		string s;
		cin >> s;
		for(int i = 0;i < s.size();i++){
			a[s[i]-'a']++;	
			}
		for(int i = 0;i <= 26;i++){
			if(a[i]%2)ok=1;	
			}
		if(ok)puts("No");
		else puts("Yes");
		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/arc067_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, A ,B;
  cin >> N >> A >> B;
  
  vector<ll> c(N);
  rep(i, N) { cin >> c[i]; }

  ll ans = 0;
  rep(i, N - 1) { ans += min((c[i + 1] - c[i]) * A, B); }

  cout << ans << endl;
}

Measured memory_bytes: 3996
#include <algorithm>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using ll = long long;
using namespace std;
static ll imin = std::numeric_limits<ll>::min() / 2;
static ll imax = std::numeric_limits<ll>::max() / 2;
#define rep(i, n) for (ll i = 0; (i) < (n); ++(i))
#define rep1(i, n) for (ll i = 1; (i) < (n); ++(i))
#define rev_rep(i, n) for (ll i = (n)-1; (i) >= 0; --(i))
#define range(a, i, b) for (ll i = (a); (i) < (b); ++(i))

#ifdef LOCAL
#define dump(x) cout << #x << ":" << x << "\n";
#endif

#define all(v) v.begin(), v.end()
#define readl(N) \
  ll N;          \
  cin >> N
#define readlv(N, vec) \
  vector<ll> vec(N);   \
  rep(i, N) { cin >> vec[i]; }
#define greater_than [](ll l, ll r) { return l > r; }
template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::map<T1, T2>& mp);
template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& pair);
template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& vec);
template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& pair) {
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template <class T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& vec) {
  std::size_t n = vec.size();
  if (n == 0) {
    return os;
  }
  os << " ";
  for (ll i = 0; i < n - 1; ++i) {
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template <class T1, class T2>
std::ostream& operator<<(std::ostream& os, std::map<T1, T2>& mp) {
  std::size_t n = mp.size();
  if (n == 0) {
    return os;
  }
  os << " ";
  for (auto&& x : mp) {
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template <class T>
std::ostream& operator<<(std::ostream& os, std::set<T>& mp) {
  std::size_t n = mp.size();
  if (n == 0) {
    return os;
  }
  os << " ";
  for (auto&& x : mp) {
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

ll fact(ll n) {
  ll res = 1;
  while (n > 0) {
    res *= n;
    n--;
  }
  return res;
}

ll pow(ll i, ll n) {
  ll res = 1;
  while (n >= 0) {
    res *= i;
    n--;
  }
  return res;
}

ll gcd(ll l, ll r) {
  if (l < r) {
    return gcd(r, l);
  }
  if (r == 0) {
    return l;
  }
  return gcd(r, l % r);
}

template <class T>
vector<T> accum_sum(vector<T> a) {
  vector<T> b(a.size() + 1);
  b[0] = a[0];
  rep(i, a.size()) { b[i + 1] = b[i] + a[i]; }
  return b;
}
constexpr ll mod = 1e9 + 7;
vector<ll> input;

int main(int argc, char const* argv[]) {
  readl(H);readl(W);
  readl(h);readl(w);
  cout << H * W - h * W -  w * H + h * w << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;


void solve(long long N, long long D, std::vector<long long> X, std::vector<long long> Y){
    long long result = 0;
    REP(i, N) { 
        if(sqrt(X[i] * X[i] + Y[i] * Y[i]) <= D ) { 
            result++;
        }
    }
    cout << result << endl;
    return;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
    }
    solve(N, D, std::move(X), std::move(Y));
    return 0;
}


Measured memory_bytes: 6488
# coding: utf-8
AB = input().split()
A = int(AB[0])
B = int(AB[1])
ans = 0
if A>B:
  ans +=A
  A = A -1
else:
  ans +=B
  B = B -1

if A>B:
  ans +=A
else:
  ans +=B

print(ans)


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int h;
    cin >> h;
    if (h >= K) ans++;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = set(a)
c = []
x = 1
ans = 0

if(len(b) > k):
    for i in range(1,n):
        if(a[i]!=a[i-1]):
            c.append(x)
            x = 1
        else:
            x += 1
    c.append(x)
    c.sort()
    for i in range(len(b) - k):
        ans += c[i]
        
print(ans)


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

using namespace std;

int main()
{
	int N, P;
	cin >> N >> P;
	vector<long long> A(N);

	int num_odd = 0;
	for (auto &x : A) {
		cin >> x;
		if (x % 2 != 0) {
			++num_odd;
		}
	}

	if (num_odd == 0) {
		if (P == 0) {
			cout << (1LL << N) << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else {
		cout << (1LL << (N - 1)) << endl;
	}
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())
a = make_divisors(N)
if N < 100000:
    ans = 0
    for n in range(1, N):
        a = N%n
        b = N//n

    #     print(n, a, b, a == b)
        if a == b:
            ans += n
#     print([ a +1 for a in anss], sum(anss), len(anss))
    print(ans)
else:
    if len(a)%2 == 0:
        print(sum(a[len(a)//2:]) - len(a)//2)
    else:
        print(sum(a[len(a)//2 + 1:]) - len(a)//2)

Measured memory_bytes: 3280
import java.util.*;
 
public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        long N = sc.nextLong();
        long M = sc.nextLong();
        sc.close();
        
        if(N == 1 && M == 1)
            System.out.println(1);
        else if(N==1)
            System.out.println(M-2);
        else if(M==1)
            System.out.println(N-2);
        else {
            System.out.println((N-2) * (M-2));
        }
    }
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);

    std::vector<std::string> result;

    while(first < str.size()) {
        std::string subStr(str, first, last - first);

        result.push_back(subStr);

        first = last + 1;
        last = str.find_first_of(del, first);

        if(last == std::string::npos) {
            last = str.size();
        }
    }

    return result;
}

int N;

int main() {
    cin >> N;
    double sum = 0;
    REP(i, N) {
        double X;
        cin >> X;
        SCIN(u);
        if(u == "JPY") {
            sum += X;
        } else {
            sum += X * 380000.0;
        }
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 256
x,y,z,k = map(int,input().split())
list1 = [list(map(int,input().split())) for i in range(3) ]

list_ab = []
list_ab_c = []

for i in list1[0]:
	for j in list1[1]:
		list_ab.append(i+j)
list_ab.sort(reverse=True)
for i in list_ab[:3000]:
	for j in list1[2]:
		list_ab_c.append(i+j)

list_ab_c.sort(reverse=True)

for i in range(k):
	print(list_ab_c[i])

Measured memory_bytes: 156660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for(int64_t &x: A)
    {
        cin >> x;
        if(x==0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    int64_t ttl=1;
    int64_t test=1000000000000000000;
    for (int i = 0; i < N; i++)
    {
        ttl*=A[i];
        test/=A[i];
    }
    if(test==0) cout << -1 << endl;
    else cout << ttl << endl;
    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>    //万能头文件
using namespace std;
string  st;
int ans;        //记录次数
bool flag = true;    //用来标记是否能构造回文
int main()
{
    cin >> st;
    int L=0,R = st.size() - 1;  //定义左、右端
    while ( L <= R )    //运行到字符串中间
    {
        if ( st[L] == st[R] ) {L++,R--;continue;}   //相同则不管它
        if ( st[L] == 'x' ) {L++,ans++;continue;}   //判断左端是否为x
        if ( st[R] == 'x' ) {R--,ans++;continue;}   //同理
        flag = false; break;    //上面方法都行不通，标记，退出循环
    }
    ans = flag ? ans : -1;  
    cout << ans ;   //输出
    return 0;  //记得打return 0
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, pair<int,int> > iii;
int n,cnt=0,res=0,x,y,farm[300000];
vector< pair<int,int> > adjx,adjy;
priority_queue<iii,vector<iii>,greater<iii> > pq;
int Find(int n)
{
	if(farm[n]<0) return n;
	else return farm[n]=Find(farm[n]);
}
void Union(int x,int y)
{
	x=Find(x),y=Find(y);
	if(x!=y)
	{
		farm[x]+=farm[y];
		farm[y]=x;
	}
}
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		adjx.push_back({x,i});
		adjy.push_back({y,i});
	}
	sort(adjx.begin(),adjx.end());
	sort(adjy.begin(),adjy.end());
	for(int i=0;i<=n-2;i++)
	{
		pq.push({abs(adjx[i].first-adjx[i+1].first),{adjx[i].second,adjx[i+1].second}});
		pq.push({abs(adjy[i].first-adjy[i+1].first),{adjy[i].second,adjy[i+1].second}});
	}
	memset(farm,-1,sizeof(farm));
	while(!pq.empty())
	{
		if(cnt==n-1) break;
		int u=pq.top().second.first,v=pq.top().second.second,val=pq.top().first;
		pq.pop();
		if(Find(u)!=Find(v))
		{
			cnt++;
			Union(u,v);
			res=res+val;
		}
	}
	cout<<res;
}

Measured memory_bytes: 13404
#include<cstdio>
#include<cstring>
#include<algorithm>

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

using namespace std;

int main(){
	int T; scanf("%d%*c",&T);
	while(T--){
		char s[1024]; fgets(s,200,stdin);
		int len=strlen(s);
		s[--len]='\0';

		int cur=0;
		int m; scanf("%d",&m);
		while(m--){
			char cmd[9]; scanf("%s ",cmd);
			char arg[200]; fgets(arg,200,stdin); arg[strlen(arg)-1]='\0';

			if(cmd[0]=='f' && arg[0]=='c'){ // forward char
				cur=min(cur+1,len);
			}
			else if(cmd[0]=='f' && arg[0]=='w'){ // forward word
				for(;cur<len;cur++) if(s[cur]!=' ') break;
				for(;cur<len;cur++) if(s[cur]==' ') break;
			}
			else if(cmd[0]=='b' && arg[0]=='c'){ // backward char
				cur=max(cur-1,0);
			}
			else if(cmd[0]=='b' && arg[0]=='w'){ // backward word
				for(;cur>0;cur--) if(s[cur-1]!=' ') break;
				for(;cur>0;cur--) if(s[cur-1]==' ') break;
			}
			else if(cmd[0]=='d' && arg[0]=='c'){ // delete char
				if(cur<len){
					for(int i=cur;i<len;i++) s[i]=s[i+1];
					len--;
				}
			}
			else if(cmd[0]=='d' && arg[0]=='w'){ // delete word
				if(cur<len){
					int i=cur;
					for(;i<len;i++) if(s[i]!=' ') break;
					if(i<len){ // J[\È~ª·×ÄóÈçíµÈ¢
						for(;i<len;i++) if(s[i]==' ') break;
						rep(j,len-i+1) s[cur+j]=s[i+j];
						len-=i-cur;
					}
				}
			}
			else{ // insert
				// "" ðí
				int len2=strlen(arg)-2;
				rep(i,len2) arg[i]=arg[i+1];
				arg[len2]='\0';

				for(int i=len;i>=cur;i--) s[i+len2]=s[i];
				rep(i,len2) s[cur+i]=arg[i];
				cur+=len2;
				len+=len2;
			}
		}

		rep(i,len+1){
			if(i==cur) putchar('^');
			if(i<len) putchar(s[i]);
		}
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,sum=0;
	cin>>a>>b>>c>>d;
	for(int i=0;i<a;i++)
	{
		if(i<b) sum+=c;
		else sum+=d;
	}
	cout<<sum;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;
    


int main(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-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};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vec a(n);
    loop(i, n) cin >> a[i];
    ll ans = 0;
    loop(i, n)
    {
        ans += a[i] / 2;
        a[i] -= (a[i] / 2) * 2;
        if (i == n - 1)
            break;
        ans += min(a[i], a[i + 1]);
        a[i + 1] -= min(a[i], a[i + 1]);
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 1024