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

using namespace std;
int n;
int s[200001], a[200001], b[200001], kol[29];
int bin(int x){
    int l = 1;
    int r = n + 1;
    while(r - l > 1){
        int mid = (r + l) / 2;
        if(s[mid] >= x){
            r = mid;
        }
        else{
            l = mid + 1;
        }
    }
    if(s[l] >= x){
        return l;
    }
    return r;
}
int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int j = 1; j <= n; j++){
        cin >> b[j];
    }
    long long ans = 0;
    for(int i = 0; i <= 28; i++){
        long long cnt = 0;
        int step = (1 << (i + 1));
        for(int j = 1; j <= n; j++){
            s[j] = b[j] % step;
        }
        sort(s + 1, s + 1 + n);
        for(int j = 1; j <= n; j++){
            cnt += n - bin((1 << (i)) - (a[j] % step)) + 1;
        }
        for(int j = 1; j <= n; j++){
            cnt -= bin(step + ((1 << i) - (a[j] % step))) - bin(step - (a[j] % step));
        }
        if(cnt % 2){
            ans += (1 << i);
        }
    }
    cout << ans;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>

#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void){
  int N,K;
  cin >> N >> K;
  vector<int> v;
  for(int i= 0;i< N;i ++){
    int x;
    cin >> x;
    v.push_back(x);
  }
  int count = 0;
  if(N == K){
  cout << 1 << endl;    
  }else{
    while(N > 0){
      if(N == K) {
        count ++;
        break;
      }
      N = N - K + 1;
      count ++;
    }
  cout << count << endl;
  }
}

Measured memory_bytes: 892
// ------------------------------------
// Date:2018/ 2/18
// Problem:ABC 088 _ b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

int main()
{
  int N,a,b;
  cin >> N;
  a = b = 0;
  vector <int> V(N);
  REP(i,N) {
    cin >> V[i];
  }
  sort(V.begin(),V.end());
  REP(i,V.size()) {
    if (i%2 == 0) {
      a += V[V.size()-i-1];
      //cout << a << endl;
    } else {
      b += V[V.size()-i-1];
      //cout << b << endl;
    }
  }
  cout << a-b << endl;
  return 0;
}



Measured memory_bytes: 256
def main():
    n = int(input())
    a = [int(i) for i in input().split()]

    s = max(list(set(a))) + 1
    
    c = 0
    for i in range(1, n):
        if a[i-1] == a[i]:
            c += 1
            a[i] = s
            s += 1

    print(c)
            
if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import heapq
import sys

input = sys.stdin.readline

def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d
#########################
n,w = map(int,input().split())
edge = [[] for i in range(n)]
#隣接リスト edge[i]:[コスト,行先]
for i in range(n-1):
    edge[i+1].append([0, i])

for i in range(w):
    x,y,z = map(int,input().split())
    edge[x-1].append([z,y-1])
    edge[y-1].append([z,x-1])
ret = dijkstra_heap(0, edge)[-1]
if ret == float("inf"):
    ret = -1
print(ret)



Measured memory_bytes: 62112
import collections


N = int(input())
A = [int(input()) for i in range(N)]


sorted_A = list(reversed(sorted(A)))

maxiuam = sorted_A[0]
is_there_tow_maximum = A.count(maxiuam) >= 2

second = None
for Ai in sorted_A:
    if Ai < maxiuam:
        second = Ai
        break

answer = []
for Ai in A:
    if is_there_tow_maximum:
        answer.append(maxiuam)
    elif Ai == maxiuam:
        answer.append(second)
    else:
        answer.append(maxiuam)
answer = "\n".join(map(str, answer))

print(answer)


Measured memory_bytes: 29664
/*
 
@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //     
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai
*/
 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
#define fr(i,start,end, inc) for(ll i=(start); i<(end); i+=inc)
#define rf(i,end,start, inc) for(ll i=(start-1); i>=(end); i-=inc)
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<n; i++)
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define pl pair<ll, ll>
#define pi pair<int,int>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx =  1e9+7;

bool compare(const pl &a, const pl &b){
    return a.fi<b.fi || (a.fi==b.fi && a.se<b.se);
}
ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll inv(ll n, ll p){
    return power(n,p-2, p);
}
inline vector<ll> allinv(ll n, ll p){
    vector<ll> arr(n);
    arr[1]=1;
    fr(i,2,n,1){
        arr[i] = (p - (p/i)*arr[p%i]%p)%p;
    }
    return arr;
}
vector<ll> inline allncr(ll n, ll p){
    vector<ll> nci(n+1);
    nci[0]=1;
    nci[n]=1;
    vector<ll> v = allinv(n,p);
    fr(i,1,n,1){
        nci[i]=(nci[i-1]*(n-i-1))%p;
    }
    return nci;
}
ll max3(ll a, ll b, ll c){
    return max(max(a,b),c);
}

bool inline isPrime(ll n) { 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
}

void prt(int i){   
    i ? cout << "YES\n" : cout << "NO\n" ;
}

template<class T>
void printv(T &v){
    ll n = v.size();
    rep(i,n)
        cout << v[i] << " ";
    cout << "\n";
}


int main(){
    fsync
    ll test=1;
    // cin >> test;
    while(test--){
        ll n;
        cin >> n;
        cout << n/2 + n%2 << "\n";
    }

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
int n, dp[100005][4],tab[100005][4];

cin>>n;
for(int i=1; i<=n; i++){
  cin>>tab[i][1]>>tab[i][2]>>tab[i][3];
}

dp[1][1]=tab[1][1];
dp[1][2]=tab[1][2];
dp[1][3]=tab[1][3];


for(int i=2; i<=n; i++){
dp[i][1]=max(dp[i-1][2],dp[i-1][3])+tab[i][1];
dp[i][2]=max(dp[i-1][1],dp[i-1][3])+tab[i][2];
dp[i][3]=max(dp[i-1][1],dp[i-1][2])+tab[i][3];
}

int wynik=max(dp[n][1],dp[n][2]);
cout<<max(wynik,dp[n][3]);

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  ll L, R; cin >> L >> R;

  ll ans = inf;
  if(R-L>=4038) {
    cout << 0 << endl;
  }
  else {
    for(ll i=L; i<=R-1; i++) {
      for(ll j=i+1; j<=R; j++) {
        ans = min(ans, (i*j)%2019);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
# coding: utf-8
import math

N = int(input())

sum = 0
ans = 0
for a in range(1, math.floor(math.sqrt(N)) + 1):
    b = N // a
    if N == a * b:
        sum = 0
        while not b == 0:
            b = b // 10
            sum += 1
        if ans > sum or ans == 0:
            ans = sum
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  string s;
  char s2[3] = "a" ;
  int d;
  map<string,int> msi ;
  while(scanf("%d,%s",&d,s2) != EOF){
    s = s2 ;
    ++msi[s] ;
  }
  cout << msi["A"] << "\n" << msi["B"] << "\n" << msi["AB"] << "\n" << msi["O"] << endl;
  return 0;
}

Measured memory_bytes: 1228
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 10
#else
#define SIZE 223450
#endif

int N,M;
int A[SIZE], B[SIZE];

void solve() {
    cin>>N;
    REP1(i,N)cin>>A[i];
    RREP1(i,N) {
        int sum = 0;
        for (int j=2; i*j<=N; j++) {
            sum += B[i*j];
        }
        if (A[i]!=sum%2) {
            B[i]=1;
            M++;
        }
    }
    cout << M << endl;
    REP1(i,N) if (B[i]) cout << i << " ";
    if (M) cout << endl;
}


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

int main(){
  vector<int> v;

  for(int j = 0; j < 2; j++){
    int t[10];

    for(int i = 0; i < 10; i++){
      cin >> t[i];
    }
    sort(t, t + 10, greater<int>());
    v.push_back(t[0] + t[1] + t[2]);
  }

  cout << v[0] << " " << v[1] << endl;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
	static Scanner in = new Scanner(System.in);
	
	public static void main(String[] args){
		int H = in.nextInt(), W = in.nextInt();
		String[] a = new String[H];
		a[0] = in.nextLine();
		for(int i = 0; i < H; i++){
			a[i] = in.nextLine();
		}
		int sum = 0;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(a[i].charAt(j) == '#'){
					sum++;
				}
			}
		}
		if(sum == (H + W - 1)){
			System.out.println("Possible");
		}else{
			System.out.println("Impossible");
		}
	}
}

Measured memory_bytes: 21972
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

#include <cassert>
#include <iosfwd>

template <int M> class ModularInteger {
    static_assert(M >= 2);

  public:
    static constexpr int modulus = M;

    ModularInteger(long long x = 0) : value(x % M) {}

    ModularInteger& operator+=(const ModularInteger& Mi) noexcept {
        value += Mi.value;
        auto x = value - M;
        if (x >= 0)
            value = x;
        return *this;
    }

    ModularInteger& operator-=(const ModularInteger& Mi) noexcept {
        value -= Mi.value;
        if (value < 0)
            value += M;
        return *this;
    }

    ModularInteger& operator*=(const ModularInteger& Mi) noexcept {
        value = large{value} * large{Mi.value} % M;
        return *this;
    }

    friend std::ostream& operator<<(std::ostream& stream, const ModularInteger& Mi) { return (stream << Mi.value); }

    friend std::istream& operator>>(std::istream& stream, ModularInteger& Mi) {
        long long v = 0;
        stream >> v;
        v %= M;
        Mi.value = (v < 0 ? v + M : v);
        return stream;
    }

    friend constexpr long long unwrap(ModularInteger Mi) noexcept { return Mi.value; }

  private:
    long long value = 0;
};

template <int M> class Modular {
    static_assert(M >= 2);

  public:
    static constexpr int modulus = M;
    using IntegerType = ModularInteger<M>;

    static long long power(long long base, long long exp) noexcept {
        assert(0 <= base && base < M);
        assert(0 <= exp && exp < M);
        if (exp == 0)
            return 1;
        if (exp == 1)
            return base;

        auto p = power(base * base % M, exp / 2);
        if (exp % 2 == 1) {
            p *= base;
            p %= M;
        }
        return p;
    }

    static long long factorial(long long n) noexcept {
        assert(0 <= n && n < M);
        if (n <= 1)
            return 1;

        long long f = 2;
        while (n > 2) {
            f = (f * n) % M;
            --n;
        }
        return f;
    }

    static long long inverse(long long x) noexcept { return power(x, M - 2); }

    static long long combination(long long n, long long k) noexcept {
        assert(0 <= k && k <= n);

        auto fn = factorial(n);
        auto fk = factorial(k);
        auto fnk = factorial(n - k);
        auto d = inverse(fk * fnk % M);
        return fn * d % M;
    }
};

using M = Modular<1'000'000'007>;

static large solve(const int X, const int Y) {
    // a: number of {+1, +2}
    // b: number of {+2, +1}

    // a * 2 + b * 1 == Y
    // a * 1 + b * 2 == X
    // a * 3         == 2 * Y - X
    // a = (2 * Y - X) / 3
    // b = Y - 2 * a

    auto q = 2 * Y - X;
    if (q < 0 || q % 3 != 0) {
        return 0;
    }

    auto a = q / 3;
    auto b = Y - 2 * a;
    if (b < 0) {
        return 0;
    }

    return M::combination(a + b, a);
}

int main() {
    auto X = 0, Y = 0;
    cin >> X >> Y;

    cout << solve(X, Y) << "\n";
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
int a[maxn],b[maxn];

int main(){
	int n,m;
	cin >> n >> m;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	for(int i = 1;i <= m;i++){
		int t;
		string s;
		cin >> t >> s;
		if(s == "AC"){
			a[t] = 1;
		}
		else if(s == "WA"){
			if(!a[t])
				b[t]++;
		}
	}
	int cnt1 = 0,cnt2 = 0;
	for(int i = 1;i <= n;i++){
		if(a[i]){
			cnt1++;
			cnt2 += b[i];
		}
	}
	printf("%d %d\n",cnt1,cnt2);	
	return 0;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
        #include<chrono>
         
        using namespace std;
        using namespace std::chrono;
        typedef long long ll;
        typedef vector<int> vi;
        typedef pair<int,int> pi;
        #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
        #define F first
        #define S second
        #define PB push_back
        #define EB emplace_back
        #define MP make_pair
        #define REP(i,a,b) for(i=a;i<=b;i++)
        #define RAP(i,a,b) for(i=a;i>=b;i--)
        ll mod=1000000007;
        const int MX=0x3f3f3f3f;
        
        int main(){
            IOS;
            int n,W,i,j;
            cin>>n>>W;
            ll w[n],v[n];
            REP(i,0,n-1) cin>>w[i]>>v[i];
            int V=1e5;
            vector<ll> dp(V+1,INT32_MAX);
            dp[0]=0;
            REP(i,1,n){
                RAP(j,V,v[i-1]){
                    dp[j]=min(dp[j],dp[j-v[i-1]]+w[i-1]);
                    //cout<<dp[j]<<" ";
                }
                //cout<<"\n";
            }
            RAP(i,V,0){
                if(dp[i]<=W) {
                    cout<<i;
                    break;
                }
            }
            return 0;
        }

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 100000;
    for (int i = 0; i <= s.size() - t.size(); i++) {
        string l = s.substr(i, t.size());
        int cnt = 0;
        for (int j = 0; j < t.size(); j++) {
            if (l[j] != t[j]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
vector<int>v;
int n, a;
int dp[100][6000];
int f(int i, int p) {
	if (dp[i][p + a*n] >= 0)return dp[i][p + a*n];
	if (i == v.size()) return (p == 0 ? 1 : 0);
	return dp[i][p + a*n] = (f(i + 1, p)+ f(i + 1, p + v[i]));
}
signed main() {
	cin >> n >> a;
	for (int i = 0; i <= n; i++) 
		for (int j = 0; j <= a*n*2; j++)dp[i][j] = -1;
	int p = 1;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		if (x == a) {
			p *= 2;
		}
		else v.push_back(x - a);
	}
	cout << p * f(0, 0) - 1 << endl;
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm>
#define int long long
#define MAX 20000
using namespace std;

signed main() {
  int n;
  cin >> n;
  int s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  sort(s, s + n);
  int dp[MAX];
  for (int i = 0; i < MAX; i++) {
    dp[i] = 0;
  }

  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = MAX - 1; j >= 0; j--) {
      if (dp[j]) {
	dp[j + s[i]] = 1;
      }
    }
  }

  for (int i = MAX - 1; i > 0; i--) {
    if (dp[i] && i % 10) {
      cout << i << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
string s;
int n,r,g,b;
void solve(){
    cin>>n>>s;
    for(auto i:s){
    	if(i=='R') r++;
    	if(i=='G') g++;
    	if(i=='B') b++;
    }
    int ans=r*g*b;
    rep(i,0,n){
    	rep(j,1,n){
    		int l=i-j;
    		int rr=i+j;
    		if(l>=0 and l<n and rr>=0 and rr<n and s[l]!=s[i] and s[rr]!=s[i] and s[l]!=s[rr]) ans--;
    	}
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        sc.nextLine();
        long a[] = new long[5];
        for(int i = 0;i<5;i++){
            a[i] = sc.nextLong();
            sc.nextLine();
        }
        Arrays.sort(a);
        long ans = 4;
        ans += n / a[0];
        if(n % a[0] != 0){
            ans += 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int c = 0;
	while (A >= B) {
		B *= 2;
		++ c;
	}
	while (B >= C) {
		C *= 2;
		++ c;
	}
	cout << (c <= K ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3620
def main():
  import sys
  b=sys.stdin.buffer
  h,w=map(int,b.readline().split())
  x=w+1
  s=[c>>3for c in b.read()]
  dp=[10000]*h*x
  dp[0]=5-s[0]
  for i in range(1,w):
    dp[i]=dp[i-1]+(s[i-1]^s[i])
  for i in range(x,h*x,x):
    l=i-x
    dp[i]=dp[l]+(s[l]^s[i])
    for j in range(1,w):
      k=i+j
      l=k-1
      t=dp[l]+(s[l]^s[k])
      l=k-x
      u=dp[l]+(s[l]^s[k])
      if t>u:t=u
      dp[k]=t
  print(dp[-2]+1>>1)
main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int f[300] = {};
    int g[300] = {};
    int flag = 1;
    rep(i,n){
        f[s[i]] = t[i];
        g[t[i]] = s[i];
    }
    string ss = s;
    string tt = t;
    rep(i,n){
        ss[i] = f[s[i]];
        tt[i] = g[t[i]];
    }
    if(ss == t && tt == s)yn;
    return 0;
}
 
 


Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 1000000000
#define MOD 1000000007;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;


int main()
{
	int N;
	cin >> N;
	string s1, s2;
	cin >> s1 >> s2;

	int ptr = 0;
	ll ans = 1;
	bool before;

	if (s1[0] == s2[0])
	{
		ptr++;
		ans *= 3;
		before = false;
	}
	else
	{
		ptr += 2;
		ans *= 6;
		before = true;
	}

	while (ptr < N)
	{
		if (s1[ptr] == s2[ptr])
		{
			if (before == false)
			{
				ptr++;
				ans = (ans * 2) % MOD;
			}
			else
			{
				ptr++;
			}

			before = false;
		}
		else
		{
			if (before == false)
			{
				ptr += 2;
				ans = (ans * 2) % MOD;
			}
			else
			{
				ptr += 2;
				ans = (ans * 3) % MOD;
			}

			before = true;
		}
	}

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



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

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

	int a,b,c;
	cin>>a>>b>>c;
	
	if(a == b && b == c)
		cout<<1;
	else if(a != b && a != c && b != c)
		cout<<3<<endl;
	else{
			cout<<2<<endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a[3],b,c,d;
scanf("%d %d %d",&a[0],&a[1],&a[2]);
for(b=0;b<=1;b++){
for(c=2;c>=b+1;c--){
if (a[c]<a[c-1]){
d=a[c];
a[c]=a[c-1];
a[c-1]=d;
}}}
printf("%d %d %d\n",a[0],a[1],a[2]);
return 0;
}

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

int main() {
  int A;
  int B;
  int C;
  int D;
  
  cin  >> A >> B >> C >> D ;
  
  int x ;
  int y ;
  x = A + B ; y = C + D;
  
  if ( x > y ) {
    cout << " Left " << endl;
  }
  else if ( x < y ) {
    cout << " Right " << endl;
  }
  else {
    cout << "Balanced " << endl;
  }
  
}




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

#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout)

int main() {
	ioso;
	#ifndef ONLINE_JUDGE
	ffe;
	#endif

	ll n; cin >> n;
	ll a[300010];
	memset(a,0,sizeof(a));
	ll b;
	for(int i=1;i<n;i++) {
		cin >> b;
		a[b]++;
	}	

	for (int i = 1; i <= n; ++i)
	{
		cout << a[i] << endl;
	}
		
}

Measured memory_bytes: 6004
H,W = map(int,input().split())
S = [input() for _ in range(H)]
L,R,D,U = [[[0]*W for _ in range(H)] for i in range(4)]
 
for h in range(H):
    for w in range(W):
        if S[h][w] == '.':
            L[h][w] = L[h][w-1]+1
            U[h][w] = U[h-1][w]+1
        if S[h][W-1-w] == '.':
            R[h][-w-1] = R[h][-w]+1
        if S[H-1-h][w] == '.':
            D[-h-1][w] = D[-h][w]+1
 
ans = 0
for h in range(H):
    for w in range(W):
        if S[h][w] == '.':
            ans = max(ans,L[h][w]+U[h][w]+R[h][w]+D[h][w]-3)
 
print(ans)

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

int solve(vi &a, vi &b)
{
    int p = 0;
    rep(i, a.size()) {
        p += (a[i] - b[i]) * (a[i] - b[i]);
    }

    rep(i, p+1) {
        if (i * i == p) {
            return 1;
        }
    }

    return 0;
}

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

    int2(n, d);
    vvi data(n, vi(d));
    rep(i, n) {
        rep(j, d) {
            cin >> data[i][j];
        }
    }

    int ans = 0;
    rep(i, n) {
        for (int j = i+1; j < n; j++) {
            ans += solve(data[i], data[j]);
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(n, m, x int, a [][]int, c []int) int {
        ans := 1 << 31
        for s := 0; s < 1<<uint(n); s++ {
                cost := 0
                d := make([]int, m)
                for i := 0; i < n; i++ {
                        if s>>uint(i)&1 == 1 {
                                cost += c[i]
                                for j := 0; j < m; j++ {
                                        d[j] += a[i][j]
                                }
                        }
                }
                ok := true
                for i := 0; i < m; i++ {
                        if d[i] < x {
                                ok = false
                        }
                }
                if ok {
                        ans = min(ans, cost)
                }
        }
        if ans == 1<<31 {
                return -1
        }
        return ans
}

func min(x, y int) int {
        if x < y {
                return x
        }
        return y
}

func main() {
        var n, m, x int
        fmt.Scan(&n, &m, &x)

        c := make([]int, 0, n)
        a := make([][]int, n)

        for i := 0; i < n; i++ {
                tmp := 0
                fmt.Scan(&tmp)
                c = append(c, tmp)

                a[i] = make([]int, 0, m)
                for j := 0; j < m; j++ {
                        tmp := 0
                        fmt.Scan(&tmp)
                        a[i] = append(a[i], tmp)
                }
        }
        fmt.Println(solution(n, m, x, a, c))
}

Measured memory_bytes: 2220
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}


int main() {
  ll n;
  cin >> n;
  ll m = 100;
  ll y = 0;
  while (m < n) {
    m *= 1.01;
    y++;
  }
  printf("%lld\n", y);
}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<cmath>
#include<string>

using namespace std;

int main(){
    string s,t;

    cin >> s >> t;

    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            cout << "No" << endl; return 0;
        }
    }

    cout << "Yes" << endl;
    

    return 0;
}

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

#define MAX_N 200005

const int mod = 998244353;

int fact[MAX_N] ,invfact[MAX_N];
int modpow(int a ,int p=mod-2){
    int x = 1;
    for( ; p; p>>=1){
        if(p&1)
            x = 1LL*x*a%mod;
        a = 1LL*a*a%mod;
    }
    return x;
}
int nCr(int n ,int r){
    return 1LL*fact[n]*invfact[r]%mod*invfact[n-r]%mod;
}

int main()
{
    fact[0] = 1 ,invfact[0] = 1;
    for(int i=1; i<MAX_N; i++)
        fact[i] = 1LL*fact[i-1]*i%mod ,invfact[i] = modpow(fact[i]);

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

    int ans = 0;
    for(int l=0; l<=k; l++){
        ans += 1LL*nCr(n-1 ,l)*modpow(m-1 ,n-l-1)%mod*m%mod;
        ans %= mod;
    }

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


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

int main(){
  int n;
  int count = 0;                   //条件を満たす組み合わせの数
  scanf("%d", &n);
  int p[n];

  for(int i = 0; i < n; i++)
    cin >> p[i];

  for(int i = 1; i < n - 1; i++){
    if(p[i-1] < p[i] && p[i] < p[i+1] || p[i+1] < p[i] && p[i] < p[i-1])
      count++;
  }

  cout << count << endl;

}

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

int main(void)
{
	int yen = 0;
	scanf("%d", &yen);

	printf("%d", yen / 500 * 1000 + (yen % 500) / 5 * 5);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int a,b;
  cin>>a>>b;
  int c=0;
  int d=1;
  while (d<b){
    --d;
    d+=a;
    ++c;
  }
  cout<<c<<endl;
  
    
  
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int n;
  scanf("%d", &n);
  string s(n, ' ');
  scanf(" %s", &s[0]);
  vector<int> acc_dot(n + 1, 0);
  for (int i = 0; i < n; ++i)
    acc_dot[i + 1] = acc_dot[i] + (s[i] == '.');

  int result = INT_MAX;
  for (int nd = 0; nd <= n; ++nd) {
    int res = (nd - acc_dot[nd]) + (acc_dot[n] - acc_dot[nd]);
    result = min(result, res);
  }
  printf("%d\n", result);

  return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		int intInput = Integer.parseInt(input.replaceAll("/", ""));
		if(intInput > 20190430) {
			System.out.println("TBD");
		}else {
			System.out.println("Heisei");
		}
		sc.close();
	}
}


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

int main()
{
  int n;
  for(;cin>>n,n;)
    { 
      int cnt=0;
      int buf=-1;
      for(int i=0;i<n;i++)
	{
	  int tmp;
	  cin>>tmp;
	  if(cnt<=0)
	    {
	      buf=tmp;
	      cout<<tmp;
	      cnt++;
	    }
	  else if(tmp!=buf+1)
	    {
	      if(cnt>1)
		cout<<"-"<<buf;
	      cout<<" "<<tmp;
	      buf=tmp;
	      cnt=1;
	    }
	  else if(i==n-1)
	    {
	      if(tmp==buf+1)
		cout<<"-";
	      else
		cout<<" ";
	      cout<<tmp;
	    }
	  else if(tmp==buf+1)
	    cnt++;
	  buf=tmp;
	}
      cout<<endl;
    }

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    string S1, S2;
    cin >> S1;
    cin >> S2;

    ll ans;
    int i = 0;
    bool tate = false;
    if(S1[i] == S2[i]){
        ans = 3;
        i++;
        tate = true;
    }
    else{
        ans = 6;
        i += 2;
    }

    while(i < N){
        char up = S1[i]; 
        char lo = S2[i]; 
        if(up == lo){
            if(tate) ans *= 2;
            else ans *= 1;
            tate = true;
            i++;
        }
        else{
            if(tate) ans *= 2;
            else ans *= 3;
            tate = false;
            i += 2;
        }
        ans %= MOD;
    }

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


Measured memory_bytes: 256
N,M = map(int,input().split())
gate = [list(map(int,input().split())) for _ in range(M)]

gate_s = sorted(gate,key=lambda x:x[0])
min_r = 1000000
max_l = 0

for i in range(M):
  if gate_s[i][1] < min_r:
    min_r = gate_s[i][1]
  if gate_s[i][0] > max_l:
    max_l = gate_s[i][0]
if min_r-max_l < 0:
  print(0)
else:
  print(min_r-max_l+1)




Measured memory_bytes: 29812
N = int(input())
A = list(map(int, input().split()))
gcd_list = [0] * N

# 最大公約数
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

#i-1番目までの最大公約数リスト
b = [0] * (N - 1)
b[0] = A[0]
for i in range(1, N - 1):
    b[i] = gcd(b[i - 1], A[i])
#i+1以降の最大公約数リスト
a = [0] * (N - 1)
a[N - 2] = A[N - 1]
for i in reversed(range(0, N - 2)):
    a[i] = gcd(a[i + 1], A[i + 1])

gcd_list[0] = a[0]
gcd_list[N-1] = b[N - 2]
for i in range(1, N - 1):
    gcd_list[i] = gcd(b[i - 1], a[i])

print(max(gcd_list))

Measured memory_bytes: 14584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define M 1000000007

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

	int n;
	cin >> n;
	int arr[n], s=0;
	for(int i=0; i<n; i++){
		cin >> arr[i];
		s += arr[i];
	}

	int ans=0;
	for(int i=0; i<n; i++){
		ans += ((arr[i]%M)*((s-arr[i])%M))%M;
		ans%=M;
	}

	ans = (ans+M)%M;
	ans = (ans*(M+1)/2)%M;

	cout << ans;


	
	

	return 0;
}

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

#define mod 1000000007

#define ll unsigned long long int

ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}

ll sumXOR(ll arr[], int n)
{
    ll sum = 0;

    for (int i = 0; i <64; i++)
    {
         ll zc = 0, oc = 0;

        ll idsum = 0;

        for (int j = 0; j < n; j++)
        {
            if (arr[j] % 2 == 0)
                zc++;
            else
                oc++;
            arr[j] /= 2;
        }


        idsum =(((oc*zc)%mod)*bigmod(2,i))%mod;

        //cout<<idsum<<" ";

        // final sum
        sum = (sum+idsum+mod)%mod;
        //cout<<sum<<endl;
    }
    return sum;
}

int main()
{
    ll sum = 0;

    int n;
    cin>>n;

    ll arr[n+2];

    for(int i=0;i<n;i++)cin>>arr[i];

    sum = sumXOR(arr,n);

    cout << sum<<endl;

    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    using namespace std;
    #define INF 10000000;
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

  
  
    int main(){
      long n,a,b;
      cin >> n >> a >> b;
      long m = b-a-1;
      long res;
      if(m%2 == 1)res = m/2+1;
      if(m%2 == 0){
        long mn = min(a-1,n-b);
        if(m)res = mn+1+m/2;
        else res = mn+1;
      }

      cout <<res<<endl;
    }

    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unistd.h>
#define int long long
const int inf=8938103643641919514ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int a,b,c,d;
int p[100000];
signed main(){
	int i,j;
	cin>>a>>b;
	for(i=0;i<b;i++){
		int u,v;
		cin>>u>>v;
		u--;
		v--;
		p[u]++;
		p[v]++;
	}
	for(i=0;i<a;i++)
		if(p[i]%2!=0){
			cout<<"NO"<<endl;
			return 0;
		}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;

fn main() {
    input! {
        an: usize,
        bn: usize,
        m: usize,
        a: [u64;an],
        b: [u64;bn],
        xym: [(usize, usize,u64);m],
    }

    let mut v = vec![];

    for i in 0..m {
        let t = a[xym[i].0 - 1] + b[xym[i].1 - 1] - xym[i].2;
        v.push(t);
    }

    v.sort();

    let mut a = a;
    let mut b = b;
    a.sort();
    b.sort();

    println!("{}", std::cmp::min(a[0] + b[0], v[0]))
}


Measured memory_bytes: 12540
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>

using namespace std;

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

string solve(int N, int K, const vector<int> &A)
{
	if (*max_element(A.begin(), A.end()) < K) {
		return "IMPOSSIBLE";
	}
	int d = accumulate(A.begin(), A.end(), A[0], gcd);
	if (K % d != 0) {
		return "IMPOSSIBLE";
	}
	return "POSSIBLE";
}

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

	cout << solve(N, K, A) << endl;
}


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

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



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

int main(){
    int n;
    vector <int> aaa(9);
    for(int i = 0; i < 9;i++){
        cin >> aaa.at(i);
    }
    cin >> n;
    vector <int> anses(n);
    for(int i = 0; i < n;i++){
        cin >> anses.at(i);
    }
    for(int i = 0;i < 9;i++){
        for(int j = 0;j < n;j++){
            if(aaa.at(i) == anses.at(j)){
                aaa.at(i) = 1;
            }
        }
    }
    for(int i = 0;1;i++){
        if(aaa.at(0) == 1){
            if(aaa.at(0) == aaa.at(1) == aaa.at(2)){
            cout << "Yes" << endl;
            break;
            }
            if(aaa.at(0) == aaa.at(4) == aaa.at(8)){
            cout << "Yes" << endl;
            break;
            }
            if(aaa.at(0) == aaa.at(3) == aaa.at(6)){
            cout << "Yes" << endl;
            break;
            }
        }
        if(aaa.at(4) == 1){
            if(aaa.at(3) == aaa.at(4) == aaa.at(5)){
                cout << "Yes" << endl;
                break;
            }
        }
        if(aaa.at(8) == 1){
            if(aaa.at(6) == aaa.at(7) == aaa.at(8)){
                cout << "Yes" << endl;
                break;
            }
        }
        if(aaa.at(2) == 1){
            if(aaa.at(2) == aaa.at(4) == aaa.at(6)){
                cout << "Yes" << endl;
                break;
            }
            if(aaa.at(2) == aaa.at(5) == aaa.at(8)){
                cout << "Yes" << endl;
                break;
            }
        }
        cout << "No" << endl;
        break;
        }
    }

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

#define ll long long int
#define ff first
#define ss second
#define MOD 1000000007
#define  N 1000010

ll fac[N], faci[N], inv[N];
void comp()
{
  fac[0] = fac[1] = 1;
  inv[1] = 1;
  faci[0] = faci[1] = 1;
  for(int i = 2; i < N; ++i)
  {
    fac[i] = (i * fac[i - 1]) % MOD;
    inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
    faci[i] = faci[i - 1] * inv[i] % MOD;
  }
}

ll ncr(int n, int r)
{
  ll ans = (fac[n] * faci[r] % MOD) * faci[n - r] % MOD;
  return ans;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);

  int x, y;
  comp();
  cin >> x >> y;

  int sum = x + y;
  int k = sum / 3;
  if(sum % 3)
  {
    cout << 0;
    return 0;
  }
  ll ans = 0;
  
    if(k >= abs(x - y))
    {
      ans = ncr(sum / 3, (k - abs(x - y))/2);
    }
    else
    {
      ans = 0;
    }
    cout << ans;  
  return 0;
}


Measured memory_bytes: 23680
using System;
using System.Linq;

namespace A___XOR_Circle
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver() ? "Yes" : "No");
        }
        static bool solver()
        {
            var N = int.Parse(Console.ReadLine());
            var Ai = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var all0 = true;
            for (int i = 0; i < N; i++)
            {
                if (Ai[i] != 0)
                {
                    all0 = false;
                    break;
                }
            }
            if (all0) return true;

            if (N % 3 != 0) return false;

            var distAi = Ai.Distinct().ToArray();
            if (distAi.Length == 3)
            {
                if (Ai.Count(s => s == distAi[0]) == Ai.Count(s => s == distAi[1]))
                    if (Ai.Count(s => s == distAi[1]) == Ai.Count(s => s == distAi[2]))
                        if ((distAi[0] ^ distAi[1]) == distAi[2])
                            return true;
            }
            if (distAi.Length == 2)
            {
                if (Ai.Count(s => s == 0) == N / 3) return true;
            }

            return false;
        }
    }
}


Measured memory_bytes: 22368
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int N, D;
    cin >> N >> D;
    double res = N;
    res /= (2 * D + 1);
    res = ceil(res);
    int t = res;
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    while(N--) {
        ll a;
        cin >> a;
        ans += K <= a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if (Math.abs(a-c) <= d || (Math.abs(a-b) <= d && Math.abs(b-c) <= d)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define FD(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define pii pair<int,int>
#define reset(x,y) memset(x, y,sizeof(x))
#define MIN(x,y) if (x > (y)) x = (y)
#define MAX(x,y) if (x < (y)) x = (y)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define EL putchar('\n');
#define mod 1000000007
#define oo 1000006
#define INF 0x3f3f3f3f
int read()
{
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
void write(int x)
{
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
ll base=1e9+7;
map<int,int>ok;
int n;
int a[oo];
void ReadInPut()
{
    n=read();
    int ans=0;
    F(i,1,n)
    {
        a[i]=read();
        ans+=ok[i-a[i]];
        ok[i+a[i]]++;
    }
    cout<<ans;
}
void Solve()
{
}
main()
{
//    freopen("t.INP","r",stdin);
  //  freopen(".OUT","w",stdout);
    int sotest=1;
    //cin>>sotest;
    for(int i=1;i<=sotest;i++)
    {
        ReadInPut();
        Solve();
    }
}


Measured memory_bytes: 27728