akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


int main() {
    int h, w;
    cin >> h >> w;
    auto dp = make_v(h, w, 0);
    dp[0][0] = 1;
    vector<string> v(h);
    for (int i = 0; i < h; ++i) {
        cin >> v[i];
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(v[i][j] == '#') continue;
            if(i != 0) (dp[i][j] += dp[i-1][j]) %= MOD;
            if(j != 0) (dp[i][j] += dp[i][j-1]) %= MOD;
        }
    }
    cout << dp[h-1][w-1] << "\n";
    return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define M(x) ((x+MOD)%MOD)
#define MAX 2010

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(b, n*a) << endl;
//	system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define int long long
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (ll i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((ll)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <ll, ll> pii ;
typedef vector <ll> vi ;
typedef vector <pii> vii ;
typedef queue <ll> qi ;
typedef queue <pii> qii ;
typedef set <ll> si ;
typedef map <ll, ll> mii ;
typedef map <string, ll> msi ;
const ll maxn = 2e6 + 100 ;
const ll inf = 0x3f3f3f3f ;
const ll iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 998244353 ;
const double eps = 1e-7 ;
template <class T = ll> T chmin(T &a, T b) { return a = min(a, b);}
template <class T = ll> T chmax(T &a, T b) { return a = max(a, b);}
template <class T = ll> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

int n, len, x[maxn], y[maxn], d[100];

bool f[2];

void Print(int X, int Y)
{
	for (int i = 1; i <= len; i++)
	{
		if (abs(X) > abs(Y))
		{
			if (X > 0) putchar('R'), X -= d[i];
			else putchar('L'), X += d[i];
		}
		else
		{
			if (Y > 0) putchar('U'), Y -= d[i];
			else putchar('D'), Y += d[i];
		}
	}
	puts("");
	return ;
}

signed main()
{
	n = read();
	rep(i, 1, n) x[i] = read(), y[i] = read(), f[(x[i] + y[i]) & 1] = 1;
	if (f[0] && f[1])
	{
		puts("-1");
		return 0;
	}
	per(i, 30, 0) d[++ len] = (1 << i);
	if (f[0]) d[++ len] = 1;
	printf("%lld\n", len); 
	rep(i, 1, len) printf("%lld%c", d[i], " \n"[i == len]);
	rep(i, 1, n) Print(x[i], y[i]);
	return 0;
}


Measured memory_bytes: 2304
package main

import (
    "fmt"
    "math"
)

func visit(cnt, a int) int {
    if a%2 == 1 {
        return cnt
    }
    return visit(cnt+1, a/2)
}

func main() {
    var n, a, cnt int
    var min int = math.MaxInt64
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        cnt = visit(0, a)
        if cnt < min {
            min = cnt
        }
    }
    fmt.Println(min)
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, const char * argv[])
{
    bool b = true;
    vector<int> a;
    int c;
    while(b)
    {
        cin >> c;
        if(c == 0)
        {
            b = false;
        }
        else
        {
            a.push_back(c);
        }
    }
    for(int d = 0; d < a.size(); d++)
    {
        cout << "Case " << d + 1 << ": " << a[d] << endl;
    }
}


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

int main(){
    int k,n;
    cin >> k >> n;
    int m;
    vector<int> a(n+1);
    rep(i,n) cin >> a[i];
    a[n] = k + a[0];
    rep(i,n){
        m = max(m,abs(a[i] - a[i+1]));
    }
    cout << k - m << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

vector<int> pf(int n) {
    vector<int> primes;
    if (n%2 == 0) {
        primes.push_back(2);
        while (n%2 == 0) n /= 2;
    }
    for (int i=3; i*i<=n; i+=2) {
        if (n%i) continue;
        primes.push_back(i);
        while (n%i == 0) n /= i;
    }
    if (n != 1) primes.push_back(n);

    return primes;
}

int main() {
    int n;
    cin >> n;
    int all_gcd;
    bool pc = true;
    unordered_map<int, bool> prime_check;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        all_gcd = i==0?a:gcd(all_gcd, a);

        if (!pc) continue;
        vector<int> primes = pf(a);
        for (auto i : primes) {
            if (prime_check[i])
                pc = false;
            prime_check[i] = true;
        }
    }

    if (pc)
        cout << "pairwise coprime" << endl;
    else if (all_gcd == 1)
        cout << "setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }

const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int w , a, b;
    cin >> w >> a >> b;
    if(a > b){
        cout << max(0, a-(b+w));
    }
    else{
        cout << max(0, b-(a+w));
    }

    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  
  // calculate floor(log_K(N))+1
  // log_K(N) = log(N) / log(K)
  int digits;
  digits = int(floor(log2(double(N)) / log2(double(K))))+1;
  cout << digits;  
  
  return 0;
}

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

int main() {
	int n,p;
	
	while(cin >> n >> p,n){
		int wan = p;
		vector<int> te;
		te.resize(n);
	
		int i=0;
		while(1){
			if(wan == 0){
				wan = te[i];
				te[i] = 0;
			}else{
				if(te[i]==p-1) break;
				te[i]++;
				wan--;
			}
		
			i++;
			i = i%n;
		}
	
		cout << i << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
p,q= input().split()
a,b =(int(p), int(q))
a_list = []
b_list = []
import math 
for i in range(int((a+2)/0.08)):
    if a/0.08 <= i and i <(a+1)/0.08:
        a_list.append(i)
for i in range(int((b+2)/0.1)):
    if b/0.1 <= i and i <(b+1)/0.1:
        b_list.append(i)

        
m=len(a_list)-1
for i in range(m):
    if a_list[i] in b_list and i is not m:
        print(a_list[i])
        break
    elif i ==m-1:
        print(-1)

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

using namespace std;

int main() {
	int n, a, b;
	ignore = scanf("%d %d %d", &n, &a, &b);
	printf(abs(a - b) % 2 == 0 ? "Alice\n" : "Borys\n");
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9

using namespace std;
inline ll read()
{
    ll x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
ll n, s;

int main() 
{
	string s;
	cin >> s;
	int j = 0;
	for (int i = 0; i < s.size();) 
	{
		if (j == s.size()) 
		{
			cout << "NO\n";
			return 0;
		}
		if (i + 7 <= s.size() && s.substr(i, 7) == "dreamer" && (i + 7 == s.size() || s[i + 7] != 'a')) i += 7;
		else if (i + 5 <= s.size() && s.substr(i, 5) == "dream") i += 5;
		else if (i + 6 <= s.size() && s.substr(i, 6) == "eraser" && (i + 6 == s.size() || s[i + 6] != 'a')) i += 6;
		else if (i + 5 <= s.size() && s.substr(i, 5) == "erase") i += 5;
		j ++;
	}
	cout << "YES\n";
	cin >> s;
}


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

using lint = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int l, r;
	cin >> l >> r;
	if ((l-1)/2019 != r/2019) {
		cout << "0\n";
		exit(0);
	}
	int minv = INT_MAX/2;
	for (int i = l % 2019; i <= r % 2019; ++i) 
		for (int j = r % 2019; j > i; --j) 
			minv = min(minv, (i*j) % 2019);
	cout << minv << '\n';
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long s,sum,n,a[1000001],b[1000001],cnt,ans;
long long f(long long x,long long y)
{
	if (x*y%9!=0)
		return x*y%9;
	if (x==0)
		return 0;
	return 9; 
} 
int main()
{
	cin>>n;
	for (int i=1;i<=n;++i)
	{
		cin>>a[i]>>b[i];
		ans+=b[i];
	}
	for (int i=1;i<=n;++i)
	{
		cnt=0;
		for (int j=0;j<=8;++j)
			if (f(a[i],j)+a[i]>9)
				cnt++;
		cnt*=(b[i]/9);
		for (int j=0;j<=b[i]%9-1;++j)
			if (f(a[i],j)+a[i]>9)
				cnt++;
		if (f(a[i],0)+a[i]>9)
			cnt--;
		ans+=cnt;
	}
	for (int i=1;i<=n;++i)
		a[i]=f(a[i],b[i]);
	for (int i=1;i<=n;++i)
		{
			sum+=a[i];
			if (sum>9)
			{
				sum-=9;
				ans++;
			}
		}
	cout<<ans-1<<endl;
	return 0;
}


Measured memory_bytes: 5888
// ReversingNumbers.c
// 与えられた数列を逆順に出力するプログラムを作成して下さい。
// 【入力】
// 入力は以下の形式で与えられます：
//   n
//   a1 a2 . . . an
// n は数列の長さを示し、ai は i 番目の数を表します。
// 【出力】
// 逆順の数列を１行に出力して下さい。数列の要素の間に１つの空白を入れて下さい
// （最後の数の後に空白は入らないことに注意して下さい）。
// 【制約】
// ・n ≤ 100
// ・0 ≤ ai < 1000
// 【例】
// 入力：
// 5
// 1 2 3 4 5
// 出力：
// 5 4 3 2 1
//
// 入力：
// 8
// 3 3 4 4 5 8 7 9
// 出力：
// 9 7 8 5 4 4 3 3
#include<stdio.h>

int main( void) {
  int n;
  int a[100];

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

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

  return 0;
}



Measured memory_bytes: 2084
import numpy as np
n = int(input())
aa = list(map(int, input().split()))
mod = 10**9+7
res = 1
pow2 = 1
ans = 0
for i in range(60):
    cnt = np.count_nonzero(np.array(aa)&pow2)
    ans = (ans + cnt * (n-cnt) * res)%mod
    res = (res*2)%mod
    pow2*=2
print(ans)

Measured memory_bytes: 48828
#include <string>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long;

int main(){
  ll N,P;
  vector<ll> a{1},b{1};//soinsuu
  cin>>N>>P;
  if(N==1){
    cout<<P<<endl;
    return 0;
  }
  ll maxa= P/(N*2);
  if(sqrt(P)<maxa)maxa=sqrt(P);
  for(ll i=2;i<=maxa;++i){
    if(i>P)break;
    if(P%i==0){
      if(a.back()!=i){
      	a.push_back(i);
        b.push_back(1);
      }else{
        b.back()++;
      }
      P/=i;
      i--;
    }
  }
  ll ans=1;
  for(int i=1;i<a.size();++i){
    ll tmp = pow(a[i],(b[i]/N));
    //cout<<"tmp"<<tmp<<endl;
    ans*=tmp;
  }
  /*for(auto num:a){
  	cout<<num<<endl;
  }
  cout<<"--"<<endl;
  for(auto num:b){
  	cout<<num<<endl;
  }*/
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
def main():
  values = [list(map(int, input().split())) for _ in range(int(input()))]
  values.sort(key=lambda x: x[1])
  cost = 0

  for c, d in values:
    cost += c

    if d < cost:
      print('No')
      return

  print('Yes')


if __name__ == '__main__':
  main()


Measured memory_bytes: 88920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0;i < n;i++){
        cin >> p[i];
        p[i]--;
    }
    int cnt = 0;
    for(int i = 0;i < n;i++){
        if(p[i] == i){
            if(i + 1 < n){
                int tmp = p[i];
                p[i] = p[i+1];
                p[i+1] = tmp;
                cnt++;
            }
            else{
                int tmp = p[i];
                p[i] = p[i-1];
                p[i-1] = tmp;
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

int constexpr M = 1e9 + 7, N = 134;
int p[N];

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    string s, t;
    cin >> n >> s >> t;
    int a = 0, b = 0;
    p[0] = 1;
    for(int i = 1; i < N; ++i) {
        p[i] = 29ll * p[i - 1] % M;
    }

    int ans = 2 * n;
    reverse(begin(s), end(s));
    for(int i = 0; i < n; ++i) {
        a += p[i] * (s[i] - 'a');
        a %= M;
        b = 29ll * b % M;
        b += t[i] - 'a';
        b %= M;
        if(a == b) ans = 2 * n - (i + 1);
    }
    cout << ans << endl;
}

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

struct S {
  int x;
  int y;
};

struct L {
  int st;
  int w;
};

int main() {
  stack<S> ls;
  stack<L> ll;

  char c;
  int px = 0;
  int py = 0;
  while(cin >> c) {
    if(c == '\\') {
      S _s;
      _s.x = px;
      _s.y = py;
      ls.push(_s);
      py--;
    }
    else if(c == '/') {
      py++;
      if(!ls.empty()) {
        if(ls.top().y == py) {
          L _l;
          _l.w = 0;
          while(!ll.empty()) {
            if(ll.top().st > ls.top().x) {
              _l.w += ll.top().w;
              ll.pop();
            }
            else {
              break;
            }
          }
          _l.st = ls.top().x;
          _l.w += px - ls.top().x;
          ll.push(_l);
          ls.pop();
        }
      }
    }
    px++;
  }

  // output
  vector<int> vec;
  int A = 0;
  int k = ll.size();
  while(!ll.empty()) {
    vec.push_back(ll.top().w);
    A += ll.top().w;
    ll.pop();
  }
  cout << A << endl;
  if(k == 0) {
    cout << k << endl;
  }
  else {
    cout << k << " ";
    for(int i=k-1;i>=0;i--) {
      cout << vec[i] << (i == 0 ? "" : " ");
    }
    cout << endl;
  }
}

Measured memory_bytes: 1368
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    
    int max = 0;

    map<string, int> dict;
    vector<string> xmax(0);
    for (string x; N--; dict[x]++) {
        cin >> x;
        if (dict[x] > max) {
            max = dict[x];
            xmax ={x};
        } else if (dict[x] == max) {
            xmax.push_back(x);
        }
    }
    
    sort(xmax.begin(), xmax.end());
    
    int size = xmax.size();
    for (int i=0; i<size; i++) {
        cout << xmax.at(i) << endl;
    }
}


Measured memory_bytes: 27248
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <utility>
#include <algorithm>
using std::cin;
using std::cout;
using std::endl;

int main(void)
{
    int N, K;
    cin >> N >> K;
    int m1;
    for(int i=0;i<N;i++) scanf("%d",&m1);
    int answer = 1;
    N = N - K;
    while (N > 0)
    {
        N = N - (K-1);
        answer++;
    }
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 384
use v5.18;
use warnings;
use utf8;
sub line { chomp(my $str = <>); $str; }
sub split_line { (split / /, line) }

my @s = split //, line;
my @ans;
for my $i (0 .. $#s) {
  if ($i % 2 == 0) {
    push @ans, $s[$i];
  }
}
say join '', @ans;


Measured memory_bytes: 16128
def main():
    import os

    INF = 10 ** 9 + 10

    D = int(input())
    *C, = map(int, input().split())
    # C[type]
    # sum(ci*(d-last(d,i) for ci in C)だけ下がる
    S = [[int(x) for x in input().split()] for _ in range(D)]
    # S[day][type]:=happiness

    last = [-1] * 26

    def diff(d, t):
        ret = S[d][t]
        ret -= sum(ci * (d - last[i]) for i, ci in enumerate(C) if i != t)
        return ret

    T = []
    score = 0
    for d in range(D):
        delta = -INF
        take_t = -1
        for t_ in range(26):
            buf = diff(d, t_)
            if delta < buf:
                delta = buf
                take_t = t_
            elif delta == buf and C[t_] > C[take_t]:
                delta = buf
                take_t = t_

        last[take_t] = d
        score += buf
        T.append(take_t + 1)
    print(*T, sep='\n')
    # print(os.path.join(os.path.dirname(__file__), 'output_file.txt'))
    # with open(file=os.path.join(os.path.dirname(__file__), 'output_file.txt'), mode='w', encoding='utf-8') as f:
    #     for t in map(str, T):
    #         f.write(t)
    #         f.write('\n')

    # print(score)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		int count01 = 0;
		int count10 = 0;

		for (int i = 0; i < s.length(); i++) {
			if (Integer.parseInt(s.substring(i, i + 1)) == i % 2) {
				count01++;
			}
		}
		count10 = s.length() - count01;
		System.out.println(Math.min(count01, count10));

		sc.close();
	}
}

Measured memory_bytes: 31632
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
    x = 0;
    T fh = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    x *= fh;
}
inline void d_read(double &x) {
    x = 0.0;
    int fh = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
    if (ch == '.') {
        double num = 1.0;
        ch = getchar();
        for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
    }
    x *= fh;
}
template <typename T>
inline void wt(T x) {
    if (x > 9) wt(x / 10);
    putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    wt(x);
    putchar(c);
}
const int N = 1e5 + 5;
char s[N], t[N];
int main() {
    scanf("%s", s + 1);
    scanf("%s", t + 1);
    int ans = 1e9, cnt = 0, n = strlen(s + 1), m = strlen(t + 1);
    for (int i = 0; i <= n - m; i ++) {
        cnt = 0;
        for (int j = 1; j <= m; j ++) {
            if (s[i + j] != t[j]) cnt ++;
        }
        ans = min(ans, cnt);
    }
    writeln(ans, '\n');
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
ll dp2[300000][60]={};
int main() {
	int n;
	cin>>n;
	ll r=0;
	rep(i,n){
		int a1,a2;
		a1=(i+1)%10;
		a2=i+1;
		if(a1==0)continue;
		if(a2>9)a2/=10;
		if(a2>9)a2/=10;
		if(a2>9)a2/=10;
		if(a2>9)a2/=10;
		if(a2>9)a2/=10;
		if(a1==a2)r++;
		if(a2+a1*10<=n)r++;
		rep(j,10){
			if(n>=(a1*100+j*10+a2))r++;
		}
		rep(j,100){
			if(n>=(a1*1000+j*10+a2))r++;
		}
		rep(j,1000){
			if(n>=(a1*10000+j*10+a2))r++;
		}
		rep(j,10000){
			if(n>=(a1*100000+j*10+a2)){
				r++;
			}else{
				break;
			}
		}

//		cout<<i<<" "<<r<<endl;
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,m,ans;
int main()
{
	cin>>n>>m;
	if(n>m) swap(n,m);
	if(n==1&&m==1){printf("1\n");return 0;}
	if(n==1) {cout<<m-2>=0?m-2:1;return 0;}
	if(n==2) {printf("0\n");return 0;}
	ans=(n-2)*(m-2);
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class CSharp{
    public static void Main(){
        Kyopuro chokudai = new Kyopuro();
	    chokudai.AtCoder();
	}
}

public class Kyopuro{
    List<int>[] list;
    bool[] v;
    bool f;
    List<int> ans1;
    List<int> ans2;
    
    public void AtCoder(){
        string[] s;
		s = Console.ReadLine().Split(' ');
		
		int n, m;
		n = int.Parse(s[0]);
		m = int.Parse(s[1]);
		
		int[] a = new int[m];
		int[] b = new int[m];
		for (int i = 0; i < m; i++){
		    s = Console.ReadLine().Split(' ');
		    a[i] = int.Parse(s[0]) - 1;
		    b[i] = int.Parse(s[1]) - 1;
		}
		
		list = new List<int>[n];
		for (int i = 0; i < n; i++) list[i] = new List<int>();
		for (int i = 0; i < m; i++){
		    list[a[i]].Add(b[i]);
		    list[b[i]].Add(a[i]);
		}
		
		ans1 = new List<int>();
		ans2 = new List<int>();
		ans1.Add(0);
		v = new bool[n];
		f = false;
		v[0] = true;
		v[list[0][0]] = true;
		Dfs1(list[0][0]);
		f = false;
		Dfs2(0);
		Console.WriteLine(ans1.Count+ans2.Count);
		foreach(int p in ans2) Console.Write(p+1+" ");
		foreach(int p in ans1) Console.Write(p+1+" ");
		Console.WriteLine();
    }
    void Dfs1(int x){
        ans1.Add(x);
        foreach(int p in list[x]){
            if(!v[p]){
                v[p] = true;
                Dfs1(p);
            }
            if(f) return;
        }
        f = true;
    }
    void Dfs2(int x){
        foreach(int p in list[x]){
            if(!v[p]){
                v[p] = true;
                Dfs2(p);
            }
            if(f){
                ans2.Add(p);
                return;
            }
        }
        f = true;
    }
    
    public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
}

Measured memory_bytes: 35964
cnt_monster,cnt_deathblow = gets.split(" ").map(&:to_i)
monster_hp = gets.split(" ").map(&:to_i)
monster_hp = monster_hp.sort.reverse!

cnt_attack = 0

(cnt_deathblow...cnt_monster).each do |i|
  cnt_attack += monster_hp[i]
end

puts cnt_attack

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

using namespace std;

const int Nmax = 100010;

int n, ans[Nmax], q;

bool viz[Nmax];

int main()
{
    int pi = 1, x, y;
    cin >> n >> q;
    ans[1] = 1;
    while(q --)
    {
        if(!viz[pi] && ans[pi])
        {
            if(pi - 1 >= 1)
            {
                ans[pi - 1] = 1;
                viz[pi - 1] = true;
            }
            if(pi + 1 <= n)
            {
                ans[pi + 1] = 1;
                viz[pi + 1] = true;
            }
        }
        cin >> x >> y;
        if(pi == x)
            pi = y;
        else if(pi == y)
            pi = x;
        swap(ans[x], ans[y]);
        swap(viz[x], viz[y]);
        if(!viz[pi] && ans[pi])
        {
            if(pi - 1 >= 1)
            {
                ans[pi - 1] = 1;
                viz[pi - 1] = true;
            }
            if(pi + 1 <= n)
            {
                ans[pi + 1] = 1;
                viz[pi + 1] = true;
            }
        }
    }
    int sum = 0;
    for(int i = 1 ; i <= n ; i++)
        sum += ans[i];
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 896
input = STDIN.read.split(' ')

def check_cost(tasks, current_task = 0, cost = 0)
  if tasks.length - 1 == current_task
    return cost
  end
  nest_task = current_task + 1
  current_cost = (tasks[nest_task].to_i - tasks[current_task].to_i).abs
  cost = cost + current_cost
  check_cost(tasks, nest_task, cost)
end

m = nil
input.permutation{ |l|
  cost = check_cost(l)
  if m == nil || cost < m 
    m = cost
  end
}
print m

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

map<string,int> mp;

int main(){
    int n;
    int ans=0;
    string s;
    cin>>n;
    while(n--){
        cin>>s;
        mp[s]=1;
    }
    
    for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++){
        ans++;
    }
    
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 19200
// C.

#include <iostream>
#include <list>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	int n, a;
	list<int> v;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (i % 2) {
			v.push_back(a);
		} else {
			v.push_front(a);
		}
	}
	if (n % 2) {
		list<int>::iterator it;
		for (it = v.begin(); it != v.end(); ++it) {
			cout << *it << " ";
		}
	} else {
		list<int>::reverse_iterator it;
		for (it = v.rbegin(); it != v.rend(); ++it) {
			cout << *it << " ";
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 8576
#include<iostream>

using namespace std;

int main(){
        int n;
        cin >> n;
        long *a = new long[n];
        long r1 = 0;
        long f = 1;
        for(int i=0;i<n;i++){
                cin >> a[i];
                r1 += f * a[i];
                f *= -1;
        }

        a[0] = a[0] - r1/2;
        for(int i=1;i<n;i++){
                a[i] = a[i] - a[i-1];
        }

        cout << r1 << " ";

        for(int i=0;i<n-1;i++){
                cout << 2 * a[i] << " ";
        }
        cout << endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <bitset>

using namespace std;
bitset <4000010> sum;
int main()
{
    int n,nr,i,s=0;
    cin>>n;
    sum[0]=1;
    for(i=1;i<=n;i++)
    {
        cin>>nr;
        sum|=(sum<<nr);
        s+=nr;
    }
    for(i=s/2+s%2;i<=s;i++)
    {
        if(sum[i]==1)
        {
            cout<<i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2300
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,K=map(int, input().split())
P = list(map(int, input().split()))

S = []

for i in range(N):
    S.append((P[i]+1)/2)

tmp = sum(S[:K])
ans = tmp

for i in range(N-K):
    tmp = tmp - S[i] + S[i+K]
    ans = max(ans, tmp)


print(ans)


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

int main(){
  ll n,k;
  cin >> n >> k;
  map<ll,ll> m;
  for(ll i=0;i<n;i++){
    ll a;
    cin >> a;
    m[a]++;
  }
  
  priority_queue<ll> pq;
  for(int i=0;i<=n;i++){
    if(m[i] != 0){
      pq.push(m[i]);
    }
  }
  
  //cout << pq.size() << endl;
  
  int num=0;
  for(int i=0;i<k;i++){
    if(!pq.empty()){
	    num += pq.top();
	  	pq.pop();
    }
    //cout << pq.size() << endl;
    //cout << num << endl;
  }
  
  //cout << pq.size() << endl;
  
  if(pq.size() != 0){
	  cout << n - num << endl;
  }else{
    cout << 0 << endl;
  }
  
  return(0);
}

Measured memory_bytes: 14964
H,N = map(int,input().split())
C = [list(map(int,input().split())) for i in range(N)]

A = []
B = []
for i in range(N):
    A.append(C[i][0])
    B.append(C[i][1])

M = max(A)
m = min(A)

dp = {} #dp[h]は体力をh減らすのに必要な魔力の最小値

for i in range(-M+1,1):
    dp[i] = 0

for i in range(1,H+m):
    dp[i] = min(dp[i-A[j]] + B[j] for j in range(N))

print(min(dp[i] for i in range(H,H+m)))

Measured memory_bytes: 43484
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
  int N; cin >> N; int H[N]; bool ab=true;
  if (N==1) {cout << "Yes" << endl; return 0;}
  for(int i=0; i<N; i++) cin >> H[i];
  for(int i=N-2; i>=0; i--) {
    if (H[i] - 1 > H[i+1]){
      cout << "No" << endl; return 0;
    } else if (H[i] - 1 == H[i+1]) {
      H[i]--;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;i <= 0; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x); i++)
#define rreps(i,x) for(ll i = (ll)(x)-1; i <= 1; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    ll ans = 0;
    rep(i,sqrt(n)+1){
        if(i > 0 && n%i == 0 && n > i * (i+1))ans += n/i-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    bool flag=true;
    for(int i=0; i<(s.size()-1)/2; i++) {
        if(s.at(i) != s.at( (s.size()+3)/2-1+i )){
            flag=false;
            break;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";
}

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

    divisors.sort()
    return divisors

n,m=map(int,input().split())
l=make_divisors(m)
for i in l:
    if n<=i:
        ans=m//i
        break
print(ans)

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

int main() {
    int n, k, i, j,ans = 0;
    cin >> n >> k;
    bool lst[n];
    for(i = 0; i < n; i++){
        lst[i] = false;
    }
    for(i = 0; i < k; i++){
        int d;
        cin >> d;
        for(j = 0; j < d; j++){
            int a;
            cin >> a;
            lst[a-1] =true;
        }
    }
    for(i = 0; i < n; i++){
        if(!lst[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

void solve()
{
    int arr[10];
    for (int i = 0; i < 10; ++i)
        cin >> arr[i];
    bool f = false;
    for (int bit = 0; bit < (1 << 10); ++bit)
    {
        bool judge = true;
        vector<int> v1, v2;
        for (int i = 0; i < 10; ++i)
        {
            if (bit >> i & 1)
                v1.push_back(arr[i]);
            else
                v2.push_back(arr[i]);
        }

        int n = v1.size();
        int m = v2.size();
        for (int i = 0; i < n - 1; ++i)
        {
            if (v1[i] < v1[i + 1])
                continue;
            else
                judge = false;
        }

        for (int i = 0; i < m - 1; ++i)
        {
            if (v2[i] < v2[i + 1])
                continue;
            else
                judge = false;
        }

        if (judge)
        {
            f = judge;
            break;
        }
    }
    if (f)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);

    int n;
    cin >> n;
    while (n--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>

int n, m;
int field[90][90];

int rec(int i, int j) {
    int tmp;
    int max = 0;

    if (field[i][j] == 0) return max;

    field[i][j] = 0;

    if (i > 0) {
        tmp = rec(i-1, j);
        if (max < tmp) max = tmp;
    }

    if (i < n-1) {
        tmp = rec(i+1, j);
        if (max < tmp) max = tmp;
    }

    if (j > 0) {
        tmp = rec(i, j-1);
        if (max < tmp) max = tmp;
    }

    if (j < m-1) {
        tmp = rec(i, j+1);
        if (max < tmp) max = tmp;
    }

    field[i][j] = 1;

    max += 1;

    return max;
}

int main() {
    while (1) {
        int i;
        int max = 0;

        scanf("%d", &m);
        scanf("%d", &n);
        if (m == 0 && n == 0) return 0;

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

        for (i=0;i<n;i++) {
            int j;
            for (j=0;j<m;j++) {
                int tmp = rec(i, j);
                if (max < tmp) max = tmp;
            }
        }

        printf("%d\n", max);
    }
}

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

using namespace std;
using ll = long long;

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


int main() {
    string s;
    cin>>s;
    ll k;
    cin>>k;

    bool flg = true;
    char sf = s[0];
    for(char ss : s){
        flg &= (ss==sf);
    }
    if(flg){
        cout<<((ll)s.size()*k)/2<<endl;
        return 0;
    }

    char now = '*', f='a', b='a';
    V<int> cnt;
    int r = 0;
    for (int i = 0; i < s.size(); i++) {
        if(i==0){
            now=s[i];
            r++;
            f=s[i];
            continue;
        }
        if(s[i]!=now || i==s.size()-1){
            if(i==s.size()-1){
                if(s[i]==now)r++;
                else{
                    cnt.push_back(r);
                    r=1;
                }
            }
            cnt.push_back(r);
            r = 1;
            now=s[i];
            if(i==s.size()-1)b=s[i];
        }else{
            r++;
        }
    }

    ll ans = 0;
    int fcnt = cnt[0], bcnt = cnt[cnt.size()-1];
    for(int ci : cnt){
        ans += ci/2;
    }

    if(f==b){
        cout<<(ans)*k-(fcnt/2+bcnt/2-(fcnt+bcnt)/2)*(k-1)<<endl;
    }else{
        cout<<(ans)*k<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[100005]={0};
int main()
{ 
string s;
cin>>s;
int count=1;
LL ans=0;
for(int i=0;i<s.length();i++)
{
	if(s[i]=='W')
	{
		ans+=(i+1)-count;
		count++;
	}
}


cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(uniqu7e(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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 END()
{
	cout << "NO" << endl;
	exit(0);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n;
	map<int, int> D;
	REP(i, n)
	{
		int d;
		cin >> d;
		D[d]++;
	}
	cin >> m;
	REP(i, m)
	{
		int t;
		cin >> t;
		if (!D.count(t) || D.at(t) == 0) END();
		D[t]--;
	}
	cout << "YES" << endl;
	
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string S;
	cin >> S;
	
	if (S == "Sunny") {
		cout << "Cloudy";
	}
	else if (S == "Cloudy") {
		cout << "Rainy";
	}
	else {
		cout << "Sunny";
	}
	
	
	
}

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'


int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


const int MOD = 1000000007;

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

int n, k;
double sum = 0;



void Input() {

    cin >> n >> k;
}

void Solve() {

    for(int i = 1; i <= n; i++) {

        double temp = 1.0/n;
        int now = i;
        while(now < k) {

            now *= 2;
            temp /= 2;
        }

        sum += temp;
    }

    cout << setprecision(12) << sum << endl;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();
  return 0;

}


Measured memory_bytes: 256
import itertools

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

L = [i for i in range(N)]

sum = 0
LL = list(itertools.permutations(L))
for v in LL:
  x, y = xy[v[0]]
  for u in v[1:]:
    x2, y2 = xy[u]
    sum += ((x2 - x) ** 2 + (y2 - y) ** 2) ** 0.5
    x, y = x2, y2
  
ave = sum / len(LL)
print(ave)

Measured memory_bytes: 80168
#include <bits/stdc++.h>
using namespace std;
int main() {
 	long long n;
 	cin >> n;
 	for(int i = sqrt(n); i >=1; --i) {
 		if(n % i == 0) {
 		    cout << (i + n / i - 2);
 		    break;
 		}	
 	}
 	
}

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

int main()
{
    int N,i;
    double value,sum=0;
    char money[5];
    char JPY[] = "JPY"; 

    scanf("%d",&N);

    for(i=0;i<N;i++){
        scanf("%lf%s",&value,money);
        if(strcmp(money,JPY) == 0){
            sum += value;
        }else{
            sum += value*380000;
        }
    }

    printf("%lf\n",sum);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(){
    string s; cin>>s;
    int n=s.size();
    int ans=(n-1)*n/2+1;
    vector<int> alpha(26,0);
    rep(i,n){
        int j=s.at(i)-'a';
        if(alpha.at(j)>0)ans-=alpha.at(j);
        alpha.at(j)++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#ABCを小さい順にリスト化
nums=sorted(list(map(int, input().split())))

#ABCのあまりをリスト化
rest=[i%2 for i in nums]

#ABCの偶奇が一致しているとき、差の半分だけ操作すれば良い（差は常に偶数）
if sum(rest)==0 or sum(rest)==3:
    print(((nums[2]-nums[1])+(nums[2]-nums[0]))//2) 
#一つだけ奇数のとき。偶数2つに１を加えて奇数にした後、差の半分だけ操作すれば良い（差は常に偶数）
elif sum(rest)==1:
    nums_2=[i+1 if i%2==0 else i for i in nums]
    print(((nums_2[2]-nums_2[1])+(nums_2[2]-nums_2[0]))//2+1) 
#一つだけ偶数のとき。奇数2つに１を加えて偶数にした後、差の半分だけ操作すれば良い（差は常に偶数）
elif sum(rest)==2:
    nums_3=[i+1 if i%2==1 else i for i in nums]
    print(((nums_3[2]-nums_3[1])+(nums_3[2]-nums_3[0]))//2+1) 

Measured memory_bytes: 3064
N = int(input().rstrip())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
score = 0

for i in range(N):
  #print(A[i],end="A ")
  score += B[A[i]-1]
  #print(score,end="B ")
  if (A[i-1] - A[i]) == -1 and i > 0:
    score += C[A[i]-2]
    #print(score,end="score ")
    
    
print(score)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

typedef long long ll;
typedef map<ll, ll> M;
typedef pair<ll, ll> P;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((ll)(x).size())

int main() {
  string s, t;
  cin >> s >> t;
  ll tmp, result = 1001;
  REP(i, SIZE(s) - SIZE(t) + 1) {
    tmp = 0;
    REP(j, SIZE(t)) {
      if (s[i+j] != t[j]) tmp++;
    }
    if (tmp < result) result = tmp;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3564
a,b,c,k = map(int,input().split())
p = 0

if a >= k:
    print(k)
    exit(0)
else:
    p = p + a 
    k = k - a 

if b >= k:
    print(p)
    exit(0)
else:
    k = k - b

if c >= k:
    print(p - k)
    exit(0)
else:
    p = p - c

print(p)

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

int main(){
    
    for(int i=1;;i++){
        int x;
        cin>>x;
        if(x == 0) break;
        cout<<"Case "<<i<<": "<<x<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3084
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
a, b, c, k  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ans = 0
if a <= k:
    ans += a
    k -= a
else:
    print(k)
    exit()

if b <= k:
    k -= b
else:
    print(ans)
    exit()

if c <= k:
    ans -= c
else:
    print(ans - k)
    exit()

print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    v[i]--;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if(i == n-1 && v[i] == i)
      ans++;
    else if(v[i] == i) {
      swap(v[i], v[i+1]);
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

int main(){
  ll N,M;
  cin >> N >> M;
  vec A(N),B(M);
  rep(i,N){
    cin >> A.at(i);
  }
  rep(i,M){
    cin >> B.at(i);
  }
  vec C=convolution(A,B);
  rep(i,N+M-1){
    cout << C.at(i) << endl;
  }
    
}

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

int main()
{
	int H, W;
	std::cin >> H >> W;

	std::vector< std::vector<int> > v( H, std::vector<int>( W ) );
	for ( int i = 0; i < H; ++i )
	{
		for ( int j = 0; j < W; ++j )
		{
			std::cin >> v[i][j];
		}
	}

	int counter = 0;
	std::vector< std::pair< std::pair<int, int>, std::pair<int, int> > > vv;

	for ( int i = 0; i < H; ++i )
	{
		if ( i & 1 )
		{
			// 奇数ならW-1から
			for ( int j = W - 1; j > 0; --j )
			{
				if ( v[i][j] & 1 )
				{
					v[i][j - 1]++;
					v[i][j]--;
					vv.emplace_back( std::make_pair( i, j ), std::make_pair( i, j - 1 ) );
					counter++;
				}
			}
			if ( ( v[i][0] & 1 ) && ( i != H - 1 ) )
			{
				v[i + 1][0]++;
				v[i][0]--;
				vv.emplace_back( std::make_pair( i, 0 ), std::make_pair( i + 1, 0 ) );
				counter++;
			}
		}
		else
		{
			// 偶数なら0から
			for ( int j = 0; j < W - 1; ++j )
			{
				if ( v[i][j] & 1 )
				{
					v[i][j + 1]++;
					v[i][j]--;
					vv.emplace_back( std::make_pair( i, j ), std::make_pair( i, j + 1 ) );
					counter++;
				}
			}
			if ( ( v[i][W - 1] & 1 ) && ( i != H - 1 ) )
			{
				v[i + 1][W - 1]++;
				v[i][W - 1]--;
				vv.emplace_back( std::make_pair( i, W - 1 ), std::make_pair( i + 1, W - 1 ) );
				counter++;
			}
		}
	}

	std::cout << counter << std::endl;
	for ( auto &&it : vv )
	{
		std::cout << it.first.first + 1 << " " << it.first.second + 1 << " "
				  << it.second.first + 1 << " " << it.second.second + 1 << std::endl;
	}

	return ( 0 );
}


Measured memory_bytes: 5232
#include<cstdio>
int main(){
    char s[4];
    scanf("%s",s);
    int i=0;
    while(s[i]!='\0')i++;
    if(i==2)printf("%s",s);
    else for(int k=0;k<3;k++)printf("%c",s[2-k]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long K, long long S){
  int cnt = 0;
  REP(a, K+1) {
    REP(b, K+1) {
      int c = S - a - b;
      if (0 <= c and c <= K){
        cnt += 1;
        // cerr << a << ' ' << b << endl;
      }
    }
  }

  cout << cnt << endl;
}

signed main(){
  long long K;
  scanf("%lld",&K);
  long long S;
  scanf("%lld",&S);
  solve(K, S);
}


Measured memory_bytes: 256