akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
long long int a[333],b[333],c[333],d[333];

int main(){
    int n;
    cin>>n;
   vector<pint> x(n);
   rep(i,0,n){
       int a,b;
       cin>>a>>b;
       x[i]=make_pair(b,a);
   }
   sort(x.begin(),x.end(),greater<pint>());
   
   vector<pint> y(n);
   rep(i,0,n){
       int a,b;
       cin>>a>>b;
       y[i]=make_pair(a,b);
   }
   sort(y.begin(),y.end());
   
   int cnt=0;
   bool used[101]={};
   rep(i,0,n){
       rep(j,0,n){
           if(used[j])continue;
           if(y[i].fi>x[j].se && y[i].se>x[j].fi){
               cnt++;
               used[j]=true;
               break;
           }
       }
   }
   cout<<cnt<<endl;
   return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
pn = gets.split.map(&:to_i)

max = sum = pn[0...k].inject(:+)

(k...n).each do |i|
  sum = sum - pn[i - k] + pn[i]
  max = sum if max < sum
end

puts (max + k) / 2.0


Measured memory_bytes: 14980
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
typedef int64_t ll;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100000)
#define MOD (998244353)

int main(void)
{
    int h,w,a,b;
    scanf("%d %d %d %d",&h,&w,&a,&b);

    for(int i=0;i<h;i++) 
    {
        for(int j=0;j<w;j++)
        {
            bool ans = i >= b;
            if(j >= a) ans = !ans;
            printf("%d", ans ? 1: 0);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 1152
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 main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	for i := 1; i < 4; i++ {
		if s[i] == s[i-1] {
			fmt.Fprintln(writer, "Bad")
			writer.Flush()
			return
		}
	}

	fmt.Fprintln(writer, "Good")
	writer.Flush()
}


Measured memory_bytes: 640
n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
s = 0
p = 0
for i in range(n):
  indx = al[i] - 1
  s += bl[indx]
  if i > 0 and al[i] - prev == 1:
    s += cl[indx - 1]
  prev = al[i]
print(s)

Measured memory_bytes: 3064
N = int(input())
value_list = [int(i) for i in input().split()]
value_list.sort()
for i in range(N-1):
    min1 = value_list[0]
    min2 = value_list[1]
    value_list.remove(min1)
    value_list.remove(min2)
    add = (min1+min2)/2
    value_list.append(add)
    value_list.sort()
print(value_list[0])

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

int A[101][101] = {0};

int main() {
    int n, i, j, k, v;
    cin >> n;
    for ( i = 0; i < n; i++ ) {
        cin >> j >> k;
        while ( k-- ) {
            cin >> v;
            A[j][v] = 1;
        }
    }

    for ( i = 1; i <= n; i++ ) {
        for ( j = 1; j <=n; j ++ ) {
                if ( j != 1 ) cout << ' ';
            cout << A[i][j];
        }
        cout << endl;
    }
}



Measured memory_bytes: 3156
"""
author : halo2halo
date : 8, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A = int(readline())
S, T = readline().decode('utf-8').split()

C = [None] * (A+A)
C[::2] = S
C[1::2] = T

ans = ''.join(C)

print(ans)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstring>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int const inf = 1 << 29;

int m, n;
bool g[21][21];
int c;
int a[21];
bool vis[21];

void solve(int v){
    vis[v] = true;
    rep(i, m){
        if (!vis[i] && g[v][i])solve(i);
    }
    a[c++] = v;
}

int main(){
    scanf("%d%d",&m,&n);
    rep(i, 21)rep(j, 21)g[i][j] = false;
    rep(i, 21)vis[i] = false;
    rep(i, n){
        int x, y; scanf("%d%d",&x,&y);
        x--; y--;
        g[x][y] = true;
    }
    c = 0;
    rep(i, m)if (!vis[i])solve(i);
    rep(i, m)printf("%d\n", a[m - i - 1] + 1);
}

Measured memory_bytes: 1008
import java.util.*;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigDecimal L = new BigDecimal(sc.next());
        BigDecimal three = new BigDecimal("3");
        
        L = L.divide(three, 6, BigDecimal.ROUND_HALF_UP);
        
        System.out.println(L.multiply(L).multiply(L));
    }
}

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

int main() {
    string s;
    cin >> s;
    if (s[0] != s[1] and s[1] != s[2] and s[2] != s[0]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> G(N, vector<bool>(N, false));
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    G.at(a-1).at(b-1) = true;
    G.at(b-1).at(a-1) = true;
  }
  vector<int> route(N);
  for (int i = 0; i < N; i++) route.at(i) = i;
  int ans = 0;
  do {
    if (route.at(0) != 0) break;
    bool flag = true;
    for (int i = 0; i+1 < N; i++) {
      int now = route.at(i);
      int next = route.at(i+1);
      if (!G.at(now).at(next)) flag = false;
    }
    if (flag) ans++;
  } while (next_permutation(route.begin(), route.end()));
  cout << ans << endl;
}

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

int main()
{
ll n ;
cin >> n ;
string s ;
cin >> s ;
rep(i,s.size()){
  s[i]=s[i]+n;
  if(s[i]>'Z')s[i]-=26;
}
cout << s << endl;
return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				return;
			}
			char[] c = sc.next().toCharArray();
			int[] score = new int[n];
			int card = 0, ba = 0;
			while (card < 100) {
				for (int i = 0; i < n; i++) {
					if (card >= 100) {
						break;
					}
					if (c[card] == 'M') {
						score[i]++;
					} else if (c[card] == 'S') {
						ba += score[i] + 1;
						score[i] = 0;
					} else {
						score[i] += ba + 1;
						ba = 0;
					}
					card++;
				}
			}
			Arrays.sort(score);
			for (int i = 0; i < n; i++) {
				System.out.print(score[i] + " ");
			}
			System.out.println(ba);
		}
	}
}

Measured memory_bytes: 29436
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline ll getint(){
  ll _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline ll add( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x + _y;
  if( _ >= _mod ) _ -= _mod;
  return _;
}
inline ll sub( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x - _y;
  if( _ < 0 ) _ += _mod;
  return _;
}
inline ll mul( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x * _y;
  if( _ >= _mod ) _ %= _mod;
  return _;
}
ll mypow( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 1ll;
  ll _tmp = mypow( _a , _x / 2 , _mod );
  _tmp = mul( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = mul( _tmp , _a , _mod );
  return _tmp;
}
ll mymul( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 0ll;
  ll _tmp = mymul( _a , _x / 2 , _mod );
  _tmp = add( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = add( _tmp , _a , _mod );
  return _tmp;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
#define N 55
LL n , a , x[ N ] , px[ N ];
void build(){

}
void init(){
  n = getint();
  a = getint();
  for( int i = 1 ; i <= n ; i ++ ){
    x[ i ] = getint();
    px[ i ] = px[ i - 1 ] + x[ i ];
  }
}
LL dp[ N ][ N ][ N * N ];
void solve(){
  dp[ 0 ][ 0 ][ 0 ] = 1;
  for( int i = 0 ; i < n ; i ++ )
    for( int j = 0 ; j <= i ; j ++ )
      for( int k = 0 ; k <= px[ i ] ; k ++ ){
        if( dp[ i ][ j ][ k ] == 0 ) continue;
        dp[ i + 1 ][ j ][ k ] += dp[ i ][ j ][ k ];
        dp[ i + 1 ][ j + 1 ][ k + x[ i + 1 ] ] += dp[ i ][ j ][ k ];
      }
  LL ans = 0;
  for( int i = 1 ; i <= n ; i ++ )
    ans += dp[ n ][ i ][ i * a ];
  printf( "%lld\n" , ans );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 9472
hi, wd = map(int, input().split())


# いずれかが１の場合
if hi==1 or wd ==1:
    print(1)
    exit()

# heightまたはwidthが偶数だった場合
if hi%2 == 0 or wd%2 == 0:
    print(hi*wd//2)
else:
    print(hi*wd//2 + 1)
    

Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define pb push_back
const ll mod = 1e9 + 7;
int x;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>x; cout<<48-x;
}


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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

//void solve(vector<int>& A) {
//	stringstream ss;
//	cout << ss.str() << '\n';
//
//    return;
//}

signed main() {
    int P, Q, R;
    cin >> P >> Q >> R;
    
//    vector<int> A(N);
//    REP(i,0,N) cin >> A[i];
    
//    solve(A);

    vector<int> a{P + Q, Q + R, R + P};
    cout << *min_element(all(a)) << '\n';
    
    return 0;
}



Measured memory_bytes: 256
n = int(input())
ans = 0
len = len(str(n))
if len == 1:
    ans = n
else:
    for i in range(1, len, 2):
        ans += 9 * 10 ** (i - 1)
    if len % 2 != 0:
        x = 10 ** (len - 1)
        d = n // x * x - x
        if d == 1:
            d = 0
        ans += d + n % x + 1
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    map<int,int> m;
    for(int i = 1; i <= n; i++){
        int cp = i;
        for(int j = 2; j*j <= cp; j++){
            while(cp%j == 0)    cp /= j, m[j]++;
        }
        if(cp != 1) m[cp]++;
    }
    ll ans = 1;
    for(auto p : m) ans = ans*(p.second+1)%mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var nk = ReadIntArray();
            var n = nk[0];
            var k = nk[1];
            Console.WriteLine($"{Math.Pow(k - 1, n - 1) * k}");

        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13396
/**
 🍪 the_hyp0cr1t3
 🍪 31.08.2020 16:54:51
**/
#ifdef W
#include "k_II.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define aylmao cin.tie(nullptr)->sync_with_stdio(false);
#endif
#define endl '\n'
#define pb emplace_back
// #define int int64_t
#define sz(x) (int)((x).size())
#define all(x) x.begin(), x.end()
#define Luv(...) [&](auto&& u, auto&& v) { return __VA_ARGS__; }
auto chmax = [](auto& A, auto&& B) { return B > A? A = B, true : false; };
auto chmin = [](auto& A, auto&& B) { return B < A? A = B, true : false; };

using ll = int64_t;
using pii = pair<int,int>;
const ll DESPACITO = 2e18;
const int INF = 2e9+2, MOD = 1e9+7;

template<class T> class Y {
    T f;
public:
    template<class U> explicit Y(U&& f): f(forward<U>(f)) {}
    template<class... Args> decltype(auto) operator()(Args&&... args) {
        return f(ref(*this), forward<Args>(args)...);
    }
}; template<class T> Y(T) -> Y<T>;

const int N = 400 + 5;
ll cache[N][N];

int32_t main() {
    aylmao
    int n;
    cin >> n;
    vector<ll> a(n+1), pref(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = pref[i-1] + a[i];
    }
    memset(cache, -1, sizeof(cache));
    cout << Y([&](auto dp, int l, int r) -> ll {
        if(l > r) return 0;
        if(l == r) return a[l];
        auto& ans = cache[l][r];
        if(~ans) return ans;
        ans = DESPACITO;
        for(int i = l; i < r; i++)
            chmin(ans, dp(l, i) + dp(i+1, r) + pref[r] - pref[l-1]);
        return ans;
    })(1, n) - pref[n];
    
    return 0;
}

Measured memory_bytes: 4968
#include <iostream>

using namespace std;

int N;

int main(){
	ios_base::sync_with_stdio(false);
	
	cin >> N;
	if(N<1200)	cout << "ABC" << endl;
	else if(N<2800)	cout << "ARC" << endl;
	else	cout << "AGC" << endl;
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

const int N_MAX = 1e5;
vi G[N_MAX];
int dp[N_MAX];

void dfs(int v, int p)
{
    vi vec;
    for(auto u:G[v]){
        if (u==p) continue;
        dfs(u,v);
        vec.pb(dp[u]);
    }
    sort(rall(vec));
    int V = vec.size();
    rep(i,V) vec[i]+=i+1;
    if (V>0) dp[v] = *max_element(all(vec));
}

//-------------------------------------------------

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

    FOR(i,1,N-1){
        int a; cin>>a; a--;
        G[i].pb(a);
        G[a].pb(i);
    }
    dfs(0,-1);
    cout<<dp[0]<<endl;
    return 0;
}


Measured memory_bytes: 22020
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;

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

int main(){
	string s1, s2, s3; cin >> s1 >> s2 >> s3;
	cout << s1[0] << s2[0] << s3[0] << endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;
typedef long long ll;

int gcd(int m, int n);
int lcm(int a, int b);

int main(void){
    using namespace  std;
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    map<string, int> mp;
    rep(i,N){
        auto itr = mp.find(S[i]);
        if(itr != mp.end())
            mp[S[i]]++;
        else
            mp[S[i]] = 1;
    }

    int max = -1;
    for (auto itr = mp.begin(); itr != mp.end();++itr){
        if(max < (*itr).second)
            max = (*itr).second;
    }

    for (auto itr = mp.begin(); itr != mp.end();++itr){
        if((*itr).second == max)
            cout << (*itr).first << endl;
    }

    return 0;
}

int gcd(int m, int n){
    int r;
    do{
        r = m % n;
        m = n;
        n = r;
    } while (r != 0);

    return m;
}

int lcm(int a, int b){
    long temp = a * b;
    return temp / gcd(a, b);
}


Measured memory_bytes: 26752
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,m,d;
  cin>>n>>m>>d;
  cout<<setprecision(10);
  if(d==0) cout<<(m-1)*(double)1/n<<endl;
  else cout<<(m-1)*(double)2*(n-d)/(n*n)<<endl;
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val Seq(n, k, q) = Seq.fill(3)(sc.nextInt)
  val a = Seq.fill(q)(sc.nextInt)

  val point = Seq.fill(n)(0).toArray

  a.foreach { a =>
    point(a - 1) = point(a - 1) + 1
  }

  point.foreach { p =>
    if (p > q - k) {
      println("Yes")
    } else {
      println("No")
    }
  }
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b){ if (a > b) { a = b; } }

int main() {
    int n;
    ll a = 0, x, ans = 0;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        if (i > 0)
            ans += max(0LL, a - x);
        a += max(0LL, x - a);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3564
# -*- coding: utf-8 -*-
import math
# 整数の入力
k, s = map(int, input().split())
# 計算
count = 0
for x in range(k+1):
    for y in range(k+1):
        if s >= x + y and s - x - y <= k:
            count += 1
        # for z in range(k+1):
        #     if x + y + z == s:
        #         count += 1
print(count)

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

int frog(int *a,int n,int k){
    int *dp=new int[n];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++){
        int *q= new int[k];
        int j=1;
        for(;j<=k;j++){
        q[j-1]=dp[i-j]+abs(a[i]-a[i-j]);
        if((i-j)<0) break;
        }
        sort(q,q+(j-1));
        dp[i]=q[0];
        delete [] q;
    }
    int op=dp[n-1];
    delete [] dp;
    return op;
}

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

    int n,k;
    cin>>n>>k;
    int *a=new int[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int op=frog(a,n,k);
    cout<<op;

    delete [] a;
    return 0;
}

Measured memory_bytes: 1024
import sys
from math import ceil
input = sys.stdin.readline
N, H = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
maxA = max(A)
B = sorted([n for n in B if n > maxA], reverse=True)
ans = 0
for b in B:
    H -= b
    ans += 1
    if H < 1:
        break
else:
    print(ans+ceil(H/maxA))
    exit()
print(ans)


Measured memory_bytes: 56668
import numpy as np
import math
from decimal import *
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def factorization(n):
    d = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            d.update({i: cnt})

    if temp!=1:
        d.update({temp: 1})

    if d==[]:
        d.update({n:1})

    return d

def main():
    N = int(input())
    d = factorization(N)
    count = 0

    for v in d.values():
        i = 1
        while(v >= i):
            v -= i
            i += 1
            count += 1
        
    print(count)


main()

Measured memory_bytes: 27136
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

	int N, A, B;
	cin >> N >> A >> B;

	if (N * A <= B) {
		cout << N * A <<endl;
	}
	else {
		cout << B << endl;
	}

	return 0;
}

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

int main(){
	string s,t;
	cin>>s>>t;
	vector<vector<int> >DParr;
	vector<int>tmparr(26,-1);
	for(int i=0;i<s.size()+1;++i){
		DParr.push_back(tmparr);
	}
	map<char,int>arr;
	for(int i=0;i<s.size();++i){
		for(int j=arr[s[i]];j<=i;++j){
			DParr[j][s[i]-'a']=i-j;
			arr[s[i]] = i+1;
		}
	}
	/*
	for(int i=0;i<DParr.size();++i){
		for(int j=0;j<26;++j){
			cout<<DParr[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	*/
	long ans = 0;
	int index = 0;
	bool can=true;
	for(int i=0;i<t.size();++i){
		if(DParr[index][t[i]-'a']!=-1){
			ans+=DParr[index][t[i]-'a']+1;
			index+=DParr[index][t[i]-'a']+1;
		}
		else if(index!=0){
			ans+=s.size()-index;
			index=0;
			if(DParr[index][t[i]-'a']!=-1){
				ans+=DParr[index][t[i]-'a']+1;
				index+=DParr[index][t[i]-'a']+1;
			}
			else{
				can=false;
				break;
			}
		}
		else{
			can=false;
			break;
		}
	}
	if(!can)cout<<-1<<endl;
	else cout<<ans<<endl;
}


Measured memory_bytes: 14384
/*
 * ITP1_1_D.c
 *
 *  Created on: 2017/05/11
 *      Author: sl2-user
 */
#include<stdio.h>

int main(void){

	int x,i=1;
	while(1){
	scanf("%d" , &x);
	if(x==0 || i>10000 ){break;}
	printf("Case %d: %d\n",i,x);
	i++;
	}
return 0;
}

Measured memory_bytes: 600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	
	static Main byakko = new Main();
	static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String[] args)throws IOException{
		
		int n,count;
		
		while(true){
			n = byakko.Input();
			
			if(n == 0)break;
			
			count = 0;
			
			n = 1000 - n;
			while(n >= 500){
				n = n - 500;
				count++;
			}
			while(n >= 100){
				n = n - 100;
				count++;
			}
			while(n >= 50){
				n = n - 50;
				count++;
			}
			while(n >= 10){
				n = n - 10;
				count++;
			}
			while(n >= 5){
				n = n - 5;
				count++;
			}
			while(n >= 1){
				n = n - 1;
				count++;
			}
			System.out.println(count);
		}
		reader.readLine();
	}
	
	public int Input()throws IOException{
		return Integer.parseInt(reader.readLine());
	}
	
}

Measured memory_bytes: 16864
n, m = map(int, input().split())
py = [[i] + list(map(int, input().split())) for i in range(m)]
py.sort(key=lambda x:(x[1],x[2]))

city = py[0][1]
num = 0

for i in py:
    if i[1] == city:
        num += 1
    else:
        city = i[1]
        num = 1
    i.append(num)

py.sort()

for i in py:
    print('{:06}{:06}'.format(i[1], i[3]))

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
	pair<int,int> a,b;
	a.fi = ri(), a.se = ri();
	b.fi = ri(), b.se = ri();
	pair<int,int> sub;
	sub.fi = b.fi-a.fi;
	sub.se = b.se-a.se;
	
	pair<int,int> c,d;
	c.fi = b.fi - sub.se;
	c.se = b.se + sub.fi;
	cout << c.fi << " " << c.se << " ";
	d.fi = c.fi - sub.fi;
	d.se = c.se - sub.se;
	cout << d.fi << " " << d.se << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int ans=0;
  char c='!';
  rep(i,s.size()){
    if(c=='!'){
      c=s[i];
      ans++;
    }else{
      if(s[i]!=c){
	ans++;
	c=s[i];
      }else if(i+1<s.size() ){
	ans++;
	i++;
	c='!';
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 720
from copy import deepcopy

N, M, Q = [int(elem) for elem in input().split(' ')]
lines = [[int(elem) for elem in input().split(' ')] for _ in range(M)]
queries = [[int(elem) for elem in input().split(' ')] for _ in range(Q)]


def cuml_1d(N, lines, queries):
    coords = [[0] * N for _ in range(N)]
    for l, r in lines:
        coords[l - 1][r - 1] += 1

    cuml_coords = deepcopy(coords)
    for l in range(N):
        for r in range(1, N):
            cuml_coords[l][r] = cuml_coords[l][r - 1] + coords[l][r]

    for query in queries:
        p, q = query[0] - 1, query[1] - 1
        num_lines = 0
        for l in range(p, max(q + 1, N)):
            if p == 0:
                num_lines += cuml_coords[l][q]
            else:
                num_lines += cuml_coords[l][q] - cuml_coords[l][p - 1]
        print(num_lines)

#cuml_1d(N, lines, queries)


def cuml_2d(N, lines, queries):
    coords = [[0] * N for _ in range(N)]
    for l, r in lines:
        coords[l - 1][r - 1] += 1
    cuml_l = deepcopy(coords)
    for r in range(N):
        for l in range(1, N):
            cuml_l[l][r] = cuml_l[l - 1][r] + coords[l][r]
    cuml_2d = deepcopy(cuml_l)
    for l in range(N):
        for r in range(1, N):
            cuml_2d[l][r] = cuml_2d[l][r - 1] + cuml_l[l][r]
    
    for query in queries:
        p, q = query[0] - 1, query[1] - 1
        if p != 0:
            num_lines = cuml_2d[q][q] - cuml_2d[q][p-1] - cuml_2d[p-1][q] + cuml_2d[p-1][p-1]
        else:
            num_lines = cuml_2d[q][q]
        print(num_lines)

cuml_2d(N, lines, queries)


Measured memory_bytes: 66836
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int a,b;
  cin >> a >> b;
  if (a>b) a--;
  cout << a << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;

int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	sort(all(a));
	cout << (a[n - 1] - a[0]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1) {
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
  int H,W;
  cin>>H>>W;
  int h,w;
  cin>>h>>w;
  cout<<(H-h)*(W-w)<<endl;
}

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


int main (){
    ll k,n;
    cin >> n >> k;
    cout << min(n%k,(k-n%k));
    return 0;
}

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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, a, b;
    cin >> k >> a >> b;
    if (a / k != b / k or a % k == 0)
        cout << "OK" << ln;
    else
        cout << "NG" << ln;

    return 0;
}


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

typedef long long ll;

ll comb[1002][1002];

void makeComb(int a, ll MOD){
  comb[0][0] = 1;
  for(int i = 1; i <= a; i++){
    comb[i][i] = comb[i][0] = 1;
    for(int j = 1; j < i; j++){
      comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % MOD;
    }
  }
}


int main() {
  ll MOD = 1000000007LL;
  makeComb(1000, MOD);

  ll p[1002][1002];
  for (int i = 1; i <= 1000; i++) {
    p[i][0] = 1;
    for (int j = 1; j <= 1000; j++) {
      p[i][j] = p[i][j - 1] * i;
      p[i][j] %= MOD;
    }
  }

  int n, k;

  while (cin >> n >> k) {
    ll ans = 0;
    for (int i = 0; i < k; i++) {
      if (i % 2 == 0) {
	ans += p[k - i][n] * comb[k][i];
      } else {
	ans += MOD * MOD;
	ans -= p[k - i][n] * comb[k][i];
      }
      ans %= MOD;
    }
    cout << ans << endl;
  }
}



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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  ll A,B,X;
  cin >> A >> B >> X;
  if(X >= A && X <= A+B){
    cout << "YES" << endl;
  } else{
    cout << "NO" << endl;
  }
}


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

ll knapsack(int *w,int *v,int n,int we)
  { 
  	     ll res[n+1][we+1];
  	     for(int i=0;i<=n;i++)
  	         res[i][0]=0;
  	     for(int i=0;i<=we;i++)
  	         res[0][i]=0;
  	     for(int i=1;i<=n;i++)
  	       {
  	           for(int j=1;j<=we;j++)
  	            {
  	                if((j-w[i-1])>=0)
  	                 {
  	                     res[i][j]=max(res[i-1][j],(res[i-1][j-w[i-1]]+v[i-1]));
  	                 }
  	               else
  	                     res[i][j]=res[i-1][j];
  	            }
  	       }
  	     return res[n][we];  
  }

int main()
 {
    int n,we;
    cin>>n>>we;
    int v[n],w[n];
    for(int i=0;i<n;i++)
    	 {
    	 	cin>>w[i];
    	 	cin>>v[i];
    	 }
    cout<<knapsack(w,v,n,we)<<"\n";	 
 }

Measured memory_bytes: 79104
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main(){
  char s[10001];
  int n;
  scanf("%d %s",&n,s);
  int len=strlen(s);
  for(int i=0;i<len;i++){
    int x=s[i]-'A';
    x=(x+n)%26;
    putchar('A'+x);
  }
  cout<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	double sums = 0;
	cin >> n;
	double k;
	string s;
	while(n--){
		cin >> k >> s;
		if(s == "BTC")
			sums += (k)*(380000.0);
		else
			sums += k;
	}
	cout << fixed << setprecision(5) << sums;
	return 0;
}

Measured memory_bytes: 3772
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

VI beet[114514];
int F[114514],S[114514];

void bFs(int n){
    REP(i,114514) F[i] = INF;
    queue<P> que;
    F[0] = 0;
    que.push(MP(n,0));

    while(!que.empty()){
        P p = que.front();que.pop();
        REP(i,beet[p.FI].size()){
            if(F[beet[p.FI][i]]>p.SE+1){
                F[beet[p.FI][i]] = p.SE+1;
                que.push(MP(beet[p.FI][i],p.SE+1));
            }
        }
    }
}

void bfS(int n){
    REP(i,114514) S[i] = INF;
    queue<P> que;
    S[n] = 0;
    que.push(MP(n,0));

    while(!que.empty()){
        P p = que.front();que.pop();
        REP(i,beet[p.FI].size()){
            if(S[beet[p.FI][i]]>p.SE+1){
                S[beet[p.FI][i]] = p.SE+1;
                que.push(MP(beet[p.FI][i],p.SE+1));
            }
        }
    }
}

signed main(){
    int n;
    cin >> n;
    REP(i,n-1){
        int a,b;
        scanf("%d%d",&a,&b);
        a--,b--;
        beet[a].PB(b),beet[b].PB(a);
    }

    bFs(0),bfS(n-1);

    /*REP(i,n) printf("%d ",F[i]);
    puts("");
    REP(i,n) printf("%d ",S[i]);
    puts("");*/

    int Fennec=0,Snuke=0;
    REP(i,n) F[i]<=S[i]?Fennec++:Snuke++;

    puts(Fennec>Snuke?"Fennec":"Snuke");
}

Measured memory_bytes: 7236
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int x[3];
  for(int i=0; i<3; i++) {
      cin >> x[i];
  }
  sort(x,x+3);
  cout << x[0] << " " << x[1] << " " << x[2] << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main()
{
    fio;
    string s1;
    cin>>s1;
    int k = 0;
    if(s1[0]=='o')
        k++;
    if(s1[1]=='o')
        k++;
    if(s1[2]=='o')
        k++;
    cout<<700+k*100<<endl;
    return 0;
}



Measured memory_bytes: 3616
#include<iostream>
#include<cmath>
using namespace std;
int main(void) {
    double x;
    cin>>x;
    double hig=x, low=x;
    while(cin >> x){
        if(hig<x)hig=x;
        if(low>x)low=x;
    }
    cout << hig-low << endl;
    return 0;
}


Measured memory_bytes: 3200
package main

import "fmt"

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

func div2(x int) int {
  ans := 0
  for x > 0 {
    r := x % 2
    if r == 0 {
      ans++
    } else {
      break
    }
    x /= 2
  }
  return ans
}

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

  ans := 30
  for i := 0; i < n; i++ {
    a := 0
    fmt.Scan(&a)
    ans = min(ans, div2(a))
  }
  fmt.Println(ans)
}


Measured memory_bytes: 512
n, m = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (n+1)
for i in range(n) :
    dp[i+1] = (dp[i] + a[i]) % m

dp = sorted(dp)

cnt = 1
now = dp[0]
ans = 0
for i in range(1,n+1) :
    if now == dp[i] :
        cnt += 1
    elif now != dp[i] :
        ans += cnt * (cnt-1) // 2
        now = dp[i]
        cnt = 1
else :
    ans += cnt * (cnt-1) // 2

print(ans)


Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<pair<string, int>> a(n);
    rep(i, n){
        string s;
        int x;
        cin >> s >> x;
        a[i] = make_pair(s, -x);
    }
    auto b = a;
    sort(all(b));
    map<pair<string, int>, int> mp;
    rep(i,n){
        mp[a[i]] = i;
    }
    rep(i,n){
        cout << mp[b[i]] + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  string str;
  cin >> str;
  string s = "Sunny";
  string c = "Cloudy";
  string r = "Rainy";
  if(str==s) cout << c << endl;
  if(str==c) cout << r << endl;
  if(str==r) cout << s << endl;
}



Measured memory_bytes: 256
import sys

n, m, l = [ int( val ) for val in sys.stdin.readline().split( " " ) ]

matrixA = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( n ) ]
matrixB = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( m ) ]	
matrixC = [ [ 0 for row in range( l ) ] for row in range( n ) ]

output = []
for i in range( n ):
	for j in range( l ):
		for k in range( m ):
			matrixC[i][j] += ( matrixA[i][k] * matrixB[k][j] )
		output.append( "{:d}".format( matrixC[i][j] ) )
		output.append( " " )
	output.pop()
	output.append( "\n" )

output.pop()
print( "".join( output ) )

Measured memory_bytes: 9988
#include <bits/stdc++.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
#define ld long double
 
using namespace std;
 
const int N = 5e5 + 123;
const ll mod = 1e9 + 7;

ll dp[N], res, was[N];
int n, maxw;

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

	cin >> n >> maxw;

	for(int i = 1;i <= 100000;i++)
		dp[i] = N * 1LL * N;

	was[0] = 1;
	for(int i = 1;i <= n;i++){
		ll x, y;
		cin >> x >> y;
		for(int j = 100000;j >= y;j--){
			if(!was[j - y])
				continue;
			was[j] = 1;
			dp[j] = min(dp[j], dp[j - y] + x);
		}
	}

	for(int i = 0;i <= 100000;i++){
		if(dp[i] <= maxw){
			res = i;
		}
	}

	cout << res;
}

Measured memory_bytes: 5120
#include <iostream>

using namespace std;

int main(){
  int K, S;
  cin >> K >> S;
  
  int x, y, z, n = 0;
  for(x = 0 ; x <= K ; x++){
    for(y = 0 ; y <= K ; y++){
      z = S - x - y;
      if(z <= K && 0 <= z){
        n++;
      }
    }
  }
  cout << n << endl;
  
 
  return 0;
}

Measured memory_bytes: 256