akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <cstdio>
using namespace std;
vector<int> a;
int N,S,W,Q,g,i;
int hard(){
	int answer = 0, base = 1, sum = 0;
	map<int,int> freq;
	freq[0] = 1;
	for(i=a.size()-1; i>=0; i--){
		sum = (a[i]*base + sum) % Q;
		base = (base*10) % Q;
		if(a[i])answer += freq[sum];
		freq[sum] ++;
	}
	return answer;
}
int easy(){
	int answer = 0, nonZero = 0;
	for(i=0; i<a.size(); i++){
		nonZero += (a[i]!=0 ? 1 : 0);
		answer += (a[i]%Q==0 ? nonZero : 0);
	}
	return answer;
}
main(){for(;scanf("%d%d%d%d",&N,&S,&W,&Q),Q;printf("%d\n",(Q==2||Q==5)?easy():hard()))for(g=S,i=0,a.clear();i<N;g=(g>>1)^((g&1)?W:0),i++)a.push_back((g/7)%10);}

Measured memory_bytes: 4024
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,K;


int main()
{
  cin>>N;
  int A, B, C, D;
  string S;
  cin >> A >> B >> C >> D >> S;

  A--;
  B--;
  C--;
  D--;
  bool r = false;
  REP(i, A, C)
  {
    if(!r&&S[i]=='#'){
      r = true;
    }else if(r&&S[i]=='#'){
      cout << "No" << endl;
      return 0;
    }else if(S[i]=='.'){
      r = false;
    }
  }
  r = false;
  REP(i, B, D)
  {
    if(!r&&S[i]=='#'){
      r = true;
    }else if(r&&S[i]=='#'){
      cout << "No" << endl;
      return 0;
    }else if(S[i]=='.'){
      r = false;
    }
  }

  if(C<D){
    cout << "Yes" << endl;
    return 0;
  }
  else
  {
    int count = 0;
    if(S[B-1]=='.'){
      count = 1;
    }
    REP(i, B, D+2)
    {
      if(S[i]=='#'){
        count = 0;
      }else{
        count++;
      }
      if(count>=3){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define TR(X) ({ if(1) cerr << "Trace: " << (#X) << " = " << (X) << endl; })

ll n,m;
ll dp[100005], res[100005];
vector<ll> adj[100005];

void dfs1(ll cur, ll par) {
	dp[cur] = 1;
	for(ll nxt: adj[cur]) if(nxt != par){
		dfs1(nxt, cur);
		(dp[cur] *= (dp[nxt] + 1)) %= m;
	}
}

void dfs2(ll cur, ll par, ll val) {
	ll k = (ll) adj[cur].size();
	vector<ll> vals(k), prfx(k, 1), sfx(k, 1);
	for(ll i = 0; i < k; i++) {
		if(adj[cur][i] != par) {
			vals[i] = dp[adj[cur][i]] + 1;
		} else {
			vals[i] = val + 1;
		}
	}
	res[cur] = 1;
	for(ll i = 0; i < k; i++) (res[cur] *= vals[i]) %= m;

	prfx[0] = vals[0];
	sfx[k - 1] = vals[k - 1];
	for(ll i = 1; i < k; i++) (prfx[i] = prfx[i - 1] * vals[i]) %= m;
	for(ll i = k - 2; i >= 0; i--) (sfx[i] = vals[i] * sfx[i + 1]) %= m;
	for(ll i = 0; i < k; i++) if(adj[cur][i] != par) {
		ll nxtval = 1;
		if(i > 0) (nxtval *= prfx[i - 1]) %= m;
		if(i < k - 1) (nxtval *= sfx[i + 1]) %= m;
		dfs2(adj[cur][i], cur, nxtval);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for(ll i = 0; i < n - 1; i++) {
		ll a,b; cin >> a >> b;
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	if(n == 1) return cout << "1\n", 0;
	dfs1(0, -1);
	dfs2(0, -1, 0);
	for(ll i = 0; i < n; i++) cout << res[i] << '\n';
}


Measured memory_bytes: 22016
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*f;
}
const int N=5e5+10;
int n,l,v[N],t[N];
struct node{
	int v;
	double t;
}q[N];
int L=1,R=0,sum=0;
double ans=0;
signed main(){
	n=read(),l=read();
	for(int i=1;i<=n;i++){
		t[i]=read();v[i]=read();
		while(sum+v[i]>l){
			int p=min(sum+v[i]-l,q[L].v);
			sum-=p;
			q[L].v-=p;
			ans-=p*q[L].t;
			if(q[L].v<=0)L++;
		}
		q[++R]=(node){v[i],t[i]};
		sum+=v[i];ans+=v[i]*t[i];
		while(L<R&&q[R].t<q[R-1].t){
			q[R-1].t=(q[R].t*q[R].v+q[R-1].t*q[R-1].v)/(q[R].v+q[R-1].v);
			q[R-1].v+=q[R].v;
			R--;
		}
		printf("%.7lf\n",ans/l);
	}
	return 0;
}

Measured memory_bytes: 24704
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>
#define ll long long
#define endl "\n"
using namespace std;

void solve()
{
    
    string  S;
    cin>>S;
    int count=0,result=0;
    for(int i=0;i<S.size();i++)
    {
       if(S[i]=='R')
       {
           count++;
           result = max(count,result);
       }
        
       else
           count=0;
    }
 
    cout<<result;
}
int main()
{
        solve();
}








Measured memory_bytes: 3132
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_H 55
#define MAX_W 55
 
int H,W,sx,sy,gx,gy;
bool visited[MAX_H][MAX_W];
char field[MAX_H][MAX_W];
set<char> st;
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};
 
void getPos(int x,int y,char ch){
    if(visited[y][x]) return;
    visited[y][x] = true;
    if(field[y][x] == ch){
	sx = min(sx,x); gx = max(gx,x);
	sy = min(sy,y); gy = max(gy,y);
    }
    for(int i = 0 ; i < 4 ; i++){
	int nx = x + dx[i];
	int ny = y + dy[i];
	if(0 <= nx && nx < W && 0 <= ny && ny < H){
	    getPos(nx,ny,ch);
	}
    }
}
 
bool remove(char ch){
    for(int i = sy ; i <= gy ; i++){
	for(int j = sx ; j <= gx ; j++){
	    if(field[i][j] != ch && field[i][j] != '*'){
		return false;
	    }
	}
    }
    return true;
}
 
void change(){
    for(int i = sy ; i <= gy ; i++){
	for(int j = sx ; j <= gx ; j++){
	    field[i][j] = '*';
	}
    }
}
 
bool check(){
    int N = st.size();
    while(N--){
	for(int i = 0 ; i < H ; i++){
	    for(int j = 0 ; j < W ; j++){
		if(field[i][j] == '.') continue;
		if(field[i][j] == '*') continue;
		memset(visited,false,sizeof(visited));
		sx = sy = 1e9; gx = gy = 0;
		getPos(j,i,field[i][j]);
		if(remove(field[i][j])){
		    change();
		    goto next;
		}
	    }
	}
	return false;
    next:;
    }
    return true;
}
 
int main(){
    int Tc;
    cin >> Tc;
    while(Tc--){
	cin >> H >> W;
	st.clear();
	for(int i = 0 ; i < H ; i++){
	    for(int j = 0 ; j < W ; j++){
		cin >> field[i][j];
		if(isupper(field[i][j])){
		    st.insert(field[i][j]);
		}
	    }
	}
	cout << (check() ? "SAFE" : "SUSPICIOUS") << endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vec T(N), A(N);
    readvec(T); readvec(A);

    int ans = 1, mod = 1000000007;

    if(N == 1){
        if(T[0] == A[0]){
            cout << 1;
        }else{
            cout << 0;
        }
        return 0;
    }

    if(A[0] > A[1] && T[0] != A[0]){
        ans = 0;
    }else if(T[0] > A[0]){
        ans = 0;
    }

    FOR(i, 1, N - 1){
        if(T[i - 1] < T[i] && A[i] == A[i + 1]){
            if(T[i] > A[i]) ans = 0;
        }else if(T[i - 1] == T[i] && A[i] > A[i + 1]){
            if(A[i] > T[i]) ans = 0;
        }else if(T[i - 1] < T[i] && A[i] > A[i + 1]){
            if(T[i] != A[i]) ans = 0;
        }else{
            ans *= min(T[i], A[i]);
            ans %= mod;
        }
            
    }

    if(T[N - 2] < T[N - 1] && A[N - 1] != T[N - 1]){
        ans = 0;
    }else if(A[N - 1] > T[N - 1]){
        ans = 0;
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

using namespace std;

const int Mod = 1000000007;

int n, k;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    long long Left = 0, Right = 0, Ans = 0;
    for (int i = 0; i <= n; i++)
    {
        Left = Left + i;
        Right = Right + n - i;
        if (i >= k - 1)
        {
            Ans = (Ans + (Right - Left + 1))%Mod;
        }
    }
    cout << Ans;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define N 1000005
#define ll long long 
using namespace std;
inline ll read(){
    ll ans=0;
    char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
    return ans;
}
ll n,s,ans,x[N],p[N];
int main(){
    n=read(),s=read();
    for(ll i=1;i<=n;++i)x[i]=read(),p[i]=read();
    ll l=1,r=n;
    while(l<=r){
        if(x[l]>=s){ans+=x[r]-s;break;}
        if(x[r]<=s){ans+=s-x[l];break;}
        ans+=x[r]-x[l];
        if(p[l]>=p[r])while(p[l]>=p[r]&&l<r)p[l]+=p[r--];
        else while(p[l]<p[r]&&l<r)p[r]+=p[l++];
    }
    printf("%lld",ans);
    return 0;
}

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

int main() {
  int n,d,x;cin>>n>>d>>x;
  vector<int>a(n);
  int cnt=0;
  rep(i,n){
    cin>>a[i];
    cnt+=(d-1)/a[i]+1;
  }
  cout<<cnt+x<<endl;
}

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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    cout<<"ABC"<<N<<endl;
}

Measured memory_bytes: 3576
num = []
while True:
    m,f,r = map(int, raw_input().split())

    ans = m + f
    if m == f == r == -1:
        break
    if (m == -1) or (f == -1):
        num.append("F")
    elif ans >= 80:
        num.append("A")
    elif (65 <= ans) and (ans < 80):
        num.append("B")
    elif (50 <= ans) and (ans < 65):
        num.append("C")
    elif (30 <= ans) and (ans < 50):
        if r >= 50:
            num.append("C")
        else:
            num.append("D")
    else:
        num.append("F")

for i in range(len(num)):
    print num[i]

Measured memory_bytes: 6416
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){ 
    int N;
    cin >>N;
    double A[N];
    double ans = 0;
    double sum = 0;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        sum += 1 / A[i];
    }
    ans = 1 / sum;
    cout << fixed << setprecision(10);
    cout << ans << endl;

}   

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
char s[3];
int a[4],sum,flag=0;
void dfs(int num){
    if(flag) return ;
    if(num==3){
        if(sum==7){
            flag=1;
            int i;
            for(i=0;i<4;i++){
                if(i<3) cout<<a[i]<<s[i];
                else cout<<a[i]<<"=7"<<endl;
            }
        }
        return ;
    }
    int i;
    for(i=0;i<2;i++){
        if(!i){
            sum+=a[num+1];
            s[num]='+';
            dfs(num+1);
            sum-=a[num+1];
        }
        else{
            sum-=a[num+1];
            s[num]='-';
            dfs(num+1);
            sum+=a[num+1];
        }
    }
}
int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        int i=3;
        while(i>=0){
            a[i--]=n%10;
            n/=10;
        }
        flag=0;
        sum=a[0];
        dfs(0);
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using Graph = vector<vector<int>>;

const ll DIV = 998244353;

ll power(int x, int y)
{
    ll ret = 1;
    for(int i = 0; i < y; i++)
    {
        ret = (ret * x) % DIV;
    }
    return ret;
}

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

    vi DepthList(N-1, 0);
    int max_depth = 0;
    rep(i, N)
    {
        int depth;
        cin >> depth;
        if((i == 0 && depth != 0) || (i != 0 && depth == 0))
        {
            cout << 0 << endl;
            return 0;
        }
        DepthList[depth] += 1;
        max_depth = max(max_depth, depth);
    }

    ll ans = 1;
    if(max_depth == 0)
        ans = 0;
    else if(max_depth > 1)
    {
        for (int i = 1; i < max_depth; i++)
        {
            if(DepthList[i] == 0)
            {
                ans = 0;
                break;
            }
            ll pattern = power(DepthList[i], DepthList[i+1]);
            ans = (ans * pattern) % DIV;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main() {
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);
  if(A == B)
    printf("%d\n", C);
  else if(A == C)
    printf("%d\n", B);
  else
    printf("%d\n", A);

  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{

    class Program
    {
        public static (long m, long s)[,] dp;
        public static long mod;


        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);

                var vals = Console.ReadLine().Split(' ')
                    .Select(x => long.Parse(x)).ToList();


                var N = vals[0];
                var X = vals[1];
                var M = vals[2];
                var checker =new int[M + 1];
                
                long ans = 0;

                long subans = 0;
                long A = X;
                long span=0;
                int si=0;
                long sa=0;
                bool flg=false;
                for (int i = 0; i<N ; i++)
                {
                    checker[A] = i+1;
                    subans += A;
                    A = (A * A) % M;
                    if (checker[A] != 0)
                    {
                        span = i - checker[A]+2;
                        si = i;
                        sa = A;
                        flg = true;
                        break;
                    }
                }
                if (flg)
                {
                    long[] As = new long[span+1];
                    As[0] = 0;
                    for (int i = 1; i < span+1; i++)
                    {
                        As[i] = As[i - 1] + sa ;
                        sa = sa * sa % M;
                    }
                    ans = subans + ((N - si - 1) / span) * As[span ] + As[(N - si - 1) % span];

                }
                else
                {
                    ans = subans;
                }
                

                Console.WriteLine(ans);

                Console.Out.Flush();
            }//cheked

        }
        
    }

}




Measured memory_bytes: 28716
from heapq import heappush, heappop

class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            self.parents[y] = x


V, E = map(int, input().split())
q = []
K = {}
ans = 0
S = UnionFind(V)

for _ in range(E):
    s, t, w = map(int, input().split())
    heappush(q, (w, s, t))
#print(q)
# クラスカル法
while len(q) > 0:
    w, s, t = heappop(q)
    if S.find(s) != S.find(t):
        ans += w
        S.union(s,t)
print(ans)


Measured memory_bytes: 23252
import math

A, B, H, M = map(int, input().split())

h = math.pi*2/(12*60)
m = math.pi*2/60

angle_M = M * m
angle_H = (H * 60 + M) * h

angle = math.fabs(angle_M - angle_H)

length = math.sqrt(A * A + B * B - 2 * A * B * math.cos(angle))

print(length)

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

# define fr(a,b) for(int i = a; i < b; i++)
# define rep(i,a,b) for(int i = a; i < b; i++)

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

void solve(){
    int n;
    cin>>n;
    cout << (n*(n+1))/2;
    line
  	return;

}

int main(){
	fast
	int t=1;
	//cin >> t;
	while(t--){
             solve();
    }

	R 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
  string s, t;
  cin >> s >> t;
  string rec = t.substr(0, sz(s));
  if (rec == s) puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
    int H[100], W[100];
    int count = 0, i, j, k;

    while (1)
    {
        scanf("%d %d", &H[count], &W[count]);
        if (H[count] == 0 && W[count] == 0)
        {
            break;
        }
        count++;
    }

    for (i = 0; i < count; i++)
    {
        for (j = 0; j < H[i]; j++)
        {
            for (k = 0; k < W[i]; k++)
            {
                if ((j + k) % 2 == 0) {
                    printf("#");
                }
                else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2100
//ABC145-D
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

template <int MOD = 1000000007>
struct Mint{
    int x;

    Mint() : x(0) {}
    Mint(int t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(int n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        int a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }

    Mint & operator *= (Mint a){
        x = int(1LL * x * a.x % MOD);
        return *this;
    }

    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        int t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

template <typename T>
struct Comb{
    vector<T> fac, fin;

    Comb(int sz) : fac(sz + 1), fin(sz + 1){
        fac[0] = fin[sz] = T(1);
        for(int i = 1; i <= sz; i++){
            fac[i] = fac[i - 1] * T(i);
        }
        fin[sz] /= fac[sz];
        for(int i = sz - 1; i >= 0; i--){
            fin[i] = fin[i + 1] * T(i + 1);
        }
    }

    inline T fact(int k) const { return fac[k]; }
    inline T finv(int k) const { return fin[k]; }

    T P(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k];
    }

    T C(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k] * fin[k];
    }

    T H(int n, int k) const {
        if(n < 0 || k < 0) return T(0);
        return k == 0 ? T(1) : C(n + k - 1, k);
    }
};

signed main(){
    ll x,y;
    cin >> x >> y;
    ll sum = x + y;
    if(sum % 3 == 0 && sum / 3 <= x && x <= sum / 3 * 2 && sum / 3 <= y && y <= sum / 3 * 2){
        ll mn = min(x, y);
        Comb<Mint<MOD>> C(1e6);
        cout << C.C(sum / 3, mn - sum / 3) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

int main(){
  char s;
  cin >> s;
  string v = "aiueo";
  bool b = false;
  for(int i=0;i<5;i++){
    if(v.at(i)==s){
      b = true;
      break;
    }
  }
  if(b){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (a < -1000 || b > 1001) {
			System.err.println("Err!");	
			return;
		}
		
		if (a < b) {
			System.out.println("a < b");	
		} else if (a > b) {
			System.out.println("a > b");			
		} else if (a == b) {
			System.out.println("a == b");
		}
	}
}


Measured memory_bytes: 26232
n,a,b,c,d=map(int,input().split())
s=input()

if c<d:
    if '##' in s[a-1:d-1]:
        print('No')
    else:
        print('Yes')
elif d<c:
    if '##' in s[a-1:c-1]:
        print('No')
    else:
        if '...' in s[b-2:d+1]:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 40816
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int m = sc.nextInt();
    int c = sc.nextInt();

    int[] b = new int[m];
    int[][] a = new int[n][m];

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

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

    int count = 0;
    for (int j = 0; j < n; j++) {
      int sum = c;
      for (int i = 0; i < m; i++) {
        sum += a[j][i] * b[i];
      }
      if (sum > 0) {
        count++;
      }
    }

    os.println(count);
  }
}

Measured memory_bytes: 22356
import bisect
def seive():
  l[0]=0
  l[1]=0
  for i in range(2,10**6+1):
    if l[i]==1:
      k.append(i)
      for j in range(i*i,10**6+1,i):
        l[j]=0
l=[1]*(10**6+1)
k=[]
seive()
#print(len(k))
n=int(input())
d=bisect.bisect_left(k,n)
print(k[d])



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

int dat[100005];
long long oper[100005];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &dat[i]);
	long long sum = 0;
	for (int i = 0; i < n; i++) sum += dat[i];
	if (sum % (n * 1ll * (n + 1) / 2))
	{
		printf("NO\n");
		return 0;
	}
	long long cnt = sum * 2 / n / (n + 1);
	oper[0] = cnt;

	for (int i = 1; i < n; i++)
	{
		int diff = dat[i] - dat[i - 1];
		if (cnt - diff < 0 || (cnt - diff) % n)
		{
			printf("NO\n");
			return 0;
		}
		oper[i] = (cnt - diff) / n;
		oper[0] -= oper[i];
	}

	if (oper[0] < 0)
	{
		printf("NO\n");
		return 0;
	}

	printf("YES\n");
}

Measured memory_bytes: 1408
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).expect("Fail");
    let vec: Vec<&str> = line.split_whitespace().collect();
    let a:i32 = vec[0].parse().unwrap();
    let b:i32 = vec[1].parse().unwrap();
    let ans = if a - 2 * b < 0 {
        0
    } else {
        a - 2 * b
    };
    print!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    ll N;
    cin >> N;
    ll ans = ((N-1)*N)/2;
    cout << ans << endl;
}


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

int main() {
    //入力
    string s;
    cin >> s;

    //処理
    int n = s.size();
    string sample01;
    if (n%2 == 0) {
        for (int i=0; i<n/2; i++) {
            sample01 += '0';
            sample01 += '1';
        }
    }
    else {
        for (int i=0; i<n/2; i++) {
            sample01 += '0';
            sample01 += '1';
        }
        sample01 += '0';
    }

    string sample10;
    if (n%2 == 0) {
        for (int i=0; i<n/2; i++) {
            sample10 += '1';
            sample10 += '0';
        }
    }
    else {
        for (int i=0; i<n/2; i++) {
            sample10 += '1';
            sample10 += '0';
        }
        sample10 += '1';
    }

    int count01 = 0;
    int count10 = 0;
    for (int i=0; i<n; i++) {
        if (s.at(i) != sample01.at(i)) count01++;
    }
    for (int i=0; i<n; i++) {
        if (s.at(i) != sample10.at(i)) count10++;
    }

    //出力
    cout << min(count01,count10) << endl;

}

Measured memory_bytes: 640
import sys, heapq

def solve():
    input = sys.stdin.readline
    N = int(input())
    Q = []
    heapq.heapify(Q)
    for i in range(N):
        a, b = map(int, input().split())
        heapq.heappush(Q, (b, a))
    time = 0

    for i in range(N):
        b, a= heapq.heappop(Q)
        if time + a > b:
            print("No")
            break
        else:
            time += a

    else: print("Yes")



    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 28764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node[] aN = new Node[n];
        Node nil = new Node(-1, null, null);
        
        for (int i = 0; i < n; i++) {
            aN[i] = new Node(i, nil, null);
        }
        
        for (int i = 0; i < n; i++) {
            int val = sc.nextInt();
            int dim = sc.nextInt();
            Node[] a = new Node[dim];
            for (int j = 0; j < dim; j++) {
                int val2 = sc.nextInt();
                aN[val2].parent = aN[val];
                a[j] = aN[val2];
            }
            aN[val].children = a;
        }
        
        for (int i = 0; i < n; i++) {
            String kind = aN[i].parent.val == -1 ? "root" : aN[i].children.length == 0 ? "leaf" : "internal node";
            String children = getStr(aN[i].children);
            
            System.out.print(
                    "node " + aN[i].val + ": parent = " + aN[i].parent.val + ", depth = " + aN[i].calcDepth() + 
                    ", " + kind + ", " + children);
            System.out.println();
        }
    }
    
    private static String getStr(Node[] a) {
        // TODO 自動生成されたメソッド・スタブ
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        
        for (int i = 0; i < a.length; i++) {
            if (i != 0) {
                sb.append(", ");
            }
            sb.append(a[i].val);
        }
        sb.append("]");
        return sb.toString();
    }

    public static class Node {
        int val;
        Node parent;
        Node[] children;
        public Node(int val, Node parent, Node[] children) {
            this.val = val;
            this.parent = parent;
            this.children = children;
        }
        
        public int calcDepth() { 
            int depth = 0;
            Node p = this.parent;
            while(p.val != -1) {
                depth++;
                p = p.parent;
            }
            return depth;
        }
    }
}



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

const int SIZE=1e6;
const int LOGN=22;
int main(){
    int N;
    cin>>N;
    vector<int> a(N),b(N);
    for(int i=0;i<N;i++){
        cin>>a[i]>>b[i];
    }
    vector<vector<int>> g(SIZE);
    for(int i=0;i<N;i++){
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    // cerr<<"#input finished"<<endl;
    vector<int> val(SIZE);
    auto isInLR=[&](int l,int r,int x){
        if(l<r){
            return l<=x && x<r;
        }
        else{
            return l<=x || x<r;
        }
    };

    vector<int> cnt(SIZE,0);
    for(auto to:g[0]) cnt[to]++;

    auto isValid=[&](int r){
        return cnt[(r+SIZE-1)%SIZE]==0;
    };

    // cerr<<"#precalucalating"<<endl;
    int r=1;
    for(int l=0;l<SIZE;l++){
        // calc val[l]
        while(isValid(r)){
            for(auto to:g[r]){
                // if(!isInLR(l,r,to)){ iranai
                cnt[to]++;
            }
            r++;
            r%=SIZE;
        }
        val[l]=(l<r ? r-1-l : r+SIZE-l-1);
        // pop l
        for(auto to:g[l]){
            cnt[to]--;
        }
    }

    
    // cerr<<"#doubling"<<endl;
    vector<vector<int>> dp(LOGN,vector<int>(SIZE));
    dp[0]=val;

    for(int i=0;i+1<LOGN;i++){
        for(int j=0;j<SIZE;j++){
            dp[i+1][j]=min(dp[i][(j+dp[i][j])%SIZE]+dp[i][j],SIZE*2);
        }
    }
    // cerr<<dp[1][dp[1][0]]<<endl;
    // cerr<<"#solving"<<endl;
    // cerr<<dp[19][0]<<endl;
    // cerr<<dp[0][666666]<<endl;
    // cerr<<dp[1][0]<<" "<<dp[0][0]<<" "<<dp[0][dp[0][0]]+dp[0][0]<<endl;
    // cerr<<dp[2][0]<<" "<<dp[1][0]<<" "<<dp[1][(dp[1][0])%SIZE]+dp[1][0]<<endl;
    int res=SIZE;
    for(int i=0;i<SIZE;i++){
        int tar=SIZE;
        int sc=0;
        int from=i;
        for(int j=LOGN-1;j>=0;j--){
            if(tar>dp[j][from]){
                sc+=(1<<j);
                tar-=dp[j][from];
                from=(from+dp[j][from])%SIZE;
            }
        }
        for(int j=0;j<LOGN;j++){
            if(dp[j][from]>=tar){
                sc+=(1<<j);
                break;
            }
        }
        res=min(res,sc);
    }

    cout<<(res/2+res%2)<<endl;
    return 0;
}


Measured memory_bytes: 135816
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;

#define rep(i, a, b) for(ll i = a; i < ll(b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    ll n;
     cin>>n;
    string str1,str2;
    cin>>str1>>str2;

    rep(i,0,str1.size()) cout<<str1[i]<<str2[i];
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		map<string,int> m;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			m[s]++;
		}
		int ma=0;
		for(auto i:m)
		ma=max(ma,i.second);
		vector<string> v;
		for(auto i:m)
		if(i.second==ma)
		cout<<i.first<<endl;
	}
	return 0;
}

Measured memory_bytes: 23808
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc80_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[][] f = new int [n][];
            int[][] p = new int [n][];

            for(int i=0; i<n; i++){
                int[] tmp = ReadLine().Split().Select(int.Parse).ToArray();
                f[i] = tmp;
            }
            for(int i=0; i<n; i++){
                int[] tmp = ReadLine().Split().Select(int.Parse).ToArray();
                p[i] = tmp;
            }

            int max = int.MinValue;
            for(int i=1; i<(1<<10); i++){
                int cc = 0;
                for(int j=0; j<n; j++){
                    int c=0;
                    for(int k=0; k<10; k++){
                        if( ((i>>k&1) == 1) && f[j][k] == 1){
                            c++;
                        }
                    }
                    cc += p[j][c];
                }
                max = Max(max, cc);
            }
            WriteLine(max);
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if(n<1200)
	{
		printf("ABC");
	}
	else if(n<2800)
	{
		printf("ARC");
	}
	else 
	{
		printf("AGC");
	}
	return 0;
}

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

typedef long long ll;

ll gcd(ll a, ll b) {
   if(a == 0 || b == 0)
       return max(a, b);
   return gcd(b, a%b);
}

int main() {
 ll A, B; cin >> A >> B;
 map<ll, int> mp;
 A = gcd(A, B);
 for(ll i=2ll; i*i<=A; ++i)
     if(A%i == 0) {
         ++mp[i];
         while(A%i == 0)
             A /= i;
     }
 if(A > 1)
     ++mp[A];
 cout << mp.size() + 1 << "\n";
 return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

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

  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  cin >> A;
  cout << (N-1+K-1-1)/(K-1) << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

	if(n % (2*d + 1) == 0) { 
		cout << n / (2*d + 1) << endl;
	}else{
		cout << n / (2*d + 1) + 1 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> v;
    v.push_back(1);
    int x = 6;
    while(x<=n){
        v.push_back(x);
        x *= 6;
    }
    x = 9;
    while(x<=n){
        v.push_back(x);
        x *= 9;
    }
    vector<int> dp(100005,INF);
    dp[0] = 0;
    sort(v.begin(), v.end(), greater<int>());
    for (auto e : v)
    {
        rep(i,n){
            if(dp[i] == INF) continue;
            if(i+e <= n){
                dp[i + e] = min(dp[i + e], dp[i] + 1);
            }
        }
    }
    cout << dp[n] << endl;
}

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


int main() {
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;

    vector<int> A(0);
    vector<int> B(0);

    int k = 0;
    int l = N-1;

    while(k < N-1 && 0 <= l){
        if(S.at(k) == S.at(k+1)) k++;
        else {
            A.push_back(k);
            k++;
        }

        if(S.at(l) == S.at(l-1)) l--;
        else{
            B.push_back(l);
            l--;
        }
    }
    int ind = 1;
    
    if (A.size() > 1 && B.size() > 1){
        int j = 1;
        while(A.at(j) < B.at(j)){
            ind++;
            j++;
        }
    }

    if(K >= ind){
        for (int i = 0; i < N; i++){
            S.at(i) = 'R';
        }
    }else if(K%2 == 0){
        for(int i = 0; i < A.at(K); i++){
            S.at(i) = S.at(0);
        }
        for(int i = N-1; i >= B.at(K); i--){
            S.at(i) = S.back();
        }
    }else{
        for(int i = 0; i < A.at(K); i++){
            S.at(i) = S.at(0);
        }
        for(int i = N-1; i >= B.at(K); i--){
            S.at(i) = S.back();
        }
        for(int i = A.at(K); i<B.at(K); i++){
            if(S.at(i) == 'R') S.at(i) = 'L';
            else S.at(i) = 'R';
        }

    }



    int Ans = 0;
    for(int i = 0; i < N - 1; i++){
        if(S.at(i) == S.at(i+1)) Ans ++;
    }

    cout << Ans << endl;
}


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

int main(){
 string n;

  int r,b,c;

  r=0;
  b=0;
  vector<int>a(5);
  for(int i=0;i<6;i++){
    cin>>r;
    a[r]++;
  }
    for(int i=1;i<5;i++){
b=max(b,a[i]);
  }
  if(b!=3){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using namespace std;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int main() {
    // input
    int a, b; cin >> a >> b;
    auto d = vectors(a, b, int());
    REP (x, a) REP (y, b) cin >> d[x][y];

    // solve
    constexpr int n = 300;
    constexpr int max_d = 100;
    constexpr int max_c = 100;
    // // prepare the structure
    vector<tuple<int, int, char> > char_edge;
    vector<int> xs(max_d + 1);
    vector<int> ys(max_d + 1);
    xs[0] = 0;
    ys[0] = n - 1;
    REP (i, max_d) {
        xs[i + 1] = xs[i] + 1;
        ys[i + 1] = ys[i] - 1;
        char_edge.emplace_back(xs[i], xs[i + 1], 'X');
        char_edge.emplace_back(ys[i + 1], ys[i], 'Y');
    }
    // // construct the required graph
    auto used = vectors(a, b, false);
    vector<tuple<int, int, int> > int_edge;
    REP (i, max_d + 1) REP (j, max_d + 1) if (i + j <= max_d) {
        int c = 0;
        REP (x, a) REP (y, b) {
            int f = i * (x + 1) + j * (y + 1);
            chmax(c, d[x][y] - f);
        }
        if (c > max_c) continue;
        int_edge.emplace_back(xs[i], ys[j], c);
        REP (x, a) REP (y, b) {
            int f = i * (x + 1) + j * (y + 1);
            assert (d[x][y] <= f + c);
            if (f + c == d[x][y]) {
                used[x][y] = true;
            }
        }
    }
    // // check the result
    bool possible = true;
    REP (x, a) REP (y, b) {
        if (not used[x][y]) {
            possible = false;
        }
    }

    // output
    cout << (possible ? "Possible" : "Impossible") << endl;
    if (possible) {
        int m = int_edge.size() + char_edge.size();
        cout << n << ' ' << m << endl;
        for (auto e : char_edge) {
            cout << get<0>(e) + 1 << ' ' << get<1>(e) + 1 << ' ' << get<2>(e) << endl;
        }
        for (auto e : int_edge) {
            cout << get<0>(e) + 1 << ' ' << get<1>(e) + 1 << ' ' << get<2>(e) << endl;
        }
        int s = xs[0];
        int t = ys[0];
        cout << s + 1 << ' ' << t + 1 << endl;
    }
    return 0;
}


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

int K;
int P[32]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
    cin >> K;
    int q = P[K-1];

    cout << q << endl;

}

Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
    int n;
    std::vector<int> a={0};
    std::cin>>n;
    int t;
    for(;std::cin>>t;){
        a.push_back(t);
    }
    
    std::vector<int> b(n+1,0);
    for(int i=a.size()-1;i>0;--i){
        int t = a[i];
        for(int k=i;k<b.size();k+=i){
            t^=b[k];
        }
        b[i]=t;
    }
    
    std::cout<<std::count(b.begin(),b.end(),1)<<"\n";
    for(int i=0;i<b.size();++i){
        if(b[i]==1)
            std::cout<<i<<"\n";
    }
}


Measured memory_bytes: 2548
import numpy as np
N,M,X = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]

ans = 10**15
flag = False
for i in range(2**N):
    r = np.array([0]*(M+1))

    for j in range(N):
        if (i>>j)&1:
            for k in range(M+1):
                r[k] += A[j][k]
    #print(r)
    if np.all(r[1:]>=X):
        if ans > r[0]:
            ans = r[0]
        flag = True
    else:
        flag = False
        
if flag:
    print(ans)
else:
    print("-1")

Measured memory_bytes: 27280
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,x;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> n >> m >> x;
    if (x<=n+m)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}


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

int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  if(a>b)
    printf("%d",a-1);
  else
    printf("%d",a);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); 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; }

vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll a, b, num;
    cin >> a >> b;
    num = gcd(a, b);
    auto add = prime_factorize(num);
    ll ans = 1;
    for (auto i: add){
        ans++;
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3604