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

using State = string::const_iterator;
using S = set<int>;

S var[5];
S U;

S formula(State &itr);
S variable(State &itr);
S factor(State &itr);

S unite(S a, S b){
    for(auto &x : b){
        a.insert(x);
    }
    return a;
}

S intersect(S a, S b){
    S res;
    for(auto &x : b){
        if(a.count(x))
        res.insert(x);
    }
    return res;
}

S diff(S a, S b){
    S res;
    for(auto &x : a){
        if(b.count(x)==0){
            res.insert(x);
        }
    }
    return res;
}

S sym_diff(S a, S b){
    return unite(diff(a,b),diff(b,a));
}

S comp(S a){
    S res;
    for(auto &x : U){
        if(a.count(x)==0){
            res.insert(x);
        }
    }
    return res;
}

S formula(State &itr){
    S res = factor(itr);
    while(*itr){
        if(*itr == 'u'){
            itr++;
            res = unite(res,factor(itr));
        }else if(*itr == 'i'){
            itr++;
            res = intersect(res, factor(itr));
        }else if(*itr == 'd'){
            itr++;
            res = diff(res, factor(itr));
        }else if(*itr == 's'){
            itr++;
            res = sym_diff(res, factor(itr));
        }else{
            break;
        }
    }
    return res;
}

S factor(State &itr){
    S res;
    if(*itr == '('){
        itr++;
        res = formula(itr);
        itr++; // '('
    }else if(*itr == 'c'){
        itr++;
        res = comp(factor(itr));
    }else if(isupper(*itr)){
        res = variable(itr);
    }else{
        // error
    }
    return res;
}

S variable(State &itr){
    S res;
    if(*itr == 'U'){
        res = U;
    }else if(isalpha(*itr)){
        res = var[*itr-'A'];
    }else{
        // error
    }
    itr++;
    return res;
}

int solve(){
    for(int i=0;i<5;i++){
        var[i].clear();
    }
    U.clear();
    char c;
    int n;
    while(cin >> c){
        cin >> n;
        if(c != 'R'){
            int idx = c-'A';
            for(int i=0;i<n;i++){
                int x;
                cin >> x;
                var[idx].insert(x);
                U.insert(x);
            }
        }else{
            string s;
            cin >> s;
            State begin = s.begin();
            S ans = formula(begin);
            if(!ans.empty()){
                for(auto itr=ans.begin();itr!=ans.end();++itr){
                    if(itr!=ans.begin()) cout << " ";
                    cout << *itr;
                }
                cout << endl;
            }else{
                cout << "NULL" << endl;
            }
            return 0;
        }
    }
    return 1;
}

int main(){
    while(solve()==0);
    return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int f;
char c[100010];
int main(){
    cin >> c;
    int l = strlen(c);
    for(int i=0;i<l;i++)
    {
        if(c[i]=='p')
            if(i%2==0) f--;
        if(c[i]=='g')
            if(i%2==1) f++;
    }
    cout<<f;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 100005;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX]; //重み付き有効グラフの隣接リスト表現

void dijkstra(){
    priority_queue<pair<int, int> > PQ;
    int color[MAX];
    int d[MAX];
    int d2[MAX];
    for(int i=0; i<n; i++){
        d[i] = INFTY;
        d2[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(make_pair(0,0));
    color[0] = GRAY;

    while( !PQ.empty() ){
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;

        color[u] = BLACK;

        //最小値を取り出し、それが最短でなければ無視
        if( d[u] < f.first * (-1) ) continue;

        for(int j=0; j<adj[u].size(); j++){
            int v = adj[u][j].first;
            if(color[v] == BLACK) continue;
            if(d[v] > d[u] + adj[u][j].second){
                d[v] = d[u] + adj[u][j].second;
                d2[v] = u;
                //priority_queueはデフォルトでは大きい値を優先するため‐１をかける
                PQ.push(make_pair(d[v]*(-1), v));
                color[v] = GRAY;
            }
        }
    }

    cout << "Yes" << endl;
    for(int i=1; i<n; i++){
        cout << d2[i] + 1 << endl;
    }
}

int main(){
    cin >> n;

    int m; cin >> m;
    for(int i=0; i<m; i++){
        int a, b; cin >> a >> b;
        adj[a-1].push_back(make_pair(b-1,1));
        adj[b-1].push_back(make_pair(a-1,1));
    }

    dijkstra();

    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

struct mint {
  ll x;
  mint(ll x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const {return mint(-x);}
  mint& operator+=(const mint a) {
    if((x+=a.x)>=mod) x-=mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    // if((x+=mod-a.x)>=mod) x-=mod;
    if((x-=a.x)<0) x+=mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    x = (x*a.x)%mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll e) const {
    if(!e) return 1;
    mint a = pow(e>>1);
    a *= a;
    if(e&1) a *= *this;
    return a;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this)*=a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct Sieve {
  vector<int> t;
  Sieve(int n) : t(n+1) {
    t[0] = t[1] = -1;
    for(int i=2; i<=n; i++) {
      if(t[i]) continue;
      t[i] = i;
      for(ll j=(ll)i*i; j<=n; j+=i) {
        if(!t[j]) t[j] = i;
      }
    }
  }
  void print() {
    rep(i,t.size()) printf("%d ", t[i]);
    printf("\n");
  }
  map<int,int> primes(int n) {
    map<int,int> ps;
    while(t[n]!=-1) {
      ps[t[n]]++;
      n /= t[n];
    }
    return ps;
  }
};

int main(int argc, char const* argv[])
{
  int n;
  cin>>n;
  Sieve sieve((int)1e+6);
  vector<int> as(n);
  rep(i,n) cin>>as[i];
  map<int,int> lcm_map;
  rep(i,n) {
    map<int,int> ps = sieve.primes(as[i]);
    for(auto e: ps) if(lcm_map[e.first]<e.second) lcm_map[e.first] = e.second;
    // for(auto e2: lcm_map) printf("%d: p:%d, cnt: %d\n", i, e2.first, e2.second); // debug
  }

  mint lcm = 1;
  for(auto e: lcm_map) {
    rep(p,e.second) lcm *= e.first;
  }

  mint ans = 0;
  rep(i,n) {
    ans += lcm / as[i];
  }

  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 4608
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <functional>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, n, m, a, ans = 0;
  vector< pair<ll, ll> > vec;
  scanf("%lld", &n);
  set<ll> s;
  for(i = 0; i < n; ++i) {
    s.insert(i);
    scanf("%lld", &m);
    for(j = 0; j < m; ++j) {
      scanf("%lld", &a);
      vec.push_back(make_pair(a, i));
    }
  }
  sort(vec.begin(), vec.end(), greater< pair<ll, ll> >());
  for(i = 0; i < vec.size() && !s.empty(); ++i) {
    set<ll>::iterator it = s.upper_bound(vec[i].second);
    if(it != s.begin()) {
      ans += vec[i].first;
      it--;
      s.erase(it);
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 22820
n=int(input())
a=list(map(int, input().split()))
b=[]
for i in range(0,n,2):
    b.append(a[n-i-1])
if n%2==0:
    for i in range(0,n,2):
        b.append(a[i])
else:
    for i in range(1,n,2):
        b.append(a[i])

print(" ".join(map(str, b)))



    





Measured memory_bytes: 29604
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int n, h[101], w[101], t;
  int a[101][101];

  while(cin>>n && n){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j)
	cin >> a[i][j];
      h[i] = 0;
      w[i] = 101;
    }

    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j){
	h[i] = max(h[i], a[j][i]);
	w[i] = min(w[i], a[i][j]);
      }

    t = 101;
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
	if(h[i] == w[j] && t > h[i]) t = h[i];

    cout << ((t == 101)? 0 : t) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#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); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    double ans;

    if(n % 2 == 0) ans = (double)(n / 2.0) / n;
    else ans =  (double) ((n / 2) + 1) / n;

    cout<<fixed<<setprecision(6)<<ans<<endl;

    return 0;
    
}

Measured memory_bytes: 3792
import java.util.*;
public class Main {
    public static int[] accumulate (int[] array) {
  	//累積和
    for (int i=1; i<array.length; i++) {
    	array[i] += array[i-1];
    }
        return array;
    }
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt(), Q = sc.nextInt();
	    String S = sc.next();
	    int[] numArray = new int [N];
	    for (int i=0; i<N-1; i++) {
	        numArray[i+1] = (S.substring(i,i+1).equals("A") && S.substring(i+1,i+2).equals("C"))? 1: 0;
	    }
	    int[] sumArray = accumulate(numArray);
	    for (int q=0; q<Q; q++) {
	        int l = sc.nextInt()-1, r = sc.nextInt()-1;
	        int ans = sumArray[r] - sumArray[l];
	        System.out.println(ans);
	    }
	}
}

Measured memory_bytes: 62844
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int t = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int min = Integer.MAX_VALUE;
		int max = 0;
		for (int i = 0; i < n; i++) {
			min = Math.min(min, a[i]);
			max = Math.max(max, a[i] - min);
		}

		TreeSet<Integer> set = new TreeSet<Integer>();
		int count = 0;
		for (int i = 0; i < n; i++) {
			set.add(a[i]);
			if (set.contains(a[i] - max)) {
				count++;
			}
		}
		System.out.println(count);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 31876
n,k = map(int,input().split())
def Base_10_to_n(X, A):
    if (int(X/A)):
        return Base_10_to_n(int(X/A), A)+str(X%A)
    return str(X%A)
ans = Base_10_to_n(n,k)
print(len(ans))

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

int main(){
  int N,M,Q;
  cin>>N>>M>>Q;
  vector<vector<int>> memo(N,vector<int>(N,0));
  vector<vector<int>> a(N,vector<int>(N,0));
  for(int i=0;i<M;++i){
    int L,R;
    cin>>L>>R;
    --L,--R;
    ++a[L][R];
  }

  //2次元累積和
  memo[N-1][0]=a[N-1][0];

  for(int i=N-2;i>=0;--i){
    memo[i][0]=memo[i+1][0]+a[i][0];
  }

  for(int j=1;j<N;++j){
    memo[N-1][j]=memo[N-1][j-1]+a[N-1][j];
  }

  for(int i=N-2;i>=0;--i){
    for(int j=1;j<N;++j){
      memo[i][j]=memo[i+1][j]+memo[i][j-1]-memo[i+1][j-1]+a[i][j];
    }
  }

  for(int i=0;i<Q;++i){
    int p,q;
    cin>>p>>q;
    --p,--q;
    cout<<memo[p][q]<<endl;
  }

}

Measured memory_bytes: 2944
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int p[3];
	REP(i, 3) cin >> p[i];
	sort(p, p + 3);
	cout << p[0] + p[1] << endl;


	return 0;
}


Measured memory_bytes: 256
def main():
    S = input()
    N = len(S)
    now = 0
    ans = [0]*N
    for i in range(N):
        if S[i] == "R":
            now += 1
        else:
            ans[i] += now//2
            if i != 0:
                ans[i-1] += int(0--now//2)
            now = 0

    now = 0
    for i in range(N-1, -1, -1):
        if S[i] == "L":
            now += 1
        else:
            ans[i] += now//2
            if i != N-1:
                ans[i+1] += int(0--now//2)
            now = 0
    print(*ans)


if __name__ == '__main__':
    main()


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

int main(){
  int n, k;
  cin >> n >> k;
  vi a(n+1);
  rep(i,n) cin >> a[i+1];
  vi dp(k+1);
  for(int i=1; i<=k; i++){
    for(int j=1; j<=n; j++){
      if(i-a[j] >= 0 && dp[i-a[j]] == 0) dp[i] = 1;
    }
  }
  if(dp[k] == 1) cout << "First" << endl;
  else cout << "Second" << endl;
}


Measured memory_bytes: 3760
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<ctime>
using namespace std;
const int N=200010;
int n,a[N];
bool judge1(int x,int y,int z) {return ((a[x]>z) &&(a[y]>z));}
bool judge2(int x,int y,int z) {return ((a[x]<=z) && (a[y]<=z));}
bool check(int x)
{
	int i;
	for(i=0;i<n-1;i++)
	{
		if(judge1(n-i,n-i-1,x) || judge1(n+i,n+i+1,x)) return 0;
		if(judge2(n-i,n-i-1,x) || judge2(n+i,n+i+1,x)) return 1;
	}
	return judge2(1,1,x);
}
int main()
{
    int i,j,l,r,mid,ans;
    scanf("%d",&n),l=1,r=2*n-1;
    for(i=1;i<=2*n-1;i++) scanf("%d",&a[i]);
    while(l<=r)
    {
    	mid=l+r>>1;
    	if(check(mid)) ans=mid,r=mid-1;
    	else l=mid+1;
	}
	cout<<ans<<endl;
    return 0;	
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n;
int a, b, c;
int l[8];
int use[8];

int cal() {
	int aa = 0, bb = 0, cc = 0;
	int cnt = 0;
	for(int i=0;i<n;i++){
		if(use[i]==0){
			aa+=l[i];
			cnt++;
		}
		if(use[i]==1){
			bb+=l[i];
			cnt++;
		}
		if(use[i]==2){
			cc+=l[i];
			cnt++;
		}
	}
	if(aa!=0 && bb!=0 && cc!=0){
		return abs(aa-a)+abs(bb-b)+abs(cc-c)+(cnt-3)*10;
	}else{
		return INT_MAX;
	}
}

int dfs(int d) {
	int mpmin = INT_MAX;
	if(d==n){
		return cal();
	}
	for(int i=0;i<4;i++){
		use[d] = i;
		mpmin = min(dfs(d+1), mpmin);
	}
	return mpmin;
}

int main() {
	cin >> n;
	cin >> a >> b >> c;
	for(int i=0;i<n;i++){
		cin >> l[i];
	}
	cout << dfs(0) << endl;
	return 0;
}

Measured memory_bytes: 256
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    int n, m, k, i, j, x=0, y=0, p=-1, h, f=0;
    string s, a;
    cin>>s>>a;
    k=a.size();
    for(i=0; i<s.size()-k+1; i++){
        f=0;
        for(j=0; j<k; j++){
            if(s[i+j]!='?'){
                if(s[i+j]!=a[j]){
                    f=1;
                    break;
                }
            }
        }
        if(f==0)p=i;
    }
    if(p==-1){
        cout<<"UNRESTORABLE"<<endl;
    }
    else{
        for(j=0; j<k; j++){
            s[j+p]=a[j];
        }
        for(i=0; i<s.size(); i++){
            if(s[i]=='?')s[i]='a';
        }
        cout<<s<<endl;
    }

    return 0;
}



Measured memory_bytes: 3548
#include<stdio.h>
int main(void)
{
	int a,b,c,x,i,j,k,cnt;
	scanf("%d%d%d%d",&a,&b,&c,&x);
	cnt=0;
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			for(k=0;k<=c;k++){
				if(i*500+j*100+k*50==x) cnt++;
			}
		}
	}
	printf("%d\n",cnt);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long l;

	std::cin >> l;

	double a, b, c;

	a = l / 3.0;
	b = l / 3.0;
	c = l - a - b;

	std::cout << std::fixed << a * b * c << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    vector<int>a(N);
    REP(i,N)cin>>a[i];
    int cnt=0;
    REP(i,N){
        if(a[i]%2==1)cnt++;
    }
    cnt%=2;
    if(cnt) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

int N;
string S;
unordered_map<string, LL> din;

LL compute(string A, string B) {
    string conc = A+'X'+B;
    if (!din.count(conc)) {
        int a = A.size(), b = B.size();
        char c = S[a+b];
        if (a+b == 2*N) {
            din[conc] = 1;
        } else if (a+b < N) {
            din[conc] = compute(A, B+c) + compute(A+c, B);
        } else {
            LL res = 0;
            if (a < N and c == B[N-1-a]) res += compute(A+c, B);
            if (b < N and c == A[N-1-b]) res += compute(A, B+c);
            din[conc] = res;
        }
    }
    return din[conc];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!
    cin >> N;
    cin >> S;
    cout << compute("", "") << "\n";
}


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

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

    if (1 <= N && N <= 9) {
        cout << N << endl;
        return 0;
    }
    if (N <= 99) {
        cout << 9 << endl;
        return 0;
    }
    if (N <= 999) {
        cout << 9 + N - 99 << endl;
        return 0;
    }
    if (N <= 9999) {
        cout << 909 << endl;
        return 0;
    }
    if (N <= 99999) {
        cout << 909 + N -9999 << endl;
        return 0;
    }
    if (N == 100000) {
        cout << 90909 << endl;
        return 0;
    }
}


Measured memory_bytes: 256
//Apparat : drobucs, aleonov, vit_72
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>

//pragma warning(disable : 4996)
//#pragma GCC optimize("O3")

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back

using namespace std;

typedef long long ll;

const int maxn = (int)2e5 + 13;
const ll INFL = 9223372036854775807;
const int INF = 2147483647;
const ll MOD = (int)1e9 + 7, MOD2 = 1e9 + 21;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;
const long double pi = 3.1415926535897932;



int main() {
	drobucs;
	
	ll n;
	cin >> n;
	cout << n * n * n << "\n";

	return 0;
}

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

int n, x, y, dist[2020], k[2020];

void bfs(int s)
{
    //初期化
    rep(i, n)
    {
        dist[i] = -1;
    }
    dist[s] = 0;
    queue<int> que;
    que.push(s);

    //本体
    while(que.size())
    {
        auto p = que.front();
        que.pop();
        if(p + 1 < n && dist[p + 1] == -1)
        {
            que.push(p + 1);
            dist[p + 1] = dist[p] + 1;
        }
        if(p - 1 >= 0 && dist[p - 1] == -1)
        {
            que.push(p - 1);
            dist[p - 1] = dist[p] + 1;
        }
        if(p == x && dist[y] == -1)
        {
            que.push(y);
            dist[y] = dist[p] + 1;
        }
    }

    for(int i = s; i < n; i++)
    {
        k[dist[i]]++;
    }

    return;
}

int main()
{
    cin >> n >> x >> y;
    x--; y--;
    rep(i, n)
    {
        bfs(i);
    }
    
    rep(i, n - 1)
    {
        cout << k[i + 1] << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,D,dp;
  long long count = 0;
  cin >> N >> D;
  vector<long long> X(N),Y(N);
  vector<double> d(N);
  for (long long i = 0; i < N; i++) {
    cin >> X.at(i) >> Y.at(i);
    dp = X.at(i)*X.at(i) + Y.at(i)*Y.at(i);
    d.at(i) = sqrt(dp);
    if(d.at(i) <= D){
        count += 1;
    }
  }

    cout << count <<endl;

}

Measured memory_bytes: 8012
n = int(input())
s = {}
for _ in range(n):
    cur = input()
    val = s.get(cur,0) + 1
    s[cur] = val
m = int(input())
t = {}
for _ in range(m):
    cur = input()
    val = t.get(cur,0) + 1
    t[cur] = val
s = list(s.items())
s.sort(key=lambda x:x[1],reverse=True)

ans = 0
for key,point in s:
    cur = point
    if key in t.keys():
        cur -= t[key]
    if ans < cur:
        ans = cur

print(ans)

Measured memory_bytes: 38512
/*
	author: Salam_35
	02.01.2020 20:16:24

*/
#include<bits/stdc++.h>
using namespace std;

#define ull unsigned long long 

int main()
{
	ull n;
	cin>> n;
	if(n&1)
	cout<<0<<endl;
	else
	{
		ull m=5;
		ull ans=0;
		while(m<n)
		{
			ans+=(n/m)/2;
			m*=5;
		}
		
		cout<<ans<<endl;
	}
}
	



Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {

    private static void nCombination3(int c) {
        int count = c;
        int num = 0;
        for (int i = 0; i < count - 2; i++) {
            for (int j = i + 1; j < count - 1; j++) {
                for (int k = j + 1; k < count; k++) {
                    num++;
                }
            }
        }
    }



    public static void main(String[] args) {
        // write your code here
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        Set<String> s= new HashSet<String>();
        for(int i=0;i<N;i++){
            String str= sc.next();
            s.add(str);
        }
        System.out.println(s.size());


    }
}


Measured memory_bytes: 77036
N = int(input())
dp = [[0 for i in range(3)] for _ in range(N)]
ls = [list(map(int,input().split())) for _ in range(N)]
dp[0][0],dp[0][1],dp[0][2] = ls[0][0],ls[0][1],ls[0][2]
for i in range(1,N):
    dp[i][0] = ls[i][0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1] = ls[i][1]+max(dp[i-1][0],dp[i-1][2])
    dp[i][2] = ls[i][2]+max(dp[i-1][1],dp[i-1][0])
print(max(dp[N-1]))


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

int main(){
    string s;
    cin >> s;
    vector<char> vec(4);
    for (int i = 0;i < 4; i++){
        vec.at(i) = s.at(i);
    }
    sort(vec.begin(), vec.end());
    if(vec.at(0) == vec.at(1) && vec.at(2) == vec.at(3) && vec.at(1) != vec.at(2)){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
N = int(input())
K = (((8 * N + 1) ** (1/2) + 1) / 2)

def recursive(k):
    if k == 2:
        return [[1], [1]]
    else:
        before = recursive(k - 1)
        r = [_ for _ in range(1 + (k - 2) * (k - 1) // 2, 1 + k * (k - 1) // 2)]
        return ([before[_] + [r[_]] for _  in range(len(r))] + [r])

if K.is_integer():
    K = int(K)
    print('Yes')
    print(K)
    [print(K - 1, ' '.join(map(str, ary))) for ary in recursive(K)]
else:
    print('No')

Measured memory_bytes: 11124
s = str(input()) 

a = int(s[:2])
b = int(s[2:])

if 1 <= a and a <= 12:
  if 1 <= b and b <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= b and b <= 12:
    print('YYMM')
  else:
    print('NA')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
  double dp[3000][3000];
int main()
{
    int n;
   // cin>>n;
   scanf("%d",&n);
    double p[n+1];
    for(int i=1;i<=n;i++) cin>>p[i];
   
    dp[0][0]=1.0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            dp[i][j]+=(j>0)? p[i]*dp[i-1][j-1]:0;
            dp[i][j]+=(j<i)? (1-p[i])*dp[i-1][j]:0;
        }


    }
   double sum=0.0;
    
        for(int j=0;j<=n;j++)
        {
           // cout<<dp[n][j]<<" ";
            if(j>n-j) sum+=dp[n][j];

        }
      //  printf("%lf\n",sum);
        cout<<setprecision(10)<<sum<<endl;

    
}


Measured memory_bytes: 68864
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}

struct Edge{
	int src,dst;
	Edge(){}
	Edge(int s,int d):src(s),dst(d){}
};
typedef vector<vector<Edge> > Graph;

bool BFS(const Graph& g,const vi& side,const vi& match,vi& level)
{
	int n=g.size();
	level.assign(n,n);
	queue<pii> q;
	rep(i,n) if(side[i]==0 && match[i]==-1)
		q.push(mp(i,0));
	bool res=false;
	while(!q.empty()){
		pii cur=q.front(); q.pop();
		int u=cur.first,l=cur.second;
		if(level[u]<=l) continue;
		level[u]=l;
		rep(i,g[u].size()){
			int v=g[u][i].dst;
			if(match[v]==-1)
				res=true;
			else
				q.push(mp(match[v],l+2));
		}
	}
	return res;
}

bool DFS(const Graph& g,const vi& side,int u,vi& match,vi& level)
{
	rep(i,g[u].size()){
		int v=g[u][i].dst;
		if(match[v]==-1 || level[match[v]]>level[u] && DFS(g,side,match[v],match,level)){
			match[u]=v;
			match[v]=u;
			return true;
		}
	}
	level[u]=-1;
	return false;
}

int HopcroftKarp(const Graph& g,const vi& side,vi& match)
{
	int n=g.size();
	match.assign(n,-1);
	int res=0;
	for(vi level;BFS(g,side,match,level);)
		rep(i,n) if(side[i]==0 && match[i]==-1)
			res+=DFS(g,side,i,match,level);
	return res;
}

int main()
{
	for(int m,n;scanf("%d%d",&m,&n),m|n;){
		vi bs(m),rs(n);
		rep(i,m) scanf("%d",&bs[i]);
		rep(i,n) scanf("%d",&rs[i]);
		
		Graph g(m+n);
		rep(i,m) rep(j,n) if(gcd(bs[i],rs[j])>1){
			g[i].push_back(Edge(i,m+j));
			g[m+j].push_back(Edge(m+j,i));
		}
		
		vi side(m+n),match;
		fill(m+all(side),1);
		printf("%d\n",HopcroftKarp(g,side,match));
	}
	
	return 0;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	for(int i = 0; i < k; i++){
		if(a >= b){
			b *= 2;
		}
		else if(b >= c){
			c *= 2;
		}
	}

	if(a < b && b < c) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 3632
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

from fractions import gcd

n = ii()
l = []
for _ in range(n):
    l.append(ii())

commul = l[0]
for i in l:
    commul = (commul*i)//gcd(commul,i)
print(commul)

Measured memory_bytes: 5076
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

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

int main(){
  int h,w;
  cin >> h >> w;

  vector<vector<char> > a(h);
  vector<vector<int> > d(h, vector<int>(w,-1));
  queue<pair<int,int> > q;

  REP(i,h){
    REP(j,w){
      char c;
      cin >> c;
      a[i].push_back(c);
      if(c == '#'){
        q.push(make_pair(i,j));
        d[i][j] = 0;
      }
    }
  }
  int ans = 0;
  while(!q.empty()){
    pair<int,int> pos = q.front();
    q.pop();

    REP(i,4){
      int x = pos.first + dx[i];
      int y = pos.second + dy[i];
      if(x < 0 || x >= h || y < 0 || y >= w) continue;

      if(a[x][y] == '#')continue;

      a[x][y] = '#';
      d[x][y] = d[pos.first][pos.second] + 1;
      ans = max(ans, d[x][y]);
      q.push(make_pair(x,y));

    }
  }

  cout << ans << endl;


}



Measured memory_bytes: 13456
#!/usr/bin/env python3

n = int(input())
h = list(map(int, input().split()))

def isallzero(h):
    ans = True
    for i in h:
        if i != 0:
            ans = False
            break
    return ans 

def func(h):
    if isallzero(h):
        return -1
    for i in range(len(h)):
        if h[i] != 0:
            return i

ans = -1
while True:
    ans += 1
#    print('h =', h)
#    print('isallzero() =', isallzero(h))
    if isallzero(h):
        break

    m = func(h)
    for i in range(m, n): 
        if h[i] != 0:
            h[i] -= 1
        else:
            break

print(ans)

Measured memory_bytes: 9168
#include<iostream>
using namespace std;
int main() {
    int a;
    while (cin >> a) {
        for (int i = 0; i < 10; i++) {
            if (1 << i & a) {
                if ((1 << (i + 1)) > a) { //一番右 " " いらない
                    cout << (1 << i);
                } else {
                    cout << (1 << i) << " ";
                }
            }
        }
        cout << endl;
    }
        
}



Measured memory_bytes: 2996
# coding: utf-8
# Your code here!
ABM= list(map(int,input().split()))
a =list(map(int,input().split()))
b =list(map(int,input().split()))

list1 =[]
for n in range(ABM[2]):
    list1.append(list(map(int,input().split())))

amin = min(a)
bmin = min(b)

min1 = amin + bmin

minlist = []

for i in range(ABM[2]):
    minlist.append(a[list1[i][0]-1] + b[list1[i][1]-1] - list1[i][2])

# print(minlist)
min2 = min(minlist)
# print(min2)

if(min1 > min2):
    min1 = min2

print(min1)

Measured memory_bytes: 42524
#include <stdio.h>

int change_stn(char *string)
{
	if (*string == 'A'){
			string++;
			if (*string == '\0') return (0);
			return (2);
	}
	
	else if (*string == 'B') return (1);
	else return (3);
}

int main(void)
{
	int list[4] = { 0 };
	char *rp;
	char tmp_in[100];
	
	while (scanf("%s", &tmp_in) != EOF){
		rp = tmp_in + 1;
		while (*rp++ != ',');
		list[change_stn(rp)]++;
	}
	
	printf("%d\n%d\n%d\n%d\n", list[0], list[1], list[2], list[3]);
	
	return (0);
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// Here your code !
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine().replace(" ", "");

		System.out.println(Integer.parseInt(str)%4 == 0 ? "YES" : "NO");
	}
}

Measured memory_bytes: 20820
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    string s;
    cin>>s;
    int q,qq;
    cin>>q;
    qq=q;
    string ans=s;
    bool ok=1;
    int cnt=0;
    V<int> a(q);
    V<pair<int,string>> p(q);
    rep(i,q){
        int t;
        cin>>t;
        a[i]=t;
        if(t==1){
            cnt++;
            if(!ok) ok=1;
            else ok=0;
        }else{
            int f;
            string c;
            cin>>f>>c;
            p[i]=make_pair(f,c);
            
        }
    }
    if(cnt%2==1) reverse(all(s));
    ans=s;
    int cc=0;
    string l,r;
    if(ok){
        rep(i,q){
        if(a[i]==2){
            string c=p[i].sc;
            if(cc%2==0){
                if(p[i].ft==1){
                    l+=c;
                    // string u=c;
                    // u+=ans;
                    // ans=u;
                }else{
                    r+=c;
                }
            }else{
                if(p[i].ft==1){
                    r+=c;
                }else{
                    l+=c;
                    // string u=c;
                    // u+=ans;
                    // ans=u;
                }
            }
        }else cc++;
    }
    }else{
        rep(i,q){
        if(a[i]==2){
            string c=p[i].sc;
            if(cc%2==1){
                if(p[i].ft==1){
                    // string u=c;
                    // u+=ans;
                    // ans=u;
                    l+=c;
                }else{
                    r+=c;
                }
            }else{
                if(p[i].ft==1){
                    r+=c;
                }else{
                    l+=c;
                    // string u=c;
                    // u+=ans;
                    // ans=u;
                }
            }
        }else cc++;
    }
    }
    reverse(all(l));
    cout<<l<<s<<r<<endl;
}

Measured memory_bytes: 14272
#include <stdio.h>

int main () {
    int a, b;
    int maior;
    scanf("%d %d", &a, &b);
    if (2*b-1 > 2*a -1 && 2*b-1 > a+b) {
        maior = 2*b-1;  
    }
    else if (2*a -1 > a+b && 2*a -1 > 2* b-1) {
        maior = 2*a-1;
    }
    else{
        maior = a + b;
    }
    printf("%d\n", maior);
    return 0;
}





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

using namespace std;

int main() {
  int k;
  cin >> k;
  k--;
  
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout << vec.at(k) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define MAX 100001
using namespace std;
int n;
int color[MAX] = {0};
vector<int> number[MAX];
void Connected_Components(void){
    int col = 0;
    for(int i=0;i<n;i++){
        if(color[i]==0){
            queue<int> Number_of_vertices;
            Number_of_vertices.push(i);
            color[i] = ++col;
            while(!Number_of_vertices.empty()){
                int v = Number_of_vertices.front();
                Number_of_vertices.pop();
                //cout << v << endl;
                for(int j=0;j<number[v].size();j++){
                    if(color[number[v][j]]==0){
                        color[number[v][j]] = col;
                        //cout << color[j] << endl;
                        Number_of_vertices.push(number[v][j]);
                    }
                }
            }
        }
    }
}
void input(void){
    int m;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        number[i].push_back(i);
    }
    for(int i=0;i<m;i++){
        int id,fre;
        cin >> id >> fre;
        number[id].push_back(fre); 
        number[fre].push_back(id);
    }
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<number[i].size();j++){
    //         cout << number[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
}
void question(void){
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int id_1,id_2;
        cin >> id_1 >> id_2;
        if(color[id_1]==color[id_2]){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
}
int main(void){
    input();
    Connected_Components();
    question();
    return 0;
}


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

int main(){
  vector<int> menu(5);
  for(int i = 0;i < 5;i++){
    cin >> menu.at(i);
  }
  vector<int> time(5);
  int max = 0;int num = 0;
  for(int i = 0;i < 5;i++){
    if(menu.at(i)%10 == 0){
      time.at(i) = menu.at(i)%10;
    }else{
      time.at(i) = 10- (menu.at(i)%10);
    }
    if(time.at(i) > max){
      max = time.at(i);
      num = i;
  }
 }
  int ans = 0;
    for(int i = 0;i < 5;i++){
      if(i == num){
        continue;
      }else{
        ans += menu.at(i) + time.at(i);
      }
    }
    ans += menu.at(num);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    s = input()
    len(s)

    for i in range(len(s)):
        s = s[0 : -1]
        #print(f"{s} length is {len(s)}")
        if len(s) % 2 == 0:
            sa = s[0 : int(len(s)/2)]
            sb = s[int(len(s)/2) : ]
            #print(f"sa is {sa} \nsb is {sb}")
            if sa == sb:
                print(len(s))
                break
resolve()

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

int main()
{
    int N;
    cin >> N;
    double res = 0;
    for(int i = 0;i < N;i++){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY"){
            res += x;
        }
        else if(u == "BTC"){
            res += x * 380000;
        }
    }
    cout << fixed << setprecision(8) << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<string>
#include<stdio.h>
#include<math.h>
#include <algorithm>

#define PI		3.14159265358979
#define IMAX	2147483647

using namespace std;

int main(void) {

	int n, x;
	cin >> n >> x;
	int sum = 0;
	int ans = 1;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		sum += tmp;
		if (x >= sum) ans++;

	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = []
a = gets.split.map(&:to_i)
b = []
b = gets.split.map(&:to_i)

#p n
#p a
#p b

t = 0
for i in 0..n-1
 if a[i] >= b[i]
     t += (a[i]-b[i])
 end
end
puts t 

Measured memory_bytes: 1788
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
int main() {
  ll n;
  cin>>n;
  string s;
  cin>>s;
  string ans;
  rep(i,0,10000)ans += ")";
  rep(i,0,200){
    rep(j,0,200){
      string s1,s2;
      rep(k,0,i){
        s1+="(";
      }
      rep(k,0,j){
        s2+=")";
      }
      string s3 = s1+s+s2;
      ll c = 0;
      ll flag = 1;
      rep(k,0,s3.sz){
        if(s3[k]=='(')c++;
        if(s3[k]==')')c--;
        if(c<0)flag = 0;
      }
      if(flag==1&&c==0){
        if(ans.sz>s3.sz){
          ans = s3;
        }
        if(ans.sz==s3.sz){
          if(ans>s3){
            ans = s3;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
const int M = 1e5 + 6;
vector< int > f[M];
int bit[M];
void upd(int x, int v) {
  for (; x; x -= x&(-x))
    bit[x] += v;
}
int get(int x) {
  int ret = 0;
  for (; x < M; x += x&(-x))
    ret += bit[x];
  return ret;
}
int ans[M];

int main() {
  for (int i = 1; i < M; i++) {
    for (int j = i; j < M; j += i)
      f[j].push_back(i);
  }
  int n, m;
  vector< pair< int, int > > ev;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    ev.push_back(make_pair(l, l));
    ev.push_back(make_pair(r+1, -l));
  }
  sort(ev.begin(), ev.end());
  int id = 0;
  for (int i = 1; i <= m; i++) {
    while (id < ev.size() && ev[id].first == i) {
      if (ev[id].second > 0)
        upd(ev[id].second, +1);
      else
        upd(-ev[id].second, -1);
      id++;
    }
    for (int ff : f[i]) {
      ans[ff] += get(i-ff+1);
    }
  }
  for (int i = 1; i <= m; i++)
    printf("%d\n", ans[i]);
  return 0;
}

Measured memory_bytes: 19052
import java.lang.reflect.Array;
import java.util.*;
import java.io.* ;
/*
NOTES:
-more than 10 digits (10^10), use long
-prefix sum of 1's and -1's to control flow of highlighting a region
-log(a)/log(b) = log base b of a
-create a position array if trying to see if elements show up next to each other sequentially
 i.e. elements 1,2,3 are within 3 spots of each other in an array
      arr[scannedInt - 1] = i; (position of i at p[i] in original)
- use a freq array when counting instances of an element occurring
- increment the counter first before simulating anything turn-based (two player game)

 */

public class Main {
    static long mod = (long)(Math.pow(10, 9) + 7);
    public static String alpha = "zabcdefghijklmnopqrstuvwxy";
    public static void main(String[] args) throws IOException{
        Scanner scan = new Scanner(System.in);
        long t = 1;
        while (t-- > 0){
            int a = scan.nextInt();
            int b = scan.nextInt();
            System.out.println(a*b);

        }
        scan.close();

    }


    static boolean isPalindrome(String s){
        for(int i = 0; i<s.length()/2; i++){
            if(s.charAt(i) != s.charAt(s.length()-i-1)) return false;
        }
        return true;
    }

    static ArrayList factors(int n ){
        ArrayList<Integer> facts = new ArrayList<>();
        for(int i = 1; i<=(int)Math.sqrt(n); i++){
            if(n%i == 0){
                if( i == Math.sqrt(n)) facts.add(i);
                else{
                    facts.add(i);
                    facts.add(n/i);
                }
            }
        }
        Collections.sort(facts);
        return facts;
    }

    static boolean isPrime (int n){
        if(factors(n).size() ==2) return true;
        else return false;
    }





    static long GCD(long a, long b) {
        // Everything divides 0
        if (a == 0) return b;
        if (b == 0) return a;

        // base case
        if (a == b) return a;

        // a is greater
        if (a > b) return GCD(a-b, b);
        return GCD(a, b-a);
    }
    static long LCM(long a, long b){
        return (a*b)/(GCD(a,b));
    }
    static String rev(String s){
        char[] arr = s.toCharArray();
        for(int i = 0; i<(s.length()+1)/2; i++){
            char temp = arr[i];
            arr[i] = arr[s.length()-i-1];
            arr[s.length()-i-1] = temp;
        }
        String fin = new String(arr);
        return fin;
    }
    static long pow(long a, long N) {
        if (N == 0) return 1;
        else if (N == 1) return a;
        else {
            long R = pow(a,N/2);
            if (N % 2 == 0) {
                return R*R;
            }
            else {
                return R*R*a;
            }
        }
    }

    static long powMod(long a, long N) {
        if (N == 0) return 1;
        else if (N == 1) return a % mod;
        else {
            long R = powMod(a,N/2) % mod;
            R *= R;
            R %= mod;
            if (N % 2 == 1) {
                R *= a;
                R %= mod;
            }
            return R % mod;
        }
    }

}

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

#define int long long
#define X first
#define Y second

int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

main() {
    int n;
    cin >> n;
    cout << arr[n-1] ;
}


Measured memory_bytes: 256
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N = int(input())

    for x in range(1, 10):
        for y in range(1, 10):
            if x * y == N:
                print('Yes')
                sys.exit(0)

    print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3700