akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

struct Edge {
    ll from;
    ll to;
    ll cost;
    Edge(ll f, ll t, ll c)
        : from(f)
        , to(t)
        , cost(c)
    {
    }
    bool operator<(const Edge& o) const
    {
        return cost < o.cost;
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };
typedef pair<int, int> P; // first:最短距離，second:頂点番号

typedef pair<ll, int> P_ll;

struct UnionFind {
    // par[i]:データiが属する木の親の番号．i==par[i]のとき，データiは木の根ノード
    vector<int> par;
    // sizes[i]:根ノードiの木に含まれるデータの数．iが根ノードでない場合は無意味な値となる
    vector<int> sizes;

    UnionFind(int n)
        : par(n)
        , sizes(n, 1)
    {
        // 最初はすべてのデータiがグループiに存在するものとして初期化
        rep(i, n) par[i] = i;
    }

    // データxが属する木の根を得る
    int find(int x)
    {
        if (x == par[x])
            return x;
        return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す
    }

    // 2つのデータx,yが属する木をマージ
    void unite(int x, int y)
    {
        //データの根ノードを得る
        x = find(x);
        y = find(y);

        // すでに同じ木に属しているならマージしない
        if (x == y)
            return;
        // xの木がyの木より大きくなるようにする
        if (sizes[x] < sizes[y])
            swap(x, y);

        // xがyの親になるように連結
        par[y] = x;
        sizes[x] += sizes[y];
        // sizes[y] = 0; // sizes[y]は無意味な値となるので0を入れておいてもよい
    }

    // 2つのデータx,yが属する木が同じならtrueを返す
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    // データxが含まれる木の大きさを返す
    int size(int x)
    {
        return sizes[find(x)];
    }
};

#define MAX_N 100000

vector<vector<ll>> dp(110, vector<ll>(100100, 0));
vector<int> w(110);
vector<ll> v(110);

// 配るDP
int main()
{
    int N, W;
    cin >> N >> W;
    for (int i = 0; i < N; i++) {
        cin >> w.at(i) >> v.at(i);
    }

    for (int j = 0; j <= W; j++) {
        dp.at(0).at(j) = 0;
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j < w.at(i)) {
                dp.at(i + 1).at(j) = dp.at(i).at(j);
                continue;
            }
            dp.at(i + 1).at(j) = max(dp.at(i).at(j - w.at(i)) + v.at(i), dp.at(i).at(j));
        }
    }

    cout << dp.at(N).at(W) << endl;
}


Measured memory_bytes: 87296
#include<stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    char str[n+1];
    scanf("%s",str);
    if(n == 1 || n == 2 || n == 3){
        puts("0");
        return 0;
    }
    int rc[n+1],gc[n+1],bc[n+1];
    rc[0] = 0;
    gc[0] = 0;
    bc[0] = 0;
    for(register int i = 0;i < n;i++){
        rc[i+1] = rc[i] + (str[i] == 'R'?1:0);
        gc[i+1] = gc[i] + (str[i] == 'G'?1:0);
        bc[i+1] = bc[i] + (str[i] == 'B'?1:0);
    }

    long long int ans = 0;

    for(register int i = 0;i <= n-3;i++)for(register int k = i + 2;k < n;k++){
        if((str[i] == 'R' && str[k] == 'B') || (str[i] == 'B' && str[k] == 'R')){
            ans += gc[k] - gc[i+1];
            if(!((k - i)%2) && str[(i+k)/2] == 'G')ans--;
        }
        if((str[i] == 'R' && str[k] == 'G') || (str[i] == 'G' && str[k] == 'R')){
            ans += bc[k] - bc[i+1];
            if(!((k - i)%2) && str[(i+k)/2] == 'B')ans--;
        }
        if((str[i] == 'G' && str[k] == 'B') || (str[i] == 'B' && str[k] == 'G')){
            ans += rc[k] - rc[i+1];
            if(!((k - i)%2) && str[(i+k)/2] == 'R')ans--;
        }
    }
    printf("%lld",ans);
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  double a; cin>>a;
  coutd(2*a*PI);
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  vector<int> d(n);
  set<int> st_d;
  for (int i = 0; i < n; ++i)
  {
    cin>>d[i];
    st_d.insert(d[i]);
  }
  int m;
  cin>>m;
  std::vector<int> t(m);
  set<int> st_t;
  for (int i = 0; i < m; ++i)
  {
    cin>>t[i];
    st_t.insert(t[i]);
  }
  sort(t.begin(), t.end());
  sort(d.begin(), d.end());
  map<int,int> mp_d,mp_t;
  for(auto&& e: st_d) {
    auto u=upper_bound(d.begin(), d.end(),e);
    auto l=lower_bound(d.begin(), d.end(),e);
    mp_d.emplace(e,u-l);
  }
  for(auto&& e: st_t) {
     auto u=upper_bound(t.begin(), t.end(),e);
     auto l=lower_bound(t.begin(), t.end(),e);
     mp_t.emplace(e,u-l);
   }
  for(auto&& e: st_t) {
    if(mp_d.find(e)==mp_d.end()||mp_t.at(e)>mp_d.at(e)){
      cout<<"NO";
      return 0;
    }
  }
  cout<<"YES";
}

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

struct Node {
    int key;
    Node *prev, *next;
};

Node* NIL;

void init() {
    NIL = new Node();
    NIL->prev = NIL;
    NIL->next = NIL;
}

void insert(int key) {
    Node *x = new Node();
    x->key = key;
    x->next = NIL->next;
    NIL->next->prev = x;
    NIL->next = x;
    x->prev = NIL;
}

Node* listSearch(int key) {
    Node* cur = NIL->next;
    while (cur->key != key && cur != NIL) {
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node* tmp) {
    if (tmp == NIL) return;
    tmp->next->prev = tmp->prev;
    tmp->prev->next = tmp->next;
    delete tmp;
}

void deleteFirst() {
    deleteNode(NIL->next);
}

void deleteLast() {
    deleteNode(NIL->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void print() {
    Node* cur = NIL->next;
    while (cur != NIL) {
        if (cur != NIL->next) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

int main() {
    int n;
    char S[20];
    int key;
    
    init();
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s %d", S, &key);
        if (S[0] == 'i') insert(key);
        if (S[0] == 'd') {
            if (S[6] == 'F') deleteFirst();
            else if (S[6] == 'L') deleteLast();
            else deleteKey(key);
        }
    }
    
    print();
    return 0;
}

Measured memory_bytes: 34392
#include <bits/stdc++.h>
using namespace std;
int cnt[26];
int main(){
    long long ans = 0;
    string s;
    cin >> s;
    int n = s.length();
    for(int i = 0; i < n; i++){
        int let = s[i] - 'a';
        ans += cnt[let];
        cnt[let]++;
    }
    cout << 1ll * n * (n - 1) / 2 - ans + 1 << endl;
    return 0;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){ 
  ll n,m,q;
  cin >> n >> m >> q;
  vector<ll> a(q);
  vector<ll> b(q);
  vector<ll> c(q);
  vector<ll> d(q);
  rep(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }

  ll ans = 0;
  for (int i = 0; i < 1 << (n+m); i++){
    vector<ll> v;
    ll num = 0;
    ll pad = 0;
    rep(j,m+n){
      if(i&1){
        // cout << i << endl;
        continue;
      }
      if(i>>j&1){
        v.push_back(num);
      }else{
        num++;
      }
    }
    if(num!=m){
      continue;
    }else{
      // rep(i,n){
      //   cout << v[i];
      // }
      // cout << endl;
      ll tmp = 0;
      rep(i,q){
        if(v[b[i]] - v[a[i]] == c[i]){
          tmp += d[i];
        }
      }
      if(ans < tmp){
        ans = tmp;
        // rep(i,n){
        //   cout << v[i] << endl;
        // }
      }

    }
  }

  cout << ans << endl;

  return 0;
}



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

int main() {
  int N, b = 1, c = 0, e = 0;
  cin >> N;
  vector<int> B(N), P(N);

  for (int i = 0; i < N; i++) cin >> B.at(i);
  P = B;
  
  while (true) {
    P.at(b - 1) = 0;
    b = B.at(b - 1);
    c++;
    
    if (b == 2) {
      cout << c << endl;
      break;
    }
    
    for (int i = 0; i < c - 1; i++) {
      if (P.at(b - 1) == 0) {
        e = -1;
        break;
      }
    }
    if ( e == -1) {
      cout << e << endl;
      break;
    }
  }
}

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

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

Measured memory_bytes: 256
def is_palindrome(string):
  return True if string==string[::-1] else False
  
S = input()

N = len(S)
a = (N-1)//2
b = (N+3)//2 - 1

ans = 'No' 
if is_palindrome(S) and is_palindrome(S[:a]) and is_palindrome(S[b:]):
  ans = 'Yes' 

print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
bool issame(int *a,int *b,int n){
	for(int i = 0;i < n;++i){
		if(a[i] != b[i]) return false;
	}
	return true;
}
int main(){
	int n,seq[12],count,tmp[12];
	bool f;
	while(cin >> n,n){
		f = false;
		count = 0;
		for(int i = 0;i < n;++i){
			cin >> seq[i];
		}
		while(!f){
			for(int i = 0;i < n;++i){
				int same = 0;
				for(int j = 0;j < n;++j){
					if(seq[i] == seq[j]) ++same;
				}
				tmp[i] = same;
			}
			++count;
			f = issame(seq,tmp,n);
			for(int i = 0;i < n;++i){
				seq[i] = tmp[i];
				tmp[i] = 0;
			}
		}
		cout << count - 1 << endl;
		for(int i = 0;i < n;++i){
			if(i) cout << " ";
			cout << seq[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N, D = [int(i) for i in input().split()]
X = []
for i in range(N):
  X += [[int(i) for i in input().split()]]
a = 0
for i in range(N):
  for j in range(i):
    y = 0
    for k in range(D):
      y += (X[i][k] - X[j][k]) ** 2
    if y == int(y ** 0.5) ** 2:
      a += 1
print(a)

Measured memory_bytes: 3060
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
count = 0
for a in t:
    left = 0
    right = n
    while left < right:
        mid = (right + left) // 2
        if a == s[mid]:
            count += 1
            break
        elif a < s[mid]:
            right = mid
        else :
            left = mid + 1

print(count)



Measured memory_bytes: 16704
# ABC053 C - X: Yet Another Die Game
x = int(input())
n = 0
ans = 0
n = x//11

if 1<= x%11 <=6:
    ans = 2*n+1
elif 7<= x%11 <=10:
    ans = 2*n+2
elif x%11 == 0:
    ans = 2*n

print(ans)



Measured memory_bytes: 2940
def pc(x):
    return format(x, 'b').count('1')


N = int(input())
X = input()
Xo = int(X, 2)

count = 0
ans = 0
ori = pc(Xo)
X = list(X)

Xp = Xo%(ori + 1)
if ori == 1:
    Xm = 0
else:
    Xm = Xo % (ori - 1)

# for i in range(N-1, -1, -1):
for i in range(N):
    if ori == 1 and X[i] == '1':
        print(0)
        continue
    else:
        if X[i] == '1':
            # ans = Xm - pow(2, i, ori - 1)
            ans = Xm - pow(2, N-1-i, ori - 1)
            ans %= ori - 1
        else:
            # ans = Xp - pow(2, i, ori + 1)
            ans = Xp + pow(2, N-1-i, ori + 1)
            ans %= ori + 1
    count = 1
    while ans > 0:
        # count += 1
        # if ans == 1:
        #     break
        ans %= pc(ans)
        count += 1

   
    print(count)
    count = 1


Measured memory_bytes: 11040
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int N;
    cin >> N;
    string S;
    cin >> S;

    int num = 0, ans = 0;
    for(int i = 0; i < N; i++){
        S[i] == 'I' ? num++ : num--;
        ans = max(ans, num);
    }

    cout << ans << endl;

    return 0;
}

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


int main(){
  int32_t A,B,C,K,Max;
  cin >> A >> B >> C >> K;
  if(K <= A){
    Max = K;
  }else{
    Max = A;
    if((K-A) > B){
      Max -= (K-A-B);
    }
  }
  cout << Max << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;


int main(){
    int n; cin >> n;
    ll k; cin >> k;
    ll K=k;
    int keta=0;
    string ks="";
    while(K){
        if(K%2==0) ks+='0';
        else ks+='1';
        K/=2;
        keta++;
    }

    int  b[42][2];
    rep(i,41)rep(j,2) b[i+1][j]=0;
    rep(i,n){
        ll a; cin >> a;
        rep(j,41){
            if(a%2==0) b[j+1][0]++;
            else b[j+1][1]++;
            a/=2;
        }
    }
    ll dp[42][2];
    if(k!=0){
        dp[keta][0]=b[keta][1]*pow(2,keta-1);
        dp[keta][1]=b[keta][0]*pow(2,keta-1);
        //cout << dp[keta][0] << ' ' << dp[keta][1] << endl;
        for(int j=keta-1; j>0; j--){
            ll ad=(ll)pow(2,j-1);
            if(ks[j-1]=='1'){
                dp[j][0]=max(dp[j+1][0]+max(b[j][0],b[j][1])*ad,dp[j+1][1]+b[j][1]*ad);
                dp[j][1]=dp[j+1][1]+b[j][0]*ad;
            }
            else{
                dp[j][0]=dp[j+1][0]+max(b[j][0],b[j][1])*ad;
                dp[j][1]=dp[j+1][1]+b[j][1]*ad;
            }
        }
    }
    else{
        dp[1][0]=dp[1][1]=0;
    }
    ll ans=0;
    for(int i=41; i>keta; i--){
        ans+=b[i][1]*pow(2,i-1);
    }
    cout << max(dp[1][0],dp[1][1])+ans << endl;
return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int odd = 0;
	REP(i,n){
		int a;
		cin >> a;
		if(a%2==1)odd++;
	}
	if(odd%2==1)cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

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

#define MAX_P (1000010)

int fact[MAX_P]; // n! mod p のテーブル O(p)

constexpr int MOD = 1e9+7;

int extgcd(int a, int b, int &x, int &y)
{
    int d = a;
    if (b != 0) {
  d = extgcd(b, a%b, y, x);
  y -= (a / b) * x;
    } else {
  x = 1; y = 0;
    }
    return d;
}

int mod_inverse(int a, int m)
{
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

int mod_fact(int n, int p, int &e)
{
    e = 0;
    if (n == 0) return 1;
    int res = mod_fact(n/p, p, e);
    e += n/p;
    if (n / p % 2 != 0) return res * (p - fact[n % p]) % p;
    return res * fact[n % p] % p;
}

int mod_comb(int n, int k, int p)
{
    if (n < 0 || k < 0 || n < k) return 0;
    int e1, e2, e3;
    int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n-k, p, e3);
    if (e1 > e2 + e3) return 0;
    return a1 * mod_inverse(a2 * a3 % p,p) % p;
}

signed main()
{
  fact[0] = 1;
  for(int i=0; i<MAX_P; i++) fact[i + 1] = fact[i] * (i + 1), fact[i + 1] %= MOD;
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  ll ans = 0LL;
  for(int i = B; i < W; i++) {
    ll x = mod_comb(H-A-1 + i, i, MOD);
    ll y = mod_comb(A-1 + W-i-1, A-1, MOD);
    ans = (ans + (x * y) % MOD + MOD) % MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define ul unsigned long long
#define ll long long
#define ld long double

int score(int s[100][100],int h, int w) {
  int c[100][100];
  fill(c[0], c[0] + 10000, INT_MAX);
  c[0][0] = s[0][0];
  for (int i = 0; i < h + w - 1; i++)
  {
    for (int j = 0; j < h; j++)
    {
      if (i - j >= w || i - j < 0)
        continue;
      int ro = j, co = i - j;
      if (ro < h - 1) {
        c[ro + 1][co] = min(c[ro + 1][co], c[ro][co] + s[ro + 1][co] - (s[ro][co] && s[ro + 1][co]));
      }
      if (co < w - 1) {
        c[ro][co + 1] = min(c[ro][co + 1], c[ro][co] + s[ro][co + 1] - (s[ro][co] && s[ro][co + 1]));
      }
    }
  }
  return c[h - 1][w - 1];
}

int main()
{
  int h,w,s[100][100];
  cin>>h>>w;
  char cs;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cin>>cs;
      s[i][j]=cs=='#';
    }
  }
  //cout <<dfs(s,h,w,0,0,0)<<endl;

  cout<<score(s,h,w)<<endl;
  return 0;
}


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


}

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

using namespace std;
int n;
int main() {
	cin>>n;
	long long sum=0;
	for(int i=1;i<=n;i++){
		if(i%3==0||i%5==0) continue;
		sum+=i;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {

	int num_people;
	cin >> num_people;

	vector<int> abs_sub(num_people);
	for (int i = 0; i < num_people; i++){

		cin >> abs_sub[i];
	}

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

	for (int i = 0; i < num_people; i++){

		if (abs_sub[i] != ( i + 2 - num_people % 2) / 2 * 2 - 1 + num_people % 2){

			cout << 0;
			return 0;
		}
	}

	cout << modpow(2,num_people/2,1000000007);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

// cout << fixed << setprecision(12)

int main(){
  
  lint N; cin >> N;
  N%=1000;
  if(N==0) cout << '0' << endl;
  else cout << 1000-N << endl;
}
 

Measured memory_bytes: 3632
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     int i,n,t,p=INT_MAX,j=0,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     string s;
     cin>>s;
     for(i=0;i<s.size();i++){
        if(s[i]=='7'){
            l=1;
        }
     }
     (l==1)?cout<<"Yes"<<endl:cout<<"No"<<endl;

     return EXIT_SUCCESS;
}



Measured memory_bytes: 3640
#include<stdio.h>

// output
void trace(int A[], int N) {
  int i;
  for (i = 0; i < N; i++) {
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

// insertion sort
void insertaion_sort(int A[], int N) {
  int i, j, v;
  for (i = 1; i < N; i++) {
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A, N);
  }
}

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

  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &A[i]);

  trace(A, N);
  insertaion_sort(A, N);

  return 0;
}



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

int ask(int a, int b){
    cout << "? " << a << " " << b << endl << flush;
    int ret;
    cin >> ret;
    return ret;
}

void answer(vector<int> v){
    cout << "!";
    for(int x : v)  cout << " " << x;
    cout << endl << flush;
}

int main(){
    int n, s, t;
    cin >> n >> s >> t;
    int d = ask(s, t);
    vector<int> use;
    for(int i = 1; i <= n; i++){
        if(ask(s, i) + ask(i, t) == d)  use.push_back(i);
    }
    vector<pair<int,int>> vp;
    for(int x : use){
        vp.push_back({ask(x, s), x});
    }
    sort(vp.begin(), vp.end());
    vector<int> ans;
    for(auto p : vp)    ans.push_back(p.second);
    answer(ans);
    return 0;
}


Measured memory_bytes: 4652
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

ll f(ll m, ll n)
{
  if(m==0||n==0) return 0;
  ll a=max(m,n);
  ll b=min(m,n);
  return m+(2*(a/b)-1)*b+f(b,a%b);
}

int main()
{
  ll n,x; cin>>n>>x;
  cout<<x+f(n-x,x)<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < n; i++)

int main()
{
	int64_t n, k, c;
	cin >> n >> k >> c;
	string str;
	cin >> str;
	vector<int64_t> hataraku_L(n, 0);
	vector<int64_t> hataraku_R(n, 0);
	int64_t temp = 0;
	int64_t temp1 = n - 1;
	rep(i, k)
	{
		for(int64_t j = temp; j < n; j++)
		{
			if (str[j] == 'o')
			{
				hataraku_L[j] = i + 1;
				temp = j + c + 1;
				break;
			}
		}
		for (int64_t j = temp1; j >= 0; j--)
		{
			if (str[j] == 'o')
			{
				hataraku_R[j] = k - i;
				temp1 = j - c - 1;
				break;
			}
		}
	}
	
	rep(i, n)
	{
		
		if (hataraku_L[i] == hataraku_R[i] && hataraku_R[i] != 0)
		{
			cout << i + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4996
using System;

namespace PapersPlease
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            string[] test = Console.ReadLine().Split(' ');

            bool hantei = true;
            foreach(string kazu in test)
            {
                if(int.Parse(kazu) % 2 == 1)
                {
                    continue;
                }
                if(int.Parse(kazu) % 3 != 0 && int.Parse(kazu) % 5 != 0)
                {
                    hantei = false;
                    break;
                }
            }
            if(hantei)
            {
                Console.WriteLine("APPROVED");
            }
            else
            {
                Console.WriteLine("DENIED");
            }
        }
    }
}

Measured memory_bytes: 13140
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *a, const void *b) { return *(int *)b - *(int *)a; }
int main() {
	int n, ans = 0;
	int l[2000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &l[i]);
	}
	qsort(l, n, sizeof(int), cmpint);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (l[i] < l[j] + l[k]) {
					ans++;
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int N;
vector<int> cnt(3);
vector<int> p(3);

int foo(int x, int t) {
  for (int j = 0; j < t; j++) {
    if (p.at(j) == x) {
      cnt.at(j)++;
      return t;
    }
  }
  if (t < 3) {
    p.at(t) = x;
    cnt.at(t) = 1;
    return t+1;
  }else {
    return -1;
  }
}

int answer(bool isOK) {
  cout << (isOK ? "Yes" : "No") << endl;
  exit(0);
}

void vSwap(int i) {
  swap(p.at(0), p.at(i));
  swap(cnt.at(0), cnt.at(i));
}

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  cin >> N;
  int t = 0;
  for (int i = 0; i < N; i++) {
    int x; cin >> x;
    t = foo(x, t);
    if (t < 0)  answer(false);
  }
  if (t == 1 && p.at(0) == 0)  answer(true);
  if (t == 2 && p.at(1) == 0)  vSwap(1);
  if (t == 2 && p.at(0) == 0 && cnt.at(1) == 2 * cnt.at(0)) answer(true);
  if (t == 3 && p.at(0) == (p.at(1) ^ p.at(2)) &&
      cnt.at(0) == cnt.at(1) && cnt.at(0) == cnt.at(2)) answer(true);
  answer(false);
  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, Z, W;

int main()
{
	in >> N >> Z >> W;
	std::vector<LL>a(N);
	rep(i, N) in >> a[i];
	if (N == 1) out << abs(a[0] - W) << std::endl;
	else out << std::max(abs(a[N - 1] - a[N - 2]), abs(a[N - 1] - W)) << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  long n;
  cin >> n;
  string s = to_string(n);
  int ha = 0;
  rep (i, s.size()) {
    ha += s[i] - '0';
  }
  if (n % ha == 0) Yes;
  else No;
  return 0;
}



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

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+10;
const int MAX2=2e5+4;
const int MAAX=2e18;
const int MOD=1e9+7;
int n,a[MAX];
int dp[MAX];
int fun(int idx)
{
    if(idx==n)
    {
        return 0;
    }

    int &ret=dp[idx];
    if(ret!=-1)
    {
        return ret;
    }
    ret=INT_MAX;
    if(idx+2<=n)
    {
        ret=abs(a[idx+2]-a[idx])+fun(idx+2);
    }
    ret=min(ret,abs(a[idx+1]-a[idx])+fun(idx+1));
    return ret;
}
in main()
{
    memset(dp,-1,sizeof dp);
cin>>n;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
}
cout<<fun(1)<<endl;
    return 0;
}


Measured memory_bytes: 4992
N = int(input())
line = [int(i) for i in input().split()]
sum = 1
line.sort(reverse=True)
if line[len(line) -1]== 0:
  print(0)
  exit()
for num in line:
  sum = sum * num
  if sum > 10 ** 18:
    print(-1)
    exit()
print(sum)

Measured memory_bytes: 21556
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll d = N * A;
    ll t = B;
    cout << ((d > t) ? t : d) << endl;

    return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int a,b;
	cin >>a>>b;
	
	cout <<(a-1)*(b-1)<< endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){

	vector<vector<int>>cnt(10, vector<int>(10, 0));
	
	while(1){
		int x, y, c;
		if(scanf("%d,%d,%d", &x, &y, &c) == EOF)break;
		if(c == 1){
			for(int i = -1; i <= 1; i++){
				for(int j = -1; j <= 1; j++){
					if(abs(i) + abs(j) > 1) continue;
					int xx = x + i, yy = y + j;
					if(0 <= xx && xx < 10 && 0 <= yy && yy < 10)cnt[yy][xx]++;
				}
			}
		}
		else if(c == 2){
			for(int i = -1; i <= 1; i++){
				for(int j = -1; j <= 1; j++){
					int xx = x + i, yy = y + j;
					if(0 <= xx && xx < 10 && 0 <= yy && yy < 10)cnt[yy][xx]++;
				}
			}
		}
		else{
			for(int i = -2; i <= 2; i++){
				for(int j = -2; j <= 2; j++){
					if(abs(i) + abs(j) > 2) continue;
					int xx = x + i, yy = y + j;
					if(0 <= xx && xx < 10 && 0 <= yy && yy < 10) cnt[yy][xx]++;
				}
			}
		}
		
	}
	
	int free = 0;
	int maxi = 0;
	rep(i, 10){
		rep(j, 10){
			if(cnt[i][j] == 0) free++;
			maxi = max(maxi, cnt[i][j]);
		}
	}
	
	cout << free << endl << maxi << endl;
	
	return 0;
}

Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>

using namespace std;


int main() {
	map<int, int> mp;
	long long int n, m=0,tmp=0,ax=0,k=0,t[500000],p[500000],x,y,res[5000],a,b,c;
	string str, str2[5000];
	cin >>n;
	for (int i = 1; i <= n; i++) {
		cin >> t[i];
		p[i] = t[i];
	}
	sort(t + 1, t + n + 1);

	for (int i = 1; i <= n; i++) {
		if (p[i] < t[n / 2 + 1]) {
			cout << t[n / 2 + 1] << endl;
		}
		else {
			cout << t[n / 2 ] << endl;
		}
	}
}

Measured memory_bytes: 9344
program ABC049C;
uses StrUtils;
var
	T: array[0..3] of string = ('dream','dreamer','erase','eraser');
	s: string;
	i,c,l,k: integer;
begin
	for i:=0 to 3 do begin
		T[i]:=ReverseString(T[i]);
	end;
	readln(s);
	s:=ReverseString(s);
	c:=0;
	l:=Length(s);
	while c<l do begin
		k:=-1;
		for i:=0 to 3 do begin
			if copy(s,c+1,Length(T[i]))=T[i] then begin
				k:=Length(T[i]);
			end;
		end;
		if k<0 then begin
			writeln('NO');
			exit;
		end;
		c:=c+k;
	end;
	writeln('YES');
end.


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

int main() {
    int n , ans;
    cin>>n;
    ans=1000 -(n % 1000);
    if(ans==1000) cout<<0<<endl;
    else cout<<ans<<endl;
    
    return 0;
    
    
}

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

using ll = long long;
const ll MOD = 998244353;
const ll INF = 1e18;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    int ans = 0;
    rep(i, N - 2) {
        for (int j = i + 1; j < N - 1; j++) {
            int it = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();
            ans += max(0, it - 1 - j);
            //cout << i << " " << j << " " << it << " " << ans << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int s,jam,menit,detik;
	scanf("%d",&s);
	jam=s/3600;
	menit=(s%3600)/60;
	detik=(s%3600)%60;
	printf("%d:%d:%d\n",jam,menit,detik);
	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

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

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

int solve(int a,int c,int d){
	int ret=a;
	ret-=a/c;
	ret-=a/d;
	ret+=a/lcm(c,d);
	return ret;
}

signed main(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	A--;
	cout<<solve(B,C,D)-solve(A,C,D)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}

int main(){
    ll n,k;cin >> n >>k;
    ll ans=INF;
    vl a(n);rep(i,n)cin >> a[i];
    sort(all(a));
    rep(i,n-k+1){
        chmin(ans,a[i+k-1]-a[i]);
    }
    cout << ans <<endl;
}

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

const int MAX_N = 100;
bool adj[MAX_N][MAX_N];

void dfs(int node, vector<int>& visited) {
    visited[node] = 1;
    for (int i = 0; i < MAX_N; i++) {
        if (adj[node][i] && !visited[i]) {
            dfs(i, visited);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    pair<int, int> bridges[m];
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a][b] = adj[b][a] = true;
        bridges[i] = make_pair(a, b);
    }
    int ans = 0;
    for (int i = 0; i < m; i++) {
        int a = bridges[i].first, b = bridges[i].second;
        adj[a][b] = false;
        adj[b][a] = false;
        vector<int> visited(MAX_N, 0);
        dfs(0, visited);
        bool flag = true;
        for (int i = 0; i < n; i++) {
            if (visited[i]) continue;
            flag = false;
        }
        adj[a][b] = true;
        adj[b][a] = true;

        if (flag) continue;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    double ans = 0;
    rep(i,n){
        double x;
        cin >> x;
        string s;
        cin >> s;
        if(s == "JPY"){
            ans += x;
        }else{
            ans += x*380000;
        }
    }
    printf("%.6f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll inf=1e18+7;

//辺に注目
//辺の両端の部分木の大きさが等しいところは，またげる回数が最大なので，その辺でまたげば最も距離を稼げる
//両端の部分木の大きさで等しいところがなければ，最も多く出入りできる点でまたぐことを考える．それは重心である．

typedef struct edge{
	ll a,b,c,sa,sb;
} edge;
ll n,subtree[100010]={},visited[100010]={},mode=0,ans=0;
edge e[100010];
vector<ll> v[100010];

ll dfs(ll p){
	visited[p]=1;
	ll sum=1;
	rep(i,v[p].size()){
		edge ed = e[v[p][i]];
		ll q = ed.a;
		if(q==p)q=ed.b;
		if(visited[q]==0){
			sum+=dfs(q);//まだ探索してない場所のみ加算
		}
	}
	return subtree[p]=sum;
}

int main(void){
	cin>>n;
	//辺に注目して解く
	reg(i,1,n-1){
		ll x,y,z;
		cin>>x>>y>>z;
		e[i].a=x;
		e[i].b=y;
		e[i].c=z;
		v[x].push_back(i);
		v[y].push_back(i);
	}
	//１を根とした時の自分＋子孫の大きさを求める．
	dfs(1);
	//辺の両端の部分木の大きさを求める
	reg(i,1,n-1){
		e[i].sa=subtree[e[i].a];
		e[i].sb=subtree[e[i].b];
		if(e[i].sa>e[i].sb){
			e[i].sa=n-e[i].sb;
		}else{
			e[i].sb=n-e[i].sa;
		}
		ans+=2*min(e[i].sa,e[i].sb)*e[i].c;
		if(e[i].sa==e[i].sb)ans-=e[i].c;
	}
	//重心があるかどうか探す
	reg(i,1,n){
		bool ok=true;
		rep(j,v[i].size()){
			edge ed=e[v[i][j]];
			if(i==ed.b){
				if((n%2==0 && ed.sa>=n/2)||(n%2==1 && ed.sa>n/2)){
					ok=false;
				}
			}else{
				if((n%2==0 && ed.sb>=n/2)||(n%2==1 && ed.sb>n/2)){
					ok=false;
				}
			}
		}
		if(ok){
			ll smallest=inf;
			rep(j,v[i].size()){
				smallest=min(smallest,e[v[i][j]].c);
			}
			ans-=smallest;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 16512
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    ll n, k;  cin >> n >> k;
    cout << min(n % k, abs(n % k - k)) << endl;
	return 0;
}


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

using namespace std;

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

	int A = S / 100;
	int B = S % 100;

	if (A == 0 || B == 0) {
		if (0 < A && A <= 12 && B == 0) {
			cout << "MMYY" << endl;
		}
		else if (A == 0 && 0 < B && B <= 12) {
			cout << "YYMM" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
	else if (A <= 12 && B <= 12) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (A <= 12 && B > 12) {
		cout << "MMYY" << endl;
	}
	else if (A > 12 && B <= 12) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}


	return 0;
}

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

const int mN = 1e5+5;
const int MOD = 1e9+7;
int n;
vector<int> graph[mN];

typedef long long LL;
LL cnt[mN][2];
int parent[mN];
void dfs(int u) {
    cnt[u][0] = 1;
    cnt[u][1] = 1;
    for (int v : graph[u]) if (parent[u] != v) {
        parent[v] = u;
        dfs(v);
        cnt[u][0] *= cnt[v][0] + cnt[v][1];
        cnt[u][0] %= MOD;
        cnt[u][1] *= cnt[v][0];
        cnt[u][1] %= MOD;
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    cin >> n;
    for (int i=1,x,y; i<n; i++) {
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    fill(parent, parent+mN, 0);
    dfs(1);
    cout << (cnt[1][0] + cnt[1][1]) % MOD << "\n";
	return 0;
}


Measured memory_bytes: 14592
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <numeric>

using namespace std;

char left_[16] = "qwertasdfgzxcvb";
char right_[12] = "yuiophjklnm";

int main(){
    char str[33] = {'\0'};
    while(cin >> str, strcmp(str,"#")){
        int l = 0, r = 0;
        int ll = 0, rr = 0;
        int cnt = 0;
        for(int i=0; i<strlen(str); i++){
            for(int j=0; j<15; j++){
                if(str[i] == left_[j]){
                    r=0;
                    l++;
                    break;
                }
            }
            for(int j=0; j<11; j++){
                if(str[i] == right_[j]){
                    l=0;
                    r++;
                    break;
                }
            }
            if(((ll-rr<0)&&(l-r>0)) || ((rr-ll<0)&&(r-l>0))){
                cnt++;
            }
            ll = l; rr = r;
        }
        cout << cnt << endl;
        for(int i=0; i<32; i++) str[i] = '\0';
    }
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
vector<int> v[200005];

int main(void) {
    int n;
    cin >> n;
    rep(i, 0, n-1) {
        int a;
        scanf("%d", &a);
        v[a-1].pb(i);
    }

    rep(i, 0, n) printf("%d\n", sz(v[i]));
    


	return 0;
}


Measured memory_bytes: 14656
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    for(int i=3; i<=num; i++){
      int check = i;
      if(check%3==0){
          System.out.printf(" %d", i);
      }else{
          while(true){
               if ( check % 10 == 3 ){
                 System.out.printf(" %d", i);
                 break;
               }else{
                 check /= 10;
                 if(check==0)
                    break;
               }
          }
      }
    }
    System.out.printf("\n");
  }
}



Measured memory_bytes: 38044
n = int(input())
a = list(map(int, input().split()))

#dp[l][r] = [l, r)区間のスライムを合体するときのコストの最小値
dp = [[-1]*(n+1) for i in range(n+1)]
for i in range(n):
    dp[i][i] = 0

#cost[r]-cost[l] = [l, r)区間を合計したときのスライムの総和
cost = [0]*(n+1)
for i in range(n):
    cost[i+1] = cost[i] + a[i]

#メモ化再帰でdp[0][n]求める
def dfs(l, r):
    if dp[l][r] != -1:
        return dp[l][r]
    elif (r - l) == 1:
        dp[l][r] = 0
        return dp[l][r]
    else:
        res = float("inf")
        for k in range(l + 1, r):
            #dp[l][k] + dp[k][r] + 合体に必要なコスト
            res = min(res, dfs(l, k) + dfs(k, r) + (cost[r] - cost[l]))
        dp[l][r] = res
    return dp[l][r]

dfs(0, n)
print(dp[0][n])

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	long long N,sum = 0,count = 0,S = 0;
  int sw = 0;
  cin >> N;
  vec(a,long long,N,0);
  vec(b,long long,N,0);
  vec(dist,long long,N,0);
  froop1(0,N){
   cin >> a.at(i);
    dist.at(i) = a.at(i);
  }
  
  froop1(0,N){
    cin >> b.at(i);
    if(a.at(i) < b.at(i)){
      sw = 1;
      count++;
    }
    dist.at(i) -= b.at(i);
    if(dist.at(i) >= 0){
    sum += dist.at(i);
    }
    if(b.at(i) - a.at(i) > 0){
    S += b.at(i) - a.at(i);
    }
  }
  
  if(sw == 0){
    cout << 0 << endl;
    return 0;
  }
  if(sum < S){
    cout << -1 << endl;
    return 0;
  }
  
  sort(dist.begin(),dist.end(),greater<long long>());
  long long c = 0,i = 0;
  while(S > 0){
   S -= dist.at(i); 
    i++;
    c++;
  }
	cout << count + c << endl;
return 0;
}

Measured memory_bytes: 5616
N = int(input())
H = []
for _ in range(N):
    h = tuple(map(int, input().split()))
    H.append(h)

dp = [H[0]]
for i in range(1, N):
    dp.append([
        max(dp[i-1][1] + H[i][0], dp[i-1][2] + H[i][0]),
        max(dp[i-1][0] + H[i][1], dp[i-1][2] + H[i][1]),
        max(dp[i-1][0] + H[i][2], dp[i-1][1] + H[i][2]),
    ])
print(max(dp[-1]))


Measured memory_bytes: 40216
N,M=map(int,input().split())
s = []
for _ in range(M):
    s.append(list(map(lambda x:int(x)-1,input().split()))[1:])
p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    fl = True
    for j in range(M):
        cnt = 0
        for sw in s[j]:
            if (i >> sw) & 1:
                cnt += 1
        if cnt % 2 != p[j]:
            fl = False
            break
    if fl:
        ans += 1
print(ans)

Measured memory_bytes: 9160