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

int main()
{
    string s;
    cin>>s;
    int i=0,n=s.size();
    int an[n]={0};
    while(i<n)
    {
        int nr=0,nl=0,j,k;
        for(j=i; j<n; j++)
        {
            if(s[j]=='L')
            {
                nr=j-i;
                break;
            }
        }
        i=j; k=j;
        for(; j<n; j++)
        {
            if(s[j]=='R')
            {
                nl=j-i;
                break;
            }
        }
        if(j==n) nl=j-i;
        //cout<<nl<<" "<<nr<<endl;
        i=j;
        if((nl+nr)%2==0)
            an[k]=an[k-1]=(nl+nr)/2;
        else
        {
            int total = max(nr,nl)-1;
            if(total%2==0)
            {
                if(nl>nr)
                {
                    an[k-1]=(nl+nr)/2;
                    an[k]=(nl+nr)/2+1;
                }
                else
                {
                    an[k]=(nl+nr)/2;
                    an[k-1]=(nl+nr)/2+1;
                }
            }
            else
            {
                if(nl>nr)
                {
                    an[k]=(nl+nr)/2;
                    an[k-1]=(nl+nr)/2+1;
                }
                else
                {
                    an[k-1]=(nl+nr)/2;
                    an[k]=(nl+nr)/2+1;
                }
            }
        }
    }
    for(int i=0; i<n; i++)
        cout<<an[i]<<" ";
    cout<<endl;
  	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  int tx,ty;
  cin >> tx >> ty;
  int x=0;
  int pos = 0;
  while(s[pos] == 'F') {
    x++;
    pos++;
  }
  tx -= x;
  int v = 0;
  int tmp = 0;
  vvi arr(2);
  srep(k,pos,sz(s)) {
    if(s[k] == 'T') {
      if(tmp > 0) {
        arr[v].push_back(tmp);
        tmp = 0;
      }
      v = 1-v;
    } else {
      tmp++;
    }
  }
  if(tmp > 0) arr[v].push_back(tmp);
  
  vi dpx(16000,0);
  dpx[8000] = 1;
  rep(i,sz(arr[0])) {
    vi dp2(16000,0);
    int n = arr[0][i];
    rep(k,16000) {
      if(dpx[k]) {
        if(k-n>=0) dp2[k-n]++;
        if(k+n<16000) dp2[k+n]++;
      }
    }
    dpx = dp2;
  }
  vi dpy(16000,0);
  dpy[8000] = 1;
  rep(i,sz(arr[1])) {
    vi dp2(16000,0);
    int n = arr[1][i];
    rep(k,16000) {
      if(dpy[k]) {
        if(k-n>=0) dp2[k-n]++;
        if(k+n<16000) dp2[k+n]++;
      }
    }
    dpy = dp2;
  }
  if(dpx[8000+tx]&&dpy[8000+ty]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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


int main () {
   int x; std::cin >> x;

   if(x == 3 || x == 5 || x == 7) {
      std::cout << "YES" << std::endl;
   } else {
      std::cout << "NO" << std::endl;
   }
   
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var u, d string
	fmt.Scanf("%s\n%s", &u, &d)
	if u == Reverse(d) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func Reverse(s string) string {

	runes := []rune(s)

	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}

	return string(runes)
}


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

#define rep(i, N) for(int i = 0; i < (int)N; i++)
#define ll long long
const ll INF = 2LL<<60;

int main()
{
    vector<int> t(3, 0);
    rep(i, 3)   cin >> t[i];

    sort(t.begin(), t.end());

    cout << t[0] + t[1] << endl;
}

Measured memory_bytes: 256
def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return

def examB():
    N, K = LI()
    A = LI()
    maxA = max(A)

    def function(s):
        stack = deque()
        num = [0]*(maxA+1)
        for i in range(s,N):
            a = A[i]
            if num[a]==0:
                stack.append(a)
                num[a] += 1
            else:
                while(num[a]>0):
                    num[stack.pop()] -= 1

        return stack

    B = [-1 for _ in range(N)]
    que = {}
    for i in range(N):
        a = A[i]
        if a not in que:
            que[a] = i
        else:
            prev = que.pop(a)
            B[prev] = i - prev
            que[a] = i
    i = 0
    while(que):
        a = A[i]
        if a in que:
            prev = que.pop(a)
            B[prev] = N + i - prev
        i += 1
    #print(B)
    locat_doubling = [[-1]*N for _ in range(51)]

    for i in range(N):
        locat_doubling[0][i] = 0
        locat_doubling[1][i] = B[i] + 1

    for k in range(2,51):
        for i in range(N):
            locat_doubling[k][i] = locat_doubling[k-1][i] + locat_doubling[k-1][(i+locat_doubling[k-1][i])%N]
            if locat_doubling[k][i]>inf:
                locat_doubling[k][i] = inf
    #print(locat_doubling[:5])
    now = 0
    rest = K*N
    for i in range(51)[::-1]:
        if locat_doubling[i][now]<=rest:
            rest -= locat_doubling[i][now]
            now = (locat_doubling[i][now]+now)%N
    #print(rest,now)

    ans = function(now)
    print(" ".join(map(str,ans)))
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 209584
A, B = map(int,input().split())
S = input()

def check(string):
    if '-' in string:
        print('No')
        quit()

if A + B + 1 != len(S) or S[A] != '-':
    print("No")
    quit()

check(S[:A])
rev_S = S[::-1]
check(rev_S[:B])

print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll; 
vector<pll> ans;
ll n,k,mx=0;
int main()
{
    cin>>n>>k;
    for(ll i=1;i<=n-2;i++) mx+=i;
    if(k>mx)
    {
    	cout<<-1<<endl;
    	return 0;
	}
	for(ll i=2;i<=n;i++) ans.push_back(make_pair(1ll,i));
	int res=mx-k;
	for(ll i=2;i<=n-1;i++)
		for(ll j=i+1;j<=n;j++)
		{
			if(res==0)
			{
				int sz=ans.size();
				cout<<sz<<endl;
				for(int z=0;z<sz;z++)
				{
					cout<<ans[z].first<<" "<<ans[z].second<<endl;
				}
				return 0;
			}
			res--;
			ans.push_back(make_pair(i,j));
		}
	int sz=ans.size();
	cout<<sz<<endl;
	for(int z=0;z<sz;z++)
	{
		cout<<ans[z].first<<" "<<ans[z].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include <cstdio>

#define maxn 100010
struct Edge
{
	Edge *next;
	int to;
} *last[maxn], e[maxn << 1], *ecnt = e;
inline void link(int a, int b)
{
	*++ecnt = (Edge) {last[a], b}; last[a] = ecnt;
	*++ecnt = (Edge) {last[b], a}; last[b] = ecnt;
}
bool f[maxn], flag;
void dfs(int x, int fa)
{
	int cnt = 0;
	for (Edge *iter = last[x]; iter; iter = iter -> next)
		if (iter -> to != fa)
		{
			dfs(iter -> to, x);
			cnt += f[iter -> to];
		}
	if (cnt > 1) flag = 1;
	f[x] = !cnt;
}
int main()
{
	int n; scanf("%d", &n);
	for (int i = 1; i < n; ++i)
	{
		int a, b; scanf("%d%d", &a, &b);
		link(a, b);
	}
	dfs(1, 0);
	puts(flag || f[1] ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, a, b, s, mn=1e9;
int main() {
	cin >> n;
	while(n--) {
		scanf("%lld%lld", &a, &b);
		s += a;
		if(a>b) mn = min(mn, b);
	}
	cout << (mn<1e9 ? s-mn : 0);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();

		int n = s.length;
		int m = 2019;
		int[] p = new int[m];
		p[0] = 1;
		long ans = 0;
		int b = 1;
		int now = 0;
		for (int i = n - 1; i >= 0; i--) {
			int c = s[i] - '0';
			now += c * b;
			now %= m;
			ans += p[now];
			p[now]++;
			b *= 10;
			b %= m;
		}
		System.out.println(ans);
	}
}


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

int main(){
    int a,b;
    double m;
    int n;

    cin >> a >> b;
    m = (a + b)/2.0;

    n = m;
    if(m-n >= 0.5)
        n++;
    
    cout << n << endl;
}

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

#define FOR(i,N) for(int i=0;i<N;i++)

int main(){
    long long H,W,Q,K,N,x,max=0,sum=0;
    cin >> N;
    vector<long>A(N);
    vector<long>cnt(100000,0);
    FOR(i,N){
        cin >> A[i];
        cnt[A[i]-1]++;
        sum += A[i];
    }
    cin >> Q;
    vector<long>B(Q),C(Q);
    FOR(i,Q)cin >> B[i] >> C[i];

    FOR(i,Q){
        x = cnt[B[i]-1];
        if(x != 0){
            cnt[B[i]-1] = 0;
            cnt[C[i]-1] += x;
            sum +=  x*(C[i]-B[i]);
        }
        cout << sum << endl;
    }


}


Measured memory_bytes: 6424
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 120
typedef long long ll;

int main(){
  ll N,K,place1,temp;
  cin>>N>>K;
  for(ll i=0;i<N;i++){
    cin>>temp;
    if(temp==1) place1=i+1;
  }
  ll ans=(N-place1+K-2-K+1+(place1-1)%(K-1))/(K-1)+(place1-1)/(K-1)+1;
  cout<<ans<<endl;
}


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


int dp[101][4][2];


int main() {
  string s; cin >> s;
  int K; cin >> K;
  int n = s.size();

  dp[0][0][0] = 1;

  rep(i, n) {
    int ni = s[i] - '0'; // N の上から i 桁目の数
    rep(j, K+1) rep(k, 2) rep(x, 10) {
      int j2 = j, k2 = k; // 遷移前の状態をコピーする

      if (x != 0) ++j2;     // 次に使う数 x が非ゼロなら j2 を更新
      if (j2 > K) continue; // 非ゼロの数が K より大きいことが確定したら無視

      if (!k && (x > ni)) continue; // N より大きい数であることが確定したら無視
      if (x < ni) k2 = 1;           // N より小さい数であることが確定したら k2 を更新

      dp[i+1][j2][k2] += dp[i][j][k]; // 遷移式
    }
  }

  cout << (dp[n][K][0] + dp[n][K][1]) << '\n';
}


Measured memory_bytes: 3608
t = input()
ans = 0
t = list(t)
for i in range(len(t)):
    if t[i]=='P':
        if i+1 < len(t) and t[i+1]=='?':
            t[i+1] = 'D'
            # t = t[:i+1] + 'D' + t[i+2:]
            ans += 1
            # print('a')
        else:
            ans += 1
            # print('b')
        
    
    elif t[i]=='?':
        if i+1 < len(t) and i > 0 and t[i-1] == 'P' and (t[i+1]=='D' or t[i+1]=='?'):
            t[i] = 'D'
            ans += 1
            # print('f')
        elif i+1 < len(t)  and (t[i+1]=='D' or t[i+1]=='?'):
            t[i] = 'P'
            # t = t[:i] + 'P' + t[i+1:]
            ans += 1
            # print('c')
        else:
            t[i] = 'D'
            # t = t[:i] + 'D' + t[i+1:]
            ans += 1
            # print('d')

    elif t[i]=='D':
        ans += 1
        # print('e')
p = ''
for i in t:
    p += i
print(p)
# print(ans)

Measured memory_bytes: 10900
#include <iostream>
#include <string>
#include <algorithm>
#include<math.h>
#include<set>
using namespace std;

int main() {
	int W,H,N;
	int x[110], y[110], a[110];
	cin >> W>>H>>N;
	for (int i = 0; i < N; i++)cin >> x[i] >> y[i]>>a[i];
	bool z[110][110] = { 0 };
	for (int i = 0; i < N; i++) {
		int X = x[i];
		int Y = y[i];
		if (a[i] == 1) {
			for (int i = 0; i < X; i++) {
				for (int j = 0; j < H; j++)z[i][j] = 1;
			}
		}
		if (a[i] == 2) {
			for (int i = X; i < W; i++) {
				for (int j = 0; j < H; j++)z[i][j] = 1;
			}
		}
		if (a[i] == 3) {
			for (int i = 0; i < W; i++) {
				for (int j = 0; j < Y; j++)z[i][j] = 1;
			}
		}
		if (a[i] == 4) {
			for (int i = 0; i < W; i++) {
				for (int j = Y; j < H; j++)z[i][j] = 1;
			}
		}
	}
	int count = 0;
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			if (z[i][j] == 0)++count;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int R,G,B,n;cin >> R >> G >> B >> n;
  int res=0;
  rep(r,3001) rep(g,3001){
    if(n-r*R-g*G<0) break;
    if((n-r*R-g*G)%B==0) res++;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define N 100000
using namespace std;

int main(){
  int n, y;
  cin >> n >> y;
  rep(i, 0, n+1){
    rep(j, 0, n+1){
      int culc = 10000*i+5000*j+1000*(n-i-j);
      if(culc == y && n-i-j>=0){
        cout << i << " " << j << " " << n-i-j << endl;
        return 0;
      }else if(culc > y)  break;
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 200020
#define M 2019
using namespace std;

int a[N];
int f[N], c[M];

int main(void)
{
    int n;
    int t;
    long long o;

    c[0] = 1;
    for(n = t = 1, o = 0; scanf("%1d", &a[n]) != EOF; n ++)
    {
        t = t * 202 % M;
        f[n] = (f[n - 1] * 10 + a[n]) % M;
        o += c[f[n] * t % M];
        c[f[n] * t % M] ++;
    }
    printf("%lld\n", o);

    return 0;
}


Measured memory_bytes: 5112
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

const int INF = 1 << 29;
const int N_MAX = 100000;
const double EPS = 1e-4;

template<class T> inline string itos(T n) { stringstream ss; ss << n; return ss.str(); }
inline int stoi(string s) { int ret; stringstream ss(s); ss >> ret; return ret; }

double dp[N_MAX+2][31];
double ans[N_MAX+1];


int main()
{
	int n;

	dp[1][1] = 1.0;
	for(int i = 0; i <= N_MAX; i++)
	{
		double prob = 1.0;
		for(int j = 1; j < 30; j++)
		{
			prob /= 2.0;
			if(i+j+1 > N_MAX)
			{
				break;
			}

			if(dp[i+j][j] == 0)
			{
				continue;
			}

			dp[i+j+1][j+1] += dp[i+j][j] * prob;
			dp[i+j+2][1] += (1 - prob)*dp[i+j][j];
					
		}
	}
/*
	for(int i = 1; i <= 10; i++)
	{
		for(int j = 1; j < 10; j++)
		{
			printf("%.5lf ",dp[i][j]);
		}
		puts("");
	}
*/
	double sum = 0;

	for(int i = 0; i <= N_MAX; i++)
	{
		for(int j = 0; j < 30; j++)
		{
			sum += dp[i][j];
		}
		ans[i] = sum;
	}

	while(cin >> n, n)
	{
		printf("%f\n",ans[n]);
	}
}

Measured memory_bytes: 26184
#include <stdio.h>
#include <string.h>

int main(void) {
	int i, j, len;
	int f = 1;
	char c;
	char s[200001], t[200001];
	scanf("%s%s", s, t);
	len = strlen(s);;
	for (i = 0; i < len; i++) {
		if (s[i] != t[i]) {
			c = t[i];
			for (j = 0; j < len; j++) {
				if (t[j] == s[i] || t[j] == c) {
					if (j < i) f = 0;
					if (t[j] == c) t[j] = s[i];
					else if (t[j] == s[i]) t[j] = c;
				}
				if (f == 0) break;
			}
		}
		if (f == 0) break;
	}
	printf(f ? "Yes\n" : "No\n");

	return 0;
}

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

int main(){
  string s;
  std::cin >> s;
  string ans = "No";
  if(s.at(0) == s.at(1) && s.at(1) == s.at(2) && s.at(2) == s.at(3)){
    ans = "No";
  }
  else if(s.at(0) == s.at(1) && s.at(2) == s.at(3)){
    ans = "Yes";
  }
  else if(s.at(0) == s.at(2) && s.at(1) == s.at(3)){
    ans = "Yes";
  }
  else if(s.at(1) == s.at(2) && s.at(0) == s.at(3)){
    ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}



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

int main(void) {
  int L, N;
  cin >> L >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      B.at(i) = A.at(0) + L - A.at(N-1);
    } else {
      B.at(i) = A.at(i) - A.at(i - 1);
    }
  }
  sort(B.begin(), B.end());
  cout << L - B.at(N-1) << endl;
}

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

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

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

#define mst(x, a) memset(x, a, sizeof(x))
#define all(a) begin(a), end(a)
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;

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

ll N, M;
vector<ll> A;
vector<ll> sum;

ll ans;

// cnt(sum > s)
ll cntGreaterThan(int s) {
  ll cnt = 0;
  ans = 0;
  ll rb = N - 1;
  rep(i, 0, N) {
    rb = max(rb, i);
    while (rb >= i && A[i] + A[rb] > s) rb--;

    cnt += 2 * (N - 1 - rb);
    ans += 2 * (N - 1 - rb) * A[i] + 2 * (sum[N] - sum[rb + 1]);

    if (rb + 1 == i) {
      cnt--;
      ans -= A[i] + A[i];
    }
  }
  return cnt;
}

void solve() {
  sort(A.begin(), A.end());
  sum = vector<ll>(N + 1, 0);
  rep(i, 0, N) { sum[i + 1] = sum[i] + A[i]; }
  int lo = 0, hi = 2e5 + 10;
  while (lo + 1 < hi) {
    int mi = lo + (hi - lo) / 2;
    if (cntGreaterThan(mi) <= M) {
      hi = mi;
    } else {
      lo = mi;
    }
  }

  ans += (M - cntGreaterThan(hi)) * hi;
  cout << ans << endl;
}

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

  cin >> N >> M;
  A.resize(N);
  rep(i, 0, N) { cin >> A[i]; }

  solve();
}

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

int main(){
    string S, T;
    cin >> S;
    cin >> T;
    int sz = S.size();
    int tz = T.size();
    vector<vector<int>> dp(sz + 1, vector<int>(tz + 1, 0));
    rep(i, sz + 1){
        rep(j, tz + 1){
            if (i == 0 || j == 0){
                continue;
            }else{
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                if (S[i - 1] == T[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
            }
        }
    }
    string ans;
    int x = tz, y = sz;
    while(0 < x && 0 < y){
        if (dp[y][x] != dp[y][x - 1] && dp[y][x] != dp[y - 1][x]){
            ans += T[x - 1];
            x--;
            y--;
        }else{
            if (dp[y][x - 1] < dp[y - 1][x]) y--;
            else x--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

ll n, k, a[200005];

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < (n - k); i++) {
    if (a[i] < a[k + i]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll a,b;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>a>>b;
    if((a-b)%2==0){
        cout <<(a+b)/2<<"\n";
    }
    else cout << "IMPOSSIBLE"<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <iomanip>
#include <math.h>
#include <algorithm>
#define M_PI 3.14159265358979323846264338327950288
#define oo 1000000007
#define maxN 3007
using namespace std;

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

    bool ans = 0;
    int cur = 0;
    for (int i = 1; i <= n; ++i) {
        int x, y;
        cin >> x >> y;
        if (x != y) cur = 0;
        else ++cur;
        if (cur >= 3) ans = 1;
    }

    if (ans) puts("Yes");
    else puts("No");

    return 0;
}

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

int main() {
    
    ll n; cin >> n;
    ll sum = 0;
    ll tmp = n;
    while (tmp > 0) {
        sum += tmp % 10;
        tmp /= 10;
    }
    if(n % sum == 0)  cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int h,w;
char a[1001][1001];
int f[1001][1001];
int main()
{
  //  freopen("grid.inp","r",stdin);
   // freopen("grid.out","w",stdout);
    cin>>h>>w;
    int i,j;
    for(i=1;i<=h;i++)
        for(j=1;j<=w;j++)
          cin>>a[i][j];
//    for(int i = 1; i <= h; i++)
//    {
//        for(int j = 1; j <= w; j++) cout << a[i][j];
//        cout << endl;
//    }
    int x=1e9+7;
    for(i=0;i<=h;i++)
        for(j=0;j<=w;j++)
            f[i][j]=0;
    f[0][1]=1;
    for(i=1;i<=h;i++)
        for(j=1;j<=w;j++)
            if(a[i][j]=='.')
             f[i][j]=(f[i-1][j]%x+f[i][j-1]%x)%x;
    cout<<f[h][w]<<endl;
    return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<iomanip>

using namespace std;
using ll=long long;

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

void Main(){
  string s;
  cin>>s;
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
  if(a-b-c-d==7) cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a-b-c+d==7) cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a-b+c-d==7) cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a-b+c+d==7) cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a+b-c-d==7) cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a+b-c+d==7) cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a+b+c-d==7) cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a+b+c+d==7) cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
}

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			Point2 p[]=new Point2[4];
			for(int i=0;i<4;i++)
				p[i]=new Point2(in.nextDouble(), in.nextDouble());
			boolean judge=false;
			if((ccw(p[0],p[3],p[1])>0&&ccw(p[1],p[3],p[2])>0&&ccw(p[2],p[3],p[0])>0)
					||(ccw(p[0],p[3],p[1])<0&&ccw(p[1],p[3],p[2])<0&&ccw(p[2],p[3],p[0])<0))
				judge=true;
			System.out.println(judge ? "YES":"NO");
		}
	}
	//counterClockWise p1->p2->p3が時計周りなら正 反時計周りなら負を返す 
	static double ccw(Point2 p1,Point2 p2,Point2 p3)
	{
		return (p2.y-p1.y)*(p3.x-p1.x)-(p3.y-p1.y)*(p2.x-p1.x);
	}
}
class Point2
{
	double x;
	double y;
	Point2(double x,double y)
	{
		this.x=x;
		this.y=y;
	}
}

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


int main() {
    int N;
    int ans = 0;
    cin >> N;
    for (int i = 1; i <= N; i = i + 2) {
        
        int yakusu = 0;
        for(int j = 1; j<=i;j++){
            if (i%j == 0) yakusu++;
        }
        if (yakusu == 8) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <22/Jun/2019 06:07:06 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    arr = [0] * n
    ans = 'Yes'
    d = {}
    for i in range(n):
        arr[i] = get_array()
        if arr[i][0] > arr[i][1]:
            ans = 'No'
        if arr[i][1] not in d:
            d[arr[i][1]] = 0
        d[arr[i][1]] += arr[i][0]
    if ans == 'No':
        print(ans)
        return
    od = sorted(list(d.items()))
    d = []
    for i in od:
        d.append([i[0], i[1]])
    for i in range(1, len(d)):
        d[i][1] += d[i - 1][1]

    for i in d:
        if i[0] < i[1]:
            ans = 'No'
            break

    print(ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


def input(): return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


Measured memory_bytes: 129172
import sys

n,k = map(int,sys.stdin.readline().split())
T = [int(sys.stdin.readline()) for _ in range(n)]

def check(P):
    i = 0
    for j in range(k):
        s = 0
        while (s + T[i] <= P):
            s += T[i]
            i += 1
            if i == n:
                return n
    return i

left = 0
right = 100000 * 10000

while (right - left > 1):
    mid = (left + right)//2
    v = check(mid)
    if v >= n:
        right = mid
    else:
        left = mid

print(right)


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

using namespace std;

int a[200005], lis[200005];

vector<int> g[200005], v;

void dfs(int u, int parant = -87) {
	bool type = 0;
	int i, boook;
	if(v.empty() || v.back() < a[u]) {
		v.push_back(a[u]);
	}
	else {
		i = lower_bound(v.begin(), v.end(), a[u]) - v.begin();
		boook = v[i];
		v[i] = a[u];
		type = 1;
	}
	lis[u] = v.size();
	for(int child:g[u]) if(child != parant)
		dfs(child, u);
	if(type) {
		v[i] = boook;
	} else {
		v.pop_back();
	}
}

int main() {	
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for(int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1);
	for(int i = 1; i <= n; i++) {
		cout << lis[i] << endl;
	}

}

Measured memory_bytes: 30400
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())
arr = [[c11, c12, c13], [c21, c22, c23], [c31, c32, c33]]

row_dis = []
col_dis = []

for i in range(3):
    row_dis.append([arr[0][i]-arr[1][i], arr[0][i]-arr[2][i], arr[1][i]-arr[2][i]])
    col_dis.append([arr[i][0]-arr[i][1], arr[i][0]-arr[i][2], arr[i][1]-arr[i][2]])

if row_dis[0] == row_dis[1] == row_dis[2] and col_dis[0] == col_dis[1] == col_dis[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int what(char c) {
  if (c == 'r') return 0;
  if (c == 's') return 1;
  return 2;
}

int cost[3];

int beat(char a, char b) {
  if (a == 'r' && b == 's') return cost[0];
  if (a == 's' && b == 'p') return cost[1];
  if (a == 'p' && b == 'r') return cost[2];
  return 0;
}

int main() {
  int n, k;
  cin >> n >> k;
  cin >> cost[0] >> cost[1] >> cost[2];
  string a;
  cin >> a;
  int ans = 0;
  for (int i = 0; i < k; i++) {
    string here;
    for (int j = i; j < n; j += k) {
      here += a[j];
    }
    int dp[here.size() + 1][3] = {};
    dp[0][0] = beat('r', here[0]);
    dp[0][1] = beat('s', here[0]);
    dp[0][2] = beat('p', here[0]);
    for (int j = 1; j < here.size(); j++) {
      dp[j][0] = beat('r', here[j]) + max(dp[j - 1][1], dp[j - 1][2]);
      dp[j][1] = beat('s', here[j]) + max(dp[j - 1][0], dp[j - 1][2]);
      dp[j][2] = beat('p', here[j]) + max(dp[j - 1][0], dp[j - 1][1]);
    }
    int nn = here.size();
    ans += max({dp[nn - 1][0], dp[nn - 1][1], dp[nn - 1][2]});
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    int n;
    cin>>n;
    map<int,ll> mp;
    for(int i=2;i<=n;i++){
        int m=i;
        for(int j=2;j*j<=m;j++){
            while(m%j==0){
                mp[j]++;
                m/=j;
            }
        }
        if(m>1) mp[m]++;
    }
    ll ans=1;
    for(auto p:mp){
        ans*=p.second+1;
        ans%=MOD;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3552
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  int x, d, ans=0;
  rep(i,0,N-1) {
    cin >> x;
    d = min(x, K-x);
    ans += d*2;
  };

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    char s[3005],t[3005];
    cin>>s;
    cin>>t;
    int slen=strlen(s),i,j;
    int tlen=strlen(t);
    int dp[slen+1][tlen+1];
    for(i=0;i<=slen;i++)
    {
        for(j=0;j<=tlen;j++)
        {
            if(!i||!j)dp[i][j]=0;
            else if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int anslen=dp[slen][tlen];
    char ans[anslen+1];
    ans[anslen]=0;
    i=slen;j=tlen;
    while(anslen>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans[anslen-1]=s[i-1];
            i--;
            j--;
            anslen--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else j--;

    }
     cout<<ans;

}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007



using namespace std;

int main()
{

  int A,B;
  cin>>A>>B;
  if((A-B)==0)cout<<"Yes";
  else cout<<"No";

  return 0 ;
}


Measured memory_bytes: 256
//By TheOneYouWant

#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e;++i)
#define forsn(i,s,e) for(int i = s; i < e;++i)
#define rforn(i,s) for(int i = s; i >= 0;--i)
#define rforsn(i,s,e) for(int i = s; i >= e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime ((double)clock()/CLOCKS_PER_SEC)
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
    c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;

const int LIM=1e5+5, MOD=1e9+7;
const ld EPS = 1e-9;
// int t,n,m,k,x,y,w;
signed main(){
    fastio;
    
    int n,a,b,c,d;
    string s;
    cin>>n>>a>>b>>c>>d;
    cin>>s;

    if(d>c){
        bool p = 1;
        forsn(i,b-1,d){
            if(s[i] == '#'){
                if(i+1 != n && s[i+1] == '#') p = 0;
            }
        }
        forsn(i,a-1,c){
            if(s[i] == '#'){
                if(i+1 != n && s[i+1] == '#') p = 0;
            }
        }
        if(!p) cout<<"No"<<ln;
        else cout<<"Yes"<<ln;
    }
    else if(c>d){
        bool p1 = 1;
        forsn(i,b-1,d){
            if(s[i] == '#'){
                if(i+1 != n && s[i+1] == '#') p1 = 0;
            }
        }
        forsn(i,a-1,c){
            if(s[i] == '#'){
                if(i+1 != n && s[i+1] == '#') p1 = 0;
            }
        }
        bool p2 = 0;
        forsn(i,b-1,d){
            if(i >= 1 && s[i-1] == '.'){
                if(s[i] == '.'){
                    if(i+1 != n && s[i+1] == '.') p2 = 1;
                }
            }
        }
        if(p1 & p2) cout<<"Yes"<<ln;
        else cout<<"No"<<ln;
    }

    return 0;
}

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

int main() {
 	long long int n; 
	cin >> n ;
  
  char a[n];
  long long int sumr = 0;
  for(int i=0; i<n; i++) 
  {
    cin >> a[i];
    if(a[i] == 'R') 
    {sumr ++;}

  }	
  
  long long int mawasu = sumr;
  
    for(int i=0; i<mawasu; i++) 
    {    
    if(a[i] == 'R') 
    {sumr --;}
      
    }
  
    	cout << sumr << endl;
}

Measured memory_bytes: 3840
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let (w,h,x,y,r) = (v[0],v[1],v[2],v[3],v[4]);
    println!("{}",
        if 0 <= x-r && w >= x+r &&
           0 <= y-r && h >= y+r { "Yes" } else { "No" }
    );
}


Measured memory_bytes: 5028
N = int(input())
P = list(map(int,input().split()))
Q = list(range(1,N+1))
J = [x - y for (x, y) in zip(P, Q)]
R = [i for i in J if i != 0]
if len(R)<=2:
  print('YES')
else:
  print('NO')

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		if(i == n - 1) {
			if(a[i] == x) {
				cnt++;
			}
		}
		else {
			x -= a[i];
			if(x < 0) {
				break;
			}
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;	
}


Measured memory_bytes: 256
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy
import bisect
import heapq


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

#X = str(input()).split()
#a = [int(x) for x in input().split()]
#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#V, E, r = map(int, input().split())
#INF = V * 10001
k = int(input())
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]
ans = A[k-1]

print(ans)


Measured memory_bytes: 38636
#include <stdio.h>

int main(void)
{
    int n,m;
    scanf("%d %d",&n,&m);
    int a[m+1];
    for(int i=0;i<m;i++){
        scanf("%d",&a[i]);
    }

    for(int i=0;i<m;i++){
        n-=a[i];
    }
    if(n<0){
        printf("-1");
    }else{
        printf("%d",n);
    }

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> P;
#define rep(i,n) for(ll i=0;i<n;++i)
const ll INF=1e18+1;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(1000005);


//nPk
 mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n,k);
    res *= comb.fact[k];
    return res;
}


int main(){
  int X,Y;
  cin>>X>>Y;
  int x,y;
  x=2*Y-X;
  y=2*X-Y;
  if (x%3!=0 or y%3!=0){
    cout<<0;
    return 0;
  }
  int x1=x/3;
  int y1=y/3;
  int s=x1+y1;
  mint c=comb(s,x1);
  cout<<c;



  }


Measured memory_bytes: 15872
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
bool used[(1<<18)+1];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int m,k;
cin>>m>>k;
if(k>(1<<m)){
    cout<<-1<<endl;
    return 0;
}
if(k==0){
 for(int i=0;i<(1<<m);i++){
    cout<<i<<" "<<i<<" ";
}
cout<<endl;
}
else{
    int t=0;vector<int> ans;
    for(int i=0;i<(1<<m);i++){
        if(i==k)continue;
        t^=i;
        ans.push_back(i);
    }
    if(t!=k){
        cout<<-1<<endl;
        return 0;
    }
    cout<<k<<" ";
    for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";
    cout<<k<<" ";
    reverse(all(ans));
    for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";
    cout<<endl;
}
}

Measured memory_bytes: 2424
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer x;

  x=nil->next;
  while(x!=nil && x->key!=key){
    x=x->next;
  }
  return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  /* your code */
  NodePointer x;
  
  x=listSearch(key);
  if(x==nil) return;
 /*x->prev->next=x->next;
   x->next->prev=x->prev;*/
  deleteNode(x);
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  /*your code*/
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32932
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template <typename T> void _dbarr(T* a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
template <typename T> void _dbarr(vector<T> a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
#define dbarr(x, n) {cerr << #x << ": "; _dbarr((x),(n));}
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second

int main()
{
	cin.tie(0)->sync_with_stdio(0);
    string a,s;
    cin >> a >> s;

    int v = stoi(a);
    if(v >= 3200) cout << s << "\n";
    else cout << "red\n";
}


Measured memory_bytes: 3648
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>

using namespace std;

int a,b,x;
bool r=false;

int main(){
    scanf("%d %d %d",&a,&b,&x);
    r= a+b>=x and a<=x;
    cout<<(r ? "YES":"NO")<<endl;
    
}


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

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define allpt(v) (v).begin(), (v).end()
#define allpt_c(v) (v).cbegin(), (v).cend()
#define allpt_r(v) (v).rbegin(), (v).rend()


const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(vector<T> v)
{
    if (v.size() == 0)
        return;
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;
    return;
}

template <typename T>
void show2dvec(vector<vector<T>> v)
{
    int n = v.size();
    rep(i, n) show1dvec(v[i]);
}

int main()
{

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

    const ll nmax = 1e6 + 1;
    ll n, ans = 0;
    cin >> n;
    for (ll i = 1; i < min(n, nmax); i++)
    {
        if (n % i == 0)
        {

            if (n / i - 1 > i)
            {
                ans += n / i - 1;
            }
        }
    }
    cout << ans << rt;
    return 0;
}


Measured memory_bytes: 256