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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

const int MAX_N = 1e5 + 7;


void solve()
{
        string s; cin >> s;
        map<int, int> mp;
        for (int i = 0; i < s.length(); ++i)
        {
                mp[s[i] - 'a']++;
        }
        bool ok = true;
        for(auto x: mp)
        {
                if (x.second % 2 == 1) ok = false;
        }
        cout << (ok ? "Yes" : "No") << endl;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3620
// https://atcoder.jp/contests/abc178/tasks/abc178_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

const int MOD = 1e9 + 7;

template <int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }
    static int get_mod() { return mod; }
};

using mint = ModInt<MOD>;
vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
    for (int i = I_.size(); i <= n; i++) {
        I_.push_back(I_[MOD % i] * (MOD - MOD / i));
        F_.push_back(F_[i - 1] * i);
        R_.push_back(R_[i - 1] * I_[i]);
    }
}

mint I(int n) {
    check_fact(abs(n));
    return n >= 0 ? I_[n] : -I_[n];
}
mint F(int n) {
    check_fact(n);
    return n < 0 ? 0 : F_[n];
}
mint R(int n) {
    check_fact(n);
    return n < 0 ? 0 : R_[n];
}
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

void solve() {
    int N;
    cin >> N;
    mint ans = 0;
    // 3個ずつをiグループ作成し、残ったものを敷居(i-1)個で分割
    // 残り2個を4グループに分ける場合は敷居3つ「○|○||」
    FOR(i, 1, N / 3 + 1) { ans += C(N - i * 3 + i - 1, i - 1); }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
using namespace std;
using int64 = int64_t;

const int64 INF = 1e18;

inline void fastin(int64 &num){
  int64 c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

inline void fastout(int64 n){
  int64 N = n, rev, count = 0;
  rev = N;
  if (N == 0) {putchar_unlocked('0'); putchar_unlocked('\n'); return;}
  while ((rev % 10) == 0) {++count; rev /= 10;}
  rev = 0;
  while (N != 0) {rev = (rev << 3) + (rev << 1) + N % 10; N /= 10;}
  while (rev != 0) {putchar_unlocked(rev % 10 + '0'); rev /= 10;}
  while (count--) putchar_unlocked('0');
}

int main(){
  int64 a, b, q; fastin(a), fastin(b), fastin(q);
  int64 s[a + 2], t[b + 2];

  s[0] = -1 * INF; t[0] = -1 * INF; s[a + 1] = INF; t[b + 1] = INF;

  for (int i = 1; i <= a; ++i) fastin(s[i]);
  for (int i = 1; i <= b; ++i) fastin(t[i]);

  for (int i = 0; i < q; ++i){
    int64 x; fastin(x);
    auto pos1 = lower_bound(s, s + a + 2, x);
    auto pos2 = lower_bound(t, t + b + 2, x);

    int64 ans = min({max(*pos1 - x, *pos2 - x), 
		     max(x - *(pos1 - 1), x - *(pos2 - 1)),
		     2 * (*pos1 - x) + x - *(pos2 - 1),
		     *pos1 - x + 2 * (x - *(pos2 - 1)),
		     2 * (*pos2 - x) + x - *(pos1 - 1),
		     *pos2 - x + 2 * (x - *(pos1 - 1))}); 
    fastout(ans); putchar_unlocked('\n');
  }
  
  return 0;
}


Measured memory_bytes: 2816
s = input()
ans ='Yes'
if(s[0] == s[1] and s[2] == s[3]):
  ans ='Yes'
elif(s[0] == s[3] and s[1] == s[2]):
  ans ='Yes'
elif(s[0] == s[2] and s[1] == s[3]):
  ans ='Yes'
else:
  ans ='No'

if(s[0] == s[1] and s[1] == s[2] and s[2] == s[3]):
  ans ='No'
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	int mx=0;
	for(int i=0; i<N; ++i){
	    cin >> a[i];
	    mx=max(mx, a[i]);
	}
	if(N%3>0){
	    cout << (mx==0 ? "Yes" : "No") << endl;
	    return 0;
	}
	vector<int> kind, check;
	map<int, int> mp;
	for(int i=0; i<N; ++i){
	    ++mp[a[i]];
	    if(mp[a[i]]==1){
	        kind.push_back(a[i]);
	    }
	}
	if(kind.size()>3){
	    cout << "No" << endl;
	    return 0;
	}
	for(int i=0; i<kind.size(); ++i){
	    if(mp[kind[i]]%(N/3)>0){
	        cout << "No" << endl;
	        return 0;
	    }
	    check.push_back(kind[i]);
	    if(mp[kind[i]]>=(N/3)*2) check.push_back(kind[i]);
	    if(mp[kind[i]]==N) check.push_back(kind[i]);
	}
	int t=check[0], u=check[1], v=check[2];
	cout << ((t^u)==v ? "Yes" : "No") << endl;
	return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  int ans = 1000000000;
  rep(i, n) {
    if (i + k - 1 >= n) break;
    ans = min(ans, h[i + k - 1] - h[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
const ll inf=1e18;

int main() {
  ll x,y;
  cin >> x >> y;
  if(abs(x-y)<=1) {
    cout << "Brown" << endl;
  }
  else {
    cout << "Alice" << endl;
  }
}

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

int a[100005];

int main(){
  ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
  int n, c, k; cin >> n >> c >> k;
  for(int i = 0 ; i < n ; i++)cin >> a[i];
  sort(a,a+n);
  int i = 0;
  int cnt =0;
  while(i!=n){
    i = min(i+c, (int)(upper_bound(a,a+n,a[i]+k)-a));
    cnt++;
    //cout << cnt << ":" << i << endl;
  }
  cout << cnt;
}


Measured memory_bytes: 640
#include<stdio.h>
#define N 10000

int main(){
    int n, i, j, m=0, x[N];
    
    scanf("%d",&n);
    
    for(i=0 ; i<n ; i++){
        scanf("%d",&x[i]);
    }
    
    for(i=0 ; i<n ; i++){
        for(j=2; j*j<=x[i] ; j++){
            if(x[i]%j == 0){
                m++;
                break;
            }
        }
    }
    printf("%d\n",n-m);
    return 0;
}




Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
#define int long long
using namespace std;
int cnt[100009];
signed main(){
	int n,k,q;
	cin>>n>>k>>q;
	for(int i=0;i<q;i++){
		int x;
		cin>>x;
		cnt[x]++;
	}
	for(int i=1;i<=n;i++){
		if( k - (q-cnt[i]) > 0)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	string ans = "No";
	for (int a = 0; a <= K; a++) {
		for (int b = 0; a + b <= K; b++) {
			int c = K - a - b;
			int temp_A, temp_B, temp_C;
			temp_A = A * (int)pow(2, a);
			temp_B = B * (int)pow(2, b);
			temp_C = C * (int)pow(2, c);
			if (temp_B > temp_A && temp_C > temp_B) ans = "Yes";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4040
import java.io.*;

class Main {
    public static void main(String[] args) {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	try{
			int a = 0;
			String op = "";
			int b = 0;
			boolean end = false;
			
			while(end == false){
				String[] tmp = br.readLine().split(" ");
				a = Integer.parseInt(tmp[0]);
				op = tmp[1];
				b = Integer.parseInt(tmp[2]);
				
				if(a < 0 && b > 20000 || (b == 0 && op.equals("/"))){
					op = "?";
				}
				switch(op){
				case "+":
					System.out.println(a+b);
					break;
				case "-":
					System.out.println(a-b);
					break;
				case "*":
					System.out.println(a*b);
					break;
				case "/":
					System.out.println(a/b);
					break;
				case "?":
					end = true;
					break;
				default:
					
				}
			}
			
        } catch (Exception e) {
            System.out.println(e);
        }
    	
    }
}

Measured memory_bytes: 24100
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 500050;
const int K = 30;
const int mod = 1e9 + 7;
int q[2][N];
int k;
int p[N];
int zz, a[N], mm;
void cmp(int i, int j, int kk = k, int m = 1){
    cout << "< " << i << " " << j << " " << kk << endl;
    a[kk] = (a[i] < a[j]);
    mm = max(mm, a[kk]);
    k += m;
    zz++;
}
void add(int i, int j, int kk = k, int m = 1){
    cout << "+ " << i << " " << j << " " << kk << endl;
    a[kk] = a[i] + a[j];
    mm = max(mm, a[kk]);
    k += m;
    zz++;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
     //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cout << 39784 << endl;
    for (int ii = 1e9; ii <= 1e9; ii++){
    for (int jj = 1e9; jj <= 1e9; jj++){
        k = 3;
        zz = 0;
        memset(a, 0, sizeof(a));
        a[0] = ii;
        a[1] = jj;
        add(0, 1);
        cmp(4, 3);
        p[0] = 4;
        for (int i = 1; i <= K; i++){
            add(k - 1, k - 1, k);
            p[i] = k - 1;
        }
        for (int i = 0; i < 2; i++){
            for (int j = K; j >= 0; j--){
                for (int l = K; l > j; l--){
                    add(q[i][l], k, k, 0);
                }
                for (int l = 0; l < j; l++){
                    add(p[l], k, k, 0);
                }
                cmp(k, i, k + 1, 0);
                for (int l = 0; l < j; l++){
                    add(k + 1, k + 1, k + 1, 0);
                }
                q[i][j] = k + 1;
                k += 2;
            }
        }
        for (int i = 0; i < K; i++){
            for (int j = 0; j < K; j++){
                int p1 = q[0][i];
                int p2 = q[1][j];
                cmp(k, p1, k + 1, 0);
                cmp(k, p2, k + 2, 0);
                cmp(k + 1, k + 2, k + 3, 0);
                cmp(k + 2, k + 1, k + 4, 0);
                cmp(k + 1, p[0], k + 5, 0);
                cmp(k + 2, p[0], k + 6, 0);
                add(k + 3, k + 4, k + 7, 0);
                add(k + 7, k + 5, k + 7, 0);
                add(k + 7, k + 6, k + 7, 0);
                add(k + 7, k + 7, k + 7, 0);
                cmp(k + 7, p[0], k + 7, 0);
                for (int l = 0; l < i + j; l++){
                    add(k + 7, k + 7, k + 7, 0);
                }
                add(k + 7, 2, 2, 0);
                k += 8;
            }
        }
        }
    }
}


Measured memory_bytes: 7584
#include <bits/stdc++.h>
using namespace std;
int main(){
  #define int long long
  int N,K,ans=1000000000000000;
  cin>>N>>K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin>>h.at(i);
  }
  for(int bit=0;bit<(1<<N);bit++){
    vector<bool> vec(N,false);
    int count=0;
    int cost=0;
    for(int i=0;i<N;i++){
      if((1<<i)&bit){
        vec.at(i)=true;
        count++;
      }
    }
    if(count!=K){
      continue;
    }
    int maxH=0;
    for(int i=0;i<N;i++){
      //cout<<i<<" "<<maxH<<" "<<h.at(i)<<endl;
      if(vec.at(i) && maxH>=h.at(i)){
        cost+=maxH-h.at(i)+1;
        maxH++;
        //cout<<i<<" "<<maxH<<" "<<maxH-h.at(i)+1<<endl;
      }
      maxH=max(maxH,h.at(i));
    }
    //cout<<cost<<endl;
    ans=min(ans,cost);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
import heapq
import sys
input = sys.stdin.readline


t = int(input())
for _ in range(t):
    n = int(input())
    info = [list(map(int, input().split())) for i in range(n)]
    p_li = []
    m_li = []
    ans = 0
    for k, l, r in info:
        diff = l - r
        if diff > 0:
            p_li.append((k - 1, abs(diff)))
            ans += r
        elif diff < 0:
            m_li.append((n - k - 1, abs(diff)))
            ans += l
        else:
            ans += l

    p_li = sorted(p_li, reverse=True)
    l = 0
    q = []
    for i in range(n)[::-1]:
        while l < len(p_li) and p_li[l][0] == i:
            heapq.heappush(q, -p_li[l][1])
            l += 1
        if q:
            val = -heapq.heappop(q)
            ans += val

    m_li = sorted(m_li, reverse=True)
    l = 0
    q = []
    for i in range(n)[::-1]:
        while l < len(m_li) and m_li[l][0] == i:
            heapq.heappush(q, -m_li[l][1])
            l += 1
        if q:
            val = -heapq.heappop(q)
            ans += val
    print(ans)

Measured memory_bytes: 115124
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	N := nextInt()

	fmt.Fprintln(out, N+N*N+N*N*N)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


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

#define _GLIBCXX_DEBUG

int main() {
  int n, m;
  vector<int> a(60);
  vector<int> b(60);
  vector<int> count(60);
  
  cin >> n >> m;
  
  for(int i = 0; i < m; i++)
    cin >> a[i] >> b[i];
  
  for(int i = 0; i < m; i++) {
    for(int j = 1; j <= n; j++) {
      if(a[i] == j)
        count[j]++;
      if(b[i] == j)
        count[j]++;
    }
  }
  
  for(int i = 1; i <= n; i++)
    cout << count[i] << endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.sort()

x = l[0]
y = 0
ans = 0
for i in range(n):
  if l[i] != x:
    if x < y:
      ans += y -x
    elif x > y:
      ans += y
    else:
      pass
    x = l[i]
    y = 1
  else:
    y += 1
else:
  if x < y:
      ans += y -x
  elif x > y:
    ans += y
  else:
    pass

print(ans)

Measured memory_bytes: 63856
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
    {
sim > struct rge
{
    c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
    ~debug()
    {
        cerr << endl;
    }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c &)
    {
        ris;
    }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 10;

int main()
{
    fastio int x, k;
    cin >> x >> k;
    int cnt=0;
    for(int i=0;i<x;i++)
    {
        int a;
        cin>>a;
        if(a>=k)
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int main()
{
    ll A,B,C,D,E;
    cin >> A >> B >> C >> D;
    E = C*D/__gcd(C,D);
    ll ans = B-A+1;
    if(A%C != 0){
        ans -= (B/C - A/C);
    }else{
        ans -= (B/C - A/C + 1);
    }
    if(A%D != 0){
        ans -= (B/D - A/D);
    }else{
        ans -= (B/D - A/D + 1);
    }
    if(A%E != 0){
        ans += (B/E - A/E);
    }else{
        ans += (B/E - A/E + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
n,k=map(int,input().split())
A=list(map(int,input().split()))
p=1
l=[0]*n
#l[0]+=1
if k<=200000:
    for i in range(k):
        p=A[p-1]
        l[p-1]+=1
    print(p)
    exit()
else:
    for i in range(200001):
        p=A[p-1]#A[0]の番号の町に飛ぶ
        l[p-1]+=1
        #print(p)
        if l[p-1]==2:
            x=i
            break
    #print("p=",str(p))
    #print(l,x)

    d=1
    for j in range(200001):
        d=A[d-1]#A[0]の番号の町に飛ぶ
        if d==p:
            y=j
            break
    #print("y=",str(y))
    z=(k-x-1)%(x-y)#yから数えて残り回す回数
    #print(z)
    for i in range(z):
        p=A[p-1]
        #print(p)
    print(p)

Measured memory_bytes: 32380
#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() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = n;
  if (n >= b-1) x = b-1;
  ll ans = a*x/b - a*(x/b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
N = int(input())
A = list(input())
B = list(input())
C = list(input())

ans = 0
for i in range(N):
    if A[i] == B[i] == C[i]:
        pass
    elif A[i] ==B[i] or B[i] == C[i] or C[i] == A[i]:
        ans += 1
    else:
        ans += 2

print (ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
int d[200000],t[200000];
int main(){
    int n,m;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&d[i]);
    scanf("%d",&m);
    if(n<m){
        printf("NO");
        return 0;
    }
    for(int i=0;i<m;i++)scanf("%d",&t[i]);
    std::sort(d,d+n);
    std::sort(t,t+m);
    int j=0;
    for(int i=0;i<m;i++){
        while(j<n&&d[j]<t[i])j++;
        if(j==n||d[j]>t[i]){
            printf("NO");
            return 0;
        }
        j++;
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#define MAX 10000

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

int main(){
    int H,i,A[MAX+1];
    scanf("%d",&H);
    for(i=1;i<=H;i++) {
        scanf("%d",&A[i]);
    }

    for(i=1;i<=H;i++) {
        printf("node %d: key = %d, ",i,A[i]);
        if(parent(i) >= 1) printf("parent key = %d, ",A[parent(i)]);
        if((left(i) <= H) && (A[left(i)]!=0)) printf("left key = %d, ",A[left(i)]);
        if((right(i) <= H) && (A[right(i)]!=0)) printf("right key = %d, ",A[right(i)]);
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2104
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		int ans = 1;
		while(N / K != 0){
			N /= K;
			ans++;
		}
		System.out.println(ans);
	}	
}

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

x = int(input())
k = int(input())
R = [(_r, i%2) for i, _r in enumerate(map(int, input().split()))]
n = int(input())
TA = [list(map(int, input().split())) for _ in range(n)]
T, A = zip(*TA)
L = [None]*n
b = 0
for i, t in enumerate(T, 1):
  R.append((t, -i))
R.sort()
dx = 1
l, r, p, q = 0, x, 0, x
for _r, i in R:
  d = _r-b
  b = _r
  if dx == 1:
    if d <= p:
      p -= d
      q -= d
    elif d < q:
      q -= d
      l = r-q
      p = 0
    else:
      l = 0
      r = 0
      p = 0
      q = 0
  else:
    if d <= x-q:
      p += d
      q += d
    elif d < x-p:
      p += d
      r = l+(x-p)
      q = x
    else:
      l = x
      r = x
      p = x
      q = x
  if i >= 0:
    dx = i
  else:
    a = A[-i-1]
    if a < l:
      res = p
    elif a <= r:
      res = (a-l)+p
    else:
      res = q
    L[-i-1] = res
print(*L, sep="\n")

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

typedef long long ll;
typedef long double ld;

int main(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  if((a+b) >= k){
    if(a>k){
      cout << k;
    }
    else{
      cout << a;
    }
    
  }
  else{
    cout << a-(k-a-b);
  }
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long n,i,p,c=0;
  cin>>n;
  for(i=1;i<=n;i++)
  {
    cin>>p;
    if(i%2==1)
      if(p%2==1)
        c++;
  }
  cout<<c<<'\n';
  return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    cin >> n;
    if(n[0] == n[1] && n[0] == n[2] || n[1] == n[2] && n[1] == n[3])
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

ac_cnt=[False]*n
wa_cnt=[0]*n

for _ in range(m):
    a,b=input().split()
    a=int(a)-1
    if b == "AC":
        ac_cnt[a] = True
    else:
        if ac_cnt[a] == False:
            wa_cnt[a] += 1
c=0
d=0

for i in range(n):
    if ac_cnt[i]:
        c += 1
        d += wa_cnt[i]

print(c,d)

Measured memory_bytes: 4596
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, m; cin >> n >> m;
  int ac = 0;
  for(int i = 0; i < m; i++){
    int a; cin >> a;
    ac += a;
  }
  cout << (n - ac >= 0 ? n-ac : -1) << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;
typedef long double ld;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){

	ll ans=1;
	ld a,b;
	cin>>a>>b;
	ans=a*b;

	cout<<ans<<endl;
	
}


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


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

int main(){

  int N,M;

  cin >> N >> M;

  int count = 0;
  if(N >= 2 ){
  for(int i=1;i<N;++i){
    count += i;
  }
}
  if(M >= 2){
  for(int i=1;i<M;++i){
    count += i;
  }
}
cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end()))
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<ll> x(n),y;
	FOR(i,0,n)cin>>x[i];
	y = x;
	SORT(x);
	ll a=x[n/2];
	ll b=x[n/2-1];
	FOR(i,0,n){
		if(y[i]<=b)cout<<a<<endl;
		else cout<<b<<endl;
	}
}


Measured memory_bytes: 5376
N = int(input())
A = list(map(int,input().split()))

count = 0
sw = 1

while sw==1:
	sw = 0
	tmp = 0
	for i in range(N):
		tmp = tmp + A[i]%2
	if tmp == 0:
		A = list(map(lambda x:x/2,A))
		count = count + 1
		sw = 1
	else:
		break

print(count)


Measured memory_bytes: 3060
K = int(input())
from math import gcd 
ans=0
for a in range(1,K+1):
  for b in range(a,K+1):
    for c in range(b,K+1):
      if a==b==c:
        ans += gcd(gcd(a,b),c)
      elif a==b or b==c or c==a:
        ans += gcd(gcd(a,b),c)*3
      else:
        ans += gcd(gcd(a,b),c)*6
      
print(ans)   

Measured memory_bytes: 9168
using System.Text;
public partial class IntroductionToProgramming{
    public static void Main(){
        int n = int.Parse(System.Console.ReadLine());
 
        StringBuilder sb = new StringBuilder();
 
        for (int i = 1; i <= n; i++)
        {
            if (i % 3 == 0)
            {
                sb.Append(" " + i.ToString());
            }
            else if (i.ToString().IndexOf('3') != -1)
            {
                sb.Append(" " + i.ToString());
            }
        }
 
        System.Console.WriteLine(sb.ToString());
    }
}

Measured memory_bytes: 6004
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int a, b;

void input() {
  cin >> a >> b;
}

void solve() {
  if (b%a==0) {
    cout << a+b << endl;
    return;
  }

  cout << b-a << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 384
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
using ll = int64_t; using ull = uint64_t; using ld = long double;

// -----------------------------------------------------------------------------

int main() {
    int a, b; cin >> a >> b;
    cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
s_lis = []

#ON/OFFのパターン
for i in range(2 ** n) :
    lis = []
    for j in range(len(bin(2 ** n)) - 3) :
        if (i >> j) & 1 :
            lis.append(1)
        else:
            lis.append(0)
    
    s_lis.append(lis)

#各電球の接続
b_lis = []
for k in range(m) :
    b_lis.append(list(map(int, input().split())))

#点灯条件
light = list(map(int, input().split()))

#各電球の合計
cnt = 0
for s in s_lis :
    c_lis = []
    for b in b_lis :
        c = 0
        for x in range(b[0]) :
            c += s[b[x + 1] - 1]
        c_lis.append(c)
    
    c_lis = list(map(lambda y : y % 2, c_lis))
    if c_lis == light :
        cnt += 1

print(cnt)

Measured memory_bytes: 9296
#include<bits/stdc++.h>
#define maxn 305
#define Mod 1000000007
#define Val(x) (((long long)x) % Mod)
using namespace std;
int limit_min[maxn][4],limit_max[maxn][4];
int dp[maxn][maxn][maxn];
bool check(int x,int y,int z) {
	int arr[] = {x,y,z};
	sort(arr,arr+3);
	if(arr[1] != 0) {
		if(limit_min[arr[2]][1] != 0 && limit_min[arr[2]][1] <= arr[1])
			return false;
		if(limit_max[arr[2]][2] != 0 && limit_max[arr[2]][2] > arr[1])
			return false;
	}
	else if(limit_min[arr[2]][2] != 0)
		return false;
	if(arr[0] != 0) {
		if(limit_min[arr[2]][2] != 0 && limit_min[arr[2]][2] <= arr[0])
			return false;
		if(limit_max[arr[2]][3] != 0 && limit_max[arr[2]][3] > arr[0])
			return false;
	}
	else if(limit_min[arr[2]][3] != 0)
		return false;
	return true;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	for(int i=1,l,r,x;i<=m;i++) {
		cin >> l >> r >> x;
		if(x > (r - l + 1)) {
			cout << 0 << endl;
			return 0;
		}
		if(limit_min[r][x] == 0)
			limit_min[r][x] = limit_max[r][x] = l;
		else {
			limit_min[r][x] = min(limit_min[r][x],l);
			limit_max[r][x] = max(limit_max[r][x],l);
		}
	}
	dp[1][0][0] = dp[0][1][0] = dp[0][0][1] = 1;
	for(int i=2;i<=n;i++) {
		for(int j=0;j<i-1;j++)
			for(int k=0;k<i-1;k++)
				if(j == 0 || k == 0 || j != k) {
					int v[] = {i-1,j,k};
					for(int t=0;t<3;t++) {
						int x = v[0] , y = v[1] , z = v[2];
						dp[i][y][z] = Val(dp[i][y][z] + dp[x][y][z]);
						dp[x][i][z] = Val(dp[x][i][z] + dp[x][y][z]);
						dp[x][y][i] = Val(dp[x][y][i] + dp[x][y][z]);
						swap(v[t],v[(t+1)%3]);
					}
				}
		for(int j=0;j<i;j++)
			for(int k=0;k<i;k++)
				if(j == 0 || k == 0 || j != k) {
					int v[] = {i,j,k};
					for(int t=0;t<3;t++) {
						int x = v[0] , y = v[1] , z = v[2];
						if(!check(i,y,z))	dp[i][y][z] = 0;
						if(!check(x,i,z))	dp[x][i][z] = 0;
						if(!check(x,y,i))	dp[x][y][i] = 0;
						swap(v[t],v[(t+1)%3]);
					}
				}
	}
	int ans = 0;
	for(int j=0;j<n;j++)
		for(int k=0;k<n;k++)
			if(j == 0 || k == 0 || j != k)
				ans = Val(ans + dp[n][j][k] + dp[j][n][k] + dp[j][k][n]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 110976
# B - Can you solve this?
n, m, c = map(int, input().split())
b = list(map(int, input().split()))

cnt = 0
for i in range(n):
    a = list(map(int, input().split()))
    _sum = sum([_a*_b for _a, _b in zip(a, b)]) + c
    if _sum > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL; */ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, S, A[3000];

ll dp[3005][3005];
ll solve(int n, int s){
    if(s < 0) return 0;
    if(n == N){
        if(s == 0) return 1;
        else return 0;
    }
    if(dp[n][s] != -1) return dp[n][s];
    return dp[n][s] = (solve(n+1, s) * 2 + solve(n+1, s-A[n])) % MOD;
}

signed main(){
    cin >> N >> S;
    rep(i, N) cin >> A[i];
    memset(dp, -1, sizeof(dp));
    cout << solve(0, S) << endl;
}

Measured memory_bytes: 74384
package main

import (
	"fmt"
)

func main() {
	var N int
	var S string
	fmt.Scan(&N,&S)
	
	judge := false
	if N % 2 == 0 {
		judge = true
		for i := 0; i < N / 2; i++ {
			if S[i] != S[i + N / 2]{
				judge = false
				break
			}
		}
	}
	
	if judge {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
	
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>

using namespace std;

#define NMAX 100

struct S1{
	int wx, wy, r;
};

/*点と円 true->点は円の内部*/
bool po_cr(int cx, int cy, int cr, int px, int py){
	return pow((cx - px), 2.0) + pow((cy - py), 2.0) <= pow(cr, 2.0);
}

/*円と線 true->接している*/
bool li_cr(int cx, int cy, int cr,int lx1, int ly1, int lx2, int ly2){

	double A, B, C, CA, AS, BS;
	double d;

	A = pow(cx - lx1, 2.0) + pow(cy - ly1, 2.0);
	B = pow(cx - lx2, 2.0) + pow(cy - ly2, 2.0);
	C = pow(lx1 - lx2, 2.0) + pow(ly1 - ly2, 2.0);
	CA = (lx2 - lx1) * (cy - ly1) - (cx - lx1) * (ly2 - ly1);
	AS = (cx - lx1) * (lx2 - lx1) + (cy - ly1) * (ly2 - ly1);
	BS = (cx - lx2) * (lx2 - lx1) + (cy - ly2) * (ly2 - ly1);

	if(C != 0) d = pow(CA, 2.0) / C;
	else d = 0;

	if(d <= pow(cr, 2.0)){
		if(AS * BS <= 0){
			return 1;
		}
		else if(pow(cr, 2.0) > A || pow(cr, 2.0) > B){
			return 1;
		}
	}
	return 0;
}

int main(){

	int n, m;
	S1 wall[NMAX];
	int tx, ty, sx, sy;
	bool f1, f2;

	while(1){

		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; i++){
			cin >> wall[i].wx >> wall[i].wy >> wall[i].r;
		}

		cin >> m;

		for(int i = 0; i < m; i++){

			cin >> tx >> ty >> sx >> sy;

			f1 = true;
			for(int j = 0; j < n; j++){
				if(po_cr(wall[j].wx, wall[j].wy, wall[j].r, tx, ty)!=po_cr(wall[j].wx, wall[j].wy, wall[j].r, sx, sy)){
					f1 = false;
				}
			}
			
			f2 = true;
			for(int j = 0; j < n; j++){
				if(!po_cr(wall[j].wx, wall[j].wy, wall[j].r, sx, sy)){
					if(li_cr(wall[j].wx, wall[j].wy, wall[j].r, tx, ty, sx, sy)){
						f2 =  false;
					}
				}
			}

			if(f1 && f2 ) cout << "Danger" << endl;
			else cout << "Safe" << endl;
		}
	}

}

Measured memory_bytes: 1156
#include <stdio.h>
int main(void)
{
	int n;
	float x[4],y[4];
	int i,j;
	float slope1, slope2;

	scanf("%d",&n);

	for (i = 0; i < n; i++) {
		for (j = 0; j < 4; j++)
			scanf("%f %f",&x[j],&y[j]);
		slope1 = (y[1] - y[0]) / (x[1] - x[0]);
		slope2 = (y[3] - y[2]) / (x[3] - x[2]);

		if (slope1 == slope2)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){

    string s; cin >> s;

    if(s[2] == s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	
	int input;
	scanf("%d", &input);
	for (int i = 0; i >= 0; i++){
		if (i*1000 >= input){
			printf("%d", i*1000 -input);
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,sum=0;
    cin>>n;
    vector<ll>a(n),cnt(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sum/=2;
    ll odd=0,even=0;
    for(int j=0;j<(n-1)/2;j++){
        even+=a[(1+j*2)%n];
    }
    cnt[0]=sum-even;
    for(int j=0;j<(n-1)/2;j++){
        odd+=a[(2+j*2)%n];
    }
    cnt[1]=sum-odd;
    for(int i=2;i<n;i+=2){
        even=even-a[(i+n-1)%n]+a[(i+n-2)%n];
        cnt[i]=sum-even;
    }
    for(int i=3;i<n;i+=2){
        odd=odd-a[(i+n-1)%n]+a[(i+n-2)%n];
        cnt[i]=sum-odd;
    }
    for(int i=0;i<n;i++){
        cout<<cnt[i]*2<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
  int N;
  cin >> N;
  long long ans = 0;
  for(int i = 1; i <= N; i++){
    if(i % 3 != 0 && i % 5 != 0){
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    string s; cin >> s;
    ll left_w[300001]; INITA(left_w, 0, 300000, 0);
    ll right_e[300001]; INITA(right_e, 0, 300000, 0);

    // そこまでに西を向いている人の数、それより後に東を向いている人の数の和が最も小さくなる人を選ぶ
    ll tmp_w = 0;
    FOR(i, 0, n-1) {
        left_w[i] = tmp_w;
        if (s[i] == 'W') {
            tmp_w++;
        }
    }
    ll tmp_e = 0;
    FORD(i, n-1, 0) {
        right_e[i] = tmp_e;
        if (s[i] == 'E') {
            tmp_e++;
        }
    }

    ll res = 10e10;
    REP(i, n) {
        res = min(res, left_w[i] + right_e[i]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8428
main = do 
    [n, l] <- map (read :: String -> Int). words <$> getLine
    let result = if 0 < l 
        then 
            1 
        else 
            if n < (1 -l )
                then
                    n
                else 
                    1 - l 
    
    print $ ( div ( n * (n + 1 ) ) 2 ) - n +  n * l  - ( l + result - 1 )



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

int main()
{
    int n,k;
    cin>>n>>k;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    bool dp[k+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(A[j]<=i){
                if(!dp[i-A[j]]){
                    dp[i] = 1;
                }
            }
        }
    }
    if(dp[k]){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
    
	return 0;
}

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

int n;
long long mmax[4];

int main(){
	scanf("%d",&n);
	for(int i=0;i<4;i++) mmax[i]=-2e9;
	long long ans=0;
	long long x,y;
	for(int i=1;i<=n;i++){
		scanf("%lld %lld",&x,&y);
		ans=max(ans,max(x+y+mmax[0],max(x-y+mmax[1],max(-x+y+mmax[2],-x-y+mmax[3]))));
		mmax[0]=max(mmax[0],-x-y);
		mmax[1]=max(mmax[1],-x+y);
		mmax[2]=max(mmax[2],x-y);
		mmax[3]=max(mmax[3],x+y);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3800
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::min;

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  int L=0;
  int R=0;
  for (int i=0;i<M;++i){
    int a;
    cin >> a;
    if (a<X) L++;
    else R++;
  }
  cout << min(R,L) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
 
#define gc getchar
#define db double
#define ll long long int
#define ull unsigned long long int
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define sclu(x) scanf("%llu", &x)
#define scd(x) scanf("%lf", &x)
#define pass cout<<"pass\n"
#define vi vector<int>
#define pb push_back
#define vec vector
#define vi vector<int>
#define el "\n"
#define pii pair<int, int>
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define f(i,x,y) for(int i=x;i<y;++i)
#define ff(i,x,y) for(int i=x;i<=y;++i)
#define MOD 1000000007
#define MAX2 1000001
#define MAX 103
#define pbb pair<bool,bool>

using namespace std;

int n,m;

bool comp(pii a, pii b) {
	return (a.S < b.S);
}

int main() {
	int x,y;
	sc(n); sc(m);
	vec<pii> ar(m);
	f(i,0,m) {
		sc(ar[i].F); sc(ar[i].S);
	}
	ll ans =0LL;
	int p=-1;
	sort(ar.begin(), ar.end(), comp);
	for(int i=0;i<m;++i) {
	//	cout << "ar = " << ar[i].F << " " << ar[i].S << el;
		if(ar[i].F < p) continue;
		ans+= 1;
		p = ar[i].S;
	//	cout << "i = " << i << " ans = " << ans << el;
	}
	cout << ans << el;
	ar.clear();
	return 0;
}




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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;
const int inf = 1e9;


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

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

    int n, m, k;
    cin>>n>>m>>k;

    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    --x1; --y1; --x2; --y2;

    vector<string> g(n);
    for (int i=0; i<n; i++) {
	cin>>g[i];
    }



    vector<vector<int>> dist(n, vector<int>(m, inf));
    vector<vector<int>> viz(n, vector<int>(m, 0));

    dist[x1][y1] = 0;
    viz[x1][y1] = 0;


    queue<pair<int,int>> qq;
    qq.push({x1,y1});

    while (qq.size()) {
	int x = qq.front().first;
	int y = qq.front().second;
	qq.pop();

	for (int dir=0; dir<4; dir++) {
	    for (int i=1; i<=k; i++) {
		int nx = x+dx[dir]*i;
		int ny = y+dy[dir]*i;
		if (nx<0 || ny<0 || nx>=n || ny>=m) break;
		if (g[nx][ny] == '@') break;
		if (viz[nx][ny] && 1+dist[x][y] > dist[nx][ny]) break;
		if (viz[nx][ny]) continue;

		dist[nx][ny] = 1+dist[x][y];
		viz[nx][ny] = 1;
		qq.push({nx,ny});
	    }
	}
    }

    if (!viz[x2][y2]) out(-1);
    cout<<dist[x2][y2]<<endl;
    
    
    return 0;
}


Measured memory_bytes: 16336
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgramingStudying2
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var a = inputs[0];
            var b = inputs[1];
            var c = inputs[2];
            var d = inputs[3];

            var anslist = new List<long>();
            anslist.Add(a * c);
            anslist.Add(a * d);
            anslist.Add(b * c);
            anslist.Add(b * d);

            Console.WriteLine(anslist.Max());
        }
    }
}


Measured memory_bytes: 28368
/* ITP1_7_B */
#include <stdio.h>

#define INFINITY_LOOP 1
#define FIRST_NUM 1

/* ????????????????????°????????? */
short get_combination_cnt(short n, short x);

int main(void)
{
	// n?????§?????°,????¨????x
	short n = 0, x = 0;
	
	while( INFINITY_LOOP )
	{
		// ??\????????????
		scanf("%hd %hd", &n, &x);
		
		// n,x???0?????´?????\??????????????¨??????
		if( 0 == n && 0 == x )
		{
			break;
		}
		
		// ???????????????
		printf("%d\n", get_combination_cnt(n, x));
	}
	return 0;
}

/* ????????????????????°?????????*/
short get_combination_cnt(short n, short x)
{
	short ii, jj, kk, result = 0;
	
	// 1???????????°
	for( ii = 1; ii <= n; ii++ )
	{
		// 2???????????°
		for( jj = ii + 1; jj <= n; jj++ )
		{
			//3???????????°
			for( kk = jj + 1; kk <= n; kk++ )
			{
				// X??¨3????????°???????¨?????????????
				if( x == (ii + jj + kk) )
				{
					result++;
				}
			}
		}
	}
	return result;
}

Measured memory_bytes: 600
N = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if p[i] == i+1:
        a, b = p[i], p[i+1]
        p[i], p[i+1] = b, a
        ans += 1
if p[N-1] == N:
    ans += 1

print(ans)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    vector<bool> number(1000000000 + 1);
    int num;
    for (int i = 0; i < N; i++)
    {
        cin >> num;
        if (number[num] == false)
        {
            number[num] = true;
        }
        else
        {
            number[num] = false;
        }
    }

    int ans = 0;
    for (int i = 1; i < number.size(); i++)
    {
        if (number[i] == true)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 122368