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

using namespace std;

#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define SZ 100010
#define PB push_back
#define MEM(n, val) memset((n), val, sizeof(n))
#define INF 1000000000
#define F first
#define S second
#define MP make_pair
#define LL long long

int n, m;

bool is_active[12];
int ara[] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

string dp[10010];
bool vis[10010];

string func(int val)  {
    if(val == 0)    {
        return "";
    }
    if(vis[val])    {
//        return "0";
        return dp[val];
    }
    string ans = "0";
    for(int i = 9; i >= 1; i--)   {
        if(is_active[i] == 0)    {
            continue;
        }
        if(val - ara[i] < 0)    {
            continue;
        }
//        func(val - ara[i]);
        string suff = func(val - ara[i]);
        if(suff == "0")    {
            continue;
        }

        char ch = (i + '0');
        string who = ch + suff;
//        cout << who << "\n";

        if(who.size() > ans.size())    {
            ans = who;
        }
        else if(who.size() == ans.size())    {
            ans = max(ans, who);
        }
    }
    vis[val] = 1;

//    return ans;
    return dp[val] = ans;
}

int main()  {
//    freopen("in.txt", "r", stdin);
    cin >> n >> m;
    FOR(i, 0, m - 1)   {
        int tmp;cin >> tmp;
        is_active[tmp] = 1;
    }
    MEM(vis, 0);
    cout << func(n);

    return 0;
}
/**
*/


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

int main()
{
	int n;	cin>>n;
	int a[n+1],i,j;
	bool done[n+1];
	for(i=1;i<=n;i++){
		cin>>a[i];	done[i]=0;
	}
	int ans=0;
	for(i=1;i<n;i++){
		if(done[i]){
			i++;	continue;
		}
		if(a[i+1]==a[i]){
			if(i+2<=n && a[i+2]==a[i]){
				ans++;	i++;
			}
			else{
				ans++;	i++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
(defvar ht (make-hash-table :test 'equal))

(defun solve (x A B C D)
  (cond 
    ((= x 0) 0)
    ((= x 1) D)
    (#1=(gethash x ht) #1#)
    (t (setf #1# (min (* x D)
                      (+ C (* D (mod (- x) 5))
                         (solve (ceiling x 5) A B C D))
                      (+ C (* D (mod x 5))
                         (solve (floor x 5) A B C D))
                      (+ B (* D (mod (- x) 3))
                         (solve (ceiling x 3) A B C D))
                      (+ B (* D (mod x 3))
                         (solve (floor x 3) A B C D))
                      (+ A (* D (mod (- x) 2))
                         (solve (ceiling x 2) A B C D))
                      (+ A (* D (mod x 2))
                         (solve (floor x 2) A B C D)))))))

(loop repeat (read) do
      (clrhash ht)
      (princ (solve (read) (read) (read) (read) (read)))
      (terpri))



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

inline int gi()
{
	char c = getchar();
	while(c < '0' || c > '9') c = getchar();
	int sum = 0;
	while('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

typedef long long ll;
const int maxn = 100005;

int n, s, x[maxn];
ll ans, p[maxn];


int main()
{
	n = gi(); s = gi();
	for (int i = 1; i <= n; ++i) x[i] = gi(), p[i] = gi();

	int l = 1, r = n, d = p[1] >= p[n];
	while (1) {
		if (x[l] >= s) {ans += x[r] - s; break;}
		if (x[r] <= s) {ans += s - x[l]; break;}
		if (p[l] >= p[r]) {
			if (d != 0) {ans += x[r] - x[l]; d ^= 1;}
			p[l] += p[r--];
		} else {
			if (d != 1) {ans += x[r] - x[l]; d ^= 1;}
			p[r] += p[l++];
		}
	}

	printf("%lld\n", ans);
	
	return 0;
}



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

int main(){
	int nb,a;
	cin >> nb;
	vector<int> v;
	for (int i=0; i<nb; ++i){
		cin >> a;
		v.emplace_back(a);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	int t=0;
	for (int i=0; i<nb; ++i){
		if (i % 2 == 0){
			t += v[i];
		}
		else{
			t -= v[i];
		}
	}
	cout << t;
	return 0;
}

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

N = int(input())
A = list(map(int, input().split()))
dp = [0]*(N+1)
dp[0] = 1000

for i in range(N):
    for j in range(i+1):
        dp[i+1] = max(dp[i+1], dp[j]%A[j]+dp[j]//A[j]*A[i])

print(max(dp))

Measured memory_bytes: 65160
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long ans, n, i, j, k, a, b;

	cin >> k >> a >> b;
	n = 0;
	if ((a >= b) || (k < a)) ans = k + 1;
	else {
		ans = k + 1;
		n = a + (k - a + 1) / 2 * (b - a) + ((k - a + 1) % 2);
		ans = max(ans, n);
	}
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 384
N, X = map(int, input().split())
x = list(map(int, input().split()))
x = [abs(a - X) for a in x]


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)


a = x[0]
for i in range(1, N):
    a = gcd(a, x[i])


print(a)

Measured memory_bytes: 14252
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int mypow(int _x, int _n){
	int ret = 1;
	while(0 < _n){
		if((_n % 2) == 0){
			_x *= _x;
            _x %= MOD;
			_n >>= 1;
		}
		else{
			ret *= _x;
            ret %= MOD;
			--_n;
		}
	}
	return ret;
}

int ans1[200000];

signed main(){
    int n,k;
    cin >> n >> k;
    int ans = 0;
    for(int i = k;i>0;i--){
        int now = i;
        int nn = k/now;
        int n3 = mypow(nn,n);
        while(now <= k){
            n3 += MOD;
            n3 -= ans1[now];
            n3 %= MOD;
            now += i;
        }
        ans1[i] = n3;
        ans += n3 * i;
        ans %= MOD; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4404
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    long long w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(20) << (double)w * h / 2 << " ";
    if(x * 2 == w && y * 2 == h){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
 
using namespace std;
 
int main(void){
    while (true){
        int ans = 0;
        string number;
        getline(cin, number);
        if (number == "0") break;
        for (int i = 0; i < number.size(); i++) {
            ans = ans + (number[i] - '0');
        }
        cout << ans << endl;
    }
}

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

typedef long long ll;
using namespace std;

struct UnionFind {
    vector<int> parent;

    UnionFind(int N) : parent(N) {
        parent = vector<int>(N, -1);
    }

    int root(int n) {
        return (parent[n] < 0) ? n : parent[n] = root(parent[n]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        if (parent[root(rx)] > parent[root(ry)])
            swap(rx, ry);
        parent[rx] += parent[ry];
        parent[ry] = rx;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind road(n + 1), train(n + 1);
    for (int i = 0; i < k; i++) {
        int p, q;
        cin >> p >> q;
        road.unite(p, q);
    }
    for (int i = 0; i < l; i++) {
        int r, s;
        cin >> r >> s;
        train.unite(r, s);
    }
    map<pair<int, int>, int> m;
    for (int i = 1; i <= n; i++) {
        pair<int, int> k(road.root(i), train.root(i));
        m[k]++;
    }
    for (int i = 1; i <= n; i++) {
        pair<int, int> k(road.root(i), train.root(i));
        cout << m[k] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 13584
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
char a[104][104];
vector<int> del_hang;
vector<int> del_lie;
int main()
{
    int H,W;
    int i,j,k;
    int h,w;
    int flag;
    while(cin>>H>>W)
   {   
       memset(a,0,sizeof(a));
       del_hang.clear();
       del_lie.clear();
       for(i=0;i<H;i++)
          for(j=0;j<W;j++)
            cin>>a[i][j];
       for(j=0;j<H;j++)
       {
	 for(i=0;i<W;i++)
         {
          if(a[j][i]!='.') break;
         }
          if(i>=W) del_hang.push_back(j+1);
       }

       for(i=0;i<W;i++)
       {
	       for(j=0;j<H;j++)
         {
          if(a[j][i]!='.') break;
         }
          if(j>=H) del_lie.push_back(i+1);
       }
       
       for(i=0;i<W;i++) //列
       {
       	 vector<int>::iterator result = find( del_lie.begin( ), del_lie.end( ), i+1 ); 
         if(result==del_lie.end()) continue;
				  for(j=0;j<H;j++)//行
         {
           a[j][i]='@';
          }
       }

       for(i=0;i<H;i++) 
       {
          flag=0;
          for(j=0;j<W;j++)
         {
           if(del_hang.size())
           {
            if(i==del_hang[0]-1){del_hang.erase(del_hang.begin());break;}
            }
           if(a[i][j]!='@') 
            {cout<<a[i][j];flag=1;}
          }
          if(flag) cout<<endl;
       }
    }   

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string a;
    cin>>a;
    int k=0;
    if(a.length()==0){
        k=1;
    }
    if(a.length()%2==0){
        for(int i=0;i<a.length();i+=2){
            if(a[i]=='h'&&a[i+1]=='i'){
                
            }
            else{
                k=1;
            }
        }
    }
    else{
        k=1;
    }
    if(k==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from itertools import chain
# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter
# import numpy as np


def solve(c):
    if c.lower() == c:
        return 'a'
    else:
        return 'A'

def main():
    c = input()
    answer = solve(c)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9048
d, g = [int(i) for i in input().split()]
p = [0] + [[int(i) for i in input().split()] for _ in range(d)]

def recursive(d, g):
    if d == 0:
        return 10 ** 9
    n = min(g // (100 * d), p[d][0])
    t = 100 * d * n
    # Full
    if n == p[d][0]:
        t += p[d][1]
    # Partial
    if t < g:
        n += recursive(d-1, g-t)
    return min(n, recursive(d-1, g))

def bit(d, g):
    ans = 10 ** 9
    for i in range(2 ** d):
        b = '-' + format(i, '0{}b'.format(d))
        last_zero_index = 0
        tmp_ans = 0
        total_score = 0
        for j in range(1, d+1):
            if b[j] == '1':
                total_score += p[j][0] * (100 * (j))
                total_score += p[j][1]
                tmp_ans += p[j][0]
            else:
                last_zero_index = j
        if total_score < g:
            diff = g - total_score
            q = diff // (100 * last_zero_index)
            r = diff % (100 * last_zero_index)
            if r != 0:
                q += 1
            if q > p[last_zero_index][0]:
                continue
            else:
                tmp_ans += q
        ans = min(ans, tmp_ans)
    return ans

solve = recursive
#solve = bit
print(solve(d, g))


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){

    int a, b;
    cin >> a >> b;
    vector<int> t(1000);

    t[0] = 0;
    for(int i = 1;i < 1000;i++){
        t[i] = t[i-1] + i;
    }
    cout << (t[b-a-1])-a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val){ //usage: int dp[10][10]; Fill(dp,INF);
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;

struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------
int n,m;
int ballCount[100001];
bool redExist[100001];
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin>>n>>m;
    for (int i = 0; i < n; ++i) {
        ballCount[i]=1;
        redExist[i]=false;
    }
    redExist[0]=true;
    for (int i = 0; i < m; ++i) {
        int x,y;
        cin>>x>>y;
        x--;y--;
        if(redExist[x]) {
            if (ballCount[x] > 1 ) {
                redExist[y] = true;
            } else if (ballCount[x] == 1) {
                redExist[x] = false;
                redExist[y] = true;
            }
        }
        ballCount[x]--;
        ballCount[y]++;
    }
    int ans=0;
    for (int i = 0; i < n; ++i) {
        if(redExist[i])
            ans++;
    }
    cout<<ans<<endl;
}

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


int main(){
	unsigned int a, b, c;
	cin >> a >> b >> c;
	unsigned int hoge = 0;
	for (unsigned int i = a; i <= b; i++) {
		if (c%i == 0) {
			hoge++;
		}
	}
	cout << hoge << endl;

}


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

using namespace std;

// solve func


int main(){
    // code here
    int k;
    string s;
    cin >> k >> s;
    if(s.length() > k){
        for(int i = 0;i < k;i++){
            cout<< s[i];
        }
       cout<<"...";
    }
    else {
        cout<<s;
    }
    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

bool f(int n) {
  set<int> s;
  while (n) {
    s.insert(n % 10);
    n /= 10;
  }
  return s.size() == 1;
}

int main() {
  int n;
  cin >> n;
  int diff = 100000000;
  REP(i, n, 1000) if (f(i) && diff > (i - n)) diff = i - n;
  cout << n + diff << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

H, W = map(int, raw_input().split())

a = [raw_input() for _ in range(H)]
f1 = [False] * H
f2 = [False] * W

for i in range(H):
    hoge = True
    for j in range(W):
        if a[i][j] == '#':
            hoge = False
    f1[i] = hoge

for i in range(W):
    hoge = True
    for j in range(H):
        if a[j][i] == '#':
            hoge = False
    f2[i] = hoge

for i in range(H):
    if f1[i]:
        continue
    S = ""
    for j in range(W):
        if not f2[j]:
            S += a[i][j]
    print S


Measured memory_bytes: 3320
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;
const int N = 1<<17;

int bit[MAX_N+1];
vector<P> len[MAX_N];

//i番目までの和を計算する
int sum(int i)
{
	int s = 0;
	while(i>0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
//i番目の値にxを加える
void add(int i,int x)
{
	while(i <= MAX_N){
		bit[i] += x;
		i += i & -i;
	}
}

int main()
{
	int n,m,l,r,ans;
	cin >> n >> m;
	rep(i,n){
		scanf("%d%d",&l,&r);
		len[r-l].push_back(P(l-1,r-1));
	}
	cout << n << "\n";
	int res = n;
	for(int i=1;i<m;i++){
		ans=0;
		rep(j,len[i-1].size()){
			add(len[i-1][j].first+1,1);
			add(len[i-1][j].second+2,-1);
			res--;
		}
		ans += res;
		for(int in=i+1;in<=m;in+=(i+1)){
			ans += sum(in);
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 7936
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int a[10];
int n;
 
bool dfs(int i,int left,int right){
    if(i==10) return true;
    if(a[i]>left){
        return dfs(i+1,a[i],right);
    }
    if(a[i]>right){
        return dfs(i+1,left,a[i]);
    }
    return false;
}
 
void solve(){
    rep(i,10) cin >> a[i];
    if(dfs(0,0,0)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return;
}
 
int main(){
    cin >> n;
    rep(i,n){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1152
a, b, k = list(map(int, input().split()))
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        tmp_a = a//2
        a -= tmp_a
        b += tmp_a
    if i % 2 == 1:
        if b % 2 == 1:
            b -= 1
        tmp_b = b//2
        b -= tmp_b
        a += tmp_b

print(a, b)


Measured memory_bytes: 9076
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	// A 0, B 1, C 2
	int n; cin >> n;
	vvi A = vvi(3);
	rep(i, n){
		int a, b, c; cin >> a >> b >> c;
		A[0].pb(a);
		A[1].pb(b);
		A[2].pb(c);
	}

	vvll dp = vvll(3, vll(n, -1));
	dp[0][0] = A[0][0];
	dp[1][0] = A[1][0];
	dp[2][0] = A[2][0];

	for(int i = 1; i < n; i++){
		dp[0][i] = A[0][i] + max(dp[1][i-1], dp[2][i-1]);
		dp[1][i] = A[1][i] + max(dp[0][i-1], dp[2][i-1]);
		dp[2][i] = A[2][i] + max(dp[0][i-1], dp[1][i-1]);
	}
	cout << max({dp[0][n-1], dp[1][n-1], dp[2][n-1]});
}

Measured memory_bytes: 7652
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

template <typename T>
std::vector<T> divisor(T n) {
	std::vector<T> divisors;
	for(T i = 1; i * i <= n; i++) {
		if(n % i != 0) {
			continue;
		}
		divisors.push_back(i);
		if(i * i != n) {
			divisors.push_back(n / i);
		}
	}
	return divisors;
}

// 終了判定
template <typename T,
		  typename enable_if<is_integral<T>::value>::type* = nullptr>
bool finds(T left, T right) {
	return right - left > 1;
}

// 二分探索
template <typename T, typename F>
T bin_search(T left, T right, F pred) {
	while(finds<T>(left, right)) {
		T middle = (left + right) / 2;
		if(pred(middle)) {
			left = middle;
		} else {
			right = middle;
		}
	}
	return left;
}

int main() {
	int n, m;
	cin >> n >> m;
	VI divisors = divisor(m);
	sort(ALL(divisors));
	int result = bin_search<int>(0, divisors.size(), [n, m, &divisors](int a) {
		return (m / divisors[a]) >= n;
	});
	cout << divisors[result] << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
const int e[40]={0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,
                 5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8};
int main(void)
{
  int p,j,x;
  long long a=0,N;
  x=scanf("%lld",&N);
  for(p=2;p<=1e6;p++)
  {
    for(x=0;N%p==0;x++)N/=p;
    a+=e[x];
  }
  if(N>1)a++;
  return printf("%lld\n",a),0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    cout << (n+1)*n/2 << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



long long n, s;

long long sum(long long n, long long b) {
    long long res = 0;
    while (n > 0) {
        res += (n % b);
        n /= b;
    }
    return res;
}


vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n%i == 0LL) {
            res.push_back(i);
            long long temp = n/i;
            if (i != temp) res.push_back(temp);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


long long solve() {
    if (n == s) return n+1;
    if (n < s) return -1;
    
    long long b = 0;
    for (b = 2; b <= 400000; ++b) {
        long long ts = sum(n, b);
        if (ts == s) return b;
    }
    
    vector<long long> div = divisor(n-s);
    sort(div.begin(), div.end());
    for (int i = 0; i < div.size(); ++i) {
        b = div[i] + 1;
        long long ts = sum(n, b);
        if (ts == s) return b;
    }
    
    return -1;
}

int main() {
    //cout << sum(1434, 10) << endl;
    //cout << sum(1690, 10) << endl;
    while (cin >> n >> s) {
        cout << solve() << endl;
    }
}















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const ll siz = 1e6 + 7;
const ll mod = 1e9 + 7;
ll fac[siz];
ll inv[siz];
ll binpow(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}

ll ncr(ll n, ll r) {
	if (r == 0 || n == r)return 1;
	return (((fac[n] * inv[n - r]) % mod) * inv[r]) % mod;
}

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	fac[0] = 1;
	for (int i = 1; i < siz; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
		inv[i] = binpow(fac[i], mod - 2);
	}
	ll ans = 0;
	for (int i = b; i < w; i++) {
		int y1 = h - a - 1, x1 = i;
		int y2 = a - 1, x2 = w - i - 1;
		ll res = (ncr(x1 + y1, x1)) * (ncr(x2 + y2, x2)) % mod;
		ans = (ans + res) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 4000010
#define md 1000000007

ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
/*inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=power(f[M-1],md-2,md);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}*/



int main()
{
	IOS;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int c1=0,c2=0;
	rep(i,0,(int)s.size())
	{
		if(s[i]=='R')c1++;
		else
		c2++;
	}
	int flag=1;
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]=='W'&&s[i+1]=='R')flag=0;
	}
	if(flag)
	{
		cout<<0;
		return 0;
	}
	ll ans=min(c1,c2);
	ll c=0;
	for(int i=0;i<c1;i++)
	{
		if(s[i]=='W')c++;
	}
	ans=min(c,ans);
	cout<<ans<<endl;
}



Measured memory_bytes: 3760
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int MAX_N = 2e5 + 10, MOD = 1e9 + 7;
int N, M, K;
int F[MAX_N];
int Fdiv[MAX_N];

int _sum (int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;

	return c;
}

int _sub (int a, int b) {
	int c = a - b;
	if (c < 0)
		c += MOD;

	return c;
}

int _mul (int a, int b) {
	int c = 1LL * a * b % MOD;
	return c;
}

int _pow (int a, int b) {
	if (!b)
		return 1;

	int res = _pow(a, b >> 1);
	res = _mul(res, res);

	if (b & 1)
		res = _mul(res, a);

	return res;
}

int _choose (int a, int b) {
	if (b < a || min(a, b) < 0)
		return 0;

	return _mul(F[b], _mul(Fdiv[a], Fdiv[b - a]));
}

void preProcess() {
	F[0] = 1;
	for (int i = 1; i < MAX_N; i++)
		F[i] = _mul(i, F[i - 1]);

	Fdiv[0] = 1;
	Fdiv[1] = 1;
	for (int i = 2; i < MAX_N; i++)
		Fdiv[i] = _mul(_sub(0, MOD / i), Fdiv[MOD % i]);

	for (int i = 1; i < MAX_N; i++)
		Fdiv[i] = _mul(Fdiv[i - 1], Fdiv[i]);
}

int main() {
	preProcess();
	cin >> N >> M >> K;
	int A = 0, B = 0;
	for (int i = 1; i <= N; i++)
		A = _sum(A, _mul(i, N - i));

	for (int i = 1; i <= M; i++)
		B = _sum(B, _mul(i, M - i));

	int ans = _sum(_mul(A, _mul(_mul(M, M), _choose(K - 2, N * M - 2))), 
				   _mul(B, _mul(_mul(N, N), _choose(K - 2, N * M - 2))));	

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
'use strict'

function main(input) {
    input = input.split("\n")
    input = input[0].split('')

    let ans = "AC"

    //found A
    if (input[0] != "A") {
        ans = "WA"
    }

    let isUpper = (str) => {
        return str.match(/^[A-Z]+$/) ? true : false
    }
    let isLower = (str) => {
        return str.match(/^[a-z]+$/) ? true : false
    }

    let cnt = 0;

    for (let i = 1; i < input.length; i++) {
        if (isUpper(input[i])) {
            if (i == 1 ||
                i == input.length - 1 ||
                input[i] != 'C') {
                ans = "WA";
            }
            ++cnt;
        }
    }
    if (cnt != 1) {
        ans = "WA";
    }

    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 11468
n, k = map(int, input().split())
balls = list(map(int, input().split()))

if len(set(balls)) <= k:
  print(0)
  exit(0)

import collections
c = collections.Counter(balls)
c = c.most_common()[::-1]

kc = len(c)
total = 0
for num, count in c:
  kc -= 1
  total += count
  if kc == k:
    print(total)
    exit(0)

print(0)

Measured memory_bytes: 48440
#include<stdio.h>
int main(void){
  int d;
  scanf("%d",&d);
  if(d==25){
    printf("Christmas");
  }
  if(d==24){
    printf("Christmas Eve");
  }
  if(d==23){
    printf("Christmas Eve Eve");
  }
  if(d==22){
    printf("Christmas Eve Eve Eve");
  }
      return 0;
  }
      


Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        PriorityQueue<Integer> a = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
        }

        ArrayList<Swap> list = new ArrayList<>();

        for (int i = 0; i < m; i++) {
            list.add(new Swap(sc.nextInt(), sc.nextInt()));
        }

        list.sort((sa, sb) -> sb.value - sa.value);

        int count = 0;
        for (Swap s : list) {
            int add = Math.min(n - count, s.count);
            for (int i = 0; i < add; i++) {
                a.add(s.value);
            }
            count += add;
            if (count == n) {
                break;
            }
        }

        long ans = 0;

        for (int i = 0; i < n; i++) {
            ans += a.poll();
        }

        System.out.println(ans);
    }

    private static class Swap {
        private int count;
        private int value;

        public Swap(int count, int value) {
            this.count = count;
            this.value = value;
        }
    }
}


Measured memory_bytes: 98400
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
import numpy as np

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

k = int(input())
m = []
flatten = lambda x: [str(z) for y in x for z in (flatten(y) if hasattr(y, '__iter__') and not isinstance(y, str) else (y,))]

ll = [str(i) for i in range(1,10)]
o = []
for s in ll:
    l = []
    l.append(s)
    for i in range(10):
        p = []
        for j in l[-1]:
            t = []
            if str(j[-1])=='0':
                t.append(j+'0')
                t.append(j+'1')
            elif str(j[-1])=='9':
                t.append(j+'8')
                t.append(j+'9')
            else:
                t.append(j+str(int(j[-1])-1))
                t.append(j+str(int(j[-1])))
                t.append(j+str(int(j[-1])+1))
            p.append(t)
        l.append(flatten(p))
    o.append(l)

flatten = lambda x: [int(z) for y in x for z in (flatten(y) if hasattr(y, '__iter__') and not isinstance(y, str) else (y,))]

#print(sorted(set(flatten(o))))
print(sorted(set(flatten(o)))[k-1])


Measured memory_bytes: 102604
# メイン関数
def main():
    # 入力データ
    N, W = map(int, input().split())
    w = []
    v = []
    for i in range(N):
        wi, vi = map(int, input().split())
        w.append(wi)
        v.append(vi)

    # dpテーブルの作成
    dp = [[0] * (W+1) for i in range(N)]
    for i in range(N):
        for j in range(W + 1):
            if j - w[i] >= 0:
                dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j])
            else:
                dp[i][j] = dp[i - 1][j]

    # 解答の出力
    print(dp[-1][-1])
    return

# 実行
if __name__ == '__main__':
    main()


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

using namespace std;

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

	int n,k;
	cin>>n>>k;
	if(n>=2*k-1){ 
		cout<<"YES";
	}else{ 
		cout<<"NO";
	}

	return 0;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
l=[0]+list(map(int,input().split()))
from itertools import accumulate
l=list(accumulate(l))
l=[i%m for i in l]
import collections
c=collections.Counter(l)
ans=0
for i in c.values():
    ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 64664
<?php
fscanf(STDIN, "%d", $n);

$min = 0;
$result = 0;
for ($i = 1; $i <= $n; $i++) {
    fscanf(STDIN, "%d", $m);

    if (1 == $i) {
        $min = $m;
        continue;
    }

    if ($i > 2) {
        $result = max($result, $m - $min);
    }
    else {
        $result = $m - $min;
    }

    $min = min($min, $m);
}

echo "$result\n";

Measured memory_bytes: 6560
n, k = gets.chomp.split.map(&:to_r)

sum = 0
1.upto([n, k - 1].min) do |i|
  sum += 2**(-Math.log(k / i, 2).ceil)
end
puts (sum / n).to_f + (n >= k ? 1 - (k - 1) / n : 0)

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())


int main(){
    double n; cin>>n;
    vi x(n); rep(i,n) cin>>x.at(i);

    double total=0; rep(i,n) total+=x.at(i);

    double ave=round(total/n);

    int hp=0; rep(i,n) hp+=pow(x.at(i)-ave,2);

    cout<<hp<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define int long long
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	cout<<n*n*n<<endl;	
	return 0;	
}

Measured memory_bytes: 256
def solve(n, m):
    ans = [-1] * n
    for _ in range(m):
        s, c = input().split()
        s = int(s) - 1
        if ans[s] == c:
            continue
        elif ans[s] == -1:
            ans[s] = c
        else:
            return -1

    if ans[0] == '0':
        if n == 1:
            return '0'
        else:
            return -1
    elif ans[0] == -1:
        if n == 1:
            return '0'
        else:
            ans[0] = '1'

    for i in range(1, n):
        if ans[i] == -1:
            ans[i] = '0'
    return ''.join(ans)

n, m = map(int, input().split())
print(solve(n, m))

Measured memory_bytes: 3064
def main():
    A = list(map(int,input().split()))
    N = A[0]
    X = A[1]
    Y = A[2]
    list1 = [[0 for i in range(N)] for j in range(N)]
    ans = [0 for i in range(N-1)]

    for i in range(N):
        for j in range(i+1,N):
            list1[i][j] = min(j-i,abs(X-1-i)+1+abs(j-Y+1), abs(Y-1-i)+1+abs(j-X+1))
            ans[list1[i][j]-1] += 1

    for i in ans:
        print(i)


main()

Measured memory_bytes: 79324
a,b=map(int,input().split())
if a*b<0:
  ans=(abs(abs(a)-abs(b))+1)
elif a*b==0:
  ans=(max(abs(a),abs(b)))
  if a>b:
    ans+=1
elif a<=b:
  ans=(b-a)
else:
  ans=(a-b+2)
print(ans)

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

lli x;

int main(void){
	cin >> x;
	lli ans = 0;
	for(int i = 1; i < 40; i++){
		lli b = i;
		for(int j = 0; j < 10; j++){
			b*=i;
			if(b > x) break;
			ans = max(ans, b);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3572
s = int(input())
 
a = ['#']
i = 0
while i < 1000001:
  i += 1
  if i == 1:
    a.append(s)
  else:    
    if a[i-1]%2 == 0:
      ai = a[i-1] / 2
    else:
      ai = 3 * a[i-1] + 1
   
    if ai in a:
      print(i)
      exit()
    
    a.append(ai)
s = int(input())

a = ['#']
i = 0
while i < 1000001:
  i += 1
  if i == 1:
    a.append(s)
  else:    
    if a[i-1]%2 == 0:
      ai = a[i-1] / 2
    else:
      ai = 3 * a[i-1] + 1
   
    if ai in a:
      print(i)
      exit()
    
    a.append(ai)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int h,w,memo[1111][1111];
char mp[1111][1111];
int dp(int y,int x){
  int ret=0;
  if(memo[y][x]!=-1) return memo[y][x];
  if(y==h-1&&x==w-1) return 1;
  if(y<h&&mp[y+1][x]!='#') ret+=dp(y+1,x);
  if(x<w&&mp[y][x+1]!='#') ret+=dp(y,x+1);
  return memo[y][x]=ret%1000000007;
}
int main(){
  memset(memo,-1,sizeof(memo));
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>mp[i][j];
    }
  }
  cout<<dp(0,0)<<endl;
  return(0);
}


Measured memory_bytes: 6272
import heapq
n ,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]*=(-1)
heapq.heapify(a)

for i in range(m):
    x=heapq.heappop(a)
    x=((-1)*x)//2
    heapq.heappush(a, (-1)*x)
ans=0
for i in range(n):
    y=heapq.heappop(a)
    ans+=(-1)*y
print(ans)

Measured memory_bytes: 75116
#include<stdio.h>
#define abs(x) (((x)<0)?-(x):(x))
long d[500000],q[500000],a[500001],b[500001];

int main(int argc, char const *argv[]){
	long n,D,Q,i;
	scanf("%ld %ld",&n,&D);
	a[0]=D;
	for(i=0;i<n;i++){
		scanf("%ld",&d[i]);
		if(abs(a[i]-d[i])<a[i]) a[i+1]=abs(a[i]-d[i]);
		else a[i+1]=a[i];
	}
	b[n]=1;
	for(i=n-1;i>=0;i--){
		if(b[i+1]<=d[i]/2) b[i]=b[i+1];
		else{
			b[i]=b[i+1]+d[i];
		}
	}
	scanf("%ld",&Q);
	for(i=0;i<Q;i++){
		scanf("%ld",&q[i]);
	}
	for(i=0;i<Q;i++){
		if(a[q[i]-1]>=b[q[i]]) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 17536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	float  D,T,S;
	cin>>D>>T>>S;
	if(D/S<=T)
	{
		cout<<"Yes";

	}
	else
	{
		cout<<"No";
	}

	return 0;
}

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

int main(){
  int N;
  int i,x,y;
  int a,b,c;
  cin >> N;
  int d[2][3];
  cin >> d[0][0] >> d[0][1] >>d[0][2];
  x = 1;
  y = 0;
  for(i=1;i<N;i++){
    cin >> a >> b >> c;
    d[x][0] = max(d[y][1],d[y][2])+a;
    d[x][1] = max(d[y][0],d[y][2])+b;
    d[x][2] = max(d[y][0],d[y][1])+c;
    swap(x,y);
  }
  cout << max(d[y][0],max(d[y][1],d[y][2])) << endl;
  
  return 0;
}


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

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n+1,-1);
  int c = 1, l = 0;
  {
    int v = 1;
    while (ord[v] == -1) {
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];
  }

  if (k < l) cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  return 0;
}


Measured memory_bytes: 5884
package main

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

func main() {
	defer writer.Flush()
	n, q := ReadInt(), ReadInt()
	t := MakeSegTree(n)
	for _q := 0; _q < q; _q++ {
		if ReadInt() == 0 {
			i, x := ReadInt(), ReadInt()
			t.Update(i, x)
		} else {
			x, y := ReadInt(), ReadInt()
			Println(t.Query(x, y+1))
		}
	}
}

// Segment Tree for Range Minimum Query (RMQ)
type SegTree []int

const Unit = 1<<31 - 1

func MakeSegTree(n_ int) SegTree {
	n := 1
	for n < n_ {
		n <<= 1
	}
	t := make([]int, n*2)
	for i := 1; i < len(t); i++ {
		t[i] = Unit
	}
	return t
}

func (t SegTree) Update(i, x int) {
	i += len(t) >> 1
	t[i] = x
	for i > 1 {
		i >>= 1
		t[i] = Min(t[i*2], t[i*2+1])
	}
}

func (t SegTree) Query(a, b int) int {
	return t.queryRecur(a, b, 1, 0, len(t)>>1)
}

func (t SegTree) queryRecur(a, b, k, l, r int) int {
	if b <= l || r <= a {
		return Unit
	}
	if a <= l && r <= b {
		return t[k]
	}
	return Min(
		t.queryRecur(a, b, k*2, l, (l+r)>>1),
		t.queryRecur(a, b, k*2+1, (l+r)>>1, r),
	)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Buffer(make([]byte, 256), 1e9)
	scanner.Split(bufio.ScanWords)
}
func ReadString() string { scanner.Scan(); return scanner.Text() }
func ReadInt() int {
	a, err := strconv.Atoi(ReadString())
	if err != nil {
		panic(err)
	}
	return a
}

var writer = bufio.NewWriter(os.Stdout)

func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }



Measured memory_bytes: 5360
#include <cstdio>

#define N_MAX 500000
#define A_MAX 2000000000

int A[N_MAX], A1[N_MAX / 2 + 2], A2[N_MAX / 2 + 2];
int cnt = 0;

void myPrint(int n, int A[]) {
	for (int i = 0; i < n; i++) {
		if (i != 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void merge(int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) A1[i] = A[left + i];
	for (int i = 0; i < n2; i++) A2[i] = A[mid + i];
	A1[n1] = A2[n2] = A_MAX;
	int i1 = 0, i2 = 0;
	for (int i = left; i < right; i++) {
		cnt++;
		if (A1[i1] <= A2[i2]) {
			A[i] = A1[i1++];
		}
		else {
			A[i] = A2[i2++];
		}
	}
}

void mergeSort(int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(left, mid);
		mergeSort(mid, right);
		merge(left, mid, right);
	}
}

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

	mergeSort(0, n);
	myPrint(n, A);
	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    

    string s,t;
    cin >> s >> t;
    cout << t << s << endl;

}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    cout << N*(N-1)/2 << endl;
    return 0;
}

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

int main(){
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;

    if(r<=x&&x<=(w-r)&&r<=y&&y<=(h-r)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3104
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;
int main(){
    long long ans;
    
    int t;
    cin>>t;
    
    for(int j=0;j<t;++j){
        int n,k;
        vector<int> x;
        
        cin>>n>>k;
        
        for(int i=0;i<n;++i){
            int tmp;
            cin>>tmp;
            x.push_back(tmp);
        }
        
        sort(x.begin(),x.end());
        
        vector<int> d;
        
        for(int i=0;i<n-1;++i){
            d.push_back(x[i+1]-x[i]);
        }
        
        sort(d.begin(),d.end());
        
        ans=0;
        for(int i=0;i<n-k;++i){
            ans+=d[i];
        }
        
        cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 2388
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = ~(1 << 31);

ll march[5];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll ans = 0;
    int n;
    cin >> n;
    vector<string> vs(n);
    rep(i,n){ cin >> vs[i]; }
    rep(i,n){
        if(vs[i][0] == 'M'){
            march[0]++;
        }else if(vs[i][0] == 'A'){
            march[1]++;
        }else if(vs[i][0] == 'R'){
            march[2]++;
        }else if(vs[i][0] == 'C'){
            march[3]++;
        }else if(vs[i][0] == 'H'){
            march[4]++;
        }
    }
    int i = 0,j = 1,k = 2;
    while(true){
        if(i >= 2 && j >= 3 && k > 4) break;

        //cerr << i << " " << j << " " << k << endl;
        ans += march[i] * march[j] * march[k];

        if(k != 4){ 
            k++; 
        }else{
            if(j != 3){ 
                j++; 
                k = j + 1;
            }else{
                i++;
                j = i + 1;
                k = j + 1;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		ArrayList<Character> al = new ArrayList<Character>();
		ArrayList<Character> la = new ArrayList<Character>();
		String s = sc.next();
		sc.close();
		for(int i = 0 ; i < s.length() ; i++){
			if(i % 2 == 0) al.add(s.charAt(i));
			else la.add(s.charAt(i));
		}
		boolean ebishu = true;
		if(al.contains('L')) ebishu = false;
		if(la.contains('R')) ebishu = false;
		if(ebishu) ou.print("Yes\n");
		else ou.print("No\n");
		ou.flush();
    }
}

Measured memory_bytes: 35744