akhauriyash/Code-Regression huggingface dataset:
/**Bismillahir Rahmanir Rahim.**/

/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>

using namespace std;

//----------------------------------------------------------//

typedef long long int                        ll;
typedef unsigned long long int              ull;
typedef long double                          ld;

//-----------------------------------------------------------//
#define      test                       int t; cin>>t;  while(t--)

#define      cube(x)                    (x*x*x)
#define      sqr(x)                     (x*x)

#define      INPUT                      freopen("input.txt", "r", stdin)
#define      OUTPUT                     freopen("output.txt", "w", stdout)

#define      srev                       reverse(s.begin(),s.end())
#define      sortstr                    sort(s.begin(), s.end());
#define      gtl(x)                     getline(cin, (x))
#define      dot(x)                     fixed << setprecision(x)

#define      Case                       cout << "Case " << ++tt << ": " ;

#define      PI                         acos(-1) // 3.1415926535897932
#define      MIN                        9999999
#define      EPS                        (1e-7)

#define      Faster                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);




//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


//--------------------------------------Solution------------------------------//

int main()
{

    #ifndef ONLINE_JUDGE
    clock_t tStart = clock();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    Faster;


    int tt = 0 ;

    string s;
    
    cin >> s ;

    int len = s.size() ;

    if (s[len - 1] == 's')
        cout << s << "es" << endl;
    else
        cout << s << "s" << endl;

    #ifndef ONLINE_JUDGE
    fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif


    return 0 ;
}


Measured memory_bytes: 3604
// AOJ 0202

#include <iostream>
#include <algorithm>

using namespace std;

const int limit = 1000500;

bool prime[limit];
void p(void)
{
	fill(prime, prime + limit, true);
	prime[0] = prime[1] = false;
	for (int i = 2; i * i < limit; i++){
		if (prime[i]){
			for (int j = i * 2; j < limit; j += i){
				prime[j] = false;
			}
		}
	}
	return;
}

int main(void)
{
	p();

	int n, x;
	while (cin >> n >> x, n || x){
		bool dp[limit]; fill(dp, dp + limit, false);
		int hanayo[35];

		for (int i = 0; i < n; i++){
			cin >> hanayo[i];
		}

		for (int i = 0; i < n; i++){
			int kotori = hanayo[i];
			dp[kotori] = true;
			// cout << kotori << " ***** " << endl;
			for (int j = 0; j < limit; j++){
				if (dp[j] && j + kotori <= x){
					// cout << j << " " << kotori << endl;
					dp[j + kotori] = true;
				}
			}
		}

		int ret = -1;
		for (int i = x; i >= 0; i--){
			if (prime[i] && dp[i]){
				ret = i;
				break;
			}
		}
		if (ret == -1){
			cout << "NA" << endl;
		}
		else {
			cout << ret << endl;
		}
	}

	return 0;
}

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

int main() {
    int K; cin >> K;
    int r = 7 % K;
    for (int i = 1; i <= K; i++) {
        if (r == 0) {
            cout << i << endl;
            return 0;
        }
        r = (10 * r + 7) % K;
    }
    cout << -1 << endl;
}

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

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

using namespace std;
using lint=long long;

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

	lint sum=0;
	map<int,int> f;
	rep(i,n){
		int a; scanf("%d",&a);
		sum+=a;
		++f[a];
	}

	int q; scanf("%d",&q);
	rep(_,q){
		int b,c; scanf("%d%d",&b,&c);
		lint cnt=f[b];
		sum+=cnt*(c-b);
		f[b]=0;
		f[c]+=cnt;
		printf("%lld\n",sum);
	}

	return 0;
}


Measured memory_bytes: 8204
a=int(input())
b=[]
d=0
e=[]
m=['S','H','C','D']
for i in range(a):
    c=input()
    b.append(c.split(" "))
for w in range(4):
    for n in range(13):
        if b.count([m[w],str(n+1)])==0:
            d+=1
            e.append([m[w],str(n+1)])

for g in range(d):
    print(e[g][0],e[g][1])


Measured memory_bytes: 5600
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	int p[20];

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

	int ans = 0;
	for (int i = 1; i + 1 < n;i++) {
		if (p[i-1] < p[i] && p[i] < p[i+1] || p[i - 1] > p[i] && p[i] > p[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n;
  cin >> n;
  int cnt = 0;
  vector<int> a(n);
  cin >> a;
  rep3(i, 1, n - 1) {
    vector<pii> v;
    v.eb(a[i - 1], i - 1);
    v.eb(a[i], i);
    v.eb(a[i + 1], i + 1);
    sort(all(v));
    if (v[1].S == i) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Ma = sc.nextInt();
		int Mb = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}

		int[][][] dp = new int[N + 1][401][401];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < dp[0].length; j++) {
				Arrays.fill(dp[i][j], Integer.MAX_VALUE);
			}
		}
		dp[0][0][0] = 0;
		for (int i = 1; i <= N; i++) {
			for (int j = 0; j < dp[i].length; j++) {
				for (int k = 0; k < dp[i][j].length; k++) {
					dp[i][j][k] = dp[i - 1][j][k];
					if (a[i - 1] <= j && b[i - 1] <= k) {
						if (dp[i - 1][j - a[i - 1]][k - b[i - 1]] == Integer.MAX_VALUE)
							continue;
						dp[i][j][k] = Math.min(
								dp[i][j][k], dp[i - 1][j - a[i - 1]][k - b[i - 1]] + c[i - 1]
						);
					}
				}
			}
		}

		int answer = Integer.MAX_VALUE;
		for (int i = 1; i < 1000; i++) {
			if (Ma * i > 400 || Mb * i > 400) break;
			answer = Math.min(answer, dp[N][i * Ma][i * Mb]);
		}

		if (answer == Integer.MAX_VALUE) {
			System.out.println(-1);
		} else {
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 53456
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvl G;
vl visited;
ll n, m;
ll ans = 0;

void check() {
    ll ok = 1;
    rep(i, n) {
        if(!visited[i]) {
            ok = 0;
        }
    }
    if(ok) {
        ans++;
    }
}

void dfs(ll v) {
    check();
    for(auto u : G[v]) { 
        if(visited[u]) {
            continue;
        }
        visited[u] = 1;
        dfs(u);
        visited[u] = 0;
    }
}

int main() {
    
    cin >> n >> m;    

    G.resize(n);
    visited.resize(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    visited[0] = 1;
    dfs(0);

    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    rp(i,n+1){
        if((int)(i*1.08)==n){
            print(i);
            return;
        }
    }
    print(":(");
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  f(i,n)       for(int i=0; i<n; i++)
#define  ff(i,j,n)    for(int i=int(j);i<=int(n);++i)
#define  sf(i)        scanf("%d",&i)
#define  pf(i)        printf("%d",i)
#define  pb(x)        push_back(x);
#define  in(x)        int x; cin>>x;
#define  w(t)         int t; cin>>t; while(t--)
#define  d(x)         cout<<x<<"\n"
#define  endl         "\n"
#define  fopen        freopen("in.txt", "r" , stdin),freopen("out.txt", "w" , stdout)
#define  fastio       ios::sync_with_stdio(0),cin.tie(0)
#define  PI           acos(-1.0)
#define  all(v)       v.begin(),v.end()
#define  mem(a,value) memset(a,value,sizeof(a))
#define  vi           vector<int>

typedef long long     ll;

const int mod = 1000000007;
using namespace std;

int main() {

    in(n);

    ll sum = 0;
    ff(i,1,n)
    ff(j,1,n)
    ff(k,1,n) {
        sum+= __gcd(__gcd(i,j),k);
    }
    d(sum);
}



Measured memory_bytes: 3636
import sys
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
li = []
C = sorted(Counter(a).items())
for i in range(len(C)):
    if C[i][1] >= 4:
        li.append(C[i][0])
        li.append(C[i][0])
    elif C[i][1] >= 2:
        li.append(C[i][0])
if len(li) <= 1:
    print(0)
    sys.exit()
print(li[-1]*li[-2])

Measured memory_bytes: 25864
import scala.io.StdIn.{readLong,readLine}
object Main {
    def main(args: Array[String]): Unit = {
        val input = readLine.split(" ").map(_.toInt) 
        val luggages = (1 to input(0)).foldLeft(Nil: List[Long]) { (list, v) => readLong :: list}
        println(allocation(input(1), luggages.reverse))
    }
    def allocation(k: Int, wList: List[Long]): Long = {
        // 最大積載量 = capacity の場合にトラックに荷物が乗り切るかどうか
        def inCapacity(luggages: List[Long], truck: Int, capacity: Long, curr: Long): Boolean = luggages match {
            case Nil => true
            case x :: xs if (x > capacity) => false
            case x :: xs => curr + x match {
                case tmp if tmp > capacity && truck == 1 => false
                case tmp if tmp > capacity => inCapacity(xs, truck - 1, capacity, x)
                case tmp => inCapacity(xs, truck, capacity, tmp)
            }
        }
        def binSearch(min: Long, max: Long, currMin: Long): Long = (min + max) / 2 match {
            case median if min == max => if (median < currMin && inCapacity(wList, k, median, 0L)) median else currMin
            case median => inCapacity(wList, k, median, 0) match {
                case true => binSearch(min, median, median)
                case false => binSearch(median + 1, max, currMin)
            }
        }

        val maxCapa = wList.sum
        binSearch(0L, maxCapa, maxCapa)
    }
}


Measured memory_bytes: 67504
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        long[] a = new long[N];
        long sumA = 0;
        for (int i = 0; i < N; i++) {
        	a[i] = sc.nextLong();
        	sumA += a[i];
        }
        
        long[] b = new long[N];
        long sumB = 0;
        for (int i = 0; i < N; i++) {
        	b[i] = sc.nextLong();
        	sumB += b[i];
        }
        
        if (sumA < sumB) {
        	System.out.println(-1);
        	return;
        }
        
        long[] sa = new long[N];
        for (int i = 0; i < N; i++) {
        	sa[i] = a[i] - b[i];
        }
        
        Arrays.sort(sa);
        
        int count = 0;
        long sum = 0;
        while(sa[count] < 0) {
        	sum += Math.abs(sa[count]);
        	count++;
        }
        
        int endIndex = sa.length-1;
        while(sum > 0) {
        	sum -= sa[endIndex];
        	endIndex--;
        	count++;
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 79692
a = [input().split() for l in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
ans = 'No'
for i in range(3):
        for j in range(3):
                a[i][j] = int(a[i][j])
                for k in range(N):
                        if a[i][j] == b[k]:
                                a[i][j] = 0
for i in range(3):
        if a[i][0] + a[i][1] + a[i][2] == 0:
                ans = 'Yes'
for i in range(3):
        if a[0][i] + a[1][i] + a[2][i] == 0:
                ans = 'Yes'
if a[0][0] + a[1][1] + a[2][2] == 0:
        ans = 'Yes'
if a[0][2] + a[1][1] + a[2][0] == 0:
        ans = 'Yes'


print(ans)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max<R>(x, 0.0));}

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

// Problem Specific Parameter:
// http://codeforces.com/blog/entry/18051

template <int depth>  struct Segment_tree {
	const static int h = depth;
	const static int n = 1 << h;

	using T = long long;
	T data[2 * n], lazy[2 * n];
	const T out = (1LL << 31) - 1;

	inline T vmerge(T l, T r) {return min(l, r);}

	void init() {
		fill_n(data, 2 * n, out);
		fill_n(lazy, 2 * n, out);
	}

	// lazy_evaluation

	void apply(T v, int p, int l, int r) {
		data[p] = v;
		lazy[p] = v;
	}

	void push(int p, int l, int r) {
		const int m = (l + r) / 2;
		if (lazy[p] == out) return;
		apply(lazy[p], 2 * p + 1, l, m);
		apply(lazy[p], 2 * p + 2, m, r);
		lazy[p] = out;
	}

	void range_update(int a, int b, T x, int k = 0, int l = 0, int r = n) {
		if (r <= a or b <= l) return;
		if (a <= l and r <= b) return apply(x, k, l, r);
		push(k, l, r);
		const int m = (l + r) / 2;
		range_update(a, b, x, k * 2 + 1, l, m);
		range_update(a, b, x, k * 2 + 2, m, r);
		data[k] = vmerge(data[k * 2 + 1], data[k * 2 + 2]);
	}

	T range_query(int a, int b, int k = 0, int l = 0, int r = n) {
		if (r <= a or b <= l) return out;
		if (a <= l and r <= b) return data[k];
		push(k, l, r);
		const int m = (l + r) / 2;
		T vl = range_query(a, b, k * 2 + 1, l, m);
		T vr = range_query(a, b, k * 2 + 2, m, r);
		return vmerge(vl, vr);
	}
};

Segment_tree<17> seg;



int main(void) {
	int n, q;
	cin >> n >> q;

	seg.init();

	rep(loop, q) {
		int com, s, t, x;
		cin >> com;
		if (com) {
			cin >> s >> t;
			cout << seg.range_query(s, t + 1) << endl;
		} else {
			cin >> s >> t >> x;
			seg.range_update(s, t + 1 , x);
		}
	}
	return 0;
}

Measured memory_bytes: 7228
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
using namespace std;
#define ll long long

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;
	return 0;
}

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

int main() {
 int k,n;
    cin >> k >> n;
 vector<int> a(n + 5);
    rep(i,n) {
    cin >>a.at(i);
    }
    
    int dist = 0;
    
    rep(i,n - 1) {
     dist = max(dist, a.at(i+1) - a.at(i));
    }
    
    dist = max((k - a.at(n - 1) + a.at(0)), dist);
    
    cout << k - dist;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
using ll = long long;

int op(int a, int b) { return max(a, b); }

int e() { return -1; }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, Q;
    cin >> N >> Q;
    atcoder::segtree<int, op, e> st(N);
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        st.set(i, a);
    }
    for(int j=0; j<Q; j++)
    {
        int t, x, v;
        cin >> t >> x >> v;
        if(t == 1) st.set(x - 1, v);
        else if(t == 2) cout << st.prod(x - 1, v) << '\n';
        else if(t == 3){
            auto f = [v](int a) -> bool { return a < v; };
            cout << st.max_right<decltype(f)>(x - 1, f) + 1 << '\n';
        }
    }

    return 0;
}


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

int main() 
{
    string s;
    cin>>s;
    if(s=="RRS")
    {
        cout<<"2"<<endl;
    }
    else if(s=="RRR")
    {
        cout<<"3"<<endl;
    }
    else if(s=="SSS")
    {
        cout<<"0"<<endl;
    }
    else if(s=="RSR")
    {
        cout<<"1"<<endl;
    }
    else if(s=="RSS")
    {
        cout<<"1"<<endl;
    }
    else if(s=="SRS")
    {
        cout<<"1"<<endl;
    }
    else if(s=="SSR")
    {
        cout<<"1"<<endl;
    }
    else if(s=="SRR")
    {
        cout<<"2"<<endl;
    }
    
	return 0;
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
 
int func(int N){
  if(N<10) return N;
  return func(N/10)+N%10;
}
int main() {
  int N;
  cin>>N;
  int c=func(N);
  if(N%c==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

int main()
{
    /*
    const double PI=3.14159265358979323846;
    double r;
    cin>>r;
    cout<<2.0*PI*r;
    */
    /*
    int n,m;
    cin>>n>>m;
    
    for(int i=0;i<m;i++)
    {
        int x;
        cin>>x;
        n-=x;
    }
    if(n<0)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<n<<endl;
    }
    */

    int n;
    cin>>n;
    vector <pair<int,int>> a(n);
    a[0].first = 1;
    a[0].second = 0;
    for(int i=1;i<n;i++)
    {
        a[i].first=i+1;
        cin>>a[i].second;
    }

    map <int,int> mp;
    for(int i=1;i<n;i++)
    {
        mp[i];
    }
    for(int i=1;i<n;i++)
    {
        mp[a[i].second-1]++;
    }

    for(auto it = mp.begin(); it != mp.end(); ++it)
    {
        cout <<it->second << "\n";
    }


    return 0;
}

Measured memory_bytes: 13988
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S,str = "2019/04/30";
    cin >> S;
    if(S > str)cout << "TBD" << endl;
    else cout << "Heisei" << endl;
}


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

struct Node {
    Node *parent;
    Node *left;
    Node *right;
    int key;
};

Node *NIL, *root;

void init() {
    root = NIL;
}

void insert(int key) {
    Node *y = NIL;
    Node *x = root;
    while (x != NIL) {
        y = x;
        if (key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    Node *node = (Node *)malloc(sizeof(Node));
    node->parent = y;
    node->key = key;
    node->left = NIL;
    node->right = NIL;
    if (y == NIL) {
        root = node;
    } else if (key < y->key) {
        y->left = node;
    } else {
        y->right = node;
    }
}

void printByPreorder(Node *node) {
    if (node == NIL) {
        return;
    }

    cout << " "<< node->key;
    printByPreorder(node->left);
    printByPreorder(node->right);
}

void printByInorder(Node *node) {
    if (node == NIL) {
        return;
    }

    printByInorder(node->left);
    cout << " "<< node->key;
    printByInorder(node->right);
}

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

    string command;
    int key;
    for (int i = 0; i < n; i++) {
        cin >> command;
        if (command == "insert") {
            cin >> key;
            insert(key);
        } else {
            printByInorder(root);
            cout << endl;
            printByPreorder(root);
            cout << endl;
        }
    }
}


Measured memory_bytes: 26560
N,M = [int(x) for x in input().split()]       
s=list(N*"0")

for i in range(M):    
    x,y =[z for z in input().split()]
    
    if x=="1" and y=="0" and N > 1:
        print(-1)
        exit()
        
    if s[int(x)-1] == "0" or s[int(x)-1]==y:
        s[int(x)-1]=y 
    else:
        print(-1)
        exit()
if s[0]=="0" and N>1:s[0]="1"     
print(''.join(s))


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main()
{
    char str[105];
    int find=1,i;
    unsigned int a;
    scanf("%s",str);
    a=strlen(str);
    for(i=0;i<a;i+=2)
    {
        if(str[i]=='L')
        {
            find=0;
            break;
        }
    }
    if(find==1){for(i=1;i<a;i+=2)
    {
        if(str[i]=='R')
        {
            find=0;
            break;
        }
    }
    }
    if(find==1){
        printf("Yes");
    }else{
    printf("No");
    }
}


Measured memory_bytes: 128
#include<stdio.h>   //B - Shift only

int main(){

    int num;
    int flag = 0;
    int count = 0;
    scanf("%d",&num);
    int n[num];

    for(int i=0;i<num;i++){
        scanf("%d",&n[i]);
    }

    while(flag==0){
        for(int i=0;i<num;i++){
            if(n[i]%2==1){
                flag=1;
                count--;
                break;
            }else{
                n[i]=n[i]/2;
            }
        }
        count++;
    }
    printf("%d\n",count);
    
    return 0;
}

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

using namespace std;

int main() {
		
	long n;
	cin >> n ;

	for (long i = 0; i < n; i++) {
		string x, y;
		cin >> x >> y;
		long xl, yl;
		xl = x.size();
		yl = y.size();
		vector<vector<long>> dp(xl+1, vector<long> (yl+1,0));
		for (long j = 0; j < xl; j++) {
			for (long k = 0; k < yl; k++) {

				if (x[j] == y[k]) {
					dp[j+1][k+1] =dp[j][k]+1;
				}
				else{
					dp[j + 1][k + 1] = max(dp[j][k + 1], dp[j + 1][k]);
				}
			}
		}
		cout << dp[xl][yl] << endl;
	}

	return 0;

}


Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define coord_comp(v) sort(all(v)), v.erase(unique(all(v)), v.end())
#define v_index(v, x) (lower_bound(all(v),x)-(v).begin())
typedef pair<int,int> pp;
typedef long long ll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T1,typename T2>
void read(pair<T1,T2>& p){ read(p.first); read(p.second); }
template<typename T,typename... Args>
void read(T&a,Args&...b){ read(a); read(b...); }

int n;

int main(){
	read(n);
	priority_queue<int> pq;
	for(;n--;){
		int buf; read(buf); pq.push(-buf);
		read(buf); pq.push(-buf);
	}
	int ans=0;
	while(pq.size()){
		int a=pq.top(); pq.pop();
		int b=pq.top(); pq.pop();
		ans -= max(a,b);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] p = new int[n];

        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 1; i < n-1; i ++) {
            if (p[i-1] < p[i] && p[i] < p[i+1] ||
                    p[i-1] > p[i] && p[i] > p[i+1])
                ans++;
        }

        System.out.println(ans);
    }
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

// undirected
void addEdge(Graph& G, int x, int y) {
    G[x].emplace_back(y);
    G[y].emplace_back(x);
}

vector<int> bfs(const Graph& G, int s) {
	int n = G.size();
    vector<int> d(n, inf);
	queue<int> que;
    que.push(s);
    d[s] = 0;

    while (!que.empty()) {
        int pre = que.front(); que.pop();
        for (auto nxt: G[pre]) {
            if (d[nxt] == inf) {
                que.push(nxt);
                d[nxt] = d[pre] + 1;
            }
        }
    }

    return d;
}

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

    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    Graph G(n);
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        addEdge(G, x, y);
    }


    auto d1 = bfs(G, s);
    auto d2 = bfs(G, t);
    int D = d1[t];

    if (D == 1) {
        cout << 0 << endl;
        return 0;
    }

    vi c1(n);
    vi c2(n);

    rep(i, n) {
        if (d1[i] == inf) continue;
        c1[d1[i]]++;
    }
    rep(i, n) {
        if (d2[i] == inf) continue;
        c2[d2[i]]++;
    }

    int ans = 0;
    for (int i = 0, j = D - 2; j >= 0; i++, j--) {
        ans += c1[i] * c2[j];
    }

    rep(i, n) {
        for (auto j : G[i]) {
            if (i < j) continue;
            if (d1[i] + d2[j] == D - 2 || d2[i] + d1[j] == D - 2) {
                ans--;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 13476
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
const int maxn=105;
const int maxv=1e5+5;
const int inf=0x3f3f3f3f;
int w[maxn],v[maxn];
long long dp[maxn][maxv];
int main()
{
	int n,tw;
	while(~scanf("%d%d",&n,&tw))
	{
		int tv;
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&w[i],&v[i]);
			tv+=v[i];
		}
		memset(dp,inf,sizeof(dp));
		dp[0][0]=0;
		for(int i=1;i<=n;i++)//n件物品 
		{
			for(int j=0;j<=tv;j++)//总价值 
			{
				if(j-v[i]>=0)
				  dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
				else
				  dp[i][j]=dp[i-1][j];
				//cout<<dp[j][i]<<" ";
			}
			//cout<<endl;
		}
		for(int i=tv;i>=0;i--)
		{
			if(dp[n][i]<=tw)
			{
				cout<<i<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 85696
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define endl '\n'
#define PB pop_back
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
const int MAXN = 2e5 + 10;
int n , cnt = 1 , sum , a[MAXN];
vector<int> ind;
bool bo[MAXN];
int32_t main()
{
	cin >> n;
	for(int i = 0 ; i < n ; i ++)
		cin >> a[i] , bo[a[i]] = true;
	if(!bo[1])
		return cout << -1 << endl , 0;
	for(int i = 0 ; i < n ; i ++)
		if(a[i] == cnt)
			ind.pb(i) , cnt ++;
	/*for(auto it : ind)
		cout << it << " ";*/
	return cout << n - sz(ind) << endl , 0;
}
	


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B<C+D){
    cout << "Right" << endl;
  }
  else if(A+B>C+D){
    cout << "Left" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

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

int main() {
  	int N;
  	cin >> N;
  	int X[N];
  	for (int i = 0; i < N; i++) cin >> X[i];
  
  	int A[N];
  	for (int i = 0; i < N; i++) A[i] = X[i];
  
  	sort(A, A + N);
  	int median[2];
  	median[0] = A[N / 2 - 1];
  	median[1] = A[N / 2];
  
  	int res[N];
  
  	for (int i = 0; i < N; i++){
      	if (median[0] >= X[i]) res[i] = median[1];
      	else res[i] = median[0];
    }
  
  	for (int i = 0; i < N; i++) cout << res[i] << endl;
}

Measured memory_bytes: 4480
using System;

class ABC_131_C
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        long A = long.Parse(input[0]);
        long B = long.Parse(input[1]);
        long C = long.Parse(input[2]);
        long D = long.Parse(input[3]);

        long c1 = (A-1) / C;
        long c2 = B / C;
        long countC = c2 - c1;

        long d1 = (A-1) / D;
        long d2 = B / D;
        long countD = d2 - d1;

        long CD = LCM(C, D);
        long cd1 = (A-1) / CD;
        long cd2 = B / CD;
        long countCD = cd2 - cd1;

        long ans = B - A + 1 - countC - countD + countCD;

        Console.WriteLine(ans);
    }

    static long GCD(long a, long b)
    {
        if (b == 0) return a;
        return GCD(b, a % b);
    }
    static long LCM(long a, long b)
    {
        return (a * b) / GCD(b, a % b);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int h, w, i, j, res = 1, flag = 0;
    cin >> h >> w;
    string s[h];
    for(i=0; i<h; i++){
        cin >> s[i];
    } 
    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            flag = 0;
            if(s[i][j] == '#'){
                if(i != 0 && s[i-1][j] == '#') flag = 1;
                else if(i != h-1 && s[i+1][j] == '#') flag = 1;
                else if(j != 0 && s[i][j-1] == '#') flag = 1;
                else if(j != w-1 && s[i][j+1] == '#') flag = 1;
                res &= flag;
            }
        }
    }
    cout << (res ? "Yes\n" : "No\n");
    return 0;
}

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

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

  int n,w,s,e;
  n=0;
  w=0;
  s=0;
  e=0;
  
  for(int i = 0; i < S.size(); i++){
    if(S.at(i)=='N'){
      n++;
    }
    else if(S.at(i)=='W'){
      w++;
    }
    else if(S.at(i)=='S'){
      s++;
    }
    else{
      e++;
    }
  }
    
  if(n==0 and s==0){
    if(w==0 and e==0 or w!=0 and e!=0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else if(n!=0 and s!=0){
    if(w==0 and e==0 or w!=0 and e!=0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  } else {
    rep(i, n / 2) {
      if (s[i] != s[i + n / 2]) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  return 0;
}

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

//WA

bool ok=true;
ll n,m,d[710][710],visit[710]={},color[710]={},dp[710]={},smallest=1e9;
vector<int> c1,c2;

int main(void){
	rep(i,710)rep(j,710)d[i][j]=0;
	cin>>n>>m;
	rep(i,m){
		ll a,b;
		cin>>a>>b;
		d[a-1][b-1]=1;
		d[b-1][a-1]=1;
	}
	rep(i,n)rep(j,n){
		if(i==j)continue;//補グラフでも自己辺は認めない
		d[i][j]=1-d[i][j];
	}
	//孤立点があった時にどうするか
	rep(i,n){
		if(visit[i]==0){
			int a[3]={};
			a[1]++;
			visit[i]=1;
			color[i]=1;
			queue<mp> Q;
			Q.push({i,1});
			while(!Q.empty()){
				mp p=Q.front();Q.pop();
				rep(j,n){
					if(d[p.first][j]==1){
						if(visit[j]==0){
							visit[j]=1;
							color[j]=3-p.second;
							a[color[j]]++;
							Q.push({j,color[j]});
						}else{
							if(color[j]!=3-color[p.first]){
								ok=false;
								break;
							}
						}
					}
				}
			}
			//孤立点でも1,0になるので行けるか？
			c1.push_back(a[1]);
			c2.push_back(a[2]);
		}
	}
	// rep(i,c1.size())cout<<"c1:"<<c1[i]<<endl;
	// rep(i,c2.size())cout<<"c2:"<<c2[i]<<endl;
	//可能な数を列挙
	dp[0]=1;
	rep(i,c1.size()){
		int dp2[710]={};
		rep(j,710){
			if(dp[j]==1){
				if(j+c1[i]<710)dp2[j+c1[i]]=1;
				if(j+c2[i]<710)dp2[j+c2[i]]=1;
			}
		}
		rep(j,710)dp[j]=dp2[j];
	}
	rep(i,710){
		if(dp[i]==1){
			smallest=min(smallest,i*(i-1)/2+(n-i)*(n-i-1)/2);//ここを最小にする
		}
	}
	cout<<(ok?smallest:-1)<<endl;
	return 0;
}

Measured memory_bytes: 4224
/*----------------------------------avatar_7---------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define lli long long int 
#define ull unsigned long long
#define mod 1000000007
#define endl "\n"
#define GIO ios_base::sync_with_stdio(0);cin.tie(0);
 
int main()
{   ll n;
    cin>>n;
    ll llc;
    ll A[n];
    for(ll i=0;i<n;i++) cin>>A[i];
 	 llc=A[0];
 	 for(ll i=1;i<n;i++)
 	 {
 	     llc=llc*A[i]/__gcd(llc,A[i]);
 	 }
 	 cout<<llc<<"\n";
   
return 0;
}





Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

vector<ll> sieve(int n){
  vector<ll> ret;
  bool is_prime[n+1];
  memset(is_prime, true, sizeof(is_prime));
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<n+1;i++){
    if(is_prime[i]){
      ret.push_back(i);
      for(int j=2*i;j<n+1;j+=i)is_prime[j]=false;
    }
  }
  return ret;
}

int main(){
  vector<ll> prime = sieve(1005);
  ll N;
  map<ll, ll> mp;
  cin >> N;
  for(int i = 2; i <= N; i++){
    ll X = i, cnt = 0;
    while(X != 1){
      if(X % prime[cnt] == 0){
	mp[prime[cnt]]++;
	X /= prime[cnt];
      }else{
	cnt++;
      }
    }
  }

  ll ans = 1;
  for(auto itr : mp){
    ans = (ans * (itr.second + 1)) % mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <cstring>
#include <map>
#include <queue>
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
char s[15];
int main(){
	scanf("%s", s);
	int flag = 1;
	int len = strlen(s);
	for(int i = 0; i < len-1; i++){
		if(s[i] == 'h'){
			if(s[i+1] == 'i')
				i++;
			else{
				flag = 0;
				break;
			}
		}
		else{
			flag = 0;
			break;
		}
	}
	if(len % 2 == 1) flag = 0;
	if(flag == 1)
		printf("Yes\n");
	else printf("No\n");
} 

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	char a[5], b[5];
	
	int hit, blow;
	
	a[0] = b[0] = '1';
	
	while(scanf("%s %s", a, b), !(a[0] == '0' && b[0] == '0')){
		hit = blow = 0;
		
		
		for (int i = 0; i < 4; i++){
			for (int j = 0; j < 4; j++){
				if (a[i] == b[j]){
					if (i == j){
						hit++;
					}
					else{
						blow++;
					}
					
					break;
				}
			}
		}
		
		printf("%d %d\n", hit, blow);
	}
	
	
}

Measured memory_bytes: 968
// AOJ 3132 Earthquakes
// 2020.1.15 bal4u

#include <stdio.h>
#include <math.h>

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int T[100005]; int N;
double a[100005];
double vlog10[10];

// 見つからなければ、一つ小さい要素を返す
int bsLE(int x) {
	int m, l = 1, r = N;

    while (l < r) {
        m = (l+r) >> 1;
        if (T[m] <= x) l = m + 1; else r = m;
    }
	return l-1;
}

int main()
{
	int A, n, Q;
	
	for (A = 1; A <= 7; ++A) vlog10[A] = log10((double)(10-A)) - 1;

	n = in(), N = 1;
	while (n--) {
		T[N] = in(), A = in();
		if (A) {
			a[N] = a[N-1] + vlog10[A];
			++N;
		}
	}
	Q = in();
	while (Q--) {
		int l = in(), r = in();
		double ans = a[bsLE(r)] - a[bsLE(l)];
		printf("%.10lf\n", pow(10, 9+ans));
	}
	return 0;
}



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


#define M 1000000007
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod 998244353
#define sz(v) (int)(v).size()

#define pii pair<int, int>
#define vi vector<int>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

ll add(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a+b)%M;
	return (p+M)%M;
}

ll mul(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a*b)%M;
	return (p+M)%M;
}


int main()
{
	fastio;
	ll a,b;
	cin>>a>>b;
	cout<<6-a-b<<endl;
    return 0;
}





Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys

def _solve(counts, k, n, used=[]):
    ret = 0
    digits = 0
    while k >= 2 ** digits:
        digits += 1
    tmp = 0
    for idx, c in enumerate(counts):
        if not idx in used:
            if n - 2 * c > 0 and tmp + 2 ** idx <= k:
                ret += (2 ** idx) * (n - c)
                tmp += 2 ** idx
            else:
                ret += (2 ** idx) * c
    #print('k : %d, digits : %d, ret : %d, used : %s' % (k, digits, ret, used))
    #print('counts : %s' % (counts))
    if digits > 0:
        last = counts[digits - 1]
        if n - 2 * last >= 0:
            most_bit = 2 ** (digits - 1)
            k_ = k - most_bit
            #ret = max(ret, _solve(counts[:digits - 1], k_, n) + most_bit * (n - last))
            ret = max(ret, _solve(counts, k_, n, used + [digits - 1]) + most_bit * (n - last))
        #most_bit = 2 ** (digits - 1)
        #k_ = k - most_bit
        #ret = max(ret, _solve(counts, k_, n, used + [digits - 1]) + most_bit * (n - last))
    #print(ret)
    return ret


def solve(N: int, K: int, A: "List[int]"):
    counts = [0] * 45
    for num in A:
        n = num
        idx = 0
        while n > 0:
            if n % 2 == 1:
                counts[idx] += 1
            idx += 1
            n //= 2
    ret = _solve(counts, K, N)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


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

using namespace std;

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

    int m, n;
    cin >> n >> m;

    int item;
    int selected = 0;
    int total_votes = 0;
    vector<int> input;

    for(int i=0; i<n; i++)
    {
        cin >> item;
        input.push_back(item);
        total_votes += item;
    }

    float baseline = (float) total_votes / (4.0f * (float) m);

    for (vector<int>::iterator i=input.begin(); i != input.end(); i++)
    {
        if ((float) *i >= baseline){
            selected++;
        }
    }

    if (selected >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int count = 0;
  while(true){
    int max = a;
    if(max < b) max = b;
    if(max < c) max = c;
    int v[2] = {0};
    if(max == a){
      v[0] = max-b;
      v[1] = max-c;
    }
    else if(max = b){
      v[0] = max-a;
      v[1] = max-c;
    }
    else if(max = c){
      v[0] = max-a;
      v[1] = max-b;
    }
    // cout << v[0] <<" "<< v[1] << endl;
    int ans = v[0]+v[1];
    if((ans+count)%2 == 0){
      // cout << ans << endl;
      cout << (ans+count)/2 << endl;
      return 0;
    }
    // else if((ans + 1)%2 == 0){
    //   cout << (ans+1)/2+count << endl;
    //   return 0;
    // }
    else{
      if(max == a){
        a++;
      }
      else if(max = b){
        b++;
      }
      else if(max = c){
        c++;
      }
    }
    count++;
    // cout << count << endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

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

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	n := readInt()
	m := make(map[int]int)
	a := make([]int, 0)
	for i := 0; i < n; i++ {
		x := readInt()
		m[x]++
		if m[x] == 2 {
			a = append(a, x)
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	w := make([]int, 0)
	i := 0
	for len(w) < 2 && i < len(a) {
		x := a[i]
		if m[x] >= 2 {
			m[x] -= 2
			w = append(w, x)
		} else {
			i++
		}
	}
	if len(w) < 2 {
		println(0)
	} else {
		println(int64(w[0]) * int64(w[1]))
	}
}


Measured memory_bytes: 7552