akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s);i<(e);i++)
#define rep(i,n) REP(i,0,n)

int C[100003];

int main(void) {
    int N, M, L, R;
    cin >> N >> M;
    rep(i, M) {
        cin >> L >> R;
        C[L]++;
        C[R+1]--;
    }
    REP(i, 1, N + 2) {
        C[i] += C[i-1];
    }
    int ans = 0;
    REP(i, 1, N + 2) {
        ans += C[i] == M;
    }
    cout << ans << endl;
}


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

ll w[102], v[102], dp[102][100005];

int main() {
	int n;
	ll W;
	scanf("%d %lld", &n, &W);
	for (int i = 1; i <= n; i++) {
		scanf("%lld %lld", &w[i], &v[i]);
	}
    for (int i = 1; i < 100005; i++)
        dp[0][i] = 1e18;
	for (int i = 1; i <= n; i++) {
		dp[i][100001] = 1e18;
		for (int j = 100000; j >= 0; j--) {
			dp[i][j] = min(dp[i][j + 1], dp[i - 1][j]);
			if (j >= v[i]) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
			}
		}
	}
    for (int i = 100000; i>=0; i--){
        if (dp[n][i] <= W){
            printf("%d", i);
            return 0;
        }
    }
}

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

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    bool check=true;
    if(a==b && b==c) check=false;
    if(a!=b && b!=c && c!=a) check=false;

    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
using namespace std;

int main(void) {
	string s;
	cin >> s;
	for (int i=0; i < s.length(); i++) {
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				cout << "No";
				return 0;
			}
		}
		else {
			if (s[i] == 'R') {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}


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

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b&&a == c)cout << 1 << endl;
	else if (a==b || a == c || b== c)cout << 2 << endl;
	else cout << 3 << endl;
	
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=[int(i)-1 for i in input().split()]
p=0
visited=[0]*n
first=[]
roop=[]
while visited[p]!=2:#二回通っていたらやめる
    if visited[p]==0:#初めて通った
        first.append(p)
    else:#一回通った
        roop.append(p)
    visited[p]+=1#通った跡をつける
    p=a[p]#テレポート
if len(first)>k:#一回もループしていないのなら
    print(first[k]+1)#最初のk番目
else:
    print(roop[(k-(len(first)-len(roop)))%len(roop)]+1)#そうでなければkから一回目のループと二回目のループを引いて二回目のループの回数の余剰

Measured memory_bytes: 32332
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
  int x;
    cin>>x;
    A.at(i)=x-1;
  }set<int>S;
  bool ans=false;
  int sum=0;
  for(int i=0; ;i=A.at(i)){
  sum++;
    if(A.at(i)==1){
    ans=true; break;
  }else{
  if(S.count(A.at(i))){
    break;
  }else{
   S.insert(A.at(i));
  } 
  }
  
  }if(ans)
    cout<<sum<<endl;
  else
    cout<<-1<<endl;
   return 0;
}

Measured memory_bytes: 5376
from collections import defaultdict
N=int(input())
charl=[]
ans=0
for _ in range(N):
    charl.append(''.join(sorted(input())))
anad=defaultdict(int)
for char in charl:
    anad[char]+=1
for anadv in anad.values():
    if anadv>1:
        ans+=anadv*(anadv-1)//2
print(ans)

Measured memory_bytes: 23912
S = input()
moji1 = int(S[:2])
moji2 = int(S[2:])
 
if 1 <= moji1 <= 12:
    if 1 <= moji2 <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= moji2 <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;


int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; i++) cin >> b.at(i);
  vector<vector<int>> a(n, vector<int>(m));
  int sum, cnt = 0;
  for (int i = 0; i < n; i++) {
    sum = c;
    for (int j = 0; j < m; j++) {
      cin >> a.at(i).at(j);
      sum += a.at(i).at(j) * b.at(j);
    }
    if (sum > 0) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000;
int N;
string str;
int sum1[MAX_N+10]; // #
int sum2[MAX_N+10]; // .

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

  cin >> N;
  cin >> str;

  for (int i = 1; i <= N; ++i) {
     sum1[i] = sum1[i-1];
     if (str[i-1] == '#') ++sum1[i];
  }

  for (int i = N; i > 0; --i) {
      sum2[i] = sum2[i+1];
      if (str[i-1] == '.') ++sum2[i];
  }

  ll ans = 1e9;
  for (int i = 1 ; i <= N+1; ++i) {
      ll tmp = sum1[i-1] + sum2[i];
      ans = min(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int a,b,c,k,q=0;
  cin>>a>>b>>c>>k;
  while(b<=a)q++,b<<=1;
  while(c<=b)q++,c<<=1;
  if(q<=k)cout<<"Yes";
  else cout<<"No";
  
  return 0;
}
//2020.07.25 20:03:59


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	vl a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	ll k; cin >> k;
	cout << a[k-1] << endl;
}



Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

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

    vector<int> b(m);
    rep(i, m) cin >> b[i];

    int ans = 0;
    rep(i, n){
        int tmp = c;
        rep(j, m){
            int a;
            cin >> a;
            tmp += a * b[j];
        }
        if(tmp > 0){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	int n;
	double students[1000] = {0},sum,m,div;

	while(true){
		scanf("%d",&n);
		if(n == 0) break;
		div = sum = 0;
		for(int i = 0; i < n; i++){
			scanf("%lf",&students[i]);
			sum += students[i];
		}
		m = sum/n;
		for(int i = 0; i < n;i++){
			div += (students[i] - m)*(students[i] - m);
			students[i] = 0;
		}
		printf("%.8lf\n",sqrt(div/n));
	}
}

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

int main(){
    int n;
    cin>>n;
    ll h[n];
    for(int i=0; i<n; i++){
        cin>>h[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2; i<n; i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 5152
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define max 100000

//qsort(d, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main()
{
    int n, i, j;
    
    scanf("%d", &n);
    
    for (i=1; i<10; i++) {
        for (j=i; j<10; j++) {
            if(n==i*j){
                printf("Yes");
                return 0;
            }
        }
    }
    
    printf("No");
    return 0;
}



Measured memory_bytes: 128
//16, 06, 2018, 09:14:11 Rafaelcs cpp
#include <bits/stdc++.h>

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

typedef unsigned long long ull;

int main(){
    int n;

    cin >> n;

    ll cnt = 0LL;

    for(int i = 0 ; i < n ; i++){
        int x;

        cin >> x;

        while(x % 2LL == 0LL){
            cnt++;
            x /= 2LL;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
from functools import reduce
import math
import collections
def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N, K = (int(_) for _ in input().split())
    A = list(int(_) for _ in input().split())
    d = collections.defaultdict(int)
    for a in A:
        d[a] +=1
    d = sorted(d.items(),key=lambda x:x[1])
    V = []
    for k,v in d:
        V.append(v)
    ans = 0
    for i in range(len(V)-K):
        ans += V[i]
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 39592
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define N 110
int n,a[N],ans=0;
int main()
{
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<n;i++)
	{
		int j=i;
		while (a[j+1]==a[i]) j++;
		ans+=(j-i+1)>>1;
		i=j;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi pair<ll,int> 
#define pii pair<int,ll>
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
int main()
{
    IOS
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<((a+b)*c)/2<<endl;
    return(0);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, arr[10] = {0};

int check (int a) {
    int cont[10] = {0};
    long long int num = 0;
    
    if (a < 2) return 0;
    for (int i=0; i<=a; i++) {
        //cout << arr[i] << endl;
        num *= 10;
        num += arr[i];
        cont[arr[i]] = 1;
    }
    
    if (cont[3] && cont[5] && cont[7] && num <= n) {
        return 1;
    }
    else {
        return 0;
    }
}

int func(int a, int lim) {
    if (n < lim) {
        return 0;
    }

    int ret = 0;
    arr[a] = 3;
    ret += check(a);
    ret += func(a+1, lim*10);
    arr[a] = 5;
    ret += check(a);
    ret += func(a+1, lim*10);
    arr[a] = 7;
    ret += check(a);
    ret += func(a+1, lim*10);

    return ret;
}

int main() {
    cin >> n;

    int ans = func(0, 1), tmp = 0;

    cout << func(0, 1) << endl;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
    int N, M, Q; cin >> N >> M >> Q;
    vector<int> a(Q), b(Q), c(Q), d(Q); rep(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i], a[i]--, b[i]--;
    vector<int> A(N);
    int ans = INT_MIN;
    auto dfs = [&](auto dfs, int k, int mn) -> void {
        if (k == N) {
            int cost = 0;
            rep(i, Q) {
                if (A[b[i]] - A[a[i]] == c[i]) {
                    cost += d[i];
                }
            }
            ans = max(ans, cost);
            return;
        }
        for (int i = mn; i <= M; i++) {
            A[k] = i;
            dfs(dfs, k + 1, i);
        }
    };
    dfs(dfs, 0, 1);
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
int main(){
	int m,f,r,sum=0,i=0,count;
	char res[256];
	while(1){
		std::cin>>m>>f>>r;
		if(m==-1&&f==-1&&r==-1)break;
		if(m==-1||f==-1)res[i]='F';
		else{
			sum=m+f;
			if(80<=sum)res[i]='A';
			if(65<=sum&&sum<80)res[i]='B';
			if(50<=sum&&sum<65)res[i]='C';
			if(30<=sum&&sum<50){
				if(r!=-1&&r>=50)res[i]='C';
				else res[i]='D';
			}
			if(sum<30)res[i]='F';
		}
		i++;
		count=i;
	}
	for(i=0;i<count;i++){
		std::cout<<res[i]<<std::endl;
	}
	return 0;
}

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

int main(){
    ll x,y;
    cin >> x >> y;
    
    ll ans=0;
    while(x<=y){
        x *= 2;
        ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3580
n=int(input())
a=list(map(int,input().split()))
a1=[a[i] for i in range(0,len(a),2)]
a2=[a[i] for i in range(1,len(a),2)]

import collections
c1=collections.Counter(a1)
c2=collections.Counter(a2)

c1=sorted(c1.items(),key=lambda x:x[1],reverse=True)
c2=sorted(c2.items(),key=lambda x:x[1],reverse=True)
ans=0
if c1[0][0]==c2[0][0]:
  if len(c1)==1:
    ans+=(n//2)
  elif c1[1][1]<=c2[1][1]:
    ans+=(n//2)-c1[0][1]
    ans+=(n//2)-c2[1][1]
  else:
    ans+=(n//2)-c1[1][1]
    ans+=(n//2)-c2[0][1]
else:
  ans+=(n//2)-c1[0][1]
  ans+=(n//2)-c2[0][1]

print(ans)

Measured memory_bytes: 19040
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

// ABC170-C
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int N = sc.nextInt();

		List<Integer> pList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			pList.add(sc.nextInt());
		}

		if (N == 0) {
			System.out.println(X);
			sc.close();
			return;
		}

		List<Integer> numList = new ArrayList<>();
		for (int i = -1; i <= 101; i++) {
			numList.add(i);
		}

		for (Integer p : pList) {
			numList.remove(p);
		}

		int abs = Integer.MAX_VALUE;
		int pResult = 0;

		for (Integer num : numList) {
			int tmpAbs = Math.abs(X - num);

			if (tmpAbs < abs) {
				abs = tmpAbs;
				pResult = num;
			}

			if (tmpAbs == abs && num < pResult) {
				pResult = num;
			}
		}

		System.out.println(pResult);
		sc.close();
	}
}


Measured memory_bytes: 36136
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  string s; cin >> s;
  const ll n = s.size();
  ll cnt = 0, ans = 0;
  rep(i, n) {
    if (s[i] == 'W') {
      ans += i - cnt;
      ++cnt;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 720
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  string month;
  month = S.substr(5, 6);
  int month_ = atoi(month.c_str());

  if (month_ >= 5)
    cout << "TBD" << endl;
  else
    cout << "Heisei" << endl;

  return 0;
}


Measured memory_bytes: 256
h = Hash.new(0)

n = gets.to_i
n.times do
  h[gets.chomp] += 1
end

m = gets.to_i
m.times do
  h[gets.chomp] -= 1
end

ans = h.sort_by{|k,v|-v}[0][1]

p ans < 0 ? 0 : ans


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

using i64 = int64_t;

constexpr i64 INF = 1e9;

i64 digit_sum(i64 n){
    i64 res = 0;
    while(n > 0){
        res += n % 10;
        n /= 10;
    }
    return res;
}

int main(){
    string s;
    cin >> s;
    i64 ans = 0;
    reverse(s.begin(), s.end());
    vector<vector<i64>> dp(2, vector<i64>(s.size()+1, INF));
    dp[0][0] = 0;
    for(int j=1;j<=(int)s.size();++j){
        for(int k=0;k<10;++k){
            i64 x = k;
            i64 y = s[j-1] - '0';
            i64 i = x < y;
            if(i)x += 10;
            i64 m = digit_sum(x) + digit_sum(x-y);
            if(dp[0][j-1] < INF)dp[i][j] = min(dp[i][j], dp[0][j-1]+m);
            if(dp[1][j-1] < INF)dp[i][j] = min(dp[i][j], dp[1][j-1]+m-(x-y>0?2:0));
        }
    }
    ans = min(dp[0][(int)s.size()], dp[1][(int)s.size()]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 24836
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input!{
        r: usize,
        g: usize,
        b: usize,
        n: usize,
    }
    let mut count = 0;
    for i in 0..(n / r + 1) {
        for j in 0..(n / g + 1) {
            let s0 = r * i + g * j;
            if s0 > n {
                break;
            }
            if (n - s0) % b == 0 {
                count += 1;
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M;
int A[100010];
string S;
int main(){
	cin>>N>>M;
	cin>>S;
	REP(i,N){
		A[i]=-1;
	}
	int now=N;
	int tmp=N;
	for(int i=N-1;i>=0;i--){
		if(S[i]=='1')continue;
		if(i+M>=now){
			A[i]=now;
			tmp=i;
		}else{
			if(i+M>=tmp){
				now=tmp;
				A[i]=now;
				tmp=i;
			}else{
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	int n=0;
	while(n!=N){
		if(n!=0)cout<<" ";
		cout<<A[n]-n;
		n=A[n];
	}
	cout<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const long long mod=1e9+7;

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

    //入力
    int M, N; cin >> N >> M;
    vector<vector<int>> vec(M);
    rep(i, M){
        int k; cin >> k;
        vec[i].resize(k);
        rep(j, k){
            cin >> vec[i][j];
            vec[i][j]--;//スイッチの番号
        }
    }
    vector<int> p(M);
    rep(i, M) cin >> p[i];

    int ans = 0;
    for (int i = 0; i < (1 << N); i++){//000, 001, 010..., 選び方の集合が全部列挙できる
        bool ok = true;
        rep(j, M){
            int c = 0;
            for (int id : vec[j]){
                if((i >> id) & 1){//iビット目が立っているかどうか
                    c++;
                }
            }
            c %= 2;
            if (c != p[j]){//2で割った余りが等しくなかったらfalse
                ok = false;
            }
        }
        if (ok){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int sectionBegin = 0;
        int sectionEnd = n - 1;
        int lastSex = readSex(0);
        while (true)
        {
            int count = sectionEnd - sectionBegin + 1;
            if(count == 3)
            {
                if ((readSex(sectionBegin + 1) == 0)) return;
                if ((readSex(sectionBegin + 2) == 0)) return;
            }
            else
            {
                //Console.WriteLine($"{sectionBegin} {sectionEnd}");
                int halfPoint = (sectionBegin + sectionEnd) / 2 + ((count / 2) % 2 == 0 ? 0 : 1);
                int sex = readSex(halfPoint);
                if (sex == 0) return;
                //前のグループ
                if (lastSex != sex)
                {
                    sectionEnd = halfPoint;
                    //Console.WriteLine("S");
                }
                //後のグループ
                else
                {
                    sectionBegin = halfPoint;
                    lastSex = sex;
                    //Console.WriteLine("M");
                }
            }
        }
    }
    static int readSex(int i)
    {
        Console.WriteLine(i);
        switch (Console.ReadLine())
        {
            case "Male":
                return 1;
            case "Female":
                return -1;
        }
        return 0;
    }
}

Measured memory_bytes: 13508
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

template<typename T>
void input(T &x) {
	x=0; T a=1;
	register char c=getchar();
	for(;c<48||c>57;c=getchar())
		if(c==45) a=-1;
	for(;c>=48&&c<=57;c=getchar())
		x=x*10+c-48;
	x*=a;
	return;
}

int n,m;

namespace solve70 {
	
	const int N=310;
	const int M=310;
	int a[N][M],cnt[N],sum[N];
	bool go[M];

	bool Judge(int mid) {
		memset(go,0,sizeof(go));
		for(int i=1;i<=n;i++) cnt[i]=1;
		while(1) {
			memset(sum,0,sizeof(sum));
			bool flag=true;
			for(int i=1;i<=n;i++) {
				for(;cnt[i]<=m&&go[a[i][cnt[i]]];cnt[i]++);
				if(cnt[i]>m) return false;
				if(++sum[a[i][cnt[i]]]>mid)
					go[a[i][cnt[i]]]=true,flag=false;
			}
			if(flag) return true;
		}
		return false;
	}

	int main() {
		input(n),input(m);
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;++j)
				input(a[i][j]);
		int l=1,r=n,ans;
		while(l<=r) {
			int mid=l+r>>1;
			if(Judge(mid)) ans=mid,r=mid-1;
			else l=mid+1;
		}
		printf("%d\n",ans);
		return 0;
	}

}

int main() { return solve70::main(); }


Measured memory_bytes: 512
#include<stdio.h>

static const int N = 1000;

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

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  for(i=2;i<=n;i++){
   
    key=A[i];
    j=i-1;
    while(j>=0 && A[j]>key){
      A[j+1]=A[j];
      j--;
      A[j+1]=key;
    }
     trace(A,n);
  }

  
  return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
#pragma optimize ("O3")
using namespace std;
#define int long long
typedef pair<int, int> ii;

int dem[20];
int h, w, n, i, x, y, j, a, b;
map<ii, bool> painted;

main(){
	cin >> h >> w >> n;
	dem[0] = (h-2)*(w-2);
	while(n--){
		cin >> a >> b;
		a--;
		b--;
		painted[ii(a, b)] = true;
		for(x=max((int)0, a-2);x<=min(h-3, a);x++){
			for(y=max((int)0, b-2);y<=min(w-3, b);y++){
				int cnt = 0;
				for(i=x;i<=x+2;i++){
					for(j=y;j<=y+2;j++)
						if (painted[ii(i, j)])
							cnt++;
				}
				dem[cnt]++;
				dem[cnt-1]--;
			}
		}
	}
	for(i=0;i<=9;i++)
		cout << dem[i] << "\n";
}

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

using namespace std;
typedef pair<int, int> pii;

int w, h;
int a[110][110];
int out[110][110];
int di[2][6] = {{-1, -1, 0, 0, 1, 1}, {-1, -1, 0, 0, 1, 1}};
int dj[2][6] = {{0, 1, -1, 1, 0, 1}, {-1, 0, -1, 1, -1, 0}};

int main(void) {
  cin >> w >> h;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }

  fill(out[0], out[110], -1);

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j]) continue;
      if (i != 0 && i != h - 1 && j != 0 && j != w - 1) continue;
      queue<pii> que;
      que.push(pii(i, j));
      out[i][j] = 1;
      while (!que.empty()) {
        pii p = que.front();
        que.pop();
        for (int k = 0; k < 6; k++) {
          int ni = p.first + di[p.first & 1][k], nj = p.second + dj[p.first & 1][k];
          if (ni >= 0 && ni < h && nj >= 0 && nj < w && !a[ni][nj] && out[ni][nj] != 1) {
            out[ni][nj] = 1;
            que.push(pii(ni, nj));
          }
        }
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (!a[i][j]) continue;
      if (i == 0) {
        ans += 2;
        ans += (j == 0);
        ans += (j == w - 1) * 2;
      } else if (i == h - 1) {
        ans += 2;
        ans += (j == 0) * 2;
        ans += (j == w - 1);
      } else if (i & 1) {
        ans += (j == 0) * 3;
        ans += (j == w - 1);
      } else {
        ans += (j == 0);
        ans += (j == w - 1) * 3;
      }

      for (int k = 0; k < 6; k++) {
        int ni = i + di[i & 1][k], nj = j + dj[i & 1][k];
        if (ni >= 0 && ni < h && nj >= 0 && nj < w && !a[ni][nj] && out[ni][nj] == 1) {
          ans += 1;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3216
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
sum=0
for i in range(N):
    if A[i]+A[i+1]<=B[i]:
     sum+=A[i]+A[i+1]
     A[i+1]-=B[i]-A[i]
     if A[i+1]<0:
         A[i+1]=0
    else:
        sum+=B[i]
        if A[i]<=B[i]:
            A[i+1]-=B[i]-A[i]
print(sum)

Measured memory_bytes: 18476
#include<stdio.h>
int main(void)
{
   int a,b,c,i;
   scanf("%d%d",&a,&b);
   for(i=0;i<2;i++){
      if(a>=b){
         c=c+a;
         a=a-1;
         }
      else{
         c=c+b;
         b=b-1;
         }
   }
   printf("%d\n",c);
   return 0;
   }


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

using namespace std;

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

    vector<int> dp(13);
    vector<int> dp_tmp(13);

    reverse(S.begin(), S.end());

    if (S[0] == '?')
    {
        for (int i = 0; i < 10; i++)
        {
            dp[i] = 1;
        }
    }
    else
    {
        dp[S[0] - '0'] = 1;
    }
    // for (auto x : dp)
    // {
    //     cout << x << ' ';
    // }
    // cout << endl;

    int base = 10;

    for (int j = 1; j < S.size(); j++)
    {
        dp_tmp = dp;
        if (S[j] == '?')
        {
            for (auto &x : dp)
            {
                x = 0;
            }

            for (int i = 0; i < 13; i++)
            {
                for (int k = 0; k < 10; k++)
                {
                    int idx = (k * base + i) % 13;
                    dp[idx] = (dp[idx] + dp_tmp[i]) % (1000000000 + 7);
                }
            }
        }
        else
        {
            for (int i = 0; i < 13; i++)
            {
                int idx = ((S[j] - '0') * base + i) % 13;
                dp[idx] = dp_tmp[i];
            }
        }

        base = (base * 10) % 13;
        // for (auto x : dp)
        // {
        //     cout << x << ' ';
        // }
        // cout << endl;
    }
    cout << dp[5] << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
    int i, j, k;
    int n;
    int building, floor, room, people;
    int cnt[4][3][10];
    /*people[building][floor][room]*/

    /*initialize*/
    for (i = 0; i < 4; i++){
        for (j = 0; j < 3; j++){
            for (k = 0; k < 10; k++){
                cnt[i][j][k] = 0;
            }
        }
    }

    /*count*/
    scanf("%d", &n);
    for (i = 1; i <= n; i++){
        scanf("%d %d %d %d", &building, &floor, &room, &people);
        cnt[building - 1][floor - 1][room - 1] += people;
        /*building No.1, floor No.1, room No.1 is cnt[0][0][0]*/
    }

    for (i = 0; i < 4; i++){
        if (i){
            printf("####################\n");
        }
        for (j = 0; j < 3; j++){
            for (k = 0; k < 10; k++){
                printf(" %d", cnt[i][j][k]);
            }
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 612
import Control.Applicative
import Control.Monad
import System.IO.Unsafe
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

f :: Int -> [[Int]]
f n = f' n n
f' :: Int -> Int -> [[Int]]
f' _ 0 = [[]]
f' 1 r = [replicate r 1]
f' n r
  | n>r = f' r r
  | otherwise = [n : s | s <- f' n (r-n)] ++ f' (n-1) r

main = do
    n <- getInt
    when (n/=0) $ do
        mapM_ putStrLn $ map sjoin $ f n 
        main

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

const int MAXN = 1005;
const int INF = 1<<28;
int N;
bool used[MAXN];
string name[MAXN];
bool sell[MAXN];
string mono[MAXN];
int price[MAXN];

map<string, int> low, high, sum, num;
map<string, int> B, S;

int main() {
  while(cin >> N && N) {
    low.clear();
    high.clear();
    sum.clear();
    num.clear();
    B.clear();
    S.clear();
    for(int i = 0; i < N; ++i) {
      string sb;
      cin >> name[i] >> sb >> mono[i] >> price[i];
      sell[i] = (sb == "SELL");
      low[mono[i]] = INF;
      high[mono[i]] = -INF;
      sum[mono[i]] = 0;
      num[mono[i]] = 0;
      B[name[i]] = 0;
      S[name[i]] = 0;
    }
    fill(used, used+MAXN, false);
    for(int i = 0; i < N; ++i) {
      if(used[i]) continue;
      int p = sell[i] ? -1 : 1;
      int bestP = INF;
      int bestJ = -1;
      for(int j = 0; j < i; ++j) {
	if(used[j]) continue;
	if(name[i] == name[j]) continue;
	if(!(sell[i] ^ sell[j])) continue;
	if(mono[i] != mono[j]) continue;
	int newP = price[j] * p;
	if(newP < bestP) {
	  bestP = newP;
	  bestJ = j;
	}
      }
      if(bestJ == -1) continue;
      bestP *= p;
      int buyP, sellP;
      if(sell[i]) {
	buyP = bestP;
	sellP = price[i];
      } else {
	buyP = price[i];
	sellP = bestP;
      }
      if(sellP > buyP) continue;
      int v = (buyP+sellP)/2;
      used[i] = used[bestJ] = true;
      low[mono[i]] = min(low[mono[i]], v);
      high[mono[i]] = max(high[mono[i]], v);
      sum[mono[i]] += v;
      ++num[mono[i]];
      if(sell[i]) {
	B[name[bestJ]] += v;
	S[name[i]] += v;
      } else {
	B[name[i]] += v;
	S[name[bestJ]] += v;
      }
    }

    for(map<string,int>::iterator it = low.begin();
	it != low.end(); ++it) {
      if(num[it->first] == 0) continue;
      cout << it->first;
      cout << " " << low[it->first];
      cout << " " << sum[it->first]/num[it->first];
      cout << " " << high[it->first] << endl;
    }
    cout << "--" << endl;
    for(map<string,int>::iterator it = B.begin();
	it != B.end(); ++it) {
      cout << it->first;
      cout << " " << B[it->first];
      cout << " " << S[it->first] << endl;
    }
    cout << "----------" << endl;
  }
  return 0;
}

Measured memory_bytes: 1360
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
Comlist = []
Ans = dict()
Answer = 0
for i in range(1,10):
    for j in range(1,10):
        M = i*10 + j
        Comlist.append(str(M))
        Ans[str(M)] = 0
for k in range(1,N+1):
    strk = str(k)
    if k < 10:
        Tar = strk + strk
        Ans[Tar] += 1
    else:
        Tar = strk[0] + strk[-1]
        if Tar in Ans:
            Ans[Tar] += 1
Answer = 0
for q in range(len(Comlist)):
    p = Comlist[q]
    pin = p[1] + p[0]
    Answer += Ans[p] * Ans[pin]
print(Answer)

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define int long long
const int maxn=(int) 1e6+6;
using namespace std;
signed main(){
    priority_queue<int> pq;
    int n,m,sum=0;
    cin >> n >> m;
    vector<int> vec[maxn];
    for(int i = 0;i < n; i++){
        int days,score;
        cin >> days >> score;
        vec[days].push_back(score);
    }
    for(int i = 1; i <= m ;i++){
        for(int j = 0; j < (int)vec[i].size(); j++){
            pq.push(vec[i][j]);
        }
          if(!pq.empty()){
             sum+=pq.top();
             pq.pop();
          }
    }
    cout << sum;
}

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

using namespace std;

int main(int argc, const char * argv[]) {
    int N = 0;
    cin >> N;
    
    vector<int> hotels(N,0);
    for(int i = 0; i < N; i++) {
        cin >> hotels[i];
    }
    
    int oceanView = 0;
    int leftMax = 0;
    for(auto v : hotels) {
        if(leftMax <= v) {
            oceanView++;
        }
        leftMax = max(leftMax, v);
    }
    cout << oceanView << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K, X;
  cin >> K >> X;
  if(K*500 >= X) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

using namespace std;

int main()
{
  int a,b;
  cin >> a >> b;
  if(a <= 5) {
    cout << 0 << endl;
  } else if(a <= 12) {
    cout << b/2 << endl;
  } else {
    cout << b << endl;
  }
}

Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
    string str;
    cin>>str;
    ll i,j,cc=0;
    for(i=0;i<str.size();i++){
        if(i%2==0){
            if(str[i]=='L'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else{
            if(str[i]=='R'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}

int main() {
int N,M;
cin>>N>>M;
cout<<(N==M ? "Yes" : "No")<<endl;
return 0;
}


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

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

	int train = a * n;
	int taxi = b;

	int out;

	if (train < taxi) {
		out = train;
	}
	else {
		out = taxi;
	}

	cout << out << endl;

	return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<f64>();
    let pi = std::f64::consts::PI;
    let (a, b, h, m) = (line[0], line[1], line[2], line[3]);
    let mut y = (m/60.0)*2.0*pi;
    let mut x =  (h/12.0)*2.0*pi + (m/60.0/12.0)*2.0*pi;
    let cos = (x-y).abs().cos();

    let ans = a*a + b*b - 2.0*a*b*cos;
    println!("{}", ans.sqrt());
}


Measured memory_bytes: 3016
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	UnionFind uf(n);
	rep(i, m)
	{
		int a, b; cin >> a >> b;
		--a, --b;
		uf.merge(a, b);
	}
	int res = 0;
	rep(i, n)chmax(res, uf.size(i));
	cout << res << endl;
}

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

long long N, C;
vector<pair<long long, long long> >xv;

long long goright[100005];
long long goleft[100005];
long long backright[100005];
long long backleft[100005];

int main(){
	cin >> N >> C;
	for(long long i = 0; i < N; i++){
		long long x, v;
		cin >> x >> v;
		xv.push_back(make_pair(x, v));
	}
	sort(xv.begin(), xv.end());

	long long curmaxi = 0;
	long long curbackmaxi = 0;
	long long curadd = 0;
	long long cursub = 0;
	for(long long i = 0; i < N; i++){
		curadd += xv[i].second;
		cursub = xv[i].first;
		curmaxi = max(curmaxi, curadd - cursub);
		curbackmaxi = max(curbackmaxi, curadd - 2*cursub);
		goright[i] = curmaxi;
		backright[i] = curbackmaxi;
	}

	curmaxi = 0;
	curbackmaxi = 0;
	curadd = 0;
	cursub = 0;
	for(long long i = N-1; i >=0 ; i--){
		curadd += xv[i].second;
		cursub = C - xv[i].first;
		curmaxi = max(curmaxi, curadd - cursub);
		curbackmaxi = max(curbackmaxi, curadd - 2*cursub);
		goleft[i] = curmaxi;
		backleft[i] = curbackmaxi;
	}


	//for(long long i = 0; i < N; i++){
	//	cout << "goright[" << i << "]=" << goright[i] << endl;
	//	cout << "backright[" << i << "]=" << backright[i] << endl;
	//}

	//for(long long i = 0; i < N; i++){
	//	cout << "goleft[" << i << "]=" << goleft[i] << endl;
	//	cout << "backleft[" << i << "]=" << backleft[i] << endl;
	//}


	long long ans = max(goright[N-1], goleft[0]);

	//go right and left
	for(long long i = 0; i < N-1; i++){
		ans = max(ans, goright[i] + backleft[i+1]);
	}

	//go left and right
	for(long long i = 1; i < N; i++){
		ans = max(ans, goleft[i] + backright[i-1]);
	}

	cout << ans << endl;
}

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


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

class AABCSwap {
public:
	void solve(std::istream& in, std::ostream& out) {
        int x,y,z;
        in >> x >> y >> z;
        out << z << " " << x << " " << y << endl;
	}
};


int main() {
	AABCSwap solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

ll gcd(ull a, ull b){
    return (a==0)?b:gcd(b%a,a);
}

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

ll n;

ll R(ll l, ll r){
    return l * (n - r + 1);
}

int main(){
    ll ans = 0;
    cin >> n;
    for(ll i=1;i<=n;++i){
        ans += R(i, i);
    }
    for(int i=1;i<n;++i){
        ll u, v;
        cin >> u >> v;
        if(u > v){
            swap(u, v);
        }
        ans -= R(u, v);
    }
    cout << ans << endl;
}


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

int main()
{
    int x, n;
    cin >> x >> n;
    bool flag[102];
    int p;
for(int i=0; i<102; i++){
        flag[i] = false;
    } 

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

    int d = 0;
    while(1){
        if(flag[x-d]==false) {cout <<  x-d << endl; break;}
        if(flag[x+d]==false) {cout <<  x+d << endl; break;}
        d++;
    }
}


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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    vector<long long> a(3);

    for(long long i = 0 ; i < 3 ; i++) {

        cin >> a[i];

    }

    set<long long> b(a.begin(),a.end());

    if(b.size()==2) {

        cout << "Yes" <<'\n';

    } else {

        cout << "No" <<'\n';

    }

    return 0;

}



Measured memory_bytes: 3644
// 2011/08/09 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int L;
		cin >> L;
		if(L==0)
			break;

		int M[12], N[12];
		for(int i=0; i<12; i++)
			cin >> M[i] >> N[i];

		int sav = 0;
		bool flg = false;
		for(int i=0; i<12; i++){
			sav += (M[i]-N[i]);
			if(sav>=L){
				cout << i+1 << endl;
				flg = true;
				break;
			}
		}

		if(!flg)
			cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 0