akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

struct Dice {
  int f[6];

  void roll(char ch) {
    if (ch == 'N') {
      int t = f[0];
      f[0] = f[1];
      f[1] = f[5];
      f[5] = f[4];
      f[4] = t;
    } else if (ch == 'E') {
      int t = f[0];
      f[0] = f[3];
      f[3] = f[5];
      f[5] = f[2];
      f[2] = t;
    } else if (ch == 'W') {
      int t = f[0];
      f[0] = f[2];
      f[2] = f[5];
      f[5] = f[3];
      f[3] = t;
    } else if (ch == 'S') {
      int t = f[0];
      f[0] = f[4];
      f[4] = f[5];
      f[5] = f[1];
      f[1] = t;
    }
  }

  void spin() {
    int t = f[1];
    f[1] = f[2];
    f[2] = f[4];
    f[4] = f[3];
    f[3] = t;
  }

  int top() {
    return f[0];
  }

  int left() {
    return f[3];
  }

  int right() {
    return f[2];
  }

  int front() {
    return f[1];
  }

  bool equal(Dice d) {
    return f[0] == d.f[0] &&
      f[1] == d.f[1] &&
      f[2] == d.f[2] &&
      f[3] == d.f[3] &&
      f[4] == d.f[4] &&
      f[5] == d.f[5];
  }
};

bool equal(Dice d1, Dice d2) {
  bool flag = 0;

  for (int i = 0; i < 4; i++) {
    d1.spin();

    for (int j = 0; j < 4; j++) {
      if (flag) break;
      d2.roll('N');
      flag = d1.equal(d2);
    }
  }

  d1.roll('E');
  for (int j = 0; j < 4; j++) {
    if (flag) break;
    d2.roll('N');
    flag = d1.equal(d2);
  }

  d1.roll('W');
  d1.roll('W');
  for (int j = 0; j < 4; j++) {
    if (flag) break;
    d2.roll('N');
    flag = d1.equal(d2);
  }

  return flag;
}

int main() {
  Dice d1, d2;

  for (int i = 0; i < 6; i++) cin >> d1.f[i];
  for (int i = 0; i < 6; i++) cin >> d2.f[i];

  bool flag = 0;
  flag = equal(d1, d2);

  cout << (flag ? "Yes" : "No") << endl;

  return 0;
}



Measured memory_bytes: 3112
#include<iostream>
using namespace std;
int main()
{
    // 1行目
    int n;
    cin >> n;
    
    int a[n];
	a[0] = 0;
	
	int max = 0;
	int min = 1000000000; //10^9
	
    for (int i = 1; i < n + 1; i++) {
        a[i] = 0;
    	cin >> a[i];
	
    	if( max < a[i]){
    		max = a[i];
    	}
    	if( min > a[i]){
    		min = a[i];
    	}
    }
	
	// 結果
	cout << max - min << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  string c;
  cin>>c;
  int r = 0, w = 0;
  REP(i, n) if(c[i] == 'R') r++;
  int br = -1;
  for(int i = n - 1; i >= 0; i--){
    if(c[i] == 'R'){
      br = i;
      break;
    }
  }
  int ans = 0;
  int cnt = 0;
  REP(i, n){
    if(cnt == r) break;
    if(c[i] == 'R'){
      cnt++;
      continue;
    }
    c[i] = 'R';
    c[br] = 'W';
    ans++;
    cnt++;
    for(int j = br - 1; j >= 0; j--){
      if(c[j] == 'R'){
        br = j;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int l,r;
  int sum = 0;
  for(int i = 0; i < N; i++){
  	cin >> l >> r;
    sum += (r -l + 1);
  }
  cout << sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    unsigned long long int h;
    cin>>h;
    unsigned long long int c=1;
    while(h>0)
    {
        h=h/2;
        c=c*2;
    }
    cout<<c-1;
    return 0;
}


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

int main()
{
  int n,x,h;
  h=0;
  cin>>n;
  x=n*25/27;
  for(int i=x-1;i<=x+1;i++)
  {
    if(i*27/25==n)
    {
      h=1;
      cout<<i<<endl;
      break;
    }
  }
  if(h==0)
    cout<<":("<<endl;
}

Measured memory_bytes: 3512
///Code by: Luis Alejandro
///Handle: Sekai
///Country: Cuba

#include <bits/stdc++.h>
#define endl '\n'
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")

using namespace std;

typedef unsigned long long ull;
typedef long long lld;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN=1e5+5;
const int MOD=1e9+7;
const int INF=1e9;
const ld PI=acos(-1);
const ld EPS=1e-9;

#define lg2(x) 31-__builtin_clz(x)
#define logx(a,b) (log(a)/log(b))
#define pow2(a) a*a
#define pow3(a) a*a*a
#define lcm(a,b) (a*b)/__gcd(a,b)

pii mkp(int a, int b){
    if(a>b)swap(a,b);
    return make_pair(a,b);
}

int mod_pow(int a, int b){
    if(!b)return 1;
    if(b&1)return mod_pow(a,b-1)*a%MOD;
    int power=mod_pow(a,b>>1);
    return power*power%MOD;
}

int modular_inverse(int a){
    return mod_pow(a,MOD-2);
}

vector<int> movy={0,0,1,-1};
vector<int> movx={1,-1,0,0};

void solve(){
    int a, b, c, cnt5=0, cnt7=0;
    cin>>a>>b>>c;
    if(a==5)cnt5++;
    if(b==5)cnt5++;
    if(c==5)cnt5++;
    if(a==7)cnt7++;
    if(b==7)cnt7++;
    if(c==7)cnt7++;
    if(cnt5==2 && cnt7==1){
        cout<<"YES"<<endl;
        return;
    }
    cout<<"NO"<<endl;
}

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("IN.txt","r",stdin);
        //freopen("OUT.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

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

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

int main() {
    int n, c;
    cin >> n >> c;
    vector<int> a(n), b(n);
    for (auto &&i : a) scanf("%d", &i);
    for (auto &&i : b) scanf("%d", &i);
    vector<ll> ans(1, 1);
    for (int i = 0; i < n; ++i) {
        vector<ll> u(c+1), ans2(c+1);
        for (int j = a[i]; j <= b[i]; ++j) {
            ll x = 1;
            for (int k = 0; k <= c; ++k) {
                (u[k] += x) %= MOD;
                (x *= j) %= MOD;
            }
        }
        for (int j = 0; j < ans.size(); ++j) {
            for (int k = 0; k < u.size(); ++k) {
                if(j+k > c) continue;
                (ans2[j+k] += ans[j]*u[k]) %= MOD;
            }
        }
        ans = ans2;
    }
    cout << ans[c] << "\n";
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

template<typename T> T my_lcm(T a, T b){
	return a * b / my_gcd(a, b);	
}

template<typename T> struct UF {
    vector<int> par;
    vector<T> sz;

    UF(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }

    T size_of_tree(int x) {
        return sz[find_root(x)];
    }
};

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

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int M = 20000;
    vector<int> A(n), B(n);
    rep(i, n) {
        A[i] = M * (i + 1);
        B[i] = M * (n - i);
    }

    rep(i, n) A[p[i] - 1] += i + 1;

    rep(i, n) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    rep(i, n) {
        if (i) cout << " ";
        cout << B[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
long a,b,q,s[100002],t[100002],ans,i,j,k,x,c,d;
int main(){
  scanf("%ld%ld%ld",&a,&b,&q);
  for(i=1;i<=a;i++)scanf("%ld",&s[i]);
  s[a+1]=1e18;s[0]=-1e18;
  sort(s,s+a+2);
  for(i=1;i<=b;i++)scanf("%ld",&t[i]);
  t[b+1]=1e18;t[0]=-1e18;
  sort(t,t+b+2);
  for(i=1;i<=q;i++){
    scanf("%ld",&x);
    c=lower_bound(s,s+a+2,x)-s;
    d=lower_bound(t,t+b+2,x)-t;
    ans=1e18;
    for(j=c-1;j<c+1;j++){
      for(k=d-1;k<d+1;k++){
        ans=min(ans,abs(x-s[j])+abs(s[j]-t[k]));
        ans=min(ans,abs(x-t[k])+abs(t[k]-s[j]));
      }
    }
    printf("%ld\n",ans);
  }
  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    string s;
    getline(cin, s);
    repi(i, s.length(), 0)
    {
        cout << (char)(isalpha(s.at(i)) ? isupper(s.at(i)) ? tolower(s.at(i)) : toupper(s.at(i)) : s.at(i));
    }
    cout << endl;
    return 0;
}


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

int main(){
  int H,W;
  cin>>H>>W;
  vector <vector <char>> A(H, vector <char>(W));
   for (int i = 0; i < H; ++i) {
   for (int j = 0; j < W; ++j) {
   cin >> A[i][j];
}
}
////////
  vector<int> gyou;
  vector<int> retsu;
  vector<int> copy{0};
  for(int i=0;i<H;++i){
    int count = 0;
    for(int j=0;j<W;++j){
      if(A[i][j]=='.'){
        count += 1;
      }
    }
  if(count == W){gyou.push_back(i);}
  }
 
  for(int j=0;j<W;++j){
    int count = 0;
    for(int i=0;i<H;++i){
      if(A[i][j]=='.'){
        count += 1;
      }
    }
  if(count == H){retsu.push_back(j);}
  }
//////////////
gyou.push_back(10000);
retsu.push_back(10000);
int a =0;
for (int i = 0; i < H; ++i) {
    a=0;
    if(gyou[0]==i){
      gyou.erase(gyou.begin());}
    else{
      for(int j=0;j<W;++j) {
        copy[0] = retsu[a];
        if(copy[0]==j){
          a+=1;
        }
        else{
          cout<<A[i][j];
        }
      }
      cout<<endl;
    }

}
}

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

int main(){

  string a, b, c;
  cin >> a >> b >> c;
  
  a += 'z';
  b += 'z';
  c += 'z';
  int counta, countb = -1, countc = -1;
  char next = 'a';
  
  while(true){
  	if(next == 'a'){
          if(a.at(counta) == 'z'){
  		  cout << 'A' << endl;
    	  break;
  		  }
  			else if(a.at(counta) == 'a'){
    		counta += 1;
      		next ='a';
    		}
   			else if(a.at(counta) == 'b'){
    		countb += 1;
      		next ='b';
    		}
    		else {
    		countc += 1;
        	next ='c';
    		}
   		 }
    
    else if(next == 'b'){
          
          if(b.at(countb) == 'z'){
  		cout << 'B' << endl;
    	break;
  	}
          
          
  			else if(b.at(countb) == 'a'){
    		counta += 1;
      		next ='a';
    		}
    		else if(b.at(countb) == 'b'){
    		countb += 1;
      		next ='b';
   			 }
    		else {
    		countc += 1;
        	next ='c';
   			}
   		 }
    
       else	if(next == 'c'){
          
          if(c.at(countc) == 'z'){
  		cout << 'C' << endl;
    	break;
 	 }
          
  			else if(c.at(countc) == 'a'){
    		counta += 1;
      		next ='a';
    		}
    		else if(c.at(countc) == 'b'){
    		countb += 1;
      		next ='b';
    		}
    	else {
    		countc += 1;
        	next ='c';
   			 }
   		 }
    
    
  		}
 	 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
	int n;
	cin >> n;
	string yes = "Yes", no = "No";
	cout << (n%10 == 9 || n /10 == 9 ?yes : no) << endl;
	return 0;
}

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

int main() {
  int A, B,C,D;
  cin >> A >> B >> C >> D;

  if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  if ( A+B < C+D ) {
    cout << "Right" << endl;
  }
    
}


Measured memory_bytes: 3572
#include <iostream>
using namespace std;
 
int main() {
    long long N;

    cin >> N;

    string ans = "";

    while (N > 1) {
        N -= 1;

        ans += char((int('a') + int(N % 26)));

        N /= 26;
    }

    if (N != 0) {
        N -= 1;
        ans +=  char(int('a') + N);

    }

    for (int i = 1; i <= int(ans.length()); i++) {
        cout << ans[ans.length() - i];
    }

    cout << endl;
        
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(s.length()<=n)
    {
        cout<<s;
    }
    else
    {
        cout<<s.substr(0,n)<<"...";
    }
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>

using namespace std; using ll=long long; const int INF=1e9;
typedef pair<int,int> P;

int main() {
  int n,m,q; cin>>n>>m>>q;
  int a[q], b[q], c[q], d[q];
  for(int i=0;i<q;i++) {
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--; b[i]--;
  }

  int an=0;
  int p[n]; fill(p,p+n,1);
  for(int i=1;i<=m;i++) {
    if (n>=10) p[n-10]=i;
    for(int j=i;j<=m;j++) {
      if (n>=9) p[n-9]=j;
      for(int k=j;k<=m;k++) {
        if (n>=8) p[n-8]=k;
        for(int i2=k;i2<=m;i2++) {
          if (n>=7) p[n-7]=i2;
          for(int j2=i2;j2<=m;j2++) {
            if (n>=6) p[n-6]=j2;
            for(int k2=j2;k2<=m;k2++) {
              if (n>=5) p[n-5]=k2;
              for(int i3=k2;i3<=m;i3++) {
                if (n>=4) p[n-4]=i3;
                for(int j3=i3;j3<=m;j3++) {
                  if (n>=3) p[n-3]=j3;
                  for(int k3=j3;k3<=m;k3++) {
                    if (n>=2) p[n-2]=k3;
                    for(int i4=k3;i4<=m;i4++) {
                      if (n>=1) p[n-1]=i4;
                      int sm=0;
                      for(int o=0;o<q;o++) {
                        if (p[b[o]] - p[a[o]] == c[o]) sm+=d[o];
                      }
                      an=max(an,sm);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout<<an<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=4e3+5;
char s[N];
int main() {
    int n;
    scanf("%d%s",&n,s);
    int a=0,b=0,c=0;
    for(int i=0;i<n;i++) {
        if(s[i]=='R') a++;
        if(s[i]=='G') b++;
        if(s[i]=='B') c++;
    }
    ll ans=1LL*a*b*c;
    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n;j++) {
            if(s[i]==s[j]) continue;
            if(2*j-i<n&&s[i]!=s[2*j-i]&&s[j]!=s[2*j-i]) ans--;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3844
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int main() {
	int n;
	scanf("%d", &n);

	// 맨하탄거리 보고. 최초시점 기준으로 홀수 만큼 남으면 불가능.
	int pt = 0, px = 0, py = 0;
	int t, x, y;
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &t, &x, &y);
		
		int tt = t - pt;
		int xx = abs(x - px);
		int yy = abs(y - py);

		if (tt < xx + yy)
			return !printf("No");
		if ((tt - (xx + yy)) % 2)
			return !printf("No");

		pt = t;
		px = x;
		py = y;
	}

	printf("Yes");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  unsigned long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 998244353;
const double PI = 3.141592653589793238463;
const int MAXN = 1000030;

int main()
{
    FAST
    
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


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

const int N=(int)2e5+10;
int arr[N];
int n,k;
bool isvalid(int mid)
{
	int kk=k;
	if(mid==0)
	return 0;
	for(int i=0;i<n;i++)
	{
		if(arr[i]<=mid)
		continue;
		int t=arr[i]/mid;
		kk-=t;
	}
	return (kk>=0);
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	cin>>arr[i];
	
	int i=0,j=(int)1e9+10;
	while(i<j)
	{
		int mid=(i+j)/2;
		if(isvalid(mid))
		{
			j=mid;
		}
		else
		i=mid+1;
	}
	cout<<j<<endl;
}
	


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

int main(){
  int n, cnt=0;
  cin >> n;
  rep(i, n){
    int a;
    cin >> a;
    if((i+1)%2==1&&a%2==1){
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3616
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x_sum, y_sum = 0, 0
for i in range(n):
  k = i + 1
  x_sum += (2*k - n - 1) * x[i]
  x_sum = x_sum % 1000000007
for i in range(m):
  k = i + 1
  y_sum += (2*k - m - 1) * y[i]
  y_sum = y_sum % 1000000007
ans = (x_sum * y_sum) % 1000000007
print(ans)

Measured memory_bytes: 18576
a, b=map(int,input().split())
if a-b>1:
    print(a+a-1)
elif a-b==1:
    print(a+a-1)
elif a==b and a-1<b:
    print(a+b)
elif b>a and (b-1)==a:
    print(b+b-1)
elif b>a and b-1>a:
    print(b+b-1)

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

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 N,W;
int w[110],v[110];
long long dp[110][100010]; // dp[N][W] - 制限をWとした時の、N番目までの最大価値

int main(){
    cin >> N >> W;
    for(int i=1;i<=N;++i) cin >> w[i] >> v[i];

    for(int i=0;i<=W;++i) dp[0][i] = 0;

    for(int i=1;i<=N;++i){
        for(int j=0;j<=W;++j){
            chmax(dp[i][j],dp[i-1][j]); // i番目の品物を使わない。
            if(j>=w[i]) chmax(dp[i][j],dp[i-1][j-w[i]]+v[i]); // 使う。
        }
    }
    
    cout << dp[N][W] << endl;
    return 0;

}

Measured memory_bytes: 80128
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[200000];

  scanf("%s", s);

  long ans = 0;
  long count = 0;
  for (int i = 0; i < strlen(s); i++) {
    if (s[i] == 'B')
      count++;
    else if (s[i] == 'W')
      ans += count;
  }

  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Union_Find_Tree{
	public:
	vi Par,Rank,Size;
	Union_Find_Tree(int n){
		Par=Rank=vi(n);
		Size=vi(n,1);
		for(int i=0;i<n;i++) Par[i]=i;
	}
	int Find_Par(int x){
		if(Par[x]==x) return x;
		return Par[x]=Find_Par(Par[x]);
	}
	int Find_Size(int x){
		return Size[Find_Par(x)];
	}
	bool Unite(int x,int y){
		x=Find_Par(x);
		y=Find_Par(y);
		if(x==y) return 0;
		if(Rank[x]<Rank[y]){
			Par[x]=y;
			Size[y]+=Size[x];
		}
		else{
			Par[y]=x;
			Size[x]+=Size[y];
			if(Rank[x]==Rank[y]) Rank[x]++;
		}
		return 1;
	}
	bool Same(int x,int y){
		return Find_Par(x)==Find_Par(y);
	}
};

int n,m;
vvp g;
vl p;

void dfs(int v,int c){
	p[v]=c;
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i].first;
		if(p[u]==INF) dfs(u,c+g[v][i].second);
	}
}

int main(){
	while(1){
		cin>>n>>m;
		if(!n) break;
		g=vvp(n);
		p=vl(n,INF);
		vi t(m);
		vp a(m);
		Union_Find_Tree uft(n);
		for(int i=0;i<m;i++){
			char c;
			cin>>c;
			if(c=='!'){
				int v,u,c;
				cin>>v>>u>>c;
				v--;u--;
				g[v].push_back({u,c});
				g[u].push_back({v,-c});
				a[i]={v,u};
			}
			else{
				t[i]=1;
				int v,u;
				cin>>v>>u;
				a[i]={v-1,u-1};
			}
		}
		for(int i=0;i<n;i++) if(p[i]==INF) dfs(i,0);
		for(int i=0;i<m;i++){
			if(!t[i]) uft.Unite(a[i].first,a[i].second);
			else{
				int v=a[i].first,u=a[i].second;
				if(!uft.Same(u,v)) cout<<"UNKNOWN"<<endl;
				else{
					cout<<p[u]-p[v]<<endl;
				}
			}
		}
	}
}

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

int main(){
  bool t[1000001];
  int n,a,b;

  for(;;){
    cin >> n >> a >> b;
    if(!n && !a && !b)break;

    for(int i=0;i<=n;i++)t[i] = false;
    for(int i=0;i<=n;i+=a)t[i] = true;
    for(int i=0;i+b<=n;i++)
      if(t[i])t[i+b] = true;

    cout << count(t+1,t+n+1,false) << endl;
  }
}
  

Measured memory_bytes: 0
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=1

n=I()
s=input()
l,r=0,0

for i in range(n*2):
    t=1 if s[i]=='B' else 0
    if (l-r+t)%2==1:
        l+=1
    else:
        ans*=(l-r)
        ans%=mo
        r+=1
    if i>=n:
        ans*=i-n+1
        ans%=mo
if r-l!=0:
    print(0)
else:
    print(ans)


Measured memory_bytes: 42204
import java.util.Scanner;

public class Main {

	public static void main(String... nui) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();
		
		for (int i = 0; i < s.length(); i++) {
			
			if (i == a) continue;
			
			if (s.charAt(i) < '0' || s.charAt(i) > '9') {
				
				System.out.println("No");
				return;
				
			}
			
		}
		
		System.out.println((s.charAt(a) == '-') ? "Yes" : "No");
		
	}

}

Measured memory_bytes: 22100
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>

using namespace std;

struct UnionFind {
private:
    const int n;
    int __size;
    vector<int> uf;
public:
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n) : n(_n), __size(_n), uf(_n, -1) {}
    // find (木の根を求める)
    int find(int x) {return (uf[x] < 0) ? x : uf[x] = find(uf[x]);}
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x が属する集合の要素数
    int size(int x) {return -uf[find(x)];}
    // 集合はいくつあるか
    int size()      {return __size;}
    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        __size--;
        if(uf[y] < uf[x]) swap(x, y);
        uf[x] += uf[y]; uf[y] = x;
    }
};

int main(){
    cin.tie(0);
    
    string S; cin >> S;
    int ans = 0;
    int stack = 0;
    for (int i = 0; i < S.length(); i++){
        if (stack > 0){
            if (S[i] == '0'){
                stack++;
            }else{
                stack--;
                ans++;
            }
        }else if(stack == 0){
            if (S[i] == '0') stack++;
            else stack--;
        }else{
            if (S[i] == '0'){
                stack++;
                ans++;
            }else{
                stack--;
            }
        }
    }
    cout << ans*2 << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<pair<int,int>> A(N);
    rep(i, N){
        cin >> A[i].first;
        A[i].second = i+1;
    }

    debug(A);
    sort(A.begin(), A.end());
    debug(A);

    rep(i, N){
        cout << A[i].second;
        if(i!=N-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1664
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()

anums = getList()
bnums = getList()
cnums = getList()

anums = [-100] + anums

ans = 0
for i, j in zip(anums, anums[1:]):
    ans += bnums[j-1]
    if j == i + 1:
        ans += cnums[i-1]


print(ans)

Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int x, t;
	cin >> x >> t;

	if (x - t >= 0) {
		out(x - t);
	}
	else {
		out(0);
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

long long x;
long long r;
long long d;

int main(){
    
    scanf("%lld %lld %lld",&r,&d,&x);

    for(int i = 1;i <= 10;i++){
        x = r * x - d;

        printf("%lld\n",x);
    }

    return 0;
}


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

using namespace std;

int main(){
	int n;
	while(cin >> n){
		if(n==0) break;
		int m = 9999999, M = 0, sum = 0;
		for(int i=0;i<n;i++){
			int tmp; cin >> tmp;
			m = min(m,tmp);
			M = max(M,tmp);
			sum += tmp;
		}
		cout << ((sum-m-M)/(n-2)) << endl;
	}
}

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

int main()
{
	int a[3], score = 0;
	cin >> a[0] >> a[1] >> a[2];

	int i;
	for (int i = 0; i< 3; i++)
	{
		int j;
		for (j = 0; j < 3; j++)
		{
			if (i == j)
			{
				continue;
			}
			if ((a[i] & 1) == (a[j] & 1))
			{
				break;
			}
		}
		if (j == 3)
		{
			a[0]++; a[1]++; a[2]++;
			a[i]--;
			score++;
			break;
		}
	}

	if (a[0] > a[2])
	{
		int tmp;
		tmp = a[0];
		a[0] = a[2];
		a[2] = tmp;
	}
	if (a[0] > a[1])
	{
		int tmp;
		tmp = a[0];
		a[0] = a[1];
		a[1] = tmp;
	}
	if (a[1] > a[2])
	{
		int tmp;
		tmp = a[1];
		a[1] = a[2];
		a[2] = tmp;
	}

	score += (a[2] - a[1]) / 2;
	score += (a[2] - a[0]) / 2;
	cout << score << endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N;
	int x[505];

	cin >> N;
	rep(i,N){
		cin >> x[i];
		x[i]--;
	}

	vector<pii> v;
	rep(i,N) v.emplace_back(x[i], i);
	sort(all(v));

	vector<int> ans;
	bool able = true;
	rep(i,N){
		int num = ans.size() + i;
		if( v[i].X - num < v[i].Y ){
			able = false;
			break;
		}else{
			rep(j, v[i].Y) ans.push_back(v[i].Y);
		}
	}
	// cout << able << endl;
	// cout << ans << endl;

	vector<pii> rv;
	rrep(i,N) rv.emplace_back(N*N - v[i].X - 1, v[i].Y);
	vector<int> rans;
	rep(i,N){
		int num = rans.size() + i;
		int right = N - rv[i].Y - 1;
		if( rv[i].X - num < right ){
			able = false;
			break;
		}else{
			rep(j, right) rans.push_back(rv[i].Y);
		}
	}
	// cout << able << endl;
	// cout << rans << endl;

	if( !able ){
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	int pos = 0;
	reverse(all(ans));
	//cout << v << endl;
	rep(i,N*N){
		if( i == v[pos].X ){
			cout << v[pos].Y+1 << " ";
			pos++;
		}else{
			if( ans.size() ){
				cout << ans.back()+1 << " ";
				ans.pop_back();
			}else{
				cout << rans.back()+1 << " ";
				rans.pop_back();
			}
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 2300
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int N, K;

signed main()
{
	cin >> N >> K;
	double ans = 0;

	for (int i = 1; i <= N; ++i) {
		double prob = 1.0;
		int s = i;
		while (s < K) {
			prob /= 2.0;
			s *= 2;
		}

		ans += prob / N;
	}

	printf("%.10f\n", ans);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
pair<double,double> d[100005];
double x[100005],y[100005];
double pro(double t){
  	double minx=1e18,miny=1e18,maxx=-1e18,maxy=-1e18;
    for(int j=0;j<n;j++){
      double x1=x[j]+t*d[j].first;
      double y1=y[j]+t*d[j].second;
      minx=min(minx,x1);
      maxx=max(maxx,x1);
      miny=min(miny,y1);
      maxy=max(maxy,y1);
    }
    return (maxx-minx)*(maxy-miny);
}
int main()
{
	cin>>n;
	map<char,pair<double,double> >m;
	m['U']=make_pair(0.0,1.0);
	m['D']=make_pair(0.0,-1.0);
	m['L']=make_pair(-1.0,0.0);
	m['R']=make_pair(1.0,0.0);
	for(int i=0;i<n;i++){
		double x1,y1;
		char ch;
		cin>>x1>>y1>>ch;
		x[i]=x1;
		y[i]=y1;
		d[i]=m[ch];
	}
	double l=0.0,r=1e10,a1,a2;
	for(int i=0;i<150;i++){
		double l1=l+(r-l)/3.0,r1=r-(r-l)/3.0;
		a1=pro(l1);
		a2=pro(r1);
		if(a1<a2)r=r1;
		else l=l1;
	}
	printf("%.12lf",a1);
}

Measured memory_bytes: 3328
//~#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//~#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//~#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

vector<int>fc,inv;

int nCr(int n,int r){
	if(n<r){
		return 0;
	}
	return mul(mul(fc[n],inv[r]),inv[n-r]);
}

void prec(int n){
	fc.resize(n);
	inv.resize(n);
	fc[0]=1;
	for(int i=1;i<n;i++){
		fc[i]=mul(fc[i-1],i);
	}
	inv[n-1]=powz(fc[n-1],mod-2);
	for(int i=n-2;i>=0;i--){
		inv[i]=mul(inv[i+1],i+1);
	}
}

void solve(){
	prec(2000006);
	int r1,c1,r2,c2;
	cin>>r1>>c1>>r2>>c2;
	int ans=0;
	for(int i=r1;i<=r2;i++){
		add(ans,sub(nCr(i+c2+1,c2),nCr(i+c1-1+1,c1-1)));
	}
	cout<<ans;
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 31488
import sys
input = sys.stdin.readline

N = int(input())
d = {'JPY':1, 'BTC':380000.0}
X = [None] * N
U = [None] * N

for i in range(N):
    X[i], U[i] = input().split()

print(sum(float(x) * d[u] for x, u in zip(X, U))) 

Measured memory_bytes: 3064
import java.util.*;

class Main{
    public static void main(String[] args){
        
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        int count = 0;
        for(int i=a; a <= b; a++){
            if(c%a == 0) count++;
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 26280
N, A, B = map(int, input().split())
S = input()


P = [0]*N
for i in range(N):
  if S[i] == 'a':
    if A > 0:
      A -= 1
      P[i] = 1
    elif B >0:
      B -= 1
      P[i] = 1
  elif S[i] == 'b' and B > 0:
    B -= 1
    P[i] = 1
for i in range(N):
  print('Yes' if P[i] else 'No')

Measured memory_bytes: 4784
n,w=map(int,raw_input().split())
vw=[map(int,raw_input().split()) for _ in xrange(n)]
dp=[0]*(w+1)
for i in xrange(n):
    for j in xrange(vw[i][1],w+1):
        dp[j]=max(dp[j],dp[j-vw[i][1]]+vw[i][0])
print(dp[w])     

Measured memory_bytes: 6644
import java.util.Scanner;

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

			int N = scan.nextInt();
			long[]A = new long[N];
			for(int i = 0;i<N;i++)A[i] = scan.nextLong();


			int nanko = 1;

			if(N==1) {
				System.out.println(1);
				return;
			}

			int mode = 0;



			for(int i = 0;i<N-1;i++) {
				if(mode==0) {
					if(A[i]<A[i+1])mode=1;
					if(A[i]>A[i+1])mode=-1;
				}else if(mode==1) {
					if(A[i]>A[i+1]) {
						nanko++;
						mode = 0;
					}
				}else if(mode==-1) {
					if(A[i]<A[i+1]) {
						nanko++;
						mode = 0;
					}
				}
			}


			System.out.println(nanko);

		}


	}


}


Measured memory_bytes: 60644
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val x = sc.nextLong

  val res = x / 11 * 2 + {
    x % 11 match{
      case 0 => 0
      case y if y <= 6 => 1
      case _           => 2
    }
  }

  println(res)
}

Measured memory_bytes: 27320
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    int n; cin >> n;
    int a[110];
    rep(i, n) cin >> a[i];
    bool flag = true;
    rep(i, n) {
        if(a[i] % 2 == 0) {
            if(a[i] % 3 != 0 && a[i] % 5 != 0) {
                flag = false;
            }
        }
    }
    if (flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}


Measured memory_bytes: 256
#Multiple Clocks
N = int(input())

T = []
for i in range(N):
    T.append(int(input()))


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a    

def lcm(a, b):
    return a * b // gcd (a, b)

a = T[0]

for Ti in T[1:]:
    a = lcm(a, Ti)

print(a)
    

Measured memory_bytes: 3060
import sys
import numpy as np

def comb(n):
    return n * (n - 1) // 2

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n = I[0]
a = I[1:]

def main():
    c = np.bincount(a, minlength=np.amax(a)+1) 
    tot = comb(c).sum()
    res = tot - comb(c[a]) + comb(c[a]-1)
    return res
        
if __name__ == "__main__":
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 32532
#include<cstdio>
using namespace std;
int main(){
  int n,x;
  while(1){
    scanf(" %d %d",&n,&x);
    if(n==0 &&x==0 ){
        break;
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
    for(int k=j+1;k<=n;k++){
      if(i+j+k==x)cnt++;
    }
      }
    }
    printf("%d\n",cnt);
  }
}


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

using lint = long long;
const lint MOD = 1e9 + 7;

lint power(lint n, lint p) {
    lint res = 1;
    while (p > 0) {
        if (p % 2 == 1) {
            res = res * n % MOD;
        }
        n = n * n % MOD;
        p /= 2;
    }
    return res;
}

lint minv(lint n) {
    return power(n, MOD - 2);
}

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

    lint n, a, b, c;
    cin >> n >> a >> b >> c;
    a = a * minv(100) % MOD;
    b = b * minv(100) % MOD;
    lint win = (a + b) % MOD;
    a = a * minv(win) % MOD;
    b = b * minv(win) % MOD;
    c = c * minv(100) % MOD;

    lint ans = 0;
    lint comb = 1;
    for (int k = 0; k < n; k++) {
        if (k > 0) {
            comb = comb * (n + k - 1) % MOD * minv(k) % MOD;
        }
        lint draw = (n + k) % MOD;
        lint prob = comb * ((power(a, n) * power(b, k) % MOD
                            + power(b, n) * power(a, k) % MOD) % MOD) % MOD;
        ans = (ans + draw * prob % MOD)% MOD;
    }

    cout << ans * minv(1 - c + MOD) % MOD << endl;

    return 0;
}

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

// https://atcoder.jp/contests/abc132/tasks/abc132_f
namespace FSmallProducts
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inputs[0], k = inputs[1];

            // ある数aに対して a * b <= n となる最大値bの一覧を作成
            // for で n 回走査すると TLE のため、双曲線の特徴を活かして √n まで x , n/x で一覧をとる
            List<int> divSummary = new List<int>();
            for (var i = 1; i * i <= n; i++)
            {
                divSummary.Add(i);
                if (i * i != n) divSummary.Add(n / i);
            }
            divSummary.Sort();

            var divCount = divSummary.Count;
            ModNum[,] dp = new ModNum[k, divCount];

            for (var i = 0; i < divCount; i++)
            {
                dp[0, i] = divSummary[i];
            }

            for (var i = 1; i < k; i++)
            {
                dp[i, 0] = dp[i - 1, divCount - 1];
                for (var j = 1; j < divCount; j++)
                {
                    var overlap = divSummary[j] - divSummary[j - 1];
                    dp[i, j] = dp[i, j - 1] + overlap * dp[i - 1, divCount - 1 - j];
                }
            }

            // 解答の出力
            Console.WriteLine(dp[k - 1, divCount - 1].X);
        }
    }

    public struct ModNum : IEquatable<ModNum>
    {
        const int Mod = 1000000007;
        public long X { get; }

        public ModNum(long x) { X = x % Mod; }
        public static implicit operator ModNum(long x) => new ModNum(x);

        public bool Equals(ModNum other) => X == other.X;
        public override bool Equals(object obj) => obj is ModNum && Equals((ModNum)obj);
        public override int GetHashCode() => X.GetHashCode();
        public static bool operator ==(ModNum a, ModNum b) => a.X == b.X;
        public static bool operator !=(ModNum a, ModNum b) => a.X != b.X;

        public static ModNum operator +(ModNum a, ModNum b) => a.X + b.X;
        public static ModNum operator -(ModNum a, ModNum b) => Mod + a.X - b.X;
        public static ModNum operator *(ModNum a, ModNum b) => a.X * b.X;
        public static ModNum operator /(ModNum a, ModNum b) => a.X * Pow(b, Mod - 2);

        public static ModNum Pow(ModNum baseNum, int exponent)
        {
            switch (exponent)
            {
                case 0:
                    return 1;
                case 1:
                    return baseNum;
                default:
                    var pow = Pow(baseNum, exponent / 2);
                    return (exponent % 2) == 0 ? pow * pow : pow * pow * baseNum;
            }
        }
    }
}


Measured memory_bytes: 58976
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int a, b=10,t=0;
	rep(i, 5) {
		cin >> a;
		if ((a + 9) % 10 <= (b + 9) % 10) {
			b = a;
		}
		t += (a + 9) / 10 * 10;
	}
	cout << t - (b + 9) / 10 * 10  + b << endl;
}



Measured memory_bytes: 256