akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

vector<int> enumerate(int a, int b, int c){
    int h[3] = {a,b,c};
    vector<int> res;
    for(int i=0; i<60; i++){
        sort(h, h+3);
        do{
            if(h[0]%5 != h[1]/12) continue;
            res.push_back((h[0]/5)*3600 +60*h[1] +h[2]);
        }while(next_permutation(h, h+3));
        for(int i=0; i<3; i++) h[i] = (h[i]+1)%60;
    }
    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end());
    return res;
}

void printtime(int n){
    printf("%02d:", n/3600);
    n %= 3600;
    printf("%02d:%02d", n/60, n%60);
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        vector<vector<int> > t(n);
        for(int i=0; i<n; i++){
            int a,b,c;
            cin >> a >> b >> c;
            t[i] = enumerate(a,b,c);
        }

        int tmin=inf, s=-1;
        for(int i=0; i<60*60*24; i++){
            int tmax=0;
            for(int j=0; j<n; j++){
                vector<int>::iterator itr = lower_bound(t[j].begin(), t[j].end(), i);
                if(itr == t[j].end()){
                    tmax = inf;
                    i = inf;
                    break;
                }
                tmax = max(tmax, *itr -i);
            }
            if(tmax < tmin){
                s = i;
                tmin = tmax;
            }
        }
        printtime(s);
        cout << " ";
        printtime(s+tmin);
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3184
#!/usr/bin/env python3
import sys
import numpy as np


def solve(K: int, A: int, B: int):
    for i in range(A, B+1):
        if i%K==0:
            print('OK')
            return
    print('NG')
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(K, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27140
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

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

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }

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

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

#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10


int N, M;
vector<vector<int> > G;

int dp[100010];

int Solve(int v)
{
    if (dp[v] != -1) return dp[v];

    int ans = 0;
    for (auto nv : G[v])
    {
        updateMax(ans, Solve(nv) + 1);
    }
    return dp[v] = ans;
}

int main()
{
    cin >> N >> M;
    G.assign(N, vector<int>());
    REP(i, M)
    {
        int x, y;
        cin >> x >> y;
        --x; --y;
        G[x].push_back(y);
    }

    REP(v, N) dp[v] = -1;

    int ans = 0;
    REP(v, N) updateMax(ans, Solve(v));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

ll num;

int count(ll a)
{
    int ret=0;
    if(a>num)return 0;
    string str=to_string(a);
    bool s=false,f=false,t=false;
    rep(i,str.length())
    {
        if(str[i]=='3')
        {
            t=true;
        }
        else if(str[i]=='5')
        {
            f=true;
        }
        else if(str[i]=='7')
        {
            s=true;
        }
        if(s==true &&t==true && f==true)
        {
            ret=1;
        }
    }
    ret+=count(a*10+5);
    ret+=count(a*10+3);
    ret+=count(a*10+7);
  	return ret;
}


int main()
{
    cin>>num;
    cout<<count(0)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	int n=read(),k=read();
	for(int i=k-n+1;i<=k+n-1;i++)printf("%lld ",i);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi 2*acos(0.0)
#define MOD 1000000007
#define N 100001
#define SZ 1000006
int main()
{
    int n,i,flag=0,flag1=0,digit1;
    ll x,mul=1,digit=0;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>x;
        ll temp=x;
        flag1=0;
        while(temp>9)
        {
            digit++;
            digit1=temp%10;
            if(digit1>0)
                flag1=1;
            temp/=10;
        }
        if(flag1==1 && digit>=18)
            mul=-1;
        else
        {
            mul*=x;
        }
        if(mul>1000000000000000000 || mul<0)
        {
            mul=-1;
        }
        if(x==0)
        {
            flag=1;
        }
    }
    if(flag==1)
        mul=0;
    cout<<mul<<endl;
    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,c=0;
  cin>>n>>x;
  int a[n+1];
  a[0]=0;
  for(int i=1;i<=n;i++)
  {   int k;
      cin>>k;
      a[i]=a[i-1]+k;
     // cout<<a[i]<<" ";
  }
  for(int i=0;i<=n;i++)
  {
      if(a[i]>x)
      {   c=1;
          cout<<i;
          break;
      }
  }
  if(c==0)
    cout<<n+1;


}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Majk
 */

#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
constexpr int MOD = 1000000007;

typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned int ui;

template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;

struct input {
	std::istream &cin;
	explicit input(std::istream &cin) :cin(cin){}
	template <typename T> operator T() { T t; cin >> t; return t; }
};
#define $ input{cin}

int logceil(ll x) {int b=0;while(x){x>>=1;++b;}return b;}

namespace std {
    template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector<vector<T>>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector<vector<T>>>(a,vector<vector<T>>(b,vector<T>(c,t))){}};

// #include "../l/mod.h"

class D {
public:
	int N, S, W1;
	map<int, vector<int>> I;

	ll best(int w, ll weight, ll value) {
		if (w == W1+4) return value;

		ll ans = best(w+1, weight, value);
		for (int v: I[w]) {
			weight += w;
			value += v;
			if (weight > S) break;
			ans = max(ans, best(w+1, weight, value));
		}
		return ans;
	}

    void solve(istream& cin, ostream& cout) {
		cin >> N >> S;
		I.clear();
		for (int i = 0; i < N; ++i) {
			int v, w; cin >> w >> v;
			if (i==0) W1 = w;
			I[w].push_back(v);
		}

		for(auto it = I.begin(); it!=I.end();++it) {
			sort(it->y.begin(), it->y.end(), greater<int>());
		}
		cout << best(W1, 0LL, 0LL) << endl;
    }
};


int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	D solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void) {
	int i;
	string s;

	cin >> s;

	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


signed main(void){
    int A,B;
    cin >> A >> B;
    cout << A*B << endl;
    
    return 0;
}




Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <queue>
#include <cstring>
using namespace std;

#define EPS 1e-8

double calcR(double r1, double r2)
{
	return sqrt((r1+r2)*(r1+r2)-(r1-r2)*(r1-r2));
}

class Trl
{
public:
	int p, h;
	double c;
	Trl(int p, int h, double c)
	:p(p),h(h),c(c)
	{}
	
	bool operator<(const Trl& t) const
	{
		return c>t.c;
	}
};


bool v[13][1<<12];
		
int main()
{
	double cst[11][11]={0};
	for(int i=0; i<=10; i++)
		cst[0][i]=2*i;
		
	for(int i=3; i<=10; i++)
	for(int j=3; j<=10; j++)
		cst[i][j]=calcR(i,j)-i+j;
		
	int L;
	while(cin >> L)
	{
		int cake[13], p=0;
		cake[0]=0;
		while(cin.peek() != '\n')
		{
			cin >> cake[p+1];
			p++;
		}
		
		memset(v,0,sizeof(v));
		priority_queue<Trl> q;
		q.push(Trl(0,0,0));
		bool g=false;
		while(!q.empty())
		{
			Trl t=q.top(); q.pop();
			if(v[t.p][t.h]) continue;
			v[t.p][t.h]=1;
			
			if(t.h==(1<<p)-1)
			{
				g=true;
				break;
			}
		
			for(int i=0; i<p; i++)
			{
				if(t.h&(1<<i)) continue;
				double tc=t.c+cst[cake[t.p]][cake[i+1]];
				int th=t.h+(1<<i);
				if(v[i+1][th]) continue;
				if(tc>L+EPS) continue;
				
				q.push(Trl(i+1, th, tc));
			}
		}
		cout << (g?"OK":"NA") << endl;
	}
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

    int n,x,y;cin >> n >> x >> y;
    x--;y--;
    vi ans(n);
    rep(fst,n){
        vi dist(n,-1);
        queue<int> que;
        auto push = [&](int v,int d){
            if(dist[v] != -1)return;
            dist[v] = d;
            que.push(v);
        };

        push(fst,0);
        while(!que.empty()){
            int nv = que.front();que.pop();
            int d = dist[nv];

            if(nv-1>=0)push(nv-1,d+1);
            if(nv+1<n)push(nv+1,d+1);
            if(nv == x)push(y,d+1);
            if(nv == y)push(x,d+1);
        }
        rep(i,n)ans[dist[i]]++;
    }
    for(int i=1;i<n;i++){
        cout << ans[i]/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Result struct {
	elems []int
	count int
}

func calcG(length int) ([]int, error) {
	if length <= 0 {
		err := fmt.Errorf("illegal length: %d\n", length)
		return nil, err
	}
	n := length - 1
	g := []int{}
	for n > 1 {
		g = append(g, n)
		n = n / 2
	}
	g = append(g, 1)
	return g, nil
}

func insertionSort(elems []int, g int) Result {
	n := len(elems)
	count := 0
	for i := g - 1; i < n; i++ {
		v := elems[i]
		vi := i
		for j := i - g; j >= 0; j = j - g {
			if elems[j] > v {
				elems[j+g] = elems[j]
				vi = j
				count++
			} else {
				break
			}
		}
		elems[vi] = v
	}
	return Result{elems, count}
}

func shellSort(elems []int) (Result, []int) {
	g, _ := calcG(len(elems))
	count := 0
	for _, v := range g {
		result := insertionSort(elems, v)
		count += result.count
		elems = result.elems
	}
	return Result{elems, count}, g
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	elems := make([]int, n)
	for i := 0; i < len(elems); i++ {
		x, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		elems[i] = x
	}

	result, g := shellSort(elems)

	fmt.Println(len(g))
	fmt.Println(strings.Join(isToAs(g), " "))
	fmt.Println(result.count)
	fmt.Println(strings.Join(isToAs(result.elems), "\n"))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func isToAs(is []int) []string {
	as := make([]string, len(is))
	for i := 0; i < len(as); i++ {
		as[i] = strconv.Itoa(is[i])
	}
	return as
}



Measured memory_bytes: 71048
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
//繰り返し二乗法
ll ex(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==1)return ex(x,n-1)*x;
    else return ex(x*x,n/2);
};
int main(){
    ll n;
    cin >> n;
    
    bool flag=false;
    if(n%2==1)cout << 0 << endl;
    else{
        n/=2;
        ll sum=0;
        for(int i=1; i<1000; i++){
            sum+=n/ex(5,i);
            if(n/ex(5,i)==0)break;
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

#define MAX_N 100010

int n;
string s;
int ans[MAX_N];

bool check() {
  rep(i,n) {
    int next = ( i + 1 ) % n;
    int prev = ( i - 1 + n ) % n;
    if( ans[i] == 0 ) {
      if( s[i] == 'o' ) {
	if( !( ans[prev] == ans[next] ) ) return false;
      } else {
	if( !( ans[prev] != ans[next] ) ) return false;
      }
    } else {
      if( s[i] == 'o' ) {
	if( !( ans[prev] != ans[next] ) ) return false;
      } else {
	if( !( ans[prev] == ans[next] ) ) return false;
      }
    }
  }
  return true;
}

bool calc(int a,int b) {
  memset(ans,-1,sizeof ans);
  ans[0] = a, ans[1] = b;
  REP(i,1,n-1) {
    int next = ( i + 1 ) % n;
    int prev = ( i - 1 + n ) % n;
    if( s[i] == 'o' ) {
      if( ans[i] == 0 ) {
	ans[next] = ans[prev];
      } else {
	ans[next] = (ans[prev]+1)%2;
      }
    } else {
      if( ans[i] == 0 ) {
	ans[next] = (ans[prev]+1)%2;
      } else {
	ans[next] = ans[prev];
      }
    }
  }
  return check();
}

void compute() {
  rep(i,2) {
    rep(j,2) {
      if( calc(i,j) ) {
	rep(k,n) {
	  if( ans[k] == 0 ) cout << "S";
	  else cout << "W";
	} puts("");
	return;
      }
    }
  }
  puts("-1");
}

int main() {
  cin >> n >> s;
  compute();
  return 0;
}


Measured memory_bytes: 896
n,q = gets.split.map(&:to_i)
s = gets.chomp

k = Array.new(n + 1,0)
(1..n - 1).each do |i|
    cnt = 0
    if s[i] == 'C' && s[i - 1] == 'A' 
        k[i + 1] = k[i] + 1 
    else
    k[i + 1] = k[i]
    end
end

q.times do
    l,r = gets.split.map(&:to_i)
    puts k[r] - k[l]
end


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

int main() {
  //はイパボリックうんちっち
  int N,T;
  cin >> N >> T;
  int min=1000000001,ben=0;//benはうんち!
  int sum=0;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    if(a<min)min=a;
    else if((a-min)==ben)sum++;
    else if((a-min)>ben){
      sum=1;
      ben=a-min;
    }
  }
  cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

#include <set>
using namespace std;

int main(void){
	string str;
	int n;
	set<string> s;
	cin>>n;
	while(n--){
		cin>>str;
		if(str=="insert"){
			cin>>str;
			s.insert(str);
		}else{
			cin>>str;
			set<string>::iterator it;
			it=s.find(str);
			if(it==s.end()) cout<<"no"<<endl;
			else cout<<"yes"<<endl;
		}
	}
	return 0;
}

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

using namespace std;
using LL = long long;

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

	int n, k;
	cin >> n >> k;

	set <int> used;

	for(int i = 1; i <= k; ++i) {
		int d; cin >> d;
		for(int j = 0; j < d; ++j) {
			int x; cin >> x;
			used.insert(x);
		}
	}

	int ans = 0;
	for(int i = 1; i <= n; ++i) {
		ans += (!used.count(i));
	}

	cout << ans << '\n';

	return 0;	
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define vd void
#define il inline
using namespace std;
typedef long long ll;
il ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
#ifdef mod
il int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
#endif
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	ll n=gi(),a=gi(),b=gi();
	if(a+b+1&1)printf("%lld\n",llabs(a-b)+1>>1);
	else printf("%lld\n",std::min(a-1+(b-a+1)/2,n-b+(b-a+1)/2));
	return 0;
}



Measured memory_bytes: 256
//package Contest066;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter (System.out);
            int a = sc.nextInt(),b = sc.nextInt(),c = sc.nextInt();
            out.println(Math.min((a+b),Math.min(b+c,a+c)));


        out.flush();
    }
}


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

int main() {
  int n; cin >> n;
  vector<double> value(n);
  vector<string> coin(n);
  for(int i=0; i<n; i++) cin >> value[i] >> coin[i];
  
  double ans=0;
  for(int i=0; i<n; i++) {
    if(coin[i]=="JPY") ans+=value[i];
    else ans+=value[i]*380000.0;
  }
  
  cout << ans;
}

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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x < r | x + r > w | y < r | y + r > h) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
import copy

a = map(int,raw_input().split())

def myfunc(A):
  A.sort(reverse=True)
  if (A[0]%2 != 0 and A[1]%2 !=0 and A[2]%2 != 0):
    print A[1]*A[2]
  else:
    print 0

myfunc(a)

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a*b>c*d){
    cout<<a*b<<"\n";
    return(0);
  }
    if(a*b<c*d){
    cout<<c*d<<"\n";
    return(0);
  }
    cout<<a*b<<"\n";
    return(0);
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int,input().split())
u = UnionFind(n)

for _ in range(m): 
	a, b = map(lambda x: int(x)-1, input().split())
	u.union(a, b)

result = 0
for i in range(n): 
	result = max(result, u.size(i))

print(result)

Measured memory_bytes: 14756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();

		for(int i = 1; i <= K; i++) {
			int tmp = Math.max(Math.max(A, B), C);
			if(tmp == A) {
				A *= 2;
			}else if(tmp == B) {
				B *= 2;
			}else {
				C *= 2;
			}
		}
		int sum = A + B + C;
		System.out.println(sum);
	}

}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  char x;
  cin>>x;
  if(x=='a' || x=='e' || x=='i' || x=='o' || x=='u'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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 COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////



int main() {
ll a,b,n;
cin>>a>>b>>n;

ll ans=0;
ll fin=0;
for(ll i=0;i<=1000003;i++){
ll k=b-1+b*i;
if(k>n){k=n;
fin=1;}
ll p=(a*k)/b;
ll q=a*(k/b);
ans=max(ans,p-q);
if(fin)break;
}

cout<<ans<<endl;
return 0;

}





Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=200005;
priority_queue<pii,vector<pii>,greater<pii> > Q;
int pre[N],suf[N],q[N];
int a[N],l[N],r[N],n,L;
int Sl[N],Sr[N];
ll ans;
void erase(int x){
	suf[pre[x]]=suf[x];
	pre[suf[x]]=pre[x];
}
void work(){
	//printf("work %d %d\n",*q,ans);
	//For(i,1,*q) printf("%d %d %d\n",q[i],l[i],r[i]); puts("");
	int m=*q,pl,pr;
	q[0]=pre[q[1]];
	q[m+1]=suf[q[m]];
	Sl[0]=Sr[m+1]=0;
	For(i,1,m+1) Sl[i]=Sl[i-1]+l[q[i]];
	Rep(i,m,0) Sr[i]=Sr[i+1]+r[q[i]];
	For(i,L,m) ans+=1ll*r[q[i]]*Sl[i-L+1];
	pl=m+1,pr=max(1,m-L+2);
	Rep(i,m/L,1){
		pl-=L; pr=max(1,pr-L);
		l[q[i]]=Sl[pl]-Sl[pr-1];
	}
	pl=0,pr=min(m,L-1);
	For(i,1,m/L){
		pl+=L; pr=min(m,pr+L);
		r[q[i]]=Sr[pl]-Sr[pr+1];
	}
	if (m<L){
		For(i,2,m) erase(q[i]);
		a[q[1]]=1<<30;
		Q.push(pii(a[q[1]],q[1]));
	}
	else{
		For(i,1,m/L) ++a[q[i]];
		For(i,1,m/L) Q.push(pii(a[q[i]],q[i]));
		For(i,m/L+1,m) erase(q[i]);
		For(i,1,m/L) Sl[i]=Sl[i-1]+l[q[i]];
		For(i,L,m/L) ans-=1ll*r[q[i]]*Sl[i-L+1];
	}
}
int main(){
	scanf("%d%d",&n,&L);
	For(i,1,n) scanf("%d",&a[i]);
	For(i,1,n) l[i]=r[i]=1;
	For(i,1,n) pre[i]=i-1,suf[i]=i+1;
	For(i,1,n) Q.push(pii(a[i],i));
	while (!Q.empty()){
		q[++*q]=Q.top().se; Q.pop();
		if (a[q[1]]==1<<30) break;
		for (;!Q.empty()&&Q.top().fi==a[q[*q]];){
			int tmp=Q.top().se; Q.pop();
			if (tmp!=suf[q[*q]]) work(),*q=0;
			q[++*q]=tmp;
		}
		work(); *q=0;
	}
	printf("%lld\n",ans+n);
}

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

int main() {
    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i, n-1) cin >> b[i];
    vector<int> a(n);
    rep(i, n) {
        if (i == 0) {
            a[i] = b[i];
        }
        else if (i == n-1) {
            a[i] = b[i-1];
        }
        else {
            a[i] = min(b[i-1], b[i]);
        }
    }
    cout << accumulate(a.begin(), a.end(), 0) << endl;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define All(v) (v).begin(), (v).end()
#define Pb push_back

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

    ll n,m,x,a[101],cost1=0,cost2=0;
    cin >> n >> m >> x;
    rep(i,m) cin >> a[i];
    REP(i,x,n){
        rep(j,m){
            if(i==a[j]) cost1++;
        }
    }
    repr(i,x){
        rep(j,m){
            if(i==a[j]) cost2++;
        }
    }
    cout << min(cost1,cost2) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define INF 2000000000
#define llong long long
using namespace std;
int main(){
  int n;
  char str[10],com[13];
  map<string,bool> T;
  scanf("%d",&n);
  REP(i,n){
    scanf("%s %s",com,str);
    if(com[0]=='i') T[string(str)]=true;
    else {
      if(T[string(str)]) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 47468
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define print(n) cout << n << endl
#define in(v) int v; cin >> v
#define vint vector<int>
#define pb push_back
typedef long long int ll;


int main(){
  long double a,b;cin>>a>>b;
  cout<<setprecision(16)<<floor(a*b)<<endl;
  return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG
 
void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}
 
void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}
 
void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}
 
void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}
 
 
 
int main() {
  ll A,B,N;
  cin >> A >> B >> N;
  cout << min(B-1,N)*A/B << endl;
}

Measured memory_bytes: 3640
s=input()
t=input()
q=len(s)
w=len(t)
def qwe(s,t):
    ans=0
    for i,j in zip(s,t):
        if i!=j:
            ans+=1
    return ans

ans=10**10
for i in range(q-w+1):
    ans=min(ans, qwe(s[i:i+w], t))
print(ans)

Measured memory_bytes: 67444
fun main(args: Array<String>) {
    val N = readInputLine().toLong()

    if (N % 2 == 1L) {
        println(0)
    } else {
        var ans = 0L
        var div = 10L
        while (div <= N) {
            ans += N / div
            div *= 5L
        }
        println(ans)
    }
}

fun readInputLine(): String {
    return readLine()!!
}



Measured memory_bytes: 33756
import java.util.Scanner;
 
class Main{
	static public void main(String args[]){
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\\s");
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if(x+r<=W && x-r>=0 && y+r<=H && y-r>=0){
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26276
from itertools import product

N = int(input())
input_table = list([-1] * N for _ in range(N))
ans = 0

for i in range(N):
    A_i = int(input())
    for j in range(A_i):
        x_i_j, y_i_j = map(int, input().split())
        x_i_j -= 1
        input_table[i][x_i_j] = y_i_j

for pat in product((0, 1), repeat = N):
    for i in range(N):
        if pat[i] == 1:
            for j in range(N):
                i_says_j_is_kind = input_table[i][j]
                if i_says_j_is_kind == -1:
                    continue
                else:
                    if i_says_j_is_kind != pat[j]:
                        break
            else:
                continue
            break
    else:
        honest_persons = sum(pat)
        ans = max(ans, honest_persons)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	long double r,pi=3.1415926535;
	cin>>r;
	cout<<r*2*pi<<endl;
	return 0;
}

Measured memory_bytes: 3788
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/9/ITP1_9_C

#include <iostream>
#include <cstring>

int main()
{
    int n;
    std::string tCard, hCard;
    int tPoint = 0;
    int hPoint = 0;

    std::cin >> n;

    while (n)
    {
        std::cin >> tCard >> hCard;

        int tlen = tCard.length();
        int hlen = hCard.length();

        for (int i = 0; i < tlen && i < hlen; i++)
        {
            if (tCard.c_str()[i] > hCard.c_str()[i])
            {
                tPoint += 3;
                break;
            }
            else if (tCard.c_str()[i] < hCard.c_str()[i])
            {
                hPoint += 3;
                break;
            }
            else if (tCard.c_str()[i] == hCard.c_str()[i])
            {
                if (i == tlen - 1 || i == hlen - 1)
                {
                    if (tlen == hlen)
                    {
                        tPoint++;
                        hPoint++;
                    }
                    else if (tlen < hlen)
                    {
                        hPoint += 3;
                    }
                    else if (tlen > hlen)
                    {
                        tPoint += 3;
                    }
                }
            }
        }
        n--;
    }

    std::cout << tPoint << " " << hPoint << std::endl;
}


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

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  cout<<a.at(N/2)-a.at(N/2-1)<< endl;
  
}


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

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define mx			2050
#define inf			1e9
#define pb			push_back
#define mod			1234567

using namespace std;

typedef long long ll;

int main(){
	int a, b;
	cin >> a >> b;
	if(a <= 0 && 0 <= b) cout << "Zero\n";
	else{
		if(a < 0 && b < 0){
			int v = b - a + 1;
			if(v % 2 == 0) printf("Positive\n");
			else printf("Negative\n");
		}
		else if(a > 0 && b > 0) printf("Positive\n");
		else assert(0);
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] t = new long[n];
        for(int i = 0; i < n; i++) {
        	t[i] = sc.nextLong();
        }
        if(n == 1) {
        	System.out.println(t[0]);
        	return;
        }
        long lcm = 1;
        for(int i = 0; i < n; i++) {
        	lcm = lcm / gcd(lcm, t[i]) * t[i];
        }
        System.out.println(lcm);
    }
	
	public static long gcd(long a, long b) {
		if(a % b == 0) return b;
		return gcd(b, a % b);
	}
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(){
  int N,Na,Nb,Nc;
  scanf("%d",&N);
  Na = N/100;
  Nb = (N-Na*100)/10;
  Nc = N-Na*100-Nb*10;
  if(Na==7 || Nb==7 || Nc==7){
    printf("%s","Yes");
  } else {
    printf("%s","No");
  }
  
  
  
  
 return 0; 
}

Measured memory_bytes: 1732
def bfs_min(w,h,data):
    queue = [[0,0]]
    check = [[0,0]]
    memo = [[0 for j in range(w)] for i in range(h)]
    while True:
        if len(queue) != 0:
            s = queue[0]
            hNow,wNow = s[0],s[1]
        else:
            return -1

        if hNow == H-1 and wNow == W-1:
            return memo[H-1][W-1]
        queue.pop(0)

        if hNow < h-1:
            if (data[hNow+1][wNow] == '.') and ([hNow+1,wNow] not in check):
                queue.append([hNow+1,wNow])
                check.append([hNow+1,wNow])
                memo[hNow+1][wNow] = memo[hNow][wNow] + 1

        if wNow < w-1:
            if (data[hNow][wNow+1] == '.') and ([hNow,wNow+1] not in check):
                queue.append([hNow,wNow+1])
                check.append([hNow,wNow+1])
                memo[hNow][wNow+1] = memo[hNow][wNow] + 1

        if hNow > 0:
            if (data[hNow-1][wNow] == '.') and ([hNow-1,wNow] not in check):
                queue.append([hNow-1,wNow])
                check.append([hNow-1,wNow])
                memo[hNow-1][wNow] = memo[hNow][wNow] + 1

        if wNow > 0:
            if (data[hNow][wNow-1] == '.') and ([hNow,wNow-1] not in check):
                queue.append([hNow,wNow-1])
                check.append([hNow,wNow-1])
                memo[hNow][wNow-1] = memo[hNow][wNow] + 1
        
        
            
    
    
    
    





H,W = list(map(int,input().split()))
s = [list(input()) for i in range(H)]
wh = 0
bl = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            wh += 1
        else:
            bl += 1

if bfs_min(W,H,s) >= 0:
    print(wh - bfs_min(W,H,s) - 1)
else:
    print(-1)
        

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

using namespace std;

int Solve(vector<long long int> res, long long int point) {
	sort(res.begin(), res.end(), greater<long long int>());
	int t = 0;
	for (int i = 0; point > 0; i++) {
		point -= res[i];
		t++;
	}
	return t;
}

int main()
{
	int D, G, pmax = 0;
	cin >> D >> G;
	vector<long long int>p(D);
	vector<long long int>c(D);
	for (int i = 0; i < D; i++) {
		cin >> p[i] >> c[i];
		pmax += p[i];
	}

	int pmin = pmax;

	for (int i = 0; i < (1 << D); i++) {
		long long int sp = G;
		int sw = 0;
		vector<long long int>res;
		for (int j = 0; j < D; j++) {
			if ((i&(1 << j)) != 0) {
				sp -= 100 * (j + 1) * p[j] + c[j];
				sw += p[j];
			}
			else {
				for (int k = 0; k < p[j]; k++)
					res.push_back(100 * (j + 1));
			}
		}
		if (sp <= 0)
			pmin = min(pmin, sw);
		else {
			pmin = min(pmin, sw + Solve(res, sp));
		}
	}

	cout << pmin << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 1000000001
#define MOD 10000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
int main(){
      ll sum[100][100];
      int n,a;
      cin>>n;
      memset(sum,0,sizeof(sum));
      REP(i,n){
            REP(j,n){
                  cin>>sum[j][i];
            }
      }
      REP(i,n){
            REP(j,n){
                  if(i==0&&j==0)continue;
                  if(i!=0)sum[j][i]+=sum[j][i-1];
                  if(j!=0)sum[j][i]+=sum[j-1][i];
                  if(i!=0&&j!=0)sum[j][i]-=sum[j-1][i-1];
            }
      }
      ll ans=sum[0][0];
      REP(i,n)REP(j,n)REP(k,n)REP(l,n){
            if(k<i||l<j)continue;
            ll res=sum[l][k];
            if(i!=0)res-=sum[l][i-1];
            if(j!=0)res-=sum[j-1][k];
            if(i!=0&&j!=0)res+=sum[j-1][i-1];
            ans=max(res,ans);
      }

      cout<<ans<<endl;
}

Measured memory_bytes: 1252
N = int(input())
S = input()

r , g, b = S.count("R"), S.count("G"), S.count("B")
ans = r * g * b

for i in range(N-2):
    for j in range(i+1, N-1):
        k = 2*(j+1) - (i+1) # j > iより k = 2j - i > j
        if k <= N:
            if S[i] != S[j] and S[j] != S[k-1] and S[k-1] != S[i]:
                ans -= 1
print(ans)

Measured memory_bytes: 68012
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");

const nums = input[0].split(" ").map(n => Number(n));
if (nums[0] < nums[2] && nums[2] < nums[1]) {
    console.log("Yes");
} else if (nums[1] < nums[2] && nums[2] < nums[0]){
    console.log("Yes");
} else {
    console.log("No");
}


Measured memory_bytes: 7372
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i].first >> a[i].second;
		a[i].first--;
	}
	for (int i = 0; i <= 999; i++) {
		string s = to_string(i);
		if (s.size() != n)continue;
		bool flag = true;
		for (int j = 0; j < m; j++) {
			if (a[j].second != s[a[j].first] - '0') {
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

int main() {
	static char s[N + 1], t[N + 1];
	int n, i;

	scanf("%d%s%s", &n, s, t);
	for (i = 0; i < n; i++)
		printf("%c%c", s[i], t[i]);
	printf("\n");
	return 0;
}


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

#define ll long long int
#define pb push_back
#define ifor for(i=0; i<n; i++)

using namespace std;

ll INF=1e10;

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL); cout.tie(NULL);

    ll n, m;
    vector < ll > a, b, c, d;
    ll i, j, clo;
    cin>>n>>m;
    ll x, y, dis, pos;
    ifor
    {
        cin>>x>>y;
        a.pb(x); b.pb(y);
    }
    for(i=0; i<m; i++)
    {
        cin>>x>>y;
        c.pb(x); d.pb(y);
    }
    ifor
    {   clo=INF;
        for(j=0; j<m; j++)
        {
            dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(dis<clo) {clo=dis; pos=j+1;}
        }
        cout<<pos<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
x=gets.split.map(&:to_i)
s=x[k-1]-x[0]
ans=s+((x[0].abs<x[k-1].abs)? x[0].abs : x[k-1].abs)
(k..(n-1)).each{|i|
  f=i-k+1
  t=x[i]-x[f]
  u=t+((x[f].abs<x[i].abs)? x[f].abs : x[i].abs)
  ans=ans<u ? ans:u
}
puts ans

Measured memory_bytes: 8460
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>
using namespace std;
main() {
    vector<int> xs(5); for(auto& x:xs) cin>>x;
    int min_= INT_MAX;
    do {
        int time=0;
        for(auto x:xs) {
            time= (time+9) /10*10;
            time+= x;
        }
        min_= min(min_, time);
    } while (next_permutation(xs.begin(), xs.end()));
    cout<< min_ <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const int MAX = 4;

static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

int main() {
	string s; cin >> s;

	bool a = s[0] == s[s.size() - 1];
	bool b = s.size() % 2;
	cout << ((a ^ b) ? "First" : "Second") << endl;

	return 0;
}

Measured memory_bytes: 512
N,x=map(int,input().split())
A=list(map(int,input().split()))
count=0
for i in range(N-1):
    if A[i]+A[i+1]>x:
        count+=A[i]+A[i+1]-x
        A[i+1]-=A[i]+A[i+1]-x
        if A[i+1]<0:
            A[i]+=A[i+1]
            A[i+1]=0
print(count)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

ll game(ll str,ll end,vector<ll> &v,vector<vector<ll> > &dp)
{	
	
	if(str>end)
		return 0;
	if(str+1==end||str==end)
		return(dp[str][end]=max(v[str],v[end]));
		
	if(dp[str][end]!=-1)
		return dp[str][end];
		
	if(dp[str+2][end]==-1)
		dp[str+2][end]=game(str+2,end,v,dp);
	
	if(dp[str+1][end-1]==-1)
		dp[str+1][end-1]=game(str+1,end-1,v,dp);
		
	if(dp[str][end-2]==-1)
		dp[str][end-2]=game(str,end-2,v,dp);
		
	dp[str][end]=max(v[str]+min(dp[str+2][end],dp[str+1][end-1]),v[end]+min(dp[str+1][end-1],dp[str][end-2]));
	
	return dp[str][end];
}
void solve()
{ll n,m,x,y,z,d,p=0,b=0,q,l=INT_MAX,k,mini=0,prev;
 cin>>n;
 vector<ll> v(n);
 for(ll i=0;i<n;i++)
 {
 	cin>>v[i];  p+=v[i];
 }
 
 vector<vector<ll> > dp(3005,vector<ll>(3005,-1));//a(3005,vector<ll>(m,0));
 cout<<(2*game(0,n-1,v,dp))-p;
}

int main()
{
  fast
ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 73108
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
    string s;
    vector<char> ch;
    while(cin>>s)
    {
        int len1=s.size();
        for(int i=0;i<len1;i++)
        {
            if(s[i]=='0')
            {
                ch.push_back('0');
            }
            else if(s[i]=='1')
            {
                ch.push_back('1');
            }
            else if(!ch.empty())
            {
                ch.pop_back();
            }
        }
        int len2=ch.size();
        for(int i=0;i<len2;i++)
        {
            cout<<ch[i];
        }
        cout<<endl;
    }
    return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
    int n;
    string s;
    map<string, int> mp;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> s;
        mp[s]++;
    }
    vector<pair<string, int> > v;
    for (auto &x : mp) {
        v.pb({x.fi, x.se});
    }
    sort(v.begin(), v.end(), [](pair<string, int> &a, pair<string, int> &b) {
        if (a.se == b.se) return a.fi < b.fi;
        return a.se > b.se;
    });
    cout << v[0].fi << endl;
    int maxx = v[0].se;
    for (int i = 1; i < v.size(); i++) {
        if (v[i].se == maxx) cout << v[i].fi << endl;
        else break;
    }
}

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


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

int balls[10];

bool dfs(int left, int right, int currentID){
	if(currentID > 9) return true;
	
	bool ok = false;
	if (left < balls[currentID]){
		ok = dfs(balls[currentID], right, currentID+1);
	}
	if (right < balls[currentID]){
		ok = dfs(left, balls[currentID], currentID+1);
	}
	return ok;
}

int main() {
	int n; cin >> n;
	
	while(n--){
		for (int i = 0; i < 10; i++) cin >> balls[i];
		cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 3056
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  unordered_map<long, long> mp;
  long crown = 0;
  cin >> N;
  rep (i, N) {
    long a;
    cin >> a;
    if (a < 3200) mp[a / 400]++;
    else crown++;
  }
  long minimum = mp.size();
  if (minimum == 0 and crown != 0) minimum = 1;
  long maximum = mp.size() + crown;
  cout << minimum << " " << maximum << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main(){
    long N,mc=0,ac=0,rc=0,cc=0,hc=0;
    cin >> N;
    string s;
    char temp;
    rep(i,N){
        cin >> s;
        temp=s.at(0);
        if(temp=='M') ++mc;
        if(temp=='A') ++ac;
        if(temp=='R') ++rc;
        if(temp=='C') ++cc;
        if(temp=='H') ++hc;
    }
    long long ans=0;
    ans=((mc*ac*rc)+(mc*ac*cc)+(mc*ac*hc)+(mc*rc*cc)+(mc*rc*hc)+(mc*cc*hc)+(ac*rc*cc)+(ac*rc*hc)+(ac*cc*hc)+(rc*cc*hc));
    cout << ans << endl;
}

Measured memory_bytes: 256