akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: [isize;n],
    }
    let mut a = a;
    for i in 0..n {
        a[i] -= i as isize + 1isize;
    }
    a.sort();
    let b = a[n / 2];
    let mut sum = 0;
    for num in a {
        sum += (num - b).abs();
    }
    println!("{}", sum);
}


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

int main() {
  int n;
  cin >> n;
  int keta = to_string(n).size();
  vector<int> v = {0,9,909,90909};
  if(keta%2 == 0){
    cout << v.at(keta/2) << endl;
  }
  else{
    cout << v.at(keta/2) + n-pow(10,keta-1) + 1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
main(){int a[5];rep(i,5) cin>>a[i];int k;cin>>k;int m=0;rep(i,5)rep(j,5) if(abs(a[i]-a[j])>k)m++;cout<<(m>0?":(":"Yay!");}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    print(N * 800 - (N/15) * 200);

}


Measured memory_bytes: 256
import re
s = str(input())
n = len(s)
z = [0] * n
lr = [m.start() for m in re.finditer('LR', s)]
rl = [m.start() for m in re.finditer('RL', s)]
t = []
if lr == []:
    t.append(s)
else:
    t.append(s[:lr[0]+1])
    for i in range(len(lr)-1):
        t.append(s[lr[i]+1 : lr[i+1]+1])
    t.append(s[lr[-1]+1:])
for i in range(len(t)):
    r = t[i].count('R')
    l = len(t[i]) - r
    # x : RL界面左側の数。y : RL界面右側の数。
    x = (r+1) // 2 + l // 2
    y = r // 2 + (l+1) // 2
    z[rl[i]] = x
    z[rl[i]+1] = y

delta = [str(i) for i in z]
ans = ' '.join(delta)
print(ans)

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

using namespace std;

const int N = 101;

int dp[3][N], a[3][N];

signed main(){
	int n;
	cin >> n;
	for(int i:{1,2})
		for(int j=1;j<=n;++j) cin >> a[i][j];
	
	for(int j=1;j<=n;++j)
		for(int i=1;i<=2;++i)
		 	dp[i][j] = a[i][j] + max(dp[i-1][j],dp[i][j-1]);
	cout << dp[2][n];
}

Measured memory_bytes: 3628
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const char *dir = "NWSE";
const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
int h, w;
ll l, p[100][101][4];
char in[100][101];

int main(){
	while(cin >> h >> w >> l, h){
		int y, x, d;
		rep(i, h){
			cin >> in[i];
			rep(j, w) if(isalpha(in[i][j])) y = i, x = j;
		}
		for(d = 0; dir[d] != in[y][x]; d++);
		
		memset(p, -1, sizeof(p));
		ll t = 0;
		while(t < l){
			if(p[y][x][d] >= 0){
				ll T = t - p[y][x][d];
				t += (l - t) / T * T;
				if(t == l) break;
			}
			p[y][x][d] = t;
			
			rep(it, 4){
				int ny = y + dy[d], nx = x + dx[d];
				if(ny < 0 || nx < 0 || ny >= h || nx >= w || in[ny][nx] == '#'){
					d = (d + 3) % 4;
					continue;
				}
				y = ny; x = nx; break;
			}
			t++;
		}
		cout << y + 1 << " " << x + 1 << " " << dir[d] << endl;
	}
	return 0;
}

Measured memory_bytes: 1504
n=int(input())
f=[0]*(n+1)
def fib(n,f):
	if n==0 or n==1:
		return 1
	else:
		if f[n]!=0:
			return f[n]
		else:
			f[n]=fib(n-1,f)+fib(n-2,f)
			return f[n]
print(fib(n,f))


Measured memory_bytes: 5600
import scala.io.StdIn.readLine
import scala.annotation.tailrec

object Main {
    def main(args: Array[String]): Unit = { 
        digit(readLine.split(" ").map(_.toInt).sum)
    }
    
    @tailrec
    def digit(n: Int): Unit = {
       println(n.toString.length)
       val next: String = readLine
       if(next == null) Unit else digit(next.split(" ").map(_.toInt).sum)
    }
}

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

using namespace std;
#define INFS (1LL<<28)
#define INF (1LL<<60)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
#define all(n) n.begin(),n.end()

int a[1000][1000];
int cnt[1000];
int al[1000];
signed main(){
	string s;
	cin>>s;
	string t;
	cin>>t;
	int ans=0;
	lp(i,3){
		if(s[i]==t[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
    int A1, A2, A3;

    cin >> A1 >> A2 >> A3;

    if((A1+A2+A3) >= 22) cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}

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

using ll = long long;
ll modinv(ll a, ll m) {
	assert(m > 0);
	if (m == 1) return 0;
	a %= m;
	if (a < 0) a += m;
	assert(a != 0);
	if (a == 1) return 1;
	return m - modinv(m, a) * m / a;
}

template <int MOD_> struct modnum {
private:
	int v;
public:
	static const int MOD = MOD_;

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int () const { return v; }
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum operator ~ () const {
		modnum res;
		res.v = modinv(v, MOD);
		return res;
	}

	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= (~o);
	}

	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }

	friend modnum pow() {}
};

using num = modnum<998244353>;

template <typename T> T pow(T a, long long b) {
	assert(b >= 0);
	T r = 1; while (b) { if (b & 1) r *= a; b >>= 1; a *= a; } return r;
}

vector<num> fact;
vector<num> ifact;

void init(){
	fact = {1};
	for(int i = 1; i < 11000000; i++) fact.push_back(i * fact[i-1]);
	ifact.resize(fact.size());
	ifact.back() = 1 / fact.back();
	for(int i = (int)ifact.size() - 1; i > 0; i--) ifact[i-1] = i * ifact[i];
}

num ncr(int n, int k){
	if(k < 0 || k > n) return 0;
	return fact[n] * ifact[k] * ifact[n-k];
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	init();
	num ans = 1;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) ans *= 3;
	vector<num> p2(n+1, 0);
	for(int i = 0; i < n/2; i++){
		ans -= 2 * pow(num(2), i) * ncr(n, i);
	}
	cout << (int)ans << '\n';
}

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

ll N;

const ll mod = 1000000007;

int main(){
	cin >> N;
	vector<ll> A(N);
	
	for ( int i = 0; i < N; i++ ){
		cin >> A[i];
	}
	
	ll result = 0;
	
	// 各ビットを独立に計算する
	for ( ll b = 0; b < 60; b++ ){
		ll bb = (ll)1 << b;
		
		// 立っているビットの累積和
		vector<int> bitacc(N+1);
		int acc = 0;
		for ( int i = 0; i < N; i++ ){
			bitacc[i] = acc;
			if ( A[i] & bb )
				acc++;
		}
		bitacc[N] = acc;
		
		// ΣΣ(ai^aj) を求める
		ll sum = 0;
		for ( int i = 0; i < N-1; i++ ){
			if ( A[i] & bb ){
				sum += (N-1-i) - (bitacc[N] - bitacc[i+1]);
			}
			else {
				sum += bitacc[N] - bitacc[i+1];
			}
		}
		
		//cout << b << " " << bb << " " << sum << endl;
		result += (bb%mod) * (sum%mod);
		result %= mod;
	}
	
	cout << result << endl;
	
	return 0;
}



Measured memory_bytes: 3820
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		int neL = scan.nextInt();
		int neS = scan.nextInt();
		int hour = scan.nextInt();
		int minute = scan.nextInt();

		System.out.println(Math.sqrt(Math.pow(neL, 2) + Math.pow(neS, 2) - 2 * neS * neL * Math.cos(Math.toRadians(Math.abs(minute*6 - (30 * hour + 0.5 * minute))))));
		scan.close();
	}
}

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

int main() 
{ 
   char n[1001];
  while(1){ 
   cin>>n;
   int sum=0;
   for(int i=0;i<strlen(n);i++){
    sum+=(n[i] -'0');
   }
   
   if(sum==0) exit(0);
    
    cout<<sum<<"\n";
  }
    

return 0; 
} 




Measured memory_bytes: 3088
L = []
A = ["S","H","C","D"]
for i in A :
    for j in range(1,14) :
        L.append("{} {}".format(i,j))

N = int(input())
for i in range(N) :
    l = input()
    L.remove(l)
for i in range(len(L)) :
    print(L[i])



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

using namespace std;

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

long long n;

bool isok(long long x) {
    bool seven=false, five=false, three=false;
    while(x > 0) {
        if(x%10 == 7) seven = true;
        else if(x%10 == 5) five = true;
        else if(x%10 == 3) three = true;
        x /= 10;
    }
    return seven && five && three;
}

long long dfs(long long x) {
    if(x > n) return 0;
    int ret = isok(x)? 1:0;
    ret += dfs(10*x+3);
    ret += dfs(10*x+5);
    ret += dfs(10*x+7);
    return ret;
}

int main() {
	cin >> n;
	cout << dfs(0) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) (v.begin(),v.end())
#define ff first
#define ss second
const ll maxn=1e6+10;
const ll mod=1e9+7;
 
 
 
 
int main() {
  	fast;
  	ll n,w;
  	cin>>n>>w;
  	ll we[n],co[n];
  	for(ll i=0;i<n;i++){
  		cin>>we[i]>>co[i];
	  }
  		
	// dp[x]-> represents max value we can get at weight value x; to find : dp[w].
	vector<ll> dp(w+1,0);
	
	for(ll i=0;i<n;++i){
		for(ll j=w;j>=we[i];--j){
			dp[j]=max(dp[j],dp[j-we[i]]+co[i]);
		}
	}
	cout<<dp[w];
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//https://www.youtube.com/watch?v=RDaGj_ztNz4&feature=youtu.be

//-----CODE------//

int dfs(int v,int c,vector<vector<int> > & GRAPH,vector<int> & color)
{

  color[v] = c;
  // DEBUG(color);
  for (auto &&u : GRAPH[v])
  {
    if(color[u] == c)
    {
      return false;
    }
    
    if(color[u] ==0 && !dfs(u,-1*c,GRAPH,color))
    {
    return false;
    }
  }
  return true;
  
}
void solve(void)
{
  int n,m;
  cin>>n>>m;
  vector<vector<int> > GRAPH (n);
  for (int i = 0; i < m; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    GRAPH[A].push_back(B);
    GRAPH[B].push_back(A);
  }
  int b = 0,w = 0;
  vector<int> color(n,0);
  if(dfs(0,1,GRAPH,color))
  {
    for (int i = 0; i < n; i++)
    {
      if(color[i] == 1)
      {
        b++;
      }
      else if(color[i] == -1)
      {
        w++;
      }
    }
    cout<<b*w - m <<endl;
    
  }
  else
  {
    cout<<n*(n-1)/2 - m<<endl;
  }
  


  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 10500
import java.awt.AlphaComposite;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		char[][] matA = new char[n][n];
		char[][] matAEx = new char[2*n][2*n];
		
		int alphabet[] = new int[26];
		for(int i = 0; i < n; i++){
			String tmpArray = br.readLine();
			
			for(int j = 0; j < n; j++){
				matA[i][j] = tmpArray.charAt(j);
				matAEx[i][j] = matA[i][j];
				matAEx[i+n][j] = matA[i][j];
				matAEx[i][j+n] = matA[i][j];
				matAEx[i+n][j+n] = matA[i][j];
				
				alphabet[matA[i][j] - 'a']++;
			}
		}
		
		char[][] matB = new char[n][n];
		
		//配列の転地コピー
		
		long result = 0;
		for(int a = 0; a < 1; a++){
			for(int b = 0; b < n; b++){
//				System.out.println("a = "+a+" b = "+b);
				
				//対角成分集計
				int[] alphaClone = Arrays.copyOf(alphabet, 26);
				
				for(int i = 0; i < n; i++){
					char tmpC = matAEx[i + a][i + b];
					
					alphaClone[tmpC - 'a']--;
				}
				
				boolean isOdd = false;
				for(int i = 0; i < 26; i++){
					if(alphaClone[i] % 2 == 1){
						isOdd = true;
						break;
					}
				}
				
				if(isOdd){
					continue;
				}
				
				boolean good = true;
				for(int i = 0; i < n; i++){
					for(int j = i + 1; j < n; j++){	
						int A = i - a + n;
//						if(A < 0){
//							A += n;
//						}
						
						int B = j - b + n;
//						if(B < 0){
//							B += n;
//						}
//						System.out.println(i+" "+j+" "+A+" "+B);
//						matB[i][j] = matA[A][B];
//						matB[j][i] = matA[B][A];
						
//						if(matB[i][j] != matB[j][i]){
						if(matAEx[i + a][j + b] != matAEx[j + a][i + b]){
							good = false;
							break;
						}
					}
					
					if(!good){
						break;
					}
				}
				
				if(good){
					result+=n;
				}
			}
		}
		
		System.out.println(result);
	}
}



Measured memory_bytes: 27576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
double judge(ll p, ll q, ll d) {
    return ((p*p + q*q) <= d*d);
}
int main() {
    ll n, d; cin >> n >> d;
    int ans = 0;
    rep(i, n) {
        ll x, y; cin >> x >> y;
        if (judge(x, y, d)) ans++;
    }
    cout << ans << endl;
}


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

int main()
{
    // 整数の入力
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a * c, a * d), max(b * c, b * d));
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <set>
#define ll long long
using namespace std;




int main() {
    int n;
    cin>>n;
    int temp = n;
    int s = 0;
    while(n){
        int b = n%10;
        s+=b;
        n/=10;
    }
    if(temp%s==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (k, n) = readLine()!!.split(" ").map{ it.toInt() }
    var a = readLine()!!.split(" ").map{ it.toInt() }
    var diff_max = k - a[n-1] + a[0]
    var old = a[0]
    for (ai in a.slice(1..n-1)) {
        diff_max = Math.max(diff_max, ai - old)
        old = ai
    }
    println(k-diff_max)
}


Measured memory_bytes: 82820
/*
わからん.
np.ndarrayみたいに全要素一斉足し算とか出来たらいいのだが
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  // 10^18 くらいまでいける

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

const ll INF = 1LL << 60;

int main(){
  /*
  * n: 人数
  * k: 初期の1人の持ちポイント (全員一緒)
  * q: Q回正解が出る
  */
  ll n, k, q;
  cin >> n >> k >> q;

  // vector<ll> members(n, k);
  ll members[100100];
  rep(i, n) members[i] = 0;

  ll ansNo;
  rep(i, q){
    cin >> ansNo;
    ansNo--;  // C++の配列はidx0スタートなので
    members[ansNo]++;
  }

  rep(i, n){
    if (members[i] > (q-k))
      Yn(true);
    else
      Yn(false);
  }

  return 0;
}

Measured memory_bytes: 1408
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pob pop_back
#define forr(x) for(ll i = 0; i < x; i++)
#define forrr(x) for(ll j = 0; j < x; j++)
#define F first
#define S second
#define endl '\n'
#define pi pair<ll, ll>
#define mp make_pair
const ll N = 105, inf = 1e18 + 5;

ll n;
ll W;
ll w[N];
ll v[N];
ll dp[N][(ll)1e5 + 5];
ll ans;

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> W;
	forr(n)
		cin >> w[i] >> v[i];
	forr(n)
		forrr(1e5 + 5)
			dp[i][j] = inf;
	for(ll i = 1; i <= v[0]; i++)
	{
		dp[0][i] = w[0];
		if(w[0] <= W)
			ans = max(ans, i);
	}
	dp[0][0] = 0;

	for(ll i = 1; i < n; i++)
	{
		for(ll j = 0; j < 1e5 + 5; j++)
		{
			if(j == 0)
				dp[i][j] = 0;
			else if(j > 0&& j >= v[i])
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
			else if(j > 0)
				dp[i][j] = dp[i - 1][j];
			if(dp[i][j] <= W)
				ans = max(ans, j);
		}
	}
	cout << ans;
	return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};


/*
    ref: ??????????§??????¨??£??°(?????¨) https://tomcatowl.github.io/blog/2016/12/12/ds-and-alg-1/
*/

/*
struct Monoid {
    using T = _underlying_set_;                                 // ??¢??????????????°????????????
    T operator() (const T &a, const T &b) { return _a_op_b_; }  // ???????????? 
    static constexpr T identity() { return _identity_element; } // ?????????
};
*/

template<class Monoid>
class SegmentTree {
private:
    using T = typename Monoid::T;
    Monoid op;
    const int n;
    vector<T> dat;
    void prop_to(int i) { dat[i] = op(dat[2*i], dat[2*i+1]); }

public:
    SegmentTree(int _n) : n(_n), dat(2*_n, op.identity()) {}
    SegmentTree(const vector<T> &v) : n(v.size()), dat(2*n)
    {
        copy(v.begin(), v.end(), dat.begin() + n);
        for (int i=n-1; i>0; i--) prop_to(i);
    }

    void update(int i, const T &x)
    {
        dat[i += n] = x;
        while (i >>= 1) prop_to(i);
    }

    T get(int i) { return dat[i + n]; }

    T accumulate(int l, int r) // [l, r)
    {
        T acc_l = op.identity(), acc_r = op.identity();
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) acc_l = op(acc_l, dat[l++]);
            if (r & 1) acc_r = op(dat[r-1], acc_r);
        }
        return op(acc_l, acc_r);
    }
};

struct RMQ {
    using T = int;
    T operator() (const T &a, const T &b) { return min(a, b); }
    static constexpr T identity() { return (1LL<<31) - 1; }
};

int main()
{
    ios::sync_with_stdio(false);
    
    int N, Q;
    cin >> N >> Q;

    SegmentTree<RMQ> seg_tree(N);
    rep(q, Q) {
        int C, X, Y;
        cin >> C >> X >> Y;

        if (C == 0) {
            seg_tree.update(X, Y);
        } else {
            cout << seg_tree.accumulate(X, Y+1) << endl;
        }
    }
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long ,long long>>vi;
long long n , w ;
long long mem[105][100005];
bool vis[105][100005];
long long sol(int indx ,int ca){
	if(indx==n)
		return 0;

	if(vis[indx][ca])return mem[indx][ca];
	mem[indx][ca] = 0;
	vis[indx][ca] = true;
	long long fch = sol(indx + 1 , ca);
	long long sch = 0;
	if(ca - vi[indx].first >=0)
		sch = sol(indx + 1 , ca -vi[indx].first ) + vi[indx].second;
	return mem[indx][ca] = max(fch , sch);
}
int main()
{
		cin>>n>>w;
		vi.resize(n);
		for(int i = 0; i < n ;i++){
			long long x , y;
			cin>>vi[i].first>>vi[i].second;
		}
		cout<<sol(0,w);
	return 0;
}



Measured memory_bytes: 89856
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    rep(i, N){
        cin >> t[i];
    }
    int ans = T;
    rep(i, N-1){
        if(t[i] + T < t[i+1]){
            ans += T;
        }else{
            ans += (t[i+1] - t[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std; 
int main()
{
int a,b,c,d,e,f,g,h,i,N;
cin >> N ;
if(N == 1){printf("Yes");}
else{
a = N%10;
b = (N%100-N%10)/10;
c = (N%1000-N%100)/100;
d = (N%10000-N%1000)/1000;
e = (N%100000-N%10000)/10000;
f = (N%1000000-N%100000)/100000;
g = (N%10000000-N%1000000)/1000000;
h = (N%100000000-N%10000000)/10000000;
i = (N%1000000000-N%100000000)/100000000;
if(N%(a+b+c+d+e+f+g+h+i)==0){printf("Yes");}
else{printf("No");}
}
}

Measured memory_bytes: 256
MOD = 10**9+7
k = int(input())
s = input()
n = len(s)
 
 
U = n+k
fact = [0]*(U+1)
fact[0] = 1
for i in range(1, U+1):
    fact[i] = fact[i-1]*i % MOD
 
 
invfact = [0]*(U+1)
invfact[U] = pow(fact[U], MOD-2, MOD)
for i in reversed(range(U)):
    invfact[i] = invfact[i+1]*(i+1) % MOD
 
 
def nCr(n, r):
    if r < 0 or n < r:
        return 0
    return fact[n]*invfact[r]*invfact[n-r]
 
 
ans = 0
for x in range(k+1):
    ans += pow(26, x, MOD)*nCr(n+k-x-1, n-1)*pow(25, k-x, MOD)
    ans %= MOD
print(ans)

Measured memory_bytes: 120984
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<lld,lld> pi;
#define F first
#define S second
#define MOD 1000000000007
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (lld i = a; i < b; i++)
lld r,j,l,x,y,m,b,n,s,f,q,i,z,p,c,k,d,t,u,e,g;string s1,s2,s3,s4;
vi v[100001];lld visited[1000001],parent[1000001],dis[1000001];
void dijkstra()
{
  priority_queue<pi>q;
  q.push({0,1});
  dis[1]=0;
  while(!q.empty())
  {
    k=q.top().second;q.pop();
    if(visited[k])
        continue;
    visited[k]=1;
    for(auto x:v[k])
    {
      p=x,d=1;
      if(dis[p]>dis[k]+d)
      {
        dis[p]=dis[k]+d;
        q.push({-dis[p],p});
      }
    }
  }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin>>n>>m;char ch;
  lld a[n+2][m+2];
  rep(i,0,n+2)
  {
    rep(j,0,m+2)
    {
      if(i==0||i==n+1||j==0||j==m+1)
        a[i][j]=-1;
      else
      {
        cin>>ch;
        if(ch=='.')
          a[i][j]=1;
        else
          a[i][j]=-1;
      }
    }
  }
  rep(i,0,n+2)
  {
    rep(j,0,m+2)
    {
      lld curr,left,right,up,down;
      if(a[i][j]==1)
      {
        curr=(m*(i-1))+j;left=(m*(i-1))+j-1;right=(m*(i-1))+j+1;up=(m*(i-2))+j,down=(m*i)+j;
        if(a[i-1][j]==1)
          v[curr].PB(up);
        if(a[i+1][j]==1)
          v[curr].PB(down);
        if(a[i][j+1]==1)
          v[curr].PB(right);
        if(a[i][j-1]==1)
          v[curr].PB(left);
      }
    }
  }
  rep(i,0,1000001)
    dis[i]=MOD;
  dijkstra();
  /*parent[1]=-1;p=0;x=(n*m);
  while(parent[x]!=-1)
  {
    p++;//cout<<x<<endl;
    x=parent[x];
  }q=0;cout<<p;*/
  r=0;

  if(dis[n*m]==MOD)
  {
    cout<<-1;return 0;
  }
  rep(i,0,n+2)
  {
    rep(j,0,m+2)
    {
      if(a[i][j]==1)
        r++;
    }
  }
  cout<<r-dis[n*m]-1;
} 

Measured memory_bytes: 13952
n, m = list(map(int, input().split()))
goods = list(map(int, input().split()))
flag = 1
limit = float(sum(goods)) / (4 * m)
for i in range(n - 1):
  for j in range(n - i - 1):
    if goods[j] <= goods[j+1]:
      tmp = goods[j]
      goods[j] = goods[j+1]
      goods[j+1] = tmp
for i in range(1, m):
  if goods[i] < limit:
    flag = 0
    break
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9220
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>


int main(){
	int n;
	int ans;
	std::cin>>n;

	std::vector<int> wList(n);

	for(int i=0; i<n; i++)
		std::cin>>wList[i];

	int sum1=0;
	int sum2=0;

	for(int i=0; i<n; i++)
		sum1+= wList[i];

	ans= sum1;

	for(int i=0; i<n; i++){
		sum2+=wList[i];
		sum1-=wList[i];
		ans= std::min(ans, std::abs(sum2-sum1));
	}

	std::cout<<ans<<std::endl;

	return 0;
	
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, A[int(2e5+5)];
ll ans = 0;

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  if (A[0] > 0){
    cout << -1 << endl; return 0;
  }

  for (int i = 1; i < N; i++){
    if (A[i] == 0) continue;
    if (A[i - 1] + 1 == A[i]){
      ans++; continue;
    }
    if (A[i-1] >= A[i]){
      ans += A[i]; continue;
    }
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5200
x = int(input())
num = []
for i in range(50):
    for j in range(2,10):
        if i**j <=1000 and i**j not in num:
                num.append(i**j)
        elif i**j >1000:
            break
num = sorted(num)

index = [i for i in range(len(num)) if num[i]<=x][-1]
print(num[index])

Measured memory_bytes: 3060
class Card
  include Comparable
  def initialize(val)
    @val = val
  end

  def mark
    @val[0]
  end

  def number
    @val[1].to_i
  end

  def <=>(other)
    number <=> other.number
  end

  def to_s
    @val.dup
  end
end

def bubble_sort(arr)
  n = arr.size - 1
  0.upto(n) do |i|
    n.downto(i + 1) do |j|
      arr[j-1], arr[j] = arr[j], arr[j-1] if arr[j] < arr[j-1]
    end
  end
end

def selection_sort(arr)
  n = arr.size - 1
  0.upto(n) do |i|
    mini_j = i
    i.upto(n) do |j|
      mini_j = j if arr[j] < arr[mini_j]
    end
    arr[i], arr[mini_j] = arr[mini_j], arr[i]
  end
end

def same_order?(orig_order, cards)
  order = Hash.new {|h, k| h[k] = ''}
  cards.each{|c| order[c.number] << c.mark }
  orig_order.map{|k, v| order[k] == v}.all?
end


n = gets.to_i
cards = gets.split.map{|v| Card.new(v)}
order = Hash.new {|h, k| h[k] = ''}
cards.each{|c| order[c.number] << c.mark }

bubble = cards.dup
selection = cards.dup

bubble_sort(bubble)
puts bubble.join("\s")
puts same_order?(order, bubble) ? 'Stable' : 'Not stable'

selection_sort(selection)
puts selection.join("\s")
puts same_order?(order, selection) ? 'Stable' : 'Not stable'

Measured memory_bytes: 8824
program ABC153B
    implicit none
    integer(8)::H,N,i
    integer(8),allocatable,dimension(:)::A
    read(5,*)H,N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)

    if(sum(A)>=H)then
        print'(A)',"Yes"
    else
        print'(A)',"No"
    end if
end program ABC153B

Measured memory_bytes: 1536
INF = 1001001001

N = int(input())
X = list(map(int, input().split()))

ans = INF
for i in range(1, 101):
    stamina = 0
    for j in range(1, N+1):
        stamina += (X[j-1] - i)**2
    ans = min(ans, stamina)

print(ans)


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

void solve()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == 'R')
            ans++;
    }
    if (ans == 0 || ans == 1 || ans == 3)
    {
        cout << ans << endl;
        return;
    }
    if (s[1] == 'R')
    {
        cout << 2 << endl;
        return;
    }
    cout << 1 << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    long long t = 1;
    // cin >> t;
    for (long long i = 1; i <= t; i++)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=100005;
int h[MAX_N];
int dp[MAX_N]; 
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

void solve(){

   int x, y;
   cin >> x >> y;

   if (x <= y){
      cout<<"unsafe";      
   }
   else{
      cout<<"safe";
   }

}

int32_t main(){_
   
   int t = 1;
   //cin >> t;

   while(t--){
     solve();
     cout << endl;
   }
   

   return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int a,b,t;
  cin>>a>>b>>t;
  cout << b * (int)((t+0.5) / a) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000") 
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n;
long long ans=1;
inline long long gcd(long long x,long long y){
	if(!y)return x;
	return gcd(y,x%y);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		long long t;
		cin>>t;
		ans=ans/gcd(ans,t)*t;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    ans = 0
    for i in range(N):
        if A[i] < B[i]:
            B[i] -= A[i]
            ans += A[i]
            if A[i+1] < B[i]:
                ans += A[i+1]
                A[i+1] = 0
            else:
                ans += B[i]
                A[i+1] -= B[i]
        else:
            ans += B[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        n--;
        k--;
        System.out.println((n+k-1)/k);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T& a, T b) { if (a < b)a = b; }
template<class T>void chmin(T& a, T b) { if (a > b)a = b; }
constexpr int INF = 1000000000000000000;
constexpr int mod = 1000000007;
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int kaijo[2000010];
struct edge { int to, cost; };
int gcd(int a, int b) {
    if (b == 0)return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
bool prime(int a) {
    if (a == 1)return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0)return false;
    }
    return true;
}
void init_fact() {
    kaijo[0] = 1;
    for (int i = 1; i <= 2000000; i++) {
        kaijo[i] = kaijo[i - 1] * i;
        kaijo[i] %= mod;
    }
}
int modpow(int a, int b) {
    if (b == 0)return 1;
    if (b % 2)return modpow(a, b - 1) * a % mod;
    int memo = modpow(a, b / 2);
    return memo * memo % mod;
}
int comb(int a, int b) {
    if (!kaijo[0])init_fact();
    return kaijo[a] * modpow(kaijo[a - b], mod - 2) % mod * modpow(kaijo[b], mod - 2) % mod;
}
int inv(int x) {
    x = modpow(x, mod - 2);
    return x;
}
bool kosa(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy) {
    double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
    double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
    double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
    double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
    return tc * td < 0 && ta * tb < 0;
}
int n, a[2001], sum;
bitset<4000001>dp;
signed main() {
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    dp[0] = 1;
    rep(i, n) {
        dp |= (dp << a[i]);
    }
    rep(i, 4000001) {
        if (sum <= i * 2 && dp[i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
a = []

for i in range(N):
  x,y = input().split()
  a.append([x,y])

ans = 0
for i in a:
  if i[1] == "JPY":
    ans += int(i[0])
  elif i[1] == "BTC":
    ans += float(i[0]) * 380000

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
signed main(){
    string s , t;
    cin >> s >> t;
    bool f = false;
    
    for(int i = s.size()-t.size() ;i >= 0 && f == false ;i-- ){
        f = true;
        for(int j=0 ;j<t.size() ;j++ ){
            if(t[j] != s[i+j] && s[i+j] != '?'){
                f = false;
            }
        }
        if(f == true){
            for(int j=0 ;j<t.size() ;j++ ){
                s[i+j] = t[j];
            }
        }
    }
    
    if(f){
        for(int i=0 ;i<s.size() ;i++ ){
            if(s[i] == '?'){
                cout << 'a';
            } else {
                cout<< s[i];
            }
        } 
        cout << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }
    
    return(0);
}

Measured memory_bytes: 256
class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.bisect_k = 1 << (N.bit_length() - 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __str__(self):
        return "BIT: [{}]".format(
            ", ".join(str(self.sum(i + 1) - self.sum(i))
                      for i in range(self.size))
        )

    def bisect(self, w):
        bit, N = self.tree, self.size
        i = 0
        k = self.bisect_k
        while k > 0:
            if i + k <= N and bit[i + k] < w:
                w -= bit[i + k]
                i += k
            k //= 2
        return i + 1

N, *A = map(int, open(0).read().split())

memo = {a: i for i, a in enumerate(sorted(set(A)), 1)}
B = [memo[a] for a in A]
M = len(memo) + 10

bit = BIT(M)
for b in B:
    s = bit.sum(b - 1)
    if s > 0:
        i = bit.bisect(s)
        bit.add(i, -1)
    bit.add(b, 1)

print(bit.sum(M))


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

using namespace std;

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;

  bool ok = true;
  for (int i = 0; i < a; i++) {
    ok &= isdigit(s[i]);
  }
  ok &= s[a] == '-';
  for (int i = a + 1; i < s.size(); i++) {
    ok &= isdigit(s[i]);
  }
  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 384
n,a,b=map(int,input().split())
l=[int(input())for i in range(n)]
a-=b
def  enough(x):
    return sum(max((h-b*x+a-1)//a,0) for h in l)<=x
#(ng,ok]type
ok,ng=10**9,-1
# [ok,ng)type->eraseng,ok=ok,ng
eps=10**(-10)
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if enough(mid):ok=mid
    else:ng=mid
print(ok)

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

main(){
  int n,a,b;
  cin>>n>>a>>b;
  vector<int> x(n);
  rep(i,n){
    cin>>x[i];
  }
  vector<int> div(n-1);
  rep(i,n-1){
    div[i]=x[i+1]-x[i];
  }
  ll ans=0;
  rep(i,n-1){
    ans+=min(div[i]*a,b);
  }
  cout<<ans<<endl;
}


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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int ansl = N;
  int term = 0;
  for (int i=1; i<N; i++) {
    if (S[i-1] != S[i]) {
      term = max(i,N-i);
      ansl = min(ansl,term);
    }
  }
  int ansr = N;
  term = 0;
  for (int i=N-1; i>0; i--) {
    if (S[i-1] != S[i]) {
      term = max(i,N-i);
      ansr = min(ansr,term);
    }
  }
  cout << max(ansl,ansr) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

bool f(ll k, ll a, ll b) {
  ll ab = a * b;

  return ((k + 1) / 2) * (k / 2 + 1) < ab;
}

int main() {
  int q;
  cin >> q;
  REP(i, q) {
    ll a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 2LL * a - 2LL << endl;
      continue;
    }
    if (a > b)
      swap(a, b);
    ll ok = 0;
    ll ng = 2 * b;
    while (abs(ok - ng) > 1) {
      ll mid = (ok + ng) / 2;
      if (f(mid, a, b)) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    cout << ok - 1 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<malloc.h>
using namespace std;

typedef struct node{
	string name;
	int time;
}Node;

int main()
{
	int n, q;
	cin>>n>>q;
	queue<Node> qu;
	Node tmp;
	
	for(int i = 0; i < n; i++)
	{
		cin>>tmp.name>>tmp.time;
		qu.push(tmp);
	}
	int timer = 0;
	while(!qu.empty())
	{
		if(qu.front().time > q)
		{
			timer += q;
			qu.front().time -= q;
			Node tmp = qu.front();
			qu.pop();
			qu.push(tmp);
		}
		else if(qu.front().time == q)
		{
			timer += q;
			cout<<qu.front().name<<" "<<timer<<endl;
			qu.pop();
		}
		else
		{
			timer += qu.front().time;
			cout<<qu.front().name<<" "<<timer<<endl;
			qu.pop();
		}
	}
	return 0;
}


Measured memory_bytes: 6288
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    /*ll n,a,b;
    cin >> n >> a >> b;
    ll sum = a+b ;
    ll re = n/sum;
    ll ans= re * a;
   // ll amari = min(n-re*sum,a);  
   ll amari;
   if(n-re*sum > a) amari = a;
   else amari = n-sum*re;
    ans+=amari;
    cout << ans << endl;
    return 0;*/



    ll n,a,b;
    cin >> n >> a >> b;
    ll sum = a+b ;
    ll re = n/sum;
    ll ans=0;
    ll amari;
    if(n-sum*re>=a) amari = a;
    else amari = n- sum*re;
    //ans = re*a + amari;
    ans = re*a;
    ans += amari;

    cout << ans << endl;
    return 0;




}





Measured memory_bytes: 256
//
//  main.cpp
//  ITP1_5-C
//
//  Created by Saicj on 2015/07/14.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, const char * argv[])
{

    int H,W;
    
    while (true) {
        cin >> H >> W;
        
        if (H == 0 && W == 0){
            break;
        }
        
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                
                if (i == 0 || i % 2 == 0) {
                    // ??¶??°???
                    if ((i + j) == 0 || (i+j)%2 == 0) {
                        printf("#");
                    }else{
                        printf(".");
                    }
                }else if(i % 2 != 0){
                    //?\???°???
                    if ((i + j) == 0 || (i+j)%2 == 0) {
                        printf("#");
                    }else{
                        printf(".");
                    }

                }
            }
            
            printf("\n");
        }

                    printf("\n");
        
    }
    
    return 0;
}

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

using namespace std;
#define REP(i, n)  for(int i=0;i<(int)(n);++i)
#define FOR(i, b, n)  for(int i=b;i<(n);++i)
#define ALL(c) (c).begin(),(c).end()
#define PB(c) push_back(c)
#define SS size()
#define ST first
#define ND second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef set<int> si;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }
template<typename T> void sout(T &w) {
  for (auto x : w) cout << x << ", ";
  cout << endl;
}


int main() {
  ios::sync_with_stdio(0);
  int a, b, c; cin >> a >> b >> c;
  int max_move = max(0, a-b);
  int move = min(max_move, c);
  int rest = c - move;
  cout << rest << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  if (a == 7 && b == 5 && c == 5) {
    printf("YES\n");
  } else if (a == 5 && b == 7 && c == 5) {
    printf("YES\n");
  } else if (a == 5 && b == 5 && c == 7) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 128