akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin>>N;
  vector<int>x(2*N);
  for(int i=0;i<2*N;i++) cin>>x[i];
  double ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      long long y=pow(x[2*i]-x[2*j],2);
      long long z=pow(x[2*i+1]-x[2*j+1],2);
      ans+=sqrt(y+z);
    }
  }
  ans=ans*2;
  ans=ans/N;
  cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cassert>

using namespace std;

typedef unsigned int index;

int main()
{
#ifdef ONPC
        assert(freopen("a.in", "r", stdin));
        assert(freopen("a.out", "w", stdout));
#else
#endif
        size_t n;
        cin >> n;
        vector<int> a(n);
        for (auto &i: a)
                cin >> i;
        int sum = 0;
        for (index i = 0; i < a.size(); i++)
                sum += a[i];
        if (sum % 10 != 0)
                cout << sum << endl;
        else
        {
                int m = (int)1e9 + 1;
                for (index i = 0; i < a.size(); i++)
                        if (a[i] % 10 != 0)
                                m = min(m, a[i]);
                if (m == 1e9 + 1)
                        cout << 0 << endl;
                else
                        cout << sum - m << endl;
        }
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	a := nextInt()
	b := nextInt()
	s := nextStr()

	acnt := 0
	bcnt := 0
	for i := 0; i < n; i++ {
		if s[i] == 'a' {
			if acnt+bcnt < a+b {
				fmt.Println("Yes")
				acnt++
			} else {
				fmt.Println("No")
			}
		} else if s[i] == 'b' {
			if (acnt+bcnt < a+b) && (bcnt < b) {
				fmt.Println("Yes")
				bcnt++
			} else {
				fmt.Println("No")
			}
		} else {
			fmt.Println("No")
		}
	}

}

// ---- readfunc
func scanInit() {
	const cap = 100 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2056
#include <stdlib.h>
#include <iostream>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); ++i)
int main(){
	int n, m;
	cin >> n >> m;
	char a[50][50];
	char b[50][50];
	REP(i, n){
		REP(j, n){
			cin >> a[i][j];
		}
	}

	REP(i, m){
		REP(j, m){
			cin >> b[i][j];
		}
	}

	bool ans = false;
	for(int i = 0; i < n-m+1 && !ans; ++i){
		for(int j = 0; j < n-m+1 && !ans; ++j){
			bool is_exist = true;
			for(int k = 0; k < m && is_exist; ++k){
				for(int l = 0; l < m && is_exist; ++l){
					if(a[i+k][j+l] != b[k][l]){
						is_exist = false;
					}
				}
			}
			if(is_exist){
				ans = true;
			}
		}
	}

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

	return 0;
}



Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val p = Seq.fill(n)(sc.nextInt)
  val q = Seq.fill(n)(sc.nextInt)
  
  def point(seq: Seq[Int], count: Int): Int = {
    if (seq.isEmpty) count
    else {
      val dropped = seq.drop(1)
      val plus = if (seq(0) == 1 || seq.length == 1) 0
        else (dropped.filter(_ < seq(0)).length) * (1 to dropped.length).reduce((a,b) => a*b)
      point(dropped, count + plus)
    }
  }
  
  val a = point(p, 0) + 1
  val b = point(q, 0) + 1
  println(math.abs(a - b))
}

Measured memory_bytes: 25544
n = int(input())
h = input().split()
 
ans = 1
m = n-1
high = int(h[0])
 
for i in range(m):
    if int(h[i+1]) >= high:
        ans += 1
        high = int(h[i+1])
    else:
        continue
        
 
print(ans)

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

int main(){
  int n,d,x,m;
  cin >> n >> d >> x;
  r(i,n){
    cin >> m;
    x+=(d-1)/m+1;
  }
  cout << x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
const int maxn = 100000 + 5;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n, m;
vector<int> G[maxn];
bool col[maxn][2];

int cnt = 0;
bool flag = true;

void dfs(int u, int c = 0) {

    if(c) ++ cnt;
    col[u][c] = true;
    for(const auto&v : G[u]) {
        if(col[v][c]) flag = false;
        if(!col[v][c^1]) dfs(v, c ^ 1);
    }
}

int main() {
#ifdef Wearry
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    n = read<int>();
    m = read<int>();
    for(int i = 0; i < m; ++i) {
        int u = read<int>(), v = read<int>();
        G[u].pb(v), G[v].pb(u);
    }

    dfs(1);

    if(flag) {
        printf("%lld\n", 1LL * (n - cnt) * cnt - m);
    }
    else printf("%lld\n", 1LL * n * (n-1) / 2 - m);

    return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

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


int main(){
    vector<int> a(3);
    rep(i, 3)cin >> a[i];
    int count = 0;
    while(true){
        if(a[0] == a[1] && a[1] == a[2])break;
        sort(a.begin(), a.end());
        if(a[0] + 2 <= a[2])a[0] += 2;
        else a[2]--;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
{- |
   Module      : ALDS1_11_A
   Description : The "ALDS1_11_A" module
   Copyright   : (c) kiripon
   License     : BSD-style (see the file LICENSE)
 -}
module Main where
import Control.Applicative
import qualified Data.Array.IO as IOArray
import Control.Monad
getInts :: IO [Int]
getInts = map read . words <$> getLine
main :: IO ()
main = do
  n <- readLn :: IO Int
  a <- IOArray.newArray ((1,1),(n,n)) (0 :: Int) :: IO (IOArray.IOArray (Int,Int) Int)
  replicateM_ n $ do
    i:_:xs <- getInts
    forM_ xs $ \to -> do
      IOArray.writeArray a (i,to) 1
  forM_ [(x,y) | x <- [1..n], y <- [1..n]] $ \(x,y) -> do
    v <- IOArray.readArray a (x,y)
    if y == n
      then print v
      else putStr $ show v ++ " "
  return ()

Measured memory_bytes: 5000
N, M = map(int,input().split())
ans = 0
if N == 1 and M == 1:
  ans = 1
elif N == 1:
  ans = max(M-2,0)
elif M == 1:
  ans = max(N-2,0)
else:
  ans = (N-2)*(M-2)
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#define INFTY 1000000001
int count=0;
void mergeSort(int*, int, int);
void merge(int *, int, int, int);

int main(){
  
  int n, S[500000], i;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &S[i]);
  }

  mergeSort(S, 0, n);

  for(i=0; i<n-1; i++){
    printf("%d ",S[i]);
  } printf("%d\n", S[n-1]);

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

  return 0;
}

void mergeSort(int S[], int left, int right){

  int mid, i;
  
  if( (left+1)<right ){ //left==rightじゃない時、２つ分けにしていく

    mid=(left+right)/2;

    mergeSort(S, left, mid);//left~midまで一旦sort
    mergeSort(S, mid, right);//mid~rightまでsort

    merge(S, left, mid, right);
  }
}
void merge(int S[], int left, int mid, int right){

  int nL=mid-left, nR=right-mid;
  int arrL[nL], arrR[nR];
  int i, j, k;

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

    arrL[i]=S[left+i];
  }
  for(i=0; i<nR; i++){

    arrR[i]=S[mid+i];
  }
  
  arrL[nL]=INFTY;//無限...絶対必要
  arrR[nR]=INFTY;//Sの要素より絶対に大きいであろう数を具体的にdefineする

  i=0;
  j=0;

  for(k=left; k<right; k++){ //これからS[]に2つの配列をの大小比較し、merge

    if(arrL[i]<=arrR[j]){
      S[k]=arrL[i];
      i++;
      count++;
    }else if(arrR[j]<arrL[i]){
      S[k]=arrR[j];
      j++;
      count++;
    }
  }//merge終了

}


  
  

  
    



Measured memory_bytes: 5612
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	dic
# CreatedDate:  2020-06-30 15:07:10 +0900
# LastModified: 2020-06-30 15:09:49 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    dic = {}
    for _ in range(n):
        command, s = input().split()
        if command == 'insert':
            dic[s] = 1
#            print(dic)
        else:
            print("yes" if s in dic.keys() else "no")



if __name__ == "__main__":
    main()



Measured memory_bytes: 33124
def factorization(n):
    arr = []
    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
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


n=int(input())
arr=factorization(n)

z=0    
if n!=1:
    for i in range(len(arr)):
        k=0
        for j in range(1,100000):
            k+=j
            z+=1
            if k+j+1>arr[i][1]:
                break

print(z)        

    





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

////////////
// ModInt //
////////////

// 四則演算の最も左に存在する値がModIntでなければキャストでバグる
// 例えばx = mint * 1000;やx = ModInt(1000) * mint;はいいがx = 1000 * mint;は駄目。
template<int64_t mod_ = 1'000'000'007>
class ModInt {
private:
	int64_t integer_;

public:
	constexpr ModInt(const int64_t initial_number = 0)
		: integer_(initial_number){}
	
	// 四則演算
	constexpr ModInt operator+(const ModInt& operand) const
	{
		ModInt ret{this->integer_ + operand.integer_};
		if (ret.integer_ >= mod_)
			ret.integer_ -= mod_;
		return ret;
	}
	constexpr ModInt operator-(const ModInt& operand) const
	{
		ModInt ret{this->integer_ - operand.integer_};
		if (ret.integer_ < 0)
			ret.integer_ += mod_;
		return ret;
	}
	constexpr ModInt operator*(const ModInt& operand) const
	{
		return {this->integer_ * operand.integer_ % mod_};
	}
	constexpr ModInt operator/(const ModInt& operand) const
	{
		return *this * (operand ^ (mod_ - 2));
	}

	// 累乗
	constexpr ModInt operator^(const int64_t operand) const
	{
		ModInt ret{1}, pow_ope{this->integer_};
		for (int64_t pow{operand}; pow > 0; pow >>= 1)
		{
			if (pow & 1) ret *= pow_ope;
			pow_ope *= pow_ope;
		}
		return ret;
	}

	// 代入
	constexpr ModInt& operator=(const ModInt& operand)
	{
		this->integer_ = operand.integer_;
		return *this;
	}
	constexpr ModInt& operator+=(const ModInt& operand)
	{
		*this = *this + operand;
		return *this;
	}
	constexpr ModInt& operator-=(const ModInt& operand)
	{
		*this = *this - operand;
		return *this;
	}
	constexpr ModInt& operator*=(const ModInt& operand)
	{
		*this = *this * operand;
		return *this;
	}
	constexpr ModInt& operator/=(const ModInt& operand)
	{
		*this = *this / operand;
		return *this;
	}

	// その他
	constexpr operator int64_t() { return integer_; }

	constexpr ModInt getOne() const
	{
		return ModInt(1ll);
	}
	constexpr ModInt getZero() const
	{
		return ModInt(0ll);
	}
};

////////////////
// 組み合わせ //
///////////////

template<int64_t mod_ = 1'000'000'007, int max_ = 200'000>
class Combination {
public:
	std::array<ModInt<mod_>, max_ + 1> inv, fact, finv;

	constexpr Combination()
	{
		inv[0] = inv[1] = fact[0] = fact[1] = finv[0] = finv[1] = 1;
		for (int num{2}; num <= max_; num++)
		{
			inv[num] = (mod_ - (int64_t)inv[mod_ % num] * (mod_ / num) % mod_) % mod_;
			fact[num] = num * fact[num - 1] % mod_;
			finv[num] = inv[num] * finv[num - 1] % mod_;
		}
	}

	constexpr ModInt<mod_> getCombi(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[r] * finv[n - r];
	}

	constexpr ModInt<mod_> getPerm(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[n - r];
	}
};
Combination<> combi;

int main()
{
	int N;
	int64_t M;
	scanf("%d%lld", &N, &M);
	using Mint = ModInt<>;
	Mint ans(1ll);
	for (int64_t i{2}; i * i <= M; i++)
	{
		if (M % i) continue;
		int count{};
		while (M % i == 0)
		{
			M /= i;
			count++;
		}
		ans *= combi.getCombi(N - 1 + count, count);
	}
	if (M > 1) ans *= Mint(N);
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=2e5+10;
char ch[M];
int calc(int len){
	if (len%3==0) return len/3*2;
	return len/3*2+1;
}
int main(){
	scanf("%s",ch+1); 
	int n=strlen(ch+1);
	ch[n+1]='%';
	int len=0,ans=0;
	F(i,1,n){
		len++;
		if (ch[i+1]!=ch[i]){
			ans+=calc(len);
			if (len%3==2 && (i+1)<=n){
				ans++;
				i++;
			}
			len=0;
		}
	}
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll N,A,B,C;
vector<ll> L;

ll dfs(ll n,ll a,ll b,ll c,ll cost){
   if(n == N){
      if(a == 0 || b == 0 || c == 0) return INF;
      return abs(A-a) + abs(B-b) + abs(C-c) + cost;
   }
   ll res = INF;
   res = min({
      dfs(n+1,a+L[n],b,c,cost + 10),
      dfs(n+1,a,b+L[n],c,cost + 10),
      dfs(n+1,a,b,c+L[n],cost + 10),
      dfs(n+1,a,b,c,cost)
   });
   return res;
}

int main(){
    cin >> N >> A >> B >> C;
    rep(i,N){
       ll l;cin >> l;
       L.push_back(l);
    }
    cout << dfs(0,0,0,0,0) - 30 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int digsum(int a){
    int sum = 0;
    while(1){
        if(a == 0) break;
        sum += a - (a/10)*10; 
        a/=10;
    }
    return sum;
}

int main(){
    int N, min=INT_MAX, A, B;
    scanf("%d", &N);
    A = N-1; B = 1;
    while(1){
        if(A==0) break;
        if(digsum(A)+digsum(B) < min) min = digsum(A) + digsum(B);
        A--;B++;
    }
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define PI acos(-1)
#define EPS 1e-12
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bitCount __builtin_popcount
#define forn(i, n) for(i = 0; i < (ll)n; i++)
#define for1(i, n) for(i = 1; i <= (ll)n; i++)
#define forv(i, v) for(i = 0; i < v.size(); i++)
#define forab(i, a, b) for(i = a; i <= (ll)b; i++)
#define Sort(v) sort(v.begin(), v.end())
#define bend(v) v.begin(), v.end()
#define sz(v) v.size()
#define trace(x) cout<<"x = "<<x<<"\n"
#define trace2(x, y) cout<<"x = "<<x<<" y = "<<y<<"\n"
#define trace3(x, y, z) cout<<"x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define trace4(w, x, y, z) cout<<"w = "<<w<<" x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define ln "\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef set<int>::iterator sit;
typedef set<ll>::iterator sllt;
typedef set<char>::iterator sct;
typedef map<int, int>::iterator mit;
typedef vector<int>::iterator vit;
typedef multiset<int>::iterator msit;
const int maxn = 1e5+5;
const ll mod = 1e9+7;
const int alphabet = 26;
const int inf = INT_MAX;
const ll linf = 1e18+9;
namespace util{
	inline ll cnm(char ch){ return (ch-'0'); }
	inline ll cap(char ch){ return (ch-'a'); }
	inline void instr(string& s, ll& n){ cin>>s;    n = s.length(); }
	inline void instr(string& s){ cin>>s; }
	template<typename T> T gcd(T a, T b){ if(a==0) return b; return gcd(b%a, a); }
	template<typename T> bool min(T a, T b, T c){
		return  std::min(a, std::min(b, c));
	}
}
using namespace util;


void solve(int tc)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll i, j, k, m, n;
	char c;
	cin>>c;
	if(c>='A' and c<='Z') cout<<"A";
	else cout<<"a";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	int i = 1;
	// cin>>t;
	while(i <= t){
		solve(i);
		i++;
	}

	return 0;
}



Measured memory_bytes: 3612
input = gets.to_s
s1 = []
s2 = []
(input.length).times do |i|
  area = 0
  case input[i]
  when '\\'
    s1.push(i)
  when '/'
    next if s1.empty?
    left = s1.pop
    area += i - left
    while !s2.empty? && left < s2.last.first do
      area += s2.pop.last
    end
    s2.push([left, area])
  end
end
line1 = 0
line2 = s2.length.to_s
(s2.length).times do |i|
  line1 += s2[i].last
  line2 += ' ' + s2[i].last.to_s
end
puts line1
puts line2

Measured memory_bytes: 15484
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    D, N = map(int, input().split())
    if N == 100:
        print((N + 1) * 100 ** D)
    else:
        print(N * 100 ** D)


if __name__ == '__main__':
    main()


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

int main(){
  int a[3][3];
  for(int i=0;i<3;i++){
  	for(int j=0;j<3;j++) cin>>a[i][j];
  }
  int n;
  cin>>n;
  int b[n];
  for(int i=0;i<n;i++) cin>>b[i];
  bool c[3][3]={0};
  
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      
      for(int k=0;k<n;k++){
        if(a[i][j]==b[k]) c[i][j]=1;
      }
      
    }
  }
  bool ans=0;
    if(c[0][0]==1&&c[1][0]==1&&c[2][0]==1) ans=1;
  else if(c[0][1]==1&&c[1][1]==1&&c[2][1]==1) ans=1;
  else if(c[0][2]==1&&c[1][2]==1&&c[2][2]==1) ans=1;
  else if(c[0][0]==1&&c[0][1]==1&&c[0][2]==1) ans=1;
  else if(c[1][0]==1&&c[1][1]==1&&c[1][2]==1) ans=1;
  else if(c[2][0]==1&&c[2][1]==1&&c[2][2]==1) ans=1;
  else if(c[0][0]==1&&c[1][1]==1&&c[2][2]==1) ans=1;
  else if(c[1][3]==1&&c[1][1]==1&&c[3][1]==1) ans=1;
  
  
  if(ans) cout<<"Yes" <<endl;
  else cout<<"No" <<endl;
  
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
using namespace std;

const int maxn = 300010,inf = 1<<29;
int W,H,N,ans,tree[maxn*4],tag[maxn*4];

inline int gi()
{
	char ch; int ret = 0,f = 1;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

struct node
{
	int x,y;
	inline node(int _x = 0,int _y = 0):x(_x),y(_y) {}
	inline void read() { x = gi(); y = gi(); }
	friend inline bool operator <(const node &a,const node &b) { return a.x < b.x; }
}P[maxn];

inline void build(int now,int l,int r)
{
	tree[now] = -inf; tag[now] = 0; if (l == r) return;
	int mid = (l+r) >> 1;
	build(now<<1,l,mid); build(now<<1|1,mid+1,r);
}

inline void pushdown(int now,int l,int r)
{
	if (l != r)
	{
		tree[now<<1] += tag[now]; tag[now<<1] += tag[now];
		tree[now<<1|1] += tag[now]; tag[now<<1|1] += tag[now];
	}
	tag[now] = 0;
}

inline void modify(int now,int l,int r,int ql,int qr,int key)
{
	if (tag[now]) pushdown(now,l,r);
	if (l == ql&&r == qr) { tree[now] += key; tag[now] = key; return; }
	int mid = (l+r) >> 1;
	if (qr <= mid) modify(now<<1,l,mid,ql,qr,key);
	else if (ql > mid) modify(now<<1|1,mid+1,r,ql,qr,key);
	else modify(now<<1,l,mid,ql,mid,key),modify(now<<1|1,mid+1,r,mid+1,qr,key);
	tree[now] = max(tree[now<<1],tree[now<<1|1]);
}

inline void change(int now,int l,int r,int pos,int key)
{
	if (tag[now]) pushdown(now,l,r);
	if (l == r) { tree[now] = key; return; }
	int mid = (l+r) >> 1;
	if (pos <= mid) change(now<<1,l,mid,pos,key);
	else change(now<<1|1,mid+1,r,pos,key);
	tree[now] = max(tree[now<<1],tree[now<<1|1]);
}

inline void work()
{
	sort(P+1,P+N+1); build(1,1,N+1);
	stack <node> S1,S2; int mid = H>>1;
	change(1,1,N+1,1,H); S1.push(node(mid,0)); S2.push(node(H-mid,0));
	for (int i = 1;i <= N;++i)
	{
		ans = max(ans,(P[i].x+tree[1])<<1); int h,last;
		if (P[i].y <= mid)
		{
			for (h = mid,last = i;!S1.empty()&&mid-P[i].y < (S1.top()).x;h = (S1.top()).x,last = (S1.top()).y,S1.pop())
				modify(1,1,N+1,(S1.top()).y+1,last,mid-P[i].y-h);
			if (S1.empty()) S1.push(node(mid-P[i].y,0));
			else modify(1,1,N+1,(S1.top()).y+1,last,mid-P[i].y-h);
			S1.push(node(mid-P[i].y,i));
		}
		else
		{
			for (h = H-mid,last = i;!S2.empty()&&P[i].y-mid < (S2.top()).x;h = (S2.top()).x,last = (S2.top()).y,S2.pop())
				modify(1,1,N+1,(S2.top()).y+1,last,P[i].y-mid-h);
			if (S2.empty()) S2.push(node(P[i].y-mid,0));
			else modify(1,1,N+1,(S2.top()).y+1,last,P[i].y-mid-h);
			S2.push(node(P[i].y-mid,i));
		}
		change(1,1,N+1,i+1,H-P[i].x);
	}
	ans = max(ans,(W+tree[1])<<1);
}

int main()
{
	//freopen("D.in","r",stdin);
	//freopen("D.out","w",stdout);
	W = gi(); H = gi(); N = gi();
	for (int i = 1;i <= N;++i) P[i].read();
	ans = max((H+1)<<1,(W+1)<<1);
	work();
	for (int i = 1;i <= N;++i) swap(P[i].x,P[i].y); swap(H,W);
	work();
	cout << ans << endl;
	return 0;
}

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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 2001
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> xx(n);
  vector<int> yy(n);
  for (int i = 0; i < n; i++)
  {
    cin >> x[i] >> y[i];
    xx[i] = (x[i] + y[i]);
    yy[i] = (x[i] - y[i]);
  }
  int a = *max_element(xx.begin(), xx.end());
  int b = *min_element(xx.begin(), xx.end());
  int c = *max_element(yy.begin(), yy.end());
  int d = *min_element(yy.begin(), yy.end());
  cout << max({a - b, c - d});
}


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

class Cube{
public:
  int f[6]; //??????????????°???
  Cube(){} //?????????????????????
  void roll_z(){ roll(1, 2, 4, 3);} //????????????????????§??????????????????????????°???????????¨????????????
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }
};

//getRight??¢??°?????????????????¢??°??§????????????

  int getRight( Cube c1, int f1, int f2){
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < 4; j++) {
        if ( c1.f[0] == f1 && c1.f[1] == f2 ) return c1.f[2]; //return??§?????´?????°??????????????°?????????
        c1.roll_z();
      }
      if (i % 2 == 0) c1.roll_y();
      else c1.roll_x();
      /*i?????¶?\?????????????x, y??????????????¢???????????°?????¨????????°??????????????¢????????????????????¶?????§z??????????????¢???????????????????????????????????????????????????*/
    }
    return -1;
  }



int main(){
  Cube c;
  int f1, f2;

  for ( int i = 0; i < 6; i++) cin >> c.f[i];
  int q; cin >> q;

  for ( int i = 0; i < q; i++){
    cin >> f1 >> f2;
    cout << getRight(c, f1, f2) << endl;

  }


return 0;
}

Measured memory_bytes: 3072
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Item struct {
	priority int
	index int
}

type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].priority > pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	n:= nextInt()
	m:= nextInt()
	q := &PriorityQueue{}

	heap.Init(q)

	for i:=0; i<n ; i++ {
		v := nextInt()
		item := &Item{
			priority: v,
			index: i,
		}
		heap.Push(q, item)
	}

	for i:=0; i< m; i++ {
		item := heap.Pop(q).(*Item)
		heap.Push(q, &Item{
			priority: item.priority / 2,
			index:    item.index,
		})
	}

	sum := 0
	for i := 0; i< n ; i++ {
		item := heap.Pop(q).(*Item)
		sum += item.priority
	}

	fmt.Printf("%d", sum)
}


Measured memory_bytes: 7040
n=int(input())
alist = []
for i in range(n):
    a,b=input().split()
    alist.append([a, int(b)])
blist=sorted(alist,key=lambda x:x[1],reverse=True)
blist.sort(key=lambda x:x[0])
for i in range(n):
  print(alist.index(blist[i])+1)

Measured memory_bytes: 9116
N,M=map(int,input().split())

x=[-1]*N
ok=True
for _ in range(M):
    s,c=map(int,input().split())
    s-=1
    if (s==0 and c==0 and N>1) or x[s]!=-1 and x[s]!=c:
        ok=False
        break
    x[s]=c

if ok:
    ans=0
    for i in range(N):
        if x[i]==-1:
            x[i]=0 if (i>0 or N==1) else 1
        ans=ans*10+x[i]
    print(ans)
else:
    print(-1)


Measured memory_bytes: 61884
#include <stdio.h>
#define int64 long long

int main(void)
{
  long long int n;
  scanf( "%lld", &n );
  long long int h[n];
  for( long long int i = 0;i < n; i++ )
  {
    scanf("%lld",&h[i]);
  }
  int64 cnt = 0, ans = 0;
  for( int64 i = 0; i < n - 1; i++ )
  {
    if(h[i] >= h[i+1])
    {
      cnt++;
    }
    else
    {
      if(ans < cnt)
      {
        ans = cnt;
      }
      cnt = 0;
    }
  }
   if(ans < cnt)
      {
        ans = cnt;
      }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 2512
#include <iostream>
using namespace std;
int main(void)
{
	int prime[50000];
	prime[0] = 2;
	prime[1] = 3;
	int ptr = 2;
	for(int num = 5; num <=50100; num++){
		bool f = false;
		for(int i=0; i<ptr; i++){
			if(prime[i]*prime[i]>num){
				break;
			}
			if(num%prime[i]==0){
				f = true;
				break;
			}
		}
		if(!f){
			prime[ptr++] = num;
		}
	}
	int n;
	while(cin>>n){
		int i=0;
		while(prime[i]<=n){
			i++;
		}
		if(prime[i-1]==n){
			printf("%d %d\n",prime[i-2],prime[i]);
		}else{
			printf("%d %d\n",prime[i-1],prime[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
map<string,int>p;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t,ans=0;
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        if(p[s]==0) {
            ans++;
            p[s]=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 19232
#include <iostream>

using namespace std;

int main()
{
	int  a, b, endFlg = 0;
	char op;
	
	while(endFlg != 1)
	{
		cin >> a;
		cin >> op;
		cin >> b;
		
		switch(op)
		{
		case '+':
			cout << a + b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
		case '*':
			cout << a * b << endl;
			break;
		case '/':
			cout << a / b << endl;
			break;
		case '?':
			endFlg = 1;
			break;
		default:
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include<string>
#include <algorithm>

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

#define vi         vector<int>
#define vs         vector<string>

#define vpii       vector<pair<int,int>>
#define vpis       vector<pair<int,string>>
#define vpss       vector<pair<string,string>>
#define mkp        make_pair

#define vvi        vector<vector<int>>

using namespace std;

int main()
{
  int n;
  vs v;

  cin >> n;

  vs s(n);

  rep(i,n){
    cin >> s[i];
      v.emplace_back(s[i]);
  }

  sort(v.begin(), v.end());

  v.erase(unique(v.begin(), v.end()), v.end());

  cout << v.size();

  return 0;
}


Measured memory_bytes: 17844
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if (A <= B) {
        rep(i, 0, B) {
            cout << A;
        }
        cout << endl;
    }
    else {
        rep(i, 0, A) {
            cout << B;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string x;
    cin >> x;

    int res = x.size();
    int s = 0;
    rep(i, x.size()) {
        if(x[i]=='S') s++;
        else {
            if(s) {
                res -= 2;
                s--;
            }
        }
    }

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

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

int main(){
    int n[3];
    for(int i=0; i<3; ++i){
        cin >> n[i];
    }
    sort(n, n+3);
    cout << n[0] << " " << n[1] << " " << n[2] << endl;
}


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

int main() {
	//ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int n;
	priority_queue<double, vector<double>, greater<double>> pq;
	double a[110];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		pq.push(a[i]);
	}
	while (pq.size() != 1) {
		double primero = pq.top();
		pq.pop();
		double segundo = pq.top();
		pq.pop();
		double nuevo = (primero + segundo) / 2.0;
		pq.push(nuevo);
	}
	printf("%0.5lf\n", pq.top());
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from sys import stdin
    
def main():
    a,b = [int(x) for x in stdin.readline().rstrip().split()]
    ans = 0
    for x in range(2):
        if a > b:
            ans += a
            a -= 1
        else:
            ans += b
            b -= 1
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 2940
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad         (forM_, when)
import qualified Data.Array.MArray     as MA
import           Data.Array.ST         (runSTUArray)
import           Data.Array.Unboxed    (UArray, (!))
import qualified Data.ByteString.Char8 as BS
import           Data.List             (permutations)
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [n, m, r] <- readInts <$> BS.getLine
  rs <- readInts <$> BS.getLine
  abcs <- map readInts . BS.lines <$> BS.getContents
  print $ solve n m r rs abcs

solve :: Int -> Int -> Int -> [Int] -> [[Int]] -> Int
solve n m _ rs abcs = minimum . map travel $ permutations rs where
  travel ss = sum . map (dss !) . zip ss $ tail ss
  dss = warshallFloyd n m abcs

warshallFloyd :: Int -> Int -> [[Int]] -> UArray (Int, Int) Int
warshallFloyd n _ abcs = runSTUArray $ do
  dss <- MA.newArray ((1, 1), (n, n)) (maxBound `div` 3)
  forM_ abcs $ \[a, b, c] -> do
    MA.writeArray dss (a, b) c
    MA.writeArray dss (b, a) c
  forM_ [1 .. n] $ \k ->
    forM_ [1 .. n] $ \i ->
      forM_ [1 .. n] $ \j -> do
        dij <- MA.readArray dss (i, j)
        dik <- MA.readArray dss (i, k)
        dkj <- MA.readArray dss (k, j)
        when (dij > dik + dkj) $
          MA.writeArray dss (i, j) (dik + dkj)
  return dss

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

readInts :: BS.ByteString -> [Int]
readInts = map readInt . BS.words


Measured memory_bytes: 2300
h, w = map(int, input().split())
M = [str(input()) for _ in range(h)]

cnt = 0
for i in range(h):
    cnt += M[i].count('.')

M = ['#'*w] + M + ['#'*w]
M = ['#'+c+'#' for c in M]

sy, sx = 1, 1

from collections import deque
stack = deque()
stack.append((sy, sx))
visit = [[-1]*(w+2) for _ in range(h+2)]
visit[sy][sx] = 0

while stack:
    y, x = stack.popleft()
    if y == h and x == w:
        break
    for dy, dx in (-1, 0), (1, 0), (0, -1), (0, 1):
        new_y, new_x = y+dy, x+dx
        if visit[new_y][new_x] == -1 and M[new_y][new_x] != '#':
            visit[new_y][new_x] = visit[y][x]+1
            stack.append((new_y, new_x))
else:
    print(-1)
    exit()

print(cnt-(visit[h][w]+1))


Measured memory_bytes: 70504
#include<bits/stdc++.h>
 
using namespace std;
 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007
 
int main()
{
    boost
    int n, m;
    cin >> n >> m;

    vector<vi> G(n + 1);
    for(int i = 0; i < m; i++)
    {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
    }

    vector<float> DP(n + 1, 0);
    vi max_child(n + 1, -1);
    for(int i = n - 1; i > 0; i--)
    {
        int size = 0;
        int idx = -1;
        double max = 0.0;
        loop(q, G[i])
        {
            DP[i] += DP[q];
            if(max < DP[q]) max = DP[q], idx = q;
            size++;
        }
        max_child[i] = idx;
        if(size) DP[i] /= size;
        DP[i]++;
    }

    float min_ = 1e9;
    min_ = DP[1];

    for(int j = 1; j <= n; j++)
    {
        pii z = {j, max_child[j]};
        fill(DP.B, DP.E, 0.0);
        for(int i = n - 1; i > 0; i--)
        {
            int size = 0;
            loop(q, G[i])
            {
                if(i == z.F && q == z.S) continue;
                DP[i] += DP[q];
                size++;
            }
            if(size)
            {
                DP[i] /= size;
                DP[i]++;
            }
            else DP[i] = 1e9;
        }
        min_ = min(min_, DP[1]);
    }

    cout << fixed << setprecision(9) << min_ << nl;
    return 0;
}


Measured memory_bytes: 1408
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
using namespace std;

#define MAX 1000000
long long N,M;
long long L[MAX],R[MAX];


int main(){
  cin >> N >> M;
  long long Lmax,Rmin;
  Lmax = 1;
  Rmin = N;
  for(int i=0;i<M;i++){
    cin >> L[i] >> R[i];
  }
  for(int i=0;i<M;i++){
    Lmax = max(Lmax,L[i]);
    Rmin = min(Rmin,R[i]);
  }

  long long ans;
  long long r = 0;
  ans = max(Rmin - Lmax + 1,r);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

string weather[3] = {"Sunny","Cloudy","Rainy"};

int main(){
    string s;
    cin >> s;
    if(s == weather[0]) cout << weather[1] << endl;
    else if(s == weather[1]) cout << weather[2] << endl;
    else cout << weather[0] << endl; 
}

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

int main() {
    string stra,strb;
    int x,y,z,k=0,q=0;
    cin >> stra;
    cin >> strb;
    x= stra.length();
    y= strb.length();
    z=x+y;
    for(int i=0;i<z;i++){
        if(i%2!=0){
            cout << strb[k];
            k++;
        }else if(i%2==0){
            cout << stra[q];
            q++;
        }
    }
    cout << endl;
}

Measured memory_bytes: 3584
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

bool throw_comp(const pair<ll, ll> & p1, const pair<ll, ll> & p2)
{
	return p1.second > p2.second;
}

int main()
{
	ll N = 0;
	ll H = 0;
	ll max_a = -1;
	ll ret = 0;

	cin >> N >> H;

	vector< pair<ll, ll> > sword(N);	// sword[i] = (a, b)

	Rep(i, N) {
		cin >> sword[i].first >> sword[i].second;
		if (max_a < sword[i].first) {
			max_a = sword[i].first;
		}
	}

	// sort bi
	sort(sword.begin(), sword.end(), throw_comp);

	Rep(i, N) {
		if (sword[i].second > max_a) {
			ret++;
			H -= sword[i].second;
			if ( H <= 0 ) {
				break;
			}
		}
		else {
			break;
		}
	}
	if (H > 0) {
		ret += ceil((double)H / max_a);
	}

	cout << ret << endl;

	return 0;
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (auto it = vc.begin(); it != vc.end(); ++it)
  {
    if (std::next(it) == vc.end())
      os << *it;
    else
      os << *it << ' ';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  using std::cout;
  ui N{}; std::cin >> N;
  double_t sum{};
  constexpr ui BTC = 380000;
  const string JPY = "JPY";

  rep(0, N)
  {
    double_t tmp{};
    string str{};
    cin >> tmp >> str;
    if(str == JPY)
    {
      sum += tmp;
    }
    else
    {
      sum += tmp * BTC;
    }
  }

  cout << sum << '\n';
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  
int main(void){
	int a,b,d,r;
	double f; 
    scanf("%d %d\n", &a, &b);
 
 	d = a/b;
 	r = a%b;
 	f = 1.0 * a/b ;
 
	printf("%d ",d);
	printf("%d ",r);
	printf("%.8lf\n",f);
     
    return 0;
} 

Measured memory_bytes: 1072
# -*- coding: utf-8 -*-

N=input()

#約数列挙
def make_divisors(n):
    divisors=[]
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n/i:
                divisors.append(n/i)
    return divisors

def func(a,b):
    return a**5-b**5

L=make_divisors(N)
for yakusu in L:
    for a in range(1,10**3):
        b=a-yakusu
        ret=func(a,b)
        if ret==N:
            print a,b
            quit()


Measured memory_bytes: 86788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<n;i++)
int main(){
   int a,s; cin>>a; s=0;
   rep(i,a+1) {if(i<10) s++; else if(i>99 && i<1000) s++; else if(i>9999 && i<100000) s++;}
  cout<<s<<endl;
}

Measured memory_bytes: 256
#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);
 
  ll K;
  cin >> K;
  ll val = 7;
  for (ll i = 1; i <= 3e7; ++i) {
    val %= K;
    if (!val) {
      cout << i << endl;
      return 0;
    }
    val = val*10 + 7;
  }
  cout << -1 << endl;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){s[i]='X';}
        else if(s[i]=='B'){s[i]='Y';}
        else if(s[i]=='C'){s[i]='Z';}
        else s[i]-=3;
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3232
#include <cstdio>
int H, W, Q, ax, ay, bx, by, s[2009][2009], ex[2009][2009], ey[2009][2009]; char c[2009][2009];
int main() {
	scanf("%d %d %d", &H, &W, &Q);
	for (int i = 0; i < H; i++) {
		scanf("%s", c[i]);
		for (int j = 0; j < W; j++) s[i + 1][j + 1] = c[i][j] - 48;
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W - 1; j++) {
			if (s[i][j] && s[i][j + 1]) ex[i][j] = 1;
		}
	}
	for (int i = 1; i <= H - 1; i++) {
		for (int j = 1; j <= W; j++) {
			if (s[i][j] && s[i + 1][j]) ey[i][j] = 1;
		}
	}
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) s[i + 1][j + 1] += s[i + 1][j];
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) s[i + 1][j + 1] += s[i][j + 1];
	for (int i = 0; i < H; i++) for (int j = 0; j < W - 1; j++) ex[i + 1][j + 1] += ex[i + 1][j];
	for (int i = 0; i < H; i++) for (int j = 0; j < W - 1; j++) ex[i + 1][j + 1] += ex[i][j + 1];
	for (int i = 0; i < H - 1; i++) for (int j = 0; j < W; j++) ey[i + 1][j + 1] += ey[i + 1][j];
	for (int i = 0; i < H - 1; i++) for (int j = 0; j < W; j++) ey[i + 1][j + 1] += ey[i][j + 1];
	for (int i = 0; i < Q; i++) {
		scanf("%d %d %d %d", &ax, &ay, &bx, &by); ax--, ay--;
		int vc = s[ax][ay] + s[bx][by] - s[ax][by] - s[bx][ay];
		int exc = ex[ax][ay] + ex[bx][by - 1] - ex[ax][by - 1] - ex[bx][ay];
		int eyc = ey[ax][ay] + ey[bx - 1][by] - ey[ax][by] - ey[bx - 1][ay];
		printf("%d\n", vc - exc - eyc);
	}
	return 0;
}

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

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

    int count = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <=c; k++) {
                if (500*i + 100*j + 50*k == x) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
h, w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))

s = []
for i in range(n):
  s += [str(i+1)]*a[i]
#print(s)
#quit()

for i in range(h):
  l = s[w*i:w*(i+1)]
  if i%2 == 1:
    l.reverse()
  print((" ").join(l))

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename Key,typename Value>
class hashmap {
	std::vector<std::pair<Key,Value>> map;
	uint64 mask, temp, count;
public:
	hashmap() :map(8192, std::make_pair(~static_cast<Key>(0), Value())) {
		mask = 8191; count = 0;
	}
	hashmap(size_t s) {
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<Key>(0), Value()));
	}
	Value &operator[](Key suf) {
		temp = mask&std::hash<Key>()(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(Key key, const Value &value) {
		temp = mask&std::hash<Key>()(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<Key, Value> mkey;
			uint64 t = mask;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<Key>(0), Value()));
			while (~map[t].first) {
				--t;
			}
			while (++t <= (mask >> 1)) {
				mkey = map[t];
				map[t].first = ~static_cast<Key>(0);
				temp = mask&std::hash<Key>()(mkey.first);
				while (~map[temp].first) {
					temp = mask&(temp + 1);
				}
				map[temp] = mkey;
			}
			for (t = 0;t <= mask >> 1;++t) {
				if (~map[t].first) {
					mkey = map[t];
					map[t].first = ~static_cast<Key>(0);
					temp = mask&std::hash<Key>()(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(Key key) {
		temp = mask&std::hash<Key>()(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	hashmap<uint64,uint32> map(1);
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 15272
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std; 
#define MAXA 100
#define MAXB 100
int main(int argc,char const* argv[])
{
  int a,b,c,i;
  cin >> a >> b >> c;
  for(i=1;i<=(MAXA*(MAXA-1))/2;i++)
    {
      if(a*i%b==c)
	{
	  cout << "YES" << endl;
	  return 0;
	}
    }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
A,B = map(int,input().split())
S = input()
ans = 0
for i in range(A+B+1):
    if i < A:
        if ord(S[i]) >= 48 and ord(S[i]) <= 57:
            ans += 1
    elif i == A:
        if ord(S[A]) == 45:
            ans += 1
    else:
        if ord(S[i]) >= 48 and ord(S[i]) <= 57:
            ans += 1
if ans == A+B+1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064