akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    int N;
    int lim = 114514;
    cin >> N;
    vector<ll> cnt(lim);
    REP(i, N) {
        int tmp;
        cin >> tmp;
        cnt[tmp]++;
    }

    int Q;
    cin >> Q;

    ll ans = 0;
    for (ll i = 1; i <= lim; ++i) {
        ll tmp = cnt[i] * i;
        ans += tmp;
    }

    while (Q--) {
        int b, c;
        cin >> b >> c;

        ll diff = -cnt[b] * b + cnt[b] * c;
        ans += diff;

        cnt[c] += cnt[b];
        cnt[b] = 0;


        cout << ans << endl;
    }


}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3676
# -*- coding: utf-8 -*-
n = int(input())
h = [int(i) for i in input().split()] 

for i in reversed(range(1, n)):
    if h[i - 1] > h[i]:
        h[i - 1] -= 1
#print(h)
#print(sorted(h))
if h != sorted(h):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 14396
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N := ReadInt()
	v := ReadInts(N)
	rest := make([]float64, N)
	for i := 0; i < N; i++ {
		rest[i] = float64(v[i])
	}
	for len(rest) > 1 {
		sort.Float64s(rest)
		n := (rest[0] + rest[1]) / 2
		rest = append(rest[2:], n)
	}
	fmt.Println(rest[0])
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	string s, t;
	cin >> s >> t;

	for(int i = s.length() - t.length(); i >= 0; i--) {
		bool flag = true;
		rep(j, 0, t.length()) {
			if(s[i + j] == t[j] or s[i + j] == '?') continue;
			else {
				flag = false;
				break;
			}
		}
		if(flag) {
			string rsl = "";
			rep(j, 0, i) {
				if(s[j] == '?') rsl += 'a';
				else rsl += s[j];
			}
			rep(j, 0, t.length()) {
				rsl += t[j];
			}
			rep(j, i + t.length(), s.length()) {
				if(s[j] == '?') rsl += 'a';
				else rsl += s[j];
			}
			cout << rsl << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  char op;
  int result;
  cin >> A >> op >> B;
  if (op == '+'){
    result = A + B;
  }
  else if (op == '-'){
    result = A - B;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(X: int, K: int, D: int):
    X = abs(X)
    t = X // D
    if t <= K:
        if t % 2 == K % 2:
            print(abs(X - D * t))
            return
        else:
            print(abs(X - D * (t + 1)))
            return
    else:
        print(abs(X - D * K))
        return
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(X, K, D)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61788
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
        	double dispersion = 0;
            double a = 0;
            int n = sc.nextInt();
            int[] s = new int[n];
            if(n==0){
            	break;
            }
            double m = 0;
            for(int i=0; i < n; i++){
            	s[i] = sc.nextInt();
            	m += s[i];
            }
            m = m/n;
            for(int j=0; j<n; j++){
            	dispersion += (s[j]-m)*(s[j]-m);
            }
            dispersion = dispersion / n;
            //System.out.println("dispersion:"+dispersion);
            a = Math.sqrt(dispersion);
            System.out.println(a);
        }

    }
}



Measured memory_bytes: 31164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define fi first
#define se seconde
#define pb push_back()
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
ll k,n,ans;
int main(){
	cin>>n>>k;
	if(!k){
		cout<<n*n<<endl;
		return 0;
	}
	rep(i,k+1,n){
		ans+=(n/(ll)i*((ll)i-k));
		if(n%i){
			ans+=max(0ll,n%i-k+1);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    string s,t;
    cin >> s ;
    cin >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    
    if(s<t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

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

    vector<int> s(n);
    for(int i=0; i<m; i++){
        int k;
        cin >> k;
        for(int j=0;j<k; j++){
            int tmp;
            cin >> tmp;
            s[tmp-1] |= 1 << i;
        }
    }

    int p = 0;
    for(int i=0; i<m ; i++){
        int tmp;
        cin >> tmp;
        if(tmp) p |= 1 << i;
    }

    int ans = 0;
    for(int i=0; i<(1<<n); i++){
        int cmp = 0;
        for(int j=0; j<n; j++){
            if(i >> j & 1) cmp ^= s[j];
        }
        if(cmp == p) ans++;
    }
    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  map<ll, ll> mp;
  int n;
  cin >> n;
  REP(i,n){
    int x;
    cin >> x;
    mp[x]++;
  }

  ll ans = 0;
  for(auto v: mp){
    ans += v.first * v.second;
  }

  int q;
  cin >> q;
  REP(i,q){
    ll b,c;
    cin >> b >> c;
    ans -= mp[b] * b;
    ans += mp[b] * c;

    mp[c] += mp[b];
    mp[b] = 0;
    PRINT(ans);
  }

}



Measured memory_bytes: 9544
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, max;
            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            max = a + b;
            if (max < a - b)
                max = a - b;
            if (max < a * b)
                max = a * b;

            Console.WriteLine(max);

            Console.ReadKey();
        }
    }


}


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

int main(){
	int N;
	int i, j, cnt, max_digit = 1;
	unsigned long c[100]={0};
	unsigned long ans = 0;

	scanf("%d", &N);

	for(cnt=1; cnt<=N; cnt++){
		if(cnt >= max_digit*10){
			max_digit *= 10;
		}
		i = cnt % 10;
		j = cnt / max_digit;
		c[j*10+i]++;
	}

	for(i=1; i<10; i++){
		for(j=1; j<10; j++){
			ans += c[j*10+i] * c[i*10+j];
		}
	}

	printf("%lu", ans);

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int d[n];
    map<int,int> freq;
    for(int i = 0; i < n; i++){
        cin >> d[i];
        if(d[i] == 0){
            cout << 0 << endl;
            return 0;
        }
        freq[d[i]]++;
    }
    if(freq[0]){
        cout << 0 << endl;
        return 0;
    }
    if(freq[12] >= 2){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 0; i <= 12; i++){
        if(freq[i] >= 3){
            cout << 0 << endl;
            return 0;
        }
    }
    if(n > 12){
        cout << 1 << endl;
        return 0;
    }
    int ans = 0;
    for(int j = 0; j < (1<<n); j++){
        vector<int> t;
        t.push_back(0);
        for(int i = 0; i < n; i++){
            if(j & (1<<i)){
                t.push_back(d[i]);
            } else {
                t.push_back(24-d[i]);
            }
        }
        int mindist = 100000;
        for(int a = 0; a < t.size(); a++){
            for(int b = 0; b < a; b++){
                int z = (48 + t[a] - t[b]) % 24;
                mindist = min(mindist, min(z,24-z));
            }
        }
        ans = max(ans, mindist);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b,c,s=0;

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

  a-=c;

  while(a>=0){
    a-=b;
    a-=c;
    s++;
  }

  if(a<0) s--;

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

  return 0;
}

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

int main() {
	string S;
	cin >> S;
	for(int i=0; i<S.size(); ++i) cout << 'x';
	cout << endl;
	return 0;
}

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

a = [[] for _ in range(n)]
c = [0] * n

for i in range(n):
    t = [int(e) for e in input().split()]
    c[i],a[i] = t[0],t[1:]

inf = 10 ** 9
min_cash = inf

for j in range(2**n):
    sum_cash = 0
    al = [0]*m
    for k in range(n):
        if ((j>>k) & 1):
            sum_cash += c[k]
            for l in range(m):
                al[l] += a[k][l]
       
    f = 1   
    for j in range(m):
        if al[j] < x:
            f = 0

    if f:
        min_cash = min(min_cash,sum_cash)

if min_cash == inf:
    min_cash = -1

print(min_cash)

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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (1000006)
#define INF (1LL << 60)
const int MOD = (int)1e9+7;


signed main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = N*(N-1)*(N-2)/6;

    for(int i=0; i<=9; i++){
        for(int j=0; j<=9; j++){
            for(int k=0; k<=9; k++){
                int cnt1=0, cnt2=0, cnt=0;
                for(int p=0; p<N; p++){
                    int d = S[p]-'0';
                    if(d==k){
                        cnt += cnt2;
                    }
                    if(d==j){
                        cnt2 += cnt1;
                    }
                    if(d==i) cnt1++;
                }
                ans -= max(cnt-1,0LL);
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec) for(int never = 0; never < vec.size(); never++){ cin>>vec[never];}
#define printVec(vec) for(int never = 0; never < vec.size(); never++){ cout<<vec[never]<<" ";} cout<<endl;
#define S second
#define F first
typedef long long ll;
typedef long double ld;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;



void solve() {
    // cout << "test" << endl;
    string s;
    cin >> s;
    vector<ll> v (s.size()+1);
    v[0] = 0;
    ll ctr = 1;
    for (int i = 0; i < s.size(); i++) {
        v[i+1] = (ctr * (s[s.size() - 1 - i] - '0')) % 2019;
        ctr = (ctr * 10) % 2019;
    }
    for (int i = 1; i < v.size(); i++) {
        v[i] = (v[i] + v[i-1]) % 2019;
        // cout << v[i] << endl;
    }   

    map<ll,ll> m;
    for (int i = 0; i < v.size(); i++) {
        m[v[i]]++;
    }
    ll ans = 0;
    for (auto t: m) {
        // cout << "___" << t.first << "  " << t.second << endl;
        ans += ((t.second-1) * t.second) / 2;
    }

    cout << ans << endl;
}

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

    int t;
    t = 1;
    // cin >> t;
    while(t--) {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 5132
import java.util.Scanner;

class Main{
    public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[111];

        for (int i = 0; i < n; ++i) {
            a[i] = scan.nextInt();
        }
        int sw = bubbleSort(a, n);

        for (int i = 0; i < n; i++) {
            System.out.print(a[i]);
            if (i < n- 1 ) System.out.print(" ");
        }
        System.out.println();
        System.out.print(sw);
        System.out.println();
    }

    private static int bubbleSort(int[] A, int N) {
        // 交換回数
        int sw = 0;
        // 交換したかどうかのフラグ
        boolean flag = true;

        for (int i = 0; flag; i++) {
            flag = false;
            for (int j = N - 1; j > 0; j--) {
                if (A[j] < A[j - 1]) {
                    // 隣接要素を交換する
                    swap(A, j, j-1);
                    flag = true;
                    sw++;
                }
            }
        }
        return sw;
    }

    private static void swap(int[] A, int firstElemIdx, int secondElemIdx) {
        int tmp = A[firstElemIdx];
        A[firstElemIdx] = A[secondElemIdx];
        A[secondElemIdx] = tmp;
    }

}


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

using namespace std;

int main(void)
{
	int N, K;
	
	cin >> N;
	
	vector<int> d(N);
	
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	
	sort(d.begin(), d.end());
	
	cout << d[N / 2] - d[N / 2 - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 640
H, W, h, w=map(int, raw_input().split())
if H%h==0 and W%w==0:
	print "No"
	exit()
swapped=False
if not W%w:
	swapped=True
	H, W, h, w=W, H, w, h
a=[(([1000000]*(w-1)+[-1000000*(w-1)-1])*(W/w+1))[:W]]*H
if swapped:
	a=[[a[i][j] for i in range(H)] for j in range(W)]
print "Yes"
for row in a:
	for value in row:
		print value,
	print

Measured memory_bytes: 6788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)

int main(){
	ll n;
  	cin >> n;
  	vector<ll> a(n + 1);
  	rep(i, 1, n + 1) cin >> a[i];
  	rrep(i, 1, n + 1){
      	for(ll j = i * 2; j <= n; j += i) a[i] ^= a[j];
    }
  	cout << accumulate(a.begin(), a.end(), 0ll) << endl;
  	rep(i, 1, n + 1) if(a[i]) cout << i << ' ';
  	cout << endl;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);    
     int n,c=0;
         cin>>n;
           for(int i=0;i<n; i++){
		       int k;
		          cin>>k;
		           if(k%2==0)
		           {
					    if(k%3 && k%5 ){
						c=1;
						}
					      
					     
				   }
		   
		   }
		   if(c)
		     cout<<"DENIED"<<endl;
		     else
		     cout<<"APPROVED"<<endl;
    }



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

using namespace std;

int main()
{
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> bm(m);
	int sum = 0;
	for (int i = 0; i < m; i++) {
		cin >> bm[i];
	}
	int a;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		sum = 0;
		for (int j = 0; j < m; j++) {
			cin >> a;
			sum += a * bm[j];
		}
		sum += c;
		if (sum > 0) cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int n = sz(s);
    ll ans = 0;
    vector <int> st(n + 1);
    st[0] = 1;
    int mod = 2019;
    for (int i = 1; i <= n; i++) st[i] = (st[i - 1] * 10) % mod;
    vector <int> suff(n);
    map <int, int> cnt;
    ++cnt[0];
    for (int i = n - 1; i >= 0; i--) {
        suff[i] = (s[i] - '0') * st[n - i - 1];
        if (i + 1 < n) suff[i] += suff[i + 1];
        suff[i] %= mod;
        ans += cnt[suff[i]];
        ++cnt[suff[i]];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	string a;
	cin>>a;
	fo(i,a.sz-8)
	cout<<a[i];
	cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)



int main()
{
	ll n;
	cin >> n;
	vector<ll> d(n);
	rep(i, n) cin >> d[i];
	sort(d.begin(), d.end());
	ll k = n / 2;
	cout << d[k] - d[k-1] << "\n";

	return 0;
}

Measured memory_bytes: 4048
#include <stdio.h>
int main() {
	int num;
	int a[2];
	int b[4] = { 0, };
	for (int i = 0; i < 2; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < 2; i++) {
		b[a[i]] = 1;
	}
	for (int i = 1; i <= 3; i++) {
		if (b[i] != 1)
			printf("%d", i);
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	unsigned long long int N, M;
	cin >> N >> M;

	unsigned long long int ans = N*M;
	if (N == 1 && M == 1)
	{
		cout << ans << endl;
		return 0;
	}

	if (N == 1 || M == 1)
	{
		cout << ans - 2 << endl;
		return 0;
	}

	cout << ans - 4 - (N - 2) * 2 - (M - 2) * 2 << endl;
	return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}


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

bool chkTyofuku(vector<string>& vec,string str){
  int cnt = 0;
  for(int i = 0; i < vec.size(); i++){
    if(vec.at(i) == str) cnt++;
  }
  
  if(cnt >= 2) return false;
  else true;
}

int main(){
  int num;
  bool chk = true;
  cin >> num;
  
  vector<string> vec(num);
  for(int i = 0; i < num; i++){
    cin >> vec.at(i);
  }
  
  string befor,after;
  for(int i = 0; i < num; i++){
    if(i == 0) continue;
    
    befor = vec.at(i-1);
    after = vec.at(i);
    if(befor.substr(befor.size()-1,1) != after.substr(0,1)) chk = false;
    if(chkTyofuku(vec,after) == false) chk = false;
  }
  
  if(chk == true) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
//#define ll __int64
#define ll long long
int n;
ll a[222222];
ll b[222222];

int main(){
    cin>>n;
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];

    ll ans=0;
    
    for(int i=n-1;i>=0;i--){
        
        
        ll cnt2=min(b[i],a[i+1]);
        ans+=cnt2;
        b[i]-=cnt2;
        a[i+1]-=cnt2;
        
        
        ll cnt=min(b[i],a[i]);
        
        ans+=cnt;
        b[i]-=cnt;
        a[i]-=cnt;
    }    
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;

const double pi = 3.14159265358979323846;

int main(){
  int n,temp;
  vector<int> R;
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> temp;
    R.push_back(temp);
  }

  int maxv = -2000000000;
  int minv = R[0];

  for (int i=1;i<n;++i){
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

cout << maxv << endl;

  return 0;
}

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

int main() {
    int N;
    cin >> N;
    int H[N];
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }
    bool judge = true;
    for(int i = N - 1; i >= 1; i--){
        if(H[i - 1] - H[i] > 1){
            judge = false;
        }else if(H[i - 1] - H[i] == 1){
            H[i - 1]--;
        }
    }
    if(judge){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
map<ll,ll> mp;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll ans=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        ans+=a[i];
        mp[a[i]]++;
    }
    ll q;
    cin>>q;
    vector<ll> res(q);
    for(ll i=0;i<q;i++){
        ll b,c;
        cin>>b>>c;
        ans+=(c-b)*mp[b];
        res[i]=ans;
        mp[c]+=mp[b];
        mp[b]=0;
    }
    for(ll i=0;i<q;i++) cout<<res[i]<<endl;

}

Measured memory_bytes: 10492
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

long long int a,b,c,x,ans ;

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



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

static bool canhold(
    const std::vector<std::pair<long long, long long>>& Ps,
    long long xr,
    long long xl,
    long long yb,
    long long yt,
    int k
)
{
    int cnt = 0;
    for (auto& p: Ps) {
        if (xr <= p.first && p.first <= xl && yb <= p.second && p.second <= yt) {
            cnt++;
        }
    }
    return cnt >= k;
}

int main() {
    int n, k; std::cin >> n >> k;
    std::vector<std::pair<long long, long long>> Ps(n);

    for (int i = 0; i < n; i++) {
        int x, y; std::cin>> x >> y;
        Ps[i].first = x; Ps[i].second = y;
    }

    long long m = 2e9 * 2e9;

    for (int xr = 0; xr < n; xr++) {
        for (int xl = xr + 1; xl < n; xl++) {
            for (int yb = 0; yb < n; yb++) {
                for (int yt = yb + 1; yt < n; yt++) {
                    auto XR = std::min(Ps[xr].first, Ps[xl].first);
                    auto XL = std::max(Ps[xr].first, Ps[xl].first);
                    auto YB = std::min(Ps[yb].second, Ps[yt].second);
                    auto YT = std::max(Ps[yb].second, Ps[yt].second);

                    auto M = (YT - YB) * (XL - XR);

                    if (M >= m) {
                        continue;
                    }

                    if (!canhold(Ps, XR, XL, YB, YT, k)) {
                        continue;
                    }

                    m = std::min(m, M);
                }
            }
        }
    }

    std::cout << m << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
 
using namespace std;
 
const int N = 2e5;
int r[N];
 
int main()
{
    int n;
 
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> r[i];
 
    int maxval = INT_MIN;
    int minval = r[0];
    for(int i=1; i<n; i++) {
        maxval = max(maxval, r[i] - minval);
        minval = min(minval, r[i]);
    }
 
    cout << maxval << endl;
 
    return 0;

}


Measured memory_bytes: 3876
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<iostream>
using namespace std;
int n;
long long d;
long long a;
long long ans;
long long res;
struct point
{
	long long x,h;
}p[200020];
bool cmp(point p1,point p2)
{
	return p1.x<p2.x;
}
long long dp[200020];
int check(long long x)
{
	int l=1;
	int r=n+1;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(p[mid].x<=x)
		{
			l=mid+1;
		}
		else
		r=mid-1;
	}
	if(l>r)
	{
		swap(l,r);
	}
	while(l>=1&&p[l].x>x)
	{
		l--;
	}
	while(l<=n&&p[l].x<=x)
	{
		l++;
	}
	return l;
}
int main()
{
	cin>>n>>d>>a;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i].x>>p[i].h;
	}
	sort(p+1,p+n+1,cmp);
	//printf("%d %d %d\n",check(1),check(6),check(9));
	for(int i=1;i<=n;i++)
	{
		res-=dp[i];
		p[i].h-=res;
		if(p[i].h>0)
		{
			long long x=p[i].h/a;
			if(a*x<p[i].h)
			{
				x++;
			}
			ans+=x;
			long long y=p[i].x+2ll*d;
			int pos=check(y);
			dp[pos]+=a*x;
			res+=a*x;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define N 2000010
#define mod 1000000007
#define int long long
using namespace std;
struct data
{
	int c,w;
}a[N];
int fac[N],imfac[N],n,X,Y,num,sum[N],minn1,minn2,minn[N];
long long ans=1;
int fastpow(int x,int y)
{
	int sum=1;
	while(y)
	{
		if(y&1)
		{
			sum=(sum*x)%mod;
		}
		x=(x*x)%mod;
		y>>=1;
	}
	return sum;
}
int C(int n,int m)
{
	if(!m)
	{
		return 1;
	}
	if(m>n)
	{
		return 0;
	}
	return ((fac[n]*imfac[n-m])%mod*imfac[m])%mod;
}
signed main()
{
	memset(minn,127,sizeof(minn));
	scanf("%lld%lld%lld",&n,&X,&Y);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i].c,&a[i].w);
		minn[a[i].c]=min(minn[a[i].c],a[i].w);
	}
	for(int i=1;i<=n;i++)
	{
		if(minn[i]<minn[minn1])
		{
			minn2=minn1;
			minn1=i;
		}else{
			if(minn[i]<minn[minn2])
			{
				minn2=i;
			}
		}
    }
	for(int i=1;i<=n;i++)
	{
		if(a[i].w+minn[a[i].c]<=X)
		{
			a[i].w=minn[a[i].c];
		}
		if(a[i].c==minn1&&minn[minn2]+a[i].w<=Y)
		{
			sum[a[i].c]++;
			num++;
		}
		if(a[i].c!=minn1&&minn[minn1]+a[i].w<=Y)
		{
			sum[a[i].c]++;
			num++;
		}
    }
	fac[0]=1;
	for(int i=1;i<=n;i++)
	{
		fac[i]=(1ll*fac[i-1]*i)%mod;
	}
	imfac[n]=fastpow(fac[n],mod-2);
	for(int i=n-1;i>=0;i--)
	{
		imfac[i]=(1ll*imfac[i+1]*(i+1))%mod;
	}
	for(int i=1;i<=n;i++)
	{
		if(sum[i])
		{
			ans=1ll*ans*C(num,sum[i])%mod;
			num-=sum[i];
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 33024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

// int main(){
// 	int n;
// 	cin >> n;
// 	vector<ll> dp(n+1);
// 	for(int i = 0; i <= n; i++) {
// 		dp[i] = n;
// 	}
// 	dp[0] = 0;
// 	//もらうDP
// 	for(int i = 0; i <= n; i++) {
// 		ll tmp = 1;
// 		while(tmp <= i && tmp <= n){
// 			dp[i] = min(dp[i],dp[i - tmp] + 1);
// 			tmp *= 6;
// 		}
// 		tmp = 1;
// 		while(tmp <= i && tmp <= n){
// 			dp[i] = min(dp[i],dp[i - tmp] + 1);
// 			tmp *= 9;
// 		}
// 	}

// 	cout << dp[n] << endl;
// 	return 0;
// }

int main(){
	int n;
	cin >> n;
	vector<ll> dp(n+1);
	for(int i = 0; i <= n; i++) {
		dp[i] = n;
	}
	dp[0] = 0;
	//あげるDP
	for(int i = 0; i <= n; i++) {
		ll tmp = 1;
		while(tmp+i <= n){
			dp[i + tmp] = min(dp[i + tmp],dp[i] + 1);
			tmp *= 6;
		}
		tmp = 1;
		while(i+tmp <= n){
			dp[i+tmp] = min(dp[i+tmp],dp[i] + 1);
			tmp *= 9;
		}
	}

	cout << dp[n] << endl;
	return 0;
}

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

void addString(int i, char ch, string& str) {
    char buff[16] = {};
    sprintf(buff, "%d", i);
    str += buff;
    str += ch;
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        string from;
        cin >> from;
        for (int i = 0; i < n; i++) {
            int count = 1;
            char pre = from[0];
            string to;
            for (int j = 1; j < (int) from.length(); j++) {
                if (pre == from[j]) {
                    count++;
                } else {
                    addString(count, pre, to);
                    count = 1;
                    pre = from[j];
                }
            }
            addString(count, pre, to);
            from = to;
        }
        cout << from << endl;
    }
}

Measured memory_bytes: 0
a,b,c = map(int,input().split())
k = int(input())

is_Ok = False
for i in range(k) :
    # print(k,a,b,c)
    if (a >= b) :
        b *= 2
        continue

    if (b >= c) :
        c *= 2
        continue

    if (a<b and b<c) :
        is_Ok = True
        break

if (a<b and b<c) :
    is_Ok = True

if (is_Ok) :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 9224
#include<iostream>

using namespace std;

void Swap(int *a,int *b){
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){

	int a[10];

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

	int i,j;
	for(i=0;i<10;i++){
		for(j=9;j>i;j--){
			if(a[j]<=a[j-1]){
				Swap(&a[j],&a[j-1]);
			}
		}
	}

	cout<<a[9]<<endl;
	cout<<a[8]<<endl;
	cout<<a[7]<<endl;

	return 0;
}

Measured memory_bytes: 0
import math

#
X, Y = list(map(int, input().split()))

#
A = lambda i: X*2**(i-1)

#
n = int(math.log2(Y/X) + 1)

for i in range(-2, 3):
    if Y<A(n + i):
        print(n + i - 1)
        exit()


Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int main() {
	int n,a[100];
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = n-1; i > 0; --i) cout << a[i]<<' ';
	cout << a[0];
	cout << endl;	
}


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


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

    string S;
    cin >> S;

    if(N % 2 != 0){
        cout << "No";
        return 0;
    }

    int a;
    a = N/2;


    for(int i=0;i<a;i++){
        if(S.at(i) != S.at(a+i)){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  int tn = N; while(tn%2==0) tn /= 2;
  if (tn==1) { cout << "No" << endl; return 0; }

  cout << "Yes" << endl;
  cout << 1 << " " << 2 << endl; cout << N+1 << " " << N+2 << endl;
  cout << 2 << " " << 3 << endl; cout << N+2 << " " << N+3 << endl;
  cout << 3 << " " << N+1 << endl;

  for (int i=4; i+1<=N; i+=2) {
    cout << 1 << " " << i << endl; cout << i << " " << i+1 << endl;
    cout << 1 << " " << N+i+1 << endl; cout << N+1+i << " " << N+i << endl;
  }
  if (N%2==0) {
    cout << N << " " << N/tn << endl;
    cout << N*2 << " " << N*2-N/tn+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 2304
n = int(input())
sp = [list(input().split())+[i+1] for i in range(n)]
sp = [[s,-int(p),i] for s,p,i in sp]

sp.sort()

for s,p,i in sp:
    print(i)

"""
from operator import itemgetter

n = int(input())
l = []

for i in range(n):
    s,p = map(str,input().split())
    p = int(p)
    l.append([s,p,i+1])

l.sort(key = itemgetter(0))
l = sorted(l, key = lambda x:(x[1]),reverse = True)
print(l)
"""


Measured memory_bytes: 3060
// while( !(succeed == try()) );

#include "bits/stdc++.h"
using namespace std;

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


void alpha()
{	
	int n;
	cin>>n;

	int arr[n+1];
	int sum = 0;
	loop(i,1,n+1){
		if(i%3 != 0 and i%5!=0) sum+=i;
	}

	cout<<sum;
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

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

int main()
{
  int n;
  cin >> n;
  int m = -10000, idx;

  for (int i = 1; i <= n; i++) {
    int tmp = 0, x = i;
    while (x != 1 && x != 0) {
      x /= 2;
      tmp++;
    }
    if (m < tmp) {
      m = tmp;
      idx = i;
    }
  }

  cout << idx << endl;
}


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

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');
    cout.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

int main(){
    nimble;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll as=a*d;
    ll as2=a*c;
    ll as3=b*c;
    as=max(as,b*d);
    as=max(as,as2);
    as=max(as,as3);
    cout<<as;
    return 0;
}



Measured memory_bytes: 3648
n = int(input())
h = list(map(int, input().split()))

res = 0
while max(h) > 0:
    first_flag = True
    for i in range(n):
        if h[i] == 0:
            first_flag = True
            continue

        if first_flag:
            res += 1
            first_flag = False
        h[i] -= 1

print(res)

Measured memory_bytes: 39024
/*
カタラン数は何も語ら   
*/
 
//#define NDEBUG
 
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <map>
#include <set>
#include <vector>
#include <complex>
#include <queue>
#include <tuple>
 
using namespace std;
typedef long long ll;

ll pow_mod(ll x, ll n, ll mod) {
    ll r = 1;
    while (n) {
        if (n & 1) r = (r * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return r;
}

ll invp(ll r, ll mod) {
    return pow_mod(r, mod-2, mod);
}

const int MN = 300100;
const ll MD = 1e9+7;
ll fact[MN];
ll invf[MN];
void init() {
    fact[0] = 1;
    for (int i = 1; i < MN; i++) {
        fact[i] = fact[i-1]*i;
        fact[i] %= MD;
    }
    for (int i = 0; i < MN; i++) {
        invf[i] = invp(fact[i], MD);
    }
}

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

int main() {
    init();
    int n, m, k;
    cin >> n >> m >> k;
    int u = n+m+2*k;
    ll res = 0;
    for (int i = 0; i <= k; i++) {
        int j = k-i;
        ll r = comb(u, n+2*i);
        r *= (comb(n+2*i, i)-comb(n+2*i, i-1)+2*MD)%MD;
        r %= MD;
        r *= (comb(m+2*j, j)-comb(m+2*j, j-1)+2*MD)%MD;
        r %= MD;
        res += r;
        res %= MD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5844
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long ac = 0;
            long wa = 0;
            long tle = 0;
            long re = 0;
            for (var i = 1; i <= n; i++)
            {
                string tmp = Console.ReadLine();
                switch (tmp)
                {
                    case "AC":
                        ac++;
                        break;
                    case "WA":
                        wa++;
                        break;
                    case "TLE":
                        tle++;
                        break;
                    case "RE":
                        re++;
                        break;
                }
            }
            Console.WriteLine($"AC x {ac}");
            Console.WriteLine($"WA x {wa}");
            Console.WriteLine($"TLE x {tle}");
            Console.WriteLine($"RE x {re}");
        }
    }
}

Measured memory_bytes: 30528