akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
using namespace std;

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

	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == 2) sum++;
		else {
			int k = ceil(sqrt(a[i]));
			for (int j = 2; j <= k; j++) {
				if (a[i] % j == 0) break;
				if (j == k) sum++;
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>
#include <stdlib.h>
int func(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}
int main(void){
  int min = 1000000001, n, k, tree[100000] = {0};
  scanf("%d %d", &n, &k);getchar();
  for(int i = 0; i < n; i++){
    scanf("%d", &tree[i]);getchar();
  }
  qsort(tree, n, sizeof(int), func);
  
  for(int i = 0; i < n - k + 1; i++){
    if(tree[i + k - 1] - tree[i] < min){
      min = tree[i + k - 1] - tree[i];
    }
  }
  printf("%d\n", min);
  return 0;
}

Measured memory_bytes: 892
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                PrintWriter ou = new PrintWriter(System.out);
                int n = Integer.parseInt(sc.next());
                int m = Integer.parseInt(sc.next());
                sc.close();
                boolean ebishu = true;
                for(int i = m / n ; ebishu && i > 0 ; i--){
                        if(m % i == 0){
                                ebishu = false;
                                ou.print(i + "\n");
                        }
                }
                ou.flush();
        }
}

Measured memory_bytes: 38500
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];

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

    int tt=INT_MAX;
    int id=0;

    for(int i=1;i<=n;i++)
    {
        int rs=0;
        for(int k=1;k<=i;k++)
            rs+=a[k];
        int rs1=0;
        for(int k=i+1;k<=n;k++)
            rs1+=a[k];
        //cout<<"rs1 "<<rs1 <<' ' <<rs<<endl;

        if(abs(rs1-rs)<tt)
        {
            tt=abs(rs1-rs);
            id=i;
        }
    }
    cout<<tt<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'
function main(input) {
  input = input.trim()
  let stack = [input[0]]
  let count = 0
  for (let i = 1; i < input.length; i++) {
    if (stack.length > 0 && stack[stack.length - 1] != input[i]) {
      stack.pop()
      count += 2
    } else {
      stack.push(input[i])
    }
  }
  console.log(count)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 10060
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N, M;
    cin >> N >> M;

    ll ans;
    if (N * 2 >= M) {
        ans = M / 2;
    } else {
        ans = N + (M - N * 2) / 4;
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define N 1000003
int i,j,t;
long long p[N];
main(){
	p[1]=2;
	for(i=2;i<N;p[i++]=p[i-1]+(i-p[i]-1))if(!p[i])for(j=2*i;j<N;j+=i)p[j]+=(j-1-p[j])/i;
	for(cin>>t;t--;cout<<p[i]<<endl)cin>>i;
}

Measured memory_bytes: 8680
#include<cstdio>
#include<cctype>

int main(){
    char a;
    while(1){
        scanf("%c",&a);
        if(isalpha(a)){
            if(islower(a))printf("%c",toupper(a));
            else printf("%c",tolower(a));
        }
        else printf("%c",a);
        if(a=='\n')break;
    }
    return 0;
}


Measured memory_bytes: 2688
from math import sqrt, fabs


class Circle:
    def __init__(self, x, y, r):
        self.x = x
        self.y = y
        self.r = r
        self.eps = 1e-8

    def contain(self, x, y):
        d2 = (self.x - x) ** 2 + (self.y - y) ** 2
        return d2 <= self.r ** 2 + self.eps

    def intersect(self, other):
        eps = self.eps

        if self.r > other.r:
            x1, y1, R = self.x, self.y, self.r
            x2, y2, r = other.x, other.y, other.r
        else:
            x1, y1, R = other.x, other.y, other.r
            x2, y2, r = self.x, self.y, self.r
        d = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

        # d = 0 and R = r
        if fabs(d) < eps and fabs(R - r) < eps:
            return '相同', None

        # d == R - r
        if fabs(d - (R - r)) < eps:
            x3 = (R * x2 - r * x1) / (R - r)
            y3 = (R * y2 - r * y1) / (R - r)
            return '內切', [(x3, y3)]

        # d == R + r
        if fabs(d - (R + r)) < eps:
            x3 = (R * x1 + r * x2) / (R + r)
            y3 = (R * y1 + r * y2) / (R + r)
            return '外切', [(x3, y3)]

        # d < R - r
        if d < R - r - eps:
            return '內離', None

        # d > R + r
        if d > R + r + eps:
            return '外離', None

        # R - r < d < R + r
        a = (R ** 2 - r ** 2 + d ** 2) / (2 * d)
        h = sqrt(R ** 2 - a ** 2)
        cx = x1 + a * (x2 - x1) / d
        cy = y1 + a * (y2 - y1) / d
        x3 = cx + h * (y2 - y1) / d
        y3 = cy - h * (x2 - x1) / d
        x4 = cx - h * (y2 - y1) / d
        y4 = cy + h * (x2 - x1) / d
        return '相交', [(x3, y3), (x4, y4)]


N, K = map(int, input().split())
X, Y, C = [], [], []
for _ in range(N):
    x, y, c = map(int, input().split())
    X.append(x)
    Y.append(y)
    C.append(c)


def check(t):
    circles = [Circle(x, y, t / c) for x, y, c in zip(X, Y, C)]

    cands = []
    for i in range(N):
        cands.append((X[i], Y[i]))
        for j in range(i + 1, N):
            kind, points = circles[i].intersect(circles[j])
            if kind in ['相交', '內切', '外切']:
                cands.extend(points)

    for (x, y) in cands:
        cnt = sum(1 for circle in circles if circle.contain(x, y))
        if cnt >= K:
            return True

    return False


# 0 0 0 1 1 1
lb, ub = 0, 1e9
for _ in range(100):
    mid = (lb + ub) / 2
    if check(mid):
        ub = mid
    else:
        lb = mid
print(ub)


Measured memory_bytes: 81260
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define repeat(i, n, m) for(int i = n; i < (m); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
inline T chmin(T& a, const T& b) {
	if (a > b)a = b;
	return a;
}

template<typename T>
inline T chmax(T& a, const T& b) {
	if (a < b)a = b;
	return a;
}

////atcoder library
//#include <atcoder/all>
//using namespace atcoder;

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	rep(i, n)printf("ACL");
	puts("");

	Please AC;
}

Measured memory_bytes: 3780
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n,x,k = rm()
print(math.ceil(n/x)*k)













Measured memory_bytes: 27128
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	//freopen("in.txt", "r", stdin);
	int n, C;
    cin >> n >> C;
    int c[505][505];
    int d[35][35];
    rep(i,1,C+1) rep(j,1,C+1) {
        cin >> d[i][j];
    }
    rep(i,1,n+1) rep(j,1,n+1) {
        cin >> c[i][j];
    }

    int a[3][35];
    memset(a, 0, sizeof(a));

    rep(i,1,n+1) rep(j,1,n+1) {
        int x = c[i][j];
        int idx = (i+j)%3;
        a[idx][x]++;
    }

    int memo[3][35];
    memset(memo, 0, sizeof(memo));

    rep(y,1,C+1) {
        rep(idx,0,3) {
            rep(x,1,C+1) {
                memo[idx][y] += d[x][y] * a[idx][x];
            }
        }
    }

    int ret = 1e9;
    rep(i,1,C+1) rep(j,1,C+1) rep(k,1,C+1) {
        if(i == j || j == k || k == i) continue;
        ret = min(ret, memo[0][i] + memo[1][j] + memo[2][k]);
    }
    cout << ret << '\n';
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
  if(abs(a-b)>1000000000000000000)cout<<"Unfair"<<endl;
  else if(k%2==0)cout<<a-b<<endl;
  else cout<<b-a<<endl;
  return 0 ;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)

n, x = map(int, input().split())

num = [0] * (n + 1)
num_p = [0] * (n + 1)
num_h = [0] * (n + 1)
num[0] = 1
num_p[0] = 1

for i in range(1, n + 1):
    num[i] = num[i - 1] * 2 + 3
    num_p[i] = num_p[i - 1] * 2 + 1

for i in range(n + 1):
    num_h[i] = num[i] // 2 + 1

# idx 番目までに含むPの数を返す
def func(idx, n):
    if idx == 1 and n == 0:
        return 1
    if idx == 1 and n == 1:
        return 0
    if idx <= n or n < 0:
        return 0

    if idx == num_h[n]:
        ret = num_p[n - 1] + 1

    elif idx > num_h[n]:
        ret = num_p[n] - func(num[n] - idx - 1, n - 1)

    elif idx < num_h[n]:
        ret = func(idx - 1, n - 1)

    return ret

print(func(x, n))

Measured memory_bytes: 38728
def run(n, a):
    max_a = max(a)
    min_a = min(a)
    return max_a - min_a


def read_line():
    n = int(input())
    a = list(map(int, input().split()))
    return (n, a)


def main():
    n, a = read_line()
    print(run(n, a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>


using namespace std;

int main(void){

    int ans = 0;
    vector<int> a(3);
    for(int i = 0;i < 3;i++) cin >> a[i];

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

    ans += abs(a[0] - a[1]);
    ans += abs(a[1] - a[2]);

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
N, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

ans = a.map { |i| [0, i - x].max }.inject(:+)
a = a.map { |i| i > x ? x : i }

(N - 1).times do |i|
  next if a[i] + a[i+1] <= x
  y = a[i] + a[i+1] - x
  ans += y
  a[i+1] = [0, a[i+1] - y].max
end

p ans


Measured memory_bytes: 12688
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
diff=[0]*N
     
ans=0
need=0
for i in range(N):
    diff[i]=B[i]-A[i]
    if diff[i]>0:
        ans+=1
        need+=diff[i]

diff.sort()

for i in range(N):
    if need<=0:
        break
    if diff[i]>0:
        ans=-1
        break
    need+=diff[i]
    ans+=1
    
print(ans)
    





Measured memory_bytes: 80176
#include<bits/stdc++.h>
using namespace std;
int main(){
	int flag=1,cnt=0;
	char a[200],b[200],ans[200],tmp[200];
	scanf("%s",a),scanf("%s",b);
	int lenb=strlen(b),lena=strlen(a);
	for(register int i=0;i<lena;i++){
		for(register int j=0;j<lenb;j++){
			if(b[j]!=a[i+j]&&a[i+j]!='?'){
				flag=2;
				break;
			}
		}
		if(flag==2)flag=1;
		else{
			for(register int k=0;k<lena;k++)tmp[k]=a[k];
			for(register int k=i;k<=lenb+i-1;k++){
				tmp[k]=b[k-i];
			}
			for(register int k=0;k<lena;k++){
				if(tmp[k]=='?')ans[k]='a';
				else ans[k]=tmp[k];
			}
			cnt++;
		}
	}
	if(cnt){
		for(register int i=0;i<lena;i++)cout<<ans[i];
	}else cout<<"UNRESTORABLE"<<endl;
	return 0;
}

Measured memory_bytes: 256
x=int(input())
first=list(map(int,input().split()))
drink_count=int(input())
count=0
Total=sum(first)
drink=[list(map(int,input().split())) for i in range(drink_count)]
for T in range(drink_count):
    change_num = drink[count][0]
    score = first[change_num-1]-drink[count][1]
    print(Total-score)
    count+=1


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<map>
#include<set>
using namespace std;main(){int n;string s;map<string,set<int> >z;map<string,set<int> >::iterator q;set<int>::iterator x;while(cin>>s>>n)z[s].insert(n);for(q=z.begin();q!=z.end();cout<<endl){cout<<(s=q++->first)<<endl;for(x=z[s].begin(),n=0;x!=z[s].end();cout<<*x++)if(n++)cout<<" ";}}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string w, text;
    int ans = 0;
    cin >> w;

    while (true)
    {
        cin >> text;
        if (text == "END_OF_TEXT")
            break;

        transform(text.begin(), text.end(), text.begin(), ::tolower);
        if (text == w)
            ans++;
    }

    printf("%d\n", ans);
}


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

using namespace std;
#define int long long


#define ff first
#define ss second
// #define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

void manacher(vi& d1, vi& d2, int n, string& s) {
	for(int i = 0, l = 0, r = -1; i < n; i++) {
		int k = (i > r) ? 1 : min(d1[l + r - i], r - i + 1);
		while (0 <= i - k && i + k < n && s[i - k] == s[i + k])
			k++;
		d1[i] = k--;
		if (i + k > r) {
			l = i - k;
			r = i + k;
		}
	}
	for(int i = 0, l = 0, r = -1; i < n; i++) {
		int k = (i > r) ? 0 : min(d2[l + r - i + 1], r - i + 1);
		while (0 <= i - k - 1 && i + k < n && s[i - k - 1] == s[i + k])
			k++;
		d2[i] = k--;
		if (i + k > r) {
			l = i - k - 1;
			r = i + k ;
		}
	}
}
signed main(void)
{
	IOS;
	int n; cin>>n;
	vector<string> s(n);
	vi t(n);
	for(int i = 0; i < n; i++) {
		cin>>s[i]>>t[i];
	}
	string ss;
	cin>>ss;
	int id=-1;
	int ans=0;
	for(int i = 0; i < n; i++) {
		if(s[i]==ss) {
			id=i;
			break;
		}
	}
	for(int i = id+1; i < n; i++) {
		ans += t[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
_n,m = gets.split(' ').map(&:to_i)
l = []
r = []
m.times do |a|
    single_l,single_r = gets.split(' ').map(&:to_i)
    l << single_l
    r << single_r
end
array = (l.max..r.min).to_a
puts array.length


Measured memory_bytes: 4228
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

a1,b1,c1,d1,e1 = a%10, b%10, c%10, d%10, e%10

ans = 0
# 時間の合計
total = a+b+c+d+e
# 待機時間
a1 = 10 - a1
b1 = 10 - b1
c1 = 10 - c1
d1 = 10 - d1
e1 = 10 - e1

if a1 == 10:
    a1 = 0
if b1 == 10:
    b1 = 0
if c1 == 10:
    c1 = 0
if d1 == 10:
    d1 = 0
if e1 == 10:
    e1 = 0

wait = a1+b1+c1+d1+e1 - max(a1,b1,c1,d1,e1)

ans = total + wait
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF (1LL<<60)
#define MOD 1000000007

int N;
long long A[100000];
long long S[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N) {
    S[i] = (i>0?S[i-1]:0) + A[i];
  }
  long long m = INF;

  long long c = 0;
  long long b = 0;
  for (int i=0; i<N; i++) {
    long long s = S[i]+b;
    if (i%2 == 0) {
      // +
      if (s <= 0) {
        b += 1LL-s;
        c += 1LL-s;
      }
    }
    else {
      // -
      if (s >= 0) {
        b -= s+1LL;
        c += s+1LL;
      }
    }
  }
  m = min(m, c);

  c = 0;
  b = 0;
  for (int i=0; i<N; i++) {
    long long s = S[i]+b;
    if (i%2 == 0) {
      // -
      if (s >= 0) {
        b -= s+1LL;
        c += s+1LL;
      }
    }
    else {
      // +
      if (s <= 0) {
        b += 1LL-s;
        c += 1LL-s;
      }
    }
  }
  m = min(m, c);
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const long long N=2e6+10;
long long n;
void solve(){
    cin>>n;
    long long f[n+1],ans=0;
    for(long long i=1;i<=n;i++)f[i]=0;
    for(long long i=1;i<=n;i++){
        for(long long j=i;j<=n;j+=i){
            f[j]++;
        }
    }
    for(long long i=1;i<n;i++)ans+=f[i];
    cout<<ans<<endl;
}
int main(){
    long long t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 11396
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz
 
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	string s;
	cin >> s;
	int c=0, ans=0;
	for(auto it: s){
		if(it=='R')c++;
		else{
			ans = max(ans, c);
			c=0;
		}
	}
	ans = max(ans, c);
	cout << ans << endl;
 
	return 0;
}  

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int x, a, b ;
  cin >> x >> a >> b ;
  
  if(b<=a){
    cout <<"delicious"<<endl ;
  }
  else if(b>a && b<=a+x){
    cout <<"safe"<<endl ;
  }
  else{
    cout <<"dangerous"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
long long int factorial(long long int x){
  return x==0 ? 1 : x*factorial(x-1);
}
int main(){
  int i, j, n;
  cin >> n;
  int d[n];
  for(i=0; i<n; i++)
    cin >> d[i];
  sort(d, d+n);
  if(d[n/2-1]==d[n/2]){
    cout << 0;
    return 0;
  }
  if(n==2){
    cout << d[n/2]-d[n/2-1];
    return 0;
  }
  cout << d[n/2]-d[n/2-1];
  return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main () {
    int a, b;
    std::cin >> a >> b;

    int ans = -1;
    for (int i = 1000; i > 0; i--)
    {
        if(int(i*0.08) == a && int(i*0.1) == b) {
            ans = i;
        }
    }

    std::cout << ans << "\n";
}

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

int main(int argc, char const *argv[])
{
	int m,d;
	cin>>m>>d;
	int ans=0;
	for (int i = 1; i <= d; ++i)
	{
		int d1=i%10,d2=i/10;
		if (d1>=2&&d2>=2&&d1*d2<=m)
		{
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(void){
	int n;
	int i;
	int temp;
	int sum[5000];
	int num;
	
	while(1){
		for(i=0; i<5000; i++){
			sum[i] = -100001;
		}
		sum[0] = 0;
		num = 0;
	
		scanf("%d", &n);
		if(n == 0) break;
		
		for(i=0; i<n; i++){
			scanf("%d", &temp);
			if(temp > 0 && sum[num] < 0){
				num++;
				sum[num] = temp;
			}else if(temp > 0){
				sum[num] += temp;
			}else if(temp <= 0 && sum[num] < 0){
				num++;
				sum[num] = temp;
			}else{
				num++;
				sum[num] = sum[num-1] + temp;
				if(i == 0 && sum[num-1] == 0) sum[num-1] = -100001;
			}	
		}

		sort(sum, sum + 5000, greater<int>());
		
		printf("%d\n", sum[0]);
		
	}
	
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	vector<int>b(n);
	rep(i,n){
		cin>>a[i]>>b[i];
	}
	bool ret = false;
	FOR(i,2,n){
		if(ret)break;
		if(a[i-2]==b[i-2] && a[i-1]==b[i-1] && a[i]==b[i])ret=true;
	}
	if(ret)print("Yes");
	else print("No");
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int A, B;
  cin >> A >> B;
  cout << lcm(A,B) << endl;
  return 0;
}


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

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    auto xs = new long[int][](M);
    foreach (x; readln.split.to!(int[])) {
        auto p = x % M;
        ++xs[p][x];
    }

    auto ps = new long[](M);
    auto rs = new long[](M);
    foreach (i, xx; xs) {
        foreach (_, v; xx) {
            ps[i] += v/2*2;
            rs[i] += v%2;
        }
    }

    long res = ps[0]/2 + rs[0]/2;
    foreach (i; 1..M) {
        auto j = M-i;
        if (i >= j) {
            if (i == j) res += ps[i]/2 + rs[i]/2;
            break;
        }
        auto r = min(rs[i], rs[j]);
        res += r;
        rs[i] -= r;
        rs[j] -= r;
        if (rs[i] > 0) {
            auto p = min(rs[i], ps[j]);
            res += p;
            ps[j] -= p;
        } else if (rs[j] > 0) {
            auto p = min(ps[i], rs[j]);
            res += p;
            ps[i] -= p;
        }
        res += ps[i]/2 + ps[j]/2;
    }
    writeln(res);
}

Measured memory_bytes: 28780
n=int(input())
a=list(map(int, input().split()))

money=1000

chart=[a[0]]

for kabuka in a:
    if kabuka==chart[-1]:
        continue
    else:
        chart.append(kabuka)

days=len(chart)
kabu=0

if days==1:
    print(money)
    exit()

for i in range(days):
    if i==0:
        if chart[0]<chart[1]:
            kabu=money//chart[0]
            money%=chart[0]

    elif i==days-1:
        money+=kabu*chart[i]
        kanu=0
    
    else:
        if chart[i-1]<chart[i] and chart[i]>chart[i+1]:
            money+=kabu*chart[i]
            kabu=0

        if chart[i-1]>chart[i] and chart[i]<chart[i+1]:
            kabu=money//chart[i]
            money%=chart[i]

print(money)

Measured memory_bytes: 62048
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://cf16-exhibition-final-open.contest.atcoder.jp/tasks/cf16_exhibition_final_c>
問題文============================================================
 チーターと不正者がニムをすることになりました。 このゲームでは、N 個の石の山を使います。
 最初に i 番目の山には ai 個の石があります。 チーターが先手で、交互にターンを取ります。
 それぞれのターンでは、プレイヤーは一つの山を選び、その山から一個以上の石を取り除きます。
 ターンが回ってきたときに操作ができなくなったプレイヤーの負けです。
 
 しかし、ゲームが始まる前に、
 不正者はチーターがどのような動きをしても必ず勝つことができるように少し不正をすることにしました。
 それぞれの山から、不正者は 0 個または 1 個の石を取り除き、ゲームが始まる前に食べます。
 不正者が必ず勝てるようにする方法が複数通りある場合は、食べる石の個数を最小にするようにしたいです。
 
 不正者が食べる石の個数を求めてください。 不正をしても不正者が必ず勝つようにできない場合は、-1 を出力してください。
=================================================================

解説=============================================================

================================================================
*/

ll solve(){
    ll N; cin >> N;
    vector<ll> a(N);
    for(auto &in:a) cin >> in;
    ll x = 0;
    for(int i = 0; i < N;i++) x ^= a[i];

    // a[i] -> a[i] - 1 := x^(a[i]^(a[i]-1)) = x^(2^k - 1)
    bool f[31] = {false};
    for(int i = 0; i < N;i++){
        ll t = a[i]^(a[i]-1);
        ll cnt = 0, n = 1;
        while(n <= t){cnt++; n<<=1;}
        f[cnt] = true;
    }
    ll ret = 0;
    for(int i = 30; i >= 0; i--){
        if((x>>i)&1){
            if(f[i+1] == false) return ret = -1;
            x^=((1<<(i+1)) - 1); ret++;
        }
    }
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vvs vector<vs>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  string s, t;
  cin >> s >> t;

  int i = 0;
  do {
    if (s == t) {
      cout << "Yes" << endl;
      return 0;
    }
    rep(i, s.size() - 1) {
      string new_s;
      new_s = s[s.size() - 1];
      FOR(j, 1, s.size()) { new_s.push_back(s[j - 1]); }
      s = new_s;
    }
    i++;
  } while (i < s.size());

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
import fractions
s=list(map(int,input().split()))
t=[int(i)//2 for i in input().split()]
ans = t[0]
for i in range(1,s[0]):
  ans=(ans*t[i])//fractions.gcd(ans,t[i])
  if ans>10**10:
    print(0)
    exit()
for j in t:
  if (ans//j)%2==0:
    print(0)
    exit()
if ans<=s[1]:
  print(int((s[1]//ans+1)//2))
else:
  print(0)

Measured memory_bytes: 16280
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

const int MAX_N = 500010;
ll fact[MAX_N], finv[MAX_N], inv[MAX_N];

void init_combination(ll p) {
    fact[0] = fact[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < MAX_N; ++i) {
        inv[i] = inv[p % i] * (p - p / i) % p;
        fact[i] = fact[i - 1] * i % p;
        finv[i] = finv[i - 1] * inv[i] % p;
    }
}

ll comb(int n, int k, ll p) {
    if (n < k || n < 0 || k < 0) return 0;
    return fact[n] * (finv[k] * finv[n - k] % p) % p;
}


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

    int h, w, a, b;
    cin >> h >> w >> a >> b;
    ll p = (ll) 1e9 + 7;
    init_combination(p);
    ll ans = 0;
    for (int i = b; i < w; ++i) {
        (ans += comb(h - a - 1 + i, i, p) * comb(a - 1 + w - i - 1, a - 1, p)) %= p;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12032
while True:
    n, p = map(int, input().split())
    if n == 0:
        break
    w = p
    s = [0] * n
    i = 0
    while True:
        if i == n:
            i = 0
        if w == 0:
            w = s[i]
            s[i] = 0
        else:
            s[i] = s[i] + 1
            w = w - 1
            if s[i] == p:
                print(i)
                break
        i = i + 1
            

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

void solve() {

}

#define MAX 20
int N,M,X,C[MAX], A[MAX][MAX];

int main() {
  cin >> N >> M >> X;
  rep(i,N) {
    cin >> C[i];
    rep(j,M) {
      cin >> A[i][j];
    }
  }
  ll ans = -1;
  rep(i,(1<<N)) {
    vector<int> a(M,0);
    ll cost = 0;
    rep(j,N) {
      if( (i>>j) & 1 ) {
	cost += C[j];
	rep(k,M) {
	  a[k] += A[j][k];
	}
      }
    }
    bool ok = true;
    rep(j,M) {
      if( a[j] < X ) {
	ok = false; break;
      }
    }
    if( ok ) {
      if( ans == -1 ) ans = cost;
      else ans = min(ans,cost);
    }
  }
  if( ans == -1 ) {
    puts("-1");
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,m;
priority_queue<int > que;

int main(){
	cin>>n>>m;
	int a;
	REP(i,n){
		cin>>a;
		que.push(a);
	}
	REP(i,m){
		int t1=que.top();
		que.pop();
		que.push(t1/2);
	}
	ll ans=0;
	REP(i,n){
		ans+=(ll)que.top();
		que.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int main()
{
	char a, b, c;
	scanf("%c%c%c", &a, &b, &c);
	
	if(a==b && b!=c || a==c && c!=b || b==c && c!=a){
		puts("Yes");
	}
	else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 1584
x=0
b = int(input())
a = list(map(int,input().split()))
for i in range(b):
    if a[i]%2==0:
        if a[i]%3 !=0 and a[i]%5!=0:
            x=1
            break      
if (x==0):print("APPROVED")
else :print("DENIED")


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

int tri(int a) {
    return (a+1) * a / 2;
}
int main(void) {
    int a, b;
    cin >> a >> b;
    cout << tri(b - a) - b << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char ch(char s,int d){
	if(s=='.'|| s=='\n'||s==' '|| s=='\0')return s;
	if(s+d>'z')return 'a'+(s+d-1-'z');
	else if(s+d<'a')return 'z'-('a'-(s+d+1));
	return s+d;
}
d;int main(){
	char str[90];
	int i;
	while(fgets(str,90,stdin)!=NULL){
		for(d=-13;d<13;d++){
			for(i=0;str[i]!='\0';i++)str[i]=ch(str[i],d);
			if(strstr(str,"this")!=NULL ||strstr(str,"that")!=NULL||strstr(str,"the")!=NULL){
				printf("%s",str);break;
			}
			for(i=0;str[i]!='\0';i++)str[i]=ch(str[i],-d);
		}
	}
	exit(0);
}

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

typedef pair<int,int> pii;

int main(){
    int n;
    cin >> n;
    vector<int> v[n], deg(n, 0);
    vector<pii> vp;
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        v[a].push_back(b);
        v[b].push_back(a);
        vp.push_back({a,b});
        deg[a]++, deg[b]++;
    }
    int k = *max_element(deg.begin(), deg.end());
    cout << k << endl;
    int f;
    for(int i = 0; i < n; i++)  if(deg[i] == k) f = i;
    map<pii,int> col;
    queue<pii> q;
    q.push({0,f});
    vector<bool> vis(n, 0);
    vis[f] = true;
    while(!q.empty()){
        auto x = q.front();  q.pop();
        int now = 1;
        for(int child : v[x.second]){
            if(vis[child])  continue;
            vis[child] = true;
            if(now == x.first)  now++;
            col[{min(x.second,child),max(x.second,child)}] = now;
            q.push({now++, child});
        }
    }
    for(pii p : vp) cout << col[p] << endl;
    return 0;
}

Measured memory_bytes: 13428
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int h,a;
  cin>>h>>a;
  cout<<((h+a-1)/a)<<endl;
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	int ans = 1;
	set<int>S; 
	S.insert(N);
	while (true) {
		++ans;
		int num = S.size();
		if (1 == N%2) {
			N = 3 * N + 1;
		}
		else {
			N /= 2;
		}
		S.insert(N);
		if (num ==S.size()) {
			break;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
		int a ,b, c;
		cin >> a >> b >> c;
		
		puts( ((a==b && a!= c) || (a==c && a!=b) || (b==c && a!=b)) ? "Yes":"No");
		
		
		return 0;
} 


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    ll N, Y;
    cin >> N >> Y;
    rep(i, N + 1)rep(j, N + 1 - i) {
        ll tmp;
        tmp = 10000 * i + 5000 * j + 1000 * (N - i -  j);
        if (Y == tmp) {
            cout << i << " " << j << " " << N - i - j << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
 
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# import bisect
# from collections import Counter, deque, OrderedDict, defaultdict
# from copy import copy, deepcopy # pythonのみ．copyは1次元，deepcopyは多次元．
# from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


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


def resolve():

    n, m, K = map(int, input().split())
    class Combination:
        """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""

        def __init__(self, n, MOD):
            self.fact = [1]
            for i in range(1, n + 1):
                self.fact.append(self.fact[-1] * i % MOD)
            self.inv_fact = [0] * (n + 1)
            self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
            for i in reversed(range(n)):
                self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
            self.MOD = MOD

        def factorial(self, k):
            """k!を求める O(1)"""
            return self.fact[k]

        def inverse_factorial(self, k):
            """k!の逆元を求める O(1)"""
            return self.inv_fact[k]

        def permutation(self, k, r):
            """kPrを求める O(1)"""
            if k < r:
                return 0
            return (self.fact[k] * self.inv_fact[k - r]) % self.MOD

        def combination(self, k, r):
            """kCrを求める O(1)"""
            if k < r:
                return 0
            return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD

        def combination2(self, k, r):
            """kCrを求める O(r) kが大きいが、r <= nを満たしているときに使用"""
            if k < r:
                return 0
            res = 1
            for l in range(r):
                res *= (k - l)
                res %= self.MOD
            return (res * self.inv_fact[r]) % self.MOD
    MOD = 998244353
    comb = Combination(10 ** 6, MOD)

    ans = 0
    df=m*pow(m-1,n-1-K,MOD)

    now = df
    for i in range(K, -1, -1):
        now = comb.combination(n-1, i)
        ans += now*df
        ans %= MOD
        df *= (m-1)
        df%=MOD

    print(ans)

resolve()

Measured memory_bytes: 161328
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from collections import deque
def resolve():
    n, k =map(int,input().split())
    Q = deque([])
    sum = 0
    ans = 0
    for a in map(int,input().split()):
        Q.append(a)
        sum += a
        if(len(Q)==k):
            ans = max(ans, (sum+k)/2)
            sum -= Q.popleft()

    print(ans)
resolve()

Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long  int n,a,i,sum=0,sum1=0,l,s=0,dif,mx;
    vector<int>v;
    cin>>n;
    for(i=0;i<n;i++)
    {cin>>a;
    v.push_back(a);
    s+=a;

    }


      for(int i=n-1;i>=1;i--)
      {
          s-=v[i];
          sum+=v[i];
          dif=abs(s-sum);
          if(i==n-1){mx=dif;}
        else  {

            if(mx>dif)
            {
                mx=dif;
            }
          }
      }
cout<<mx<<endl;

}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll x, y, X, Y;
  cin >> x >> y >> X >> Y;
  cout << X-Y+y << sp << Y+X-x << sp << x-Y+y << sp << y+X-x << rt;
}

Measured memory_bytes: 256
a, b, c = sorted(map(int, input().split()))
a = c-a; b = c-b
p = a%2; q = b%2
if p and q:
    print(a//2+b//2+1)
elif p or q:
    print(a//2+b//2+2)
else:
    print(a//2+b//2)


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

typedef pair<int,int> pii;
typedef vector<int> vec;
typedef unordered_map<int,int> hash;
#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,v) memset(a,v,sizeof(a))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define INF 0x3f3f3f3f//infinity for integers
#define JJ ios_base::sync_with_stdio(0); cin.tie(0)//input fast
#define MOD 1000000007


int main()
{
	JJ;
	int n; cin>>n;
	string str; cin>>str;
	int r=0;
	for(int i=0;i<n;i++){
		if(str[i]=='R'){
			r++;
		}
	}
	int ans=0;
	for(int i=0;i<r;i++){
		if(str[i]!='R')
			ans++;
	}
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll a,b,c,d;cin>>a>>b>>c>>d;
  
  ll ans=max(a*c,a*d);
  ans=max(ans,b*c);
  ans=max(ans,b*d);
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3524
array = []

n = gets.chomp.to_i
n.times {
    s, x = gets.chomp.split()
    case s
    when "insert"
        array.unshift(x.to_i)
    when "delete"
        idx = array.find_index(x.to_i)
        array.delete_at(idx) if idx != nil
    when "deleteFirst"
        array.shift
    when "deleteLast"
        array.pop
    end
}

puts array.join(" ")


Measured memory_bytes: 21396
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <map>
using namespace std;

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

  string s;
  cin >> s;

  for (int lb = 0; lb < s.size(); lb++) {
    for (int ub = lb; ub < s.size(); ub++) {
      string new_s = s.substr(0, lb) + s.substr(ub);

      if (new_s == "keyence") {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256