akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int N; cin >> N;
    string S; cin >> S;

    string ans = "";


    rep(i,S.size()) {
        ans += (char)( ( ((int)(S[i] - 'A') + N) % 26) + 'A');
    }
    cout << ans << endl;

    return 0;
}

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

int M[50][50];
int vs[50][50];
int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };
struct st { int x, y, cnt; };

int main()
{
  int H, W, street = 0;
  cin >> H >> W;
  rep(i, H) rep(j, W) {
    char c;
    cin >> c;
    if (c == '.') {
      street++;
      M[i][j] = 1;
    }
  }

  int root;
  queue<st> que;
  que.push({0, 0, 0});
  vs[0][0] = 1;
  bool ok = false;

  while (!que.empty()) {
    int x = que.front().x, y = que.front().y, cnt = que.front().cnt;  que.pop();
    if (x == H-1 && y == W-1) { root = cnt; ok = true; break; }
    rep(i, 4) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= H || ny < 0 || ny >= W || vs[nx][ny] || !M[nx][ny]) continue;
      que.push({nx, ny, cnt+1});
      vs[nx][ny] = 1;
    }
  }
  if (ok) cout << street - (root + 1) << endl;
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back

using namespace std;

using ll = long long;
using PAIR = pair<int, int>;
//using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VVI = vector<VI>;


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


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

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

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9

// Main program
void solve(){
    ll A,B,C,D,r,x,tmp;
    cin >> A >> B >> C >> D;
    ll a,b,c,d,E;//lcm(C,D)
    c = C;
    d = D;

    x = C * D;
 
  /* 自然数 a > b を確認・入替 */
  if(C < D){
    tmp = C;
    C = D;
    D = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = C % D;
  while(r!=0){
    C = D;
    D = r;
    r = C % D;
  }
 
  E = x /D;
  DPRINT(E)

    ll ans;
    ans = (B/c - (A-1)/c)+(B/d - (A-1)/d)-(B/E - (A-1)/E);

    ll ans1;
    DPRINT(d)
    ans1 = (B / d );
    DPRINT(ans1)
    cout << B - A + 1 - ans << endl;

}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

	for (int i = 0; i < T; ++i) {
		solve();
	}
}

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


int N, K;
vector<int> A(110);
vector<bool> dp(100010, false);

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int k = 0; k <= K; k++){
        for(int i = 0; i < N; i++){
            if(k+A[i] > K) continue;
            dp[k+A[i]] = (!(dp[k]) || dp[k+A[i]]);
        }
    }

    if(dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 3620
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] input = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();
        int n = input[0];
        int t = input[1];

        int[] tn = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();

        int cnt = 0;

        cnt += t;

        for (int i = 0; i < n - 1; i++)
        {
            cnt += Math.Min(tn[i+1]-tn[i], t);
        }

        Console.WriteLine(cnt);
    }
}

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

int main() {
	int n;
	cin>>n;
	
	vector<vector<int>> A,dp(n+1,vector<int> (3,0));
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		A.push_back({a,b,c});
	}
	
	for(int i=n-1;i>=0;i--)
	{
		dp[i][0]=A[i][0]+max(dp[i+1][1],dp[i+1][2]);
		dp[i][1]=A[i][1]+max(dp[i+1][0],dp[i+1][2]);
		dp[i][2]=A[i][2]+max(dp[i+1][0],dp[i+1][1]);
	}
	
	cout<<max({dp[0][0],dp[0][1],dp[0][2]});
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	VI zz(31);
	
	rep(i, n){
		rep(j, 31){
			if(a[i] >> j &1) zz[j]++;
		}
	}
	rep(j, 31){
		if(zz[j] &1) {puts("No"); return 0;}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 640
#create date: 2020-09-19 21:01

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    cnt = 0
    ans = False
    for _ in range(n):
        d1, d2 = na()
        if d1 == d2:
            cnt += 1
            if cnt == 3:
                ans = True
        else:
            cnt = 0
    print("Yes" if ans else "No")
        

if __name__ == "__main__":
    main()

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

ll n,x,y,poc;
string s;
vector<ll> goredole,levodesno;
unordered_set<ll> dpx[16005],dpy[16005];

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

    cin>>s>>x>>y;
    n=s.size();

    ll cnt=0;
    for(ll i=0;i<n;i++)
        if(s[i]=='F')
            cnt++;
        else
        {
            poc=cnt;
            break;
        }
    if(cnt==n)
    {
        x-=n;
        if(x==0&&y==0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
        return 0;
    }
    x-=poc;
    ll br=0,smer=1;
    for(ll i=cnt;i<n;i++)
    {
        if(s[i]=='F')
            br++;
        else
        {
            if(br>0)
            {
                if(smer==1)
                    levodesno.push_back(br);
                else
                    goredole.push_back(br);
                br=0;
            }
            smer*=-1;
        }
    }
    if(br>0)
    {
        if(smer==1)
            levodesno.push_back(br);
        else
            goredole.push_back(br);
        br==0;
    }
    /*ll ind1=2,ind2=2;
    if(goredole.size()==0)
        if(y==0)
            ind1=1;
        else
            ind1=0;
    if(levodesno.size()==0)
        if(x==0)
            ind2=1;
        else
            ind2=0;
    */
    dpx[0].insert(0); dpy[0].insert(0);
    for(ll i=0;i<levodesno.size();i++)
    {
        for(ll j=-n;j<=n;j++)
            if(dpx[i].count(j+levodesno[i])||dpx[i].count(j-levodesno[i]))
                dpx[i+1].insert(j);
    }
    for(ll i=0;i<goredole.size();i++)
    {
        for(ll j=-n;j<=n;j++)
            if(dpy[i].count(j+goredole[i])||dpy[i].count(j-goredole[i]))
                dpy[i+1].insert(j);
    }
    /*if(ind1!=2||ind2!=2)
    {
        if(ind1==1&&ind2==1)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
        return 0;
    }*/
    
    if(dpx[levodesno.size()].count(x)&&dpy[goredole.size()].count(y))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    for (int i = 0; i < M; i++)
        cin >> X[i];
    sort(X.begin(), X.end());

    vector<int> diff(M - 1);
    for (int i = 0; i < M - 1; i++) {
        diff[i] = X[i + 1] - X[i];
    }
    sort(diff.begin(), diff.end());
    
    long long res = 0;
    for (int i = 0; i < M - N; i++) {
        res += diff[i];
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	cin>>n>>m;
	int a,b;
	a=(double)n/0.08;
	b=(double)m/0.1;
	int k,l;
	k=a<b?a-1:b-1;
	l=a>b?a+1:b+1;
	double ns,ms;
//	cout<<k<<" "<<l<<endl;
	for(int i=k;i<=l;i++) {
//		cout<<"test:"<<i<<endl;
		ns=(double)i*(double)0.08;
		ms=(double)i*(double)0.1;
		if(floor(ns)==n && floor(ms)==m) {
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;


void solve(long long N, std::vector<std::string> S){
    vector<int> a(4);
    fill(a.begin(), a.end(), 0);
    REP(i, N) { 
        if ("AC" == S[i]) {
            a[0]++;
        } else if ("WA" == S[i]){ 
            a[1]++;
        } else if ( "TLE" == S[i])  {
            a[2]++;
        } else if ( "RE" == S[i])  { 
            a[3]++;
        }
    }
    
    cout << "AC x " << a[0] << endl;
    cout << "WA x " << a[1] << endl;
    cout << "TLE x " << a[2] << endl;
    cout << "RE x " << a[3] << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 6420
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	string str;
	cin >> n >> str;
	int lcnt = 0;
	int o = 0;
	for (auto& c : str)
	{
		if (c == '(') o++;
		else o--;
		if (o < 0) lcnt++, o = 0;
	}
	cout << string(lcnt, '(') << str << string(o, ')') << endl;
	return 0;
}

Measured memory_bytes: 256
K = int(input())
n = "7"*(len(str(K))+1)
m = "7"*len(str(K))
p = int(n)
ans = 0
flag = 0
if(K%2==0):
  print("-1")
elif(K==1 or K==11 or K==111 or K==1111 or K==11111 or K==111111):
  print(len(str(K)))
elif(K==7 or K==77 or K==777 or K==7777 or K==77777 or K==777777):
  print(len(str(K)))
else: 
  while(ans <= K):
    ans += 1
    q = p % K
    p = str(q) + "7"
    p = int(p)
    if(q==0):
      print(ans+len(str(K)))
      flag = 1
      break
  if(flag==0):
    print("-1")

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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  int mod = (N*M) % 2;
  if (mod == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int n,a,l,r;
int main(){
	while(cin>>n,n){
		int sum=0;
		string s="OK";
		priority_queue<P2>q1,q2;
		r(i,n){
			cin>>a>>l>>r;
			q1.push(P2(-l,P(r,a)));
		}
		while(!q1.empty()){
			P2 p=q1.top();q1.pop();
			while(!q2.empty()){
				P2 x=q2.top();
				if(-x.F<=-p.F){
					q2.pop();
					sum-=x.S.S;
				}
				else break;
			}
			sum+=p.S.S;
			if(150<sum)s="NG";
			q2.push(P2(-p.S.F,P(p.F,p.S.S)));
		}
		cout<<s<<endl;
	}
}


Measured memory_bytes: 2996
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long ll;

int main(){
    int N, M;cin >> N >> M;
    int problem[N];
    rep(i, N)problem[i] = 0;
    int wrongCount[N];
    rep(i, N)wrongCount[i] = 0;
    int ans = 0, ansWrong = 0;
    rep(i, M){
        int p;
        string s;
        cin >> p >> s;
        --p;
        if(s == "AC")
            problem[p] = 1;
        else if(s == "WA"){
            if(problem[p] == 0)
                wrongCount[p] += 1;
        }
    }
    rep(i, N){
        if(problem[i]){
            ans += 1;
            ansWrong += wrongCount[i];
        }
    }
    cout << ans << ' ' << ansWrong;
}


Measured memory_bytes: 1024
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
 
M = [None]*(max(A)+1)
T = [None]*N
for i,a in enumerate(A):
    M[a] = i
 
for i,a in enumerate(A):
    T[M[a]]=(i+1)%N
    M[a]=i
 
ptr=0
ptr_head = [ptr]
while True:
    ptr_next = T[ptr]
    if ptr_next==0: break
    if ptr_next <= ptr+1: ptr_head.append(ptr_next)
    ptr = ptr_next
 
period = len(ptr_head)
if T[-1]==0: period+=1
 
if K % period==0:
    print()
    exit()
 
ret = []
ptr = ptr_head[K % period - 1]
while ptr<N:
    ptr_next = T[ptr]
    if ptr_next > ptr+1:
        ptr = ptr_next
    elif ptr_next==0 and ptr!=N-1:
        break
    else:
        ret.append(A[ptr])
        ptr+=1
 
print(' '.join(map(str, ret)))

Measured memory_bytes: 43704
import scala.math.{min,max}

object Main {
    def main(args: Array[String]) {
        var input = io.Source.stdin.getLines().mkString("\n");
        var ss = input.split('\n').toList;
        val xs = to_array_int(ss(0));
        val a = xs(0);
        val b = xs(1);
        val t = xs(2);
        val res = t / a * b;
        println(res);
    }
    def to_array_int(s: String): Array[Int] = {
        return s.split(' ').map(_.toInt).toArray;
    }
}


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

int main(){
	int n,k;
  	cin >> n >>k;
  	int a[n];
  	int count =0;
  
  	for(int i=1; i<=n;i++) cin >> a[i];
  
  	for(int i=1; i<=n;i++){
    	if(k <= a[i]) {
          count++;
        }
    }
  	cout << count << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define PI 3.14159265358979323846
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

signed main(){
	
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double n1=PI*2.0/720.0*(h*60.0+m);
	double n2=PI*2.0/60.0*m;
	double n23=abs(n1-n2);
	if(n23>=PI)n23=2*PI-n23;
	double n3=a*a+b*b-2.0*a*b*cos(n23);
	double n4=sqrt(n3);
	//cout<<abs(n23)/(2*PI)*360.0<<endl;
	printf("%.20lf",n4);
	cout<<endl;

}


Measured memory_bytes: 4292
#ある数gを用意して，最も近いgの倍数にするための手数を数える，プラマイの総和が0にならない限り，最も変更に要する手数が大きいところは逆転させる？
#gはAの総和の約数

N,K=map(int,input().split())
A=list(map(int,input().split()))


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

div=make_divisors(sum(A))

ans=0
for g in div:
    near=[0]*N
    S=0
    for i in range(N):
        near[i]=a=A[i]%g
        S+=near[i]
    near.sort()
    ii=0
    while S!=0:
        S-=g
        ii-=1
    temp=sum(near[:ii])
    if temp<=K:
        ans=max(ans,g)
        
print(ans)
    
    




Measured memory_bytes: 41708
#include <stdio.h>

int main(int argc, char **argv)
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);
    int i;

    for (i=0; a<=b; a++) {          
        if (c % a == 0) i++;        
    }
    printf("%d\n", i);

    return 0;
}

Measured memory_bytes: 596
// ABC062
// A - Grouping
#include<bits/stdc++.h>

using namespace std;

int main(){
    int x,y;
    set<int> s1{1,3,5,7,8,10,12}, s2{4,6,9,11}, s3{2};
    cin >> x >> y;
    if((s1.count(x)==1 and s1.count(y)==1) ||
        (s2.count(x)==1 and s2.count(y)==1) ||
        (s3.count(x)==1 and s3.count(y)==1))
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
s=input()
a=0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i]=="L":
      a+=1
      break
  else:
    if s[i]=="R":
      a+=1
      break
if a>0:
  print("No")
else:
  print("Yes")

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>h(n),cnt(n,0); for(auto&i:h)cin>>i;
	int ans=0;
	for(int i=0;h!=cnt;i=0){
		while(i<n&&h.at(i)==0)++i;
		while(i<n&&h.at(i)!=0)--h.at(i),++i;
		++ans;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    while(1){
        int r=32;
        int i;
        int a[1000];
        cin>>i;
        if(i==0)break;
        for(int j=0;j<i;j++){
            cin>>a[j];
        }
        int k=0;
        for(int j=0;r>0;j++){
            if(j%2==0)r-=(r-1)%5;
            else if(j%2==1)r-=a[k],k++;
            if(k==i)k=0;
            if(r>0)cout<<r<<endl;
            else cout<<0<<endl;
        }
    }
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int a[100100];
  int num = 1;
  cin >> n;
  for(int i=1; i<=n; i++){
    cin >> a[i];
  }
  int ans[100100];
  for(int i=1; i<=n; i++){
    ans[a[i]] = i;
  }
  for(int i=1; i<=n; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	string s;
	cin>>s;
	int cnt=0;
	int ans=0;
	rep(i,3){
		if(s[i]=='R'){
			cnt++;
		}else{
			ans=max(ans,cnt);
			cnt=0;
		}
	}
	ans=max(ans,cnt);
	cout<<ans<<endl;

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  vector<long double> v(n);
  for(int i=0;i<n;i++){
      cin>>v[i];
  }
 // cout<<v[0]<<v[1]<<v[2]<<endl;
  vector<long double> dp(n+1,0);
  dp[0] = 1;
  for(int i=1;i<=n;i++){
      vector<long double> temp(n+1);
      for(int j=0;j<=n;j++){
          if(j==0){
              temp[j] = dp[j]*(1-v[i-1]);
             // cout<<temp[j]<<" ";
              continue;
          }
          temp[j] = dp[j]*(1-v[i-1]) + v[i-1]*dp[j-1];
          //cout<<temp[j]<<" "<<v[i-1]<<"*"<<temp[j-1]<<" ";
      }
      //cout<<endl;
      dp = temp;
  }
  long double ans =0;
  for(int i=(n+1)/2;i<=n;i++){
      ans = ans + dp[i];
  }
 // cout<<dp[2]<<" "<<dp[3]<<" ";
 // cout<<((1-v[0])*(1-v[1])*(1-v[2]));
  cout<<setprecision(10)<<ans;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	int a,b,c;

	scanf("%d",&a);

	while(scanf("%d %d %d",&a,&b,&c)!=EOF){

		a = a*a;
		b = b*b;
		c = c*c;

		if(a==b+c||c==a+b||b==c+a)
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}

Measured memory_bytes: 580
#include <algorithm>
#include <iostream>
#include <string>
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

string a[100010];
int n;
ll s, ans; 

bool cmp(string x, string y){
	for(int i = 0; i < 10; i++)
		if(x[i] < y[i]) return true;
		else if(x[i] > y[i]) return false;
	return false;
}

int main(){

	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n; i++)
		std::sort(a[i].begin(), a[i].end());
	std::sort(a + 1, a + n + 1, cmp);
	s = 1;
	for(int i = 1; i <= n; i++){
		if(a[i] == a[i - 1])
			s++;
		else{
			ans += s * (s - 1) / 2;
			s = 1;
		}
	}
	if(s) ans += s * (s - 1) / 2;
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 7296
C =input()
alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(len(alp)):
    if alp[i] == C:
        print(alp[i+1])
        exit()

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

#define ll long long int
#define vi vector<int> 

int main() {
	int n;
	cin >> n;
	string s="ABC";
	string a;
	cin >> a;
	
	
	int cnt1=0;
	for(int i=0;i+2<n;i++){
	    int cnt=0;
	    for(int j=0;j<3;j++){
	        if(a[i+j]==s[j])
	          cnt++;
	        
	    }
	    if(cnt==3)cnt1++;
	}
	cout << cnt1;
}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n;
    string s;
    cin >> n;
    cin >> s;
    lint count[26];
    for (int i=0; i<26; ++i){
        count[i] = 0;
    }
    for (int i=0; i<n; ++i){
        count[s[i] - 'a']++;
    }
    lint ans = 1;
    for (int i=0; i<26; ++i){
        ans *= (count[i] > 0) ? (count[i] + 1) : 1;
        ans = ans % MOD;
    }
    ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
    
   ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    
    vector<int> v(1);
    cin >> v[0];
    for (int i = 1; i < n; i++) {
        int a; cin >> a;;
        if (v[v.size() - 1] >= a) {
            v.push_back(a);
        } else {
            *upper_bound(v.begin(), v.end(), a, greater<int>()) = a;
        }
    }
    
    cout << v.size() << endl;
    
    return 0;
}


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

int main()
{
    long long int n, m;
    vector<long long int> a;
    vector<pair<long long int, long long int>> vp;
    cin >> n >> m;
    a.resize(n);
    vp.resize(m);
    for (long long int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    std::sort(a.begin(), a.end());
    for (long long int i = 0; i < m; i++)
    {
        cin >> vp[i].first >> vp[i].second;
    }
    std::sort(vp.begin(), vp.end(), [](auto &p1, auto &p2){return p1.second > p2.second;});
    long long int c = 0, sum = 0;
    for (long long int i = 0; i < n && c < m; c++)
    {
        if (a[i] >= vp[c].second)
            break;
        for (; vp[c].first > 0; i++, vp[c].first--)
        {
            if (a[i] < vp[c].second)
                a[i] = vp[c].second;
            else
                break;
        }
    }
    for (long long int i = 0; i < n; i++)
    {
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <string>

int main()
{
    int n;
    std::string s;

    std::cin >> n;
    std::cin >> s;

    int cnt = -1;
    int sz = -1;
    do {
        sz = s.find("ABC", sz+1);
        cnt++;
    } while ( sz != std::string::npos );

    std::cout << cnt;

    return 0;
}


Measured memory_bytes: 256
/*
 * author :Sadik Hassan(_sad_)
 *
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
using   ld =          long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define urep(i,n)     for(int i=n-1;i>=0;i--)
#define urep1(i,n)    for(int i=n;i>=1;i--)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(15);

typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = (int)2e5+5;
const int MOD =(int)1e9+7;
const ll INF = (ll)1e18+5;

int main()
{
    _SAD()
    int n;
    cin>>n;
    vii a(n+5,0);
    a[0]=1;
    for(int i=3;i<=n;i++)
    {
        for(int j=3;j<=i;j++)
        {
            a[i]+=a[i-j];
            a[i] %= MOD;
        }
    }
    cout<<a[n]<<nl;
    return 0;
}


Measured memory_bytes: 3644
use std::io;


fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {
    let l = read_line();
    let n: i64 = to_i(&l);

    let nums = read_nums();
    let mut count = 0;
    //let mut flag = true;
    let mut max = 0;
    for i in 0..n {
        let h = nums[i as usize];;
        if i==0 {
            max = h;
            count += 1;
        }else{
            if h>=max {
                count +=1;
            }
            if h>max {
                max = h;
            }
        }
    }


    print!("{}", count);
}   

Measured memory_bytes: 4352
n = int(input())
h = list(map(int, input().split()))

ans = True
for i in range(n-1, 0, -1):
  if h[i-1] == h[i] + 1:
    h[i-1] -= 1
  elif h[i-1] > h[i] + 1:
    ans = False
    break
  elif h[i-1] <= h[i]:
    pass
 
if ans == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14396
#include <stdio.h>
main(){
  int a,b,c,tmp,i,j;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  if(a>c){
    tmp=a;
    a=c;
    c=tmp;
  }
  if(b>c){
    tmp=b;
    b=c;
    c=tmp;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}

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

template<class T>
struct GraphNode {
    GraphNode(T data):
        neighbors(),
        data(data) 
    { }

    std::vector<GraphNode *> neighbors;
    T data;
};

template<class T>
class Graph {
public:
    enum CONTINUE_SEARCH {
        CONTINUE, END
    };

    Graph(const uint64_t num_nodes, T data):
        nodes(num_nodes, GraphNode<T>(data))
    { }

    GraphNode<T> &get_node(uint64_t n) {
        return nodes[n];
    }

    void add_bidirectional_edge(const uint64_t a, const uint64_t b) {
        nodes[a].neighbors.push_back(&nodes[b]);
        nodes[b].neighbors.push_back(&nodes[a]);
    }

    void depth_first_search(
        const uint64_t start_node,
        std::function<CONTINUE_SEARCH(GraphNode<T> &, uint64_t)> func)
    {
        auto searched_nodes = std::unordered_set<GraphNode<T> *>();
        depth_first_search_impl(nodes[start_node], func, searched_nodes, 0);
    }

private:
    void depth_first_search_impl(
        GraphNode<T> &node,
        std::function<CONTINUE_SEARCH(GraphNode<T> &, uint64_t)> func,
        std::unordered_set<GraphNode<T> *> &searched_nodes,
        uint64_t depth)
    {
        if(searched_nodes.insert(&node).second) {
            if(func(node, depth) == CONTINUE_SEARCH::CONTINUE) {
                for(auto neighbor: node.neighbors) {
                    depth_first_search_impl(*neighbor, func, searched_nodes, depth + 1);
                }
            }
        }
    }

    std::vector<GraphNode<T> > nodes;
};

uint64_t solve(Graph<uint64_t> &g, uint64_t runner, uint64_t chaser) {
    g.depth_first_search(chaser, [](GraphNode<uint64_t> &node, uint64_t depth) {
        node.data = depth;
        return Graph<uint64_t>::CONTINUE;
    });

    uint64_t farthest = 0;

    g.depth_first_search(runner, [&](GraphNode<uint64_t> &n, uint64_t depth) {
        if(n.data <= depth) {
            return Graph<uint64_t>::END;
        }
        if(farthest < n.data) {
            farthest = n.data;
        }
        return Graph<uint64_t>::CONTINUE;
    });
    return farthest - 1;
}

int main() {
    uint64_t n, runner, chaser;
    std::cin >> n >> runner >> chaser;
    auto g = Graph<uint64_t>(n, 0);
    for(int i = 0; i < n - 1; ++i) {
        uint64_t a, b;
        std::cin >> a >> b;
        g.add_bidirectional_edge(a - 1, b - 1);
    }

    std::cout << solve(g, runner - 1, chaser - 1);

    return 0;
}


Measured memory_bytes: 17444
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define PI			2*acos(0.0)
int main()
{
    int n;
    cin >>n;
    int l=3*n;
    long long int a[l+1],i,sum=0;
    for(i=0;i<3*n;i++)
    {
        cin >>a[i];
    }
    sort(a,a+l,greater<int>());
    for(i=1;i<2*n;i+=2)
    {
        sum=sum+a[i];
    }
    cout <<sum;
    return 0;
}

Measured memory_bytes: 5892
MOD = 10**9+7

N = int(input())
A = list(map(int,input().split()))

def gcd(x,y):
    while y:
        x,y = y,x%y
    return x

LCM = A[0]
for i in range(1,N):
    GCD = gcd(LCM,A[i])
    LCM = LCM*A[i]//GCD
LCM %= MOD
ans = 0

for i in range(N):
    ans += LCM*pow(A[i],MOD-2,MOD)
    ans %= MOD

print(ans%MOD)

Measured memory_bytes: 41692
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int jousu(int, int);
int jousu(int x, int y) {
	int z = 1;
	for (int i = 0; i < y; i++) {
		z *= x;
	}
	return z;
}
int kurai(int x, int y) {
	int z = (x%jousu(10,y)) / jousu(10, y-1);
	return z;
}
int keta(int x) {
	int z = x;
	int w = 0;
	while (z != 0) {
		z /= 10;
		w++;
	}
	return w;
}


int main(){
	int k, x;
	cin >> k >> x;
	if (k * 500 < x) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    cout<<arr[n-1]-arr[0]<<endl;
}

Measured memory_bytes: 3628
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func solve(a,b,c,k int) bool {
	if(c>b && b>a){
		return true
	}
	if(k==0){
		return false
	}
	return solve(a,b,2*c,k-1)||solve(a,2*b,c,k-1)||solve(2*a,b,c,k-1)
}

// Credits - github.com/EndlessCheng/codeforces-go
func solve2(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var a,b,c,k int
	Fscan(in, &a,&b,&c)
	Fscan(in, &k)
	if solve(a,b,c,k){
		Fprintln(out,"Yes")
	} else {
		Fprintln(out,"No")
	}
}

func main() { solve2(os.Stdin, os.Stdout) }



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

int main()
{
    int n;
    cin>>n;
    int arr[n][2];
    for(int i=0;i<n;i++)
        cin>>arr[i][0]>>arr[i][1];
    
    bool flag = false;
    for(int i=0;i<n-2;i++)
    {
        if(arr[i][0]==arr[i][1] && arr[i+1][0]==arr[i+1][1] && arr[i+2][0]==arr[i+2][1])
        {
            flag = true;
            cout<<"Yes";
            break;
        }
    }
    if(flag == false)
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N; cin >> N;
    cout << (int)((1.0*N-1)/2) << endl;
    return 0;
}


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

int n, k, root = 1;
int p[2042], sz[2042];
vector < int > chs[2042];
int dp[2042][2042], maxL[2042];

void rootTr ( int x ) {
    sz[x] = 1;
    for ( int i = 0 ; i < chs[x].size() ; i ++ ) {
        if ( chs[x][i] == p[x] ) {
            swap( chs[x][i], chs[x][ chs[x].size()-1 ] );
            chs[x].pop_back();
            i --;
        }else {
            p[ chs[x][i] ] = x;
            rootTr ( chs[x][i] );
            sz[x] += sz[ chs[x][i] ];
        }
    }
}

void solve ( int x ) {
    for ( int i = 0 ; i < chs[x].size() ; i ++ ) {
        solve( chs[x][i] );
    }
    dp[x][0] = sz[x];
    dp[x][1] = sz[x]-1;

    for ( int l = 2 ; l <= k+1 ; l ++ ) {
        dp[x][l] = dp[x][l-1];

        int sum = 0;
        for ( int i = 0 ; i < chs[x].size() ; i ++ ) {
            sum += dp[ chs[x][i] ][ min( k-l+1, l-1 ) ];
        }
        for ( int i = 0 ; i < chs[x].size() ; i ++ ) {
            int nSum = sum - dp[ chs[x][i] ][ min( k-l+1, l-1 ) ] + dp[ chs[x][i] ][ l-1 ];
            dp[x][l] = min( dp[x][l], nSum );
        }

    }
}

int main () {
    cin >> n >> k;
    for ( int i = 0 ; i < n-1 ; i ++ ) {
        int a,b;
        cin >> a >> b;
        chs[a].push_back( b );
        chs[b].push_back( a );
    }
    rootTr ( root );
    solve( root );
    int ans = 1<<20;
    for ( int i = 1 ; i <= n ; i ++ ) {
        ans = min( ans, dp[i][k+1] + (n-sz[i]) );
    }
    cout << ans << "\n";

    return 0;
}


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


# 二項係数を 10^9+7 で割った余りを求める
# https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-%E4%BA%8C%E9%A0%85%E4%BF%82%E6%95%B0-ncr
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6

mod = 10**9 + 7

# x ** a をmodで割った余りを、lod(a)時間で求める。
def power(x, a):
	if a == 0:
		return 1
	elif a == 1:
		return x
	elif a % 2 == 0:
		return power(x, a//2) **2 % mod
	else:
		return power(x, a//2) **2 * x % mod

# xの逆元を求める。フェルマーの小定理より、 x の逆元は x ^ (mod - 2) に等しい。計算時間はlog(mod)程度。
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
	return power(x, mod-2)

# 二項係数の左側の数字の最大値を max_len　とする。nとかだと他の変数と被りそうなので。
# factori_table = [1, 1, 2, 6, 24, 120, ...] 要は factori_table[n] = n!
max_len = n #適宜変更する

factori_table = [1] * (max_len + 1)
factori_inv_table = [1] * (max_len + 1)
for i in range(1, max_len + 1):
	factori_table[i] = factori_table[i-1] * (i) % mod
	factori_inv_table[i] = modinv(factori_table[i])

def binomial_coefficients(n, k):
	# n! / (k! * (n-k)! )
	return (factori_table[n] * factori_inv_table[k] * factori_inv_table[n-k]) % mod

for i in range(1, k+1):
	if i-1 > n-k:
		# 境界を i-1 個作らなければならないが、赤いボールの数 n-k よりもこれが多いと条件を満たす置き方は存在しない
		print(0)
	else:
		# (n-k+1)C(i) * (k-1)C(k-i)
		print((binomial_coefficients(n-k+1, i) * binomial_coefficients(k-1, k-i)) % mod)

		

Measured memory_bytes: 3444
package main

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

type Range struct {
	left  int
	right int
}

type Ranges []Range

func (r Ranges) Len() int {
	return len(r)
}

func (r Ranges) Less(i, j int) bool {
	return r[i].right < r[j].right
}

func (r Ranges) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

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

	_ = scanInt(sc) // nIslands
	nQuestions := scanInt(sc)

	ranges := make([]Range, nQuestions)
	for i := 0; i < nQuestions; i++ {
		left := scanInt(sc)
		right := scanInt(sc)
		ranges[i] = Range{left, right}
	}

	sort.Sort(Ranges(ranges))

	nBlocks := 0
	right := 0
	for _, r := range ranges {
		if r.left >= right {
			right = r.right
			nBlocks += 1
		}
	}

	fmt.Println(nBlocks)
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


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

bool kaibun(string s){
  int n=s.size();
  bool kai=true;
  for(int i=0;i<n/2;i++){
    if(s.at(i)!=s.at(n-i-1)){
      kai=false;
    }
  }
  return kai;
}

int main(){
  string S;
  cin>>S;
  int N=S.size();

  bool l1, l2, l3;
  
  l1 = kaibun(S);
  l2 = kaibun(S.substr(0, (N-1)/2));
  l3 = kaibun(S.substr((N+3)/2-1, N));
  
  if(l1&&l2&&l3){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(void){
        int n,a,b,na;
        scanf("%d %d %d",&n,&a,&b);
        na=n*a;
        if(na<b){
                printf("%d\n",na);
        }else{
                printf("%d\n",b);
        }
        return 0;
}

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


void solve(){
  int n, q; cin >> n >> q;
  vector<queue<int> > qq(n);
  while(q--){
    int type; cin >> type;
    switch(type){
      case 0:
        int t0, x; cin >> t0 >> x;
        qq[t0].push(x);
        break;
      case 1:
        int t1; cin >> t1;
        if(!qq[t1].empty())
        cout << qq[t1].front() << endl;
        break;
      case 2:
        int t2; cin >> t2;
        if(!qq[t2].empty()){
          qq[t2].pop();
        }
        break;
      default: 
        cout << "Error" << endl;  
    }
  }
}

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



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

#define ll long long int

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

  int n;
  cin>>n;
  int a[n];
  int c=0;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
    if(i%2&&a[i]%2)
      c++;
  }
  cout<<c;
    

  return 0;
}

Measured memory_bytes: 3604
def run(N, M, L, R):
    maxL = max(L)
    minR = min(R)
    if maxL > minR:
        ret = 0
    else:
        ret = minR - maxL + 1
    return ret


def main():
    N, M = map(int, input().split())
    L = []
    R = []
    for _ in range(M):
        LR = list(map(int, input().split()))
        L.append(LR[0])
        R.append(LR[1])
    print(run(N, M, L, R))


if __name__ == '__main__':
    main()


Measured memory_bytes: 11296
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int a, b; readV(a, b);
  writeln(a <= 8 && b <= 8 ? "Yay!" : ":(");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long n,a,b;
  scanf("%lld %lld %lld",&n,&a,&b);
  if(b-a<2||n+1<=a){
    printf("%lld\n",n+1);
    return 0;
  }
  n-=a-1;
  printf("%lld\n",a+n/2*(b-a)+n%2);
  return 0;
}


Measured memory_bytes: 128
n,m=map(int,input().split())
l=sorted(list(map(int,input().split())))
l1=[]
l2=0
if n>=m:
  print(0)
else:
  for i in range(m-1):
    l1.append(l[i+1]-l[i])
  l1=sorted(l1)
  for i in range(m-n):
    l2+=l1[i]
  print(l2)

  


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

int main()
{
    int a,b;
  cin >> a >> b;
  double fa=a,fb=b;
  cout<<fixed;
  cout <<setprecision(8)<< (a/b) <<" "<<(a%b)<<" "<<(fa/fb);
  cout<<"\n";

    return 0;
}



Measured memory_bytes: 3276
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=12e4;

int a[N],b[N],aa[N],bb[N];
int n,m,hs;
int fa[N];

map<int,int> s;

inline int get(int o)
{return (fa[o]==o)?o:(fa[o]=get(fa[o]));}

int main()
{
	cin>>n;
	fo(i,1,n)scanf("%d",&a[i]),a[n+1]^=a[i];
	fo(i,1,n)scanf("%d",&b[i]),b[n+1]^=b[i];
	++n;
	fo(i,1,n)aa[i]=a[i],bb[i]=b[i];
	sort(aa+1,aa+n+1); sort(bb+1,bb+n+1);
	fo(i,1,n)if(aa[i]!=bb[i]){
		puts("-1");
		return 0;
	}
	int p=0;
	aa[0]=-1;
	fo(i,1,n)if(aa[i]!=aa[i-1]){
		++p;
		s[aa[i]]=p;
	}
	int ans=-1;
	fo(i,1,n)a[i]=s[a[i]];
	fo(i,1,n)b[i]=s[b[i]];
	fo(i,1,n)if(a[i]!=b[i])fa[a[i]]=a[i],fa[b[i]]=b[i],ans=ans+(i<n);
	fo(i,1,n)if(a[i]!=b[i])fa[get(a[i])]=get(b[i]);
	fo(i,1,p)if(!fa[i])fa[i]=get(i);
	fo(i,1,p)if(fa[i]==i)++hs;
	ans=ans+hs;
	if(a[n]==b[n]&&fa[a[n]]==0)++ans;
	if(ans<0)ans=0;
	cout<<ans;
}

Measured memory_bytes: 7808
import sys

MOD = 1000000007


def main():
    s = sys.stdin.readline().strip()
    dp = [[0] * 13 for _ in range(len(s))]

    if s[0] == '?':
        for i in range(10):
            dp[0][i] = 1
    else:
        num = int(s[0])
        dp[0][num] = 1

    for i in range(1, len(s)):
        if s[i] == '?':
            for num in range(10):
                for rem_prev in range(13):
                    val = rem_prev * 10 + num
                    rem_cur = val % 13
                    dp[i][rem_cur] = (dp[i][rem_cur] + dp[i-1][rem_prev]) % MOD
        else:
            s_i = int(s[i])
            for rem_prev in range(13):
                rem_cur = (rem_prev * 10 + s_i) % 13
                dp[i][rem_cur] = (dp[i][rem_cur] + dp[i-1][rem_prev]) % MOD

    print(dp[len(s)-1][5])


if __name__ == '__main__':
    main()



Measured memory_bytes: 61916
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()
A = sorted(A)

if A[0] == 1:
    if N >= 2 and A[1] == 1:
        print(0)
        exit()
    else:
        print(1)
        exit()

B = [0]*(10**6+1)  # B[i] = iがAの元の倍数になっていたら1
C = [0]*(10**6+1)  # C[i] = iが条件を満たすとき1
for i in range(len(A)):
    if B[A[i]] == 0:
        C[A[i]] = 1
    for j in range(A[i],10**6+1,A[i]):
        B[j] = 1

from collections import Counter

c = Counter(A)

for i in c.keys():
    if c[i] >= 2:
        C[i] = 0

print(sum(C))

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

int main(){
   string a,b;
   cin >> a >> b;
   if(a.size() == b.size()){
      if(a>b){
         cout << "GREATER";
      }else if(a<b){
         cout << "LESS";
      }else{
         cout << "EQUAL";
      }
   }else{
      if(a.size()>b.size())
         cout << "GREATER";
      else
         cout << "LESS";            
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i += 2)
    {
        cout << s[i];
    }
    cout << "\n";
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 512