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

int main(int argc, const char * argv[]) {
    bool possible = true;
    string target;
    cin >> target;
    int i = 0;
    int str_size = int(target.length());
    
    int moving_index = ((str_size - 1) / 2 ) -1;
    while (moving_index >= 0 && possible) {
        if (target[i] != target[moving_index])
            possible = false;
        moving_index--;
        i++;
    }
    if (possible == false) {
        cout << "No" <<endl;
        return 0;
    }
    
    i = ((str_size + 3) / 2) - 1;
    moving_index = str_size - 1;
    while (target[i] && possible) {
        if (target[i] != target[moving_index])
            possible = false;
        moving_index--;
        i++;
    }
    if (possible == false) {
        cout << "No" <<endl;
        return 0;
    }

    i = 0;
    moving_index = str_size - 1;
    while (target[i] && possible) {
        if (target[i] != target[moving_index])
            possible = false;
        moving_index--;
        i++;
    }
    if (possible == false) {
        cout << "No" <<endl;
        return 0;
    }
    if (possible)
        cout << "Yes" << endl;

    
    return 0;
}

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

long int LA[100002], RA[100002];

long int merge(long int* A, int n, int left, int mid, int right) {
    int i,j,k;
    long int inv=0;
    int n1 = mid-left;
    int n2=right-mid;
    for (i=0; i<n1; i++) {
        LA[i] = A[left+i];
    }
    for (i=0; i<n2; i++) {
        RA[i] = A[mid+i];
    }
    LA[n1] = RA[n2] = 2000000000;
    i=j=0;
    for (k=left; k<right; k++) {
        if (LA[i]<=RA[j]) {
            A[k]=LA[i];
            i++;
        } else {
            A[k]=RA[j];
            inv+=(n1-i);
            j++;
        }
    }
    return inv;
}

long int mergesort(long int* A, int n, int left, int right) {
    int mid;
    long int inv1=0, inv2=0, inv3=0;
    if (left+1<right) {
        mid = (left+right)/2;
        inv1 = mergesort(A, n, left, mid);
        inv2 = mergesort(A, n, mid, right);
        inv3 = merge(A, n, left, mid, right);
    }
    return inv1+inv2+inv3;
}

int main() {
    int n;
    std::cin >> n;
    static long int a[200001];
    for (int i=0; i<n; i++) {
        std::cin >> a[i];
    }

    std::cout << mergesort(a, n, 0, n) << std::endl;

    return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N)
    {
        cin >> h.at(i);
    }
    int ans = 0;
    rep(i, N)
    {
        if (h.at(i) >= K)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
var
	n,i,k,min:longint;
	a:array[0..100010] of longint;
procedure qsort(l,r:longint);
var
	i,j,t,mid:longint;
begin
	i:=l; j:=r; mid:=a[(l+r) div 2];
	repeat
		while a[i]<mid do inc(i);
		while a[j]>mid do dec(j);
		if i<=j then
		begin
			t:=a[i]; a[i]:=a[j]; a[j]:=t;
			inc(i); dec(j);
		end;
	until i>j;
	if l<j then qsort(l,j);
	if i<r then qsort(i,r);
end;
begin
	readln(n,k);
	for i:=1 to n do read(a[i]);
	qsort(1,n);
	min:=2000000000;
	for i:=k to n do
		if a[i]-a[i-k+1]<min then min:=a[i]-a[i-k+1];
	writeln(min);
end.

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

bool dp[100010];

int main() {
    ll N, K;
    cin >> N >> K;
    ll a[N];
    REP(i, 0, N) {
        cin >> a[i];
    }
    dp[0] = false;
    REP(i, 1, K + 1) {
        bool ok = false;
        REP(j, 0, N) {
            if (i - a[j] >= 0) {
                if (!dp[i - a[j]]) {
                    ok = true;
                    break;
                }
            }
        }
        if (ok) {
            dp[i] = true;
        } else {
            dp[i] = false;
        }
    }
    if (dp[K]) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}


Measured memory_bytes: 384
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N; cin>>N;
    ll arr[N][N];
    ll dp[1LL << N];
    
    for(ll i=0;i<N;++i)   
    {
        for(ll j=0;j<N;++j)
        {
            cin>>arr[i][j];
        }
    }
    
    dp[0] = 1; //base case
    for(ll mask = 1;mask < (1 << N);++mask)
    {
        dp[mask] = 0;
        ll male_no = __builtin_popcount(mask);
        male_no--;
        
        for(ll j=0;j<N;++j)
        {
            if(arr[male_no][j] && (mask & (1LL << j)))
            {
                dp[mask] += dp[mask ^ (1LL << j)];
                dp[mask] %= MOD;
            }
        }
    }
    
    cout<<dp[(1LL << N) - 1]<<endl;
}

Measured memory_bytes: 20044
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [X, A, B] = input[0].map(Number);

  if (B <= A) {
    return "delicious";
  } else if (B <= A + X) {
    return "safe";
  } else {
    return "dangerous";
  }
};

console.log(main(read()));


Measured memory_bytes: 29588
#include <stdio.h>

int main(void)
{
    int n, d, min, max;
    long int sum;
    scanf("%d%d", &n, &d);

    sum = min = max = d;
    for (n=n-1; n>0; n--) {
        scanf("%d", &d);
        sum += d;
        if (min > d) {
            min = d;
        }
        if (max < d) {
            max = d;
        }
    }

    printf("%d %d %ld\n", min, max, sum);

    return 0;
}


Measured memory_bytes: 2108
N, A, B, C, D=map(int, input().split())
A-=1
B-=1
C-=1
D-=1

S=input()

if C<D:
    for i in range(B, D-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
    for i in range(A, B-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
    print("Yes")
else:
    flag=False
    for i in range(B-1, D):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
        if S[i]=='.' and S[i+1]=='.' and S[i+2]=='.':
            flag=True
    for i in range(A, C-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
    print("Yes" if flag else "No")

Measured memory_bytes: 3572
import numpy as np
l = int(input())
a = [ np.int(x) for x in input().split() ]
a = np.array(a, dtype = 'int32')
ans = 0
while True:
    b =  a / 2
    c = a // 2
    if (b - c).any():
        break
    else:
        a = b
        ans += 1
print(ans)

Measured memory_bytes: 12464
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; ll a, b; cin >> n >> a >> b;
  vector<ll> X(n); rep(i, n) cin >> X[i];
  ll ans = 0;
  rep(i, n-1) {
    ans += min((X[i+1]-X[i])*a, b);
  }
  cout << ans << "\n";
  return 0;
}


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

const long long MAX = 1e18;

int main() {
    int N;
    cin >> N;
    long long *A = new long long[N];
    long long sum = 1;
    long long sum_old = 1;
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    
        if (A[i] == 0) {
            cout << 0;
            return 0;
        }
    }
    
    for (int i = 0; i < N; i++) {
        if ( MAX / sum >= A[i] ) {
            sum *= A[i];
        } else {
            cout << -1;
            return 0;
        }
    }
    
    cout << sum;
    return 0;
}

Measured memory_bytes: 4340
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val g = Graph(n,n-1)
    val (q,k) = readLine()!!.split(" ").map { it.toInt() }
    val qs = (1..q).map { readLine()!!.split(" ").map { it.toInt() } }

    val d = g.makeRootedTree(k)
    qs.map {
        d[it[0]] + d[it[1]]
    }.joinToString("\n").let { println(it) }
}

class Graph (val N: Int, val M: Int){

    data class Edge(val to: Int, val cost: Long)

    val adj = run {
        val adjList = Array<MutableList<Edge>>(N+1){ mutableListOf()}
        (1..M).forEach {
            val line = readLine()!!.split(" ")
            val from = line[0].toInt()
            val to = line[1].toInt()
            val cost = line.getOrElse(2){"1"}.toLong()
            adjList[from].add(Edge(to,cost))
            adjList[to].add(Edge(from,cost))
        }
        adjList.map { it.toList() }
    }

    // root を根とした根付き木を返す。
    fun makeRootedTree(root: Int): LongArray{
        val parent = IntArray(N+1){-1}
        val dist = LongArray(N+1){-1}
        dist[root] = 0L
        dfs(root, parent, dist)
        return dist
    }

    fun dfs(v: Int, parent: IntArray, dist: LongArray) {
        adj[v].filter { dist[it.to]==-1L }.forEach {
            parent[it.to] = v
            dist[it.to] = dist[v] + it.cost
            dfs(it.to, parent, dist)
        }
    }
}


Measured memory_bytes: 145376
#include <bits/stdc++.h>
#define sort stable_sort
using namespace std; 

int _; 

int ans;
string s;

int main()
{ 
	//for(scanf("%d",&_);_;_--)
	cin >> s;
	for(int i=0;i<s.size();i++)
		if(s[i] == 'R')
			ans++;
	if(ans == 2 && s[1] != 'R')
		ans--;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3636
/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;
const int MAX=1e5+5;
vector<int> vec2;
bool isPal(string s)
{
	bool ret=true;
	int beg=0;
	int en=s.length()-1;
	while(beg<=en)
	{
		if(s[beg]==s[en])
		{
			beg++;
			en--;
		}
		else
		{
			ret=false;
			break;
		}
	}
	return ret;
}

int main() 
{
	string s;
	cin>>s;
	string st="";
	vec2.push_back(0);
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!='x')
		{
			st+=s[i];
			vec2.push_back(i+1);
		}
	}
	vec2.push_back(s.length()+1);
	/*for(int i=0;i<vec2.size();i++)
	{
		printf("%d\n",vec2[i]);
	}*/
	if(isPal(st))
	{	
		int sz=vec2.size();
		int lft,rgt;
		int ans=0;
		if(sz%2)
		{
			lft=rgt=(sz/2);
		}
		else
		{
			lft=(sz/2)-1;
			rgt=(sz/2);
		}
		while(lft>0&&rgt<sz)
		{
			ans+=abs(vec2[lft]-vec2[lft-1]-vec2[rgt+1]+vec2[rgt]);
			lft--;
			rgt++;
			//printf("%d\n",ans);
		}
		printf("%d\n",ans);
	}
	else
	{
		printf("-1\n");
	}
	return 0;
}
//0 2 3 5 6

Measured memory_bytes: 1148
def solve(d,c,s,k):
    last=[0]*27
    srate=[]
    ans=[]
    for i in range(1,d+1):
        a=0
        for j in range(1,27):
            a-=c[j-1]*(i-last[j])
        pa=0
        mlast=[0]*2
        for t in range(1,27):
            if s[i-1][t-1]+c[t-1]*(min(k*(k-1)/2,(366-d)*((366-d)-1)/2))>pa:
                mlast=[t,i]
                pa=s[i-1][t-1]+c[t-1]*(i-last[t])
        a+=pa
        last[mlast[0]]=mlast[1]           
        ans.append(mlast[0])
        srate.append(a)
    return ans,srate

def main():
    d=int(input())
    c=list(map(int,input().split()))
    s=[list(map(int,input().split())) for _ in range(d)]
    ans,srate=solve(d,c,s,13)
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> v(k, 0);
    ll ans = 0;
    for (int i = 1; i <= n; i++) v[i%k]++;
    for (int a = 1; a <= n; a++) {
        int b = (k - a) % k;
        if (b < 0) b += k;
        if (b * 2 % k != 0) continue;
        ans += v[b] * v[b];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int a[4][4],n,b[20];
    bool c[3][3];
    for(int i=0;i<3;i++){
        for(int j = 0;j<3;j++){
            c[i][j] = false;
        }
    }
    for(int i=0;i<3;i++){
        for(int j = 0;j<3;j++){
            cin >> a[i][j];
        }
    }

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> b[i];
        for(int j=0;j<3;j++){
            for(int k = 0;k<3;k++){
                if(b[i] == a[j][k]) c[j][k] = true;
            }
        }
    }
    bool flag = false;
    for(int i=0;i<3;i++){
        if(c[i][0]&&c[i][1]&&c[i][2])flag = true;
    }
    for(int i=0;i<3;i++){
        if(c[0][i]&&c[1][i]&&c[2][i])flag = true;
    }
    if(c[0][0]&&c[1][1]&&c[2][2])flag = true;
    if(c[0][2]&&c[1][1]&&c[2][0])flag =true;
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

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

int main(){
    int a, b, c, x, ans = 0;
    cin >> a >> b >> c >> x;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(500*i+100*j+50*k==x)ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int x[n];
    rep(i, 0, n) {
        cin >> x[i];
    }
    int ans = INF;
    rep(i, 0, 101) {
        int sum = 0;
        rep(j, 0, n) {
            sum += (x[j] - i) * (x[j] - i);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

std::int64_t run()
{
	int N;
	std::cin >> N;
	std::vector<std::multiset<std::pair<std::int64_t, std::int64_t>, std::greater<>>> left(N), right(N);
	std::int64_t sum = 0;
	for (auto _ : boost::irange(N))
	{
		int K;
		std::int64_t L, R;
		std::cin >> K >> L >> R;
		if (L == R || K == N)
		{
			sum += L;
		}
		else
		{
			if (L > R)
			{
				left[K - 1].emplace(L - R, R);
			}
			else
			{
				right[N - K - 1].emplace(R - L, L);
			}
		}
	}
	lib::p_queue<std::int64_t> queue;
	for (auto i : boost::irange(N))
	{
		for (auto [diff, base] : left[i])
		{
			sum += base;
			queue.emplace(diff);
		}
		while (i + 1 < queue.size())
		{
			queue.pop();
		}
	}
	while (queue.size())
	{
		sum += queue.top();
		queue.pop();
	}
	for (auto i : boost::irange(N))
	{
		for (auto [diff, base] : right[i])
		{
			sum += base;
			queue.emplace(diff);
		}
		while (i + 1 < queue.size())
		{
			queue.pop();
		}
	}
	while (queue.size())
	{
		sum += queue.top();
		queue.pop();
	}
	return sum;
}

void Main()
{
	int T;
	std::cin >> T;
	for (auto _ : boost::irange(T))
	{
		std::cout << run() << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 35336
#include<stdio.h>
#include<math.h>
int main()
{
    int t,n,s,i,cnt,ck ;
    scanf("%d",&t);
    cnt=0;
    while(t--)
    {

        scanf("%d",&n);
        if(n==2||n==3)
        {
            cnt++;
        }
        else
        {
            s=sqrt(n);
            ck=0;
            for(i=2; i<=s; i++)
            {
                if(n%i==0)
                {
                    ck=1;
                }
            }
            if(ck==0)
            {
                cnt++;
            }
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 1800
#include <iostream>
#include <string>

using namespace std;

int a, b;
const int alpha[] = {1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25};

inline char affine(char ch)
{
    return (alpha[a] * ch + b) % 26 + 'a';
}

void solve()
{
    string str;

    getline(cin, str);
    str += ' ';
    string::size_type pos1, pos2;
    bool flag = false;

    for (pos2 = str.find(' '), pos1 = 0; pos2 != string::npos;
         pos1 = pos2 + 1, pos2 = str.find(' ', pos1)) {
        if (str.substr(pos1, pos2 - pos1).size() == 4) {
            string tmp = str.substr(pos1, pos2 - pos1);

            for (int ai = 0; ai < 12; ai++) {
                for (int bi = 1; bi < 26; bi++) {
                    string cmp = "";
                    a = ai;
                    b = bi;

                    for (int i = 0; i < tmp.size(); i++) 
                        cmp.push_back(affine(tmp[i]));
                    if (cmp == "this" || cmp == "that") {
                        flag = true;
                        break;
                    }
                    if (flag)
                        break;
                }
                if (flag)
                    break;
            }
        }
        if (flag)
            break;
    }

    for (int i = 0; i < str.size() - 1; i++) {
        if (isalpha(str[i]))
            cout << affine(str[i]);
        else
            cout << str[i];
    }
    cout << endl;
}


int main()
{
    int n;
    
    cin >> n;
    cin.ignore();
    while (n--) {
        solve();
    }

    return 0;
}

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

int main(){

	int a, b;

	cin >> a >> b;

	if(a > b){
		cout << "a > b" << endl;
	}else if(b > a){
		cout << "a < b" << endl;
	}else{
		cout << "a == b" << endl;
	}

	return 0;

}



Measured memory_bytes: 3080
#include <iostream>

using namespace std;

int main()
{
	char c;
	string vo("aiueo");
	
	cin >> c;
	
	if ((int)vo.find(c) != -1) {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
	
	return (0);
}

Measured memory_bytes: 256
A,V = map(int, input().split())
B,W = map(int, input().split())
T = int(input())

if A == B:
    print('YES')
    exit()
if W >= V:
    print('NO')
    exit()

if (abs(A-B)+(V-W)-1)//(V-W) <= T:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 61796
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#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 RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	set<int> st;
	int n, a;
	cin >> n;
	while (n--) {
		cin >> a;
		st.insert(a);
	}

	cout << st.size() << endl;

	return 0;
}

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

int main() {

long A,B,C,D;
cin>>A>>B>>C>>D;

while(A>0||C>0){
  C-=B;
  if(C<=0){
    cout<<"Yes"<<endl;
    return 0;
  }
  A-=D;
  if(A<=0){
    cout<<"No"<<endl;
    return 0;
  }
}

}


Measured memory_bytes: 3636
object Main extends App {
  @scala.annotation.tailrec
  def loop(ints: Seq[Int], acc: Seq[Int], indecies: Seq[Int]): Seq[Int] =
    ints match {
      case Seq() => indecies
      case x :: xs => loop(xs, acc :+ x, indecies :+ (x - acc.count(_ < x) - 1))
    }
  def countOrder(ints: Seq[Int], factorials: Seq[Int]): Int =
    loop(ints, Vector.empty, Vector.empty)
      .zip(factorials)
      .map {
        case (index, factorial) => index * factorial
      }
      .sum
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val P, Q = List.fill(n)(sc.nextInt())
  val factorials: Seq[Int] = (2 until n).scanLeft(1)(_ * _).reverse
  println(math.abs(countOrder(P, factorials) - countOrder(Q, factorials)))
}


Measured memory_bytes: 55660
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <climits>
#include <map>
#include <math.h>
using namespace std;

int main(void)
{
    string str;
    cin >> str;

    if (str[1] == str[2])
    {
        if (str[0] == str[1] || str[1] == str[3])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string str;
  cin>>str;
  string ans;
  for(int i=0;i<str.size();i++)
  {	
    if(str[i]=='?')
    {
      ans+="D";
    }
    else{
    	ans+=str[i];
    }
  }	
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3904
init=input().split()
num=int(init[0])
snacks=int(init[1])
check=[]
 
for i in range(snacks):
  sNum=int(input())
  if sNum>1:
    whos=input().split()
    for j in range(sNum):
      check.append(whos[j])
  else:
    who=input()
    check.append(who)
   
count=0
for i in range(1,num+1):
  if str(i) not in check:
    count=count+1
print(count)

Measured memory_bytes: 9348
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main()
{
	int n,ans=0ll;
	cin>>n;
	if(n==1)
	{
		cout<<0<<endl;
		return 0;
	}
	
	for(int i=2;i*i<=n;i++)
		if(n%i==0)
		{
			int pos=0;
			while(n%i==0)
			{
				n=n/i;
				pos++;
			}
			
			int x=sqrt(pos*2);
			if(x*(x+1)>pos*2)
				x--;
			
			ans+=x;
		}
	
	if(n>1)
		ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
using namespace std;

int n, c;
string a;
int main()
{
	int i;
	cin >> n >> a;
	c = 1;
	for (i = 1; i < n; i++) {
		if (a[i] != a[i - 1]) c++;
	}
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 512
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
ans =0
for i in range(n):
    if i<k:
        if t[i] =='r':
            ans+=p
        elif t[i] =='s':
            ans+=r
        else :
            ans+=s
    else:
        if t[i] =='r' and t[i-k]!='r':
            ans+=p
        elif t[i] =='s' and t[i-k]!='s':
            ans+=r
        elif t[i] =='p' and t[i-k]!='p':
            ans+=s
        else:
            t[i]='a'
            continue
print(ans)


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

int main() {
  int N;
  cin>>N;
  for (int i=0;i<N;i++){
    string S;
    cin>>S;
    if (S=="Y"){
      cout<<"Four"<<endl;
      break;
    }
    if (i==N-1 && S!="Y"){
      cout<<"Three"<<endl;
    }
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
    #define M_PI 3.14159265358979323846
    int main()
    {
     // clock_t begin = clock();
     // #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
     // #endif
   tani_nachi_ke  
    
  int n,W;
  cin>>n>>W;
  int w[n+1],value[n+1];
  for(int i=1; i<=n; i++)cin>>w[i]>>value[i];
  long long dp[W+1][n+1];
  memset(dp,0,sizeof(dp));
  for(int i=1; i<=W; i++)
  {
    for(int j=1; j<=n; j++)
    {
      if(w[j]<=i)
      {
        dp[i][j]=max(dp[i-w[j]][j-1]+(long long)value[j],dp[i][j-1]);
      }
      else dp[i][j]=dp[i][j-1];
    }
  }
  // for(int i=1; i<=W; i++)
  // {
  //   for(int j=1; j<=n; j++)cout<<dp[i][j]<<" ";
  //   cout<<endl;
  // }
  cout<<dp[W][n]<<endl;

    
  
    // #ifndef ONLINE_JUDGE 
    // clock_t end = clock();
    // cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
    // #endif 
    // return 0;
}






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

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

int main()
{
    int x; cin >> x;
    while(true)
    {
        if(x%2 != 0)
        {
            bool ok = true;
            for(int i = 3; i < x; i += 2)
            {
                if(x%i == 0)
                {
                    ok = false;
                    break;
                }
            }
            if(ok)
                break;
            else
                x += 2;
        }
        else if(x == 2)
            break;
        else
            ++x;
    }
    pri(x);
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 998244353;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


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

	std::vector<mint> combn(n+1);
	mint comb = 1;
	rep(i,n+1) {
		combn[i]=comb;
		if(i==n) break;
		comb*=mint(n-i);
		comb/=mint(i+1);
	}

	mint count = 0;
	for(int sa=0;sa<=n;sa++) {
		int x = k-sa*a;
		if(x>=0 && x%b==0) {
			int sb = x/b;
			if(sb<=n) count+=combn[sa]*combn[sb];
		}
	}

	print(count);

	return 0;
}


Measured memory_bytes: 2688
H, W = map(int, input().split())
A = []
for _ in range(H):
  A.append(input())
  
all_flag = True
for i in range(H):
  for j in range(W):
    if A[i][j] == '.':
      flag = True
    else:
      flag = False
      if i > 0:
        if A[i-1][j] == '#':
          flag = True
      if i < H-1:
        if A[i+1][j] == '#':
          flag = True
      if j > 0:
        if A[i][j-1] == '#':
          flag = True
      if j < W-1:
        if A[i][j+1] == '#':
          flag = True
    if not flag:
      all_flag = False
      break
  if not all_flag:
    break
if all_flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,W;
    cin>>n>>W;

    int wt[n+1];
    int val[n+1];

    for(int i=1;i<=n;i++){
        cin>>wt[i]>>val[i];
    }

    long long int dp[n+1][W+1];

    for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }else{

                if(wt[i]>j){
                    dp[i][j]=dp[i-1][j];
                }else{
                    dp[i][j]=max(dp[i-1][j],val[i]+dp[i-1][j-wt[i]]);
                }

            }
        }
    }

    cout<<dp[n][W];
    
}


Measured memory_bytes: 82316
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 A, B;
  cin >> A >> B;

  i64 g;
  g = __gcd(A, B);

  i64 ans = 1;
  for(i64 i = 2; i*i <= g; i++){
    if(!(g % i)){
      ans++;
      while(!(g % i)){
        g /= i;
      }
    }
  }

  if(g>1) ans++;

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

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  int ans = 0;
  srep(k,1,N+1) {
    if(k%2==0) continue;
    int cnt = 0;
    srep(i,1,k+1) {
      if(k%i==0) cnt++;
    }
    if(cnt==8) ans++;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 764
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<ll,ll> mp;
    ll ans = 0;
    REP(i,n){
        ll a;
        cin >> a;
        mp[a]++;
    }
    set<ll> st;
    for(auto p : mp){
        
        if((ll)st.size()== 0){
            if(p.se==1){
                ans++;
            }
        }else{
            if(p.se==1){
                bool f = true;
                ll now = p.fi;
                for(ll i =1;i*i<=now;++i){
                    if(now%i==0){
                        auto itr = st.find(i);
                        if(itr!=st.end()){
                            f = false;
                            break;
                        }
                        auto itr2 = st.find(now/i);
                        if(itr2!=st.end()){
                            f = false;
                            break;
                        }
                    }
                }
                if(f){
                    ans++;
                }
            }
        }
        st.insert(p.fi);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 25448
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: i64,
    }
    let mut n = n;
    let mut m = -1;
    for _ in 0..4 {
        if m == n % 10 {
            println!("Bad");
            return;
        }
        m = n % 10;
        n /= 10;
    }
    println!("Good");
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"

typedef long long int lli;

using namespace std;

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

	int N,  cunt = 1,res=999999999;
	cin >> N;
	vector<int> ver(N);

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

	while (cunt < N) {
		int A = 0, B = 0;
		for (int i = 0; i < N; i++)
		{
			if (i > cunt) {
				A += ver[i];
			}
			else {
				B += ver[i];
			}
		}
		res = min(res, abs(A - B));
		cunt++;
	}
	
	cout << res << endl;
}

Measured memory_bytes: 256
#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 ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll n, k;
  cin >> n >> k;
  ll r, s, p;
  cin >> r >> s >> p;
  map<char, ll> mp;
  mp['r'] = p, mp['s'] = r, mp['p'] = s;
  string t;
  cin >> t;
  vector<char> prev(k);
  ll ans = 0;
  REP(i, t.length()) {
    if (i < k) {
      ans += mp[t[i]];
      prev[i] = t[i];
    } else {
      if (prev[i % k] == t[i]) {
        prev[i % k] = 'n';
        continue;
      } else {
        ans += mp[t[i]];
        prev[i % k] = t[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<int> A(n),B(m);
    for(int i=0;i<n;i++) cin >> A.at(i);
    for(int i=0;i<m;i++) cin >> B.at(i);
    int i,j,sum=0;
    for(i=0; i<n; i++){
        sum += A.at(i);
        if(sum>k){
            sum -= A.at(i);
            break;
        }
    //i冊の本が読める
    }
    int maxij = i;
    for(j=0; j<m; j++){
        sum += B.at(j);
        while(sum > k && i > 0){
            i--;
            sum -= A.at(i);
        }
        if(sum > k){
            break;
        }
        
        if(maxij < i+j + 1){
            maxij = i + j + 1;
        }
        
    }

    cout << maxij << endl;
}


Measured memory_bytes: 4732
#include <iostream>

using namespace std;
int n,k,i,q,a[101],d[100009];
int main()
{
    cin>>n>>k;
       for(i=1; i<=n; i++)
           cin>>a[i];
    d[0]=false;
    for(q=1; q<=k; q++)
    {
        for(i=1; i<=n; i++)
        {
            if(a[i]<=q)
                if(d[q-a[i]]==false)d[q]=true;
        }
    }
    //cout<<d[1]<<" ";
    if(d[k]==true)cout<<"First";
    else cout<<"Second";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  rep(i,0,N-2)rep(j,i+1,N-1)rep(k,j+1,N){
    if(P[i]+P[j]-P[k]>0)sum++;
    else break;
    }
  Out(sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  lint h, w;
  cin >> h >> w;
  lint sum = w * (h / 2);
  if (h % 2) sum += (w + 1) / 2;
  if (h == 1 || w == 1) sum = 1;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <valarray>
#include <array>

using namespace std;

int main() {
	int n, d, x, ans, temp;
	cin >> n >> d >> x;
	d--;
	ans = x;
	for (int i = 0; i < n; i++) {
		cin >> temp;
		ans += (d / temp + 1);
	}
	cout << ans << endl;
}

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

bool solve(){
    int n;
    cin >> n;
    if(n == 0) return true;
    vector<pair<string,int> > ls;
    for(int i=0;i<n;i++){
        string s, t;
        cin >> s >> t;
        ls.emplace_back(make_pair(s,1));
        ls.emplace_back(make_pair(t,-1));
    }
    sort(ls.begin(), ls.end());
    int cnt = 0, ans = 0;
    for(auto p : ls){
        cnt += p.second;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return false;
}

int main(){
    while(!solve());
    return 0;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int X, Y;
    std::cin >> X >> Y;
    std::cout << X + Y / 2 << std::endl;

    return 0;
}


Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  for i in range(k):
    nxtl=[0]*n

    # 実験 n=100 k=100 l=[0]*100 で回すとi=13で全部行き渡るようになった
    # f=False
    # for a in range(n):
    #   if l[a]<n-1:
    #     f=True
    # if not f:
    #   return i

    ff=True
    for j in range(n):
      left=j-l[j]
      if left<0:
        left=0
      else:
        ff=False
      nxtl[left]+=1

      right=j+l[j]+1
      if right<n:
        nxtl[right]-=1
        ff=False

    for i in range(1,n):
      nxtl[i]+=nxtl[i-1]

    if ff:
      return ' '.join(str(x) for x in l)

    l=nxtl

    # print(l)

  return ' '.join(str(x) for x in l)

# main()
print(main())


Measured memory_bytes: 137716
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    ios::sync_with_stdio(false);
    int n,ans=INT_MIN;
    cin>>n;
    vector<vector<int>>shop(n,vector<int>(10));
    vector<vector<int>>bene(n,vector<int>(11));
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin>>shop[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++){
            cin>>bene[i][j];
        }
    }
    for(int bit=1;bit<(1<<10);bit++){
        int tmp=0;
        vector<int>a;
        for(int i=0;i<10;i++){
            if(bit&(1<<i)) a.push_back(1);
            else a.push_back(0);
        }
        for(int i=0;i<n;i++){
            int c=0;
            for(int j=0;j<10;j++){
                if(a[j]&shop[i][j]) c++;
            }
            tmp+=bene[i][c];
        }
        if(ans<tmp) ans=tmp;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("02")
#define ll long long
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
struct ios{
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline ios & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
int c[4][4];
int main(){
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++) inc>>c[i][j];
	puts((c[1][2]+c[2][3]+c[3][1]+c[1][3]+c[2][1]+c[3][2]==(c[1][1]+c[2][2]+c[3][3])*2)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string s;
    cin >> s;
    int a[26]={0};
    for (int i=0;i<s.length();i++){
	int x=s[i]-97;
	a[x]++;
    }

    for (int i=0;i<26;i++){
	if (a[i] == 0){
	    char c=i+97;
	    cout << c << endl;
	    return 0;
	}
    }

    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

def main():

    S = input()

    week = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']

    for i, name in enumerate(week):
        if name == S:
            ans = 7 - i

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9020