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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

template<int_fast64_t m=MOD>
struct Mcomb{
  using i64=int_fast64_t;
  vector<i64>f;  //$B3,>h(B
  vector<i64>finv; //$B3,>h$N5U85(B
  vector<i64>inv;  //$B5U85(B

  Mcomb(i64 max){
    f.resize(max+1,0);
    finv.resize(max+1,0);
    inv.resize(max+1,0);
    f[0]=f[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(i64 i=2;i<=max;i++){
      f[i]=f[i-1]*i%m;
      inv[i]=m-inv[m%i]*(m/i)%m;
      finv[i]=finv[i-1]*inv[i]%m;
    }
  }

  //nCr=n!/r!(n-r)!
  i64 slove(i64 n,i64 r){
    if(n<r)return 0;
    if(n<0||r<0)return 0;
    return (f[n]*(finv[r]*finv[n-r]%m)%m)%m;
  }
};

template<uint_fast64_t m>
int_fast64_t mpow(int_fast64_t x,int_fast64_t n){
  using i64=int_fast64_t;
  if(n==0)return 1;
  if(n%2)return ((x%m)*(mpow<m>(x,n-1)%m))%m;
  else {
    i64 half=mpow<m>(x,n/2)%m;
    return (half*half)%m;
  }
}

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

  int N;
  cin>>N;

  int ans=((mpow<MOD>(10,N)-((2*mpow<MOD>(9,N)-(mpow<MOD>(8,N)))%MOD+MOD)%MOD)%MOD+MOD)%MOD;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	string s; cin>>s;
	int n; cin>>n;
	string ans;
	rep(i,0,s.size()){
		if(i%n==0)ans.push_back(s[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3476
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    double t,i,j,n,x,a,b,h,m;
    cin>>a>>b>>h>>m;double p;
    if(h>(m/5.0)){
        p=(30*((h-(m/5.0))))+(m/2.0);
    }
    else{
        p=(30*((-h+(m/5.0))))-(m/2.0);
    }
    double q=cos((p/180.0)*3.14159265358979323846);
    double y=(q*2.0*a*b);
    y=(a*a)+(b*b)-y;
    y=sqrt(y);
    std::cout << std::fixed;
  std::cout << std::setprecision(9) << y << '\n';
}

Measured memory_bytes: 4240
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll              long long
#define l1(i, n)        for (ll i = 1; i <= n; i++)
#define l0(i, n)        for (ll i = 0; i < n; i++)
#define lo(i, s, n)     for (ll i = s; i <= n; i++)
#define sca(n)          scanf("%lld", &n)
#define pri(n)          printf("%lld", n)
#define pb              push_back
#define mp              make_pair
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define ms(a, b)        memset(a, b, sizeof(a));
#define cases(tc)       cout<<"Case "<<tc<<": "
#define nl              cout<<"\n";
#define pnl             printf("\n");
#define pi              acos(-1)
#define mod             1000000007
#define inf             999999999999999999
			
 


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

    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    */

    ll t;
    t=1;
    while(t--){
        string x; 
        cin>>x;
        ll cnt=0;
        ll ans=0;
        l0(i, 3){
            if(x[i]=='S'){
                ans=max(ans, cnt);
                cnt=0;
            }
            else cnt++;
        }
        ans=max(ans, cnt);
        cout<<ans;
        nl
    }
    return 0;
}


Measured memory_bytes: 3648
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()

idx = 0
cnt = [0]*n
for i in range(n):
    while b[i] >= c[idx] and idx + 1 < n: idx += 1
    if b[i] >= c[idx]: break
    cnt[i] = n-idx

for i in range(n-1)[::-1]: cnt[i] += cnt[i+1]

idx = 0
ans = 0
for i in range(n):
    while a[i] >= b[idx] and idx + 1 < n: idx += 1
    if a[i] >= b[idx]: break
    ans += cnt[idx]

print(ans)

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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> r(n); for (int i = 0; i < n; i++) cin >> r[i];
  vector<int> mi(n + 1, 2e9), ma(n + 1, 0);
  for (int i = 0; i < n; i++) mi[i + 1] = min(mi[i], r[i]);
  for (int i = n - 1; i >= 0; i--) ma[i] = max(ma[i + 1], r[i]);
  int res = -2e9;
  for (int i = 1; i < n; i++) res = max(res, ma[i] - mi[i]);
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 5212
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e18;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> ans(n+1, INF);
  vector<ll> x(n), y(n), p(n);
  rep(i,n) {
    cin >> x[i] >> y[i] >> p[i];
  }

  // xl[i][j] .. i: bit representation of roads, j: min distance from j to nearest road.
  vector<vector<ll>> xl(1ll<<n, vector<ll>(n)); // vertical
  vector<vector<ll>> yl(1ll<<n, vector<ll>(n)); // horizontal
  rep(i,1ll<<n) {
    rep(j,n) {
      xl[i][j] = abs(x[j]); // main road
      yl[i][j] = abs(y[j]); // main road
      rep(k,n) {
        if (i>>k&1) {
          chmin(xl[i][j], abs(x[j]-x[k]));
          chmin(yl[i][j], abs(y[j]-y[k]));
        }
      }
    }
  }

  rep(i,1ll<<n) {
    ll cnt = __builtin_popcount(i);
    // Loop in all sub sets. In ordinal case, we use
    // `for (ll j = i; j > 0; j=(j-1)&i) { ... }`, but we want to include j=0,
    // so it is slightly different.
    for (ll j = i; j >= 0; --j) {
      j &= i;
      // Here, we use `j` roads as xl.

      ll now = 0;
      rep(k,n) {
        if (!((i>>k)&1)) { // when k is not in i, it means we must calculate cost.
          now += min(xl[j][k], yl[i-j][k]) * p[k];
        }
      }
      chmin(ans[cnt], now);
    }
  }

  rep(i,n+1) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 12952
import java.util.Scanner;

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

		int n;

		while ((scan.hasNext())) {
			int pattern = 0;
			n = Integer.parseInt(scan.next());
			for (int a = 0; a < 10; a++) {
				for (int b = 0; b < 10; b++) {
					for (int c = 0; c < 10; c++) {
						for (int d = 0; d < 10; d++) {
							if ((a + b + c + d) == n) {
								pattern++;

							}

						}
					}
				}
			}

			System.out.println(pattern);

		}

	}

}

Measured memory_bytes: 12000
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, D = LI()

    print((N - 1) // (2 * D + 1) + 1)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9916
package main

import "fmt"

func min(a ...int64) int64 {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		if ret > a[i] {
			ret = a[i]
		}
	}
	return ret
}

func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n, a, b, c, d int64
		fmt.Scan(&n, &a, &b, &c, &d)

		memo := make(map[int64]int64)
		var f func(x int64) int64
		f = func(x int64) int64 {
			if x == 0 {
				return 0
			}
			if x == 1 {
				return d
			}
			if memo[x] != 0 {
				return memo[x]
			}
			ret := int64(1e18)
			if ret/d > x {
				ret = x * d
			}
			memo[x] = min(
				ret,
				f(x/2)+abs(x-(x/2)*2)*d+a,
				f((x+1)/2)+abs(x-((x+1)/2)*2)*d+a,
				f(x/3)+abs(x-(x/3)*3)*d+b,
				f((x+2)/3)+abs(x-((x+2)/3)*3)*d+b,
				f(x/5)+abs(x-(x/5)*5)*d+c,
				f((x+4)/5)+abs(x-((x+4)/5)*5)*d+c,
			)
			return memo[x]
		}

		fmt.Println(f(n))
	}
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int n,k,x,y;cin>>n>>k>>x>>y;

  if(k>=n){
    cout<<x*n<<endl;
  }else{
    cout<<x*k+y*(n-k)<<endl;
  }

  return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	map<int, int> d;
	d[a]++;
	d[b]++;
	d[c]++;
	if (d.size() == 2) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 998244353;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<vector<ll>> dp(c+1, vector<ll>(d+1));
  dp[a][b] = 1;
  for(ll i=a; i<=c; i++) {
    for(ll j=b; j<=d; j++) {
      if(i==a&&j==b) continue;
      if(i!=a) (dp[i][j] += dp[i-1][j]*j) %= mod;
      if(j!=b) (dp[i][j] += dp[i][j-1]*i) %= mod;
      if(i!=a&&j!=b) (dp[i][j] += mod - dp[i-1][j-1]*(i-1)%mod*(j-1)%mod) %= mod;
    }
  }
  cout << dp[c][d] << "\n";
  return 0;
}


Measured memory_bytes: 73652
#include<stdio.h>
#define SWAP(type,a,b)do{type temp=a;a=b;b=temp;}while(0)
typedef struct{
  char t;
  int point1;
  int point2;
  int NO;
}P;
int main(){
  int n,r,i,j,l,a,s,win,lost;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    a=n-1;
    P data[n];
    for(i=0;i<n;i++)data[i].NO=i;
    for(l=0;l<n;l++){
      scanf(" %c ",&data[l].t);
      for(i=0,win=0,lost=0;i<a;i++){
	scanf(" %d",&s);
	if(s==0)win++;
	else if(s==1)lost++;
      }
      data[l].point1=win;
      data[l].point2=lost;
    }
    for(i=0;i<n-1;i++){
      for(j=n-1;j>i;j--){
	if(data[j].point1>data[j-1].point1) SWAP(P,data[j],data[j-1]);
      }
    }
    for(i=0;i<n-1;i++){
      for(j=n-1;j>i;j--){
	if(data[j].point1==data[j-1].point1){
	  if(data[j].point2<data[j-1].point2) SWAP(P,data[j],data[j-1]);
	}
      }
    }
    for(i=0;i<n-1;i++){
      for(j=n-1;j>i;j--){
	if(data[j].point1==data[j-1].point1&&data[j].point2==data[j-1].point2){
	  if(data[j].NO<data[j-1].NO)
	  SWAP(P,data[j],data[j-1]);
	}
      }
    }
    for(i=0;i<n;i++)printf("%c\n",data[i].t);
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<stack>
#include<utility>
using namespace std;

vector< vector<bool> > getunion(const vector< vector<int> >& base){
	vector< vector<bool> > ret;
	stack< pair<int,int> > nxt;
	int xmax=base[0].size();
	int ymax=base.size();
	int tar=base[0][0];
	int curx,cury;
	ret.resize(ymax);
	for(int i=0;i<ymax;i++)ret[i].resize(xmax);
	nxt.push(pair<int,int>(0,0));
	while(!nxt.empty()){
		curx=nxt.top().first;
		cury=nxt.top().second;
		nxt.pop();
		if(base[cury][curx]==tar&&!ret[cury][curx]){
			ret[cury][curx]=true;
			if(curx>0)nxt.push(pair<int,int>(curx-1,cury));
			if(curx<xmax-1)nxt.push(pair<int,int>(curx+1,cury));
			if(cury>0)nxt.push(pair<int,int>(curx,cury-1));
			if(cury<ymax-1)nxt.push(pair<int,int>(curx,cury+1));
		}
	}
	return ret;
}

vector< vector<int> >ccolor(const vector< vector<int> >& base,int color){
	vector< vector<int> > ret;
	vector< vector<bool> > uni=getunion(base);
	int ymax=base.size();
	int xmax=base[0].size();
	ret=base;
	for(int i=0;i<ymax;i++){
		for(int j=0;j<xmax;j++){
			if(uni[i][j])ret[i][j]=color;
		}
	}
	return ret;
}

int score(const vector< vector<int> >& base){
	vector< vector<bool> > get=getunion(base);
	int ymax=get.size();
	int xmax=get[0].size();
	int ret=0;
	for(int i=0;i<ymax;i++){
		for(int j=0;j<xmax;j++){
			if(get[i][j])ret++;
		}
	}
	return ret;
}

int cal(const vector< vector<int> >& base,int target,int count){
	if(count==1){
		return score(ccolor(base,target));
	}else{
		vector< vector<int> > cald;
		int max=0,get;
		// 最大色数指定
		for(int i=1;i<7;i++){
			if(i!=base[0][0]){
				cald=ccolor(base,i);
				get=cal(cald,target,count-1);
				if(get>max)max=get;
			}
		}
		return max;
	}
}

int main(){
	int xsize,ysize,target;
	vector< vector<int> > base;
	while(true){
		cin>>ysize>>xsize>>target;
		if(target==0)break;
		base.resize(ysize);
		for(int i=0;i<ysize;i++){
			base[i].resize(xsize);
			for(int j=0;j<xsize;j++){
				cin>>base[i][j];
			}
		}
//繰り返し回数指定
		cout<<cal(base,target,5)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1244
n = gets.chomp.to_i
h = gets.split.map(&:to_i)
for i in 0..(n-2)
    if h[n-i-2] <= h[n-i-1]
    elsif h[n-i-2] > h[n-i-1] && h[n-i-2]-1 == h[n-i-1]
        h[n-i-2] -= 1
    else
        puts "No"
        exit
    end
end
puts "Yes"

Measured memory_bytes: 8580
N = int(input())
h = [int(i) for i in input().split()]

inf = float("inf")
cost = [inf]*N

cost[0] = 0
for i in range(1, N):
  cost[i] = min(cost[i], cost[i-1] + abs(h[i] - h[i-1]))
  
  if i - 2 >= 0:
    cost[i] = min(cost[i], cost[i-2] + abs(h[i] - h[i-2]))

print(cost[-1])

Measured memory_bytes: 13772
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;
int a[100005],s[100005];
int main()
{
    int N,K,Q,i,k,sum=0;
    scanf("%d%d%d",&N,&K,&Q);
    fill(a,a+N,K);
    for(i=0;i<Q;i++)
    {
        int j=0,b;
        scanf("%d",&b);
        s[b-1]++;
    }
    for(i=0;i<N;i++)
        sum+=s[i];
    for(i=0;i<N;i++)
    {
        if(a[i]+s[i]-sum<=0)
        {
            printf("No\n");
        }
        else
            printf("Yes\n");
    }
}


Measured memory_bytes: 1408
import sys
from math import factorial
sys.setrecursionlimit(100000)
def modfact(x,p):
    if x==1:
        return 1
    else:
        return (x%p)*modfact(x-1,p)
N,M=map(int,input().split())
P=10**9+7
"""
if N==M:
    print((2*modfact(N,P)*modfact(M,P))%P)
elif min(N,M)+1==max(N,M):
    print((modfact(N,P)*modfact(M,P))%P)
else:
    print("0")
"""
if N==M:
    print((2*((factorial(N))%P)*((factorial(M))%P))%P)
elif min(N,M)+1==max(N,M):
    print((((factorial(N))%P)*((factorial(M))%P))%P)
else:
    print("0")

Measured memory_bytes: 46960
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    if N % 10 in (2,4,5,7,9):
        print("hon")
    elif N % 10 in (0,1,6,8):
        print("pon")
    else:
        print("bon")

if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	double x;
	string s;
	double res = 0;
	for (int i = 0; i < n; i++) {
		cin >> x >> s;
		if (s == "JPY")res += x;
		else res += 380000 * x;
	}
	cout << res << endl;
}

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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

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

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

struct RMQ {
  long dat[kMax5][20];
  long dat2[kMax5][20];

  RMQ() {}
  void init(const vector<long> & a) {
    auto n = a.size();
    rep(i, 0, n - 2) {
      dat[i][1] = max(a[i], a[i + 1]);
      dat2[i][1] = min(a[i], a[i + 1]);
      // cout << i << " " << 1 << " " << dat[i][1] << " " << dat2[i][1] << endl;
    }
    for (auto j = 2; (1 << j) <= n; ++j) {
      for (auto i = 0; i + (1 << j) - 1 < n; ++i) {
        dat[i][j] = max(dat[i][j - 1], dat[i + (1 << (j - 1))][j - 1]);
        auto min_dat = min(dat[i][j - 1], dat[i + (1 << (j - 1))][j - 1]);
        auto max_dat2 = max(dat2[i][j - 1], dat2[i + (1 << (j - 1))][j - 1]);
        dat2[i][j] = max(min_dat, max_dat2);
        // cout << i << " " << j << " " << dat[i][j] << " " << dat2[i][j] << endl;
      }
    }
  }

  long query(ll l, ll r) {
    if (l > r) {
      return 0;
    }

    auto k = 0;
    while (l + (1 << (k + 1)) - 1 <= r) { ++k; }
    auto dat_l = dat[l][k];
    auto dat_r = dat[r - (1 << k) + 1][k];
    auto dat2_l = dat2[l][k];
    auto dat2_r = dat2[r - (1 << k) + 1][k];
    // auto min_dat = min(dat[l][k], dat[r - (1 << k) + 1][k]);
    // auto max_dat2 = max(dat2[l][k], dat2[r - (1 << k) + 1][k]);
    if (dat_l == dat_r && dat2_l == dat2_r) {
      return dat2_l;
    } else if (dat_l == dat_r) {
      return max(dat2_l, dat2_r);
    } else if (dat2_l == dat2_r){
      return min(dat_l, dat_r);
    } else if (dat_l == dat2_r){
      return dat_l;
    } else if (dat2_l == dat_r){
      return dat2_l;
    } else {
      return max(min(dat_l, dat_r), max(dat2_l, dat_r));
    }
  }
};

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

  ll ans = 0;
  string s;
  vector<long> a;
  int n;
  // cin >> n;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }

  return 0;
}


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

int	main()
{
	int	N;
	int64_t	x;
	cin >> N >> x;
	vector<int64_t>	a(N);
	for (int i = 0; i < N; ++i)
		cin >> a.at(i);
	sort(a.begin(), a.end());
	int	cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (x < a.at(i) || (i == N - 1 && x != a.at(i)))
			break;
		x -= a.at(i);
		++cnt;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int cmp(char[], char[]);

int main(void) {
  int n, i, j, k, m;
  char a[101][2], b[101][2],tmp[2];
  scanf("%d",&n);
  for(i = 0; i < n; i++) {
    scanf("%s",a[i]);
    for(k = 0; k < 2; k++) b[i][k]=a[i][k];
  }
  for(i = 0; i < n; i++) {
    for(j = n - 1; j > i; j--) {
      if(a[j][1]<a[j - 1][1]) {
	for(k = 0; k < 2; k++) tmp[k]=a[j][k];
	for(k = 0; k < 2; k++) a[j][k]=a[j - 1][k];
	for(k = 0; k < 2; k++) a[j - 1][k]=tmp[k];
      }
    }
  }
  for(i = 0; i < n; i++) {
    m=i;
    for(j = i + 1; j < n; j++) {
      if(b[j][1]<b[m][1]) m = j;
    }
    if(b[m][1] < b[i][1]) {
      for(k = 0; k < 2; k++) tmp[k]=b[i][k];
      for(k = 0; k < 2; k++) b[i][k]=b[m][k];
      for(k = 0; k < 2; k++) b[m][k]=tmp[k];
    }
  }
  int ck = 1;
  for(i = 0; i < n; i++) {
    if(a[i][0]!=b[i][0]) ck = 0;
  }    
  for(i = 0; i < n; i++) {
    if(i) printf(" ");
    printf("%c%c",a[i][0],a[i][1]);
  }
  printf("\nStable\n");
  for(i = 0; i < n; i++) {
    if(i) printf(" ");
    printf("%c%c",b[i][0],b[i][1]);
  }
  if(ck) printf("\nStable\n");
  else printf("\nNot stable\n");
  return 0;
}


Measured memory_bytes: 2104
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<stack>
using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define double long double
#define en "\n"
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> pii;
bool secdes(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi>b.fi;}else{return a.se>b.se;}}//second descending !
bool sir(const pair<int,int>&a , const pair<int,int>&b){if(a.fi==b.fi){return a.se>b.se;}else{return a.first>b.first;}}//first descending !
bool bysec(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi<b.fi;} else{return a.se<b.se;}}//second ascending !

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

const int no=3e6+5;
const int modulo=1e9+7;
const int inf=1e18+9;
const int N=1001;
int a[no]={},b[no]={},cc[no]={},suma[no]={},mat[N][N]={{0}};
stack<int> S;
stack<int> ma;

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

int poww(int x, int y, int modulo) {x %= modulo;int res=1;while (y > 0) {if (y & 1){res = res * x % modulo;}x = x * x % modulo;y >>= 1;}return res;}

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/
vector<int> adj[no];
int used[no]={};

void solve(){
    int x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x==0){
        if(k%2==0 || k==0) cout<<0<<en;
        else cout<<d<<en;
    }
    else {
        int q=x/d;
        int rem=x%d;
        if(k<=q) cout<<x-(k*d)<<en;
        else {
            if(rem==(d-rem)){
                cout<<rem<<en;
            }
            else {
                k-=q;
                if(rem>(d-rem)){
                    k--;
                    if(k%2==0)  cout<<d-rem<<en;
                    else cout<<rem<<en;
                }
                else {
                    if(k%2==0)  cout<<rem<<en;
                    else cout<<d-rem<<en;
                }
            }
        }
    }
}

void runn(){
        #ifndef ONLINE JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif
    }

signed main()
{
    night_rider
    //runn();
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 73972
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

#define rep(i,n) for(int i=0; i<int(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

string name, str;
int length1, length2;

bool check(int i, int j) {
	for (int k = 0; k < length1; k++) {
		if (i + j*k >= length2)
			return false;
		if (name[k] != str[i + j*k])
			return false;
	}
	return true;
}

int main() {
	int N; cin >> N;
	cin >> name;
	length1 = name.size();
	
	int ans = 0;
	for (int i = 0; i < N; i++) {
		bool flag = 0;
		cin >> str;
		length2 = str.size();
		for (int i = 0; i < length2; i++) {
			for (int j = 1; j < length2; j++) {
				if (check(i, j)) {
					ans++;
					flag = 1;
					break;
				}
			}
			if (flag)break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3124
x=int(input())
i=0
while True:
    a=(i**5-x)
    if(a<0):
        ans=-(-a)**(1/5)
    else:
        ans=a**(1/5)
    if(int(ans)**5==a):
        print(i,int(ans))
        break
    
    a=(i**5+x)
    if(a<0):
        ans=-(-a)**(1/5)
    else:
        ans=a**(1/5)
    if(int(ans)**5==a):
        print(int(ans),i)
        break
    
    i+=1

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

vector<int> a;
vector<string> b(4);
string st;


bool dfs(int i, int sum, int n) {

	if (i == 0) {
		sum = sum + a[0];
		i++;
	}

	if (i == n) {
		if (sum == 7) {
			for (int j = 0; j < n; j++) {
				if (j == 0) {
					cout << st[j];
					continue;
				}
				cout << b[j] << st[j];
			}
			cout << "=" << sum << endl;
			return true;
		}
		else{
			return false;
        }
    }

	b[i] = "+";
	if (dfs(i + 1, sum + a[i], n)) return true;

	b[i] = "-";
	if (dfs(i + 1, sum - a[i], n)) return true;
  
    return false;
}

int main(void) {

	cin >> st;
	for (int i = 0; i < 4; i++)
		a.push_back(st[i] - '0');

	bool a = dfs(0, 0, 4);


}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int p[20];
    cin >> n;
    for(int i = 0;i < n;i++){
        scanf("%d",&p[i]);
    }
    int count = 0;
    for(int j = 1;j < n-1;j++){
        if(p[j-1] <= p[j] && p[j+1] >= p[j] || p[j-1] >= p[j] && p[j+1] <= p[j]){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <climits>
#include <bitset>

/*
	Not easy to be successful,Dont give up
*/

using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define pb push_back
#define Compiler_Beso ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)        memset(v, d, sizeof(v))
#define endl '\n'
const double EPS = 1e-12;
typedef long long ll;
const double PI = 3.14159265359;
enum dir       { DOWN = 0, UP, RIGHT, LEFT, DOWN_RIGHT, DOWN_LEFT, UP_RIGHT, UP_LEFT };
int  dir_r[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int  dir_c[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int g(int k){
	int s = 0;
	while (k)
	{
		s += k % 10;
		k /=10;
	}
	return s;
}
int main()
{
	Compiler_Beso


		int k;
	cin >> k;
	int a, b;
	int mn = 1e9;
	for (int i = 1; i < k; i++){
		a = i;
		b = k - a;
		if (a < 0 || b < 0)
			break;
		mn = min(g(a) + g(b), mn);
	}
	cout << mn;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long[] list = new long[n];
		for(int i = 0; i < n; i++){
		    list[i] = sc.nextLong();
		}
		Arrays.sort(list);
		
		// 計算
		long result = 0;
		PriorityQueue<Num> q = new PriorityQueue<Num>((s, t) -> {
		    long sn = min(s.num1, s.num2);
		    long tn = min(t.num1, t.num2);
		    return Long.compare(tn, sn);
		});
		for(int i = n-1; i >= 0; i--){
		    long a = list[i];
		    Num now = q.poll();
		    if(now != null){
		        //System.out.println(now.num1 + " " + now.num2);
		        result += min(now.num1, now.num2);
		        q.add(new Num(a, max(now.num1, now.num2)));
		        q.add(new Num(a, min(now.num1, now.num2)));
		    }else{
		        q.add(new Num(a, a));
		    }
		}
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}

class Num {
	long num1;
	long num2;
	
	Num(long num1, long num2){
		this.num1 = num1;
		this.num2 = num2;
	}
}


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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define F first
#define S second
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...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif




int main(void) 
{


	string s, t; 
	cin >> s >> t; 

	int s1, t2; 
	scanf("%d %d", &s1, &t2); 

	string tp;
	cin >> tp; 
	if (tp == s) s1--; 
	else t2--; 

	printf("%d %d\n", s1, t2); 



 
 
 
	return false;   
}













Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 1000000000+7;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
#define print(s) cout<<s<<endl
#define input(s) cin>>s
ll n;
bool f(ll num) {
	for (ll i = 2; i < sqrt(num) + 1; ++i)if (num%i == 0)return 0;
	return 1;
}
int main() {
	input(n);
	vector<pp>v;
	v.push_back(pp{ 2,0 });
	for (int i = 2; i < 1000; ++i)if (f(i))v.pb(pp{i,0});
	for (int i = 2; i <= n; ++i) {
		ll num = i;
		for (int j = 0; j < v.size(); ++j) {
			while (num%v[j].fi == 0) { num /= v[j].fi; v[j].se++; }
		}
	}
	ll ans = 1;
	rep(i, v.size()) {
		ans *= (v[i].se+1);
		ans %= mod;
	}
	print(ans);
	return 0;
}

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

void solve(){
  string str;
  cin>>str;
  int ans=0;
  for(char ch:str) ans+=(ch-'0');
  if(ans%9==0) cout<<"Yes";
  else cout<<"No";
}

int32_t main()
{
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

int mp[505][505];

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

    int h, w;
    cin >> h >> w;
    for( int i = 1; i <= h; ++i ) {
        for( int j = 1; j <= w; ++j ) {
            cin >> mp[i][j];

        }
    }

    queue< pair<P, P> > q;
    for( int i = 1; i <= h; ++i ) {
        for( int j = 1; j <= w; ++j ) {
            if( mp[i][j] % 2 == 1 ) {
                if( i + 1 <= h ) {
                    mp[i + 1][j]++;
                    q.push(MP(MP(i, j), MP(i + 1, j)));

                } else if( j + 1 <= w ) {
                    mp[i][j + 1]++;
                    q.push(MP(MP(i, j), MP(i, j + 1)));

                }
            }
        }
    }

    cout << q.size() << endl;
    while( !q.empty() ) {
        pair<P, P> p = q.front(); q.pop();
        cout << p.F.F << " " << p.F.S << " " << p.S.F << " " << p.S.S << endl;

    }

    return 0;
}



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

using namespace std;

int main() {
    // 数字リスト
    const int nums[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

    while(1) {
        int n, s;

        cin >> n >> s;
        if(n == 0 && s == 0) { break; }

        // 0-1のフラグ配列を定義
        // nの数だけフラグを立てておき、next_permutationで順列を順次生成する
        // 全列挙を得るため、逆方向からフラグを立てる
        char flag[10] = {0};
        for(int i = 0; i < n; i++) { flag[9-i] = 1; }
        
        int count = 0;
        // フラグ配列の全列挙から異なる数字組を生成
        do {
            int sum = 0;
            
            // フラグが立っている箇所に相当する数字の総和をとる
            for(int i = 0; i < 10; i++) 
                if(flag[i]) { sum += nums[i]; }
            
            // 総和が入力と一致したものをカウント
            if(sum == s) { count++; }
        } while(next_permutation(flag, flag + 10));

        cout << count << endl;
    }
}


Measured memory_bytes: 3092
#include<cstdio>
int main(void){
int a[100][100];
int b[100];
int c[100];
int n,m;
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
scanf("%d",&a[i][j]);
}
}
for(int i=0;i<m;i++)scanf("%d",&b[i]);
for(int i=0;i<n;i++){
c[i]=0;
for(int j=0;j<m;j++){
c[i]=a[i][j]*b[j]+c[i];
}
printf("%d\n",c[i]);
}
}

Measured memory_bytes: 2768
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    ll n;
    cin >> n;
    vll a(n), b(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];

    ll ca = 0, cb = 0;
    rep(i, 0, n)
    {
        if (a[i] == b[i])
            continue;
        if (a[i] > b[i])
            cb += a[i] - b[i];
        else
        {
            if ((b[i] - a[i]) % 2 == 0)
                ca += (b[i] - a[i]) / 2;
            else
            {
                ca += (b[i] - a[i]) / 2 + 1;
                cb++;
            }
        }
    }
    print(ca >= cb);
}

Measured memory_bytes: 384
N = int(input())
S = {}
for i in range(N):
  s = input()
  if s in S: S[s] += 1
  else: S[s] = 1  
sorted_S = sorted(S.items(), reverse = True, key=lambda x: x[1]) 
ans = []
for word, value in sorted_S:
  if value == sorted_S[0][1]: ans.append(word)
ans.sort()
for i in ans:
  print(i)



Measured memory_bytes: 113112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  string s;
  cin >> s;
  ll length=s.size();
  sort(s.begin(),s.end());
  queue<ll>que;
  ll count = 1;
  for(int i=1; i<length; i++){
    if(s[i]!=s[i-1]){
      if(count>1) que.push(count);
      count=1;
    }
    else if(s[i]==s[i-1] && i==length-1){
      count++;
      if(count>1) que.push(count);
    }
    else count++;
  }
  
  ll all = length*(length-1)/2;
  ll fact=0;
  while(que.size()>0){
    ll x = que.front();
    que.pop();
    fact+=x*(x-1)/2;
  }
  cout << all-fact+1 << endl;
}
  
  
  


Measured memory_bytes: 640
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            n = int.Parse(Console.ReadLine());
            if(n == 1)
                Console.WriteLine(2);
            else if(n == 0 || n == 2)
                Console.WriteLine(1);
            else
                Console.WriteLine(0);
        }
    }
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//以下、素集合と木は同じものを表す
class UnionFind {
public:
    vector<ll> parent; //parent[i]はiの親
    vector<ll> siz; //素集合のサイズを表す配列(1で初期化)
    map<ll,vector<ll>> group;//素集合ごとに管理する連想配列(keyはそれぞれの素集合の親、valueはその素集合の要素の配列)

    //コンストラクタ
    UnionFind(ll n):parent(n),siz(n,1){ 
        //全ての要素の根が自身であるとして初期化
        for(ll i=0;i<n;i++){parent[i]=i;}
    }

    //データxの属する木の根を取得(経路圧縮も行う)
    ll root(ll x){
        if(parent[x]==x) return x;
        return parent[x]=root(parent[x]);//代入式の値は代入した変数の値なので、経路圧縮できる
    }

    //xとyの木を併合
    void unite(ll x,ll y){
        ll rx=root(x);//xの根
        ll ry=root(y);//yの根
        if(rx==ry) return;//同じ木にある時
        //小さい集合を大きい集合へと併合(ry→rxへ併合)
        if(siz[rx]<siz[ry]) swap(rx,ry);
        siz[rx]+=siz[ry];
        parent[ry]=rx;//xとyが同じ木にない時はyの根ryをxの根rxにつける
    }

    //xとyが属する木が同じかを判定
    bool same(ll x,ll y){
        ll rx=root(x);
        ll ry=root(y);
        return rx==ry;
    }

    //xの素集合のサイズを取得
    ll size(ll x){
        return siz[root(x)];
    }

    //素集合をそれぞれグループ化
    void grouping(ll n){
        //経路圧縮を先に行う
        rep(i,n)root(i);
        //mapで管理する(デフォルト構築を利用)
        rep(i,n)group[parent[i]].push_back(i);
    }
};

int main(){
    ll n,m;cin>>n>>m;
    vector<ll>a(m),b(m);
    rep(i,m){cin>>a[i]>>b[i];a[i]--;b[i]--;}
    UnionFind u(n);
    ll ans=n*(n-1)/2;
    deque<ll>d;
    d.push_front(ans);
    for(int i=m-1;i>=1;--i){
        if(u.same(a[i],b[i]))d.push_front(ans);
        else{
            ans-=(u.size(a[i]))*(u.size(b[i]));
            d.push_front(ans);
        }
        u.unite(a[i],b[i]);
    }
    while(!d.empty()){
        ll x=d.front();
        d.pop_front();
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 7176
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
m = 0
nn = n**2

a.each do |i|
  m += b[i-1]
  if nn+1 == i
    m += c[i-2]
  end
  nn = i
end

puts m


Measured memory_bytes: 1788
import java.util.*;
	
	
	
	public class Main {
	
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int preT = 0;
			int preX = 0;
			int preY = 0;
			
			for (int i=0;i<N;i++) {
				int proT = sc.nextInt();
				int proX = sc.nextInt();
				int proY = sc.nextInt();
				
				int T = proT -preT;
				int goX = proX-preX;
				int goY = proY-preY;
				
				if((goX+goY)>T || (T-goX-goY)%2 !=0) {
					System.out.println("No");
					return;
				}	
			}
			
			System.out.println("Yes");
			
			sc.close();
			
		}
		
		
	}

Measured memory_bytes: 86484
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,sum,sum2=0,temp=0,var,i;
    cin>>n>>a>>b;
    for(i=1; i<=n; i++)
    {

        sum=0,temp=i;
        while(temp!=0)
        {
            var=temp%10;
            sum=sum+var;
            temp=temp/10;
        }

        if(a<=sum&& sum<=b)
        {

            sum2=sum2+i;
        }
    }
    cout<<sum2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long long int factorial (long long int n);

int main(void){
	long long int n;

	scanf("%lld", &n);
	printf("%lld\n", factorial(n));

	return (0);
}

long long int factorial (long long int n){
	if (n > 0) {
		return (n * factorial(n - 1));
	} else {
		return (1);
	}
}

Measured memory_bytes: 596
#include<iostream>

using namespace std;

int solve(int l[10],int v[2])
{
	double sum=0;
	double t;
	double len;
	for(int i=0;i<10;i++)
	{
		sum+=l[i];
	}
	t=sum/(v[0]+v[1]);
	len=v[0]*t;
	sum=0;
	for(int i=0;i<10;i++)
	{
		sum+=l[i];
		if(len<=sum)
		{
			return i+1;
		}
	}
}

int main(void)
{
	int l[10],v[2];
	char c;
	while(cin>>l[0])
	{
		for(int i=1;i<10;i++)
		{
			cin>>c>>l[i];
		}
		for(int i=0;i<2;i++)
		{
			cin>>c>>v[i];
		}
		cout<<solve(l,v)<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stdio.h>
#include <string.h>
#include <typeinfo>
#include <memory>
#include <deque>
#include <iomanip>
using namespace std;

typedef long long lld;

#include <iostream>

using namespace std;


int main()
{
    string s;
    cin >> s;
    bool f1 = false, f2 = false;
    for(int i = 0;  i< s.size(); ++i){
        if(s[i] == 'C')
            f1 = true;
        else if(f1 && s[i] == 'F')
            f2 = true;
    }
    if(f1 && f2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}






Measured memory_bytes: 256
a=input()
b=input()
c=input()
ans=""
str="a"
for i in range(len(a)+len(b)+len(c)):
    if str=="a":
        if len(a)==0:
            ans="A"
            break
        else:
            str=a[0]
            a=a[1:]
    elif str=="b":
        if len(b)==0:
            ans="B"
            break
        else:
            str=b[0]
            b=b[1:]
    else:
        if len(c)==0:
            ans="C"
            break
        else:
            str=c[0]
            c=c[1:]
print(ans)


Measured memory_bytes: 3064
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  int n, q; rd(n, q);
  auto tree=new SquareRootDecomposition(n);
  while(q--){
    auto args=readln.split.to!(int[]);
    if(args[0]==0){
      tree.add(args[1], args[2]+1, args[3]);
    }else{
      writeln(tree.rmin(args[1], args[2]+1));
    }
  }
}

class SquareRootDecomposition{
  import std.algorithm;
  int D=1;
  int[] val, buc, laz;
  this(int n){
    while(D*D<n) D++;
    val.length=D*D;
    buc.length=laz.length=D;
  }

  void add(int ql, int qr, int x){
    foreach(k; 0..D){
      int l=k*D, r=(k+1)*D;
      if(r<=ql || qr<=l){
        // 
      }else if(ql<=l && r<=qr){
        buc[k]+=x;
        laz[k]+=x;
      }else{
        push(k);
        val[max(l, ql)..min(r, qr)]+=x;
        buc[k]=reduce!(min)(val[l..r]);
      }
    }
  }

  int rmin(int ql, int qr){
    int ret=1_000_000_000;
    foreach(k; 0..D){
      int l=k*D, r=(k+1)*D;
      if(r<=ql || qr<=l){
        // 
      }else if(ql<=l && r<=qr){
        chmin(ret, buc[k]);
      }else{
        push(k);
        chmin(ret, reduce!(min)(val[max(l, ql)..min(r, qr)]));
      }
    }
    return ret;
  }

  void push(int k){
    val[(k*D)..((k+1)*D)]+=laz[k];
    laz[k]=0;
  }

  void chmin(T)(ref T l, T r){
    if(l>r) l=r;
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 3700