akhauriyash/Code-Regression huggingface dataset:
from operator import itemgetter

N, M, K = map(int, input().split())

par = [i for i in range(N)]
rank = [1 for i in range(N)]

def get_root(A):
    if par[A] == A:
        return A
    par[A] = get_root(par[A])
    return par[A]

def connect(A, B):
    A = get_root(A)
    B = get_root(B)
    if A == B:
        return
    if rank[A] < rank[B]:
        A, B = B, A
    par[B] = A
    rank[A] += rank[B]
    rank[B] = 0


def verify_connect(A, B):
    if get_root(A) == get_root(B):
        return True
    else:
        return False


# like
like_path = [[] for i in range(N)]
like_query = [input() for i in range(M)]
dislike_query = [input() for i in range(K)]
for line in like_query:
    A, B = map(int, line.split())
    connect(A-1, B-1)
    like_path[A-1].append(B-1)
    like_path[B-1].append(A-1)

tmp_ans = []
for i in range(N):
    tmp_ans.append(rank[get_root(i)]-len(like_path[i])-1)

for line in dislike_query:
    A, B = map(int, line.split())
    if verify_connect(A-1, B-1):
        tmp_ans[A-1] -= 1
        tmp_ans[B-1] -= 1

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


Measured memory_bytes: 51972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
ll x, y;
ll Qpow(ll a, ll b);
ll C(ll a, ll b);
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> x >> y;
	if ((2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << C((2 * x - y) / 3 + (2 * y - x) / 3, min((2 * x - y) / 3, (2 * y - x) / 3)) << endl;
	}
	return 0;
}

int inv(int a)
{
	return a == 1 ? 1 : (long long)(MOD - MOD / a) * inv(MOD % a) % MOD;
}
ll C(ll n, ll m)
{
	if (m < 0)return 0;
	if (n < m)return 0;
	if (m > n - m)m = n - m;
	ll up = 1, down = 1;
	for (ll i = 0; i < m; i++)
	{
		up = up * (n - i) % MOD;
		down = down * (i + 1) % MOD;
	}
	return up * inv(down) % MOD;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
	int i,a,n,b,c;
	vector<int> A;
	for (i = 0; i < 6; i++) {
		cin >> a;
		A.push_back(a);
	}
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> b; cin >> c;
		if (b == A[0] && c == A[1])cout << A[2] << endl;
		else if (b ==A[0] && c == A[2])cout << A[4] << endl;
		else if (b == A[0] && c == A[3])cout << A[1] << endl;
		else if (b == A[0] && c == A[4])cout << A[3] << endl;
		else if (b == A[1] && c == A[0])cout << A[3] << endl;
		else if (b == A[1] && c == A[2])cout << A[0] << endl;
		else if (b == A[1] && c == A[3])cout << A[5] << endl;
		else if (b == A[1] && c == A[5])cout << A[2] << endl;
		else if (b == A[2] && c == A[0])cout << A[1] << endl;
		else if (b == A[2] && c == A[1])cout << A[5] << endl;
		else if (b == A[2] && c == A[4])cout << A[0] << endl;
		else if (b == A[2] && c == A[5])cout << A[4] << endl;
		else if (b == A[3] && c == A[0])cout << A[4] << endl;
		else if (b == A[3] && c == A[1])cout << A[0] << endl;
		else if (b == A[3] && c == A[4])cout << A[5] << endl;
		else if (b == A[3] && c == A[5])cout << A[1] << endl;
		else if (b == A[4] && c == A[0])cout << A[2] << endl;
		else if (b == A[4] && c == A[2])cout << A[5] << endl;
		else if (b == A[4] && c == A[3])cout << A[0] << endl;
		else if (b == A[4] && c == A[5])cout << A[3] << endl;
		else if (b == A[5] && c == A[1])cout << A[3] << endl;
		else if (b == A[5] && c == A[2])cout << A[1] << endl;
		else if (b == A[5] && c == A[3])cout << A[4] << endl;
		else if (b == A[5] && c == A[4])cout << A[2] << endl;
	}
	return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint N;
    cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    lint x   = 5;
    lint ans = 0;
    while (2ll * x <= N) {
        ans += (lint)N / (2 * x);
        x *= 5;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define bs2int(bs) (int)((bs).to_ulong())
#define DEBUG(X) cerr<<"  "<<#X<<" = "<<X<<endl
#define DUMP(A, n) for (auto x=begin(A); x!=begin(A)+n;x++){cout <<*x<< ' ';} cout<<endl;
#define DUMPP(A, n, m) for (auto x=begin(A); x != begin(A)+n;x++) {for (auto y=begin(*x); y != begin(*x)+m;)cout <<*y++<< ' '; cout<<endl;};
#define DUMPM(M) for (auto itr=mp.begin(); itr!=mp.end(); itr++) {cout<<itr->first<<" -> "<<itr->second<<endl;}
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)

using P = pair<int, int>;

int h,w,n;
map<P, int> mp;
int dx[9] = {1, 0, -1,  0, 1, -1,  1, -1, 0};
int dy[9] = {0, 1,  0, -1, 1, -1, -1,  1, 0};
int j[10];
ll sum;

bool check(int x, int y) {
  return !(x<=1||x>=w||y<=1||y>=h);
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin>>h>>w>>n;
  REP(i,n) {
    int y,x; cin>>y>>x;
    REP(i,9) {
      P np = {x+dx[i], y+dy[i]};
      if (!check(np.first, np.second)) continue;

      int pr = mp[np];
      if (pr) j[pr]--;
      if (pr==0) sum++;

      ++j[++mp[np]];
    }
  }
  cout << ((h-2)*1LL*(w-2))-sum << endl;
  FOR(i,1,10) {
    cout << j[i] << endl;
  }
}


Measured memory_bytes: 56576
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        if A[i] >= B[i]:
            ans += B[i]
        elif A[i] < B[i] <= A[i] + A[i+1]:
            A[i+1] = A[i+1]-(B[i]-A[i])
            ans += B[i]
        else:
            ans += A[i] + A[i+1]
            A[i+1] = 0
    print(ans)
resolve()

Measured memory_bytes: 24004
A,B,C = map(int,input().split())

ABCList = [[A,B,C]]
mugen=False

while(A%2==0 and B%2==0 and C%2==0):
    tA,tB,tC = A,B,C
    A,B,C = (tB+tC)//2,(tA+tC)//2,(tA+tB)//2
    if [A,B,C] in ABCList:
        mugen=True
        break
    else:
        ABCList.append([A,B,C])

if mugen:
    print(-1)
else:
    print(len(ABCList)-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
ll dp[51][51][2501];
int x[51];
int N, A;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> A;
	int max_v = 0;
	rep(i, 0, N) {
		cin >> x[i];
		max_v = max(max_v, x[i]);
	}
	rep(i, 0, N + 1) rep(j, 0, N + 1) rep(k, 0, max_v * N + 1) dp[i][j][k] = 0;
	dp[0][0][0] = 1;

	rep(i, 0, N) rep(j, 0, N + 1) rep(k, 0, N * max_v + 1) {
		if(k - x[i] >= 0 and j - 1 >= 0) dp[i + 1][j][k] = dp[i][j][k] + dp[i][j - 1][k - x[i]];
		else if(k - x[i] < 0) dp[i + 1][j][k] = dp[i][j][k];
		else dp[i + 1][j][k] = 0;
	}

	ll rsl = 0;
	rep(j, 1, N + 1)  {
		rsl += dp[N][j][j * A];
	}

	cout << rsl << endl;

}


Measured memory_bytes: 51072
import math
N=int(input())

ans=10**10

for i in range(1,int(N/2)+1):
    j = N-i
    A = list(map(int,str(i)))
    B = list(map(int,str(j)))

    X = sum(A) + sum(B)

    if ans > X:
        ans = X
print(ans)


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

int selectionSort(int A[], int N) {
        int sw = 0;
        for ( int i = 0; i < N; i++ ) {
                int minj = i;
                for ( int j = i; j < N; j++ ) {
                        if ( A[j] < A[minj] ) {
                                minj = j;
                        }
                }
                if ( A[i] != A[minj] ) {
                        swap(A[i], A[minj]);
                        sw++;
                }
        }
        return sw;
}

int main() {
        int A[100], N, sw;

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

        sw = selectionSort(A, N);

        for ( int i = 0; i < N; i++ ) {
                if (i) cout << " ";
                cout << A[i];
        }
        cout << endl;
        cout << sw << endl;

        return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
const int maxN = 2e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

int n;
int a[maxN];

int main() {

	n = ri();
	rep (i, 1, n) a[i] = ri() - i;
	sort(a+1, a+n+1);
	int b = a[(n+1)>>1];

	long long res = 0;
	rep (i, 1, n) res += abs(a[i] - b);
	printf("%lld\n", res);
	
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  reverse(S.begin(),S.end());
  while(S.size()>0){
    //if(S.find("dreamer") == 0){
    if(S.find("remaerd") == 0){
      
      S.erase(0, 7); 
    }
    //else if(S.find("dream") == 0){
    else if(S.find("maerd") == 0){
      
      S.erase(0, 5);
    }
    //else if(S.find("eraser") == 0){
    else if(S.find("resare") == 0){
      
      S.erase(0, 6);
    }
    //else if(S.find("erase") == 0){
    else if(S.find("esare") == 0){
      
      S.erase(0, 5);
    }
    else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned int a,b;
    int arr[5];
    memset(arr,0,sizeof arr);
    for(int i = 0; i < 3; i++){
        cin >> a >> b;
        arr[a]++;
        arr[b]++;

    }
    bool ok =  true;
    for(int i = 1; i <= 4; i++){
        if(arr[i] > 2){
            ok = false;
            break;
        }
    }
    if(!ok){
        cout << "NO" << endl;
    }
    else cout << "YES" << endl;
  return 0;
}



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

int main()
{
	int N;
	scanf("%d", &N);
	
	int A[N-1];
	int B[N];
	int r;
	for(r=0; r<N; r++) B[r]=0;
	
	for(r=0; r<N-1; r++){
		scanf("%d", &A[r]);
		B[A[r]-1]++;
	}
	
	for(r=0; r<N; r++) printf("%d\n", B[r]);
	
	return 0;
	
}


Measured memory_bytes: 3240
#include<stdio.h>
int main()
{
    int n;

    scanf("%d",&n);

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

        for(int j=1;j<=9;j++){

                if(i*j==n) {printf("Yes");return 0;}
        }
    }
    printf("No");

    return 0;
}


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

struct pro{
	char name[10];
	int time;
};

int main(int argc, char** argv) {

    list<pro> l;
    int n,q;
    cin >> n >> q;
    for(int i=0;i<n;i++){
            pro tmp1;
            char tmp2[10];
            int tmp3;
            cin >> tmp2 >> tmp3;
            for(int i=0;i<10;i++){
                tmp1.name[i]=tmp2[i];
            }
            tmp1.time=tmp3;
            l.push_back(tmp1);
    }
    int res=0;
    while(!l.empty()){
            if(l.begin()->time<=q){
                    res+=l.begin()->time;
                    cout << l.begin()->name << " " << res << endl;
                    l.pop_front();
            }else{
                    res+=q;
                    l.begin()->time-=q;
                    l.push_back(*l.begin());
                    l.pop_front();
            }
    }
    
    return 0;
}

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	string s, s1;
	int close, tmp, tmp_diff, number = 753;
	cin >> s;
	REP(i, 0, (int)s.length()-2){
		s1 = "";
		REP(j, i, i+3) s1 += s[j];
		tmp = stoi(s1);
		if(tmp_diff > abs(tmp - number)){
			tmp_diff = abs(tmp - number);
			close = tmp;
		}
	}
	cout << abs(close-number);
		
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <set>
#include <sstream>
#include <string>
#include <queue>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

//MOD//
const ll MOD = 1000000007;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

ll pow(ll n, int m){
  if(!m) return 1;
  ll ret = pow(n, m/2);
  ret *= ret;
  return (m&1) ? ret*n : ret;
}

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

int  a, b;

int main(){
  scanf("%d%d",&a,&b);
  int ans = 0;
  if (a < 0 && b < 0) {
    if ((b-a)%2==1) {
      ans = 1;
    } else {
      ans = -1;
    }
  } else if (a > 0 && b > 0) {
    ans = 1;
  } else {
    ans = 0;
  }
  if (ans < 0) {
    cout << "Negative" << endl;
  } else if (ans == 0) {
    cout << "Zero" << endl;
  } else {
    cout << "Positive" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int A, B;
    cin >> A >> B;
    int count = 0;
    for (int i = A; i <= B; ++i)
    {
        string orig = to_string(i);
        string rev = orig;
        reverse(rev.begin(), rev.end());
        if (orig == rev) ++count;
    }
    cout << count << endl;
    return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	int basket[200000] = { 0 };
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		basket[tmp]++;
	}
	sort(basket, basket + N, greater<>());
	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += basket[i];
	}
	cout << N - sum << endl;
}

Measured memory_bytes: 4380
#include <cstdio>
#include <iostream>
#include <utility>
using namespace std;

int main(){
	int n;
	int a[100];
	int count=0;
	
	scanf(" %d", &n);
	for(int i=0; i<n; ++i) scanf(" %d", &a[i]);
	
	//bubble sort	
	bool flag=true;
	while(flag){
		flag=false;
		for(int i=n-1; i>0; --i){
			if(a[i]<a[i-1]){
				swap(a[i], a[i-1]);
				flag=true;
				count++;
			}	
		}
	}
	
	for(int i=0; i<n; ++i){
		if(i>0) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n%d\n", count);
	
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  string o,e;
  cin >> o >> e;
  rep(i,e.size()){
    cout << o[i] << e[i];
  }
  if(o.size()-e.size()==1){
    cout << o[o.size()-1] << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll A, B;
  cin >> A >> B;

  if (B % A == 0)
    cout << A + B << endl;
  else
    cout << B - A << endl;
}

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

int main(){
  int N;
  cin>>N;
  int L[N];
  for (int i=0;i<N;i++){
    cin>>L[i];
  }
  int tmp;
  for (int i=0; i<N; ++i) {
    for (int j=i+1; j<N; ++j) {
      if (L[i] > L[j]) {
        tmp =  L[i];
        L[i] = L[j];
        L[j] = tmp;
      }
    }
  }
  int rest=0;
  for(int i=0;i<N-1;i++){
    rest=rest+L[i];
  }
  
  if(rest>L[N-1]){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;

  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n;
vector<int> bit;

int sum(int i){
    int ans = 0;
    while(i>0){
        ans += bit[i];
        i -= i & -i;
    }
    return ans;
}

void add(int i, int x){
    while(i<=n){
        bit[i] += x;
        i += i & -i;
    }
}

int main()
{
    cin >> n;
    bit.resize(n+1, 0);
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    b = a; sort(ALL(b));
    
    rep(i, n){
        int l=0,r=n-1,m=(l+r)/2;
        while(l<=r){
            if(a[i]==b[m]){
                c[i]=m+1;
                break;
            }else if(a[i]<b[m]){
                r = m-1;
            }else{
                l = m+1;
            }
            m = (l+r)/2;
        }
    }
    // prvec(a);
    // prvec(b);
    // prvec(c);
    ll res=0;
    rep(i, n){
        // cout << i << ": ";
        // prvec(bit);
        res += c[i] - 1 - sum(c[i]-1);
        add(c[i], 1);
    }
    pr(res);
    return 0;}


Measured memory_bytes: 5880
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define rep(i,N) repd(i,0,N)
const int INF=100000000;
//--------------------------------------//
int d,g;
int p[100],c[100];

int main(){
	cin>>d>>g;
	int f[100];
	rep(i,d) {
		cin>>p[i];
		cin>>c[i];
		f[i]=p[i]*(i+1)*100+c[i];
	}
	int a=0;
	int b=d;
	int ans=INF;
	rep(i,1010){
		int e=g-a;
		rep(j,1<<(b - 1)){
			int m=0;
			int r=0;
			int q=j;
			int z=0;
			while(q>0){
				if(q&1==1){
					m+=p[z];
					r+=f[z];
				}
				q>>=1;
				z++;
			}
			if(r>=e){
				ans=min(m+i,ans);
			}
		}
		if(e<=0) {
			ans=min(i,ans);
			break;
		}
		a+=b*100;
		if(--p[b-1]==0){
			a+=c[b-1];
			b--;
		}
	}
		cout<<ans<<endl;
	return 0;
}


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

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

#ifdef _DEBUG
#define DEBUG(x) cout << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define DEBUG(x)
#define INFILE
#endif

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL9_MOD = 1000000009LL;
static constexpr ll LL7_MOD = 1000000007LL;
static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
static void scan(vector<string>& v, bool isWord = true);
template <class T> inline bool chmax(T& a, T b);
template <class T> inline bool chmin(T& a, T b);
template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val);

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

  string s;
  cin >> s;

  ll l = s.size();
  ll first = 0, last = 0;
  vector<ll> result(l, 0);

  char stop = 'L';

  while (last < l) {
    last++;
    if (s[last] == stop || last == l) {
      for (int i = first; i < last; i++) {
        ll pivot = stop == 'L' ? last : first;
        ll diff = abs(pivot - i);
        ll pos = pivot - (diff % 2);
        result[pos]++;
      }

      first = last;
      stop = stop == 'L' ? 'R' : 'L';
    }
  }

  string ans;
  for (ll v : result) {
    ans += to_string(v);
    ans += " ";
  }
  ans.pop_back();
  cout << ans << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int l;
    cin >> l;
    int d;
    rep(i, 20){
        if(1 & (l >> i))d = i + 1;
    }

    int n = d;
    int m = 2 * (d - 1);
    vector<int> u, v, w;
    rep(i, d - 1)rep(j, 2){
        u.push_back(i+1);
        v.push_back(i+2);
        w.push_back(j * pow(2, i));
    }
    for(int i = d - 2; i >= 0; i--){
        if(l - pow(2, i) >= pow(2, d - 1)){
            u.push_back(i+1);
            v.push_back(d);
            w.push_back(l - pow(2, i));
            l -= pow(2, i);
            m++;
        }
    }
    cout << n << ' ' << m << endl;
    rep(i, u.size()){
        cout << u[i] << ' ' << v[i] << ' ' << w[i] << endl;
    }
}

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

using namespace std;

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

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

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    FOR(i,0,s.size()){
        if(i%2 == 0){
            cout << s[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, k; cin >> n >> k;
    long long a[n];
    for(int i = 0; i < n; i++) { cin >> a[i]; a[i]--; }
    vector<bool> visit(n, false);
    visit[0] = true;
    vector<int> tele;
    tele.push_back(0);
    int w = 0;
    while (true)
    {
        w = a[w];
        if(visit[w]) {
            break;
        }
        else {
            visit[w] = true;
            tele.push_back(w);
        }
    }

    long long loop;
    long long s;
    for (int i = 0; i < (int)tele.size(); i++)
    {
        if(tele[i] == w) {
            s = i;
            loop = tele.size() - i;
        }
    }

    if(k < s) {
        cout << tele[k] + 1 << endl;
        return 0;
    }
    long long ans = (k - s + loop) % loop;
    cout << tele[s+ans]+1 << endl;
    return 0;
}

Measured memory_bytes: 5840
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;


    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,i,j,a,b;
            cin>>n;
            ld x=0,z;
            vector<ll> v2,v;
            for(i=1;i<=n;++i)
            {
                cin>>a>>b;
                v2.pb(a);
                v.pb(b);
            }
            sort(v2.begin(),v2.end());
            sort(v.begin(),v.end());
            ld ans=-1,ans2=-1;
            if(n%2==1)
            {
                ans=v2[(n+1)/2-1];
                ans2=v[(n+1)/2-1];
            }
            else
            {
                ans=1.0*(v2[n/2-1]+v2[n/2])/2;
                ans2=1.0*(v[n/2-1]+v[n/2])/2;
            }
            if(n%2==1)
            {
                ll ans3=ans2-ans+1;
                cout<<ans3<<endl;
            }
            else
            {
                ll ans3 = (ans2-ans)*2+1;
                cout<<ans3<<endl;
            }
        }
        return 0;
    }


Measured memory_bytes: 6764
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

// [l, r)
ll countNum(ll l, ll r, ll div) {
    return (r-1)/div - (l-1)/div;
}

// x ?????§????????¨????????????????????¨????????????????±???????
ll calc(ll x) {
    ll p = 1;
    ll ans = 0;
    int cnt = 1;
    while (10*p < x) {
        ll np = p*10;
        // [p, np) ??§?????????????????????
        ll fizzbuzz = countNum(p, np, 15);
        ll fizz = countNum(p, np, 3) - fizzbuzz;
        ll buzz = countNum(p, np, 5) - fizzbuzz;
        ll other = (np-p) - (fizz+buzz+fizzbuzz);
        ans += fizzbuzz*8 + fizz*4 + buzz*4 + other*cnt;
        cnt++;
        p = np;
    }
    // [p, x] ????????????????????°
    ll fizzbuzz = countNum(p, x+1, 15);
    ll fizz = countNum(p, x+1, 3) - fizzbuzz;
    ll buzz = countNum(p, x+1, 5) - fizzbuzz;
    ll other = (x+1-p) - (fizz+buzz+fizzbuzz);
    ans += fizzbuzz*8 + fizz*4 + buzz*4 + other*cnt;
    return ans;
}

const string number = "0123456789";

string trans(ll x) {
    if (x%15==0) return "FizzBuzz";
    if (x%5==0) return "Buzz";
    if (x%3==0) return "Fizz";
    string ret;
    while (x) {
        ret += number[(int)(x%10)];
        x /= 10;
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

int main() {
    ll s;
    cin >> s;
    ll low = 0, high = 1ll<<58;
    // calc(x) < s ?????????????????§??? x ????±???????
    while (high-low > 1) {
        const ll med = (low+high)/2;
        if (calc(med) >= s) high = med;
        else low = med;
    }
    s -= calc(low)+1;
    // ?????£??????????????´????????£??????
    string ans;
    while (1) {
        string t = trans(++low);
        if (s > 0) {
            ans += t.substr((int)s);
            s = 0;
        } else {
            int i = 0;
            while (ans.size() < 20 && i < (int)t.size()) ans += t[i++];
        }
        if (ans.size()==20) break;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n, h, w;
  cin >> n >> h >> w;
  int a[n];
  int b[n];
  int count = 0;
  for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
  for(int i = 0; i < n; i++) {
    if(a[i] >= h && b[i] >= w) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int H = 0;
		int W = 0;
		int i = 0;
		int j = 0;
		String str = null;
		String[] split = new String[2];

		while(true){
			str = scan.nextLine();
			split = str.split(" ");
			H = Integer.parseInt(split[0]);
			W = Integer.parseInt(split[1]);
			if(H == 0 && W == 0){
				break;
			}
			for(i = 0; i < H; i++){
				for(j = 0; j < W; j++){
					System.out.print("#");
				}
				System.out.print("\n");
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 37644
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<iomanip>
#include<list>
using namespace std;

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

	int low = 100000000;

	int count = 0;

	for (int i = 0; i < N; i++) {
		int input;
		cin >> input;

		if (low > input) {
			count++;
			if (low > input) {
				low = input;
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int a =sc.nextInt();
        int b =sc.nextInt();
        int c =sc.nextInt();
        int d =sc.nextInt();
        
        int ca =Math.abs(c-a);
        int cb =Math.abs(c-b);
        int ba =Math.abs(b-a);
        
        int num1,num2=0;
        
        if(ca<=d||(cb<=d&&ba<=d)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
        
        
        
        
    }
    
    
}


Measured memory_bytes: 35664
n,q=map(int,input().split())
lst=[[] for i in range(n)]
ans=[0]*n

for i in range(n-1):
      a,b=map(int,input().split())
      lst[a-1].append(b-1)
      lst[b-1].append(a-1)

for i in range(q):
    s,t=map(int,input().split())
    ans[s-1]+=t

Q=[0]

flag=[True]+[False]*(n-1)


while Q:
  v=Q.pop()
  flag[v]=True
  for i in lst[v]:
    if flag[i]:
      continue
    flag[i]=True
    ans[i]+=ans[v]
    Q.append(i)


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

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

using namespace std;
using ll = long long int;

int main()
{
	int n, p;
	cin >> n >> p;
	string s;
	cin >> s;

	if (p == 2 || p == 5)
	{
		ll ans = 0;

		for (int i = s.length() - 1; i >= 0; i--)
		{
			if ((s[i] - '0') % p == 0)
			{
				ans += (ll) i + 1;
			}
		}

		cout << ans << endl;
		return 0;
	}

	vector<ll> count(p);
	ll last = 0;
	ll mult10 = 1;
	for (int i = s.length() - 1; i >= 0; i--)
	{
		last += (s[i] - '0') * mult10;
		last %= p;
		count[last]++;
		mult10 = (mult10 * 10) % p;
	}

	ll ans = 0;
	for (auto &c : count)
	{
		ll combination = 1;

		for (int i = 0; i < 2; i++)
		{
			combination *= c - i;
		}

		for (int i = 0; i < 2; i++)
		{
			combination /= i + 1;
		}

		ans += combination;
	}

	ans += count[0];

	cout << ans << endl;
}

Measured memory_bytes: 640
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int a[3][3];
bool b[3][3];
int main(int argc,char** argv){
	rep(i,3)rep(j,3){
		cin>>a[i][j];
	}
	int n;
	cin>>n;
	rep(k,n){
		int t;
		cin>>t;
		rep(i,3)rep(j,3){
			if(a[i][j]==t){
				b[i][j]=1;
			}
		}
	}
	if(b[0][0]==b[0][1]&&b[0][1]==b[0][2]&&b[0][2]==1){
		cout<<"Yes";
		return 0;
	}
	if(b[1][0]==b[1][1]&&b[1][1]==b[1][2]&&b[1][2]==1){
		cout<<"Yes";
		return 0;
	}
	if(b[2][0]==b[2][1]&&b[2][1]==b[2][2]&&b[2][2]==1){
		cout<<"Yes";
		return 0;
	}
	if(b[0][0]==b[1][0]&&b[1][0]==b[2][0]&&b[2][0]==1){
		cout<<"Yes";
		return 0;
	}
	if(b[0][1]==b[1][1]&&b[1][1]==b[2][1]&&b[2][1]==1){
		cout<<"Yes";
		return 0;
	}
	if(b[0][2]==b[1][2]&&b[1][2]==b[2][2]&&b[2][2]==1){
		cout<<"Yes";
		return 0;
	}
	if(b[0][0]==b[1][1]&&b[1][1]==b[2][2]&&b[2][2]==1){
		cout<<"Yes";
		return 0;
	}
	if(b[0][2]==b[1][1]&&b[1][1]==b[2][0]&&b[2][0]==1){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
a, b, x = map(int, input().split())
"""
    a~b間のxで割り切れる数は何個？
    1~b間のxで割り切れる数から1~a間のxで割り切れる数
"""
ans_b = b//x
ans_a = (a-1)//x
print(ans_b - ans_a)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll m,n,i;
    cin >> n >> m;
    ll a[n],sum=0, cnt=0;
    for(i=0;i<n;i++) {
    	cin >> a[i];
    	sum+=a[i];
    }
    sort(a, a+n);
    if((double)a[n-m] >= ((double)sum/(4*m))) cout << "Yes";
    else cout << "No";

    // for(i=0;i<n;i++) {
    // 	if((double)a[i] >= ((double)sum/(4*m))) cnt++;
    // }
    // if(cnt>=m) cout << "Yes";
    // else cout << "No";
    cout << "\n";
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for (int i=0; i<N; ++i) {
    cin >> x[i] >> u[i];
  }
  
  double sum=0;
  for (int i=0; i<N; ++i) {
    if (u[i]=="JPY") {
      sum += x[i];
    } else {
      sum += x[i]*380000.0;
    }
  }
  
  cout << sum << endl;
  return 0;
}









Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.random;
   
void main() {
  int i;
  while (1) {
    auto n = readln.chomp.to!int;
    if (!n) break;
    writeln("Case ", ++i, ": ", n);
  }
}

Measured memory_bytes: 1048
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int min = 10;
        long B = 1;
        for(long A = 1;A * A <= N;A++){
            if(N % A == 0){
                B = N / A;
            }
            if(digits(B) < min){
                min = digits(B);
            }
        }
        System.out.println(min);
    }
    public static int digits(long max){
        int count = 0;
        while(max != 0){
            max /= 10;
            count++;
        }
        return count;
    }
}


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

const ll mod = 998244353;

int dis[100000 + 10];

ll ksm(ll a, ll b)
{
	ll ans = 1;
	while( b )
	{
		if(b & 1) ans = ans * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return ans;
}

int main()
{
	ll n;
	cin>>n;
	ll x;
	ll maxn=0;
	dis[0]=1;
	cin>>x;
	ll flag=0;
	if(x != 0)
	{
		flag = 1;
	}
//	printf("YES");
	for(ll i=1; i<n; i++)
	{
		cin>>x;
		if(x == 0) flag = 1;
		maxn=max(maxn, x);
		dis[x]++;
	}
//	printf("NO");	
//	cout<<maxn<<endl;
	if(flag)
	{
		printf("0");
	}
	else
	{
		ll ans=1;
		for(ll i=1; i < maxn; i++)
		{
			if(dis[i] == 0)
			{
				printf("0");
				return 0;
			}
			ans=ans*ksm(dis[i], dis[i+1])%mod;
		}
		cout<<ans;
	}	
//	printf("YEs");
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

long long int d[1001][1001];

void warshall_floyd(int n){
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = 0; k < n; k++)
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

bool flag[1001] = {};

long long int func(int V){
	
	bool used_all = true;
	int index;
	
	for(int i = 0; i < V; i++){
		if(flag[i]){
			used_all = false;
			index = i;
			flag[index] = false;
			break;
		}
	}
	if(used_all){
		return 0;
	}
	
	long long int ret = INF;
	for(int i = index + 1; i < V; i++){
		if(flag[i]){
			flag[i] = false;
			ret = min(ret, d[index][i] + func(V));
			flag[i] = true;
		}
	}
	flag[index] = true;
	return ret;
}

int main()
{
	int V, E;
	cin >> V >> E;
	
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			d[i][j] = INF;
		}
		d[i][i] = 0;
	}
	
	long long int ans = 0;
	for(int i = 0; i < E; i++){
		long long int u, v, c;
		cin >> u >> v >> c;
		d[u][v] = min(d[u][v], c);
		d[v][u] = min(d[v][u], c);
		flag[u] = !flag[u];
		flag[v] = !flag[v];
		ans += c;
	}
	
	warshall_floyd(V);
	
	cout << ans + func(V) << endl;
	
	return 0;
}


Measured memory_bytes: 3172
import java.util.Scanner;

public class Main {

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

		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();

		for (int i = 0; i < 10; i++) {
			x = r * x - d;
			System.out.println(x);
		}

	}
}

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

int main(){
	int N; cin>>N;
	vector<int> A(N), C(N);
	rep(i, N){cin>>A[i]; A[i]--;}//値補正

	rep(i, N) C[A[i]]++;//値の種類毎の計数

	ll all = 0;//組み合わせの総計
	rep(a, N){
		ll c = C[a];
		if(c>=2) all += c*(c-1)/2;//組み合わせ
	}

	vector<ll> ans(N, 0);
	rep(k, N){
		int c = C[A[k]];// ak の値の個数
		ll del = c>=2? c*(c-1)/2: 0;// ak の値の組み合わせ
		c--;// 1 個減
		ll add = c>=2? c*(c-1)/2: 0;// ak の値の組み合わせ
		ans[k] = all - del + add;
	}

	rep(i, N) cout<< ans[i] <<endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int a,b;cin >> a >> b;
    string A,B;
    rep(i,b)A.push_back(a + '0');
    rep(i,a)B.push_back(b + '0');

    string tmp = min(A,B);
    cout << tmp << endl;     
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] str_a = br.readLine().split(" ");
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(str_a[i]); 
        }
        Arrays.sort(a);
        
        System.out.println(a[n-1] - a[0]);
    }
}


Measured memory_bytes: 21076
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
const long long Mod=1000000000039;
const long long base=1000003;
int n;
char s[250010];
long long a[250010],b[250010];
long long mul(long long a,long long b)
{
	long long ans=0,t=a;
	while(b)
	{
		if(b&1)ans=(ans+t)%Mod;
		t=(t+t)%Mod;
		b>>=1;
	}
	return ans;
}
long long fpow(long long a,long long b)
{
	long long ans=1,t=a;
	while(b)
	{
		if(b&1)ans=mul(ans,t);
		t=mul(t,t);
		b>>=1;
	}
	return ans;
}
map<long long,int>mp;
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	long long x=0,y=0,invbase=fpow(base,Mod-2);
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='-')
			x=(x-1+Mod)%Mod;
		else if(s[i]=='+')
			x=(x+1)%Mod;
		else if(s[i]=='<')
			x=mul(x,base)%Mod;
		else x=mul(x,invbase)%Mod;
	}
	long long c=x;
	x=1;y=0;
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='+')
			y=(y-x+Mod)%Mod;
		else if(s[i]=='-')
			y=(y+x)%Mod;
		else if(s[i]=='>')
			x=mul(x,base)%Mod;
		else x=mul(x,invbase)%Mod;
		b[i]=y;
		a[i]=(mul(x,c)+y)%Mod;
	}
	long long ans=0;
	for(int i=n;i>=1;i--)
	{
		mp[b[i+1]]++;
		ans+=mp[a[i]];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 37632
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,sum=0,i,j,k;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    
    sort(a,a+n);
    for(i=0;i<n;i++){
       for(j=i+2;j<n;j++){
           for(k=i+1;k<j;k++){
               if((a[i]+a[k])>a[j])
               sum++;
           }
       }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256