akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	// 連続した部分文字列がkの長さをもつとすると
	// aa
	// a*a
	// のどちらかしか存在しない。このパターンを使わないということはa**a**q...と繰り返すことになるがこの方法では条件をみたすことはないからである
	// テスト
	// asdfghjklaa : 最後だけ
	// faewasdfala
	// qwertyuioaa
	// aaqwertyuiop:最初
	static String line;

	static int N;
	public static void main(String args[]) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		line = br.readLine();
		String text[] = line.split("");
		N = text.length;
		method(text);
	}

	static void method(String text[]) {

		for (int i = 0; i < text.length - 2; i++) {
			if (text[i].equals(text[i + 2])) {
				i++;
				System.out.println(i + " " + (i + 2));
				return;
			}
		}

		for (int i = 0; i < text.length - 1; i++) {
			if (text[i].equals(text[i + 1])) {
				i++;
				System.out.println(i + " " + (i + 1));
				return;
			}
		}

		System.out.println("-1 -1");
	}
}


Measured memory_bytes: 17236
while True:
    (m, f, r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break

    mf = m + f
    if m == -1 or f == -1 or mf < 30:
        print('F')
    elif mf < 50 and r < 50:
        print('D')
    elif mf < 65:
        print('C')
    elif mf < 80:
        print('B')
    else:
        print('A')

Measured memory_bytes: 6724
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int n;

int main(void)
{
	cin >> n;
	vector<int>p;
	for (int i = 0; i < n; ++i)
	{
		int pp;
		cin >> pp;
		p.push_back(pp);
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if (p[i] == i + 1)
		{
			swap(p[i], p[i + 1]);
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892
import numpy as np
from numba import njit
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

@njit(cache=True)
def pos(W,h,w):
    return h*W+w

def solve(H,W,G):
    N = H*W+W
    INF=10**18

    dp = np.full((N,N),INF)
    for i in range(N):
        dp[i][i] = 0

    for h in range(H):
        for w in range(W):
            if G[h][w]: continue

            for i in range(4):
                dh = [0,1,0,-1][i]
                dw = [1,0,-1,0][i]
                if 0<=h+dh<H and 0<=w+dw<W:
                    if G[h+dh][w+dw]: continue
                    dp[pos(W,h,w)][pos(W,h+dh,w+dw)] = 1
                    dp[pos(W,h+dh,w+dw)][pos(W,h,w)] = 1


    ans = 0
    for k in range(N):
        for i in range(N):
            for j in range(N):
                dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j])


    for i in range(N):
        for j in range(N):
            if dp[i][j] != INF:
                ans = max(ans,dp[i][j])
    

    return ans





def main():
    H,W=mi()
    G = [[0] * W for _ in range(H)]
    for h in range(H):
        S = list(input())
        for w in range(W):
            G[h][w] = S[w] == "#"

    print(solve(H,W,np.array(G,bool)))


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')

    # basic types: https://numba.pydata.org/numba-doc/0.13/types.html
    cc.export('pos', '(i8,i8,i8,)')(pos)
    cc.export('solve', '(i8,i8,b1[:,:],)')(solve)
    cc.compile()

if __name__ == '__main__':
    try:
        from my_module import solve
        from my_module import pos
    except:
        cc_export()
        exit()

    main()

Measured memory_bytes: 93400
*s, = input()

s.append("")
s.insert(0, "")

r = [0]*(len(s))
l = [0]*(len(s))

cnt = 0
for i in range(1, len(s)):
    if s[i] == "L":
        if cnt == 0:
            continue

        if cnt%2 == 0:
            r[i] = cnt//2
            r[i-1] = cnt//2
        else:
            r[i] = cnt//2
            r[i-1] = cnt//2 + 1
        cnt = 0
    else:
        cnt += 1

cnt = 0
for i in range(len(s)-2, 0, -1):
    if s[i] == "R":
        if cnt == 0:
            continue

        if cnt%2 == 0:
            l[i] = cnt//2
            l[i+1] = cnt//2
        else:
            l[i] = cnt//2
            l[i+1] = cnt//2 + 1
        cnt = 0
    else:
        cnt += 1

ans = []
for i in range(1, len(s)-1):
    ans.append(r[i]+l[i])

print(*ans)


Measured memory_bytes: 8628
#include <stdio.h>

int main() {
	int N = 0;
	scanf("%d", &N);
	if (N % 2 == 0) {
		printf("%d\n", (N / 2));
	}
	else {
		printf("%d\n", ((N + 1) / 2));
	}

	return 0;
}

Measured memory_bytes: 128
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,T;
LL A[100000];

LL ans = 0;

void solve(){
	//i<jかつA[i]<A[j]となるようなもののうち、
	//A[i]とA[j]の差が最大になるような(i,j)の個数が答えとなる
	//ただし各組のi,jは相異なっていなければならない
	//{(1,2)(7,10)}とかはいいけど{(1,2),(2,3)}とかダメ
	LL max_value = A[N-1];
	LL max_diff = 0;
	for(int i=N-2;i>=0;i--){
		max_diff = max(max_diff,max_value - A[i]);
		max_value = max(max_value,A[i]);
		//cout << max_diff <<" " <<max_value << endl;
	}

	max_value = A[N-1];
	LL max_index = N-1;
	vector<int> used(N,0);
	for(int i=N-2;i>=0;i--){
		if(max_value-A[i]==max_diff){
			if(used[i]==0 && used[max_index]==0){
				ans++;
				used[i] = 1;
				used[max_index] = 1;
			}
		}
		if(max_value<A[i]){
			max_value = A[i];
			max_index = i;
		}
	}
}
 
int main(){
    cin >> N >> T;
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

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

Measured memory_bytes: 1408
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
q = int(input())
lr = [list(map(int,input().split())) for _ in range(q)]
b = [0]*(h*w+1)
for i in range(h):
  for j in range(w):
    b[a[i][j]] = (i,j)
c = [0]*(h*w+1)
for i in range(d+1,h*w+1):
  c[i] = c[i-d] + abs(b[i][0]-b[i-d][0])+abs(b[i][1]-b[i-d][1])
for l,r in lr:
  print(c[r]-c[l])

Measured memory_bytes: 41328
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double
#define md 1000000007

lin n,x;
lin s[201];
lin mt[201];
map<lin, lin> cch; 

lin mult(lin xx, lin yy)
{
    return xx * yy % md;
}

lin add(lin xx, lin yy)
{
    return (xx + yy) % md;
}

lin get_key(lin xx, int nn)
{
    return xx + nn * 200000;
}

lin solve(lin xx, int nn)
{
    lin key = get_key(xx, nn);
    if(cch.count(key) != 0)
    {
        //cout << " HIT " << endl;
        return cch[key];
    }

    if(nn == 1)
        return xx % s[0];

    lin res1 = solve(xx % s[nn - 1], nn - 1);
    lin res21 = solve(xx, nn - 1);
    lin res22 = nn - 1;
    lin res2 = mult(res21, res22);

    lin res = add(
        res1, res2
    );

    //cout << xx << "," << nn << " : " <<  res1 << " + " << res21 << " * " << res22 << " = " << res << endl;

    cch[key] = res;

    return res;
}

int main(void)
{
    cin >> n >> x;
    rep(i,n)
    {
        cin >> s[i];
    }

    sort(s, s+n);

    mt[0] = 1;
    rep(i, n - 1)
    {
        mt[i+1] = mult(mt[i], i + 1);
    }

    lin res = solve(x, n);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 56832
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;

ll N;
string A, B, C;

void input() {
    cin >> N >> A >> B >> C;
}

ll solve() {
    ll ans = 0;
    for (size_t i = 0; i < N; i++) {
        auto a = A[i], b = B[i], c = C[i];
        ll sum = 0;
        sum += a == b;
        sum += b == c;
        sum += c == a;
        if (sum == 0) {
            ans += 2;
        } else if (sum == 1) {
            ans += 1;
        }
    }
    return ans;
}


int main() {
    input();
    cout << solve() << endl;
    
    return 0;
}



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

typedef long long ll;
typedef pair <int , int> pii;

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , k;
   cin >> n >> k;
   int a[n];
   for(int i = 0 ; i < n ; i++)
      cin >> a[i];
   sort(a , a + n);
   ll ans = 0;
   for(int i = 0 ; i < k ; i++)
      ans += a[i];
   cout << ans;
   return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int K,S,ans,z;

int main(){
    cin>>K>>S;
    rep(i,K+1){
        rep(j,K+1){
           z=S-i-j;
           if(z>=0&&z<=K)ans++; 
        }
    }
    out(ans);
}


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

int main()
{
    const static int64_t zero64 = 0;
    int64_t A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if (A > B) {
        swap(A, B);
        swap(X, Y);
    }
    int64_t min_cost = A * X + B * Y;
    if (2 * C <= A)
        min_cost = 2 * C * max(X, Y);
    else if (2 * C <= B)
        min_cost = 2 * C * Y + A * max(zero64, X - Y);
    else if (2 * C <= A + B) {
        min_cost = 2 * C * min(X, Y);
        min_cost += A * max(zero64, X - Y) + B * max(zero64, Y - X);
    }
    cout << min_cost << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n; cin>>n;
    vector<int> h(n);
    for(int i=0; i<n; i++) cin>>h[i];

    int bh=0, ans=0;
    for(int i=0; i<n; i++){
        if(bh <= h[i]){
            ans++;
            bh = h[i];
        }
    }

    cout << ans << endl;
}

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

#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()

#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846264338327950L
#define MOD 1000000007

 
int32_t main(){

    
     IOS
	int h,a,ans=0;
	cin>>h>>a;

	if(h>a&&(h%a)!=0)
	{
		ans=(h/a)+1;
	}
	else if(h>a&&(h%a)==0)
	{
		ans=h/a;
	}
	else
	{
		ans=1;
	}
	cout<<ans;
	return 0;
}




Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())
atoz = [chr(i) for i in range(97,97+26)]

N = inp()
S = input()
ans = 0
for i in range(1,N):
	x = S[:i]
	y = S[i:]
	tmp = 0
	for s in atoz:
		if s in x and s in y:
			tmp += 1
	ans = max(tmp,ans)

print(ans)


Measured memory_bytes: 4328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);
    for(int i = 0; i < N; i++){
        cin >> x.at(i) >> y.at(i) >> h.at(i);
    }
    for(int Cx = 0; Cx <= 100; Cx++){
        bool check1 = false;
        for(int Cy = 0; Cy <= 100; Cy++){
            int H;
            for(int i = 0; i < N; i++){
                if(h.at(i) != 0){
                    H = abs(x.at(i) - Cx) + abs(y.at(i) - Cy) + h.at(i);
                    break;
                }
            }
            bool check2 = true;
            for(int i = 0; i < N; i++){
                if(max(H - abs(x.at(i) - Cx) - abs(y.at(i) - Cy), 0) != h.at(i)){
                    check2 = false;
                    break;
                }
            }
            if(check2){
                cout << Cx << " " << Cy << " " << H << endl;
                check1 = true;
                break;
            }
        }
        if(check1){
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3604
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
 
const long long MOD = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;
 
#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//mint
struct mint {
   //this library is created by snuke.
  ll x; // typedef long long ll;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

#define MAX_N 200010
ll n;
ll c[MAX_N];
mint dp[MAX_N];
mint rightsum[MAX_N];

//dpテーブルの更新
void cal(int i){
   if(c[i] == c[i+1]) dp[i] = 0;
   else{
      dp[i] = rightsum[c[i]];
      rightsum[c[i+1]] += dp[i];
   }
   //cout << "dp[i] = " << dp[i].x << endl;
}

void solve(){
    dp[0] = 1; rightsum[c[0]] = rightsum[c[1]] = 1;
   for(int i = 1;i < n;i++){
      cal(i);
   }
   cout << dp[n-1].x << endl;
}

int main(void){
   cin >> n;
   rep(i,n)cin >> c[i];
   solve();
   return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i;
	string s,t;
	cin >> n;
	cin >> s >> t;
	for(i=0; i<n; ++i){
		cout << s[i] << t[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


char s[1010];
char t[1010];
int szS;
int szT;

int main()
{
	scanf("%s\n", s);
	scanf("%s\n", t);
	szS = strlen(s);
	szT = strlen(t);
	
	int minChange = -1;
	for (int i = 0 ; i <= szS - szT ; i++) {
		int curChange = 0;
		for (int j = 0 ; j < szT ; j++) {
			if (t[j] != s[i + j])
				curChange++;
		}
		
		if ((minChange == -1) || (minChange > curChange)) {
			minChange = curChange;
		}
	}
	
	
	printf("%d\n", minChange);

	return 0;
}




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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    if(s[0]=='o')cnt++;
    if(s[1]=='o')cnt++;
    if(s[2]=='o')cnt++;
    cout << 700+cnt*100 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*
import java.util.*

const val ANSMAX = 1000000000001L
fun solve(N: Int, K: Long, A: LongArray, F: LongArray) {
    A.sort()
    F.sortDescending()
    val times = (0 until N).map { A[it] * F[it] }
    fun canAchive(x: Long): Boolean {
        val neededCost = times
            .withIndex()
            .filter { it.value > x }
            .map { (it.value - x).divCeil(F[it.index]) }
            .sum()
        return neededCost <= K
    }
    binarySearch(0L to ANSMAX) { canAchive(it) }.let { println(it) }
    return
}

fun Long.divCeil(n: Long) = this / n + if (this % n == 0L) 0 else 1L

fun binarySearch(range: Pair<Long, Long>, f: (Long) -> Boolean): Long {
    // f(x) == if(x < y) false else true となるyを求める
    var (low, high) = range
    while (low < high) {
        val mid = (low + high) / 2
        if (f(mid)) {
            high = mid
        } else {
            low = mid + 1
        }
    }
    return high
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val K = sc.next().toLong()
    val A = LongArray(N)
    for (i in 0 until N) {
        A[i] = sc.next().toLong()
    }
    val F = LongArray(N)
    for (i in 0 until N) {
        F[i] = sc.next().toLong()
    }
    solve(N, K, A, F)
}


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

int main(){
  int r,g,b;
  cin >> r >> g >>b;
  int num = 10*g +b;
  if (num %4 == 0){
    cout << "YES" <<endl;
  }
  else{
      cout << "NO" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
tmp=a[0]
up=0
check=0
stock=0
n=1000
for i in range(N-1):
    if i==0:
        if a[i]<=a[i+1]:
            check=1
            stock=n//a[i]
            n-=stock*a[0]
        else:
            check=2
    else:
        if check==1:
            if a[i]<=a[i+1]:
                pass
            else:
                check=2
                n+=stock*a[i]
                stock=0
        elif check==2:
            if a[i]<=a[i+1]:
                check=1
                stock=n//a[i]
                n-=stock*a[i]
    #print(n,stock,check)
if check==1:
    n+=stock*a[-1]
print(n)

Measured memory_bytes: 9224
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long int ll;

using namespace std;

// n!の計算関数
ll facctorialMethod(ll k) {
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}


int main() {
	int N;
	cin >> N;
	int x[10];
	int y[10];
	rep(i, N) {
		cin >> x[i] >> y[i];
	}

	vector<int> v(N);
	iota(v.begin(), v.end(), 0);       // v に 0,1, 2, ... N-1 を設定(初めに大きさを初期化しておく必要あり)

	double sum = 0; 

	do {
		rep(i, N-1) {
			double temp = sqrt((x[v.at(i)] - x[v.at(i+1)])*(x[v.at(i)] - x[v.at(i+1)]) + (y[v.at(i)] - y[v.at(i+1)])*(y[v.at(i)] - y[v.at(i+1)]));
			sum += temp;
		}
	} while (next_permutation(v.begin(), v.end()));


	printf("%.11lf\n", sum/facctorialMethod(N));


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,ans;
bool ok;
int main(){
    cin>>a>>b>>c;
    for(int i=0;i<=1000000;i++){
        ans=a*i;
        if(ans%b==c){
            cout<<"YES"<<endl;
            ok=1;
            break;
        }
    }
    if (ok==0) cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Long num;
	public static void main(String[] args) {


		try (Scanner sc = new Scanner(System.in)) {
			Long a = Long.parseLong(sc.next());
			Long b = Long.parseLong(sc.next());
			Long c = Long.parseLong(sc.next());
			Long d = Long.parseLong(sc.next());
			
			
			num = a*c;
			num = Math.max(num,a*d);
			num = Math.max(num,b*c);
			num = Math.max(num,b*d);
			Long anser = num;
			System.out.println(anser);
		}
	}		
}

Measured memory_bytes: 35604
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    val cap = LongArray(5) { readLine()!!.toLong() }
    val bn = cap.min()!!
    var total = n / bn + 4
    if (n % bn != 0L) {
        total++
    }
    println(total)
}


Measured memory_bytes: 34148
#include <bits/stdc++.h>
#define N 200002
#define P 1000000007
using namespace std;
int n,f[N],lst[N];
int main(){
    scanf("%d",&n);
    f[0]=1;
    for(int i=1,x;i<=n;++i){
        scanf("%d",&x);
        f[i]=f[i-1];
        if(lst[x] && lst[x]+1<i){
            f[i]+=f[lst[x]];
            if(f[i]>=P)f[i]-=P;
        }
        lst[x]=i;
    }
    printf("%d",f[n]);
}


Measured memory_bytes: 1792
X,K,D=map(int, input().split())
if abs(X)>=K*D:
  print(abs(X)-K*D)
else:
  a=(abs(X))//D
  A=abs(abs(X)-a*D)
  B=abs(abs(X)-a*D-D)
  if (K-a)%2==0:
    print(A)
  else:
    print(B)

Measured memory_bytes: 9184
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
int main(){
    int C;
    double rad,a,b,c,c2,S,A,L,h;
    cin >> a >> b >> C;
    double PI = acos(-1);
    scanf("%d", &C);
    rad = C * PI / 180;
    S = sin(rad)*a*b/2;
    c2 = a*a+b*b-2*a*b*cos(rad);
    c = sqrt(c2);
    L = a+b+c;
    h = 2*S/a;
    
    printf("%8f\n",S);
    printf("%8f\n",L);
    printf("%8f\n",h);
    
}



Measured memory_bytes: 3588
fun main(args: Array<String>?): Unit {
    val prime = primes(999983)
    while(true) {
        val n = readLine()!!.trim().toInt()
        if (n == 0) break
        var result = 0L
        repeat(n){
            val (p, m) = readLine()!!.trim().split(' ').map(String::toInt)
            result += prime.upperBound(p + m) - prime.lowerBound(p - m) - 1
        }
        println(maxOf(0, result))
    }
}
fun primes(upperLimit: Int): List<Int> {
    val isPrime = BooleanArray(upperLimit + 1){true}
    for (i in 2 .. upperLimit) {
        if (i * i > upperLimit) break
        if (isPrime[i]) for (j in i * i .. upperLimit step i){
            isPrime[j] = false
        }
    }
    return (2 .. upperLimit).filter(isPrime::get)
}
fun <T: Comparable<T>> List<T>.lowerBound(value: T): Int {
    var from = 0
    var until = size
    while (from < until){
        val mid = (from + until) / 2
        if (this[mid] < value) from = mid + 1
        else until = mid
    }
    return until
}
fun <T: Comparable<T>> List<T>.upperBound(value: T): Int {
    var from = 0
    var until = size
    while (from < until) {
        val mid = (from + until) / 2
        if (this[mid] <= value) from = mid + 1
        else until = mid
    }
    return until
}


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

#define INF 2000000000
using namespace std;

long long cost[300][300];
long long answer[300][300];
int main() {
    int N, M;
    long long L;
    int A[100000], B[100000];
    long long C[100000];
    int Q;
    int s[100000], t[100000];

    cin >> N >> M >> L;
    for (int i=0; i<M; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }
    cin >> Q;
    for (int i=0; i<Q; i++) {
        int tmps, tmpt;
        cin >> tmps >> tmpt;
        s[i] = tmps-1;
        t[i] = tmpt-1;
    }
    

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            cost[i][j] = INF;
        }
    }
    for (int i=0; i<M; i++) {
        cost[A[i]-1][B[i]-1] = C[i];
        cost[B[i]-1][A[i]-1] = C[i];
    }
    
    for (int i=0; i<N; i++) {
        vector<long long> times(N, INF);
        vector<long long> fuel(N);
        vector<int> used(N);

        times[i] = 0;
        fuel[i] = L;
        while(1) {
            int v = -1;
            for (int u=0; u<N; u++) {
                if (used[u]==0 && (v == -1 || (times[u]<times[v] || (times[u]==times[v] && fuel[u] > fuel[v])))) v = u;
            }
            if (v == -1) break;
            used[v] = 1;
            for (int u=0; u<N; u++) { // v to u
                if (cost[v][u] > L) continue;
                long long newtimes = times[v];
                long long newfuel = fuel[v] - cost[v][u];
                if (cost[v][u] > fuel[v]) {
                    newtimes = times[v] + 1;
                    newfuel = L - cost[v][u];
                }
                if (times[u] == newtimes) {
                    fuel[u] = max(newfuel, fuel[u]);
                } else if (times[u] > newtimes) {
                    times[u] = newtimes;
                    fuel[u] = newfuel;
                }
            }
            // cerr << "############" << endl;
            // cerr << "v:" << v+1 << endl;
            // cerr << "times" << endl;
            // for (int i=0; i<N; i++) {
            //     cerr << i+1 << ":" << times[i] << endl;
            // }
            // cerr << "fuel" << endl;
            // for (int i=0; i<N; i++) {
            //     cerr << i+1 << ":" << fuel[i] << endl;
            // }
        }
        for (int j=0; j<N; j++) {
            if (i == j) answer[i][j] = 0;
            else {
                if (times[j] == INF) answer[i][j] = -1;
                else answer[i][j] = times[j];
            }
        }
    }

    for (int q=0; q<Q; q++) {
        cout << answer[s[q]][t[q]] << endl;
    }
    return 0;
}



Measured memory_bytes: 3968
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a;
		for(int i=1;;i++){
			a = sc.nextInt();
			if(a==0)break;
			System.out.println("Case "+i+": "+a);
		}
	}

}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int[] w = new int [n];
			for (int i = 0; i < n; i++) {
				w[i] = cin.Int();
			}

			int min = w.Sum();
			for (int i = 0; i < n; i++) {
				int sum1 = w.Where((x, c) => c <= i).Sum();
				int sum2 = w.Where((x, c) => c > i).Sum();
				min = Math.Min(min, Math.Abs(sum1 - sum2));
			}

			Console.WriteLine(min);
		}
	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


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

using ll = long long;

int main() {
    ll k, a, b; cin >> k >> a >> b;

    if(k < a + 1 || a >= b) {
        cout << k + 1 << endl;
    } else {
        const ll tk = k;
        ll ans = b;
        k -= a + 1;
        ans += (b - a) * (k / 2);
        if(k & 1) {
            ans += 1;
        }
        ans = max(ans, tk + 1);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
N = raw_input()
counter = 0
num_array = []
max_data = 0
second_max = 0
while counter < int(N):
  num_array.append(int(raw_input()))
  if(num_array[counter] > max_data):
    max_data = num_array[counter]
  elif(num_array[counter] > second_max):
    second_max = num_array[counter]
  counter += 1
counter = 0  
while counter < int(N):
  if(num_array[counter] != max_data):
    print max_data
  else:
    print second_max
  counter += 1 
 

Measured memory_bytes: 10372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//HG
#define INF (int)pow(10,5)
int min_cost(vector<int> &arr, int i)
{
//     if( i >= arr.size())
//         return INF;
//     if(i == arr.size() - 1)
//         return 0;
//     int a = INF,b = INF;
//     if(i+1 < arr.size())
//         a = abs(arr[i+1] - arr[i]) + min_cost(arr, i+1);
//     if(i+2 < arr.size())
//         b = abs(arr[i+2] - arr[i]) + min_cost(arr, i+2);
    int n = arr.size();
    int dp[n];
    memset(dp, 0 ,sizeof(dp));
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    //dp[2] = min(abs(arr[1] - arr[0]), abs(arr[2] - arr[0])) ;
    for(int i = 2; i < n; i++)
    {
        int a = abs(arr[i] - arr[i-1]) + dp[i-1];
        int b = abs(arr[i] - arr[i-2]) + dp[i-2];
        dp[i] = min(a,b);
    }
    return dp[n-1];
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    //cout << INF;
    cout << min_cost(arr, 0);
	return 0;
}

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

int gcd(int x, int y) {
  return y ? gcd(y, x%y) : x;
}

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

    sort(A.begin(),A.end());

    long long int g = A[0];

    for(int i=1;i<N;i++){
        g = gcd(g,A[i]);
    }

    if(A[N-1] < K){
        cout << "IMPOSSIBLE" << endl;
    }else{
        for(int i=0;i<N;i++){
            if(A[i]==K){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }

        if(K%g==0){
            cout << "POSSIBLE" << endl;
        }else{
            cout << "IMPOSSIBLE" << endl;
        }
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

long long gcd(long long x){ 

  long long ans, i;

  for( i = 1; i <= sqrt(x); i++ ){
    if( x % i == 0 ) ans = i;
  }
  return ans;
}

int main() {

  long long a[10010], N;
  long long ans, count = 0;

  cin >> N;

  REP(i, N){
    cin >> a[i];
    ans = gcd(a[i]);
    if( ans == 1 ){
      count++;
    }
  }

  cout << count << endl;

}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3100
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int, input().split()))for i in range(n)]
cnt = 0
for i in range(n):
  total = 0
  for j in range(m):
    total += B[j] * A[i][j]
  total += c
  if total > 0:
    cnt += 1
print(cnt)

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

namespace ABC062_A_Grouping
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int x = int.Parse(input[0]);
			int y = int.Parse(input[1]);
			int[] groupA = {1, 3, 5, 7, 8, 10, 12};
			int[] groupB = {4, 6, 9, 11};

			

			if (x == 2 && y == 2)
			{
				Console.WriteLine("Yes");
				return;
			}else if (groupA.Any(value => x == value))
			{
				if (groupA.Any(value => y == value))
				{
					Console.WriteLine("Yes");
					return;
				}
			}else if (groupB.Any(value => x == value))
			{
				if (groupB.Any(value => y == value))
				{
					Console.WriteLine("Yes");
					return;
				}
			}
			
			Console.WriteLine("No");
		}
	}
}

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

string S; int N, cnt;

int main() {
	cin >> N >> S;
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
			if (S[j] == ('0' + c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int a[3];
	for(int i=0;i<3;i++) cin>>a[i];
	sort(a,a+3);
	if( (a[2]==a[1] || a[1]==a[0]) && a[2]!=a[0] ) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, c[200010];
ll mod = 1e9+7;

ll p(ll a, ll b) {
    if (b < 0) return 0;
    if (b == 0) return 1LL;
    if (b == 1) return a;
    ll ret = p(a, b/2);
    ret *= ret;
    ret %= mod;
    if (b&1) ret *= a;
    return ret % mod;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(c,c+n);
    reverse(c,c+n);
    ll base = p(2LL,n-1);
    ll inc = p(2LL, n-2);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += c[i] * base % mod;
        ans %= mod;
        base += inc;
        base %= mod;
    }
    cout << ans * p(2LL, n) % mod << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
    int i, a, b;
    
    for(i = 1;; i++){

	scanf("%d %d", &a, &b);
	if(a == 0 && b == 0)
	    break;
	if(a > b) printf("%d %d\n", b, a);
	else printf("%d %d\n", a, b);
    }

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int dp[101][4][4][4];

int main(){
	dp[0][3][3][3] = 1;
	int n;cin>>n;
	rep(len,n){
		rep(i,4){
			rep(j,4){
				rep(k,4){
					if(dp[len][i][j][k]==0)continue;
					rep(a,4){
						if(j==0 && k==1 && a==2)continue;
						if(j==0 && k==2 && a==1)continue;
						if(j==1 && k==0 && a==2)continue;
						if(i==0 && k==1 && a==2)continue;
						if(i==0 && j==1 && a==2)continue;

						dp[len+1][j][k][a] += dp[len][i][j][k];
						dp[len+1][j][k][a] %= MOD;
					}
				}
			}
		}
	}
	int ans = 0;
		rep(i,4){
			rep(j,4){
				rep(k,4){
					ans += dp[n][i][j][k];
					ans %= MOD;
				}
			}
		}
		cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

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

func main() {
	sc.Split(bufio.ScanWords)
	s, t := next(), next()
	sTable := make([]int, 26)
	tTable := make([]int, 26)
	for i := 0; i < len(s); i++ {
		sTable[s[i]-'a']++
	}
	for i := 0; i < len(t); i++ {
		tTable[t[i]-'a']++
	}

	si, ti := 0, 25
	for si <= ti {
		for si < 26 && sTable[si] == 0 {
			si++
		}
		for ti >= 0 && tTable[ti] == 0 {
			ti--
		}
		if si == 26 {
			fmt.Println("Yes")
			return
		}
		if ti == -1 {
			fmt.Println("No")
			return
		}
		if si < ti {
			fmt.Println("Yes")
			return
		}
		if si == ti && sTable[si] == tTable[ti] {
			fmt.Println("No")
			return
		}
		sTable[si]--
		tTable[ti]--
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
import math
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

# https://qiita.com/hamko/items/794a92c456164dcc04ad
def binary_search(a, k):
    ng = 0 # left:絶対に達成不可能なもの
    ok = max(a) # right:絶対に達成可能なもの
    while (ok - ng > 1):
        mid = (ng + ok) // 2
        if sum([math.ceil(a[i]/mid)-1 for i in range(n)]) <= k:
            ok = mid
        else:
            ng = mid
    return ok
print(binary_search(a, k))

Measured memory_bytes: 30984
#include <bits/stdc++.h>
 
#define int long long
 
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999999
 
using namespace std;

int gcd(int x, int y){
    if(x<y){
        int t=x;
        x=y;
        y=t;
    }

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

int32_t main(){
    int n, k;
    cin >> n >> k;

    int a[n], maxi=-1;
    REP(i, n){
        cin >> a[i];
        maxi=max(maxi, a[i]);
    }
    
    int g=a[0];
    FOR(i, 1, n){
        g=gcd(g, a[i]);
    }

    if(k<=maxi && !(k%g)){
        cout << "POSSIBLE" << endl;
        return 0;
    }

    cout << "IMPOSSIBLE" << endl;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N){

    lli sum = 0;
    REP(i,1,N+1){
        if( i%3 != 0 &&i %5 != 0)sum+=i;
    }

    cout<<sum<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    func(N);
    return 0;
}


Measured memory_bytes: 3764
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
# UnionFind
class UnionFind():
    def __init__(self, n):
        self.nodes=[-1] * n  # nodes[x]: 負なら、絶対値が木の要素数

    def get_root(self, x):
        # nodes[x]が負ならxが根
        if self.nodes[x] < 0:
            return x
        # 根に直接つなぎ直しつつ、親を再帰的に探す
        else:
            self.nodes[x]=self.get_root(self.nodes[x])
            return self.nodes[x]

    def unite(self, x, y):
        root_x=self.get_root(x)
        root_y=self.get_root(y)
        # 根が同じなら変わらない
        # if root_x == root_y:
        # pass
        if root_x != root_y:
            # 大きい木の方につないだほうが計算量が減る
            if self.nodes[root_x] < self.nodes[root_y]:
                big_root=root_x
                small_root=root_y
            else:
                small_root=root_x
                big_root=root_y
            self.nodes[big_root] += self.nodes[small_root]
            self.nodes[small_root]=big_root

def main():
    N,M = MI()

    """
    全員が誰かと言語で話せて、それが連結ならOK
    """
    uf=UnionFind(N+M)
    get_root, unite, nodes=uf.get_root, uf.unite, uf.nodes

    for i in range(N):
        _,*L = MI_()
        for l in L:
            unite(l+N, i)
    
    r = get_root(0)
    for i in range(N):
        if r!=get_root(i):
            print("NO")
            return

    print("YES")

if __name__ == '__main__':
    main()

Measured memory_bytes: 89048
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){

    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    
    int k = 1;
    int count = 0;
    bool can = false;
    for(int i=1;i<=N;i++){
        count++;
        if(a[k-1]==2) {
            can = true;
            break;
        }
        k = a[k-1];
    }
    
    if(can)cout << count;
    if(!can) cout << "-1";
}

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

using namespace std;

int main(){
    int h,w;
    
    while(1){
        cin >> h >> w;
        if(h==0&&w==0){
            break;
        }
        for(int i=0;i<h;i++){
            if(i==0||i==h-1){
                for(int j=0;j<w;j++){
                    cout << "#";
                }
                cout << endl;
                continue;
            }
            for(int j=0;j<w;j++){
                if(j==0||j==w-1){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
readline = open(0).readline
while 1:
    N, M = map(int, readline().split())
    if N == M == 0:
        break
    Q = []
    for i in range(N):
        d, p = map(int, readline().split())
        Q.append((p, d))
    Q.sort(reverse=1)
    ans = 0
    for p, d in Q:
        if M >= 0:
            x = min(M, d)
            M -= x; d -= x
        ans += d * p
    print(ans)


Measured memory_bytes: 6640
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 1000005
using namespace std;
typedef long long ll;
const int mod=998244353;
int n,m;
ll fac[N],inv[N];
ll quick_pow(ll a,ll b){
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}
ll C(int n,int m){
	if(n<m) return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	scanf("%d%d",&n,&m);
	if(m<n) return puts("0"),0;
	fac[0]=inv[0]=1;
	for(int i=1;i<=1000002;i++) fac[i]=fac[i-1]*i%mod;
	inv[1000002]=quick_pow(fac[1000002],mod-2);
	for(int i=1000001;i;i--) inv[i]=inv[i+1]*(i+1)%mod;
	ll ans=0;
	for(int i=1;i<=m;i++) if(i>=m-i&&i>=n-1){
		if(i==m-i){
			ans=(ans+C(m-1,i)-C(m-1,n-2))%mod;
			continue;
		}
		int T=i-n+1;
		ans=(ans+C(m,i)-C(m,i+T))%mod;
	}
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

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

using namespace std;
using std::vector;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

ll  atcoder = 998244353;

ll calc(ll n, ll k){
  ll sum = 1;

  for(int i = 1; i <= n; i++){
    sum *= i;
    if(sum % k == 0){
      sum /= k; 
      k--;
    }
  }
  if(k != 0){
    while(k){
      sum /= k;
     k--;
    }
  }
  return sum;
}

int main(){
 
  int a, b, c; cin >> a >> b >> c;

  if((c >= a and b >= c) or (c <= a and b <= c))
    pr("Yes");
  else
    pr("No");

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter

def main():
    n, x, y = map(int, input().split())

    def count():
        for i in range(1, n+1):
            for j in range(i+1, n+1):
                yield min(abs(j-i), abs(x-i)+1+abs(j-y))

    c = Counter(count())
    for i in range(1, n):
        print(c[i] if i in c else 0)


main()

Measured memory_bytes: 3956
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

K = len(bin(np.max(A))) - 2

ans = 0
mod = 10 ** 9 + 7
N %= mod

for i in range(K):
    bit = np.count_nonzero(A >> i & 1) % mod
    ans += pow(2, i, mod) * bit * (N - bit)
    ans %= mod
    
print(ans)

Measured memory_bytes: 48844