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

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
//is(string &s){int c;
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo

int main() {
	for (int n; (n = in());) {
		int c = 0;
		for (int i = 1; i <= log(n) / log(5); i++)
			c += n / (int) pow(5, i);
		out(c, '\n');
	}
}


Measured memory_bytes: 2716
#include <iostream>

using namespace std;
long long a,b,nr,i,j,m,k,div[100001],m1,d;

int main()
{
    cin>>a>>b;
    m=min(a,b);
    m1=max(a,b);
    d=2;
    div[++k]=1;
    while(d*d<=m&&m!=1)
    {
        int p=0;
        while(m%d==0)
            m/=d,p++;
        if(p)div[++k]=d;
        d++;
    }
    if(m!=1)div[++k]=m;
    for(i=1;i<=k;i++)
        if(m1%div[i]==0)nr++;
        cout<<nr;
    return 0;
}


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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int K = 38, N = K * (K - 1) + 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

int f[N + 1][K + 1];

int main() {
	reg id = 1;
	pr1(N), pr2(K);
	fo(i, 1, K) {
		pr1(1);
		fo(j, 0, K - 2) f[i][j] = ++id, pr1(f[i][j]);
		puts("");
	} fo(i, 0, K - 2) fo(j, 0, K - 2) {
		pr1(f[1][i]);
		fo(h, 2, K) pr1(f[h][(j + i * h) % (K - 1)]);
		puts("");
	}
	return 0;
}



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

int main() {

    int N, K;
    cin >> N >> K;

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

    sort(p, p+N);
    int ans = 0;
    for (int i = 0; i < K; i++) {
        ans += p[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
n = int(input())
dic = {input() : 1}
for i in range(1, n):
  str = input()
  if str in dic:
    num = dic[str]
    num = num + 1
    dic[str] = num
  else:
    dic[str] = 1

ans_list = []

for k in dic:
  ans_list.append(dic[k])

list.sort(ans_list, reverse = True)
max = ans_list[0]

ans = []
for k in dic:
  if dic[k] == max:
    ans.append(k)
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Measured memory_bytes: 33180
a=[int(input()) for i in range(5)]
p=[i%10 for i in a]
d=sorted(list(zip(p,a)))
q=-1
for x in d:
    if x[0]!=0:
        q=x[0]
        break
if q==-1:
    print(sum(a))
    exit(0)
s=[]
for x in d:
    if x[0]!=0:
        s.append((x[1]//10+1)*10)
    else:s.append(x[1])
print(sum(s)-10+q)

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

using namespace std;



int main() {
	int N,K;
	cin >> N >> K;
	vector<int>d(K);
	//vector<vector<int> > A(K, vector<int>(N, 0));
	vector<bool>Food(N,false);
	for (int n = 0;n < K;++n) {
		cin >> d[n];
		for (int m = 0;m<d[n];++m) {
			int l;
			cin >> l;
			Food[l - 1] = true;
		}
	}
	int nAns = 0;
	for (int n = 0;n < N;++n) {
		if (false == Food[n]) {
			++nAns;
		}
	}
	cout << nAns << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#define MAX 100000
int main(){
  int S[MAX],T[MAX];
  int i,j,cnt=0,n,q;
  int l,m,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&T[i]);
  
  for(i=0;i<q;i++){
    l=0;
    r=n-1;
    while(l<r){
      m=(l+r)/2;
      if(S[m]==T[i]||S[l]==T[i]||S[r]==T[i]){
	cnt++;
	break;
      }else if(S[m]<T[i]){
	l=m+1;
      }else{
	r=m;
      }
    }
  }

  printf("%d\n",cnt);

  return 0;
}

Measured memory_bytes: 1192
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
vector<int>a[100001];

	int c;
	int n;
	int x;
	int dfs(int v){
	priority_queue<int>pq;
		int re=0;
		int vv;
		for (int i = 0; i < a[v].size(); i++){
			pq.push(dfs(a[v][i]));
		}
		for (int i = 1; i <= a[v].size()&&pq.empty()==0; i++){
			vv = pq.top();	
			pq.pop();
			if (re < vv + i)re = vv + i;
		}

	return re;
}
int main(void){
	
	c = 0;
	scanf("%d", &n);
	for (int i = 1; i < n; i++){
		scanf("%d", &x);
		x--;
		a[x].push_back(i);
	}
	c = dfs(0);
	printf("%d\n", c);

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
using ll = long long;

using namespace std;
int main(){
	vector<int>Term(4);
	int num;
	cin >> num;
	rep(i, 4) {
		Term[3-i] = num % 10;
		num /= 10;
	}
	string ans = to_string(Term[0]);
	for (int tmp = 0; tmp < (1 << 3); tmp++) {	//演算子が入りうるすべての場所をbitで表現
		num = Term[0];
		rep(i, 3) {
			if (tmp & (4 >> i)) {
				num += Term[i+1] * (-1);
			}
			else {
				num += Term[i+1];
			}
		}
		if (num == 7) {
			rep(i, 3) {
				if (tmp & (4 >> i)) {
					ans += "-" + to_string(Term[i+1]);
				}
				else {
					ans += "+" + to_string(Term[i+1]);
				}
			}
			break;
		}
	}
	cout << ans << "=7" << endl;
}


Measured memory_bytes: 256
iranai = [int(i) for i in input().split()]
iru = [[int(i) for i in input().split()] for i in range(iranai[0])]
mikitani = []
son = []
num = 0
mikicount = 0
for i in range(iranai[0]):
    for i2 in range(iranai[1]):
        num += iru[i][i2]
    mikitani.append(num)
    num = 0

for i in range(iranai[1]):
    for i2 in range(iranai[0]):
        num += iru[i2][i]
    son.append(num)
    num = 0

for i in range(iranai[0]):
    for i2 in range(iranai[1]):
        print(iru[i][i2],end=" ")
        if i2 == iranai[1]-1:
            print(mikitani[i])
    mikicount += mikitani[i]
son.append(mikicount)

for i in range(len(son)):
    if i == len(son)-1:
        print(son[i])
    else:
        print(son[i],end=" ")

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

list_ans = []

for j in range(1,n):
    stepping_stone = a[j-1] - a[j]
    if stepping_stone > 0:
        list_ans.append(stepping_stone)
        a[j] += stepping_stone
    else:
        list_ans.append(0)

ans = sum(list_ans)
print(ans)

Measured memory_bytes: 32104
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    
    vector<vector<int> > cnt(26, vector<int>(N+1, 0));
    for(int n=0; n<N; n++) {
        cnt[(int)S[n]-'a'][n+1]++;
        for(int i=0; i<26; i++) {
            cnt[i][n+1] += cnt[i][n];
        }
    }
    
    int ans=0;
    for(int n=1; n<N; n++) {
        int ta=0;
        for(int i=0; i<26; i++) {
            if(cnt[i][n]-cnt[i][0]!=0 && cnt[i][N]-cnt[i][n]!=0) {
                ta++;
            }
        }
        if(ta>ans) {
            ans = ta;
        }
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

int main(void){
    //char buf[128];
    //scanf(%s,&buf)
    std::string s;
    std:: cin >> s;
    //printf("%s hogehoge");
    if((s[2] == s[3]) && (s[4] == s[5])){
    std:: cout << "Yes\n";
    }
    else
    {
     std:: cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

   

int main(){
lint N,K;
cin>>N>>K;
pair<lint,lint> x[N];
rep(i,N){
lint f,g;
cin>>f>>g;
x[i]=make_pair(f,g);
}
lint count=0;
sort(x,x+N);
rep(i,N){
    lint h,j;
    tie(h,j)=x[i];
    count+=j;
    if(count>=K){
        cout<<h;
        return 0;
    }
}
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>


int main ()
{
    long long int x, k, d, ans, div, q;
    scanf("%lld %lld %lld", &x, &k, &d);
    // x > 0
    if(x<0) x = -x;
    
    div = x / d;
    q = x % d;

    if ( k < div ) ans = x - k * d;
    else if ( (k - div) % 2 == 1) ans = d - q;
    else ans = q;

    printf("%lld\n", ans);

    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int> > A(n, vector<int>(m, 0));
    vector<int> b(m);
    for (int i=0; i<n; i++){
      for (int j=0; j<m;j++){
        cin >> A.at(i).at(j);
      }
    }
    for (int i=0; i<m; i++) cin >> b.at(i);

    for (int i=0; i<n; i++){
      int sum=0;
      for (int j=0; j<m; j++){
        sum += A.at(i).at(j) * b.at(j);
      }
      cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip().decode('utf-8')

a,b,c,d = sorted(S)

answer = 'Yes' if (a==b) and (b!=c) and (c==d) else 'No'
print(answer)

Measured memory_bytes: 3060
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    n, k = get_li()
    if k == 0:
        print(n * (n - 1) // 2)
        for i in range(n):
            for j in range(i + 1, n):
                print(i + 1, j + 1)
        return
    if k > (n-1) * (n-2) // 2:
        print(-1)
        return
    if n == 2:
        print(-1)
        return
    edges = []
    for i in range(1, n):
        edges.append((0, i))
    n_pair = (n-1) * (n-2) // 2
    for i in range(1, n):
        for j in range(i+1, n):
            if n_pair == k:
                break
            edges.append((i, j))
            n_pair -= 1
        if n_pair == k:
            break
    print(len(edges))
    for i, j in edges:
        print(i + 1, j + 1)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()


Measured memory_bytes: 70508
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}
int pop() {
	top--;
	return S[top+1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	while( scanf("%s", s) != EOF ) {
		if( s[0] == '+' ) {
		a = pop();
		b = pop();
		push(a + b);
		} else if ( s[0] == '-' ) {
		b = pop();
		a = pop();
		push(a - b);
		} else if ( s[0] == '*' ) {
		a = pop();
		b = pop();
		push(a * b);
		} else {
		push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

struct mint {
    constexpr static int mod = 1000000007;
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    mint tot = 0;
    rep(i, n) tot += a[i];
    mint ans = 0;
    rep(i, n) {
        tot -= a[i];
        ans += tot * a[i];
    }
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 4784
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>


using namespace std;
#define MAX 100000

int main(){
    int x1, x2, x3, x4;
    int y1, y2, y3, y4;

    cin >> x1 >> y1 >> x2 >> y2;

    int difx = x1 - x2;
    int dify = y1 - y2;
    x3 = x2 + dify;
    x4 = x3 + difx;
    y3 = y2 - difx;
    y4 = y3 + dify;

    cout << x3 << " " << y3 << " " << x4 << " " << y4;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
/*using P = pair<int, int>;*/
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    str s, t; cin >> s >> t;
    bool same = true;
    rep(i, s.size()){
        if(s[i] != t[i]) same = false;
    }
    if (same) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a[MAXX];

int main()
{
    _FastIO;
    cin >> a[0] >> a[1] >> a[2];
    sort(a , a + 3);
    cout << (a[0] * a[1]) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}


void solve(){
  int N; cin >> N;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  ll ans = 1;
  rep(i,N) ans = lcm(ans,A[i]);
  cout << ans << endl;
}

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


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  set<int>S;
  for(int i=0;i<3;i++){
    int tmp; cin >> tmp;
    S.insert(tmp);
  }
  if(S.size()==2) cout<< "Yes" <<endl;
  else cout<< "No"<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func pow(base int, exponent int) int {
	result := 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			result %= 998244353
		}
		exponent >>= 1
		base *= base
		base %= 998244353
	}
	return result
}

func main() {
	N := readInt()
	D := readInts(N)

	if D[0] != 0 {
		fmt.Println(0)
		return
	}

	c := map[int]int{}
	maxD := 0
	for _, i := range D {
		c[i]++
		if i > maxD {
			maxD = i
		}
	}

	if c[0] != 1 {
		fmt.Println(0)
		return
	}

	result := 1
	for i := 1; i <= maxD; i++ {
		if _, ok := c[i]; !ok {
			fmt.Println(0)
			return
		}
		result *= pow(c[i-1], c[i])
		result %= 998244353
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}


Measured memory_bytes: 10708
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
string s[55];
int t[55];
int main(){
        int n;
        while(cin>>n){
                F(i,0,n) cin>>s[i]>>t[i];
                string stop;
                int index;
                cin>>stop;
                F(i,0,n) if(s[i]==stop){
                        index=i+1;
                        break;
                }
                int ans=0;
                F(i,index,n) ans+=t[i];
                cout<<ans<<"\n";
        }
}

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

int main(void) {
  int n,m;
  cin >> n >> m;

  vector<int>x(m);
  for (int i = 0; i < m; i++) {
    cin >> x[i];
  }

  sort(x.begin(), x.end());
    
  vector<int>l(m-1);
  for (int i = 0; i < m-1; i++) {
    l[i] = x[i+1]-x[i];
  }

  sort(l.begin(), l.end(), greater<int>());

  int res=0;
  for (int i = n-1; i < m-1; i++) {
    res+=l[i];
  }

  cout << res << endl;
  
  return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



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

    vector<ll> a(n), b(n);
    ll t = 0;

    for(auto& i : a){
        cin >> i;
        t -= i;
    }
    for(auto& i : b){
        cin >> i;
        t += i;
    }

    if(t < 0){
        cout << "No" << endl;
        return 0;
    }

    pair<ll,ll> cnt(0,0);

    REP(i, n){
        if(a[i] < b[i]){
            cnt.first += Div(b[i] - a[i], 2LL);
            cnt.second += (b[i] - a[i]) % 2;
        }else{
            cnt.second += a[i] - b[i];
        }
    }

    if(cnt.first <= t && cnt.second <= t && (t - cnt.first)*2 == t - cnt.second){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 5e5 + 1000,mod = 998244353;
int n,k,Ans;
ll jc[N],inv[N],jcinv[N];
ll C(int x,int y){if(y < 0 || y > x) return 0; return jc[x] * jcinv[y] % mod * jcinv[x - y] % mod;}
int main()
{
	n = read(); k = read();
	if(k < n) {puts("0"); return 0;}
	jc[0] = jc[1] = inv[0] = inv[1] = jcinv[0] = jcinv[1] = 1;
	for(int i = 2;i <= k;i ++)
	{
		jc[i] = jc[i - 1] * i % mod;
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		jcinv[i] = jcinv[i - 1] * inv[i] % mod;
	}
	for(int R = 0,B;R <= k;R ++)
	{
		B = k - R; if(R < B) continue;
		if(R == B) B --;
		Ans = (Ans + C(R + B,R) - C(R + B,2 * R - n + 1) + mod) % mod;
	}
	cout << Ans << "\n";
	return 0;
}

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

using namespace std;
using LL = long long;
using VI = vector<int>;
using PI = pair<int, int>;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (int k = 0; k < n; k++) {
			cout << (k != 0 ? " " : "") << a[k];
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  ll n,m; cin >> n >> m;
  if(n>m)swap(n,m);
  ll ans = 0;
  if (n == 1 && m == 1) {
    ans = 1;
  } else if (n==1 && m!=1) {
    ans = m-2;
  } else {
    ans = (n-2)*(m-2);
  }
  COUT(ans);
  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  string S, T;
  cin >> S >> T;

  bool check = false;
  for (int i = 0; i < 26; ++i) {
    S.push_back('a' + i);
    check |= S == T;
    S.pop_back();
  }

  cout << (check?"Yes":"No") << endl;

  return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
using namespace std;
int main(){
    int a,b,c;

    while(scanf("%d",&a)!=EOF){
        int cnt = 0;
        int card[] = {0,1,2,3,4,5,6,7,8,9,10};
        scanf("%d%d",&b,&c);

        card[a] = -1;
        card[b] = -1;
        card[c] = -1;

        int ans=0;

        for(int i = 1;i <= 10; i++){
            ans = a+b;
            if(card[i] == -1)continue;
            else{
                ans += card[i];
                if(ans <= 20)cnt++;
            }
        }
        if(cnt > 3)printf("YES\n");
        else printf("NO\n");
        cnt = 0;
    }
    return 0;
}

Measured memory_bytes: 1008
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
       int a, b;

       scanf("%d %d", &a, &b );

       if( a > b * 2 )
              printf("%d\n", a - b * 2);
       else 
              puts("0");
      
       return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N, A[100];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	bool ans = true;

	for (int i = 0; i < N; i++)
	{
		if (A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0))
		{
			ans = false;
			break;
		}
	}

	if (ans) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
		 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s; 
	bool a = false;
	cin>>s;
	for(int i=0; i<3; i++)
	{
		if(s[i] == '7')
		{
			a = true;
		}
	}
	if(a)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}


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

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut ans : f64 = 0.0;

    for i in 0..n{
        let mut x = i+1;
        let mut cnt = 0;

        while x < k{
            x *= 2;
            cnt += 1
        }

        let mut p : f64 = 1.0;
        for _ in 0..cnt{
            p /= 2.0;
        }

        ans += p;
    }

    ans /= n as f64;
    println!("{:.10}",ans);

}


Measured memory_bytes: 2164
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,t,sum,x,y;
	cin>>a>>b>>c;
	if(b>a)
	{
		t=a;
		a=b;
		b=t;
	}
	if(c>a)
	{
		t=a;
		a=c;
		c=t;
	}
	if((b+c)%2==0)
		printf("%d",(2*a-b-c)/2);
	else
		printf("%d",(2*(a+1)-b-c-1)/2+1);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
Ans = 0
i = N - 1
j = i - 1
k = 0

newL = sorted(L)

while i >= 2:
  while j >= 1:
    min = newL[i] - newL[j]
    
    if k > j-1:
      break
    
    while k <= j - 1:

      if newL[k] > min:
        Ans = Ans + (j - k)
        pk = k
        break
      
      if k == j - 1:
        pk = k
        break      
     
      k = k + 1
      
    k = pk
    j = j - 1

  i = i - 1
  j = i - 1
  k = 0

print(Ans)

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

ll gcd(ll a, ll b){
    return b == 0 ? a : gcd(b, a%b);
}

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

    if(s[0] != t[0]){
        cout << -1 << endl;
        return 0;
    }

    ll g = gcd(n, m);
    ll l = n*m/g;

    if(g != 1){
        bool judge = true;
        int apos = 0, bpos = 0;
        while(apos < n && bpos < m){
            if(s[apos] != t[bpos])  judge = false;
            apos += n/g;
            bpos += m/g;
        }
        if(judge)   cout << l << endl;
        else        cout << -1 << endl;
    }else{
        cout << l << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll solve(ll N, ll A, ll B){
    if(A>B) return 0;
    if(N==1 && A!=B) return 0;
    ll low = (N-1)*A + B;
    ll high = (N-1)*B + A;
    return (high - low + 1);
}

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    
    cout << solve(N, A, B) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> k(m);
  boost::multi_array<int,2> s(boost::extents[m][10]);
  vector<int> p(m);
  rep(i,m){
    cin >> k[i];
    rep(j,k[i]){
      cin >> s[i][j];
    }
  }
  rep(i,m){
    cin >> p[i];
  }

  int count = 0;
  rep(state,1<<n){
    bool flag = true;
    rep(i,m){
      int on = 0;
      rep(j,k[i]){
        on += (state>>(s[i][j]-1))%2;
      }
      if ((on%2) != p[i]) flag = false;
    }
    if (flag) count++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;
	cin>>n;
	double ans=0;
	double sum=0;
	for(int i=1;i<=n;i++){
		int p=i;
		if(p%2==1){
			ans++;
		}
	}
	sum=ans/n;
	printf("%.10lf",sum);
	return 0;
}


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

int main() {
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  ll ans = 1;
  REP(i,n) {
    cin >> a[i];
    if(a[i] == 0) ans = 0;
  }
  
  if(ans == 0) cout << ans << endl;
  else {
    REP(i,n) {
      if(a[i] <= 1000000000000000000/ans) ans *= a[i];
      else ans = -1;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 4032
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define lc (rt<<1)
#define rc (rt<<11)
#define mid ((l+r)>>1)

typedef pair<int,int> pll;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll _INF = 0xc0c0c0c0c0c0c0c0;
const ll mod =  (int)1e9+7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
const int MAX_N = 100025;
ll dp[MAX_N][3];
struct node
{
    ll x,y,z;
}arr[MAX_N];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n;scanf("%d",&n);
    for(int i = 1;i<=n;++i) scanf("%lld%lld%lld",&arr[i].x,&arr[i].y,&arr[i].z);
    dp[1][0] = arr[1].x,dp[1][1] =arr[1].y,dp[1][2] = arr[1].z;
    for(int i = 2;i<=n;++i)
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+arr[i].x,dp[i][1] = max(dp[i-1][0],dp[i-1][2])+arr[i].y,dp[i][2] = max(dp[i-1][0],dp[i-1][1])+arr[i].z;
    printf("%lld\n",max(dp[n][0],max(dp[n][1],dp[n][2])));
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <algorithm>
#define N 4006
#define mo 1000000007
using namespace std;
int n,k,f[N][N],fac[4000006],inv[4000006];
int ksm(int x,int y)
{
	if(y==0)return 1;if(y==1)return x;int p=ksm(x,y>>1);
	if(y&1)return 1LL*p*p%mo*x%mo;return 1LL*p*p%mo;
}
int C(int a,int b)
{
	return 1LL*fac[a]*inv[b]%mo*inv[a-b]%mo;
}
int main()
{
	scanf("%d%d",&n,&k);fac[0]=inv[0]=1;
	if(k==1)return puts("1"),0;
	for(int i=1;i<=n*k;i++)fac[i]=1LL*fac[i-1]*i%mo;
	inv[n*k]=ksm(fac[n*k],mo-2);
	for(int i=n*k-1;i>=1;i--)inv[i]=1LL*inv[i+1]*(i+1)%mo;
	f[1][1]=1;
	for(int i=2;i<=2*n;i++)
		for(int j=1;j<=min(i,n);j++){
			f[i][j]=f[i-1][j-1];
			if(j>=(i+1)/2)f[i][j]=(f[i][j]+1LL*f[i-1][j]*C(n*k-j-1-(k-1)*(i-j-1),k-2)%mo)%mo;
		}
	printf("%d\n",1LL*f[2*n][n]*fac[n]%mo);
}

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

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define range(i, a, b, s) for (int i = (a); i < (b); i += (s))
#define down(i, a, b, s) for (int i = (a); (b) < i; i -= (s))

int a, b;

int main(int argc, char const *argv[]) {
  // freopen("A.txt", "r", stdin);

  while (cin >> a >> b) {
    if (a >= 13) {
      cout << b << endl;
    } else if (a >= 6) {
      cout << b / 2 << endl;
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
from itertools import chain


def solve():
    N, M, K = map(int, input().split())

    A = map(int, input().split())
    B = list(map(int, input().split()))

    answer = 0

    sum_b = sum(B)
    idx_b = M
    remain = K

    for i, a in enumerate(chain([0], A)):
        remain -= a
        if remain < 0:
            break

        while sum_b > remain and idx_b >= 0:
            idx_b -= 1
            b = B[idx_b]
            sum_b -= b
        
        i += idx_b
        answer = i if answer < i else answer

    return answer


def main():
    print(solve())


if __name__ == "__main__":
    main()


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

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    if((a == b && b != c) || (a != b && b == c) || (a == c && b != a)) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

using ll=long long;


int main(void)
{
	ll k, a, b;

	while(scanf("%lld%lld%lld", &k, &a, &b)==3)
	{
		ll ans=1;
		ll clap=min(k, a-1);

		if((k-clap)&1) clap++;
		if(a+1>=b) clap=k;
		k-=clap;
		ans+=clap;

		ans+=k/2*(b-a);
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 128
fun main(main: Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toLong() }
    if(h === 1L || w === 1L) {
        print(1)
    }
    else {
        if(0L === (h * w) % 2) {
            print((h * w) / 2)
        }
        else {
            print((h * w) / 2 + 1)
        }
    }
}


Measured memory_bytes: 37812
#pragma GCC diagnostic ignored "-Wunused-result"

#include <stdio.h>

int main(void) {
  unsigned long A,B;
  
  scanf("%lu %lu", &A, &B);

  if ((A&1==1UL)&&(B&1==1UL)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;

}


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

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

  long long ans = 0;

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

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


Measured memory_bytes: 1024
N, M = map(int, input().split())
a = [True] * (N + 3)
a[N + 1] = False
a[N + 2] = False

for _ in range(M) :
    a[int(input())] = False

MOD = 10 ** 9 + 7

dp = [0] * (N + 3)
dp[0] = 1
for i in range(N) :
    if a[i + 1] :
        dp[i + 1] = (dp[i + 1] + dp[i]) % MOD
    if a[i + 2] :
        dp[i + 2] = (dp[i + 2] + dp[i]) % MOD
   
print(dp[N])

Measured memory_bytes: 46296
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double A[100] = {};
    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    sort(A, A+n);
    double sum = 0;
    sum += A[0] + A[1];
    sum /= 2;
    for(int i = 2; i < n; i++)
    {
        sum += A[i];
        sum /= 2;
    }
    printf("%0.5f\n", sum);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    string s;
    int q,t,f;
    bool F{};
    char c;
    in>>s>>q;
    deque<char> ans;
    for(auto C:s) ans.push_back(C);
    fr(i,q){
        in>>t;
        if(t==1) F=!F;
        else{
            in>>f>>c;
            if(F) f=3-f;
            if(f-1) ans.push_back(c);
            else ans.push_front(c);
        }
    }
    if(F){
        for(auto it=ans.rbegin();it!=ans.rend();++it){
            cout<<*it;
        }
        cout<<endl;
    }
    else{
        for(auto it=ans.begin();it!=ans.end();++it){
            cout<<*it;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    vector<int> a(205);
    int x, n; cin >> x >> n;
    rep(i, n) {
        int p; cin >> p;
        a[p] = 1;
    }
    
    for (int i=0;;i++) {
        if (!a[x-i]) {
            cout << x - i;
            return 0;
        }
        if (!a[x+i]) {
            cout << x + i;
            return 0;
        }
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define vector_rsort(x) sort(all(x));reverse(all(x))
#define array_rsort(x,n) sort(x,x+n);reverse(x,x+n);
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int n,u,k,v;
int g[105][105];

int main(){
  scanf("%d",&n);

  rep(i,n){
    scanf("%d%d",&u,&k);
    rep(i,k){
      scanf("%d",&v);
      g[u][v]=1;
    }
  }
  
  REP(i,1,n+1){
    printf("%d",g[i][1]);
    REP(j,2,n+1){
      printf(" %d",g[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

    cin >> u;
    if (s == u) {
        a--;
    } else if (t == u) {
        b--;
    }

    cout << a << ' ' << b << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

class Main {
   public static void main (String[] args) {
       Scanner scanner = new Scanner(System.in);

       List<String> list = new ArrayList<>();
       int N = scanner.nextInt();
       String judge = "Yes";

       for (int i = 0; i < N; i++) {
           String str = scanner.next();
           //取得した単語をlistに追加
           list.add(str);

           if (i == 0) {
               continue;
           }

           //(i-1)番目の単語の末尾文字を取得
           char end = (list.get(i-1)).charAt((list.get(i-1)).length()-1);

           //i番目の単語の先頭文字を取得
           char first = (list.get(i)).charAt(0);

           //System.out.println("前の単語の末尾文字： " + end);
           //System.out.println("先頭文字： " + first);

           //しりとりになっているか判定
           if (end != first) {
               judge = "No";
           }
       }

       //listの要素数
       //System.out.println("listの要素数：" + list.size());

       //重複を削除
       //ArrayListをHashSetに変換
       Set<String> set = new HashSet<>(list);

       //HashSetをArrayListに変換
       List<String> HashList = new ArrayList<>(set);

       //HashListの要素数
       //System.out.println("HashListの要素数：" + HashList.size());

       //しりとりになっている場合
       //judgeを成立しているという意味のブーリアンにしておいたほうが良いのでは？
        if (judge.equals("Yes")) {
            if (list.size() != HashList.size()) {
                judge = "No";
            }
        }

       System.out.println(judge);
   }
}

Measured memory_bytes: 23124
import java.io.*;
import java.util.*;

public class Main {
	public static void main (String[] args) throws IOException{
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long s = sc.nextLong();
		long[] ans = new long[n];
		for(int i=0;i<k;i++) ans[i] = s;
		    for(int i=0;i<n;i++){
		        if(ans[i]==0) System.out.print((s!=1000000000 ? s+1 : 1)+" ");
		        else System.out.print(ans[i]+" ");
		    }
	}
	static class Pair {
	    long x, l;
	    public Pair(long a, long b){
	        x = a;
	        l = b;
	    }
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}
		String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				return null;
			}
		}
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}

Measured memory_bytes: 50168
a = lambda x: x//2

def main():
    S = input()
    K = int(input())

    l = len(S)
    hoge = [1]+[0]*(l-1)
    for i in range(1,l):
        if S[i] == S[i-1]:
            hoge[i] = hoge[i-1] + 1
            hoge[i-1] = 0
        else:
            hoge[i] = 1
    e = list(filter(lambda x: x,hoge))

    if len(e) == 1:
        return a(e[0]*K)
    elif S[0] == S[-1]:
        beg = e[0]
        end = e[-1]
        e = e[1:-1]
        return a(beg) + sum(map(a,e))*K + a(beg+end)*(K-1) + a(end)
    else:
        return sum(map(a,e))*K

print(main())





Measured memory_bytes: 3064