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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int n, x;
    cin >> n >> x;
    int d[n + 1], l[n];
    rep(i, n) cin >> l[i];

    d[0] = 0;
    int cnt = 1;
    for (int i = 1; i <= n; i++)
    {
        d[i] = d[i - 1] + l[i - 1];
        if (d[i] <= x)
            cnt++;
    }

    OP(cnt);
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD (LL)(1e9+7)

int N, K;
string S;
int main(){
	cin >> N >> K >> S;
	int ans = 0;
	for(int i=0; i<N-1; i++){
		if(S[i] == S[i+1]) ans++;
	}
	cout << min(N-1, ans+2*K) << endl;
}

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

int main() {
  string S,ans;
  
  cin >> S;
  if (S[0] == S[1] && S[1] == S[2]) {
    ans = "No";
  } else {
    ans = "Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//        VIVEK UPADHYAY
//        MANIT, BHOPAL(M.P)


//                         JAB-TAK TODEGA NHI,
//                         TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5 + 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18+ 10 ;
int main() {
    
    int N ;
    cin >> N ;
    int M ;
    cin >> M ;
    ll a[N+1] ;
    for(int i=1;i<=N;i++) cin >>a[i] ;
    
    ll pre[N+1] ;
    pre[0] =0 ;
    for(int i=1;i<=N;i++) pre[i] = pre[i-1] + a[i] ;
    map<ll,ll> mp ;
    mp[0] = 1;
    ll cnt =0 ;
    for(int i=1;i<=N;i++) {
        ll rem = pre[i]%M ;
        cnt+=mp[rem] ;
        mp[pre[i]%M]++ ;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 5760
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
 var road_1 = lines[0].split(' ');
 var road_2 = lines[1].split(' ');
 var road_3 = lines[2].split(' ');
var arr = new Array(6);
arr [0] = parseInt(road_1[0]);
arr [1] = parseInt(road_1[1]);
arr [2] = parseInt(road_2[0]);
arr [3] = parseInt(road_2[1]);
arr [4] = parseInt(road_3[0]);
arr [5] = parseInt(road_3[1]);
var cnt = new Array(4).fill(0);
// console.log(arr);
 for (var i = 0 ; i < 6 ; i++) {
var num = arr[i] - 1;
cnt[num] += 1 ;
}
// console.log(cnt);
if (cnt[0] > 2 || cnt[1] > 2 || cnt[2] > 2 || cnt[3] > 2) {
console.log("NO")
} else {
console.log("YES")
}

});

Measured memory_bytes: 11596
#include <stdio.h>
#define MAX 500005
 
int T[MAX]; 
int hs;

void maxHeapify(int);
void buildMaxHeap();
int left(int);
int right(int);
 
int main()
{
  int i;
  
  scanf("%d", &hs); 
  for(i=1; i<=hs; i++){
    scanf("%d", &T[i]);
  }
  
  buildMaxHeap();
 
  for(i=1; i<=hs; i++){   
    printf(" %d", T[i]);
  }
 
  printf("\n");
 
  return 0;
}


void buildMaxHeap()
{
  int i;

  for(i= hs/2; i>=1; i--){
    maxHeapify(i);
  }
}


void maxHeapify(int i)
{
  int largest=0, temp, l, r;

  l = left(i);
  r = right(i);
  
  if((hs >= l) && (T[l] > T[i])){
	largest = l;
  }
  else{
	largest = i;
  }
   
  if((hs >= r) && (T[r] > T[largest])){
	largest = r;
  }

  if (largest != i){
    temp = T[i];
    T[i] = T[largest];
    T[largest] = temp;
    maxHeapify(largest);
  } 

}

 
int left(int i)
{
  return (2*i);
}
 
int right(int i)
{
  return (2*i + 1);
}

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

int main(void)
{
	long n = 0, h = 0, w = 0, a = 0, b = 0,ans = 0;
	scanf("%ld%ld%ld", &n, &h, &w);

	for (int i = 0; i < n; i++)
	{
		scanf("%ld%ld", &a, &b);
		if (h <= a)
		{
			if (w <= b)
			{
				ans += 1;
			}
		}
	}

	printf("%ld",ans);

	return 0;

}

Measured memory_bytes: 128
import sys
data = []
for line in sys.stdin:
	data.append(line.split())

quontum = int(data[0][1])
targetData = data[1:]
answerData = []
totalQuontum = 0

while targetData :
	target = targetData.pop(0)

	target[1] =  int(target[1]) - quontum

	if target[1]<= 0:
		totalQuontum += quontum + int(target[1])
		target[1] = totalQuontum
		answerData.append(target)
	else :
		targetData.append(target)
		totalQuontum += quontum

for answer in answerData:
	print(str(answer[0]) + ' ' + str(answer[1]))


Measured memory_bytes: 18820
#include<bits/stdc++.h>
#define rap(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
  string s;
  int n,r=0,b=0;
  cin>>n>>s;
  for(int i=0;i<n;i++){
	 if(s[i]=='R'){
		r++;
     }else if(s[i]=='B'){
       b++;
     }
  }
  if(r>b){
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
return(0);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

int N;
unsigned long long A[100001];
unsigned long long B[100001];

long long diff[100001];

int main(int argc, char const *argv[]) {
	int i, j;
	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%llu", &A[i]);
	}

	for (i = 0; i < N; i++) {
		scanf("%llu", &B[i]);

		diff[i] = A[i] - B[i];
	}

	// for (i = 0; i < N; i++) {
	// 	printf("%lld ", diff[i]);
	// }
	// printf("\n");

	std::sort(diff, diff+N);

	// for (i = 0; i < N; i++) {
	// 	printf("%lld ", diff[i]);
	// }
	// printf("\n");

	if (0 <= diff[0]) {
		printf("0\n");
		return 0;
	}

	for (i = 0, j = N-1; i < j && diff[i] < 0;) {
		if (-diff[i] < diff[j]) {
			diff[j] += diff[i];
			i++;
		} else {
			diff[i] += diff[j];
			diff[j] = 0;
			j--;

			if (diff[j] <= 0) {
				printf("-1\n");
				return 0;
			}
		}
	}

	printf("%d\n", i+(N-j));
	// printf("%d %d %d %d\n", N, i, j, i+(N-j));

	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=200000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,m,k;
vi blo[N];

int main()
{
    n=read();m=read();k=read();
    rep(i,1,k)
    {
        int x=read(),y=read();
        blo[x].pb(y);
    }
    int ans=maxd;
    rep(i,1,n) sort(blo[i].begin(),blo[i].end());
    int r=1;
    rep(i,2,n)
    {
        int siz=blo[i].size();
        if (!siz) {r++;continue;}
        if (blo[i][0]<r+1) {printf("%d",i-1);return 0;}
        if (blo[i][0]>r+1) r++;
    }
    printf("%d",n);
    return 0;
}
        

Measured memory_bytes: 14480
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int, int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;

int n, x, a[100010];
int ans = 0;
signed main()
{
  cin >> n >> x;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  for(int i = 1; i < n; i++){
    if(a[i - 1] + a[i] > x){
      ans += a[i - 1] + a[i] - x;
      if(a[i] >= a[i - 1] + a[i] - x){
	a[i] -= a[i - 1] + a[i] - x;
      }
      else{
	a[i - 1] -= a[i - 1] + a[i] - x - a[i];
	a[i] = 0;
      }
    }
  }

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


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
 
using namespace std;
int main(void) {
    string in;
    char S[3] = {};
    for (auto &s : S) {
        cin >> in;
        s = in[0];
    }
 
    for (auto s : S) {
 
    cout << static_cast<const char>(s -32 );
    }
 
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// dile a la jardinera que traigo flores
// corner cases // int vs ll // cin vs scanf
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){

	ll n,h,w;
	cin >> n >> h >> w;

	h = max(0LL,n-h+1);
	w = max(0LL,n-w+1);
	cout << h*w << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstring>
#include<iostream>
using namespace std;
#define N 200005
inline int rd()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f*x;
}
int n,k;
double p[N],ans,res;
int main()
{
    n=rd(),k=rd();
    for(int i=1;i<=n;i++)
    {
    	int x=rd();
    	p[i]=(double)1.0*(1+x)*x/2/x;
    	//printf("%.6f\n",p[i]);
    	if(i>k) res-=p[i-k];
    	res+=p[i];
    	ans=max(ans,res);
	}
	printf("%.6f\n",ans);
    return 0;
}

Measured memory_bytes: 1792
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector.Unboxed           as VU
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

getVUIntFromInputLineAtBSC8 :: IO (VU.Vector Int)
getVUIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
getVUListIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine

readInt = fst . fromJust . BSC8.readInt
readIntTuple = tuplify2 . map readInt . BSC8.words
readIntList = map readInt . BSC8.words

getInt = readInt <$> BSC8.getLine
getIntList = readIntList <$> BSC8.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BSC8.getLine
getIntMatrix = map readIntList . BSC8.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BSC8.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BSC8.getLine
getIntTuples = map readIntTuple . BSC8.lines <$> BSC8.getContents

main :: IO [()]
main = do

    aN <- getInt
    aA <- getIntList

    let aAP    = map (\x -> (x - 1, 1)) aA

    let cntAP  =  VU.accum (+) (VU.replicate aN 0) aAP
    let combiCntAp = VU.map (con2) cntAP
    let combiDiff = VU.map (\x->con2 x - (con2 (x-1))) cntAP
    let sum = VU.sum combiCntAp

    let cntSum = map (\x -> sum - (combiDiff VU.! (x-1) )) aA
    mapM (putStrLn . show) cntSum

con2 :: Int -> Int
con2 0 = 0
con2 1 = 0
con2 x = div (x * (x - 1)) 2



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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A=MI()
    x=LI()
    M=max(x)
    
    #dp[i][j][k]はi番目まで，j枚で，和がkにできるか
    dp=[[[0]*(N*M+1) for j in range(N+1)] for _ in range(N+1)]
    dp[0][0][0]=1
    
    for i in range(N):
        for j in range(i+1):
            for k in range(N*M+1-x[i]):
                if dp[i][j][k]:
                    dp[i+1][j][k]+=dp[i][j][k]
                    dp[i+1][j+1][k+x[i]]+=dp[i][j][k]
                    

        
    ans=0
    for j in range(1,N+1):
        if j*A<=N*M:     
            ans+=dp[-1][j][j*A]
        
    print(ans)
 

                
    
        
            
            
    
            
        
        
            

main()


Measured memory_bytes: 91484
#include<cstdio>
#include<cstring>
inline int in();
inline void wr(int);
const int N=(int)1e2+5;
char s[N];
inline bool reverse(int,int);
int main(int argc,char**argv){
	scanf("%s",s+1);
	register int n=strlen(s+1);
	if(reverse(1,n)&&reverse(1,(n-1)/2)&&reverse((n+3)/2,n))
		puts("Yes");
	else
		puts("No");
}
inline bool reverse(int l,int r){
	for(;l<=r;++l,--r)
		if(s[l]!=s[r])return 0;
	return 1;
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(int x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}


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

typedef long long ll;


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

template<class T> struct BIT{
    vector<T> bit;
    int M;

    BIT(int M_):
        M(M_+1), bit(M,0) {}

    T sum(int a){//sum [1,i) 1_indexed!!!!
        int ret = 0;
        for(int i=a; i>0; i-= i & -i) ret += bit[i];
        return ret;
    }
    
    T sum(int a, int b){//sum [i,j)  1_indexed!!!!
        return sum(b-1) - sum(a-1);
    }

    void add(int a, T x){
        for(int i=a; i<M; i+= i & -i) bit[i] += x;
    }

    void print(){
        FOR(i,1,M){
            cout << sum(i,i+1) << " ";
        }
        cout << endl;
    }

};

ll inversion(vector<int> d){
    
    BIT<ll> bit(d.size() *2);
    ll ans = 0;
    REP(i,d.size()){
        ans += i - bit.sum(d[i] + d.size());
        bit.add(d[i]+d.size(), 1);
    }
    //bit.print();
    
    return ans;
}

ll count(vector<int> a, int m){
    vector<int> b(a.size());
    vector<int> c(a.size()+1,0);
    vector<int> d(a.size()+1,0);

    REP(i,a.size()){
        if(a[i]<=m) b[i] = 1;
        else b[i] = 0;

        c[i+1] = c[i] + b[i];
        d[i+1] = 2*c[i+1] - (i+1);
    }

    reverse(ALL(d));
    return inversion(d);
}

int main() {
    int N; cin >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];

    int ng = -1;
    int ok = INF;
    while(abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        ll inv = count(a,mid);
        if(inv > (ll)N*(N+1)/4 ){//ここに条件をかく
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;

    return 0;
}

Measured memory_bytes: 8812
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;
import java.util.PriorityQueue;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        ArrayList<ArrayList<Integer>> baito = new ArrayList<ArrayList<Integer>>(m) {{
            for (int i = 0; i < m; i++) {
                add(new ArrayList<Integer>() {
                });
            }
        }};

        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (--a < m) baito.get(a).add(b);
        }

        int tot = 0;
        PriorityQueue<Integer> pq = new PriorityQueue<>(new MyComparator());
        for (int i = 0; i < m; i++) {
            pq.addAll(baito.get(i));

            if (!pq.isEmpty()) tot += pq.poll();
        }
        System.out.println(tot);
    }

    static class MyComparator implements Comparator<Integer> {
        @Override
        public int compare(Integer i, Integer j) {
            return j - i;
        }
    }
}

Measured memory_bytes: 99720
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 5000005;
const lo mod = 1000000007;

lo n,m,b[li],a[li],k,flag,t,topl,sum,yes,mxx,mx;
lo cev;
string s;
vector<lo> v;
vector<lo> vv;

inline void bolenbul(lo n){
	for(lo i=1;i*i<=n;i++){
		if(n%i==0){
			v.pb(i),v.pb(n/i);
		}
	}
}

int main(void){
	scanf("%lld %lld",&n,&k);
	FOR{
		scanf("%lld",&a[i]);
		mx=max(mx,a[i]);
		topl+=a[i];
	}
	bolenbul(topl);
	for(lo i=0;i<(lo)v.size();i++){
		sum=0;
		yes=0;
		//~ if(mx<v[i])continue;
		vv.clear();
		for(int j=1;j<=n;j++){
			vv.pb(a[j]%v[i]);
			sum+=a[j]%v[i];
		}
		lo x=sum/v[i];
		sort(vv.begin(),vv.end());
		for(lo j=0;j<n-x;j++){
			yes+=vv[j];
		}
		if(yes<=k)mxx=max(mxx,v[i]);
	}
	printf("%lld\n",mxx);
	return 0;
}


Measured memory_bytes: 256
N,M = map(int, input().split())
A = [set(list(map(int,input().split()))[1:]) for i in range(N)]

res = 0
for i in range(1,M+1):
    flag = 1
    for a in A:
        if i not in a:
            flag = 0
            break
    res += flag

print(res)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    string s;
    cin >> s;
    int len = (int)s.length();
    for (int i = 0; i < len - 8; i++) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
			int N =sc.nextInt();		
			int ansi=1;
			int ans=0;
			int tmp=0;
			int X=0;
						
			for(int i=1;i<N+1;i++){
				tmp=0;
				 X=i;
				for(;X%2==0;){
					tmp++;		
					X=X/2;
				}
				if(tmp>ans){
					ans=tmp;
					ansi=i;
				}
			}
			System.out.println(ansi);
		}
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

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

    int red_count = 0;
    for (int i = 0; i < N; i++) {
        char s;
        cin >> s;
        if (s == 'R') {
            red_count++;
        }
    }

    if (red_count > (N - red_count)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

int main() {
  string N;
  cin >> N;
  
  if (N[0] == '7' || N[1] == '7' || N[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void) {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  int r = x == w / 2 && y == h / 2 ? 1 : 0;
  printf("%.10f %d\n", w*h/2, r);
  return 0;
}


Measured memory_bytes: 632
import java.util.*;
public class Main {	
	public static void main(String[] args){
		
		Scanner sc=new Scanner(System.in);
		
		long n=sc.nextLong();
		long k=sc.nextLong();
		
		//int ans=0;
		
		while(n>=k){
			n=n%k;
		}
		if(n<k){
			n=Math.min(n, k-n);
		}
		//System.out.println(ans);
		System.out.println(n);

}
	
}


Measured memory_bytes: 23508
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########

def resolve():
    n,k = mi()
    p = mi()

    p.sort()
    print(sum(p[:k]))

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9268
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int a,b;
    cin>>a>>b;
    switch(a+b){
        case 3:
            cout<<3<<endl;
            break;
        case 4:
            cout<<2<<endl;
            break;
        case 5:
            cout<<1<<endl;
            break;
        default:
            break;
    }
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp


if s[0]!="A"
	print("WA\n")
	exit
end

countC = 0
for i in 2..s.length-2
	if s[i] == "C"
		countC += 1
		indexC = i
	end 
end

if countC != 1
	print("WA\n")
	exit
end

for i in 1..s.length-1
	next if i == indexC
	if "A" <= s[i] && s[i]<= "Z"
		print("WA\n")
		exit
	end
end

print("AC\n")

Measured memory_bytes: 1916
n = int(input())
p = list(map(int, input().split()))


def _result(p):
    sum = 0
    m = p[0]
    for i in range(0, len(p)):
        if p[i] > m:
            pass
        else:
            m = p[i]
            sum += 1
    return sum


print(_result(p))

Measured memory_bytes: 24744
/* vo01.cpp */
#include <iostream>
#include <queue>
using namespace std;

int main()
{
	priority_queue<int> que;
	int h;

	for (int i = 0; i < 10; ++i) { cin >> h; que.push(h); }

	int c = 0;
	while (c < 3) {
		cout << que.top() << '\n'; que.pop();
		c++;
	}

	return 0;
}

Measured memory_bytes: 1212
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<Integer> remaining = new HashSet<>(Arrays.asList(1, 9, 7, 4));
        for (int i=0; i<4; i++) {
            int a = sc.nextInt();
            if (remaining.contains(a)) {
                remaining.remove(a);
            }
        }
        System.out.println(remaining.isEmpty() ? "YES" : "NO");
    }
}


Measured memory_bytes: 21588
#include <algorithm>
#include <bitset>
#include <cstdint>
#include <iostream>
#include <deque>
#include <vector>

auto main() -> int {
  std::string S{};
  std::cin >> S;

  const auto L = S.length();
  const auto nb = static_cast<decltype(L)>(std::count(S.cbegin(), S.cend(), '1'));

  std::cout << (std::min(nb, L - nb) * 2) << std::endl;
}



Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

long long int N, M, K, Q, W, H;
long long int ans;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M >> K;
	cout << M / K - (N + K - 1) / K+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Graph{
	private:
	int V;
	vvp g;
	vi DIJ(int s){
		priority_queue<P> que;
		vi d(V,inf);
		d[s]=0;
		que.push({0,s});
		while(!que.empty()){
			P p=que.top();
			que.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(int i=0;i<g[v].size();i++){
				int F=g[v][i].first,S=g[v][i].second;
				if(d[F]>d[v]+S){
					d[F]=d[v]+S;
					que.push({-d[F],F});
				}
			}
		}
		return d;
	}
	public:
	int D(){
		vi d=DIJ(0);
		int M=-1,v;
		for(int i=0;i<V;i++) if(M<d[i]){
			M=d[i];
			v=i;
		}
		d=DIJ(v);
		M=-1;
		for(int i=0;i<V;i++) M=max(M,d[i]);
		return M;
	}
	Graph(int v){
		V=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
		g[t].push_back({s,c});
	}
};

int n;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		int res=0;
		Graph g(n);
		vi a(n-1),b(n-1),c(n);
		for(int i=0;i<n-1;i++){
			cin>>a[i];
			a[i]--;
			c[i+1]++;
			c[a[i]]++;
		}
		for(int i=0;i<n-1;i++){
			cin>>b[i];
			res+=b[i];
		}
		for(int i=0;i<n-1;i++){
			if(c[i+1]==1||c[a[i]]==1) b[i]=0;
			g.add_edge(i+1,a[i],b[i]);
			res+=2*b[i];
		}
		res-=g.D();
		cout<<res<<endl;
	}
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

struct sphere{
  double x, y, z, r;
  sphere(){}
  sphere(double a, double b, double c, double d){
    x = a; y = b; z = c; r = d;
  }
};

struct edge{
  int from, to;
  double cost;
  edge(){}
  edge(int a, int b, double c){
    from = a; to = b; cost = c;
  }
};

bool comp(edge p, edge q){
  return p.cost < q.cost;
}

bool checker(sphere p, sphere q){
  double dx = p.x - q.x;
  double dy = p.y - q.y;
  double dz = p.z - q.z;
  
  return dx*dx + dy*dy + dz*dz <= (p.r + q.r)*(p.r + q.r);
}

double kyori(sphere p, sphere q){
  double dx = p.x - q.x;
  double dy = p.y - q.y;
  double dz = p.z - q.z;

  return sqrt(dx*dx + dy*dy + dz*dz);
  //return sqrt(pow(p.x - q.x, 2.0) + pow(p.y - q.y, 2.0) + pow(p.y - q.y, 2.0));
}

vector<int> par(110);

void init(int n){
  for(int i = 0; i < n; i++){
   par.at(i) = i;
  }
}

int root(int x){
  if(par.at(x) == x) return x;
  return par.at(x) = root(par.at(x));
}

void unite(int x, int y){
  if(root(x) == root(y)) return;
  par.at(root(x)) = root(y);
}

bool same(int x, int y){
  return root(x) == root(y);
}

int main(){
vector<double> result(0);
while(true){
  int n;
  cin >> n;
  if(n == 0) break;

  init(n);

  vector<sphere> cell(n);
  for(int i = 0; i < n; i++){
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    cell.at(i) = sphere(a, b, c, d);
  }

  vector<edge> ed(0);
  for(int i = 0; i < n; i++){
    for(int j = i; j < n; j++){
      if(checker(cell.at(i), cell.at(j))) unite(i, j);
      else{
        double c = kyori(cell.at(i), cell.at(j)) - cell.at(i).r - cell.at(j).r;
        ed.push_back(edge(i, j, c));
      }
    }
  }
  sort(ALL(ed), comp);
  double res = 0;
  for(int i = 0; i < ed.size(); i++){
    if(!same(ed.at(i).from, ed.at(i).to)){
      unite(ed.at(i).from, ed.at(i).to);
      res += ed.at(i).cost;
    }
  }
  result.push_back(res);
}
cout << fixed << setprecision(3);
for(auto x: result) cout << x << endl;
}


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

using namespace std;

const int MAXN = 120, MAXW = 1e5 + 20;

long long dp[MAXN][MAXW];
int value[MAXN], weight[MAXN], N, W;

long long knapsack(int i, int w) {
	if(dp[i][w] != -1) {
		return dp[i][w];
	}
	if(i == 0 || w == 0) {
		return 0LL;
	}
	if(weight[i] > w) {
		return dp[i][w] = knapsack(i - 1, w);
	}
	long long yes = value[i] + knapsack(i - 1, w - weight[i]);
	long long no = knapsack(i - 1, w);
	return dp[i][w] = max(yes, no);
}

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

	memset(dp, -1, sizeof dp);
	cin >> N >> W;
	for(int i = 1; i <= N; i++) {
		cin >> weight[i] >> value[i];
	}
	long long ans = knapsack(N, W);
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 94080
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define pob pop_back
#define ff first
#define ss second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
/* 	1) order_of_key (k) : Number of items strictly smaller than k .
	2) find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace __gnu_pbds;
using namespace std;
using LD = long double;

const int maxs = 1e6+1;
const int mod = 1e9+7;
const int INF = 1e18;
int row[8] = {1,1,0,-1,-1,-1,0,1};
int col[8] = {0,-1,-1,-1,0,1,1,1};

void solve() {
	int x;
	cin >> x;
	cout << !x << endl;
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t = 1,i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;



#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll maxn = 3000000+10;
#define endl '\n'
#define int ll
ll power(ll x, ll n) {
	ll res = 1;
	for (; n > 0; n >>= 1) {
	if (n & 1) res = (res * x) % mod;
	x = (x * x) % mod;
	}
	return res;
}
const int ALPHA = 26;
vector<vector<int>> trie;
bool dfs(int u)
{	
	bool check =0;
	for(int i= 0;i<26;i++)
	{
		if(trie[u][i]!=-1)
		{	
			
			bool k = (!(dfs(trie[u][i])));
			check|=k;
		}
	}
	return check;
}
bool dfs1(int u)
{	
	bool check =0;
	bool child = false;
	for(int i= 0;i<26;i++)
	{
		if(trie[u][i]!=-1)
		{	
			child = true;
			bool k = (!(dfs1(trie[u][i])));
			check|=k;
		}
	}
	if(!child)
		return true;
	return check;
}
int32_t main()
{   

  
    IOS 
	int n,m;
	cin>>n>>m;
	int ans = (n*(n-1))/2 + (m*(m-1))/2;
	cout<<ans<<endl;
	
   
		
	  


    
	
    
    
   
     
       
    

 
}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N);
	vector<int> y(M);
	string res = "War";
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> y[i];
	}
	for (int Z = X + 1; Z <= Y; Z++) {
		bool ok = true;
		for (int j = 0; j < N; j++) {
			if (x[j] >= Z) {
				ok = false;
			}
		}
		for (int j = 0; j < M; j++) {
			if (y[j] < Z) {
				ok = false;
			}
		}
		if (ok) {
			res = "No War";
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, C;
    cin >> N >> M >> C;
    int B[110];
    rep(i, M) cin >> B[i];
    int cnt = 0;
    rep(i, N) {
        int A[110];
        rep(j, M) cin >> A[j];
        int sum = C;
        rep(j, M) sum += A[j] * B[j];
        if (sum > 0) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<climits>
#include<map>
// #include<algorithm>
// #include<string>
// #include<stack>
#include<queue>
#include <fstream>
using namespace std;

int main(){
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    cout<<n*n*n<<endl; 
}

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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int r=0,b=0;
  for(int i=0;i<n;i++){
    if(s[i]=='0') r++;
    else b++;
  }
  cout<<min(r,b)*2<<endl;
  }


Measured memory_bytes: 512
<?php
$n = intval(fgets(STDIN));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));

$min = 2;
$max = 2;
for($i = $n-1; $i >= 0; $i--){
    $a = $A[$i];
    $m = ceildiv($min, $a);
    $M = intdiv($max, $a);
    if($m > $M){
        echo -1,"\n";exit;
    }
    $min = $m*$a;
    $max = $M*$a + $a - 1;
}
echo "$min $max\n";

function ceildiv($a, $b){
    return intdiv($a+$b-1, $b);
}

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(A) A.begin(), A.end()
#define SZ(A) (ll)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 1e6;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h, n, sum = 0;
    cin >> h >> n;
    ll a[n];
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum >= h) cout << "Yes\n";
    else cout << "No\n";
 	return 0;
}

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

int dp[50];

int fib(int n){
  if (n == 0 || n == 1) {
    return dp[n] = 1;
  }
  else if (dp[n] != -1) {
    return dp[n];
  }
  else {
  return dp[n] = fib(n - 1) + fib(n - 2);
  }
}

int main() {
  int n, i;
  cin >> n;
  for (i = 0; i < 50; i++) {
    dp[i] = -1;
  }
  
  scanf("%d", &n);
  printf("%d\n", fib(n));
  
  return 0;

}


Measured memory_bytes: 3212
from math import gcd
from functools import reduce

n = int(input())
A = list(map(int, input().split()))
res = ['pairwise coprime', 'setwise coprime', 'not coprime']

MAX = 10 ** 6 + 1000
dp = [i for i in range(MAX)]
# dp[x]はxを割り切る最小の素数
for x in range(2, MAX):
    if dp[x] < x: continue
    for y in range(x + x, MAX, x):
        if dp[y] == y:
            dp[y] = x

def get_factor(n):
    factors = []
    while n > 1:
        factors.append(dp[n])
        n //= dp[n]
    return factors

prime_factors = []
for a in A:
    factor = get_factor(a)
    factor_set = list(set(factor))
    prime_factors.extend(factor_set)

if len(prime_factors) == len(set(prime_factors)):
    print(res[0])
elif reduce(gcd, A) == 1:
    print(res[1])
else:
    print(res[2])


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


typedef long long ll;
int main()
{
    ll N;
    cin>>N;
    ll arr[N];
    for(ll i=0; i<N; i++){
        cin>>arr[i];
    }

    ll ans = 0;
    ll mx = 0;
    for(ll i=1; i<N; i++){

        if(arr[i]-arr[i-1]>1){
            cout<<-1<<endl;
            return 0;
        }

    }
    if(arr[0]>0){
        cout<<-1<<endl;
        return 0;
    }

    for(ll i=1; i<N; i++){
        if(arr[i]<=arr[i-1]){
            ans+=arr[i-1];
        }
    }
    ans+=arr[N-1];
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    int H, W;
    while(1){
        scanf("%d %d\n", &H, &W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                printf("#");
            }
            printf("\n");
        }printf("\n");
    }
        return 0;
}


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

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

    set<int> se;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (se.find(a) == se.end()) se.insert(a);
        else se.erase(a);
    }
    cout << se.size() << endl;

    return 0;
}


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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

vector<lint> h;
int n;
int a, b, d;

bool f(lint m) {
	lint cnt = 0;
	rep(i, n) {
		lint H = h[i] - m * b;
		if (H <= 0) continue;
		cnt += (H + d - 1) / d;
	}

	return cnt <= m;
}

int main() {
	cin >> n >> a >> b;
	d = a - b;

	lint mazai = 0;
	rep(i, n) { h.pb(in()); chmax(mazai, h[i]); }

	lint l = 0, r = mazai / b + 1000;
	while (r - l > 1) {
		lint m = (l + r) / 2;
		if (f(m)) {
			r = m;
		} else {
			l = m + 1;
		}
	}

	if (f(l)) {
		r = l;
	} else {
		l = r;
	}

	cout << l << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

typedef pair <int, int> pii;
typedef pair <string, string> pss;
typedef long long ll;

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 18;

int n;
string s;
map <pss, int> m;
ll sol;

int main(){

    cin >> n;
    cin >> s;

    for (int mask = 0; mask < (1<<n); mask++){
        string r = "", b = "";
        for (int i = 0; i < n; i++){
            if (mask & (1<<i)) r += s[i];
            else b += s[i];
        }
        reverse(b.begin(), b.end());
        m[mp(r, b)]++;
    }

    for (int mask = 0; mask < (1<<n); mask++){
        string r = "", b = "";
        for (int i = 0; i < n; i++){
            if (mask & (1<<i)) r += s[n+i];
            else b += s[n+i];
        }
        reverse(b.begin(), b.end());
        sol += m[mp(b, r)];
    }

    cout << sol;

    return 0;

}

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

int main()
{
    int x;
    cin >> x;
    cout << !x << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define pb                  push_back
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)      type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
const double pi = 3.1415926535897932384626433;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int n;cin>>n;
    fo0(i,n){
        string s;cin>>s;
        if(s=="AC")
            d++;
        if(s=="WA")
            e++;
        if(s=="TLE")
            f++;
        if(s=="RE")
            g++;
    }
    cout<<"AC x "<<d<<endl;
    cout<<"WA x "<<e<<endl;
    cout<<"TLE x "<<f<<endl;
    cout<<"RE x "<<g<<endl;
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<fixed<<setprecision(3)<<(double)(clock()-beg)/1000<<"s ";
}

Measured memory_bytes: 3844
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        x: u8,
        y: u8,
    }

    for i in 0..101 {
        for j in 0..101 {
            if i+j == x && 2*i + 4*j == y {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 2144
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def right(aim,ai,si):
    if ai==0:
        return aim if si=='o' else (1-aim)
    else:
        return (1-aim) if si=='o' else aim

n = inn()
s = ins()
for a0 in [0,1]:
    for a1 in [0,1]:
        a = [-1]*n
        a[0] = a0
        a[1] = a1
        for i in range(1,n-1):
            a[i+1] = right(a[i-1],a[i],s[i])
        if right(a[n-2],a[n-1],s[n-1])==a[0] and \
           right(a[n-1],a[0],s[0])==a[1] :
           for j in range(n):
               printn('S' if a[j]==0 else 'W')
           print('')
           exit()
print(-1)


Measured memory_bytes: 50668
#include<iostream>
using namespace std;
int main(){
	int num[1000],n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>num[i];
	}
	for(int i=n;i>1;i--){
		cout<<num[i]<<" ";
	}
	cout<<num[1]<<endl;
	return 0;
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=2e5+5;
int a[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	map<int,ll> H;
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=H[i-a[i]];
		H[i+a[i]]++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 27096
#include <stdio.h>
#include <algorithm>
long long n, k, g;
long long a[200000];
long long b[100000];
long long c[100000];
void fp(long long x, long long y) {
	long long z = (y - x + 1) / 2;
	for (int i = 0; i < z; i++) {
		if (2 * i < z)a[x + i] = y - z / 2 + i;
		else a[x + i] = x + i + z / 2;
	}
}
int main() {
	scanf("%lld%lld", &n, &k);
	if (n % 2 == 0) {
		a[0] = 2 * n - 1;
		a[2 * n - 1] = 0;
		fp(1, 2 * n - 2);
	}
	else {
		fp(0, 2 * n - 1);
	}
	for (long long i = 0; i < n; i++) {
		b[i] = (a[i] + i + 2 * k) * n + i;
		c[i] = k + 2 * n + i;
	}
	std::sort(b, b + n);
	std::sort(c, c + n);
	for (int i = 0; i < n; i++) {
		if ((b[i] / n) > c[i])g = 1;
	}
	if (g)printf("-1\n");
	else {
		for (int i = 0; i < n; i++) {
			printf("%lld %lld %lld\n", b[i] % n + k, a[b[i] % n] + k, c[i]);
		}
	}
}

Measured memory_bytes: 4480
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

    if (A <= 5){
        B = 0;
    }else if(A <= 12){
        B = B / 2;
    }
    
    cout << B << endl;
    return 0;
}

Measured memory_bytes: 256
import math
def prime_factorize(P):
    prime = list()
    for i in range(2, int(math.sqrt(P)) + 1):
        if P % i == 0:
            c = 0
            while P % i == 0:
                P //= i
                c += 1
            
            prime.append([i, c])
        else:
            continue

    if P != 1:
        prime.append([P, 1])

    return prime

def main():
    N, P = map(int, input().split())

    prime = prime_factorize(P)
    ans = 1
    for p in prime:
        n, c = p
        if c >= N:
            ans *= (n ** (c // N))

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9156