akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException {
				
		BufferedReader bis=new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(bis);
		
		
	    int data;
	    for(int i =1;;i++){data=sc.nextInt();
	    
	      if(data!=0){
	    	System.out.println("Case "+i+": "+data);
	    }else{break;}}
	
		
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define write(x) cerr << #x << " = " << (x) << ", "
#define writeI0 cerr << "i = " << 0 << ", "
#define dumpI0 cerr << "i = " << 0 << endl
#define printSet(x) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

int c[3];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    cin >> s;
    rep(i, 0, LEN(s)) {
        c[ s[i]-'a' ]++;
    }
    if(LEN(s) == 1) {
        cout << "YES";
        return 0;
    }
    if(LEN(s)==2) {
        if(s[0] == s[1]) cout << "NO";
        else cout << "YES";
        return 0;
    }
    int mn = 1e9;
    rep(i, 0, 3) {
        mn = min(mn, c[i]);
    }

    int d = 0;
    rep(i,0,3) {
        c[i] -= mn;
        if(c[i] > 1) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool check(ll a, ll b, ll c){
	if(a == b || b == c || c == a)
		return 0;
	return a+b > c;
}
int main(){
  ll n;
	cin >> n;

	vector<ll> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];	
	}

	sort(v.begin(), v.end());
	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){

			ll a = v[i], b = v[j], c = 0;
			for(int k = j+1; k < n; k++){
				c = v[k];
				if(check(a,b,c) && check(a,c,b) && check(b,c,a)){
					ans++;
				}
			}
		}
	}

	cout << ans << "\n";
}

Measured memory_bytes: 3632
#!/usr/bin/env ruby

if __FILE__ == $0
	loop do
		x, y = gets.split().map { |a| a.to_i }
		if x == 0 and y == 0 then
			break
		end

		puts '%d %d' % (x < y ? [x, y] : [y, x])
	end
end



Measured memory_bytes: 6904
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int n;
char s[300001];
int r[300000] = { 0 };
int l[300000] = { 0 };


int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	scanf("%d", &n);
	scanf("%s", s);

	REPS(i, n-1) {
		l[i] = l[i - 1];
		if (s[i - 1] == 'W')l[i]++;
		//PRINTD(l[i]);
	}
	RREP(i, n - 1) {
		r[i] = r[i + 1];
		if (s[i+1] == 'E')r[i]++;
		//PRINTD(r[i]);
	}
	int min = 1e9;
	REP(i, n) {
		if (min > l[i]+r[i])min = l[i]+r[i];
	}
	PRINTD(min);
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    rep(i,N - 2){
        string l = S.substr(i,3);
        if (l == "ABC") ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b;
    cin >>a >> b;
    if(a == b ) cout << "Draw"<<endl;
    else if(a == 1) cout << "Alice"<<endl;
    else if(b == 1) cout << "Bob"<<endl;
    else if(a > b) cout << "Alice"<<endl;
    else cout <<"Bob"<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
def valid(arr)
  cnt = 0
  0.upto($t.size-1) do |i| 
    if arr[i] == $t[i]
      cnt += 1
    end
  end
  return cnt
end
s = gets.chomp
$t = gets.chomp
max = 0
0.upto(s.size-$t.size) do |i|
  max = [max, valid(s[i..(i+$t.size-1)])].max
end

puts $t.size - max

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

struct Card { char suit, value;};

void bubble (struct Card A[], int N){
	for (int i = 0; i < N ; i++) {
		for (int j = N - 1; j >= i ; j--) {
			if ( A[j].value < A[j - 1].value) {
				Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
			}
		}
	}
}

void selection (struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j].value < A[minj]. value) minj = j;
		}
		Card t = A[i]; A[i] = A[minj]; A[minj] = t;
	}
}

void print (struct Card A[], int N) {
	for ( int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout <<A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable (struct Card C1[],struct Card C2[], int N) {
	for (int i = 0; i < N; i++) {
		if (C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main() {
	Card C1[100], C2[100];
	int N;
	string ch;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C1[i].suit >> C1[i].value;
	}

	for (int i = 0; i < N; i++) C2[i] = C1[i];

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if (isStable(C1, C2, N)) {
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}
	return 0;
}



Measured memory_bytes: 3132
#include <iostream>
using namespace std;
 
int main(){
 
    int a[26]={0};
    char s;
 
    while(cin >> s){
        if('a'<=s && s<='z'){
            a[s-'a']++;
        }
        else if('A'<=s && s<='Z'){
            a[s-'A']++;
        }
    }
 
    for(int i=0; i<26; i++){
        cout << (char)(i+'a') << " : " << a[i] << endl; 
    }
	return 0;
}

Measured memory_bytes: 3104
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;
	long ans;
	foreach (i; A..B+1)
	{
		auto s = i.to!string;
		bool ok = true;
		foreach (j; 0..s.length/2)
		{
			if (s[j] != s[$-j-1])
			{
				ok = false;
				break;
			}
		}
		if (ok) ++ans;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 1276
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintStream out = System.out;
		int x = Integer.parseInt(in.readLine());

		out.println((int)Math.pow(x, 3));
	}
}

Measured memory_bytes: 17060
#include <stdio.h>

#define MAX_N 1000000

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };
int sum_p[ MAX_N / 2 ] = { 2 }, p = 1;

int main( void ) {
	int i, j, n, sum;

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	sum = 2;
	for ( i = 3; i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			sum_p[ p++ ] = sum += i;

	for ( ; scanf( "%d", &n ), n; printf( "%d\n", sum_p[ n - 1 ] ) ) ;

	return 0;
}

Measured memory_bytes: 4812
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=(n)-1;i>=0;--i)
#define REPI(i,a) for(typeof((a).begin()) i=(a).begin();i!=(a).end();++i)
#define REPIR(i,a) for(typeof((a).rbegin()) i=(a).rbegin();i!=(a).rend();++i)
#define FOR(i,a,b) for(typeof(a) i=a;i!=(b);++i)
#define CLEAR(a,v) memset(a,v,sizeof(a))
#define SORT(a) sort(a,a+sizeof(a)/sizeof(a[0]))
#define ALL(v) (v).begin(),(v).end()
#define MP make_pair
#define PB push_back
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

int searchmin(int root, VI* winc, VVI* win){
  int w = (*winc)[root];
  if(w == 0){ return 0; }
  VI depth(w);
  REP(i,w){
    depth[i] = searchmin((*win)[root][i], winc, win);
  }
  sort(depth.begin(), depth.end(), greater<int>());
  int ret = 0;
  REP(i,w){
    int d = depth[i] + i;
    if(ret < d){
      ret = d;
    }
  }
  return ret + 1;
}

int main(){
  int N;
  cin >> N;
  VI winc(N, 0);
  VVI win(N, VI());
  FOR(i,1,N){
    int a;
    cin >> a;
    a--;
    winc[a]++;
    win[a].PB(i);
  }
  int ret = searchmin(0, &winc, &win);
  cout << ret << endl;
}


Measured memory_bytes: 18560
from itertools import accumulate
from bisect import bisect_right
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
b=list(accumulate(B))
book=bisect_right(b,K)
for i,a in enumerate(accumulate(A),1):
    if a>K:
        break
    j=bisect_right(b,K-a)
    book=max(book,i+j)
print(book)

Measured memory_bytes: 41192
$n,$m,q = gets.chomp.split.map(&:to_i)
$abcd = []

q.times do
  $abcd << gets.chomp.split.map(&:to_i)
end

$ans = 0

def max(a,b)
  a > b ? a : b
end

def dfs(arr)
  if arr.size == $n
    tmp_ans = 0
    $abcd.each do |a, b, c, d|
      tmp_ans += d if arr[b-1] - arr[a-1] == c
    end
    $ans = max($ans, tmp_ans)
    # p arr
    return
  end

  num = arr.last

  ($m - num + 1).times do |i|
    dfs(arr.dup.push(num+i))
  end
end

1.upto($m) do |start|
  dfs([start])
end

p $ans




Measured memory_bytes: 15572
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

ll N, A, B, C, D;
string S;

bool solve() {
	for (ll i = A + 1; i < C - 1; i++) {
		if (S[i] == '#'&&S[i + 1] == '#') { return 0; }
	}

	for (ll i = B + 1; i < D - 1; i++) {
		if (S[i] == '#'&&S[i + 1] == '#') { return 0; }
	}

	if (C < D) { return 1; }

	for (ll i = B; i <= D; i++) {
		if (S[i - 1] == '.'&&S[i] == '.'&&S[i + 1] == '.') { return 1; }
	}

	return 0;
}


int main() {
	cin >> N >> A >> B >> C >> D;
	cin >> S;
	S = '?' + S;

	ll b = solve();

	if (b == 1) { cout << "Yes"; }
	else { cout << "No"; }

	
	system("PAUSE");

}





Measured memory_bytes: 836
def main():
    m,k=map(int,input().split())
    if 2**m<=k:
        print(-1)
    elif m==0:
        if k==0:
            print(0,0)
        else:
            print(-1)
    elif m==1:
        if k==0:
            print(1,0,0,1)
        else:
            print(-1)
    else:
        ans=[]
        for i in range(2**m-1,-1,-1):
            if i!=k:
                ans.append(i)
        ans.append(k)
        for i in range(2**m):
            if i!=k:
                ans.append(i)
        ans.append(k)
        print(*ans)
main()

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

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
//#define sort(a,n) qsort(a,n,sizeof(int),cmpfunc)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define itn int
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define endl '\n'
#define nl printf("\n");
#define fors(i,n) for(int i=0; i<n; i++)
#define fore(i,n) for(int i=n-1; i>=0; i--)
#define forv(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef pair<int,int> pii;
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
void ASCII_Chart(){int i,j,k;printf("ASCII Chart:(30-129)\n");forv(i,30,50){fors(j,5){k=i+j*20;printf("%3d---> '%c'   ",k,k);}printf("\n");}}
const int INF = 0x3f3f3f3f;
#define pi 3.14159265
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}

//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
class node{
public:
	int id;
	int prio;
	int prd;
};

class compare{
public:
	bool operator()(node &n1, node &n2){
		if(n1.prio>n2.prio)//ascending
			return true;
		else if(n1.prio==n2.prio){
			return n1.id>n2.id;
		}
		return false;
	}
};
//priority_queue<node, vector<node>, compare> pq;

int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifdef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #else
    // online submission
    #endif*/
    
   st str;
   cin>>str;
   if(str.length()>3){
       if(str[0]=='Y'&&str[1]=='A'&&str[2]=='K'&&str[3]=='I'){
           cout<<"Yes";
       }
       else cout<<"No";
   }
   else cout<<"No";
    return 0;
}



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

#define printl(s) cout << s << endl;
#define print(s) cout << s << endl; return 0;
#define yes cout << "Yes" << endl; return 0;
#define no cout << "No" << endl; return 0;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n)+1; ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

ll calculateDivNums(ll tg){
	ll ans = 0;
	for(ll a=1;a*a<=tg;a++){
      if(tg%a!=0){
        continue;
      }
      ans++;
      if(tg!=a*a){
        ans++;
      }
    }
  return ans;
 }   



string S;
int N, cnt;

int main(){
  cin >> N;
  rep2(i,N){
    if(i%2==0) continue;
    ll divs = calculateDivNums(i);
    if(divs==8) cnt++;
  }
  
  print(cnt);
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << min({a + b, b + c, c + a}) << '\n';
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

int main(){
    LL n,N[3005],ans=0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>N[i];
    for(int i=0;i<n;i++) ans+=N[i]-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using    namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using ll = long long;
#define pb push_back
#define pi acos(-1)
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    FastIO;
    ll t, i, j, k, n, a, b, c, x, y, cnt = 0;
    cin >> a >> b >> c;
    for(i = a; i <= b; i++){
        if(i % c == 0)
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue> 
#include<cstdlib>
using namespace std;
const int MAXN=5005,INF=2147483647;
char s[MAXN];
int vis[MAXN],len,k;
void dfs(int n,int a[],int num){
	int b[MAXN];
	priority_queue<int> que; 
	for(int i=0;i<n;i++) que.push(-(s[a[i]]-'a'));
	int q=que.size();
	/*
	for(int i=0;i<q;i++){
		cout<<i<<'&';
		cout<<-que.top()<<' ';
		que.pop();
	} cout<<endl;*/
	for(int i=0,last=INF;i<q;i++){
		int x=-que.top(); que.pop();
		if(x==last) continue; last=x;
		int p=0,yes=0;
		for(int i=0;i<n;i++){
			if(s[a[i]]-'a'==x){
				if(yes==0){
					yes=1;
					if(--k==0){
						for(int j=a[i]+1-num;j<=a[i];j++)
							printf("%c",s[j]);
						//cout<<a[i]+2-num<<' '<<a[i]+1<<endl;
						printf("\n");
						exit(0); 
					}
				}
				if(a[i]+1<len) b[p++]=a[i]+1;
			}
		} 
		dfs(p,b,num+1);
	}
}
void solve(){
	int b[MAXN]; 
	for(int i=0;i<len;i++) b[i]=i;
	dfs(len,b,1); 
}
int main(){
	scanf("%s",s); len=strlen(s);
	scanf("%d",&k);
	solve();
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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; }



int N;
string s;
bool one[10];
bool two[100];
set<int> st;

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

  Rep(i, N) {
    int tmp = s[i] - '0';

    //cout << tmp << "\n";

    Rep(k, 100) {
      if (two[k]) {
        //cout << k << "\n";
        //cout << k * 10 + tmp << "\n";
        st.insert(k * 10 + tmp);
      }
    }
    Rep(k, 10) {
      if (one[k]) {
        //cout << k << "\n";
        //cout << k * 10 + tmp << "\n";
        two[k * 10 + tmp] = true;
      }
    }
    one[tmp] = true;
  }

  cout << st.size() << "\n";
} 

Measured memory_bytes: 384
// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define int ll
typedef pair <int, int> pii;
 
#define error(x) cout << #x << " = " << x << endl;
 
const int N = 1e5 + 5, mod = 1e9 + 7;
const ll inf = 1e15;
 
inline int sum(int a, int b) {
	a += b;
	if(a >= mod)
		a -= mod;
	if(a < 0)
		a += mod;
	return a;
}
 
inline int mult(int a, int b) {
	return (1LL * a * b) % mod;
}
 
int n, m, dp[N][2], S, T;
ll dist[N][2];
vector <pii> adj[N];
vector <pair <pii, int> > edge;
 
inline void dijkstra(int src, int id) {
	for (int i = 0; i < n; i++)
		dist[i][id] = inf;
	dp[src][id] = 1;
	dist[src][id] = 0;
	set <pair <ll, int>> s;
	s.insert({0, src});
	while(!s.empty()) {
		pair <ll, int> p = (*s.begin());
		s.erase(p);
		int v = p.second;
		for (auto e : adj[v]) {
			int u = e.first, w = e.second;
			if(dist[u][id] > dist[v][id] + w) {
				s.erase({dist[u][id], u});
				dist[u][id] = dist[v][id] + w;
				s.insert({dist[u][id], u});
				dp[u][id] = dp[v][id];
			}
			else if(dist[u][id] == dist[v][id] + w)
				dp[u][id] = sum(dp[u][id], dp[v][id]);
		}
	}
}

void sub(ll &a,ll b){
		a-=b;
		if(a<0)
		a+=mod;
}
 
int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cin >> n >> m >> S >> T;
	S--, T--;
	for (int i = 0; i < m; i++) {
		int v, u, w;
		cin >> v >> u >> w;
		v--, u--;
		adj[v].push_back({u, w});
		adj[u].push_back({v, w});
		edge.push_back({{u, v}, w});
	}
	dijkstra(S, 0);
	dijkstra(T, 1);
	ll ans = mult(dp[S][1], dp[T][0]);
	// error(dp[S][1]);
	// error(dp[T][0]);
	for (int i = 0; i < n; i++) {
		if(dist[i][0] == dist[i][1]) {
			// error(i);
			sub(ans, mult(mult(dp[i][0], dp[i][0]), mult(dp[i][1], dp[i][1])));
		}
	}

	for (auto e : edge) {
		int vv = e.first.first, uu = e.first.second, w = e.second;
		for (auto x : {make_pair(vv, uu), make_pair(uu, vv)}) {
			int v = x.first, u = x.second;
			if(dist[v][0] < (dist[S][1] / 2) && dist[u][1] < (dist[S][1] / 2) && dist[v][0] + dist[u][1] + w == dist[S][1]) {
				sub(ans, mult(mult(dp[v][0], dp[u][1]), mult(dp[v][0], dp[u][1])));
			}
		}
	}

	cout << ans << "\n";
 
}

Measured memory_bytes: 28980
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define df 0


int main(){
  long int S;
  scanf("%ld",&S);
  long int a=ceil(sqrt(S)), d=(S+a-1)/a;
  
  

  printf("%ld %ld %ld %ld %ld %ld",0,0,a,1,a*d-S,d);
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  string s;
  cin >> s;
  ll sum = 0;
  for (char c : s) sum += c-'0';
  
  if (sum%9==0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 3728
#include <iostream>
#include <cmath>
#include <vector>
#define MAX 32768
using namespace std;

vector<int> sq;
bool isSqNum[MAX+1];
void makeTable() {
  int tmp;
  for(int i = 0; i <= MAX; i++) {
    isSqNum[i] = false;
  }
  sq.clear();
  for(int i = 1; ( tmp = (int)pow((double)i, 2.0) ) <= MAX; i++) {
    sq.push_back(tmp);
    isSqNum[tmp] = true;
  }
}

int n;
int ans;

void rec(int cnt, int sum, int level) {
  if(cnt >= 4) return;
  if(sum > n) return;
  if(n-sum >= sq[level] && isSqNum[n-sum]) {
    ans++;
  }
  for(int i = level; i < sq.size() && sum+sq[i] <= n; i++) {
    rec(cnt+1, sum+sq[i], i);
  }
}

int main() {
  makeTable();
  while(1) {
    cin >> n;
    if(n == 0) break;
    ans = 0;
    rec(0,0,0);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 936
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int H = NextInt();
        int W = NextInt();
        int K = NextInt() - 1;
        int[] dp = new int[W];
        dp[0] = 1;
        for (int row = 0; row < H; row++)
        {
            int[] nxdp = new int[W];

            //bit全探索
            int M = (int)Math.Pow(2, (W - 1));
            for (int bit = 0; bit < M; bit++)
            {
                bool f = false;
                bool can = true;
                int[] _dp = new int[W];
                for (int i = 0; i < W; i++) _dp[i] = dp[i];
                for (int shift = 0; shift < (W - 1); shift++)
                {

                    if ((1 & bit >> shift) == 1)
                    {
                        if (f) { can = false; break; }
                        _dp[shift + 1] = dp[shift];
                        _dp[shift] = dp[shift + 1];
                        f = true;
                    }
                    else { f = false;}
                }
                if (!can) continue;
                for (int i = 0; i < W; i++)
                {
                    nxdp[i] += _dp[i];
                    nxdp[i] %= INF;
                }
            }
            dp = nxdp;
        }
        Console.WriteLine(dp[K]);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

Measured memory_bytes: 11220
#import<cstdio>
int main(){for(int a,c,r,t;r=1,c=3,~a;~-r&&printf("%d\n",r))for(char d[]="12354",s[9];a=scanf("%s",s),*s>60;r+=*d&7)*s%6-4?t=d[a+=*s%5+*s*2+c&3],d[a]=*d,d[++a%4+1]=~*d,*d=~t:c+=*s+3;}

Measured memory_bytes: 0
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = list([])
for i in range(N):
    A.append(list(map(int, input().split())))

cnt = 0
for i in range(N):
#    print("A= " + str(A[i]))
#    print("B= " + str(B))
#    print("C= " + str(C))
    ev = 0
    for j in range(M):
        ev = ev + A[i][j] * B[j]
    ev = ev + C
    if(ev > 0):
        cnt = cnt + 1

print(cnt)


Measured memory_bytes: 3064
/* ex 5_4
   ruuu0048 */

#include <stdio.h>


int main(void){
    //10文字以下なので最大の要素数は\0を含めて11
    char word[11],*ptr;
    //count:数える変数 count_max:最大のACGT文字列の長さ
    int count=0,count_max=0;

    scanf("%s", &word[0]); //文字列を入力

    ptr = &word[0]; //文字列の先頭のアドレスを代入

    while(*ptr){ //文字列の最後まで繰り返す
        if(*ptr=='A' ||*ptr=='C'||*ptr=='G'||*ptr=='T'){ //もしももACGTのどれかだったら
            count++; //数える
            if(count > count_max){ //数えたものが今までの最大よりも大きかったら
                count_max = count; //最大値を更新
            }
        }
        else{ //ACGT以外だったら
            count=0; //カウンターをリセット
        }
        ptr++; //ptrの位置を一つ右にずらす
    }
    printf("%d\n",count_max); //最大のAGCT文字列の長さを出力

    return 0;
}

Measured memory_bytes: 1728
import itertools
A,B,C,X, Y = list(map(int,input().split(" ")))
C2 = C * 2
ans = 0

if A+ B > C2:
    c = min(X,Y)
    ans += min(X,Y) * C2
    X -= c
    Y -= c



if A > C2:
    if B < C2:
        b_maisu = max(0,Y-X)
        ans += (X *  C2) + b_maisu * B


    else:
        ans += (max(X,Y)*C2)

elif A < C2:
    if B < C2:
        ans += A*X + Y * B
    else:
        a_maisu = max(0,X-Y)
        ans += (Y *  C2) + a_maisu * A

print(ans)


Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ld Calc_Dist (ld X1, ld Y1, ld X2, ld Y2){
  ld ans = (X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2);
  ans = sqrtl(ans);
  return ans;
}

int main(){
  const ld EPS = 1e-10;
  int N, K; cin >> N >> K;

  ld X[N], Y[N], C[N];
  for (int i = 0; i < N; i++){
    cin >> X[i] >> Y[i] >> C[i];
  }

  ld L = 0, R = 1e10;
  while (R - L > EPS){
    ld now = (L + R) / 2;

    vector <pair<ld, ld>> Cand;


    for (int i = 0; i < N; i++){
      Cand.push_back(make_pair(X[i], Y[i]));
      for (int j = i + 1; j < N; j++){
        ld Ri = now / C[i], Rj = now / C[j];
        ld Dist = Calc_Dist(X[i], Y[i], X[j], Y[j]);

        if (Dist < abs(Ri - Rj) - EPS) continue;
        if (Dist > Ri + Rj + EPS) continue;

        double theta = atan((Y[j] - Y[i]) / (X[j] - X[i]));
        
        if (X[j] - X[i] <= 0) theta += PI;
        else if (Y[j] - Y[i] <= 0) theta += 2 * PI;

        double phi = acos((Ri * Ri + Dist * Dist - Rj * Rj) / (2 * Ri * Dist));

        double Xnow = X[i] + Ri * cos(theta + phi);
        double Ynow = Y[i] + Ri * sin(theta + phi);
        Cand.push_back(make_pair(Xnow, Ynow));

        Xnow = X[i] + Ri * cos(theta - phi);
        Ynow = Y[i] + Ri * sin(theta - phi);
        Cand.push_back(make_pair(Xnow, Ynow));
      }
    }
    
    bool flag = false;
    for (int i = 0; i < Cand.size(); i++){
      int cnt = 0;
      ld X_now = Cand[i].first, Y_now = Cand[i].second;

      for (int j = 0; j < N; j++){
        ld Dist = Calc_Dist(X_now, Y_now, X[j], Y[j]);
        if (Dist <= now / C[j] + EPS) cnt++;
      }
      if (cnt >= K) flag = true;
    }
    
    if (flag == true) R = now;
    else L = now;
  }
  cout << setprecision(16) << (L + R) / 2 << endl;

  return 0;
}


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

int main() {
  int n,m;
  cin >> n>> m;
  
  int sum = 0;
  if (n != 0 && n!= 1){
    sum += n * (n-1) /2;
  }
  if (m != 0 && m!= 1){
    sum += m * (m-1) /2;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //CLion Standard Input for DEBUG
    //--------------------------------------------------------------------------
//    ifstream in("/Users/ryo/Dropbox/competition/CompetitivePrograming/in.txt");
//    cin.rdbuf(in.rdbuf());
    //-------------------------------------------------------------------------

    const ll MOD = 1e9+7;
    int n;
    cin >> n;

    ll ans = 1;
    for(int i = 1; i <= n; i++){
        ans *= i;
        ans = ans % MOD;

    }
    cout << ans << endl;

}

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

int main() {
	int N;
	cin >> N;
	vector<ll> H(3 * N);
	for (int i = 0;i < 3 * N;i++)
		cin >> H[i];

	multiset<ll> l;
	ll ls = 0;
	for (int i = 0;i < N;i++) {
		l.insert(H[i]);
		ls += H[i];
	}
	vector<ll> La(N + 1);
	La[0] = ls;
	auto it = l.begin();
	for (int i = 0;i < N;i++) {
		if (*it < H[N + i]){
			ls -= *it;
			ls += H[N + i];
			l.erase(it);
			l.insert(H[N + i]);
			it = l.begin();
			La[i + 1] = ls;
		}
		else
			La[i + 1] = ls;
	}

	priority_queue<ll> r;
	ll rs = 0;
	for (int i = 3 * N - 1;i >= 2 * N;i--) {
		r.push(H[i]);
		rs += H[i];
	}
	vector<ll> Ra(N + 1);
	Ra[N] = rs;
	ll it2 = r.top();
	for (int i = N - 1;i >= 0;i--) {
		if (it2 > H[N + i]) {
			rs -= it2;
			rs += H[N + i];
			r.pop();
			r.push(H[N + i]);
			it2 = r.top();
			Ra[i] = rs;
		}
		else
			Ra[i] = rs;
	}

	ll ans = La[N] - Ra[N];
	for (int i = 0;i < N;i++) {
		//cout << La[i] << " " << Ra[i] << endl;
		ans = max(La[i] - Ra[i], ans);
	}
	//cout << La[N] << " " << Ra[N] << endl;
	cout << ans << endl;
}

Measured memory_bytes: 9720
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_be = sum(B)
for i in range(N):
    if A[i] >= B[i]:
        A[i] -= B[i]
        B[i] = 0
    elif A[i] < B[i]:
        B[i] -= A[i]
        A[i] = 0
        if A[i+1] >= B[i]:
            A[i+1] -= B[i]
            B[i] = 0
        elif A[i+1] < B[i]:
            B[i] -= A[i+1]
            A[i+1] = 0
sum_af = sum(B)
print(sum_be - sum_af)

Measured memory_bytes: 19000
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int x,ans=0;
  rep(i,n){
    cin>>x;
    if(abs(x-0)<abs(x-k)){
      ans+=abs(x-0)*2;
    }
    else{
      ans+=abs(x-k)*2;
    }
  }
  cout<<ans<<'\n';
  return(0);
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

def func(now, ignore):
    if len(ignore) == n:
        return 1
    res = 0
    for i in points[now]:
        if i in ignore:
            continue
        nignore = deepcopy(ignore)
        nignore.append(i)
        res += func(i, nignore)
    return res

n, m = MAP()
ab = [LIST() for _ in range(m)]
points = [[] for _ in range(n)]
for i in range(n):
    for j in range(m):
        if ab[j][0] == i + 1:
            points[i].append(ab[j][1] - 1)
        elif ab[j][1] == i + 1:
            points[i].append(ab[j][0] - 1)
    #points[i].sort()
debug(points)

ans = func(0, [0])
print(ans)

Measured memory_bytes: 69972
import java.util.Scanner;

public class Main {

	void main() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int [n];
		
		for(int i = 0; i <a.length; i++) {
			a[i] = sc.nextInt();
		}
		System.out.print(a[a.length-1]);
		for(int i = a.length-2; i >=0; i--) {
			System.out.print(" " + a[i]);
		}
		System.out.println();
	}
	
	public static void main(String[] args) {
		new Main(). main();
	}

}



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

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

    double ans = 0;
    rep (i, n)
    {
        double x;
        string u;
        cin >> x >> u;
        if (u[0] == 'J')
            ans += x;
        else
            ans += 380000 * x;
    }

    printf("%.6f\n", ans);
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    VI A(N); 
    REP(i,N)
    {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    int cnt = 0;
    int prev = A[0];
    FOR(i,1,N)
    {
        if(prev != A[i]) cnt++;
        prev = A[i];
    }
    cnt++;
    int ans;
    if((N - cnt)%2 == 0) ans = cnt;
    else ans = cnt - 1;

    cout << ans << endl;

}


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

int n;
long long ans = 0;

int main() {
	cin >> n;
	for (int i = 1; i < n + 1; i++) {
		if (i % 3 && i % 5)
			ans += i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
#include<vector>
#include<map>
#include<algorithm>
#define int long long int
#define inf 10000000000000000
#define mod 1000000007
void dfs(int src,vector<int> adj[],int p,int value,int dp[],int answer[])
{
	value+=dp[src];
	answer[src]=value;
	for(int x:adj[src])
	{
		if(x!=p)
		{
			dfs(x,adj,src,value,dp,answer);
		}
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,q;
	cin>>n>>q;
	int j;
	vector<int> adj[n+1];
	for(j=0;j<n-1;j++)
	{
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int dp[n+1]={0};
	for(j=0;j<q;j++)
	{
		int x;
		cin>>x;
		int p;
		cin>>p;
		dp[x]+=p;
	}
	int answer[n+1]={0};
	dfs(1,adj,-1,0,dp,answer);
	for(j=1;j<=n;j++)
	   cout<<answer[j]<<" ";
	cout<<endl;
}


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

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

    int judge = 0;
    string s;
    for (int i = 0; i < N; i++)
    {
        cin >> s;
        if (s == "Y")
        {
            judge++;
            break;
        }
    }

    if (judge == 0)
    {
        cout << "Three" << endl;
    }
    else
    {
        cout << "Four" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define F first 
#define S second
#define int long long int
signed main() 
{ 
    fast;
    int n;
    cin>>n;
    if(n%2 == 1)
    {
        cout<<0;
        return 0;
    }
    int five = 0;
    for(int i=5;(n/i)>=1 ;i = i*(int)5)
    {
        int temp = n/i;
        five+=(temp/2);
    }

    int two = 0;
    for(int i=2;(n/i)>=1;i = i*(int)2)
    {
        int temp = n/i;
        two+=temp;
    }
     //cout<<five<<" "<<two<<endl;
    cout<<min(two,five);
} 

Measured memory_bytes: 256
#include"iostream"
#include"string"
using namespace std;

int main() {
	string s;
	string ans;
	cin >> s;
	int Size = s.size();
	
	int numC = 0;
	for (int i = 2; i < Size - 1; i++)
	{
		if (s.at(i) == 'C')
		{
			numC++;
		}
	}


	int numCap = 0;
	for (int i = 0; i < Size ; i++)
	{
		if ('A'<=s.at(i) && s.at(i)<='Z')
		{
			numCap++;
		}
	}


	if (s.at(0) != 'A'||numC!=1||numCap!=2)
	{
		ans = "WA";
	}
	else 
	{
		ans = "AC";
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

bool myf(string S){
    if(S.size()%2==1)return false;
    REP(i,S.size()/2){
        if(S[i]!=S[S.size()/2+i])return false;
    }
    return true;
}

signed main(){
    string S;cin>>S;
  	S=S.substr(0,S.size()-1);
    int N=S.size();
    REP(i,N){
        if(myf(S)){
            cout<<S.size()<<endl;
            break;
        }
        S=S.substr(0,S.size()-1);
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;


int main() {
	int A;
	int B;
	int C;
	int D;

	cin >> A >> B >> C >> D;
	if (A + B > C + D) {
		cout << "Left" << endl;
	}


	else if(A + B < C + D) {
		cout << "Right" << endl;

	}

	else {
		cout << "Balanced" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int nya(lint n){
  if(n < 10) return n;
  else{
    v1i m;
    lint t = n;
    while(n > 0){
      m.push_back(n%10);
      n /= 10;
    }
    reverse(m.begin(), m.end());
    v3i dp(m.size(), v2i(2, v1i(10)));
    rep(i, m.size()){
      if(i == 0){
        rep(j, 10){
          if(j < m[0]) dp[i][0][j] = 1;
          else if(j == m[0]) dp[i][1][j] = 1;
          else break;
        }
      }
      else{
        rep(j, 10){
          dp[i][0][j] += dp[i-1][0][j];
          if(j > 0) dp[i][0][j] += dp[i-1][0][j-1];
          if(j < 9) dp[i][0][j] += dp[i-1][0][j+1];
        }
        rep(j, 10){
          if(j < m[i]){
            dp[i][0][j] += dp[i-1][1][j];
            if(j > 0) dp[i][0][j] += dp[i-1][1][j-1];
            if(j < 9) dp[i][0][j] += dp[i-1][1][j+1];
          }
          else if(j == m[i]){
            dp[i][1][j] += dp[i-1][1][j];
            if(j > 0) dp[i][1][j] += dp[i-1][1][j-1];
            if(j < 9) dp[i][1][j] += dp[i-1][1][j+1];
          }
          else dp[i][1][j] = 0;
        }
      }
    }
    int s = 0;
    rep(i, 10) s += dp[m.size()-1][0][i] + dp[m.size()-1][1][i];
    if(t < 100) return s + 7;
    if(t < 1000) return s + 30;
    if(t < 10000) return s + 97;
    if(t < 100000) return s + 292;
    if(t < 1000000) return s + 860;
    if(t < 10000000) return s + 2515;
    if(t < 100000000) return s + 7339;
    if(t < 1000000000) return s + 21404;
    if(t < 10000000000) return s + 62422;
    if(t < 100000000000) return s + 182066;
    if(t < 1000000000000) return s + 531104;
    else return s += 10000000;
  }
}

int main() {
  lint k, a = pow(2, 40), b = 1e18;
  cin >> k;
  rep(i, 40){
    if(nya(a) < k) a += pow(2, 39-i);
    else if(nya(a) == k){
      b = min(b, a);
      a -= pow(2, 39-i);
    }
    else a -= pow(2, 39-i);
  }
  if(nya(a) == k) b = min(b, a);
  cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
ans ([0]:_) = []
ans ([n]:x) =
  let r = drop n x
      d = map (\ [a,b] -> (b `div` (gcd a b), a `div` (gcd a b) ) ) $ take n x
      l = foldr1 lcm $ map snd d
      g = foldr1 gcd $ map fst d
      a = map (\ (a,b) -> a * l `div` g `div` b) d
  in
    a++ans r

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ print o
  

Measured memory_bytes: 5108
#include <iostream>

using namespace std;

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

  int cnt=0;
  int res;

  for (int i=0; i < 3; i++) {
    if (S[i] == 'o') {
      cnt++;
    }
  }

  res = 700 + 100*cnt;

  cout << res << endl;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();

    rep(i, n) {
        s[i] = 'x';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256