akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
 
int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  string s;cin>>s;
  ll k;cin>>k;
  ll n=s.size();
  vector<ll>v;
  ll cnt=1;
  rep(i,0,n){
    if(i!=n-1&&s[i]==s[i+1])cnt++;
    else{
      v.PB(cnt);
      cnt=1;
    }
  }
  if(v.size()==1){
    res=(v[0]*k)/2;
  }
  else if(s[0]==s[n-1]){
    rep(i,1,v.size()-1){
      res+=v[i]/2*k;
    }
    res+=v[0]/2;
    res+=v[(ll)v.size()-1]/2;
    res+=(v[0]+v[(ll)v.size()-1])/2*(k-1);
  }
  else{
    for(auto z:v){
      res+=z/2*k;
    }
  }
  cout<<res<<endl;
  return 0;
}

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

int main(){
  int n,q,y,t=0;
  string x;
  cin >> n >> q;
  queue<pair<string,int> > a;
  pair<string,int> b;
  for(int i=0;i<n;i++){
    cin >> b.first >> b.second;
    a.push(b);
  }
  while(! a.empty()){
    b=a.front();
    if(b.second<=q){
      t+=b.second;
      cout << b.first << ' ' << t  << endl;
      a.pop();
    }
    else{
      b.second=b.second-q;
      a.pop();
      a.push(b);
      t+=q;
}
  }
}
    
  


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

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

    int p;
    int f = 0,s = 0,t = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> p;
        if(p <= a)f++;
        else if(p > b)t++;
        else s++;
    }
    
    cout << min(f, min(s ,t)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int N,K;
string S;

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

    vector < int > zatsu;
    S.push_back('?');
    char c = S.front();
    int cntt = 1;
    for (int i = 1; i < S.size(); i++) {
        if (S[i] != c) {
            zatsu.push_back(cntt * (c == '0' ? -1 : 1));
            c = S[i];
            cntt = 1;
        } else {
            cntt++;
        }
    }

    int sum = 0;
    int ans = 0;
    int cnt = 0;
    int l = 0, r = 0;
    while (l < zatsu.size()) {
        while (r < zatsu.size() && cnt <= K) {
            if (zatsu[r] < 0) {
                if (cnt + 1 > K) break;
                sum -= zatsu[r];
                r++;
                cnt++;
            } else {
                sum += zatsu[r];
                r++;
            }
        }
        ans = max(ans, sum);
        if (zatsu[l] < 0) {
            sum += zatsu[l];
            l++;
            cnt--;
        } else {
            sum -= zatsu[l];
            l++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int mi = 1000, ma = 0;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		mi = min(mi, a);
		ma = max(ma, a);
	}
	cout << ma - mi << endl;

	return 0;
}


Measured memory_bytes: 256
k,n=(int(x) for x in input().split())
 
a=list(map(int,input().split()))
d0=0
dmax=0
for i in range(n):
    d=a[i]-d0
    d0=a[i]
    if d>=dmax:
        dmax=d
d1=k-a[n-1]+a[0]
if d1>=dmax:
    print(str(k-d1))
else:
    print(str(k-dmax))
 

Measured memory_bytes: 26436
from collections import deque

N=int(input())
E=[[] for _ in range(N+1)]
P=[]

for a in range(1,N+1):
    S=input()
    for b in range(1,N+1):
        if S[b-1]=="1":
            E[a].append(b)

            if a<b:
                P.append((a,b))

M=-1
for a in range(1,N+1):
    Q=deque([a])
    T=[0 for i in range(N+1)]
    T[a]=1
    while Q:
        v=Q.popleft()
        for w in E[v]:
            if T[w]==0:
                T[w]=T[v]+1
                Q.append(w)

    F=True
    for (u,v) in P:
        F&=(abs(T[u]-T[v])==1)

    if F:
        M=max(M,max(T))

print(M)


Measured memory_bytes: 75292
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


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

	vector<vector<char>> S(N, vector<char>(N));

	rep(i, N)rep(j, N) { cin >> S[i][j]; }

	ll ans = 0;

	rep(B, N) {
		ll bo = 1;
		rep(i, N)rep(j, N) {
			if (S[i][(j + B) % N] != S[j][(i+B)%N]) { bo = 0; }
		}
		if (bo == 1) { ans += N; }
	}

	cout << ans;

	system("PAUSE");
}


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

class Abc158a
{
    static string s;

    static void Solve()
    {
        Console.WriteLine(s.Distinct().Count() > 1 ? "Yes" : "No");
    }

    static void Scan()
    {
        s = Console.ReadLine();
    }

    static void Main()
    {
        Scan();
        Solve();
    }
}

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

int main(){
  string S;
  cin >> S;
  int n;
  n = S.size();
  if (S.at(n - 1) == 's') S = S + "es";
  else S = S + "s";
  cout << S << endl; 
  return 0;
}

Measured memory_bytes: 3596
using System;
using System.Linq;
 
namespace arc082_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = new int[100010];
            for (int i = 0; i < n; i++) a[x[i]]++;
            int max = a[0] + a[1] + a[2];
            int now = a[0] + a[1] + a[2];
            for (int i = 3; i < 100010; i++)
            {
                now -= a[i - 3]; now += a[i];
                max = Math.Max(max, now);
            }
            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 18528
fun main(args:Array<String>?): Unit {
    while(true){
        val (n, q) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && q == 0) return
        val years = Array(n){
            val (eraName, eraBaseYear, westernYear) = readLine()!!.trim().split(' ')
            EraYear(westernYear.toInt() - eraBaseYear.toInt() + 1, eraBaseYear.toInt(), eraName)
        }.sortedBy(EraYear::from).toTypedArray()
        repeat(q){
            val year = readLine()!!.trim().toInt()
            val era = upperBound(years, year){it.from} - 1
            if (era in years.indices && year in years[era].range) println("${years[era].name} ${years[era].asEraYear(year)}")
            else println("Unknown")
        }
    }
}
inline fun <F, T: Comparable<T>> upperBound(array: Array<F>, target: T, selector: (F) -> T): Int {
    var left = 0
    var right = array.size
    while(left < right){
        val mid = (left + right) / 2
        if (selector(array[mid]) <= target) left = mid + 1
        else right = mid
    }
    return right
}
data class EraYear(val from: Int, val length: Int, val name: String) {
    val to: Int
        get() = from + length - 1
    val range: IntRange = from until from + length
    fun asEraYear(year: Int): Int = year - from + 1
}


Measured memory_bytes: 71856
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = list(map(int,input().split()))
    #N = 2*10**5
    #A = [i for i in range(1,N+1)]
    
    from collections import deque
    que = deque()
    for i in range(N):
        if i%2==0:
            que.append(A[i])
        else:
            que.appendleft(A[i])
    #print(list(que))
    if N%2==0:
        print(*list(que))
    else:
        print(*((list(que))[::-1]))
    
main()

Measured memory_bytes: 93212
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll n;
  cin>>n;
  vector<P> p;
  if(n%2==0){
    for(ll i=1;i<n;i++){
      for(ll j=i+1;j<=n;j++){
        if(i+j!=n+1){
          p.push_back(P(i,j));
        }
      }
    }
  }else{
    for(ll i=1;i<n;i++){
      for(ll j=i+1;j<=n;j++){
        if(i+j!=n){
          p.push_back(P(i,j));
        }
      }
    }
  }
  cout<<p.size()<<endl;
  for(int i=0;i<p.size();i++){
    cout<<p[i].first<<" "<<p[i].second<<endl;
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;cin>>n>>m;
  if(abs(n-m)>1){
    cout<<0<<endl;
    return 0;
  }
  vector<int>fact(n+m+1);
  int mod=1e9+7;

  fact[0]=1;
  rep(i,n+m)fact[i+1]=(ll)fact[i]*(i+1)%mod;
  if(n==m){
    cout<<(ll)fact[n]*fact[m]*2%mod<<endl;
  }
  else{
    cout<<(ll)fact[n]*fact[m]%mod<<endl;
  }


  return 0;

}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#define REP(i,m,n) for(i=m;i<n;i++)
#define rep(i,n) REP(i,0,n)
int Dx[]={1,0,-1,0},Dy[]={0,1,0,-1};
int dfs(int,int);
int boad[110][110];
int w,h,xs,ys,xg,yg,n,c,d;

int main(void){
  int x,y,i,j,a,b;

  while(1){
   
    scanf("%d %d",&w,&h);
    if(w==0 && h==0)break;
    scanf("%d %d",&xs,&ys);
    scanf("%d %d",&xg,&yg);
    scanf("%d",&n);
    
    for(i=0;i<110;i++){
      for(j=0;j<110;j++){
	boad[i][j]=-1;
      }
    }
    int k;
    for(k=0;k<n;k++){
      scanf("%d %d %d %d",&c,&d,&x,&y);
      
      if(d){a=4;b=2;}
      else {a=2;b=4;}
	for(i=y;i<y+a;i++){
	  for(j=x;j<x+b;j++){
	    boad[i][j]=c;
	  }
	}
    }
    c=boad[ys][xs];

    if(c && dfs(xs,ys))printf("OK\n");
    else printf("NG\n");

  }
  return 0;
}
  
int dfs(int x,int y)
{
  int i;
  if(x<=0||x>w||y<=0||y>h||boad[y][x]!=c)return 0;
  if(x==xg&&y==yg)return 1;
  boad[y][x]=0;
  rep(i,4)if(dfs(x+Dx[i],y+Dy[i]))return 1;
  return 0;
}

Measured memory_bytes: 0
N = int(input())
ans = [0]*4
for i in range(N):
    S = input()
    if S == "AC":
        ans[0] += 1
    elif S == "WA":
        ans[1] += 1
    elif S == "TLE":
        ans[2] += 1
    else:
        ans[3] += 1
print("AC x ", end = "")
print(ans[0])
print("WA x ", end = "")
print(ans[1])
print("TLE x ", end = "")
print(ans[2])
print("RE x ", end = "")
print(ans[3])
    


Measured memory_bytes: 69988
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい

int A,B;


int main(){
	cin>>A>>B;
	cout<<(A+B)%24<<endl;

	
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, A, B): (i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = format!("{} {}", std::cmp::min(A, B), std::cmp::max(0, A + B - N));

    println!("{}", ans);
}


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

int main(){
  long N, P, p, ans;
  map<long, long> m;  
  
  cin >> N >> P;
  p = P;
  
  while (p % 2 == 0) {
    ++(m[2]);
    p /= 2;
  }
  long i;
  for (i = 3; i * i <= P; i += 2) {
    while (p % i == 0) {
      ++(m[i]);
      p /= i;
    }
  }
  if (p > 1) ++(m[p]);

  ans = 1;
  for (const auto s : m){
cerr << s.first << " " << s.second << endl;
    for(i = 0; i < s.second / N; ++i){
      ans *= s.first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <set>
#include <utility>
#define MAXN 200000

using namespace std;

int N;
long long E, T;
long long x[MAXN];
long long dp[MAXN];

set <pair <long long, int>> dpm1; // min dp[i] + x[i]
long long dpm2; // min dp[i] + x[i] + 2 * x[i - 1]

long long val1(int k) {
    return dp[k] + x[k];
}

long long val2(int k) {
    return dp[k] + x[k] + 2 * x[k - 1];
}

int main() {
    scanf("%d%lld%lld", &N, &E, &T);
    for (int i = 0; i < N; i++)
        scanf("%lld", &x[i]);

    dp[N - 1] = T;
    int k = N - 1;
    dpm1.insert({val1(k), k});
    dpm2 = T + 3 * E;
    for (int i = N - 2; i >= 0; i--) {
        dp[i] = x[N - 1] - x[i] + max(2 * (x[N - 1] - x[i]), T);
        /*
        for (int j = i; j + 1 < N; j++) {
            long long cost = (x[j + 1] - x[i]) + max(2 * (x[j] - x[i]), T);
            dp[i] = min(dp[i], dp[j + 1] + cost);
        }
        */
        // keep dpm1 for j <= k where 2 * (x[j] - x[i]) <= T
        // keep dpm2 for j >= k where 2 * (x[j] - x[i]) > T
        while (k > i && 2 * (x[k - 1] - x[i]) > T) {
            dpm1.erase({val1(k), k});
            dpm2 = min(dpm2, val2(k)); // k > 0
            k--;
        }
        if (dpm1.size() > 0)
            dp[i] = min(dp[i], dpm1.cbegin()->first + T - x[i]);
        dp[i] = min(dp[i], dpm2 - 3 * x[i]);
        dpm1.insert({val1(i), i});
    }

    long long res = dp[0] + x[0] + E - x[N - 1];
    printf("%lld\n", res);
}


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

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if(a+b < k)
        k = a+b;
    
    ll c = k - a;
    if(c > 0)
    {
        b -= (k-a);
        a = 0;
    }
    else
        a -= k;
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let x: usize = read();
    let mut ans = 0;

    for i in 0..a + 1 {
        for j in 0..b + 1 {
            for k in 0..c + 1 {
                if i * 500 + j * 100 + k * 50 == x {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define ylol1 y1
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=1e14;
const int32_t LOG=21;
const int MOD=MOD1;

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
         int a,b,c,k;
         cin>>a>>b>>c>>k;
         int ans=0;
         int rem=k;
         ans+=min(k,a);
         rem-=min(k,a);
         ans+=min(rem,b)*0;
         rem-=min(rem,b);
         ans+=min(rem,c)*-1;
         rem-=min(rem,c);
         cout<<ans<<endl;
      }
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(2e5)+10;
int n,a[30],b[30],x,y;
char s[maxn],t[maxn];
int main() {
	
	scanf("%s",s+1);
	scanf("%s",t+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++) {
		x=s[i]-'a'+1,y=t[i]-'a'+1;
		if (!a[x]) a[x]=y;
		else if (a[x]!=y) { printf("No\n"); return 0; }
		if (!b[y]) b[y]=x;
		else if (b[y]!=x) { printf("No\n"); return 0; }
	}
	printf("Yes\n");
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 4152
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() { // Yes No
    input! {
        r: usize, mut g: usize, mut b: usize,
        k: usize,
    }

    let mut count = 0;
    let mut g = g;
    while g <= r {
        g *= 2;
        count += 1;
    }
    while b <= g {
        b *= 2;
        count += 1;
    }
    if count > k {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 2200
#include <iostream>
#define rep(i,q) for(int i = 0; q > i; i++)
using namespace std; 
int K;
int guu,ke;
void input() { 
  cin >> K;
} 
void compute() { 
  guu = K / 2;
  ke = (K % 2 == 1 ? K / 2 + 1 : K / 2);
} 
void output() { 
  cout << guu * ke << endl;
  //6 135 246
  //5 123 24
} 
int main() { 
    input(); 
    compute(); 
    output(); 
    return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#define rep(i, a, n) for(int i = a;i < n;++i)
#define repe(i, a, n) for(int i = a;i <= n;++i)
#define repr(i, a, n) for(int i = a;i > n;--i)
#define reper(i, a, n) for(int i = a;i >= n;--i)
using namespace std;


int N;
int A[100010];
int sum;


int main(){
	cin >> N;
	repe(i, 1, N) cin >> A[i];

	repe(i, 0, N) sum += abs(A[i]-A[i+1]);

	repe(i, 1, N){
		cout << sum - (abs(A[i-1]-A[i])+abs(A[i]-A[i+1])) + abs(A[i-1]-A[i+1]) << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n, m;
    cin >> n >> m;

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

    int H = 1, L = 1;
    rep(i, n-1) L *= 10;
    H = L * 10;
    if (L == 1) L = 0;
    for (int i = L; i < H; i++){
        bool ok = true;

        string str = to_string(i);
        if (str.size() != n) {
            continue;
        } 

        rep(j, m){
            if (str[s[j] - 1] != '0' + c[j]) {
                ok =false;
                break;
            }
        }
        
        if (ok) {
            put(i);
            return 0;
        }
    }

    put(-1);
    
    return 0;
}

Measured memory_bytes: 3696
N, M = map(int, input().split())
from_1 = 0
to_N = 0
for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        from_1 |= 1 << b
    if b == N:
        to_N |= 1 << a
print("POSSIBLE" if from_1 & to_N else "IMPOSSIBLE")

Measured memory_bytes: 3188
package main

import (
   "fmt"
)

func solution(d, n int) int {
   out := 0
   switch d {
   case 0:
        if n == 100 {
                out = (n + 1)
                break
        }
        out = n
   case 1:
        if n == 100 {
                out = (n + 1) * 100
                break
        }
        out = n * 100
   case 2:
        if n == 100 {
                out = (n + 1) * 100 * 100
                break
        }
        out = n * 100 * 100
   }
   return out
}

func main() {
   var d, n int
   fmt.Scan(&d, &n)
   fmt.Println(solution(d, n))
}

Measured memory_bytes: 1772
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, M;
  cin >> N >> M;
  vector<vector<int>> Costs(N+1,vector<int>(3,-1));

  vector<vector<int>> G(N + 1);
  for (ll i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
  }

  int start, goal;
  cin >> start >> goal;

  queue<pair<int,int>> que;
  que.push({start, 0});  // スタートを push
  Costs[start][0] = 0;

  // 幅優先探索を実施する
  while (!que.empty()) {
    const int node = que.front().first;
    const int count = que.front().second;
    que.pop();

    // 隣接頂点を探索
    for (const auto& x : G[node]) {
      const int nextcount = (count + 1) % 3;
      if (Costs[x][nextcount] != -1) {
        continue;
      }
      Costs[x][nextcount] = Costs[node][count] + 1;
      que.push({x, nextcount});
    }
  }
  if (Costs[goal][0] != -1) {
    Costs[goal][0] /= 3;
  }

  cout << Costs[goal][0] << endl;

  return 0;
}


Measured memory_bytes: 11136
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

dp = [[0,0,0] for _ in range(n)]
dp[0] = l[0]

for i in range(1, n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j], dp[i-1][k] + l[i][j])

print(max(dp[-1]))

Measured memory_bytes: 47344
// Problem : B - Snuke's Coloring 2 (ABC Edit)
// Contest : AtCoder - AtCoder Beginner Contest 047
// URL : https://atcoder.jp/contests/abc047/tasks/abc047_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, w, h, mx1=0,mx2=0, my1=0, my2=0;
	cin >> w >> h >> n;
	vector<int> x(n);
	vector<int> y(n);
	vector<int> c(n);
	for(int i=0; i < n; i++){
	    cin >> x[i] >> y[i] >> c[i];
	    if(c[i]==1){
	        mx1 = max(mx1, x[i]);
	    }
	    if(c[i]==2){
	        mx2 = max(mx2, w-x[i]);
	    }
	    if(c[i]==3){
	        my1 = max(my1, y[i]);
	    }
	    if(c[i]==4){
	        my2 = max(my2, h-y[i]);
	    }
	}
	if(mx1+mx2>=w || my1+my2>=h){
	    cout << 0;
	}
	else{
	    cout << (h-my1-my2)*(w-mx1-mx2);
	}
	return 0;
}

Measured memory_bytes: 256
s=input()
if len(s)%2==0:
  for i in range(len(s)//2):
    if s[2*i]!='R' and s[2*i]!='U' and s[2*i]!='D' :
      print('No')
      exit()
    if s[2*i+1]!='L' and s[2*i+1]!='U' and s[2*i+1]!='D':
      print('No')
      exit()
if len(s)%2==1:
  for i in range(len(s)//2):
    if s[2*i+1]!='L' and s[2*i+1]!='U' and s[2*i+1]!='D':
      print('No')
      exit()
  for i in range(len(s)//2+1):
    if s[2*i]!='R' and s[2*i]!='U' and s[2*i]!='D' :
      print('No')
      exit()
print('Yes')


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int N,ans=0;
    string S;
    cin>>N>>S;
    for(int i=1;i<N;i++){
        if(S[i-1]!=S[i])ans++;
    }
    ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e17;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c;
    cin>>a>>b>>c;
    if (b-a==c-b)cout<<"YES"<<ENDL;
    else
        cout << "NO" << ENDL;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  string s;
  cin>>n>>m>>s;
  Int prv=n,lst=n;
  vector<Int> vs;
  for(Int i=n-1;i>=0;i--){
    if(s[i]=='1') continue;
    if(i+m<lst) vs.emplace_back(lst-prv),lst=prv;
    prv=i;
  }
  vs.emplace_back(lst-prv);
  if(*max_element(vs.begin(),vs.end())>m){
    cout<<-1<<endl;
    return 0;
  }
  reverse(vs.begin(),vs.end());
  for(Int v:vs) cout<<v<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    string s;   cin >> s;
    if (s == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3560
#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>
#include <random>
#include <cassert>
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 = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	for (auto& c : str)
	{
		if (c == '1') c = '9';
		else if (c == '9') c = '1';
	}
	cout << str << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
int main(){
    int x, n;
    cin >> x >> n;
    vector<int> a(n),b(101);
    for(auto& e : a) {
	cin >> e;
	b[e] = -1;
    }
    int p1 = x, p2 = x;
    for(p1 = x; p1 >=0; --p1) {
	if(b[p1]!=-1) break;
    }
    for(p2 = x; p2 <=100; p2++) {
	if(b[p2]!=-1) break;
    }
    if(x - p1 <= p2 - x) cout << p1 << endl;
    else cout << p2 << endl;
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 != 0 && b % 2 != 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
    ll N,r=0;
    string S;
    map<char,ll> m;
    vector<ll> c(5,0);
    cin >> N;

    rep(i,N) {
        cin >> S;
        if(!m.count(S.at(0)))
            m[S.at(0)] = 1;
        else
            ++m.at(S.at(0));
    }

    if(m.count('M'))
        c.at(0) = m.at('M');
    if(m.count('A'))
        c.at(1) = m.at('A');
    if(m.count('R'))
        c.at(2) = m.at('R');
    if(m.count('C'))
        c.at(3) = m.at('C');
    if(m.count('H'))
        c.at(4) = m.at('H');

    rep(i,1<<5) {
        ll tt=1;
        vector<ll> t;
        rep(j,5)
            if(i & 1<<j)
                t.push_back(c.at(j));
        if(t.size() != 3)
            continue;
        rep(j,t.size())
            tt *= t.at(j);
        r += tt;
    }

    cout << r << endl;
}

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

int main(){
    int n; //文字数
    cin >> n;
    string s; //R,G,Bからなる文字列
    cin >> s;

    long long r = 0; //rを数える
    long long g = 0; //gを数える
    long long b = 0; //bを数える

    /* r、g、bの個数を数える */
    for(int i=0; i<n; i++){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else if(s[i] == 'B') b++;
    }

    long long int ans = r*g*b;

    for(int i=0; 2*i<n; i++){
        for(int j=0; 2*i+j<n; j++){
            if(s[j] != s[j+i] && s[j] != s[2*i+j] && s[j+i] != s[2*i+j]){
                ans--;
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3608
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))
(let* (( line (read-line nil nil))
	   (splited (mapcar #'parse-integer (splitat #\space line))))
  (format t "~A~%" (if (< (car splited) (cadr splited)) 0 10)))

Measured memory_bytes: 12392
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
        
        












    return 0;
}

Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            佛祖保佑       永无BUG
*/
#include<stdio.h>
#include<algorithm>
#define re register
using namespace std;
int n,r[505],c[505];
char s[505][505];
bool vis[505];
int main()
{
	scanf("%d",&n);
	bool flag=0;
	for(re int i=1;i<=n;++i)
	{
		scanf("%s",s[i]+1);
		for(re int j=1;j<=n;++j)
			if(s[i][j]=='#') flag=1,vis[j]=1;
	}
	if(!flag) 
	{
		printf("-1");
		return 0;
	}
	int cnt=0;
	for(re int j=1;j<=n;++j)
	{
		int sumc=0;
		for(re int i=1;i<=n;++i)
			sumc+=(s[i][j]=='#');
		if(sumc==n) cnt++;
	}
	int ans=2*n;
	for(re int i=1;i<=n;++i)
	{
		int sumc=0;
		for(re int j=1;j<=n;++j)
			sumc+=(s[i][j]=='.');
		ans=min(ans,sumc+n-cnt+(vis[i]^1));
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

#define maxs(x,y) (x=std::max(x,y))
#define mins(x,y) (x=std::min(x,y))

int main() {
  ll N;
  cin >> N;
  vector<ll> H(N);
  rep(i, N) cin >> H[i];

  bool is_ok = true;
  ll tmp{LLINF};
  drep(i, N) {
    if (H[i] > tmp) {
      if (H[i]-1 > tmp) {
        is_ok = false;
        break;
      } else {
        tmp = H[i]-1;
      }
    } else {
      tmp = H[i];
    }
  }

  if (is_ok == true) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 1024
N,T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    dif = t[i+1]-t[i]
    if dif>=T:
        ans += T
    else:
        ans += dif
        
ans += T # last one
print(ans)

Measured memory_bytes: 25196
from collections import defaultdict

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    # 1 足したとき
    count = defaultdict(int)
    for aa in a:
        count[aa] += 1
        count[aa+1] += 1
        count[aa-1] += 1
    v = 0
    for k in count.keys():
        v = max(count[k], v)
    print(v)

if __name__ == '__main__':
    main()

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

 using R=double;

 // Combination Table
 ll C[51][51]; // C[n][k] -> nCk

 void comb_table(int N){
 for(int i=0;i<=N;++i){
 for(int j=0;j<=i;++j){
 if(j==0 or j==i){
 C[i][j]=1LL;
 }else{
 C[i][j]=(C[i-1][j-1]+C[i-1][j]);
 }
 }
 }
 }

 int main(void){
 int N,A,B;
 cin >> N >> A >> B;

 const int NMAX=50;
 ll v[NMAX];

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

 comb_table(N);
 sort(v,v+N);
 reverse(v,v+N);

 R max_average=0.0;
 for(int i=0;i<A;++i){
 max_average+=v[i];
 }
 max_average/=A;

 int a_th_val_num=0,a_th_val_pos=0;
 for(int i=0;i<N;++i){
 if(v[i]==v[A-1]){
 a_th_val_num++;
 if(i<A){
 a_th_val_pos++;
 }
 }
 }

 ll cnt=0LL;
 if(a_th_val_pos==A){
 for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
 cnt+=C[a_th_val_num][a_th_val_pos];
 }
 }else{
 cnt+=C[a_th_val_num][a_th_val_pos];
 }

 cout.precision(20);
 cout << fixed << max_average << endl;
 cout << cnt << endl;

 return 0;
 }

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 main(){
    int K,S;
    cin >> K >> S;
    
    int ans=0;
    for(int i=0; i<=K; i++){
        for(int j=0; j<=K; j++){
            if(i+j > S) break;
            
            if(S-(i+j)<=K){
                ans++;
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
//#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>
void __read(T &a) { cin >> a; }
template<typename T, typename ... Args>
void __read(T &a, Args &... args) {cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T>
void outv(const T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


struct node{
    node* c[26]{};
    int cntEnd = 0;

    node(){
        memset(c, 0, sizeof(c));
    }
};

int add(const string& s, node* root){
    VI cnt(26);
    for(int i = 0; i < s.length(); ++i){
        cnt[s[i] - 'a']++;
    }
    int res = 0;
    for(int i = 0; i < s.length(); ++i){
        for(int j = 0; j < 26; ++j){
            if (cnt[j] > 0 && root->c[j] != nullptr){
                res += root->c[j]->cntEnd;
            }
        }
        cnt[s[i] - 'a']--;
        if (root->c[s[i] - 'a'] == nullptr){
            root->c[s[i] - 'a'] = new node();
        }
        root = root->c[s[i] - 'a'];
    }
    root->cntEnd++;
    return res;
}

int32_t main() {
    make(int, n);
    vector<string> a(n);
    for(auto& s : a){
        cin >> s;
        reverse(ALL(s));
    }
    sort(ALL(a), [&](const string& a, const string& b){
        return a.length() < b.length();
    });
    node* root = new node();
    int ans = 0;
    for(auto& s : a){
        ans += add(s, root);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 223104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double n;
  cin >> n;
  vector<double> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end()); 
  double count = (a.at(0) + a.at(1)) / 2;
  if (n >= 2) {
  for (int i = 0; i < n; i++) {
    if (i > 1) {
    count = (count + a.at(i)) / 2;
    }
  }
  }
  cout << count << endl;
}

Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;
int main()
{
	int N;
	string s = "APPROVED";
	vector<int>vec;

	cin >> N;
	fore(i, 0, N) {
		int t;
		cin >> t;
		vec.push_back(t);
	}
	fore(i, 0, N) {
		if (vec[i] % 2 == 0) {
			if (vec[i] % 3 != 0 && vec[i] % 5 != 0) {
				s = "DENIED";
			}
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 256
s = input()
bw, wb = 0, 0 #bwbwbw... と wbwbwb...
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == '0':
      wb += 1
    else:
      bw += 1
  else:
    if s[i] == '0':
      bw += 1
    else:
      wb += 1
print(min(bw, wb))

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

using namespace std;

typedef long long int ll;

int main()
{
	ll n; 
	cin>>n;
	ll root = sqrt(n);
	ll dx = 0;
	while(true)
	{
		ll num = root+dx;
		if(n%num==0)
		{
			root = num;
			break;
		}
		num = root-dx;
		if(n%num == 0)
		{
			root = num;
			break;
		}
		dx+=1;
	}
	ll ans = root+(n/root);
	cout<<max(0LL,ans-2);
}


Measured memory_bytes: 256
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

int read() {
    int v=0;
    char c;
    for(c=getchar(); c<48; c=getchar());
    for(; c>47; c=getchar())v=(v<<3)+(v<<1)+(c^48);
    return v;
}

int a[3003][3003];

int main()
{   ios;
    int i,j,k,l,n;
    n=read();
    rep(i,1,n)
    {
        rep(j,1,n-1)
            a[i][j]=read();
    }
    k=0;j=0;
    int vis[3003]={0},p[3003];
    rep(i,0,3002)p[i]=1;
    while(k<((n*(n-1))>>1))
    {
        l=0;
        j++;
        rep(i,1,n)vis[i]=0;
        rep(i,1,n)
        {  
            int to=a[i][p[i]]; 
            //cout<<i<<" "<<to<<":"<<a[to][p[to]]<<en;
            if(p[i]==n || vis[i]==1 || vis[to]==1)continue;
            if(a[to][p[to]]==i)
            {   l++;
                vis[to]=1;
                vis[i]=1;
                p[to]++;
                p[i]++;
                k++;
            }
        }
        if(l==0)
        {
            cout<<-1;
            return 0;
        }
    }   
    cout<<j;
    return 0;
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d;
  cin >> d;
  string s;
  if (d==25) s="Christmas";
  else if (d==24) s="Christmas Eve";
  else if (d==23) s="Christmas Eve Eve";
  else if (d==22) s="Christmas Eve Eve Eve";
  cout <<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    k = I()
    a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(a[k-1])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38460